Make the various mine states a bit clearer (inactive, active but not in seek mode, seek mode, chasing target)
authornemo
Sat, 24 Jan 2015 13:49:57 -0500 (2015-01-24)
changeset 10807 66cde98f8cbe
parent 10806 02ef8815ec9d
child 10808 1e39630d7c2e
Make the various mine states a bit clearer (inactive, active but not in seek mode, seek mode, chasing target)
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsHandlersMess.pas	Wed Jan 21 16:00:08 2015 -0500
+++ b/hedgewars/uGearsHandlersMess.pas	Sat Jan 24 13:49:57 2015 -0500
@@ -1792,12 +1792,21 @@
             targ:= nil
         end;
 
+    // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility)
+    // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0
+    // then we aren't hunting
+    if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or 
+        ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or
+        (Gear^.State and gsttmpFlag = 0) or
+        (Gear^.Angle = 0) then
+        gear^.State:= gear^.State and not gstHHChooseTarget
+    else if
     // todo, allow not finding new target, set timeout on target retention
-    if (ReadyTimeLeft = 0) and (TurnTimeLeft > 0) and ((TurnTimeLeft > cHedgehogTurnTime) or (cHedgehogTurnTime-TurnTimeLeft > 5000)) and
-       (Gear^.State and (gsttmpFlag or gstAttacking) =  gsttmpFlag) and
-       (Gear^.Angle > 0) and ((GameTicks and $FF) = 17) and
-       (GameTicks > Gear^.FlightTime) then // recheck hunted hog
-        begin
+        (Gear^.State and gstAttacking = 0) and
+        ((GameTicks and $FF) = 17) and
+        (GameTicks > Gear^.FlightTime) then // recheck hunted hog
+        begin
+        gear^.State:= gear^.State or gstHHChooseTarget;
         if targ <> nil then
              targDist:= Distance(Gear^.X-targ^.X,Gear^.Y-targ^.Y).Round
         else targDist:= 0;
--- a/hedgewars/uGearsRender.pas	Wed Jan 21 16:00:08 2015 -0500
+++ b/hedgewars/uGearsRender.pas	Sat Jan 24 13:49:57 2015 -0500
@@ -1120,9 +1120,18 @@
                        DrawSpriteRotated(sprMineOn, x, y, 0, Gear^.DirAngle)
                     else DrawSpriteRotated(sprMineDead, x, y, 0, Gear^.DirAngle);
                     end;
-         gtAirMine: if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
+         gtAirMine: if Gear^.State and gstTmpFlag = 0 then                // mine is inactive
+                        begin
+                        Tint(150,150,150,255);
+                        DrawSprite(sprAirMine, x-16, y-16, 15);
+                        untint
+                        end
+                    else if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then  // mine is chasing a hog
                          DrawSprite(sprAirMine, x-16, y-16, (RealTicks div 25) mod 16)
-                    else DrawSprite(sprAirMine, x-16, y-16, (RealTicks div 125) mod 16);
+                    else if Gear^.State and gstHHChooseTarget <> 0 then   // mine is seeking for hogs
+                         DrawSprite(sprAirMine, x-16, y-16, (RealTicks div 125) mod 16)
+                    else
+                         DrawSprite(sprAirMine, x-16, y-16, 4);           // mine is active but not seeking
 
            gtSMine: if (((Gear^.State and gstAttacking) = 0)or((Gear^.Timer and $3FF) < 420)) and (Gear^.Health <> 0) then
                            DrawSpriteRotated(sprSMineOff, x, y, 0, Gear^.DirAngle)