adding X offset seems to improve chance of drownings
authornemo
Thu, 15 Nov 2018 15:12:18 -0500
changeset 14212 ca179b615c0b
parent 14211 0f7b92397b9e
child 14213 09dacb61d526
adding X offset seems to improve chance of drownings
hedgewars/uAIAmmoTests.pas
hedgewars/uAIMisc.pas
--- a/hedgewars/uAIAmmoTests.pas	Wed Nov 14 16:58:22 2018 +0100
+++ b/hedgewars/uAIAmmoTests.pas	Thu Nov 15 15:12:18 2018 -0500
@@ -158,8 +158,8 @@
 repeat
     rTime:= rTime + 300 + Level * 50 + random(300);
     if (WorldEdge = weWrap) and (random(2)=0) then
-         Vx:= - windSpeed * rTime * 0.5 + (targXWrap + AIrndSign(2) - mX) / rTime
-    else Vx:= - windSpeed * rTime * 0.5 + (Targ.Point.X + AIrndSign(2) - mX) / rTime;
+         Vx:= - windSpeed * rTime * 0.5 + (targXWrap + AIrndSign(2) + AIrndOffset(Targ, Level) - mX) / rTime
+    else Vx:= - windSpeed * rTime * 0.5 + (Targ.Point.X + AIrndSign(2) + AIrndOffset(Targ, Level) - mX) / rTime;
     Vy:= cGravityf * rTime * 0.5 - (Targ.Point.Y + 1 - mY) / rTime;
     r:= sqr(Vx) + sqr(Vy);
     if not (r > 1) then
@@ -544,8 +544,8 @@
 repeat
     inc(TestTime, 1000);
     if (WorldEdge = weWrap) and (random(2)=0) then
-         Vx:= (targXWrap - meX) / (TestTime + tDelta)
-    else Vx:= (Targ.Point.X - meX) / (TestTime + tDelta);
+         Vx:= (targXWrap + AIrndOffset(Targ, Level) - meX) / (TestTime + tDelta)
+    else Vx:= (Targ.Point.X + AIrndOffset(Targ, Level) - meX) / (TestTime + tDelta);
     Vy:= cGravityf * ((TestTime + tDelta) div 2) - (Targ.Point.Y - meY) / (TestTime + tDelta);
     r:= sqr(Vx) + sqr(Vy);
     if not (r > 1) then
--- a/hedgewars/uAIMisc.pas	Wed Nov 14 16:58:22 2018 +0100
+++ b/hedgewars/uAIMisc.pas	Thu Nov 15 15:12:18 2018 -0500
@@ -89,7 +89,8 @@
 function  RateHammer(Me: PGear): LongInt;
 
 function  HHGo(Gear, AltGear: PGear; var GoInfo: TGoInfo): boolean;
-function  AIrndSign(num: LongInt): LongInt;
+function  AIrndSign(num: LongInt): LongInt; inline;
+function  AIrndOffset(targ: TTarget; Level: LongWord): LongInt; inline;
 
 var ThinkingHH: PGear;
     Targets: TTargets;
@@ -1028,7 +1029,7 @@
 HHJump(AltGear, jmpHJump, GoInfo);
 end;
 
-function AIrndSign(num: LongInt): LongInt;
+function AIrndSign(num: LongInt): LongInt; inline;
 begin
 if random(2) = 0 then
     AIrndSign:=   num
@@ -1036,6 +1037,14 @@
     AIrndSign:= - num
 end;
 
+function AIrndOffset(targ: TTarget; Level: LongWord): LongInt; inline;
+begin
+if Level <> 1 then exit(0);
+// at present level 2 doesn't track falls on most things
+//if Level = 2 then exit(round(targ.Radius*(random(5)-2)/2));
+if Level = 1 then exit(round(targ.Radius*(random(7)-3)/2))
+end;
+
 procedure initModule;
 begin
     friendlyfactor:= 300;