Teach AI to set minimum mine bounce for improved aiming
authorWuzzy <Wuzzy2@mail.ru>
Sat, 06 Jun 2020 20:22:57 +0200
changeset 15624 30ad3fd974f1
parent 15623 7d3877231b00
child 15625 583080b0272b
Teach AI to set minimum mine bounce for improved aiming
hedgewars/uAI.pas
hedgewars/uAIActions.pas
--- a/hedgewars/uAI.pas	Sat Jun 06 20:21:08 2020 +0200
+++ b/hedgewars/uAI.pas	Sat Jun 06 20:22:57 2020 +0200
@@ -180,6 +180,14 @@
                     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
+                        begin
+                        AddAction(BestActions, aia_Precise, aim_push, 10, 0, 0);
+                        AddAction(BestActions, aia_Timer, 1, 200, 0, 0);
+                        AddAction(BestActions, aia_Precise, aim_release, 10, 0, 0);
+                        end;
+
                     if (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0 then
                         begin
                         dAngle:= LongInt(Me^.Angle) - Abs(ap.Angle);
--- a/hedgewars/uAIActions.pas	Sat Jun 06 20:21:08 2020 +0200
+++ b/hedgewars/uAIActions.pas	Sat Jun 06 20:22:57 2020 +0200
@@ -31,6 +31,7 @@
     aia_Up         = 5;
     aia_Down       = 6;
     aia_Switch     = 7;
+    aia_Precise    = 8;
 
     aia_Weapon     = $8000;
     aia_WaitXL     = $8001;
@@ -73,7 +74,7 @@
 var PrevX: LongInt = 0;
     timedelta: Longword = 0;
 
-const ActionIdToStr: array[0..7] of string[16] = (
+const ActionIdToStr: array[0..8] of string[16] = (
 {aia_none}           '',
 {aia_Left}           'left',
 {aia_Right}          'right',
@@ -81,7 +82,8 @@
 {aia_attack}         'attack',
 {aia_Up}             'up',
 {aia_Down}           'down',
-{aia_Switch}         'switch'
+{aia_Switch}         'switch',
+{aia_Precise}        'precise'
                      );
 
 {$IFDEF TRACEAIACTIONS}