Same approach for cluster bomb.
--- a/hedgewars/uAIAmmoTests.pas Fri Mar 12 01:21:53 2010 +0000
+++ b/hedgewars/uAIAmmoTests.pas Fri Mar 12 01:44:10 2010 +0000
@@ -32,6 +32,7 @@
function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
+function TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
@@ -50,7 +51,7 @@
(
(proc: nil; flags: 0), // amNothing
(proc: @TestGrenade; flags: 0), // amGrenade
- (proc: nil; flags: 0), // amClusterBomb
+ (proc: @TestClusterBomb; flags: 0), // amClusterBomb
(proc: @TestBazooka; flags: 0), // amBazooka
(proc: nil; flags: 0), // amUFO
(proc: @TestShotgun; flags: 0), // amShotgun
@@ -210,6 +211,58 @@
TestGrenade:= valueResult
end;
+function TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
+const tDelta = 24;
+var Vx, Vy, r: hwFloat;
+ Score, EX, EY, valueResult: LongInt;
+ TestTime: Longword;
+
+ function CheckTrace: LongInt;
+ var x, y, dY: hwFloat;
+ t: LongInt;
+ begin
+ x:= Me^.X;
+ y:= Me^.Y;
+ dY:= -Vy;
+ t:= TestTime;
+ repeat
+ x:= x + Vx;
+ y:= y + dY;
+ dY:= dY + cGravity;
+ dec(t)
+ until TestCollExcludingMe(Me, hwRound(x), hwRound(y), 5) or (t = 0);
+ EX:= hwRound(x);
+ EY:= hwRound(y);
+ if t < 50 then CheckTrace:= RateExplosion(Me, EX, EY, 91)
+ else CheckTrace:= BadTurn
+ end;
+begin
+valueResult:= BadTurn;
+TestTime:= 0;
+ap.ExplR:= 0;
+repeat
+ inc(TestTime, 1000);
+ Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta);
+ Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime + tDelta);
+ r:= Distance(Vx, Vy);
+ if not (r > _1) then
+ begin
+ Score:= CheckTrace;
+ if valueResult < Score then
+ begin
+ ap.Angle:= DxDy2AttackAngle(Vx, Vy) + AIrndSign(random(Level));
+ ap.Power:= hwRound(r * cMaxPower) + AIrndSign(random(Level) * 15)+10;
+ ap.Time:= TestTime;
+ ap.ExplR:= 90;
+ ap.ExplX:= EX;
+ ap.ExplY:= EY;
+ valueResult:= Score
+ end;
+ end
+until (TestTime = 4000);
+TestClusterBomb:= valueResult
+end;
+
function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
const tDelta = 24;
var Vx, Vy, r: hwFloat;