707 ap.Time:= 0; |
707 ap.Time:= 0; |
708 ap.Power:= 1; |
708 ap.Power:= 1; |
709 x:= hwRound(Me^.X); |
709 x:= hwRound(Me^.X); |
710 y:= hwRound(Me^.Y); |
710 y:= hwRound(Me^.Y); |
711 |
711 |
712 a:= 0; |
712 a:= cMaxAngle div 2; |
713 valueResult:= 0; |
713 valueResult:= 0; |
714 |
714 |
715 while a <= cMaxAngle div 2 do |
715 while a >= 0 do |
716 begin |
716 begin |
717 dx:= sin(a / cMaxAngle * pi) * 0.5; |
717 dx:= sin(a / cMaxAngle * pi) * 0.5; |
718 dy:= cos(a / cMaxAngle * pi) * 0.5; |
718 dy:= cos(a / cMaxAngle * pi) * 0.5; |
719 |
719 |
720 v1:= RateShove(Me, x - 10, y |
720 v1:= RateShove(Me, x - 10, y + 2 |
721 , 33, 30, 115 |
721 , 32, 30, 115 |
722 , -dx, -dy, trackFall); |
722 , -dx, -dy, trackFall); |
723 v2:= RateShove(Me, x + 10, y |
723 v2:= RateShove(Me, x + 10, y + 2 |
724 , 33, 30, 115 |
724 , 32, 30, 115 |
725 , dx, -dy, trackFall); |
725 , dx, -dy, trackFall); |
726 if (v1 > valueResult) or (v2 > valueResult) then |
726 if (v1 > valueResult) or (v2 > valueResult) then |
727 if (v2 > v1) |
727 if (v2 > v1) |
728 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
728 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
729 begin |
729 begin |
734 begin |
734 begin |
735 ap.Angle:= -a; |
735 ap.Angle:= -a; |
736 valueResult:= v1 |
736 valueResult:= v1 |
737 end; |
737 end; |
738 |
738 |
739 a:= a + 15 + random(cMaxAngle div 16) |
739 a:= a - 15 - random(cMaxAngle div 16) |
740 end; |
740 end; |
741 |
741 |
742 if valueResult <= 0 then |
742 if valueResult <= 0 then |
743 valueResult:= BadTurn; |
743 valueResult:= BadTurn; |
744 |
744 |
745 TestBaseballBat:= valueResult; |
745 TestBaseballBat:= valueResult; |
746 end; |
746 end; |
747 |
747 |
748 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
748 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
749 var valueResult, v1, v2, i: LongInt; |
749 var valueResult, v1, v2, i: LongInt; |
|
750 x, y, trackFall: LongInt; |
|
751 begin |
|
752 if Me^.Hedgehog^.BotLevel = 1 then trackFall:= afTrackFall |
|
753 else trackFall:= 0; |
|
754 Level:= Level; // avoid compiler hint |
|
755 ap.ExplR:= 0; |
|
756 ap.Time:= 0; |
|
757 ap.Power:= 1; |
|
758 x:= hwRound(Me^.X); |
|
759 y:= hwRound(Me^.Y) + 4; |
|
760 |
|
761 v1:= 0; |
|
762 for i:= 0 to 8 do |
|
763 begin |
|
764 v1:= v1 + RateShove(Me, x - 5, y - 10 * i |
|
765 , 19, 30, 40 |
|
766 , -0.45, -0.9, trackFall or afSetSkip); |
|
767 end; |
|
768 v1:= v1 + RateShove(Me, x - 5, y - 90 |
|
769 , 19, 30, 40 |
|
770 , -0.45, -0.9, trackFall); |
|
771 |
|
772 |
|
773 // now try opposite direction |
|
774 v2:= 0; |
|
775 for i:= 0 to 8 do |
|
776 begin |
|
777 v2:= v2 + RateShove(Me, x + 5, y - 10 * i |
|
778 , 19, 30, 40 |
|
779 , 0.45, -0.9, trackFall or afSetSkip); |
|
780 end; |
|
781 v2:= v2 + RateShove(Me, x + 5, y - 90 |
|
782 , 19, 30, 40 |
|
783 , 0.45, -0.9, trackFall); |
|
784 |
|
785 if (v2 > v1) |
|
786 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
|
787 begin |
|
788 ap.Angle:= 1; |
|
789 valueResult:= v2 |
|
790 end |
|
791 else |
|
792 begin |
|
793 ap.Angle:= -1; |
|
794 valueResult:= v1 |
|
795 end; |
|
796 |
|
797 if valueResult <= 0 then |
|
798 valueResult:= BadTurn; |
|
799 |
|
800 TestFirePunch:= valueResult; |
|
801 end; |
|
802 |
|
803 |
|
804 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
|
805 var valueResult, v1, v2: LongInt; |
750 x, y, trackFall: LongInt; |
806 x, y, trackFall: LongInt; |
751 begin |
807 begin |
752 if Me^.Hedgehog^.BotLevel = 1 then trackFall:= afTrackFall |
808 if Me^.Hedgehog^.BotLevel = 1 then trackFall:= afTrackFall |
753 else trackFall:= 0; |
809 else trackFall:= 0; |
754 Level:= Level; // avoid compiler hint |
810 Level:= Level; // avoid compiler hint |
756 ap.Time:= 0; |
812 ap.Time:= 0; |
757 ap.Power:= 1; |
813 ap.Power:= 1; |
758 x:= hwRound(Me^.X); |
814 x:= hwRound(Me^.X); |
759 y:= hwRound(Me^.Y); |
815 y:= hwRound(Me^.Y); |
760 |
816 |
761 v1:= 0; |
|
762 for i:= 0 to 8 do |
|
763 begin |
|
764 v1:= v1 + RateShove(Me, x - 10, y - 10 * i |
|
765 , 18, 30, 40 |
|
766 , -0.45, -0.9, trackFall or afSetSkip); |
|
767 end; |
|
768 v1:= v1 + RateShove(Me, x - 10, y - 90 |
|
769 , 18, 30, 40 |
|
770 , -0.45, -0.9, trackFall); |
|
771 |
|
772 |
|
773 // now try opposite direction |
|
774 v2:= 0; |
|
775 for i:= 0 to 8 do |
|
776 begin |
|
777 v2:= v2 + RateShove(Me, x + 10, y - 10 * i |
|
778 , 18, 30, 40 |
|
779 , 0.45, -0.9, trackFall or afSetSkip); |
|
780 end; |
|
781 v2:= v2 + RateShove(Me, x + 10, y - 90 |
|
782 , 18, 30, 40 |
|
783 , 0.45, -0.9, trackFall); |
|
784 |
|
785 if (v2 > v1) |
|
786 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
|
787 begin |
|
788 ap.Angle:= 1; |
|
789 valueResult:= v2 |
|
790 end |
|
791 else |
|
792 begin |
|
793 ap.Angle:= -1; |
|
794 valueResult:= v1 |
|
795 end; |
|
796 |
|
797 if valueResult <= 0 then |
|
798 valueResult:= BadTurn; |
|
799 |
|
800 TestFirePunch:= valueResult; |
|
801 end; |
|
802 |
|
803 |
|
804 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
|
805 var valueResult, v1, v2: LongInt; |
|
806 x, y, trackFall: LongInt; |
|
807 begin |
|
808 if Me^.Hedgehog^.BotLevel = 1 then trackFall:= afTrackFall |
|
809 else trackFall:= 0; |
|
810 Level:= Level; // avoid compiler hint |
|
811 ap.ExplR:= 0; |
|
812 ap.Time:= 0; |
|
813 ap.Power:= 1; |
|
814 x:= hwRound(Me^.X); |
|
815 y:= hwRound(Me^.Y); |
|
816 |
|
817 // check left direction |
817 // check left direction |
818 {first RateShove checks farthermost of two whip's AmmoShove attacks |
818 {first RateShove checks farthermost of two whip's AmmoShove attacks |
819 to encourage distant attacks (damaged hog is excluded from view of second |
819 to encourage distant attacks (damaged hog is excluded from view of second |
820 RateShove call)} |
820 RateShove call)} |
821 v1:= RateShove(Me, x - 15, y |
821 v1:= RateShove(Me, x - 13, y |
822 , 30, 30, 25 |
822 , 30, 30, 25 |
823 , -1, -0.8, trackFall or afSetSkip); |
823 , -1, -0.8, trackFall or afSetSkip); |
824 v1:= v1 + |
824 v1:= v1 + |
825 RateShove(Me, x, y |
825 RateShove(Me, x, y |
826 , 30, 30, 25 |
826 , 30, 30, 25 |
827 , -1, -0.8, trackFall); |
827 , -1, -0.8, trackFall); |
828 // now try opposite direction |
828 // now try opposite direction |
829 v2:= RateShove(Me, x + 15, y |
829 v2:= RateShove(Me, x + 13, y |
830 , 30, 30, 25 |
830 , 30, 30, 25 |
831 , 1, -0.8, trackFall or afSetSkip); |
831 , 1, -0.8, trackFall or afSetSkip); |
832 v2:= v2 + |
832 v2:= v2 + |
833 RateShove(Me, x, y |
833 RateShove(Me, x, y |
834 , 30, 30, 25 |
834 , 30, 30, 25 |