rc plane falls down when looses control
authorunc0rr
Sun, 18 Jan 2009 13:01:49 +0000
changeset 1696 bb1e305320a1
parent 1695 028e1a1a86e0
child 1697 ea3eddd73f2c
rc plane falls down when looses control
hedgewars/GSHandlers.inc
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Sun Jan 18 12:46:24 2009 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Jan 18 13:01:49 2009 +0000
@@ -1948,6 +1948,7 @@
 Gear^.doStep:= @doStepBallgunWork
 end;
 
+////////////////////////////////////////////////////////////////////////////////
 procedure doStepRCPlaneWork(Gear: PGear);
 const cAngleSpeed = 3;
 var HHGear: PGear;
@@ -1959,22 +1960,31 @@
 begin
 AllInactive:= false;
 
-dec(Gear^.Timer);
+if Gear^.Timer > 0 then dec(Gear^.Timer);
 
 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
 FollowGear:= Gear;
 
 fChanged:= false;
-if ((Gear^.Message and gm_Left) <> 0) then
+if ((HHGear^.State and gstHHDriven) = 0) or (Gear^.Timer = 0) then
 	begin
 	fChanged:= true;
-	Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096
-	end;
+	if Gear^.Angle > 2048 then dec(Gear^.Angle) else
+		if Gear^.Angle < 2048 then inc(Gear^.Angle) else fChanged:= false
+	end
+else
+	begin
+	if ((Gear^.Message and gm_Left) <> 0) then
+		begin
+		fChanged:= true;
+		Gear^.Angle:= (Gear^.Angle + (4096 - cAngleSpeed)) mod 4096
+		end;
 
-if ((Gear^.Message and gm_Right) <> 0) then
-	begin
-	fChanged:= true;
-	Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096
+	if ((Gear^.Message and gm_Right) <> 0) then
+		begin
+		fChanged:= true;
+		Gear^.Angle:= (Gear^.Angle + cAngleSpeed) mod 4096
+		end
 	end;
 
 if fChanged then
@@ -1989,14 +1999,16 @@
 	Gear^.dY:= AngleCos(trueAngle) * -_0_25;
 	end;
 
-
 Gear^.X:= Gear^.X + Gear^.dX;
 Gear^.Y:= Gear^.Y + Gear^.dY;
 
 if (GameTicks and $FF) = 0 then
-	AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
+	if Gear^.Timer < 2500 then
+		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0)
+	else
+		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
 
-if ((HHGear^.Message and gm_Attack) <> 0)and(Gear^.Health <> 0) then
+if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then
 	begin
 	HHGear^.Message := HHGear^.Message and not gm_Attack;
 	AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
@@ -2010,7 +2022,7 @@
 
 CheckCollision(Gear);
 
-if ((Gear^.State and gstCollision) <> 0) or (Gear^.Timer = 0) then
+if ((Gear^.State and gstCollision) <> 0) then
 	begin
 	HHGear^.Message:= 0;
 	//HHGear^.State:= HHGear^.State and (not gstNotKickable);
@@ -2037,6 +2049,7 @@
 HHGear^.Message:= 0;
 HHGear^.State:= HHGear^.State or gstNotKickable;
 Gear^.Angle:= HHGear^.Angle;
+Gear^.Tag:= hwSign(HHGear^.dX);
 if HHGear^.dX.isNegative then Gear^.Angle:= 4096 - Gear^.Angle;
 Gear^.doStep:= @doStepRCPlaneWork
 end;
\ No newline at end of file
--- a/hedgewars/uGears.pas	Sun Jan 18 12:46:24 2009 +0000
+++ b/hedgewars/uGears.pas	Sun Jan 18 13:01:49 2009 +0000
@@ -1062,7 +1062,7 @@
 	case Gear^.Kind of
        gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
 
-       gtRCPlane: if (PHedgehog(Gear^.Hedgehog)^.Gear^.dX.isNegative) then
+       gtRCPlane: if (Gear^.Tag = -1) then
                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1,  DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
                   else
                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX));