# HG changeset patch
# User Wuzzy <Wuzzy2@mail.ru>
# Date 1591469472 -7200
# Node ID 583080b0272b0b37edcc69dd6fe0de5e7e83441c
# Parent  30ad3fd974f1780a489c7283f4a3818a4dafcc02
AI: Refactor bounce handling

diff -r 30ad3fd974f1 -r 583080b0272b hedgewars/uAI.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;
 
diff -r 30ad3fd974f1 -r 583080b0272b hedgewars/uAIAmmoTests.pas
--- 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