hedgewars/uAIAmmoTests.pas
branchwebgl
changeset 9950 2759212a27de
parent 9521 8054d9d775fd
parent 9844 8f5b48525a03
child 10015 4feced261c68
equal deleted inserted replaced
9521:8054d9d775fd 9950:2759212a27de
    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
   118             (proc: nil;              flags: 0), // amSnowball
   119             (proc: nil;              flags: 0), // amSnowball
   119             (proc: nil;              flags: 0), // amTardis
   120             (proc: nil;              flags: 0), // amTardis
   120             //(proc: nil;              flags: 0), // amStructure
   121             //(proc: nil;              flags: 0), // amStructure
   121             (proc: nil;              flags: 0), // amLandGun
   122             (proc: nil;              flags: 0), // amLandGun
   122             (proc: nil;              flags: 0), // amIceGun
   123             (proc: nil;              flags: 0), // amIceGun
   123             (proc: nil;              flags: 0)  // amKnife
   124             (proc: nil;              flags: 0), // amKnife
       
   125             (proc: nil;              flags: 0)  // amGirder
   124             );
   126             );
   125 
   127 
   126 implementation
   128 implementation
   127 uses uVariables, uUtils, uGearsHandlers;
   129 uses uVariables, uUtils, uGearsHandlers;
   128 
   130 
  1043     fexit: boolean;
  1045     fexit: boolean;
  1044     i, t, valueResult: LongInt;
  1046     i, t, valueResult: LongInt;
  1045 begin
  1047 begin
  1046 ap.ExplR:= 0;
  1048 ap.ExplR:= 0;
  1047 ap.Time:= 0;
  1049 ap.Time:= 0;
  1048 if (Level > 3) then
  1050 if (Level > 3) or (cGravityf = 0) then
  1049     exit(BadTurn);
  1051     exit(BadTurn);
  1050 
  1052 
  1051 ap.Angle:= 0;
  1053 ap.Angle:= 0;
  1052 ap.AttackPutX:= Targ.Point.X;
  1054 ap.AttackPutX:= Targ.Point.X;
  1053 ap.AttackPutY:= Targ.Point.Y;
  1055 ap.AttackPutY:= Targ.Point.Y;
  1220         valueResult:= BadTurn;
  1222         valueResult:= BadTurn;
  1221 
  1223 
  1222     TestCake:= valueResult;
  1224     TestCake:= valueResult;
  1223 end;
  1225 end;
  1224 
  1226 
       
  1227 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt;
       
  1228 var valueResult: LongInt;
       
  1229     x, y, dx, dy: real;
       
  1230     EX, EY, t: LongInt;
       
  1231 begin
       
  1232 Targ:= Targ; // avoid compiler hint
       
  1233 
       
  1234 x:= hwFloat2Float(Me^.X) + hwSign(Me^.dX) * 7;
       
  1235 y:= hwFloat2Float(Me^.Y);
       
  1236 dx:= hwSign(Me^.dX) * 0.03;
       
  1237 dy:= 0;
       
  1238 t:= 5000;
       
  1239 repeat
       
  1240     dec(t);
       
  1241     x:= x + dx;
       
  1242     dy:= dy + cGravityf;
       
  1243     y:= y + dy;
       
  1244     
       
  1245     if TestColl(trunc(x), trunc(y), 3) then
       
  1246         t:= 0;
       
  1247 until t = 0;
       
  1248 
       
  1249 EX:= trunc(x);
       
  1250 EY:= trunc(y);
       
  1251 
       
  1252 if Level = 1 then
       
  1253     valueResult:= RateExplosion(Me, EX, EY, 76, afTrackFall or afErasesLand)
       
  1254 else 
       
  1255     valueResult:= RateExplosion(Me, EX, EY, 76);
       
  1256 
       
  1257 if (valueResult > 0) then
       
  1258     begin
       
  1259     ap.Angle:= 0;
       
  1260     ap.Power:= 1;
       
  1261     ap.Time:= 0;
       
  1262     ap.ExplR:= 150;
       
  1263     ap.ExplX:= EX;
       
  1264     ap.ExplY:= EY
       
  1265     end else
       
  1266     valueResult:= BadTurn;
       
  1267 
       
  1268 TestDynamite:= valueResult
       
  1269 end;
       
  1270 
  1225 end.
  1271 end.