hedgewars/uAIAmmoTests.pas
changeset 9722 22dba2d8de93
parent 9495 2fc346fadae3
child 9768 08799c901a42
equal deleted inserted replaced
9721:1833dadcebf0 9722:22dba2d8de93
    52 function TestKamikaze(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    52 function TestKamikaze(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    53 function TestAirAttack(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    53 function TestAirAttack(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    54 function TestTeleport(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    54 function TestTeleport(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    55 function TestHammer(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    55 function TestHammer(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    56 function TestCake(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    56 function TestCake(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
       
    57 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    57 
    58 
    58 type TAmmoTestProc = function (Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    59 type TAmmoTestProc = function (Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
    59     TAmmoTest = record
    60     TAmmoTest = record
    60             proc: TAmmoTestProc;
    61             proc: TAmmoTestProc;
    61             flags: Longword;
    62             flags: Longword;
    72             (proc: nil;              flags: 0), // amPickHammer
    73             (proc: nil;              flags: 0), // amPickHammer
    73             (proc: nil;              flags: 0), // amSkip
    74             (proc: nil;              flags: 0), // amSkip
    74             (proc: nil;              flags: 0), // amRope
    75             (proc: nil;              flags: 0), // amRope
    75             (proc: nil;              flags: 0), // amMine
    76             (proc: nil;              flags: 0), // amMine
    76             (proc: @TestDesertEagle; flags: amtest_MultipleAttacks), // amDEagle
    77             (proc: @TestDesertEagle; flags: amtest_MultipleAttacks), // amDEagle
    77             (proc: nil;              flags: 0), // amDynamite
    78             (proc: @TestDynamite;    flags: amtest_NoTarget), // amDynamite
    78             (proc: @TestFirePunch;   flags: amtest_NoTarget), // amFirePunch
    79             (proc: @TestFirePunch;   flags: amtest_NoTarget), // amFirePunch
    79             (proc: @TestWhip;        flags: amtest_NoTarget), // amWhip
    80             (proc: @TestWhip;        flags: amtest_NoTarget), // amWhip
    80             (proc: @TestBaseballBat; flags: amtest_NoTarget), // amBaseballBat
    81             (proc: @TestBaseballBat; flags: amtest_NoTarget), // amBaseballBat
    81             (proc: nil;              flags: 0), // amParachute
    82             (proc: nil;              flags: 0), // amParachute
    82             (proc: @TestAirAttack;   flags: amtest_Rare), // amAirAttack
    83             (proc: @TestAirAttack;   flags: amtest_Rare), // amAirAttack
  1220         valueResult:= BadTurn;
  1221         valueResult:= BadTurn;
  1221 
  1222 
  1222     TestCake:= valueResult;
  1223     TestCake:= valueResult;
  1223 end;
  1224 end;
  1224 
  1225 
       
  1226 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
       
  1227 var valueResult: LongInt;
       
  1228     x, y, dx, dy: real;
       
  1229     EX, EY, t: LongInt;
       
  1230 begin
       
  1231 x:= hwFloat2Float(Me^.X) + hwSign(Me^.dX) * 7;
       
  1232 y:= hwFloat2Float(Me^.Y);
       
  1233 dx:= hwSign(Me^.dX) * 0.03;
       
  1234 dy:= 0;
       
  1235 t:= 5000;
       
  1236 repeat
       
  1237     dec(t);
       
  1238     x:= x + dx;
       
  1239     dy:= dy + cGravityf;
       
  1240     y:= y + dy;
       
  1241     
       
  1242     if TestColl(trunc(x), trunc(y), 3) then
       
  1243         t:= 0;
       
  1244 until t = 0;
       
  1245 
       
  1246 EX:= trunc(x);
       
  1247 EY:= trunc(y);
       
  1248 
       
  1249 if Level = 1 then
       
  1250     valueResult:= RateExplosion(Me, EX, EY, 76, afTrackFall or afErasesLand)
       
  1251 else 
       
  1252     valueResult:= RateExplosion(Me, EX, EY, 76);
       
  1253 
       
  1254 if (valueResult > 0) then
       
  1255     begin
       
  1256     ap.Angle:= 0;
       
  1257     ap.Power:= 1;
       
  1258     ap.Time:= 0;
       
  1259     ap.ExplR:= 150;
       
  1260     ap.ExplX:= EX;
       
  1261     ap.ExplY:= EY
       
  1262     end else
       
  1263     valueResult:= BadTurn;
       
  1264 
       
  1265 TestDynamite:= valueResult
       
  1266 end;
       
  1267 
  1225 end.
  1268 end.