Avoid overcrowding when looking for spot to move to

This commit is contained in:
Asdow
2026-01-22 00:24:53 +02:00
parent 76af6b7641
commit 1419cc6925
+10 -2
View File
@@ -655,7 +655,7 @@ static void CalculateCoverValue(SOLDIERTYPE* pSoldier, const INT32 sGridNo, cons
} }
// sevenfm: check for nearby friends, add bonus/penalty 10% // sevenfm: check for nearby friends, add bonus/penalty 10%
UINT8 ubNearbyFriends = __max(0, CountNearbyFriends(pSoldier, sGridNo, 7)); UINT8 ubNearbyFriends = __max(0, CountNearbyFriends(pSoldier, sGridNo, TACTICAL_RANGE_CLOSE));
iCoverValue -= ubNearbyFriends * abs(iCoverValue) / (6 - ubDiff); iCoverValue -= ubNearbyFriends * abs(iCoverValue) / (6 - ubDiff);
// sevenfm: penalize locations with fresh corpses // sevenfm: penalize locations with fresh corpses
@@ -963,6 +963,13 @@ INT32 FindBestNearbyCover(SOLDIERTYPE *pSoldier, INT32 morale, INT32 *piPercentB
continue; continue;
} }
// Avoid overcrowding
const auto nearbyFriends = CountNearbyFriends(pSoldier, sGridNo, TACTICAL_RANGE_VERYCLOSE);
if ( nearbyFriends > 1 && !pSoldier->IsZombie() )
{
continue;
}
// zombies only want to hide // zombies only want to hide
if (pSoldier->IsZombie() && !SightCoverAtSpot(pSoldier, sGridNo, TRUE)) if (pSoldier->IsZombie() && !SightCoverAtSpot(pSoldier, sGridNo, TRUE))
{ {
@@ -3122,7 +3129,8 @@ INT32 FindAdvanceSpot(SOLDIERTYPE *pSoldier, INT32 sTargetSpot, INT8 bAction, UI
} }
// avoid overcrowding // avoid overcrowding
if (!pSoldier->IsZombie() && NumberOfTeamMatesAdjacent(pSoldier, sGridNo) > 1) const auto nearbyFriends = CountNearbyFriends(pSoldier, sGridNo, TACTICAL_RANGE_VERYCLOSE);
if ( nearbyFriends > 1 && !pSoldier->IsZombie() )
{ {
continue; continue;
} }