225 until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or |
225 until (((Me = CurrentHedgehog^.Gear) and TestColl(trunc(x), trunc(y), 5)) or |
226 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0); |
226 ((Me <> CurrentHedgehog^.Gear) and TestCollExcludingMe(Me, trunc(x), trunc(y), 5))) or (t <= 0); |
227 EX:= trunc(x); |
227 EX:= trunc(x); |
228 EY:= trunc(y); |
228 EY:= trunc(y); |
229 |
229 |
230 value:= RateShove(Me, trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, afTrackFall); |
230 value:= RateShove(trunc(x), trunc(y), 5, 1, trunc((abs(dX)+abs(dY))*20), -dX, -dY, afTrackFall); |
231 if value = 0 then |
231 if value = 0 then |
232 value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; |
232 value:= - Metric(Targ.X, Targ.Y, EX, EY) div 64; |
233 |
233 |
234 if valueResult <= value then |
234 if valueResult <= value then |
235 begin |
235 begin |
647 |
647 |
648 |
648 |
649 function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
649 function TestSniperRifle(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
650 var Vx, Vy, x, y, t, dmg, dmgMod: real; |
650 var Vx, Vy, x, y, t, dmg, dmgMod: real; |
651 d: Longword; |
651 d: Longword; |
652 fallDmg, valueResult: LongInt; |
652 fallDmg: LongInt; |
653 begin |
653 begin |
654 if Level > 3 then exit(BadTurn); |
654 if Level > 3 then exit(BadTurn); |
655 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; |
655 dmgMod:= 0.01 * hwFloat2Float(cDamageModifier) * cDamagePercent; |
656 Level:= Level; // avoid compiler hint |
656 Level:= Level; // avoid compiler hint |
657 ap.ExplR:= 0; |
657 ap.ExplR:= 0; |
699 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
699 function TestBaseballBat(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
700 var valueResult, a, v1, v2: LongInt; |
700 var valueResult, a, v1, v2: LongInt; |
701 x, y, trackFall: LongInt; |
701 x, y, trackFall: LongInt; |
702 dx, dy: real; |
702 dx, dy: real; |
703 begin |
703 begin |
|
704 Targ:= Targ; // avoid compiler hint |
|
705 |
704 if Level < 3 then trackFall:= afTrackFall |
706 if Level < 3 then trackFall:= afTrackFall |
705 else trackFall:= 0; |
707 else trackFall:= 0; |
706 |
708 |
707 ap.ExplR:= 0; |
709 ap.ExplR:= 0; |
708 ap.Time:= 0; |
710 ap.Time:= 0; |
716 while a >= 0 do |
718 while a >= 0 do |
717 begin |
719 begin |
718 dx:= sin(a / cMaxAngle * pi) * 0.5; |
720 dx:= sin(a / cMaxAngle * pi) * 0.5; |
719 dy:= cos(a / cMaxAngle * pi) * 0.5; |
721 dy:= cos(a / cMaxAngle * pi) * 0.5; |
720 |
722 |
721 v1:= RateShove(Me, x - 10, y + 2 |
723 v1:= RateShove(x - 10, y + 2 |
722 , 32, 30, 115 |
724 , 32, 30, 115 |
723 , -dx, -dy, trackFall); |
725 , -dx, -dy, trackFall); |
724 v2:= RateShove(Me, x + 10, y + 2 |
726 v2:= RateShove(x + 10, y + 2 |
725 , 32, 30, 115 |
727 , 32, 30, 115 |
726 , dx, -dy, trackFall); |
728 , dx, -dy, trackFall); |
727 if (v1 > valueResult) or (v2 > valueResult) then |
729 if (v1 > valueResult) or (v2 > valueResult) then |
728 if (v2 > v1) |
730 if (v2 > v1) |
729 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
731 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
748 |
750 |
749 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
751 function TestFirePunch(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
750 var valueResult, v1, v2, i: LongInt; |
752 var valueResult, v1, v2, i: LongInt; |
751 x, y, trackFall: LongInt; |
753 x, y, trackFall: LongInt; |
752 begin |
754 begin |
|
755 Targ:= Targ; // avoid compiler hint |
|
756 |
753 if Level = 1 then trackFall:= afTrackFall |
757 if Level = 1 then trackFall:= afTrackFall |
754 else trackFall:= 0; |
758 else trackFall:= 0; |
755 |
759 |
756 ap.ExplR:= 0; |
760 ap.ExplR:= 0; |
757 ap.Time:= 0; |
761 ap.Time:= 0; |
760 y:= hwRound(Me^.Y) + 4; |
764 y:= hwRound(Me^.Y) + 4; |
761 |
765 |
762 v1:= 0; |
766 v1:= 0; |
763 for i:= 0 to 8 do |
767 for i:= 0 to 8 do |
764 begin |
768 begin |
765 v1:= v1 + RateShove(Me, x - 5, y - 10 * i |
769 v1:= v1 + RateShove(x - 5, y - 10 * i |
766 , 19, 30, 40 |
770 , 19, 30, 40 |
767 , -0.45, -0.9, trackFall or afSetSkip); |
771 , -0.45, -0.9, trackFall or afSetSkip); |
768 end; |
772 end; |
769 v1:= v1 + RateShove(Me, x - 5, y - 90 |
773 v1:= v1 + RateShove(x - 5, y - 90 |
770 , 19, 30, 40 |
774 , 19, 30, 40 |
771 , -0.45, -0.9, trackFall); |
775 , -0.45, -0.9, trackFall); |
772 |
776 |
773 |
777 |
774 // now try opposite direction |
778 // now try opposite direction |
775 v2:= 0; |
779 v2:= 0; |
776 for i:= 0 to 8 do |
780 for i:= 0 to 8 do |
777 begin |
781 begin |
778 v2:= v2 + RateShove(Me, x + 5, y - 10 * i |
782 v2:= v2 + RateShove(x + 5, y - 10 * i |
779 , 19, 30, 40 |
783 , 19, 30, 40 |
780 , 0.45, -0.9, trackFall or afSetSkip); |
784 , 0.45, -0.9, trackFall or afSetSkip); |
781 end; |
785 end; |
782 v2:= v2 + RateShove(Me, x + 5, y - 90 |
786 v2:= v2 + RateShove(x + 5, y - 90 |
783 , 19, 30, 40 |
787 , 19, 30, 40 |
784 , 0.45, -0.9, trackFall); |
788 , 0.45, -0.9, trackFall); |
785 |
789 |
786 if (v2 > v1) |
790 if (v2 > v1) |
787 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
791 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
804 |
808 |
805 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
809 function TestWhip(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
806 var valueResult, v1, v2: LongInt; |
810 var valueResult, v1, v2: LongInt; |
807 x, y, trackFall: LongInt; |
811 x, y, trackFall: LongInt; |
808 begin |
812 begin |
|
813 Targ:= Targ; // avoid compiler hint |
|
814 |
809 if Level = 1 then trackFall:= afTrackFall |
815 if Level = 1 then trackFall:= afTrackFall |
810 else trackFall:= 0; |
816 else trackFall:= 0; |
811 |
817 |
812 ap.ExplR:= 0; |
818 ap.ExplR:= 0; |
813 ap.Time:= 0; |
819 ap.Time:= 0; |
817 |
823 |
818 // check left direction |
824 // check left direction |
819 {first RateShove checks farthermost of two whip's AmmoShove attacks |
825 {first RateShove checks farthermost of two whip's AmmoShove attacks |
820 to encourage distant attacks (damaged hog is excluded from view of second |
826 to encourage distant attacks (damaged hog is excluded from view of second |
821 RateShove call)} |
827 RateShove call)} |
822 v1:= RateShove(Me, x - 13, y |
828 v1:= RateShove(x - 13, y |
823 , 30, 30, 25 |
829 , 30, 30, 25 |
824 , -1, -0.8, trackFall or afSetSkip); |
830 , -1, -0.8, trackFall or afSetSkip); |
825 v1:= v1 + |
831 v1:= v1 + |
826 RateShove(Me, x - 2, y |
832 RateShove(x - 2, y |
827 , 30, 30, 25 |
833 , 30, 30, 25 |
828 , -1, -0.8, trackFall); |
834 , -1, -0.8, trackFall); |
829 // now try opposite direction |
835 // now try opposite direction |
830 v2:= RateShove(Me, x + 13, y |
836 v2:= RateShove(x + 13, y |
831 , 30, 30, 25 |
837 , 30, 30, 25 |
832 , 1, -0.8, trackFall or afSetSkip); |
838 , 1, -0.8, trackFall or afSetSkip); |
833 v2:= v2 + |
839 v2:= v2 + |
834 RateShove(Me, x + 2, y |
840 RateShove(x + 2, y |
835 , 30, 30, 25 |
841 , 30, 30, 25 |
836 , 1, -0.8, trackFall); |
842 , 1, -0.8, trackFall); |
837 |
843 |
838 if (v2 > v1) |
844 if (v2 > v1) |
839 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
845 or {don't encourage turning for no gain}((v2 = v1) and (not Me^.dX.isNegative)) then |
896 if dx >= 0 then cx:= 0.45 else cx:= -0.45; |
902 if dx >= 0 then cx:= 0.45 else cx:= -0.45; |
897 |
903 |
898 for i:= 0 to 512 div step - 2 do |
904 for i:= 0 to 512 div step - 2 do |
899 begin |
905 begin |
900 valueResult:= valueResult + |
906 valueResult:= valueResult + |
901 RateShove(Me, trunc(x), trunc(y) |
907 RateShove(trunc(x), trunc(y) |
902 , 30, 30, 25 |
908 , 30, 30, 25 |
903 , cx, -0.9, trackFall or afSetSkip); |
909 , cx, -0.9, trackFall or afSetSkip); |
904 |
910 |
905 x:= x + dx; |
911 x:= x + dx; |
906 y:= y + dy; |
912 y:= y + dy; |
908 if dx = 0 then |
914 if dx = 0 then |
909 begin |
915 begin |
910 x:= hwFloat2Float(Me^.X); |
916 x:= hwFloat2Float(Me^.X); |
911 y:= hwFloat2Float(Me^.Y); |
917 y:= hwFloat2Float(Me^.Y); |
912 tx:= trunc(x); |
918 tx:= trunc(x); |
913 v:= RateShove(Me, tx, trunc(y) |
919 v:= RateShove(tx, trunc(y) |
914 , 30, 30, 25 |
920 , 30, 30, 25 |
915 , -cx, -0.9, trackFall); |
921 , -cx, -0.9, trackFall); |
916 for i:= 1 to 512 div step - 2 do |
922 for i:= 1 to 512 div step - 2 do |
917 begin |
923 begin |
918 y:= y + dy; |
924 y:= y + dy; |
919 v:= v + |
925 v:= v + |
920 RateShove(Me, tx, trunc(y) |
926 RateShove(tx, trunc(y) |
921 , 30, 30, 25 |
927 , 30, 30, 25 |
922 , -cx, -0.9, trackFall or afSetSkip); |
928 , -cx, -0.9, trackFall or afSetSkip); |
923 end |
929 end |
924 end; |
930 end; |
925 if v > valueResult then |
931 if v > valueResult then |
926 begin |
932 begin |
927 ap.Angle:= -2048; |
933 ap.Angle:= -2048; |
928 valueResult:= v |
934 valueResult:= v |
929 end; |
935 end; |
930 |
936 |
931 v:= RateShove(Me, trunc(x), trunc(y) |
937 v:= RateShove(trunc(x), trunc(y) |
932 , 30, 30, 25 |
938 , 30, 30, 25 |
933 , cx, -0.9, trackFall); |
939 , cx, -0.9, trackFall); |
934 valueResult:= valueResult + v - KillScore * friendlyfactor div 100 * 1024; |
940 valueResult:= valueResult + v - KillScore * friendlyfactor div 100 * 1024; |
935 |
941 |
936 if v < 65536 then |
942 if v < 65536 then |
937 inc(valueResult, RateExplosion(Me, trunc(x), trunc(y), 30)); |
943 inc(valueResult, RateExplosion(Me, trunc(x), trunc(y), 30)); |
938 |
944 |
939 TestKamikaze:= valueResult; |
945 TestKamikaze:= valueResult; |
940 end; |
946 end; |
941 |
947 |
942 function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
948 function TestHammer(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
943 var rate: LongInt; |
949 var rate: LongInt; |
944 begin |
950 begin |
945 Level:= Level; // avoid compiler hint |
951 Level:= Level; // avoid compiler hint |
|
952 Targ:= Targ; |
|
953 |
946 ap.ExplR:= 0; |
954 ap.ExplR:= 0; |
947 ap.Time:= 0; |
955 ap.Time:= 0; |
948 ap.Power:= 1; |
956 ap.Power:= 1; |
949 ap.Angle:= 0; |
957 ap.Angle:= 0; |
950 |
958 |
1088 end; |
1096 end; |
1089 end; |
1097 end; |
1090 |
1098 |
1091 function TestCake(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
1099 function TestCake(Me: PGear; Targ: TPoint; Level: LongInt; var ap: TAttackParams): LongInt; |
1092 var valueResult, v1, v2: LongInt; |
1100 var valueResult, v1, v2: LongInt; |
1093 x, y, trackFall: LongInt; |
|
1094 cake: TGear; |
1101 cake: TGear; |
1095 begin |
1102 begin |
|
1103 Targ:= Targ; // avoid compiler hint |
|
1104 |
1096 if (Level > 2) then |
1105 if (Level > 2) then |
1097 exit(BadTurn); |
1106 exit(BadTurn); |
|
1107 |
1098 ap.ExplR:= 0; |
1108 ap.ExplR:= 0; |
1099 ap.Time:= 0; |
1109 ap.Time:= 0; |
1100 ap.Power:= BadTurn; // use it as max score value in checkCakeWalk |
1110 ap.Power:= BadTurn; // use it as max score value in checkCakeWalk |
1101 |
1111 |
1102 FillChar(cake, sizeof(cake), 0); |
1112 FillChar(cake, sizeof(cake), 0); |