more tweakery
authornemo
Sun, 18 Jan 2015 16:01:09 -0500
changeset 10800 3c71e5158519
parent 10799 658794118fd8
child 10801 50bc2c75eee7
more tweakery
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsList.pas
hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sun Jan 18 15:12:54 2015 -0500
+++ b/hedgewars/uGearsHandlersMess.pas	Sun Jan 18 16:01:09 2015 -0500
@@ -1761,14 +1761,15 @@
 procedure doStepAirMine(Gear: PGear);
 var i,t,targDist,tmpDist: LongWord;
     targ, tmpG: PGear;
-    trackSpeed, tX, tY: hwFloat;
+    trackSpeed, airFriction, tX, tY: hwFloat;
 begin
-    if Gear^.dX.QWordValue > Gear^.Pos then
-         dec(Gear^.dX.QWordValue,Gear^.Pos)
-    else Gear^.dX:= _0;
-    if Gear^.dY.QWordValue > Gear^.Pos then
-         dec(Gear^.dY.QWordValue,Gear^.Pos)
-    else Gear^.dY:= _0;
+    if Gear^.Pos > 0 then
+        begin
+        airFriction:= _1;
+        dec(airFriction.QWordValue,Gear^.Pos);
+        Gear^.dX:= Gear^.dX*airFriction;
+        Gear^.dY:= Gear^.dY*airFriction
+        end;
     doStepFallingGear(Gear);
     if (Gear^.Angle = 0) or (Gear^.Hedgehog = nil) or (Gear^.Hedgehog^.Gear = nil) then
         begin
@@ -1777,6 +1778,16 @@
         end
     else if Gear^.Hedgehog <> nil then
         targ:= Gear^.Hedgehog^.Gear;
+    if targ <> nil then
+        begin
+        tX:=Gear^.X-targ^.X;
+        tY:=Gear^.Y-targ^.Y;
+        // allow escaping - should maybe flag this too
+        if ((tX.Round+tY.Round > Gear^.Angle*4) and
+            (hwRound(hwSqr(tX) + hwSqr(tY)) > sqr(Gear^.Angle*4))) then
+            targ:= nil
+        end;
+
     // todo, allow not finding new target, set timeout on target retention
     if (Gear^.State and (gsttmpFlag or gstAttacking) =  gsttmpFlag) and
        (Gear^.Angle > 0) and ((GameTicks and $FF) = 17) and
@@ -1821,7 +1832,8 @@
              Gear^.dY:= Gear^.dY+trackSpeed
         else if (Gear^.Y > targ^.Y) and (Gear^.dY > -_0_1) then
             Gear^.dY:= Gear^.dY-trackSpeed;
-        end;
+        end
+    else Gear^.Hedgehog:= nil;
 
     if ((Gear^.State and gsttmpFlag) <> 0) and (Gear^.Health <> 0) then
         begin
--- a/hedgewars/uGearsList.pas	Sun Jan 18 15:12:54 2015 -0500
+++ b/hedgewars/uGearsList.pas	Sun Jan 18 16:01:09 2015 -0500
@@ -370,8 +370,8 @@
                 gear^.Friction:= _0_995;
                 gear^.Density:= _1;
                 gear^.Angle:= 175; // Radius at which air bombs will start "seeking". $FFFFFFFF = unlimited. check is skipped.
-                gear^.Power:= cGravity.QWordValue div 2; // hwFloat converted. 1/2 g default. defines the "seek" speed when a gear is in range.
-                gear^.Pos:= 134217; // air friction. slows it down when not hitting stuff
+                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; // air friction. slows it down when not hitting stuff
                 gear^.Karma:= 30; // damage
                 gear^.Timer:= 500;
                 gear^.WDTimer:= 500;
--- a/hedgewars/uGearsRender.pas	Sun Jan 18 15:12:54 2015 -0500
+++ b/hedgewars/uGearsRender.pas	Sun Jan 18 16:01:09 2015 -0500
@@ -1120,7 +1120,9 @@
                        DrawSpriteRotated(sprMineOn, x, y, 0, Gear^.DirAngle)
                     else DrawSpriteRotated(sprMineDead, x, y, 0, Gear^.DirAngle);
                     end;
-         gtAirMine: DrawSprite(sprAirMine, x-16, y-16, (RealTicks div 125) mod 16);
+         gtAirMine: if (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) then
+                         DrawSprite(sprAirMine, x-16, y-16, (RealTicks div 25) mod 16)
+                    else DrawSprite(sprAirMine, x-16, y-16, (RealTicks div 125) mod 16);
 
            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)