7226 fromX := fromX + distX; |
7226 fromX := fromX + distX; |
7227 fromY := fromY + distY; |
7227 fromY := fromY + distY; |
7228 end |
7228 end |
7229 end; |
7229 end; |
7230 |
7230 |
|
7231 function CheckSentryAttackRange(Sentry: PGear; targetX, targetY: HwFloat): Boolean; |
|
7232 var distX, distY: hwFloat; |
|
7233 begin |
|
7234 distX := targetX - Sentry^.X; |
|
7235 distY := targetY - Sentry^.Y; |
|
7236 CheckSentryAttackRange := |
|
7237 (distX.isNegative = Sentry^.dX.isNegative) |
|
7238 and (distX.Round > 24) |
|
7239 and (distX.Round < 500) |
|
7240 and (hwAbs(distY) < hwAbs(distX)) |
|
7241 and (TraceAttackPath(Sentry^.X, Sentry^.Y, targetX, targetY, _4, lfLandMask) <= 18); |
|
7242 end; |
|
7243 |
7231 procedure doStepSentry(Gear: PGear); |
7244 procedure doStepSentry(Gear: PGear); |
7232 var HHGear, bullet: PGear; |
7245 var HHGear, bullet: PGear; |
7233 distX, distY, invDistance: HwFloat; |
7246 distX, distY, invDistance: HwFloat; |
7234 const sentry_Idle = 0; |
7247 const sentry_Idle = 0; |
7235 sentry_Walking = 1; |
7248 sentry_Walking = 1; |
7284 Gear^.Tag := sentry_Idle; |
7297 Gear^.Tag := sentry_Idle; |
7285 Gear^.Timer := 1000 + GetRandom(1000); |
7298 Gear^.Timer := 1000 + GetRandom(1000); |
7286 end |
7299 end |
7287 else if Gear^.Tag = sentry_Aiming then |
7300 else if Gear^.Tag = sentry_Aiming then |
7288 begin |
7301 begin |
7289 Gear^.WDTimer := 5 + GetRandom(3); |
7302 if CheckSentryAttackRange(Gear, int2hwFloat(Gear^.Target.X), int2hwFloat(Gear^.Target.Y)) then |
7290 Gear^.Tag := sentry_Attacking; |
7303 begin |
7291 Gear^.Timer := 100; |
7304 Gear^.WDTimer := 5 + GetRandom(3); |
|
7305 Gear^.Tag := sentry_Attacking; |
|
7306 Gear^.Timer := 100; |
|
7307 end |
|
7308 else |
|
7309 begin |
|
7310 Gear^.Target.X := 0; |
|
7311 Gear^.Target.Y := 0; |
|
7312 Gear^.Tag := sentry_Idle; |
|
7313 Gear^.Timer := 5000; |
|
7314 end |
7292 end |
7315 end |
7293 else if Gear^.Tag = sentry_Attacking then |
7316 else if Gear^.Tag = sentry_Attacking then |
7294 begin |
7317 begin |
7295 distX := int2hwFloat(Gear^.Target.X) - Gear^.X; |
7318 distX := int2hwFloat(Gear^.Target.X) - Gear^.X; |
7296 distY := int2hwFloat(Gear^.Target.Y) - Gear^.Y; |
7319 distY := int2hwFloat(Gear^.Target.Y) - Gear^.Y; |
7354 and (CurrentHedgehog <> nil) |
7377 and (CurrentHedgehog <> nil) |
7355 and (CurrentHedgehog^.Gear <> nil) |
7378 and (CurrentHedgehog^.Gear <> nil) |
7356 and ((CurrentHedgehog^.Gear^.State and (gstMoving or gstHHDriven)) = (gstMoving or gstHHDriven)) then |
7379 and ((CurrentHedgehog^.Gear^.State and (gstMoving or gstHHDriven)) = (gstMoving or gstHHDriven)) then |
7357 begin |
7380 begin |
7358 HHGear := CurrentHedgehog^.Gear; |
7381 HHGear := CurrentHedgehog^.Gear; |
7359 distX := HHGear^.X - Gear^.X; |
7382 if CheckSentryAttackRange(Gear, HHGear^.X, HHGear^.Y) then |
7360 distY := HHGear^.Y - Gear^.Y; |
|
7361 if (distX.isNegative = Gear^.dX.isNegative) |
|
7362 and (distX.Round > 24) |
|
7363 and (distX.Round < 500) |
|
7364 and (hwAbs(distY) < hwAbs(distX)) |
|
7365 and (TraceAttackPath(Gear^.X, Gear^.Y, HHGear^.X, HHGear^.Y, _4, lfLandMask) <= 18 ) then |
|
7366 begin |
7383 begin |
7367 Gear^.Target.X := hwRound(HHGear^.X); |
7384 Gear^.Target.X := hwRound(HHGear^.X); |
7368 Gear^.Target.Y := hwRound(HHGear^.Y); |
7385 Gear^.Target.Y := hwRound(HHGear^.Y); |
7369 Gear^.Karma := GameTicks; |
7386 Gear^.Karma := GameTicks; |
7370 Gear^.Tag := sentry_Aiming; |
7387 Gear^.Tag := sentry_Aiming; |