# HG changeset patch # User unc0rr # Date 1238776696 0 # Node ID b1ef1f86148c1891f73f185dfd84cbe8d1a72e32 # Parent bbdca883b5f96a287f8d47750f111390dcdf2fc3 Some AI tweaks by imcold diff -r bbdca883b5f9 -r b1ef1f86148c hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Fri Apr 03 16:35:59 2009 +0000 +++ b/hedgewars/uAIAmmoTests.pas Fri Apr 03 16:38:16 2009 +0000 @@ -288,14 +288,18 @@ end; function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; +const + MIN_RANGE = 80; + MAX_RANGE = 400; var Vx, Vy, x, y: hwFloat; rx, ry, Result: LongInt; + range: integer; begin ap.ExplR:= 0; ap.Time:= 0; ap.Power:= 1; -if Metric(hwRound(Me^.X), hwRound(Me^.Y), Targ.X, Targ.Y) < 80 then - exit(BadTurn); +range:= Metric(hwRound(Me^.X), hwRound(Me^.Y), Targ.X, Targ.Y); +if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then exit(BadTurn); Vx:= (int2hwFloat(Targ.X) - Me^.X) * _1div1024; Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * _1div1024; x:= Me^.X; @@ -315,7 +319,7 @@ else dec(Result, Level * 4000); exit(Result) end -until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x < _0) or (y < _0) or (x > _2048) or (y > _1024); +until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x.isNegative) or (y.isNegative) or (x.Round > LAND_WIDTH) or (y.Round > LAND_HEIGHT); TestShotgun:= BadTurn end; @@ -336,12 +340,14 @@ y:= Me^.Y; ap.Angle:= DxDy2AttackAngle(Vx, -Vy); d:= 0; + repeat x:= x + vX; y:= y + vY; if ((hwRound(x) and LAND_WIDTH_MASK) = 0)and((hwRound(y) and LAND_HEIGHT_MASK) = 0) and (Land[hwRound(y), hwRound(x)] <> 0) then inc(d); -until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x < _0) or (y < _0) or (x > _2048) or (y > _1024) or (d > 200); +until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x.isNegative) or (y.isNegative) or (x.Round > LAND_WIDTH) or (y.Round > LAND_HEIGHT) or (d > 200); + if Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 3 then Result:= max(0, (4 - d div 50) * 7 * 1024) else Result:= BadTurn; TestDesertEagle:= Result diff -r bbdca883b5f9 -r b1ef1f86148c hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Fri Apr 03 16:35:59 2009 +0000 +++ b/hedgewars/uAIMisc.pas Fri Apr 03 16:38:16 2009 +0000 @@ -237,6 +237,8 @@ end; function RateShotgun(Me: PGear; x, y: LongInt): LongInt; +const + REUSE_BONUS = 1.35; var i, dmg, Result: LongInt; begin Result:= 0; @@ -252,14 +254,12 @@ with Targets.ar[i] do begin dmg:= min(cHHRadius + cShotgunRadius - hwRound(DistanceI(Point.x - x, Point.y - y)), 25); + dmg := round(dmg * REUSE_BONUS); if dmg > 0 then begin - if dmg >= abs(Score) then - if Score > 0 then inc(Result, KillScore) - else dec(Result, KillScore * friendlyfactor div 100) - else - if Score > 0 then inc(Result, dmg) - else dec(Result, dmg * friendlyfactor div 100) + if dmg >= abs(Score) then dmg := KillScore; + if Score > 0 then inc(Result, dmg) + else dec(Result, dmg * friendlyfactor div 100); end; end; RateShotgun:= Result * 1024