forked from Mirrors/openclonk
clonk now turns automatically during UseHold. No need for that in the singe weapons anymore
parent
780240bef3
commit
ab7a8aac5c
|
@ -103,15 +103,7 @@ public func ControlUseHolding(object clonk, int x, int y)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Turn clonk if aiming in the other direction and he isn't moving
|
||||
if(!ClonkAimLimit(clonk,angle))
|
||||
if(clonk->GetComDir() == COMD_Stop && !clonk->GetXDir())
|
||||
{
|
||||
if(clonk->GetDir() == 1 && angle < 0) clonk->SetDir(0);
|
||||
else if(clonk->GetDir() == 0 && angle > 0) clonk->SetDir(1);
|
||||
}
|
||||
if(Abs(angle) > 160) angle = 160;
|
||||
|
||||
// Adjust the aiming position
|
||||
var pos = clonk->GetAnimationPosition(iAnimLoad);
|
||||
pos += BoundBy(2000*Abs(angle)/180-pos, -100, 100);
|
||||
|
|
|
@ -61,12 +61,6 @@ public func ControlUseHolding(object clonk, int x, int y)
|
|||
|
||||
clonk->SetAnimationWeight(iAimKnot, Anim_Const(Abs(angle)*1000/180));
|
||||
|
||||
// Turn clonk if aiming in the other direction and he isn't moving
|
||||
if(clonk->GetComDir() == COMD_Stop && !clonk->GetXDir())
|
||||
{
|
||||
if(clonk->GetDir() == 1 && angle < 0) clonk->SetDir(0);
|
||||
else if(clonk->GetDir() == 0 && angle > 0) clonk->SetDir(1);
|
||||
}
|
||||
}
|
||||
|
||||
protected func ControlUseStop(object clonk, int x, int y)
|
||||
|
|
|
@ -70,11 +70,7 @@ protected func ControlUseHolding(object pClonk, int ix, int iy)
|
|||
var iPos = pClonk->GetAnimationPosition(iAim);
|
||||
iPos += BoundBy(iTargetPosition-iPos, -50, 50);
|
||||
pClonk->SetAnimationPosition(iAim, Anim_Const(iPos));
|
||||
if( (pClonk->GetComDir() == COMD_Stop && !pClonk->GetXDir()) || pClonk->GetAction() == "Jump")
|
||||
{
|
||||
if(pClonk->GetDir() == 1 && angle < 0) pClonk->SetDir(0);
|
||||
else if(pClonk->GetDir() == 0 && angle > 0) pClonk->SetDir(1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -139,11 +139,6 @@ func ControlUseHolding(object pClonk, ix, iy)
|
|||
var iPos = pClonk->GetAnimationPosition(iAim);
|
||||
iPos += BoundBy(iTargetPosition-iPos, -50, 50);
|
||||
pClonk->SetAnimationPosition(iAim, Anim_Const(iPos));
|
||||
if( (pClonk->GetComDir() == COMD_Stop && !pClonk->GetXDir()) || pClonk->GetAction() == "Jump")
|
||||
{
|
||||
if(pClonk->GetDir() == 1 && angle < 0) pClonk->SetDir(0);
|
||||
else if(pClonk->GetDir() == 0 && angle > 0) pClonk->SetDir(1);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -84,20 +84,6 @@ private func UpdatePosition()
|
|||
var x = +Sin(angle,CURSOR_Radius,10);
|
||||
var y = -Cos(angle,CURSOR_Radius,10);
|
||||
|
||||
if((crew->GetComDir() == COMD_Stop && crew->GetXDir() == 0) || crew->GetProcedure() == "FLIGHT")
|
||||
{
|
||||
if(crew->GetDir() == DIR_Left)
|
||||
{
|
||||
if(x > 0)
|
||||
crew->SetDir(DIR_Right);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(x < 0)
|
||||
crew->SetDir(DIR_Left);
|
||||
}
|
||||
}
|
||||
|
||||
SetPosition(crew->GetX()+x,crew->GetY()+y);
|
||||
crew->UpdateVirtualCursorPos();
|
||||
}
|
||||
|
|
|
@ -673,6 +673,39 @@ private func HoldingUseControl(int ctrl, control, int x, int y, object obj)
|
|||
}
|
||||
|
||||
//Message("%d,%d",this,mex,mey);
|
||||
|
||||
// automatic adjustment of the position
|
||||
// --------------------
|
||||
// if this is desired for ALL objects is the question, we will find out.
|
||||
// For now, this is done for items and vehicles, not for buildings and
|
||||
// mounts (naturally). If turning vehicles just liket hat without issuing
|
||||
// a turning animation is the question. But after all, the clonk can turn
|
||||
// by setting the dir too.
|
||||
|
||||
|
||||
// not riding and not in building
|
||||
if (GetProcedure() != "ATTACH" && !Contained())
|
||||
{
|
||||
// pushing vehicle: object to turn is the vehicle
|
||||
var dir_obj = GetActionTarget();
|
||||
|
||||
// otherwise, turn the clonk
|
||||
if(!dir_obj) dir_obj = this;
|
||||
|
||||
if ((dir_obj->GetComDir() == COMD_Stop && dir_obj->GetXDir() == 0) || dir_obj->GetProcedure() == "FLIGHT")
|
||||
{
|
||||
if (dir_obj->GetDir() == DIR_Left)
|
||||
{
|
||||
if (mex > 0)
|
||||
dir_obj->SetDir(DIR_Right);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mex < 0)
|
||||
dir_obj->SetDir(DIR_Left);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var handled = obj->Call(Format("~%sUse%sHolding",control,estr),this,mex,mey);
|
||||
|
||||
|
|
Loading…
Reference in New Issue