# HG changeset patch # User Wuzzy # Date 1591674699 -7200 # Node ID 250c778463f3402c4a078196a62fbf7aab54ad74 # Parent d9c62f196fe034f98c850f78b3ee93ed7a8e0f5f "Teach" AI hogs to be inaccurate with guns (and kamikaze) diff -r d9c62f196fe0 -r 250c778463f3 ChangeLog.txt --- 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 diff -r d9c62f196fe0 -r 250c778463f3 hedgewars/uAIAmmoTests.pas --- 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;