hedgewars/uAIAmmoTests.pas
branchwebgl
changeset 8096 453917e94e55
parent 8026 4a4f21070479
parent 8033 4e40503e2b2c
child 8330 aaefa587e277
equal deleted inserted replaced
8053:2e836bebb518 8096:453917e94e55
    38 function TestSnowball(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    38 function TestSnowball(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    39 function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    39 function TestGrenade(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    40 function TestMolotov(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    40 function TestMolotov(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    41 function TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    41 function TestClusterBomb(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    42 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    42 function TestWatermelon(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
       
    43 function TestDrillRocket(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    43 function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    44 function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    44 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    45 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    45 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    46 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    46 function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    47 function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    47 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    48 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    89             (proc: @TestCake;        flags: amtest_Rare or amtest_NoTarget), // amCake
    90             (proc: @TestCake;        flags: amtest_Rare or amtest_NoTarget), // amCake
    90             (proc: nil;              flags: 0), // amSeduction
    91             (proc: nil;              flags: 0), // amSeduction
    91             (proc: @TestWatermelon;  flags: 0), // amWatermelon
    92             (proc: @TestWatermelon;  flags: 0), // amWatermelon
    92             (proc: nil;              flags: 0), // amHellishBomb
    93             (proc: nil;              flags: 0), // amHellishBomb
    93             (proc: nil;              flags: 0), // amNapalm
    94             (proc: nil;              flags: 0), // amNapalm
    94             (proc: nil;              flags: 0), // amDrill
    95             (proc: @TestDrillRocket; flags: 0), // amDrill
    95             (proc: nil;              flags: 0), // amBallgun
    96             (proc: nil;              flags: 0), // amBallgun
    96             (proc: nil;              flags: 0), // amRCPlane
    97             (proc: nil;              flags: 0), // amRCPlane
    97             (proc: nil;              flags: 0), // amLowGravity
    98             (proc: nil;              flags: 0), // amLowGravity
    98             (proc: nil;              flags: 0), // amExtraDamage
    99             (proc: nil;              flags: 0), // amExtraDamage
    99             (proc: nil;              flags: 0), // amInvulnerable
   100             (proc: nil;              flags: 0), // amInvulnerable
   185 //until (value > 204800) or (rTime > 4250); not so useful since adding score to the drowning
   186 //until (value > 204800) or (rTime > 4250); not so useful since adding score to the drowning
   186 until rTime > 4250;
   187 until rTime > 4250;
   187 TestBazooka:= valueResult
   188 TestBazooka:= valueResult
   188 end;
   189 end;
   189 
   190 
       
   191 
       
   192 function TestDrillRocket(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
       
   193 var Vx, Vy, r, mX, mY: real;
       
   194     rTime: LongInt;
       
   195     EX, EY: LongInt;
       
   196     valueResult: LongInt;
       
   197     x, y, dX, dY: real;
       
   198     t: LongInt;
       
   199     value: LongInt;
       
   200 begin
       
   201     mX:= hwFloat2Float(Me^.X);
       
   202     mY:= hwFloat2Float(Me^.Y);
       
   203     ap.Time:= 0;
       
   204     rTime:= 350;
       
   205     ap.ExplR:= 0;
       
   206     valueResult:= BadTurn;
       
   207     repeat
       
   208         rTime:= rTime + 300 + Level * 50 + random(300);
       
   209         Vx:= - windSpeed * rTime * 0.5 + (Targ.X + AIrndSign(2) - mX) / rTime;
       
   210         Vy:= cGravityf * rTime * 0.5 - (Targ.Y - 35 - mY) / rTime;
       
   211         r:= sqr(Vx) + sqr(Vy);
       
   212         if not (r > 1) then
       
   213             begin
       
   214             x:= mX;
       
   215             y:= mY;
       
   216             dX:= Vx;
       
   217             dY:= -Vy;
       
   218             t:= rTime;
       
   219             repeat
       
   220                 x:= x + dX;
       
   221                 y:= y + dY;
       
   222                 dX:= dX + windSpeed;
       
   223                 dY:= dY + cGravityf;
       
   224                 dec(t)
       
   225             until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or 
       
   226                    ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (y > cWaterLine);
       
   227             
       
   228             EX:= trunc(x);
       
   229             EY:= trunc(y);
       
   230             if Level = 1 then
       
   231                 value:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand)
       
   232             else value:= RateExplosion(Me, EX, EY, 101);
       
   233             if value = 0 then
       
   234                 value:= 1024 - Metric(Targ.X, Targ.Y, EX, EY) div 64;
       
   235             if valueResult <= value then
       
   236                 begin
       
   237                 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random((Level - 1) * 9));
       
   238                 ap.Power:= trunc(sqrt(r) * cMaxPower) - random((Level - 1) * 17 + 1);
       
   239                 ap.ExplR:= 100;
       
   240                 ap.ExplX:= EX;
       
   241                 ap.ExplY:= EY;
       
   242                 valueResult:= value
       
   243                 end;
       
   244             end
       
   245     until rTime > 4250;
       
   246     TestDrillRocket:= valueResult
       
   247 end;
       
   248 
       
   249 
   190 function TestSnowball(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   250 function TestSnowball(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   191 var Vx, Vy, r: real;
   251 var Vx, Vy, r: real;
   192     rTime: LongInt;
   252     rTime: LongInt;
   193     EX, EY: LongInt;
   253     EX, EY: LongInt;
   194     valueResult: LongInt;
   254     valueResult: LongInt;