AI: Teach AI that piano can't blast thru solid land
authorWuzzy <Wuzzy2@mail.ru>
Sun, 05 Jul 2020 21:14:44 +0200
changeset 15679 b64f96d43f1f
parent 15678 e933b1dc302d
child 15680 3224d0d970ac
AI: Teach AI that piano can't blast thru solid land
hedgewars/uAIAmmoTests.pas
--- a/hedgewars/uAIAmmoTests.pas	Sun Jul 05 21:05:35 2020 +0200
+++ b/hedgewars/uAIAmmoTests.pas	Sun Jul 05 21:14:44 2020 +0200
@@ -1808,7 +1808,7 @@
 var X, Y: real;
     dmg: array[0..BOUNCES-1] of LongInt;
     i, e, rate, valueResult, targetY: LongInt;
-    firstHit: boolean;
+    firstHit, solidBounce: boolean;
 begin
 Flags:= Flags; // avoid compiler hint
 ap.ExplR:= 0;
@@ -1831,14 +1831,20 @@
 
 i:= 1;
 firstHit:= false;
+solidBounce:= false;
 repeat
     // Piano goes down
-    Y:= Y + 11;
-    if TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(X), trunc(Y), 32) then
+    if (not solidBounce) then
+        Y:= Y + 11;
+    if solidBounce or TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(X), trunc(Y), 32) then
         begin
         if (not firstHit) then
             targetY:= trunc(Y);
         firstHit:= true;
+        if (GameFlags and gfSolidLand) <> 0 then
+            // Don't change Y when indestructible land was hit
+            solidBounce:= true;
+
         for e:= -1 to 1 do
             begin
             rate:= RateExplosion(Me, trunc(X) + 30*e, trunc(Y)+40, 161, afIgnoreMe);
@@ -1849,8 +1855,9 @@
         if (i > 1) and (dmg[i] > 0) then
             dmg[i]:= dmg[i] div 2;
         inc(i);
-        // Skip past the blast hole
-        Y:= Y + 41
+        if (not solidBounce) then
+            // Skip past the blast hole
+            Y:= Y + 41
         end;
 until (i > BOUNCES) or (Y > cWaterLine);