mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Update simultaneous combat check for group arrivals (#176)
The previous check didn't take group team into account, so it was possible for a simultaneous battle to be triggered by an enemy group moving into a friendly sector
This commit is contained in:
@@ -1892,47 +1892,48 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe
|
|||||||
fExceptionQueue = TRUE;
|
fExceptionQueue = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//First check if the group arriving is going to queue another battle. //KM : Aug 11, 1999 -- Patch fix: Added additional checks to prevent a 2nd battle in the case
|
|
||||||
//NOTE: We can't have more than one battle ongoing at a time. //where the player is involved in a potential battle with bloodcats/civilians
|
// if this group arrival would cause a simultaneous combat, then delay it!
|
||||||
if( fExceptionQueue || (fCheckForBattle && (gTacticalStatus.fEnemyInSector || HostileCiviliansPresent() || HostileBloodcatsPresent()) &&
|
// we can't have more that one battle at a time.
|
||||||
FindMovementGroupInSector( (UINT8)gWorldSectorX, (UINT8)gWorldSectorY, OUR_TEAM ) &&
|
if( fExceptionQueue
|
||||||
(pGroup->ubNextX != gWorldSectorX || pGroup->ubNextY != gWorldSectorY || gbWorldSectorZ > 0 ) && NumHostilesInSector(pGroup->ubNextX, pGroup->ubNextY, pGroup->ubSectorZ) > 0)
|
|| ((fCheckForBattle && (gTacticalStatus.fEnemyInSector || HostileCiviliansPresent() || HostileBloodcatsPresent())) // if there is an active battle
|
||||||
#ifdef JA2UB
|
&& (pGroup->ubNextX != gWorldSectorX || pGroup->ubNextY != gWorldSectorY || gbWorldSectorZ > 0)) // and the group is arriving at a different sector
|
||||||
//Ja25: NO meanwhiles
|
#ifndef JA2UB
|
||||||
#else
|
|
||||||
|| AreInMeanwhile()
|
|| AreInMeanwhile()
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
//QUEUE BATTLE!
|
if (((pGroup->usGroupTeam == OUR_TEAM || pGroup->usGroupTeam == MILITIA_TEAM) && NumHostilesInSector(pGroup->ubNextX, pGroup->ubNextY, pGroup->ubSectorZ) > 0) // if a friendly movement group will arrive at an enemy sector
|
||||||
//Delay arrival by a random value ranging from 3-5 minutes, so it doesn't get the player
|
|| (pGroup->usGroupTeam == ENEMY_TEAM && (NumPlayerTeamMembersInSector(pGroup->ubNextX, pGroup->ubNextY, pGroup->ubSectorZ) + NumNonPlayerTeamMembersInSector(pGroup->ubNextX, pGroup->ubNextY, MILITIA_TEAM) > 0))) // or an enemy movement group will arrive at a friendly sector
|
||||||
//too suspicious after it happens to him a few times, which, by the way, is a rare occurrence.
|
|
||||||
#ifdef JA2UB
|
|
||||||
/*Ja25: No meanwhiles*/
|
|
||||||
#else
|
|
||||||
if( AreInMeanwhile() )
|
|
||||||
{
|
{
|
||||||
pGroup->uiArrivalTime ++; //tack on only 1 minute if we are in a meanwhile scene. This effectively
|
//QUEUE BATTLE!
|
||||||
//prevents any battle from occurring while inside a meanwhile scene.
|
//Delay arrival by a random value ranging from 3-5 minutes, so it doesn't get the player
|
||||||
}
|
//too suspicious after it happens to him a few times, which, by the way, is a rare occurrence.
|
||||||
else
|
#ifndef JA2UB
|
||||||
#endif
|
if( AreInMeanwhile() )
|
||||||
{
|
|
||||||
pGroup->uiArrivalTime += Random(3) + 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !AddStrategicEvent( EVENT_GROUP_ARRIVAL, pGroup->uiArrivalTime, pGroup->ubGroupID ) )
|
|
||||||
AssertMsg( 0, "Failed to add movement event." );
|
|
||||||
|
|
||||||
if ( pGroup->usGroupTeam == OUR_TEAM )
|
|
||||||
{
|
|
||||||
if( pGroup->uiArrivalTime - ABOUT_TO_ARRIVE_DELAY > GetWorldTotalMin( ) )
|
|
||||||
{
|
{
|
||||||
AddStrategicEvent( EVENT_GROUP_ABOUT_TO_ARRIVE, pGroup->uiArrivalTime - ABOUT_TO_ARRIVE_DELAY, pGroup->ubGroupID );
|
pGroup->uiArrivalTime ++; //tack on only 1 minute if we are in a meanwhile scene. This effectively
|
||||||
|
//prevents any battle from occurring while inside a meanwhile scene.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
pGroup->uiArrivalTime += Random(3) + 3;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
if( !AddStrategicEvent( EVENT_GROUP_ARRIVAL, pGroup->uiArrivalTime, pGroup->ubGroupID ) )
|
||||||
|
AssertMsg( 0, "Failed to add movement event." );
|
||||||
|
|
||||||
|
if ( pGroup->usGroupTeam == OUR_TEAM )
|
||||||
|
{
|
||||||
|
if( pGroup->uiArrivalTime - ABOUT_TO_ARRIVE_DELAY > GetWorldTotalMin( ) )
|
||||||
|
{
|
||||||
|
AddStrategicEvent( EVENT_GROUP_ABOUT_TO_ARRIVE, pGroup->uiArrivalTime - ABOUT_TO_ARRIVE_DELAY, pGroup->ubGroupID );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the position of the group
|
//Update the position of the group
|
||||||
|
|||||||
Reference in New Issue
Block a user