23 uses uConsts, uFloat, uTypes, uAIMisc; |
23 uses uConsts, uFloat, uTypes, uAIMisc; |
24 const |
24 const |
25 amtest_Rare = $00000001; // check only several positions |
25 amtest_Rare = $00000001; // check only several positions |
26 amtest_NoTarget = $00000002; // each pos, but no targetting |
26 amtest_NoTarget = $00000002; // each pos, but no targetting |
27 amtest_MultipleAttacks = $00000004; // test could result in multiple attacks, set AttacksNum |
27 amtest_MultipleAttacks = $00000004; // test could result in multiple attacks, set AttacksNum |
|
28 amtest_NoTrackFall = $00000008; // skip fall tracing. |
28 |
29 |
29 var windSpeed: real; |
30 var windSpeed: real; |
30 |
31 |
31 type TAttackParams = record |
32 type TAttackParams = record |
32 Time, AttacksNum: Longword; |
33 Time, AttacksNum: Longword; |
33 Angle, Power: LongInt; |
34 Angle, Power: LongInt; |
34 ExplX, ExplY, ExplR: LongInt; |
35 ExplX, ExplY, ExplR: LongInt; |
35 AttackPutX, AttackPutY: LongInt; |
36 AttackPutX, AttackPutY: LongInt; |
36 end; |
37 end; |
37 |
38 |
38 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
39 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
39 function TestBee(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
40 function TestBee(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
40 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
41 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
41 function TestGrenade(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
42 function TestGrenade(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
42 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
43 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
43 function TestClusterBomb(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
44 function TestClusterBomb(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
44 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
45 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
45 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
46 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
46 function TestMortar(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
47 function TestMortar(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
47 function TestShotgun(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
48 function TestShotgun(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
48 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
49 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
49 function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
50 function TestSniperRifle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
50 function TestBaseballBat(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
51 function TestBaseballBat(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
51 function TestFirePunch(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
52 function TestFirePunch(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
52 function TestWhip(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
53 function TestWhip(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
53 function TestKamikaze(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
54 function TestKamikaze(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
54 function TestAirAttack(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
55 function TestAirAttack(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
55 function TestTeleport(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
56 function TestTeleport(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
56 function TestHammer(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
57 function TestHammer(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
57 function TestCake(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
58 function TestCake(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
58 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
59 function TestDynamite(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
59 |
60 |
60 type TAmmoTestProc = function (Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
61 type TAmmoTestProc = function (Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
61 TAmmoTest = record |
62 TAmmoTest = record |
62 proc: TAmmoTestProc; |
63 proc: TAmmoTestProc; |
63 flags: Longword; |
64 flags: Longword; |
64 end; |
65 end; |
65 |
66 |
108 (proc: nil; flags: 0), // amJetpack |
109 (proc: nil; flags: 0), // amJetpack |
109 (proc: @TestMolotov; flags: 0), // amMolotov |
110 (proc: @TestMolotov; flags: 0), // amMolotov |
110 (proc: nil; flags: 0), // amBirdy |
111 (proc: nil; flags: 0), // amBirdy |
111 (proc: nil; flags: 0), // amPortalGun |
112 (proc: nil; flags: 0), // amPortalGun |
112 (proc: nil; flags: 0), // amPiano |
113 (proc: nil; flags: 0), // amPiano |
113 (proc: @TestGrenade; flags: 0), // amGasBomb |
114 (proc: @TestGrenade; flags: amtest_NoTrackFall), // amGasBomb |
114 (proc: @TestShotgun; flags: 0), // amSineGun |
115 (proc: @TestShotgun; flags: 0), // amSineGun |
115 (proc: nil; flags: 0), // amFlamethrower |
116 (proc: nil; flags: 0), // amFlamethrower |
116 (proc: @TestGrenade; flags: 0), // amSMine |
117 (proc: @TestGrenade; flags: 0), // amSMine |
117 (proc: @TestHammer; flags: amtest_NoTarget), // amHammer |
118 (proc: @TestHammer; flags: amtest_NoTarget), // amHammer |
118 (proc: nil; flags: 0), // amResurrector |
119 (proc: nil; flags: 0), // amResurrector |
134 function Metric(x1, y1, x2, y2: LongInt): LongInt; inline; |
135 function Metric(x1, y1, x2, y2: LongInt): LongInt; inline; |
135 begin |
136 begin |
136 Metric:= abs(x1 - x2) + abs(y1 - y2) |
137 Metric:= abs(x1 - x2) + abs(y1 - y2) |
137 end; |
138 end; |
138 |
139 |
139 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
140 function TestBazooka(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
140 const cExtraTime = 300; |
141 const cExtraTime = 300; |
141 var Vx, Vy, r, mX, mY: real; |
142 var Vx, Vy, r, mX, mY: real; |
142 rTime: LongInt; |
143 rTime: LongInt; |
143 EX, EY: LongInt; |
144 EX, EY: LongInt; |
144 valueResult: LongInt; |
145 valueResult: LongInt; |
145 targXWrap, x, y, dX, dY: real; |
146 targXWrap, x, y, dX, dY: real; |
146 t: LongInt; |
147 t: LongInt; |
147 value: LongInt; |
148 value: LongInt; |
148 begin |
149 begin |
|
150 Flags:= Flags; // avoid compiler hint |
149 mX:= hwFloat2Float(Me^.X); |
151 mX:= hwFloat2Float(Me^.X); |
150 mY:= hwFloat2Float(Me^.Y); |
152 mY:= hwFloat2Float(Me^.Y); |
151 ap.Time:= 0; |
153 ap.Time:= 0; |
152 rTime:= 350; |
154 rTime:= 350; |
153 ap.ExplR:= 0; |
155 ap.ExplR:= 0; |
318 TestBee:= valueResult - 5000 |
321 TestBee:= valueResult - 5000 |
319 else |
322 else |
320 TestBee:= BadTurn // no digging |
323 TestBee:= BadTurn // no digging |
321 end; |
324 end; |
322 |
325 |
323 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
326 function TestDrillRocket(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
324 var Vx, Vy, r, mX, mY: real; |
327 var Vx, Vy, r, mX, mY: real; |
325 rTime: LongInt; |
328 rTime: LongInt; |
326 EX, EY: LongInt; |
329 EX, EY: LongInt; |
327 valueResult: LongInt; |
330 valueResult: LongInt; |
328 targXWrap, x, y, dX, dY: real; |
331 targXWrap, x, y, dX, dY: real; |
329 t: LongInt; |
332 t: LongInt; |
330 value: LongInt; |
333 value: LongInt; |
331 t2: real; |
334 t2: real; |
332 timer: Longint; |
335 timer: Longint; |
333 begin |
336 begin |
|
337 Flags:= Flags; // avoid compiler hint |
334 if (Level > 3) then exit(BadTurn); |
338 if (Level > 3) then exit(BadTurn); |
335 |
339 |
336 mX:= hwFloat2Float(Me^.X); |
340 mX:= hwFloat2Float(Me^.X); |
337 mY:= hwFloat2Float(Me^.Y); |
341 mY:= hwFloat2Float(Me^.Y); |
338 ap.Time:= 0; |
342 ap.Time:= 0; |
406 until rTime > 5050 - Level * 800; |
410 until rTime > 5050 - Level * 800; |
407 TestDrillRocket:= valueResult |
411 TestDrillRocket:= valueResult |
408 end; |
412 end; |
409 |
413 |
410 |
414 |
411 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
415 function TestSnowball(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
412 var Vx, Vy, r: real; |
416 var Vx, Vy, r: real; |
413 rTime: LongInt; |
417 rTime: LongInt; |
414 EX, EY: LongInt; |
418 EX, EY: LongInt; |
415 valueResult: LongInt; |
419 valueResult: LongInt; |
416 targXWrap, x, y, dX, dY, meX, meY: real; |
420 targXWrap, x, y, dX, dY, meX, meY: real; |
417 t: LongInt; |
421 t: LongInt; |
418 value: LongInt; |
422 value: LongInt; |
419 |
423 |
420 begin |
424 begin |
|
425 Flags:= Flags; // avoid compiler hint |
421 meX:= hwFloat2Float(Me^.X); |
426 meX:= hwFloat2Float(Me^.X); |
422 meY:= hwFloat2Float(Me^.Y); |
427 meY:= hwFloat2Float(Me^.Y); |
423 ap.Time:= 0; |
428 ap.Time:= 0; |
424 rTime:= 350; |
429 rTime:= 350; |
425 ap.ExplR:= 0; |
430 ap.ExplR:= 0; |
471 end |
476 end |
472 until (rTime > 5050 - Level * 800); |
477 until (rTime > 5050 - Level * 800); |
473 TestSnowball:= valueResult |
478 TestSnowball:= valueResult |
474 end; |
479 end; |
475 |
480 |
476 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
481 function TestMolotov(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
477 var Vx, Vy, r: real; |
482 var Vx, Vy, r: real; |
478 Score, EX, EY, valueResult: LongInt; |
483 Score, EX, EY, valueResult: LongInt; |
479 TestTime: LongInt; |
484 TestTime: LongInt; |
480 targXWrap, x, y, dY, meX, meY: real; |
485 targXWrap, x, y, dY, meX, meY: real; |
481 t: LongInt; |
486 t: LongInt; |
482 begin |
487 begin |
|
488 Flags:= Flags; // avoid compiler hint |
483 meX:= hwFloat2Float(Me^.X); |
489 meX:= hwFloat2Float(Me^.X); |
484 meY:= hwFloat2Float(Me^.Y); |
490 meY:= hwFloat2Float(Me^.Y); |
485 valueResult:= BadTurn; |
491 valueResult:= BadTurn; |
486 TestTime:= 0; |
492 TestTime:= 0; |
487 ap.ExplR:= 0; |
493 ap.ExplR:= 0; |
570 until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or |
576 until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or |
571 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t = 0); |
577 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me^.Hedgehog^.Gear, trunc(x), trunc(y), 5))) or (t = 0); |
572 EX:= trunc(x); |
578 EX:= trunc(x); |
573 EY:= trunc(y); |
579 EY:= trunc(y); |
574 if t < 50 then |
580 if t < 50 then |
575 if Level = 1 then |
581 if (Level = 1) and (Flags and amtest_NoTrackFall = 0) then |
576 Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) |
582 Score:= RateExplosion(Me, EX, EY, 101, afTrackFall or afErasesLand) |
577 else Score:= RateExplosion(Me, EX, EY, 101) |
583 else Score:= RateExplosion(Me, EX, EY, 101) |
578 else |
584 else |
579 Score:= BadTurn; |
585 Score:= BadTurn; |
580 |
586 |
592 //until (Score > 204800) or (TestTime > 4000); |
598 //until (Score > 204800) or (TestTime > 4000); |
593 until TestTime > 4500 - Level * 512; |
599 until TestTime > 4500 - Level * 512; |
594 TestGrenade:= valueResult |
600 TestGrenade:= valueResult |
595 end; |
601 end; |
596 |
602 |
597 function TestClusterBomb(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
603 function TestClusterBomb(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
598 const tDelta = 24; |
604 const tDelta = 24; |
599 var Vx, Vy, r: real; |
605 var Vx, Vy, r: real; |
600 Score, EX, EY, valueResult: LongInt; |
606 Score, EX, EY, valueResult: LongInt; |
601 TestTime: Longword; |
607 TestTime: Longword; |
602 x, y, dY, meX, meY: real; |
608 x, y, dY, meX, meY: real; |
603 t: LongInt; |
609 t: LongInt; |
604 begin |
610 begin |
|
611 Flags:= Flags; // avoid compiler hint |
605 valueResult:= BadTurn; |
612 valueResult:= BadTurn; |
606 TestTime:= 500; |
613 TestTime:= 500; |
607 ap.ExplR:= 0; |
614 ap.ExplR:= 0; |
608 meX:= hwFloat2Float(Me^.X); |
615 meX:= hwFloat2Float(Me^.X); |
609 meY:= hwFloat2Float(Me^.Y); |
616 meY:= hwFloat2Float(Me^.Y); |
649 end |
656 end |
650 until (TestTime = 4100); |
657 until (TestTime = 4100); |
651 TestClusterBomb:= valueResult |
658 TestClusterBomb:= valueResult |
652 end; |
659 end; |
653 |
660 |
654 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
661 function TestWatermelon(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
655 const tDelta = 24; |
662 const tDelta = 24; |
656 var Vx, Vy, r: real; |
663 var Vx, Vy, r: real; |
657 Score, EX, EY, valueResult: LongInt; |
664 Score, EX, EY, valueResult: LongInt; |
658 TestTime: Longword; |
665 TestTime: Longword; |
659 targXWrap, x, y, dY, meX, meY: real; |
666 targXWrap, x, y, dY, meX, meY: real; |
660 t: LongInt; |
667 t: LongInt; |
661 begin |
668 begin |
|
669 Flags:= Flags; // avoid compiler hint |
662 valueResult:= BadTurn; |
670 valueResult:= BadTurn; |
663 TestTime:= 500; |
671 TestTime:= 500; |
664 ap.ExplR:= 0; |
672 ap.ExplR:= 0; |
665 meX:= hwFloat2Float(Me^.X); |
673 meX:= hwFloat2Float(Me^.X); |
666 meY:= hwFloat2Float(Me^.Y); |
674 meY:= hwFloat2Float(Me^.Y); |
847 or (trunc(y) > LAND_HEIGHT); |
857 or (trunc(y) > LAND_HEIGHT); |
848 |
858 |
849 TestShotgun:= BadTurn |
859 TestShotgun:= BadTurn |
850 end; |
860 end; |
851 |
861 |
852 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
862 function TestDesertEagle(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
853 var Vx, Vy, x, y, t: real; |
863 var Vx, Vy, x, y, t: real; |
854 d: Longword; |
864 d: Longword; |
855 ix, iy, valueResult: LongInt; |
865 ix, iy, valueResult: LongInt; |
856 begin |
866 begin |
|
867 Flags:= Flags; // avoid compiler hint |
857 if (Level > 4) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn); |
868 if (Level > 4) or (Targ.Score < 0) or (Targ.Kind <> gtHedgehog) then exit(BadTurn); |
858 Level:= Level; // avoid compiler hint |
869 Level:= Level; // avoid compiler hint |
859 ap.ExplR:= 1; |
870 ap.ExplR:= 1; |
860 ap.Time:= 0; |
871 ap.Time:= 0; |
861 ap.Power:= 1; |
872 ap.Power:= 1; |
942 TestSniperRifle:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, trunc(dmg), 20, vX*0.166, vY*0.166, afTrackFall) |
954 TestSniperRifle:= RateShove(Me, Targ.Point.X, Targ.Point.Y, 1, trunc(dmg), 20, vX*0.166, vY*0.166, afTrackFall) |
943 else TestSniperRifle:= BadTurn; |
955 else TestSniperRifle:= BadTurn; |
944 end; |
956 end; |
945 |
957 |
946 |
958 |
947 function TestBaseballBat(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
959 function TestBaseballBat(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
948 var valueResult, a, v1, v2: LongInt; |
960 var valueResult, a, v1, v2: LongInt; |
949 x, y, trackFall: LongInt; |
961 x, y, trackFall: LongInt; |
950 dx, dy: real; |
962 dx, dy: real; |
951 begin |
963 begin |
|
964 Flags:= Flags; // avoid compiler hint |
952 Targ:= Targ; // avoid compiler hint |
965 Targ:= Targ; // avoid compiler hint |
953 |
966 |
954 if Level < 3 then trackFall:= afTrackFall |
967 if Level < 3 then trackFall:= afTrackFall |
955 else trackFall:= 0; |
968 else trackFall:= 0; |
956 |
969 |
994 valueResult:= BadTurn; |
1007 valueResult:= BadTurn; |
995 |
1008 |
996 TestBaseballBat:= valueResult; |
1009 TestBaseballBat:= valueResult; |
997 end; |
1010 end; |
998 |
1011 |
999 function TestFirePunch(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams): LongInt; |
1012 function TestFirePunch(Me: PGear; Targ: TTarget; Level: LongInt; var ap: TAttackParams; Flags: LongWord): LongInt; |
1000 var valueResult, v1, v2, i: LongInt; |
1013 var valueResult, v1, v2, i: LongInt; |
1001 x, y, trackFall: LongInt; |
1014 x, y, trackFall: LongInt; |
1002 begin |
1015 begin |
|
1016 Flags:= Flags; // avoid compiler hint |
1003 Targ:= Targ; // avoid compiler hint |
1017 Targ:= Targ; // avoid compiler hint |
1004 |
1018 |
1005 if Level = 1 then trackFall:= afTrackFall |
1019 if Level = 1 then trackFall:= afTrackFall |
1006 else trackFall:= 0; |
1020 else trackFall:= 0; |
1007 |
1021 |