Catapult and cannon: Add functions to rotate instantly.

Useful for scenario designers.
liquid_container
Sven Eberhardt 2016-02-06 22:45:14 -05:00
parent 439b1f481c
commit 775533a8da
2 changed files with 23 additions and 4 deletions

View File

@ -214,15 +214,25 @@ func ControlRight(object clonk)
}
}
func TurnCannon(int dir)
public func TurnCannon(int dir, bool instant)
{
turnDir = dir;
//Remove any old effect
if(GetEffect("IntTurnCannon", this)) RemoveEffect("IntTurnCannon", this);
//Add a new one
return AddEffect("IntTurnCannon", this, 1, 1, this);
// Instant turn?
if (instant)
{
// Simply set anim position to desired side
var target = 0;
if (dir == DIR_Left) target = GetAnimationLength("TurnRight");
SetAnimationPosition(animTurn, Anim_Const(target));
}
else
{
// Non-instant turn: Add timer to adjust animation (I wonder why it's not just using Anim_Linear?)
return AddEffect("IntTurnCannon", this, 1, 1, this);
}
}
func FxIntTurnCannonTimer(object cannon, proplist effect, int timer)
{

View File

@ -77,6 +77,15 @@ func ControlRight(object clonk)
}
}
public func TurnLeft()
{
// Instantly set catapult orientation to face left
var len = GetAnimationLength("TurnLeft");
turn_anim = PlayAnimation("TurnLeft", 5, Anim_Linear(len, 0, len, 1, ANIM_Hold));
dir = olddir = DIR_Left;
return true;
}
public func HoldingEnabled() { return true; }
public func ControlUseStart(object clonk)