Finish cake implementation
authorunc0rr
Sun, 27 Jul 2008 14:05:17 +0000
changeset 1110 3660bbfc1cba
parent 1109 87c44c14fdd4
child 1111 25d0ca2e4a7d
Finish cake implementation
hedgewars/GSHandlers.inc
hedgewars/uGears.pas
--- a/hedgewars/GSHandlers.inc	Sun Jul 27 13:44:04 2008 +0000
+++ b/hedgewars/GSHandlers.inc	Sun Jul 27 14:05:17 2008 +0000
@@ -1483,11 +1483,24 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 const cakeh = 27;
+      cakeDmg = 75;
 var CakePoints: array[0..Pred(cakeh)] of record x, y: hwFloat; end;
 	CakeI: Longword;
 
+procedure doStepCakeExpl(Gear: PGear);
+begin
+inc(Gear^.Tag);
+if Gear^.Tag < 2250 then exit;
+
+doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cakeDmg, EXPLAutoSound);
+AfterAttack;
+DeleteGear(Gear)
+end;
+
 procedure doStepCakeDown(Gear: PGear);
 var i: Longword;
+    gi: PGear;
+    dmg: LongInt;
 begin
 AllInactive:= false;
 
@@ -1497,9 +1510,15 @@
 
 if Gear^.Pos = 0 then
 	begin
-	doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 75, EXPLAutoSound);
-	AfterAttack;
-	DeleteGear(Gear)
+	gi:= GearsList;
+	while gi <> nil do
+		begin
+		dmg:= cakeDmg * 2 - hwRound(Distance(gi^.X - Gear^.X, gi^.Y - Gear^.Y));
+		if (dmg > 1) and (gi^.Kind = gtHedgehog) then
+			gi^.State:= gi^.State or gstWinner;
+		gi:= gi^.NextGear
+		end;
+	Gear^.doStep:= @doStepCakeExpl;
 	end else dec(Gear^.Pos)
 end;
 
--- a/hedgewars/uGears.pas	Sun Jul 27 13:44:04 2008 +0000
+++ b/hedgewars/uGears.pas	Sun Jul 27 14:05:17 2008 +0000
@@ -1102,7 +1102,7 @@
                              DeleteCI(Gear);
                              Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
                              Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
-                             Gear^.State:= Gear^.State or gstMoving;
+                             Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
                              Gear^.Active:= true;
                              FollowGear:= Gear
                              end;