AI: Refactor bounce handling
authorWuzzy <Wuzzy2@mail.ru>
Sat, 06 Jun 2020 20:51:12 +0200
changeset 15602 583080b0272b
parent 15601 30ad3fd974f1
child 15603 ac44dae6425e
AI: Refactor bounce handling
hedgewars/uAI.pas
hedgewars/uAIAmmoTests.pas
--- a/hedgewars/uAI.pas	Sat Jun 06 20:22:57 2020 +0200
+++ b/hedgewars/uAI.pas	Sat Jun 06 20:51:12 2020 +0200
@@ -180,11 +180,10 @@
                     if (Ammoz[a].Ammo.Propz and ammoprop_Timerable) <> 0 then
                         AddAction(BestActions, aia_Timer, ap.Time div 1000, 400, 0, 0);
 
-                    // Set minimum mine bounciness for improved aim
-                    if (BotLevel < 5) and (a = amMine) then
+                    if ((Ammoz[a].Ammo.Propz and ammoprop_SetBounce) > 0) and (ap.Bounce > 0) then
                         begin
                         AddAction(BestActions, aia_Precise, aim_push, 10, 0, 0);
-                        AddAction(BestActions, aia_Timer, 1, 200, 0, 0);
+                        AddAction(BestActions, aia_Timer, ap.Bounce, 200, 0, 0);
                         AddAction(BestActions, aia_Precise, aim_release, 10, 0, 0);
                         end;
 
--- a/hedgewars/uAIAmmoTests.pas	Sat Jun 06 20:22:57 2020 +0200
+++ b/hedgewars/uAIAmmoTests.pas	Sat Jun 06 20:51:12 2020 +0200
@@ -30,7 +30,7 @@
 var windSpeed: real;
 
 type TAttackParams = record
-        Time, AttacksNum: Longword;
+        Time, Bounce, AttacksNum: Longword;
         Angle, Power: LongInt;
         ExplX, ExplY, ExplR: LongInt;
         AttackPutX, AttackPutY: LongInt;
@@ -548,6 +548,7 @@
 begin
 valueResult:= BadTurn;
 TestTime:= 0;
+ap.Bounce:= 0;
 ap.ExplR:= 0;
 meX:= hwFloat2Float(Me^.X);
 meY:= hwFloat2Float(Me^.Y);
@@ -612,6 +613,7 @@
 Flags:= Flags; // avoid compiler hint
 valueResult:= BadTurn;
 TestTime:= 500;
+ap.Bounce:= 0;
 ap.ExplR:= 0;
 meX:= hwFloat2Float(Me^.X);
 meY:= hwFloat2Float(Me^.Y);
@@ -1508,6 +1510,11 @@
     ap.Angle:= 0;
     ap.Power:= 1;
     ap.Time:= 0;
+    if (Level < 5) then
+        // Set minimum mine bounciness for improved aim
+        ap.Bounce:= 1
+    else
+        ap.Bounce:= 0;
     ap.ExplR:= 100;
     ap.ExplX:= EX;
     ap.ExplY:= EY