From c115f25d8d9f22f5bfd062438d77c11f2301776f Mon Sep 17 00:00:00 2001 From: Maikel de Vries Date: Mon, 7 Sep 2015 22:33:45 +0200 Subject: [PATCH] correctly adjust balloon speed --- .../Balloon.ocd/BalloonDeployed.ocd/Script.c | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/planet/Objects.ocd/Items.ocd/Tools.ocd/Balloon.ocd/BalloonDeployed.ocd/Script.c b/planet/Objects.ocd/Items.ocd/Tools.ocd/Balloon.ocd/BalloonDeployed.ocd/Script.c index 76bd51bbf..3baac87d4 100644 --- a/planet/Objects.ocd/Items.ocd/Tools.ocd/Balloon.ocd/BalloonDeployed.ocd/Script.c +++ b/planet/Objects.ocd/Items.ocd/Tools.ocd/Balloon.ocd/BalloonDeployed.ocd/Script.c @@ -36,7 +36,6 @@ private func Deflate() SetAction("Deflate"); SetComDir(COMD_None); } - //Schedule(this, "Pack()", 20); //EndCall doesn't work. >:( } private func DeflateEffect() @@ -90,13 +89,25 @@ public func ControlJump() public func FxControlFloatTimer(object target, proplist effect, int time) { var speed = 7; + // Normalize vertical speed. if (GetYDir() > speed) SetYDir(GetYDir() - 1); if (GetYDir() < speed) SetYDir(GetYDir() + 1); - if (GetXDir() > speed * 3) SetXDir(GetXDir() - 1); - if (GetXDir() < -speed * 3) SetXDir(GetXDir() + 1); - - // Forward the control direction into movement. - SetXDir(GetXDir() + effect.control_dir); + + // Adjust horizontal speed, according to control and max speed. + var xdir = GetXDir(); + var xdir_dev = effect.control_dir; + if (xdir > speed * 3) + xdir_dev = -1; + else if (xdir < -speed * 3) + xdir_dev = 1; + else if (xdir_dev == 0) + { + if (xdir > 0) + xdir_dev = -1; + if (xdir < 0) + xdir_dev = 1; + } + SetXDir(xdir + xdir_dev); // Has a bottom vertex hit? Is the balloon stuck in material? Then deflate. if (GetContact(-1) & CNAT_Bottom || Stuck())