7195 Sentry^.Y := Sentry^.Y + int2hwFloat(offset); |
7195 Sentry^.Y := Sentry^.Y + int2hwFloat(offset); |
7196 end; |
7196 end; |
7197 MakeSentryStep := true |
7197 MakeSentryStep := true |
7198 end |
7198 end |
7199 end; |
7199 end; |
|
7200 |
|
7201 function MakeSentryJump(Sentry: PGear; maxXStep, maxYStep: LongInt): Boolean; |
|
7202 var x, y, offsetX, offsetY: LongInt; |
|
7203 jumpTime: hwFloat; |
|
7204 begin |
|
7205 MakeSentryJump := false; |
|
7206 x := hwRound(Sentry^.X); |
|
7207 y := hwRound(Sentry^.Y); |
|
7208 offsetX := (maxXStep - Sentry^.Radius) * hwSign(Sentry^.dX); |
|
7209 repeat |
|
7210 for offsetY := -maxYStep - 1 to maxYStep + 1 do |
|
7211 begin |
|
7212 if TestCollisionYImpl(x + offsetX, y + offsetY, Sentry^.Radius, 1, Sentry^.CollisionMask) <> 0 then |
|
7213 break; |
|
7214 end; |
|
7215 if (offsetY >= -maxYStep) and (offsetY <= maxYStep) then |
|
7216 break; |
|
7217 Dec(offsetX, Sentry^.Radius * hwSign(Sentry^.dX)); |
|
7218 until offsetX <= 0; |
|
7219 |
|
7220 if (offsetX > 0) and (not cGravity.isNegative) then |
|
7221 begin |
|
7222 Sentry^.dY := -_0_25; |
|
7223 jumpTime := _2 * Sentry^.dY / cGravity; |
|
7224 Sentry^.dX := SignAs(int2hwFloat(abs(offsetX) - Sentry^.Radius) / jumpTime, Sentry^.dX); |
|
7225 MakeSentryJump := true; |
|
7226 end; |
|
7227 end; |
7200 |
7228 |
7201 function TraceAttackPath(fromX, fromY, toX, toY, step: hwFloat; mask: Word): LongWord; |
7229 function TraceAttackPath(fromX, fromY, toX, toY, step: hwFloat; mask: Word): LongWord; |
7202 var distX, distY, dist, invDistance: HwFloat; |
7230 var distX, distY, dist, invDistance: HwFloat; |
7203 i, count: LongInt; |
7231 i, count: LongInt; |
7204 begin |
7232 begin |
7279 begin |
7307 begin |
7280 if Gear^.Tag = sentry_Idle then |
7308 if Gear^.Tag = sentry_Idle then |
7281 begin |
7309 begin |
7282 Gear^.Tag := sentry_Walking; |
7310 Gear^.Tag := sentry_Walking; |
7283 Gear^.Timer := 1000 + GetRandom(3000); |
7311 Gear^.Timer := 1000 + GetRandom(3000); |
7284 Gear^.dX.isNegative := GetRandom(2) = 1; |
7312 if GetRandom(4) = 0 then |
7285 if not MakeSentryStep(Gear, 6, true) then |
7313 begin |
7286 begin |
7314 if MakeSentryJump(Gear, 80, 60) then |
7287 Gear^.dX.isNegative := not Gear^.dX.isNegative; |
7315 Gear^.Timer := 4000 |
7288 if not MakeSentryStep(Gear, 6, true) then |
7316 else |
7289 begin |
7317 Gear^.Timer := 1000; |
7290 Gear^.Tag := sentry_Idle; |
7318 Gear^.Tag := sentry_Idle; |
7291 Gear^.Timer := 10000; |
7319 end |
7292 end; |
7320 else |
|
7321 begin |
|
7322 Gear^.dX.isNegative := GetRandom(2) = 1; |
|
7323 |
|
7324 if MakeSentryStep(Gear, 6, true) then |
|
7325 begin |
|
7326 if GetRandom(4) = 0 then |
|
7327 begin |
|
7328 Gear^.Timer := 2000; |
|
7329 Gear^.Tag := sentry_Idle; |
|
7330 end; |
|
7331 end |
|
7332 else |
|
7333 begin |
|
7334 Gear^.dX.isNegative := not Gear^.dX.isNegative; |
|
7335 if not MakeSentryStep(Gear, 6, true) then |
|
7336 begin |
|
7337 if GetRandom(2) = 0 then |
|
7338 begin |
|
7339 Gear^.dY := - _0_25; |
|
7340 Gear^.Timer := 3000; |
|
7341 end |
|
7342 else |
|
7343 Gear^.Timer := 5000; |
|
7344 Gear^.Tag := sentry_Idle; |
|
7345 end; |
|
7346 end |
7293 end |
7347 end |
7294 end |
7348 end |
7295 else if Gear^.Tag in [sentry_Walking, sentry_Reloading] then |
7349 else if Gear^.Tag in [sentry_Walking, sentry_Reloading] then |
7296 begin |
7350 begin |
7297 Gear^.Tag := sentry_Idle; |
7351 Gear^.Tag := sentry_Idle; |