hedgewars/uAIAmmoTests.pas
changeset 5645 b434ba5d064e
parent 5642 0ce9e01bae56
child 5933 97c240202986
equal deleted inserted replaced
5642:0ce9e01bae56 5645:b434ba5d064e
    41 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    41 function TestDesertEagle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    42 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    42 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    43 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    43 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    44 function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    44 function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    45 function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    45 function TestTeleport(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
       
    46 function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    46 
    47 
    47 type TAmmoTestProc = function (Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    48 type TAmmoTestProc = function (Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
    48     TAmmoTest = record
    49     TAmmoTest = record
    49             proc: TAmmoTestProc;
    50             proc: TAmmoTestProc;
    50             flags: Longword;
    51             flags: Longword;
    99             (proc: nil;              flags: 0), // amPiano
   100             (proc: nil;              flags: 0), // amPiano
   100             (proc: @TestGrenade;     flags: 0), // amGasBomb
   101             (proc: @TestGrenade;     flags: 0), // amGasBomb
   101             (proc: @TestShotgun;     flags: 0), // amSineGun
   102             (proc: @TestShotgun;     flags: 0), // amSineGun
   102             (proc: nil;              flags: 0), // amFlamethrower
   103             (proc: nil;              flags: 0), // amFlamethrower
   103             (proc: @TestGrenade;     flags: 0), // amSMine
   104             (proc: @TestGrenade;     flags: 0), // amSMine
   104             (proc: @TestFirePunch;   flags: 0), // amHammer
   105             (proc: @TestHammer;      flags: 0), // amHammer
   105             (proc: nil;              flags: 0), // amResurrector
   106             (proc: nil;              flags: 0), // amResurrector
   106             (proc: nil;              flags: 0), // amDrillStrike
   107             (proc: nil;              flags: 0), // amDrillStrike
   107             (proc: @TestSnowball;    flags: 0), // amSnowball
   108             (proc: @TestSnowball;    flags: 0), // amSnowball
   108             (proc: nil;              flags: 0), // amTardis
   109             (proc: nil;              flags: 0), // amTardis
   109             (proc: nil;              flags: 0), // amStructure
   110             (proc: nil;              flags: 0), // amStructure
   663     inc(valueResult);
   664     inc(valueResult);
   664 
   665 
   665 TestFirePunch:= valueResult;
   666 TestFirePunch:= valueResult;
   666 end;
   667 end;
   667 
   668 
       
   669 function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
       
   670 var rate: LongInt;
       
   671 begin
       
   672 Level:= Level; // avoid compiler hint
       
   673 ap.ExplR:= 0;
       
   674 ap.Time:= 0;
       
   675 ap.Power:= 1;
       
   676 ap.Angle:= 0;
       
   677          
       
   678 if (Abs(hwRound(Me^.X) + hwSign(Me^.dX) * 10 - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) > 20) then
       
   679     rate:= 0
       
   680     else
       
   681     rate:= RateHammer(Me);
       
   682 if rate = 0 then rate:= BadTurn;
       
   683 TestHammer:= rate;
       
   684 end;
       
   685 
   668 function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   686 function TestAirAttack(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt;
   669 const cShift = 4;
   687 const cShift = 4;
   670 var X, Y, dY: hwFloat;
   688 var X, Y, dY: hwFloat;
   671     b: array[0..9] of boolean;
   689     b: array[0..9] of boolean;
   672     dmg: array[0..9] of LongInt;
   690     dmg: array[0..9] of LongInt;