| 1362 | // Add the walking speed of the target, and also divide by (my speed - his speed)/6 if that would be < 1. |
| 1363 | // should be consistent. |
| 1364 | CmpPtr<ICmpUnitMotion> cmpTargetUnitMotion(GetSimContext(), target); |
| 1365 | if (cmpTargetUnitMotion) |
| 1366 | { |
| 1367 | CmpPtr<ICmpUnitMotion> cmpUnitMotion(GetSimContext(), GetEntityId()); |
| 1368 | if (cmpUnitMotion && cmpUnitMotion->GetWalkSpeed() > cmpTargetUnitMotion->GetWalkSpeed() + entity_pos_t::FromInt(2)) |
| 1369 | { |
| 1370 | goalDistance += cmpTargetUnitMotion->GetWalkSpeed(); |
| 1371 | fixed speedDifference = (cmpUnitMotion->GetWalkSpeed() - cmpTargetUnitMotion->GetWalkSpeed())/6; |
| 1372 | if (speedDifference < entity_pos_t::FromInt(1) ) |
| 1373 | goalDistance = goalDistance/speedDifference; |
| 1374 | if (goalDistance > maxRange) |
| 1375 | goalDistance = maxRange; |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | |