150 |
150 |
151 implementation |
151 implementation |
152 uses uConsts, uVariables, uVisualGearsList, uRandom, uCollisions, uGearsList, uUtils, uSound |
152 uses uConsts, uVariables, uVisualGearsList, uRandom, uCollisions, uGearsList, uUtils, uSound |
153 , SDLh, uScript, uGearsHedgehog, uGearsUtils, uIO, uCaptions, uLandGraphics |
153 , SDLh, uScript, uGearsHedgehog, uGearsUtils, uIO, uCaptions, uLandGraphics |
154 , uGearsHandlers, uTextures, uRenderUtils, uAmmos, uTeams, uLandTexture |
154 , uGearsHandlers, uTextures, uRenderUtils, uAmmos, uTeams, uLandTexture |
155 , uStore, uAI, uStats, uLocale; |
155 , uStore, uAI, uStats, uLocale, uLandUtils; |
156 |
156 |
157 procedure doStepPerPixel(Gear: PGear; step: TGearStepProcedure; onlyCheckIfChanged: boolean); |
157 procedure doStepPerPixel(Gear: PGear; step: TGearStepProcedure; onlyCheckIfChanged: boolean); |
158 var |
158 var |
159 dX, dY, sX, sY: hwFloat; |
159 dX, dY, sX, sY: hwFloat; |
160 i, steps: LongWord; |
160 i, steps: LongWord; |
525 Gear^.dX.isNegative := true; |
525 Gear^.dX.isNegative := true; |
526 Gear^.dY.isNegative := false |
526 Gear^.dY.isNegative := false |
527 end |
527 end |
528 else if (collV < 0) and (collH < 0) and tdX.isNegative and tdY.isNegative then |
528 else if (collV < 0) and (collH < 0) and tdX.isNegative and tdY.isNegative then |
529 Gear^.dX.isNegative := false; |
529 Gear^.dX.isNegative := false; |
530 |
530 |
531 isFalling := false; |
531 isFalling := false; |
532 Gear^.AdvBounce := 10; |
532 Gear^.AdvBounce := 10; |
533 end; |
533 end; |
534 |
534 |
535 if Gear^.AdvBounce > 1 then |
535 if Gear^.AdvBounce > 1 then |
881 else if (xx > snowRight) or (xx < snowLeft) then |
881 else if (xx > snowRight) or (xx < snowLeft) then |
882 move:=true |
882 move:=true |
883 else if (cGravity.isNegative) and (yy < LAND_HEIGHT-1200) then |
883 else if (cGravity.isNegative) and (yy < LAND_HEIGHT-1200) then |
884 move:=true |
884 move:=true |
885 // Solid pixel encountered |
885 // Solid pixel encountered |
886 else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (Land[yy, xx] <> 0) then |
886 else if ((yy and LAND_HEIGHT_MASK) = 0) and ((xx and LAND_WIDTH_MASK) = 0) and (LandGet(yy, xx) <> 0) then |
887 begin |
887 begin |
888 lf:= Land[yy, xx] and (lfObject or lfBasic or lfIndestructible); |
888 lf:= LandGet(yy, xx) and (lfObject or lfBasic or lfIndestructible); |
889 if lf = 0 then lf:= lfObject; |
889 if lf = 0 then lf:= lfObject; |
890 // If there's room below keep falling |
890 // If there's room below keep falling |
891 if (((yy-1) and LAND_HEIGHT_MASK) = 0) and (Land[yy-1, xx] = 0) then |
891 if (((yy-1) and LAND_HEIGHT_MASK) = 0) and (LandGet(yy-1, xx) = 0) then |
892 begin |
892 begin |
893 X:= X - cWindSpeed * 1600 - dX; |
893 X:= X - cWindSpeed * 1600 - dX; |
894 end |
894 end |
895 // If there's room below, on the sides, fill the gaps |
895 // If there's room below, on the sides, fill the gaps |
896 else if (((yy-1) and LAND_HEIGHT_MASK) = 0) then |
896 else if (((yy-1) and LAND_HEIGHT_MASK) = 0) then |
897 begin |
897 begin |
898 if (((xx - 1) and LAND_WIDTH_MASK) = 0) and (Land[yy - 1, (xx - 1)] = 0) then |
898 if (((xx - 1) and LAND_WIDTH_MASK) = 0) and (LandGet(yy - 1, (xx - 1)) = 0) then |
899 begin |
899 begin |
900 X:= X - _0_8; |
900 X:= X - _0_8; |
901 Y:= oldY; |
901 Y:= oldY; |
902 end |
902 end |
903 else if (((xx - 2) and LAND_WIDTH_MASK) = 0) and (Land[yy - 1, (xx - 2)] = 0) then |
903 else if (((xx - 2) and LAND_WIDTH_MASK) = 0) and (LandGet(yy - 1, (xx - 2)) = 0) then |
904 begin |
904 begin |
905 X:= X - _1_6; |
905 X:= X - _1_6; |
906 Y:= oldY; |
906 Y:= oldY; |
907 end |
907 end |
908 else if (((xx + 1) and LAND_WIDTH_MASK) = 0) and (Land[yy - 1, (xx + 1)] = 0) then |
908 else if (((xx + 1) and LAND_WIDTH_MASK) = 0) and (LandGet(yy - 1, (xx + 1)) = 0) then |
909 begin |
909 begin |
910 X:= X + _0_8; |
910 X:= X + _0_8; |
911 Y:= oldY; |
911 Y:= oldY; |
912 end |
912 end |
913 else if (((xx + 2) and LAND_WIDTH_MASK) = 0) and (Land[yy - 1, (xx + 2)] = 0) then |
913 else if (((xx + 2) and LAND_WIDTH_MASK) = 0) and (LandGet(yy - 1, (xx + 2)) = 0) then |
914 begin |
914 begin |
915 X:= X + _1_6; |
915 X:= X + _1_6; |
916 Y:= oldY; |
916 Y:= oldY; |
917 end else |
917 end else |
918 if ((((yy+1) and LAND_HEIGHT_MASK) = 0) and ((Land[yy + 1, xx] and $FF) <> 0)) then |
918 if ((((yy+1) and LAND_HEIGHT_MASK) = 0) and ((LandGet(yy + 1, xx) and $FF) <> 0)) then |
919 move:=true |
919 move:=true |
920 else |
920 else |
921 draw:= true |
921 draw:= true |
922 end |
922 end |
923 // if there's an hog/object below do nothing |
923 // if there's an hog/object below do nothing |
924 else if ((((yy+1) and LAND_HEIGHT_MASK) = 0) and ((Land[yy+1, xx] and $FF) <> 0)) |
924 else if ((((yy+1) and LAND_HEIGHT_MASK) = 0) and ((LandGet(yy+1, xx) and $FF) <> 0)) |
925 then move:=true |
925 then move:=true |
926 else draw:= true |
926 else draw:= true |
927 end |
927 end |
928 end; |
928 end; |
929 |
929 |
946 for py:= 0 to Pred(s^.h) do |
946 for py:= 0 to Pred(s^.h) do |
947 begin |
947 begin |
948 for px:= 0 to Pred(s^.w) do |
948 for px:= 0 to Pred(s^.w) do |
949 begin |
949 begin |
950 lx:=xx + px; ly:=yy + py; |
950 lx:=xx + px; ly:=yy + py; |
951 if (ly and LAND_HEIGHT_MASK = 0) and (lx and LAND_WIDTH_MASK = 0) and (Land[ly, lx] and $FF = 0) then |
951 if (ly and LAND_HEIGHT_MASK = 0) and (lx and LAND_WIDTH_MASK = 0) and (LandGet(ly, lx) and $FF = 0) then |
952 begin |
952 begin |
953 rx:= lx; |
953 rx:= lx; |
954 ry:= ly; |
954 ry:= ly; |
955 if cReducedQuality and rqBlurryLand <> 0 then |
955 if cReducedQuality and rqBlurryLand <> 0 then |
956 begin |
956 begin |
957 rx:= rx div 2;ry:= ry div 2; |
957 rx:= rx div 2;ry:= ry div 2; |
958 end; |
958 end; |
959 if Land[yy + py, xx + px] <= lfAllObjMask then |
959 if LandGet(yy + py, xx + px) <= lfAllObjMask then |
960 if gun then |
960 if gun then |
961 begin |
961 begin |
962 LandDirty[yy div 32, xx div 32]:= 1; |
962 LandDirty[yy div 32, xx div 32]:= 1; |
963 if LandPixels[ry, rx] = 0 then |
963 if LandPixels[ry, rx] = 0 then |
964 Land[ly, lx]:= lfDamaged or lfObject |
964 LandSet(ly, lx, lfDamaged or lfObject) |
965 else Land[ly, lx]:= lfDamaged or lfBasic |
965 else LandSet(ly, lx, lfDamaged or lfBasic) |
966 end |
966 end |
967 else Land[ly, lx]:= lf; |
967 else LandSet(ly, lx, lf); |
968 if gun then |
968 if gun then |
969 LandPixels[ry, rx]:= (Gear^.Tint shr 24 shl RShift) or |
969 LandPixels[ry, rx]:= (Gear^.Tint shr 24 shl RShift) or |
970 (Gear^.Tint shr 16 and $FF shl GShift) or |
970 (Gear^.Tint shr 16 and $FF shl GShift) or |
971 (Gear^.Tint shr 8 and $FF shl BShift) or |
971 (Gear^.Tint shr 8 and $FF shl BShift) or |
972 (p^[px] and AMask) |
972 (p^[px] and AMask) |
973 else LandPixels[ry, rx]:= addBgColor(LandPixels[ry, rx], p^[px]); |
973 else LandPixels[ry, rx]:= addBgColor(LandPixels[ry, rx], p^[px]); |
974 end |
974 end |
975 else allpx:= false |
975 else allpx:= false |
976 end; |
976 end; |
1517 x := hwRound(Gear^.X); |
1517 x := hwRound(Gear^.X); |
1518 y := hwRound(Gear^.Y); |
1518 y := hwRound(Gear^.Y); |
1519 |
1519 |
1520 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then |
1520 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) then |
1521 begin |
1521 begin |
1522 LandFlags:= Land[y, x]; |
1522 LandFlags:= LandGet(y, x); |
1523 if LandFlags <> 0 then inc(Gear^.Damage); |
1523 if LandFlags <> 0 then inc(Gear^.Damage); |
1524 isDigging:= (LandFlags and lfLandMask) <> 0; |
1524 isDigging:= (LandFlags and lfLandMask) <> 0; |
1525 end; |
1525 end; |
1526 // let's interrupt before a collision with land to give portals a chance to catch the bullet |
1526 // let's interrupt before a collision with land to give portals a chance to catch the bullet |
1527 if isDigging and (Gear^.Tag = 0) then |
1527 if isDigging and (Gear^.Tag = 0) then |
1759 end; |
1759 end; |
1760 |
1760 |
1761 if (Gear^.Timer mod 47) = 0 then |
1761 if (Gear^.Timer mod 47) = 0 then |
1762 begin |
1762 begin |
1763 // ok. this was an attempt to turn off dust if not actually drilling land. I have no idea why it isn't working as expected |
1763 // ok. this was an attempt to turn off dust if not actually drilling land. I have no idea why it isn't working as expected |
1764 if (( (y + 12) and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y + 12, x] > 255) then |
1764 if (( (y + 12) and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (LandGet(y + 12, x) > 255) then |
1765 for i:= 0 to 1 do |
1765 for i:= 0 to 1 do |
1766 AddVisualGear(x - 5 + Random(10), y + 12, vgtDust); |
1766 AddVisualGear(x - 5 + Random(10), y + 12, vgtDust); |
1767 |
1767 |
1768 i := x - Gear^.Radius - LongInt(GetRandom(2)); |
1768 i := x - Gear^.Radius - LongInt(GetRandom(2)); |
1769 ei := x + Gear^.Radius + LongInt(GetRandom(2)); |
1769 ei := x + Gear^.Radius + LongInt(GetRandom(2)); |
2191 targ:= nil |
2191 targ:= nil |
2192 end; |
2192 end; |
2193 |
2193 |
2194 // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) |
2194 // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) |
2195 // or hunting is disabled due to seek radius of 0 then we aren't hunting |
2195 // or hunting is disabled due to seek radius of 0 then we aren't hunting |
2196 if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or |
2196 if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or |
2197 ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or |
2197 ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or |
2198 (Gear^.Angle = 0) then |
2198 (Gear^.Angle = 0) then |
2199 gear^.State:= gear^.State and (not gstChooseTarget) |
2199 gear^.State:= gear^.State and (not gstChooseTarget) |
2200 else if |
2200 else if |
2201 // todo, allow not finding new target, set timeout on target retention |
2201 // todo, allow not finding new target, set timeout on target retention |
4243 inc(leftX); |
4243 inc(leftX); |
4244 dec(rightX); |
4244 dec(rightX); |
4245 dec(playWidth, 2); |
4245 dec(playWidth, 2); |
4246 for i:= 0 to LAND_HEIGHT - 1 do |
4246 for i:= 0 to LAND_HEIGHT - 1 do |
4247 begin |
4247 begin |
4248 Land[i, leftX] := 0; |
4248 LandSet(i, leftX, 0); |
4249 Land[i, rightX] := 0; |
4249 LandSet(i, rightX, 0); |
4250 end; |
4250 end; |
4251 end; |
4251 end; |
4252 |
4252 |
4253 if cWaterLine > 0 then |
4253 if cWaterLine > 0 then |
4254 begin |
4254 begin |
4255 dec(cWaterLine); |
4255 dec(cWaterLine); |
4256 for i:= 0 to LAND_WIDTH - 1 do |
4256 for i:= 0 to LAND_WIDTH - 1 do |
4257 Land[cWaterLine, i] := 0; |
4257 LandSet(cWaterLine, i, 0); |
4258 SetAllToActive |
4258 SetAllToActive |
4259 end; |
4259 end; |
4260 |
4260 |
4261 dec(Gear^.Tag); |
4261 dec(Gear^.Tag); |
4262 end; |
4262 end; |
5036 hasdxy, isbullet, iscake, isCollision: Boolean; |
5036 hasdxy, isbullet, iscake, isCollision: Boolean; |
5037 begin |
5037 begin |
5038 doPortalColorSwitch(); |
5038 doPortalColorSwitch(); |
5039 |
5039 |
5040 // destroy portal if ground it was attached too is gone |
5040 // destroy portal if ground it was attached too is gone |
5041 if (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] <= lfAllObjMask) |
5041 if (LandGet(hwRound(Gear^.Y), hwRound(Gear^.X)) <= lfAllObjMask) |
5042 or (Land[hwRound(Gear^.Y), hwRound(Gear^.X)] and lfBouncy <> 0) |
5042 or (LandGet(hwRound(Gear^.Y), hwRound(Gear^.X)) and lfBouncy <> 0) |
5043 or (Gear^.Timer < 1) |
5043 or (Gear^.Timer < 1) |
5044 or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team) |
5044 or (Gear^.Hedgehog^.Team <> CurrentHedgehog^.Team) |
5045 or CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then |
5045 or CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then |
5046 begin |
5046 begin |
5047 deleteGear(Gear); |
5047 deleteGear(Gear); |
5404 y := hwRound(Gear^.Y); |
5404 y := hwRound(Gear^.Y); |
5405 tx := 0; |
5405 tx := 0; |
5406 ty := 0; |
5406 ty := 0; |
5407 // avoid compiler hints |
5407 // avoid compiler hints |
5408 |
5408 |
5409 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (Land[y, x] > 255) then |
5409 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) and (LandGet(y, x) > 255) then |
5410 begin |
5410 begin |
5411 Gear^.State := Gear^.State or gstCollision; |
5411 Gear^.State := Gear^.State or gstCollision; |
5412 Gear^.State := Gear^.State and (not gstMoving); |
5412 Gear^.State := Gear^.State and (not gstMoving); |
5413 |
5413 |
5414 if (Land[y, x] and lfBouncy <> 0) |
5414 if (LandGet(y, x) and lfBouncy <> 0) |
5415 or (not CalcSlopeTangent(Gear, x, y, tx, ty, 255)) |
5415 or (not CalcSlopeTangent(Gear, x, y, tx, ty, 255)) |
5416 or (DistanceI(tx,ty) < _12) then // reject shots at too irregular terrain |
5416 or (DistanceI(tx,ty) < _12) then // reject shots at too irregular terrain |
5417 begin |
5417 begin |
5418 loadNewPortalBall(Gear, true); |
5418 loadNewPortalBall(Gear, true); |
5419 EXIT; |
5419 EXIT; |
5770 else |
5770 else |
5771 begin |
5771 begin |
5772 if (not CheckCoordInWater(rX, rY)) or (not CheckCoordInWater(x, y)) then |
5772 if (not CheckCoordInWater(rX, rY)) or (not CheckCoordInWater(x, y)) then |
5773 begin |
5773 begin |
5774 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) |
5774 if ((y and LAND_HEIGHT_MASK) = 0) and ((x and LAND_WIDTH_MASK) = 0) |
5775 and (Land[y, x] <> 0) then |
5775 and (LandGet(y, x) <> 0) then |
5776 begin |
5776 begin |
5777 if ((GameFlags and gfSolidLand) <> 0) and (Land[y, x] > 255) then |
5777 if ((GameFlags and gfSolidLand) <> 0) and (LandGet(y, x) > 255) then |
5778 Gear^.Damage := initHealth |
5778 Gear^.Damage := initHealth |
5779 else if justCollided then |
5779 else if justCollided then |
5780 begin |
5780 begin |
5781 Gear^.Damage := initHealth; |
5781 Gear^.Damage := initHealth; |
5782 end |
5782 end |
6650 HedgehogChAngle(HHGear); |
6650 HedgehogChAngle(HHGear); |
6651 ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _4; |
6651 ndX:= SignAs(AngleSin(HHGear^.Angle), HHGear^.dX) * _4; |
6652 ndY:= -AngleCos(HHGear^.Angle) * _4; |
6652 ndY:= -AngleCos(HHGear^.Angle) * _4; |
6653 if (ndX <> dX) or (ndY <> dY) or (Gear^.Message and (gmUp or gmDown) <> 0) or |
6653 if (ndX <> dX) or (ndY <> dY) or (Gear^.Message and (gmUp or gmDown) <> 0) or |
6654 (((Target.X <> NoPointX) and (Target.X and LAND_WIDTH_MASK = 0) and |
6654 (((Target.X <> NoPointX) and (Target.X and LAND_WIDTH_MASK = 0) and |
6655 (Target.Y and LAND_HEIGHT_MASK = 0) and ((Land[Target.Y, Target.X] = 0)) and |
6655 (Target.Y and LAND_HEIGHT_MASK = 0) and ((LandGet(Target.Y, Target.X) = 0)) and |
6656 (not CheckCoordInWater(Target.X, Target.Y))) and (CheckGearNear(gtAirMine, int2hwFloat(Target.X),int2hwFloat(Target.Y), Gear^.Radius*3, Gear^.Radius*3) = nil) and |
6656 (not CheckCoordInWater(Target.X, Target.Y))) and (CheckGearNear(gtAirMine, int2hwFloat(Target.X),int2hwFloat(Target.Y), Gear^.Radius*3, Gear^.Radius*3) = nil) and |
6657 (not ((WorldEdge = weBounce) and ((Target.X > rightX) or (Target.X < leftX))))) then |
6657 (not ((WorldEdge = weBounce) and ((Target.X > rightX) or (Target.X < leftX))))) then |
6658 begin |
6658 begin |
6659 updateTarget(Gear, ndX, ndY); |
6659 updateTarget(Gear, ndX, ndY); |
6660 Timer := iceWaitCollision; |
6660 Timer := iceWaitCollision; |
6684 end |
6684 end |
6685 end |
6685 end |
6686 else if CheckCoordInWater(Target.X, Target.Y) or |
6686 else if CheckCoordInWater(Target.X, Target.Y) or |
6687 ((Target.X and LAND_WIDTH_MASK = 0) and |
6687 ((Target.X and LAND_WIDTH_MASK = 0) and |
6688 (Target.Y and LAND_HEIGHT_MASK = 0) and |
6688 (Target.Y and LAND_HEIGHT_MASK = 0) and |
6689 (Land[Target.Y, Target.X] = lfIce) and |
6689 (LandGet(Target.Y, Target.X) = lfIce) and |
6690 ((Target.Y+iceHeight+5 > cWaterLine) or |
6690 ((Target.Y+iceHeight+5 > cWaterLine) or |
6691 ((WorldEdge = weSea) and |
6691 ((WorldEdge = weSea) and |
6692 ((Target.X+iceHeight+5 > rightX) or |
6692 ((Target.X+iceHeight+5 > rightX) or |
6693 (Target.X-iceHeight-5 < leftX)))) |
6693 (Target.X-iceHeight-5 < leftX)))) |
6694 ) then |
6694 ) then |
6766 end |
6766 end |
6767 else if iter^.Kind = gtAirMine then |
6767 else if iter^.Kind = gtAirMine then |
6768 begin |
6768 begin |
6769 iter^.Damage:= 0; |
6769 iter^.Damage:= 0; |
6770 iter^.State:= iter^.State or gstFrozen; |
6770 iter^.State:= iter^.State or gstFrozen; |
6771 if (hwRound(iter^.X) < RightX-16) and (hwRound(iter^.X) > LeftX+16) and |
6771 if (hwRound(iter^.X) < RightX-16) and (hwRound(iter^.X) > LeftX+16) and |
6772 (hwRound(iter^.Y) > topY+16) and (hwRound(iter^.Y) < LAND_HEIGHT-16) then |
6772 (hwRound(iter^.Y) > topY+16) and (hwRound(iter^.Y) < LAND_HEIGHT-16) then |
6773 begin |
6773 begin |
6774 AddCI(iter); |
6774 AddCI(iter); |
6775 iter^.X:= int2hwFloat(min(RightX-16,max(hwRound(iter^.X), LeftX+16))); |
6775 iter^.X:= int2hwFloat(min(RightX-16,max(hwRound(iter^.X), LeftX+16))); |
6776 iter^.Y:= int2hwFloat(min(LAND_HEIGHT-16,max(hwRound(iter^.Y),TopY+16))); |
6776 iter^.Y:= int2hwFloat(min(LAND_HEIGHT-16,max(hwRound(iter^.Y),TopY+16))); |
6777 ForcePlaceOnLand(hwRound(iter^.X)-16, hwRound(iter^.Y)-16, sprFrozenAirMine, 0, lfIce, $FFFFFFFF, false, false, false); |
6777 ForcePlaceOnLand(hwRound(iter^.X)-16, hwRound(iter^.Y)-16, sprFrozenAirMine, 0, lfIce, $FFFFFFFF, false, false, false); |
6778 iter^.State:= iter^.State or gstInvisible |
6778 iter^.State:= iter^.State or gstInvisible |
6779 end |
6779 end |
6780 else |
6780 else |
6781 begin |
6781 begin |
6782 updateTarget(Gear, ndX, ndY); |
6782 updateTarget(Gear, ndX, ndY); |
6963 if targ <> nil then |
6963 if targ <> nil then |
6964 begin |
6964 begin |
6965 tX:=Gear^.X-targ^.X; |
6965 tX:=Gear^.X-targ^.X; |
6966 tY:=Gear^.Y-targ^.Y; |
6966 tY:=Gear^.Y-targ^.Y; |
6967 // allow escaping - should maybe flag this too |
6967 // allow escaping - should maybe flag this too |
6968 if (GameTicks > Gear^.FlightTime+10000) or |
6968 if (GameTicks > Gear^.FlightTime+10000) or |
6969 ((tX.Round+tY.Round > Gear^.Angle*6) and |
6969 ((tX.Round+tY.Round > Gear^.Angle*6) and |
6970 (hwRound(hwSqr(tX) + hwSqr(tY)) > sqr(Gear^.Angle*6))) then |
6970 (hwRound(hwSqr(tX) + hwSqr(tY)) > sqr(Gear^.Angle*6))) then |
6971 targ:= nil |
6971 targ:= nil |
6972 end; |
6972 end; |
6973 |
6973 |
6974 // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) |
6974 // If in ready timer, or after turn, or in first 5 seconds of turn (really a window due to extra time utility) |
6975 // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0 |
6975 // or mine is inactive due to lack of gsttmpflag or hunting is disabled due to seek radius of 0 |
6976 // then we aren't hunting |
6976 // then we aren't hunting |
6977 if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or |
6977 if (ReadyTimeLeft > 0) or (TurnTimeLeft = 0) or |
6978 ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or |
6978 ((TurnTimeLeft < cHedgehogTurnTime) and (cHedgehogTurnTime-TurnTimeLeft < 5000)) or |
6979 (Gear^.State and gsttmpFlag = 0) or |
6979 (Gear^.State and gsttmpFlag = 0) or |
6980 (Gear^.Angle = 0) then |
6980 (Gear^.Angle = 0) then |
6981 gear^.State:= gear^.State and (not gstChooseTarget) |
6981 gear^.State:= gear^.State and (not gstChooseTarget) |
6982 else if |
6982 else if |
7236 Sentry^.Y := Sentry^.Y + int2hwFloat(offset); |
7236 Sentry^.Y := Sentry^.Y + int2hwFloat(offset); |
7237 end; |
7237 end; |
7238 MakeSentryStep := true |
7238 MakeSentryStep := true |
7239 end |
7239 end |
7240 end; |
7240 end; |
7241 |
7241 |
7242 function MakeSentryJump(Sentry: PGear; maxXStep, maxYStep: LongInt): Boolean; |
7242 function MakeSentryJump(Sentry: PGear; maxXStep, maxYStep: LongInt): Boolean; |
7243 var x, y, offsetX, offsetY, direction: LongInt; |
7243 var x, y, offsetX, offsetY, direction: LongInt; |
7244 jumpTime: hwFloat; |
7244 jumpTime: hwFloat; |
7245 begin |
7245 begin |
7246 MakeSentryJump := false; |
7246 MakeSentryJump := false; |
7289 distX := distX * invDistance; |
7289 distX := distX * invDistance; |
7290 distY := distY * invDistance; |
7290 distY := distY * invDistance; |
7291 |
7291 |
7292 for i := 0 to count - 1 do |
7292 for i := 0 to count - 1 do |
7293 begin |
7293 begin |
7294 if (Land[hwRound(fromY), hwRound(fromX)] and mask) <> 0 then |
7294 if (LandGet(hwRound(fromY), hwRound(fromX)) and mask) <> 0 then |
7295 Inc(TraceAttackPath); |
7295 Inc(TraceAttackPath); |
7296 fromX := fromX + distX; |
7296 fromX := fromX + distX; |
7297 fromY := fromY + distY; |
7297 fromY := fromY + distY; |
7298 end |
7298 end |
7299 end; |
7299 end; |