472 end; |
472 end; |
473 |
473 |
474 function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
474 function TestMortar(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
475 //const tDelta = 24; |
475 //const tDelta = 24; |
476 var Vx, Vy: real; |
476 var Vx, Vy: real; |
477 Score, EX, EY, valueResult: LongInt; |
477 Score, EX, EY: LongInt; |
478 TestTime: Longword; |
478 TestTime: Longword; |
479 x, y, dY, meX, meY: real; |
479 x, y, dY, meX, meY: real; |
480 begin |
480 begin |
481 valueResult:= BadTurn; |
481 TestMortar:= BadTurn; |
482 ap.ExplR:= 0; |
482 ap.ExplR:= 0; |
483 meX:= hwFloat2Float(Me^.X); |
483 meX:= hwFloat2Float(Me^.X); |
484 meY:= hwFloat2Float(Me^.Y); |
484 meY:= hwFloat2Float(Me^.Y); |
485 |
485 |
486 if (Level > 2) then |
486 if (Level > 2) then |
487 exit(BadTurn); |
487 exit; |
488 |
488 |
489 TestTime:= Solve(Targ.X, Targ.Y, trunc(meX), trunc(meY)); |
489 TestTime:= Solve(Targ.X, Targ.Y, trunc(meX), trunc(meY)); |
490 |
490 |
491 if TestTime = 0 then |
491 if TestTime = 0 then |
492 exit(BadTurn); |
492 exit; |
493 |
493 |
494 Vx:= (Targ.X - meX) / TestTime; |
494 Vx:= (Targ.X - meX) / TestTime; |
495 Vy:= cGravityf * (TestTime div 2) - (Targ.Y - meY) / TestTime; |
495 Vy:= cGravityf * (TestTime div 2) - (Targ.Y - meY) / TestTime; |
496 |
496 |
497 x:= meX; |
497 x:= meX; |
518 Score:= BadTurn |
518 Score:= BadTurn |
519 end |
519 end |
520 else |
520 else |
521 Score:= BadTurn; |
521 Score:= BadTurn; |
522 |
522 |
523 if valueResult < Score then |
523 if BadTurn < Score then |
524 begin |
524 begin |
525 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); |
525 ap.Angle:= DxDy2AttackAnglef(Vx, Vy) + AIrndSign(random(Level)); |
526 ap.Power:= 1; |
526 ap.Power:= 1; |
527 ap.ExplR:= 100; |
527 ap.ExplR:= 100; |
528 ap.ExplX:= EX; |
528 ap.ExplX:= EX; |
529 ap.ExplY:= EY; |
529 ap.ExplY:= EY; |
530 valueResult:= Score |
530 TestMortar:= Score |
531 end; |
531 end; |
532 |
|
533 TestMortar:= valueResult; |
|
534 end; |
532 end; |
535 |
533 |
536 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
534 function TestShotgun(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
537 const |
535 const |
538 MIN_RANGE = 80; |
536 MIN_RANGE = 80; |
539 MAX_RANGE = 400; |
537 MAX_RANGE = 400; |
540 var Vx, Vy, x, y: real; |
538 var Vx, Vy, x, y: real; |
541 rx, ry, valueResult: LongInt; |
539 rx, ry, valueResult: LongInt; |
542 range: integer; |
540 range: integer; |
543 begin |
541 begin |
|
542 TestShotgun:= BadTurn; |
544 ap.ExplR:= 0; |
543 ap.ExplR:= 0; |
545 ap.Time:= 0; |
544 ap.Time:= 0; |
546 ap.Power:= 1; |
545 ap.Power:= 1; |
547 x:= hwFloat2Float(Me^.X); |
546 x:= hwFloat2Float(Me^.X); |
548 y:= hwFloat2Float(Me^.Y); |
547 y:= hwFloat2Float(Me^.Y); |
549 range:= Metric(trunc(x), trunc(y), Targ.X, Targ.Y); |
548 range:= Metric(trunc(x), trunc(y), Targ.X, Targ.Y); |
550 if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then |
549 if ( range < MIN_RANGE ) or ( range > MAX_RANGE ) then |
551 exit(BadTurn); |
550 exit; |
552 Vx:= (Targ.X - x) * 1 / 1024; |
551 Vx:= (Targ.X - x) * 1 / 1024; |
553 Vy:= (Targ.Y - y) * 1 / 1024; |
552 Vy:= (Targ.Y - y) * 1 / 1024; |
554 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); |
553 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); |
555 repeat |
554 repeat |
556 x:= x + vX; |
555 x:= x + vX; |
557 y:= y + vY; |
556 y:= y + vY; |
558 rx:= trunc(x); |
557 rx:= trunc(x); |
559 ry:= trunc(y); |
558 ry:= trunc(y); |
560 if TestCollExcludingMe(Me, rx, ry, 2) then |
559 if TestCollExcludingMe(Me, rx, ry, 2) then |
561 begin |
560 begin |
562 x:= x + vX * 8; |
561 x:= x + vX * 8; |
563 y:= y + vY * 8; |
562 y:= y + vY * 8; |
564 valueResult:= RateShotgun(Me, vX, vY, rx, ry); |
563 valueResult:= RateShotgun(Me, vX, vY, rx, ry); |
565 |
564 |
566 if valueResult = 0 then |
565 if valueResult = 0 then |
567 valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64 |
566 valueResult:= - Metric(Targ.X, Targ.Y, rx, ry) div 64 |
568 else |
567 else |
569 dec(valueResult, Level * 4000); |
568 dec(valueResult, Level * 4000); |
570 exit(valueResult * 27 div 20) // 27/20 is reuse bonus |
569 // 27/20 is reuse bonus |
|
570 TestShotgun:= valueResult * 27 div 20; |
|
571 exit |
571 end |
572 end |
572 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 4) |
573 until (Abs(Targ.X - trunc(x)) + Abs(Targ.Y - trunc(y)) < 4) |
573 or (x < 0) |
574 or (x < 0) |
574 or (y < 0) |
575 or (y < 0) |
575 or (trunc(x) > LAND_WIDTH) |
576 or (trunc(x) > LAND_WIDTH) |
589 ap.Time:= 0; |
590 ap.Time:= 0; |
590 ap.Power:= 1; |
591 ap.Power:= 1; |
591 x:= hwFloat2Float(Me^.X); |
592 x:= hwFloat2Float(Me^.X); |
592 y:= hwFloat2Float(Me^.Y); |
593 y:= hwFloat2Float(Me^.Y); |
593 if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 40 then |
594 if Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) < 40 then |
594 exit(BadTurn); |
595 begin |
|
596 TestDesertEagle:= BadTurn; |
|
597 exit; |
|
598 end; |
595 t:= 0.5 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y)); |
599 t:= 0.5 / sqrt(sqr(Targ.X - x)+sqr(Targ.Y-y)); |
596 Vx:= (Targ.X - x) * t; |
600 Vx:= (Targ.X - x) * t; |
597 Vy:= (Targ.Y - y) * t; |
601 Vy:= (Targ.Y - y) * t; |
598 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); |
602 ap.Angle:= DxDy2AttackAnglef(Vx, -Vy); |
599 d:= 0; |
603 d:= 0; |
626 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
630 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
627 var valueResult: LongInt; |
631 var valueResult: LongInt; |
628 x, y: real; |
632 x, y: real; |
629 begin |
633 begin |
630 Level:= Level; // avoid compiler hint |
634 Level:= Level; // avoid compiler hint |
|
635 TestBaseballBat:= BadTurn; |
631 ap.ExplR:= 0; |
636 ap.ExplR:= 0; |
632 x:= hwFloat2Float(Me^.X); |
637 x:= hwFloat2Float(Me^.X); |
633 y:= hwFloat2Float(Me^.Y); |
638 y:= hwFloat2Float(Me^.Y); |
634 if (Level > 2) or (Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) > 25) then |
639 if (Level > 2) or (Abs(trunc(x) - Targ.X) + Abs(trunc(y) - Targ.Y) > 25) then |
635 exit(BadTurn); |
640 exit; |
636 |
641 |
637 ap.Time:= 0; |
642 ap.Time:= 0; |
638 ap.Power:= 1; |
643 ap.Power:= 1; |
639 if (Targ.X) - trunc(x) >= 0 then |
644 if (Targ.X) - trunc(x) >= 0 then |
640 ap.Angle:= cMaxAngle div 4 |
645 ap.Angle:= cMaxAngle div 4 |
668 (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), |
673 (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), |
669 trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX)*0.45, -0.9, 1) = 0) then |
674 trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX)*0.45, -0.9, 1) = 0) then |
670 val1:= Succ(BadTurn) |
675 val1:= Succ(BadTurn) |
671 else |
676 else |
672 val1:= BadTurn; |
677 val1:= BadTurn; |
673 exit(val1) |
678 TestFirePunch:= val1; |
|
679 exit; |
674 end; |
680 end; |
675 (* |
681 (* |
676 For some silly reason, having this enabled w/ the AI |
682 For some silly reason, having this enabled w/ the AI |
677 val1:= 0; |
683 val1:= 0; |
678 for i:= 0 to 4 do |
684 for i:= 0 to 4 do |
716 if TestColl(trunc(x), trunc(y) - 16, 6) |
722 if TestColl(trunc(x), trunc(y) - 16, 6) |
717 and (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX), -0.8, 1) = 0) then |
723 and (RateShove(Me, trunc(x) + 10 * hwSign(Me^.dX), trunc(y) - 40, 30, 30, 40, hwSign(Me^.dX), -0.8, 1) = 0) then |
718 valueResult:= Succ(BadTurn) |
724 valueResult:= Succ(BadTurn) |
719 else |
725 else |
720 valueResult:= BadTurn; |
726 valueResult:= BadTurn; |
721 exit(valueResult) |
727 TestWhip:= valueResult; |
|
728 exit; |
722 end; |
729 end; |
723 |
730 |
724 valueResult:= 0; |
731 valueResult:= 0; |
725 for i:= 0 to 4 do |
732 for i:= 0 to 4 do |
726 valueResult:= valueResult + RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x), |
733 valueResult:= valueResult + RateShove(Me, trunc(x) + 10 * hwSignf(Targ.X - x), |
824 var |
834 var |
825 i, failNum: longword; |
835 i, failNum: longword; |
826 maxTop: longword; |
836 maxTop: longword; |
827 begin |
837 begin |
828 TestTeleport := BadTurn; |
838 TestTeleport := BadTurn; |
829 exit(); |
839 exit; |
830 Level:= Level; // avoid compiler hint |
840 Level:= Level; // avoid compiler hint |
831 //FillBonuses(true, [gtCase]); |
841 //FillBonuses(true, [gtCase]); |
832 if bonuses.Count = 0 then |
842 if bonuses.Count = 0 then |
833 begin |
843 begin |
834 if Me^.Health <= 100 then |
844 if Me^.Health <= 100 then |