Force locations for hogs if even TryHard fails on initial spawn.
authornemo
Thu, 31 Dec 2015 12:47:33 -0500
changeset 11482 e425a6eb9da3
parent 11481 c4e1d39acc56
child 11483 8c95d5a4366c
Force locations for hogs if even TryHard fails on initial spawn.
hedgewars/hwengine.pas
hedgewars/uGears.pas
hedgewars/uGearsUtils.pas
hedgewars/uVariables.pas
--- a/hedgewars/hwengine.pas	Thu Dec 31 10:17:15 2015 -0500
+++ b/hedgewars/hwengine.pas	Thu Dec 31 12:47:33 2015 -0500
@@ -80,9 +80,9 @@
                 AddClouds;
             AddFlakes;
             SetRandomSeed(cSeed, false);
+            StoreLoad(false);
             AssignHHCoords;
             AddMiscGears;
-            StoreLoad(false);
             InitWorld;
             ResetKbd;
             if GameType = gmtSave then
--- a/hedgewars/uGears.pas	Thu Dec 31 10:17:15 2015 -0500
+++ b/hedgewars/uGears.pas	Thu Dec 31 12:47:33 2015 -0500
@@ -770,7 +770,8 @@
                                 end;
         t:= LAND_WIDTH div 2
         end
-    end else // mix hedgehogs
+    end 
+else // mix hedgehogs
     begin
     Count:= 0;
     for p:= 0 to Pred(TeamsCount) do
@@ -799,7 +800,21 @@
         ar[i]:= ar[Count - 1];
         dec(Count)
         end
-    end
+    end;
+for p:= 0 to Pred(TeamsCount) do
+    with TeamsArray[p]^ do
+        for i:= 0 to cMaxHHIndex do
+            with Hedgehogs[i] do
+                if (Gear <> nil) and (Gear^.State and gsttmpFlag <> 0) then
+                    begin
+                    DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50);
+                    ForcePlaceOnLand(hwRound(Gear^.X) - SpritesData[sprTargetBee].Width div 2, 
+                                     hwRound(Gear^.Y) - SpritesData[sprTargetBee].Height div 2, 
+                                     sprTargetBee, 0, lfBasic, $FFFFFFFF, false, false, false);
+                    Gear^.Y:= int2hwFloat(hwRound(Gear^.Y) - 16 - Gear^.Radius);
+                    Gear^.State:= Gear^.State and not gsttmpFlag;
+                    AddFileLog('Carved a hole for hog at coordinates (' + inttostr(hwRound(Gear^.X)) + ',' + inttostr(hwRound(Gear^.Y)) + ')')
+                    end
 end;
 
 
--- a/hedgewars/uGearsUtils.pas	Thu Dec 31 10:17:15 2015 -0500
+++ b/hedgewars/uGearsUtils.pas	Thu Dec 31 12:47:33 2015 -0500
@@ -927,13 +927,42 @@
         AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')');
         end
     end
-    else
+else
     begin
     OutError('Can''t find place for Gear', false);
     if Gear^.Kind = gtHedgehog then
-        Gear^.Hedgehog^.Effects[heResurrectable] := 0;
-    DeleteGear(Gear);
-    Gear:= nil
+        begin
+        cnt:= 0;
+        if GameTicks = 0 then
+            begin
+            //AddFileLog('Trying to make a hole');
+            while (cnt < 1000) do
+                begin
+                inc(cnt);
+                x:= leftX+GetRandom(rightX-leftX-16)+8;
+                y:= topY+GetRandom(LAND_HEIGHT-topY-16)+8;
+                if NoGearsToAvoid(x, y, 100, 100) then
+                    begin
+                    Gear^.State:= Gear^.State or gsttmpFlag;
+                    Gear^.X:= int2hwFloat(x);
+                    Gear^.Y:= int2hwFloat(y);
+                    AddFileLog('Picked a spot for hog at coordinates (' + inttostr(hwRound(Gear^.X)) + ',' + inttostr(hwRound(Gear^.Y)) + ')');
+                    cnt:= 2000
+                    end
+                end;
+            end;
+        if cnt < 2000 then
+            begin
+            Gear^.Hedgehog^.Effects[heResurrectable] := 0;
+            DeleteGear(Gear);
+            Gear:= nil
+            end
+        end
+    else
+        begin
+        DeleteGear(Gear);
+        Gear:= nil
+        end
     end
 end;
 
--- a/hedgewars/uVariables.pas	Thu Dec 31 10:17:15 2015 -0500
+++ b/hedgewars/uVariables.pas	Thu Dec 31 12:47:33 2015 -0500
@@ -623,7 +623,7 @@
             (FileName:  'Egg'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
             Width:  16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprEgg
             (FileName:  'TargetBee'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-            Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprTargetBee
+            Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: true; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprTargetBee
             (FileName:  'amBee'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil;
             Width:  128; Height: 128; imageWidth: 0; imageHeight: 0; saveSurf: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprHandBee
             (FileName:  'Feather'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;