19 {$INCLUDE "options.inc"} |
19 {$INCLUDE "options.inc"} |
20 |
20 |
21 unit uAIAmmoTests; |
21 unit uAIAmmoTests; |
22 interface |
22 interface |
23 uses SDLh, uConsts, uFloat, uTypes; |
23 uses SDLh, uConsts, uFloat, uTypes; |
24 const amtest_OnTurn = $00000001; |
24 const |
|
25 amtest_OnTurn = $00000001; // from one position |
|
26 amtest_NoTarget = $00000002; // each pos, but no targetting |
25 |
27 |
26 var windSpeed: real; |
28 var windSpeed: real; |
27 |
29 |
28 type TAttackParams = record |
30 type TAttackParams = record |
29 Time: Longword; |
31 Time: Longword; |
66 (proc: nil; flags: 0), // amSkip |
68 (proc: nil; flags: 0), // amSkip |
67 (proc: nil; flags: 0), // amRope |
69 (proc: nil; flags: 0), // amRope |
68 (proc: nil; flags: 0), // amMine |
70 (proc: nil; flags: 0), // amMine |
69 (proc: @TestDesertEagle; flags: 0), // amDEagle |
71 (proc: @TestDesertEagle; flags: 0), // amDEagle |
70 (proc: nil; flags: 0), // amDynamite |
72 (proc: nil; flags: 0), // amDynamite |
71 (proc: @TestFirePunch; flags: 0), // amFirePunch |
73 (proc: @TestFirePunch; flags: amtest_NoTarget), // amFirePunch |
72 (proc: @TestWhip; flags: 0), // amWhip |
74 (proc: @TestWhip; flags: amtest_NoTarget), // amWhip |
73 (proc: @TestBaseballBat; flags: 0), // amBaseballBat |
75 (proc: @TestBaseballBat; flags: amtest_NoTarget), // amBaseballBat |
74 (proc: nil; flags: 0), // amParachute |
76 (proc: nil; flags: 0), // amParachute |
75 (proc: @TestAirAttack; flags: amtest_OnTurn), // amAirAttack |
77 (proc: @TestAirAttack; flags: amtest_OnTurn), // amAirAttack |
76 (proc: nil; flags: 0), // amMineStrike |
78 (proc: nil; flags: 0), // amMineStrike |
77 (proc: nil; flags: 0), // amBlowTorch |
79 (proc: nil; flags: 0), // amBlowTorch |
78 (proc: nil; flags: 0), // amGirder |
80 (proc: nil; flags: 0), // amGirder |
103 (proc: nil; flags: 0), // amPiano |
105 (proc: nil; flags: 0), // amPiano |
104 (proc: @TestGrenade; flags: 0), // amGasBomb |
106 (proc: @TestGrenade; flags: 0), // amGasBomb |
105 (proc: @TestShotgun; flags: 0), // amSineGun |
107 (proc: @TestShotgun; flags: 0), // amSineGun |
106 (proc: nil; flags: 0), // amFlamethrower |
108 (proc: nil; flags: 0), // amFlamethrower |
107 (proc: @TestGrenade; flags: 0), // amSMine |
109 (proc: @TestGrenade; flags: 0), // amSMine |
108 (proc: @TestHammer; flags: 0), // amHammer |
110 (proc: @TestHammer; flags: amtest_NoTarget), // amHammer |
109 (proc: nil; flags: 0), // amResurrector |
111 (proc: nil; flags: 0), // amResurrector |
110 (proc: nil; flags: 0), // amDrillStrike |
112 (proc: nil; flags: 0), // amDrillStrike |
111 (proc: nil; flags: 0), // amSnowball |
113 (proc: nil; flags: 0), // amSnowball |
112 (proc: nil; flags: 0), // amTardis |
114 (proc: nil; flags: 0), // amTardis |
113 (proc: nil; flags: 0), // amStructure |
115 (proc: nil; flags: 0), // amStructure |
638 Level:= Level; // avoid compiler hint |
640 Level:= Level; // avoid compiler hint |
639 TestBaseballBat:= BadTurn; |
641 TestBaseballBat:= BadTurn; |
640 ap.ExplR:= 0; |
642 ap.ExplR:= 0; |
641 x:= hwFloat2Float(Me^.X); |
643 x:= hwFloat2Float(Me^.X); |
642 y:= hwFloat2Float(Me^.Y); |
644 y:= hwFloat2Float(Me^.Y); |
643 if (Level > 2) or (Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) > 25) then |
645 if (Level > 2) then |
644 exit(BadTurn); |
646 exit(BadTurn); |
645 |
647 |
646 ap.Time:= 0; |
648 ap.Time:= 0; |
647 ap.Power:= 1; |
649 ap.Power:= 1; |
648 if (Targ.X) - trunc(x) >= 0 then |
650 if (Targ.X) - trunc(x) >= 0 then |
708 TestFirePunch:= val2 |
710 TestFirePunch:= val2 |
709 end |
711 end |
710 else TestFirePunch:= BadTurn; |
712 else TestFirePunch:= BadTurn; |
711 end; |
713 end; |
712 |
714 |
713 // TODO: TestWhip, TestFirepunch and TestBaseballBat could be called only once at each position |
715 |
714 // (now they're called for each possible target in each position) |
|
715 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
716 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
716 var valueResult, v1, v2: LongInt; |
717 var valueResult, v1, v2: LongInt; |
717 x, y: real; |
718 x, y: real; |
718 begin |
719 begin |
719 Level:= Level; // avoid compiler hint |
720 Level:= Level; // avoid compiler hint |
721 ap.Time:= 0; |
722 ap.Time:= 0; |
722 ap.Power:= 1; |
723 ap.Power:= 1; |
723 x:= hwFloat2Float(Me^.X); |
724 x:= hwFloat2Float(Me^.X); |
724 y:= hwFloat2Float(Me^.Y); |
725 y:= hwFloat2Float(Me^.Y); |
725 |
726 |
726 if(abs(Targ.X - x) > 50) or (abs(Targ.Y - y) > 30) then // we're way too far from our target |
|
727 exit(BadTurn); |
|
728 |
|
729 // check left direction |
727 // check left direction |
730 {first RateShove checks fartherest of two whip's AmmoShove attacks |
728 {first RateShove checks fartherest of two whip's AmmoShove attacks |
731 to encourage distant attacks (damaged hog is excluded from view of second |
729 to encourage distant attacks (damaged hog is excluded from view of second |
732 RateShove call)} |
730 RateShove call)} |
733 v1:= RateShove(Me, trunc(x) - 15, trunc(y) |
731 v1:= RateShove(Me, trunc(x) - 15, trunc(y) |