stun airmines on shove
authoralfadur
Tue, 13 Nov 2018 01:56:42 +0300
changeset 14205 1bdce164eb72
parent 14204 3c36a4e66c82
child 14206 abf4d12a59b1
stun airmines on shove
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
hedgewars/uGearsRender.pas
hedgewars/uGearsUtils.pas
share/hedgewars/Data/Graphics/AirMine.png
--- a/hedgewars/uGearsHandlersMess.pas	Mon Nov 12 20:30:06 2018 +0300
+++ b/hedgewars/uGearsHandlersMess.pas	Tue Nov 13 01:56:42 2018 +0300
@@ -2090,6 +2090,16 @@
     if (TurnTimeLeft = 0) and ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) > _0_02.QWordValue) then
         AllInactive := false;
 
+    //Disable targeting while the airmine is stunned
+    if Gear^.Tag <> 0 then
+        begin
+        Gear^.Hedgehog:= nil;
+        dec(Gear^.FlightTime);
+        if Gear^.FlightTime = 0 then
+            Gear^.Tag:= 0;
+        exit
+        end;
+
     if (TurnTimeLeft = 0) or (Gear^.Angle = 0) or (Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.Gear = nil) then
         begin
         Gear^.Hedgehog:= nil;
--- a/hedgewars/uGearsList.pas	Mon Nov 12 20:30:06 2018 +0300
+++ b/hedgewars/uGearsList.pas	Tue Nov 13 01:56:42 2018 +0300
@@ -447,6 +447,7 @@
                 gear^.Angle:= 175; // Radius at which air bombs will start "seeking". $FFFFFFFF = unlimited. check is skipped.
                 gear^.Power:= cMaxWindSpeed.QWordValue div 2; // hwFloat converted. 1/2 g default. defines the "seek" speed when a gear is in range.
                 gear^.Pos:= cMaxWindSpeed.QWordValue * 3 div 2; // air friction. slows it down when not hitting stuff
+                gear^.Tag:= 0;
                 if gear^.Timer = 0 then
                     begin
                     if cMinesTime < 0 then
--- a/hedgewars/uGearsRender.pas	Mon Nov 12 20:30:06 2018 +0300
+++ b/hedgewars/uGearsRender.pas	Tue Nov 13 01:56:42 2018 +0300
@@ -1339,6 +1339,8 @@
          gtAirMine: 
 					if (Gear^.State and gstFrozen <> 0) then 
                         DrawSprite(sprFrozenAirMine, x-16, y-16, 15)
+          else if (Gear^.Tag <> 0) then
+                        DrawSprite(sprAirMine, x-16, y-16, 16 + ((RealTicks div 50 + Gear^.Uid) mod 16))
 					else if (Gear^.State and gstTmpFlag = 0) then                // mine is inactive
                         begin
 						if (Gear^.State and gstTmpFlag = 0) then Tint(150,150,150,255);
--- a/hedgewars/uGearsUtils.pas	Mon Nov 12 20:30:06 2018 +0300
+++ b/hedgewars/uGearsUtils.pas	Tue Nov 13 01:56:42 2018 +0300
@@ -1242,7 +1242,13 @@
                         t^.State:= t^.State or gstMoving;
                         if t^.Kind = gtKnife then t^.State:= t^.State and (not gstCollision);
                         t^.Active:= true;
-                        FollowGear:= t
+                        FollowGear:= t;
+
+                        if t^.Kind = gtAirmine then
+                        begin
+                            t^.Tag:= 1;
+                            t^.FlightTime:= 5000;
+                        end
                         end
                     end;
             gtGrave: begin
@@ -1388,7 +1394,13 @@
                                 State:= ord(sprStar)
                                 end
                         end;
-                ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove)
+                ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg, dsShove);
+
+                if Gear^.Kind = gtAirmine then
+                    begin
+                        Gear^.Tag:= 1;
+                        Gear^.FlightTime:= 5000;
+                    end
                 end
             else
                 Gear^.State:= Gear^.State or gstWinner;
Binary file share/hedgewars/Data/Graphics/AirMine.png has changed