"Teach" AI hogs to be inaccurate with guns (and kamikaze)
authorWuzzy <Wuzzy2@mail.ru>
Tue, 09 Jun 2020 05:51:39 +0200
changeset 15614 250c778463f3
parent 15613 d9c62f196fe0
child 15615 5a949495ee29
"Teach" AI hogs to be inaccurate with guns (and kamikaze)
ChangeLog.txt
hedgewars/uAIAmmoTests.pas
--- a/ChangeLog.txt	Mon Jun 08 23:37:38 2020 +0200
+++ b/ChangeLog.txt	Tue Jun 09 05:51:39 2020 +0200
@@ -15,6 +15,7 @@
  +   - use drill strike, piano strike, air mine
  +   - use mine strike (0 seconds only)
  +   - use RC plane (very basic)
+ + Low level computer players are more inaccurate with guns
  * Racer: Resize waypoints in custom-sized drawn maps
  * Mutant: Fix impossible to become mutant after mutant is gone
  * A Classic Fairytale: Mission 1: Fix possibility of getting stuck in “Leap of Faith” section
--- a/hedgewars/uAIAmmoTests.pas	Mon Jun 08 23:37:38 2020 +0200
+++ b/hedgewars/uAIAmmoTests.pas	Tue Jun 09 05:51:39 2020 +0200
@@ -482,6 +482,10 @@
             (((ap.Angle < 0) and (windSpeed > 0)) or ((ap.Angle > 0) and (windSpeed < 0))) then
             exit(BadTurn);
 
+        // Apply inaccuracy
+        if (not cLaserSighting) then
+            inc(ap.Angle, + AIrndSign(random((Level - 1) * 9)));
+
         if (valueResult <= 0) then
             valueResult:= BadTurn;
         exit(valueResult)
@@ -936,6 +940,9 @@
 Vx:= (Targ.Point.X - x) * 1 / 1024;
 Vy:= (Targ.Point.Y - y) * 1 / 1024;
 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
+// Apply inaccuracy
+if (not cLaserSighting) then
+    inc(ap.Angle, + AIrndSign(random((Level - 1) * 10)));
 repeat
     x:= x + vX;
     y:= y + vY;
@@ -990,6 +997,9 @@
 Vx:= (Targ.Point.X - x) * t;
 Vy:= (Targ.Point.Y - y) * t;
 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
+// Apply inaccuracy
+if (not cLaserSighting) then
+    inc(ap.Angle, + AIrndSign(random((Level - 1) * 10)));
 d:= 0;
 
 ix:= trunc(x);
@@ -1044,6 +1054,9 @@
 Vx:= (Targ.Point.X - x) * t;
 Vy:= (Targ.Point.Y - y) * t;
 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy);
+// Apply inaccuracy
+inc(ap.Angle, + AIrndSign(random((Level - 1) * 5)));
+
 d:= 0;
 
 repeat
@@ -1270,6 +1283,9 @@
         dy:= (Targ.Point.Y - y) * t;
 
         ap.Angle:= DxDy2AttackAnglef(dx, -dy)
+        // Apply inaccuracy
+        if (not cLaserSighting) then
+            inc(ap.Angle, + AIrndSign(random((Level - 1) * 10)));
         end;
 
     if dx >= 0 then cx:= 0.45 else cx:= -0.45;