Demand surrender feature will now work on each team separately, ie. demanding surrender from regular enemy will not count hostile civilians or bandits and neither it will capture them.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9271 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Shadooow
2022-01-22 16:46:13 +00:00
parent 7803378388
commit 9668618b68
+13 -19
View File
@@ -11199,11 +11199,12 @@ void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue )
if ( ubExitValue == 1 ) if ( ubExitValue == 1 )
{ {
SOLDIERTYPE *pSoldierToSurrender = MercPtrs[prisonerdialoguetargetID];
DeductPoints( MercPtrs[gusSelectedSoldier], APBPConstants[AP_TALK], 0, UNTRIGGERED_INTERRUPT ); DeductPoints( MercPtrs[gusSelectedSoldier], APBPConstants[AP_TALK], 0, UNTRIGGERED_INTERRUPT );
if ( !gGameExternalOptions.fEnemyCanSurrender ) if ( !gGameExternalOptions.fEnemyCanSurrender )
{ {
StartCivQuote( MercPtrs[prisonerdialoguetargetID] ); StartCivQuote(pSoldierToSurrender);
return; return;
} }
@@ -11256,26 +11257,14 @@ void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue )
// We justify this storywise by these soldiers being very determined leaders who don't allow surrender categorically. // We justify this storywise by these soldiers being very determined leaders who don't allow surrender categorically.
BOOLEAN fNoSurrender = FALSE; BOOLEAN fNoSurrender = FALSE;
// enemy team and creature team (bandits can be captured) // shadooow: rewritten to only check soldiers from the same team
firstid = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID; firstid = gTacticalStatus.Team[pSoldierToSurrender->bTeam].bFirstID;
lastid = gTacticalStatus.Team[CREATURE_TEAM].bLastID; lastid = gTacticalStatus.Team[pSoldierToSurrender->bTeam].bLastID;
for (uiCnt = firstid, pSoldier = MercPtrs[uiCnt]; uiCnt <= lastid; ++uiCnt, ++pSoldier) for (uiCnt = firstid, pSoldier = MercPtrs[uiCnt]; uiCnt <= lastid; ++uiCnt, ++pSoldier)
{ {
if (pSoldier->bActive && (pSoldier->sSectorX == gWorldSectorX) && (pSoldier->sSectorY == gWorldSectorY) && (pSoldier->bSectorZ == gbWorldSectorZ)) if (pSoldier->bActive && (pSoldier->sSectorX == gWorldSectorX) && (pSoldier->sSectorY == gWorldSectorY) && (pSoldier->bSectorZ == gbWorldSectorZ))
{ {
enemysidestrength += pSoldier->GetSurrenderStrength(); if (pSoldierToSurrender->bTeam == CIV_TEAM)
if ( pSoldier->ubProfile != NO_PROFILE || ARMED_VEHICLE(pSoldier) || ENEMYROBOT(pSoldier) )
fNoSurrender = TRUE;
}
}
// hostile civs
firstid = gTacticalStatus.Team[ CIV_TEAM ].bFirstID;
lastid = gTacticalStatus.Team[ CIV_TEAM ].bLastID;
for ( uiCnt = firstid, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= lastid; ++uiCnt, ++pSoldier)
{
if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) )
{ {
// hostile civs with a profile cannot be captured, as stated above, the entire team cannot surrender // hostile civs with a profile cannot be captured, as stated above, the entire team cannot surrender
if (!pSoldier->aiData.bNeutral && pSoldier->bSide == 1 && zCivGroupName[pSoldier->ubCivilianGroup].fCanBeCaptured && pSoldier->ubProfile != NO_PROFILE) if (!pSoldier->aiData.bNeutral && pSoldier->bSide == 1 && zCivGroupName[pSoldier->ubCivilianGroup].fCanBeCaptured && pSoldier->ubProfile != NO_PROFILE)
@@ -11288,6 +11277,13 @@ void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue )
// if a civilian is not neutral and on the enemy side, add his strength to the team // if a civilian is not neutral and on the enemy side, add his strength to the team
enemysidestrength += pSoldier->GetSurrenderStrength(); enemysidestrength += pSoldier->GetSurrenderStrength();
} }
else
{
enemysidestrength += pSoldier->GetSurrenderStrength();
if (pSoldier->ubProfile != NO_PROFILE || ARMED_VEHICLE(pSoldier) || ENEMYROBOT(pSoldier))
fNoSurrender = TRUE;
}
}
} }
// enemy team gets a bonus if it has officers around // enemy team gets a bonus if it has officers around
@@ -11305,8 +11301,6 @@ void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue )
if ( !fNoSurrender && playersidestrength >= gGameExternalOptions.fSurrenderMultiplier * enemysidestrength ) if ( !fNoSurrender && playersidestrength >= gGameExternalOptions.fSurrenderMultiplier * enemysidestrength )
{ {
// it is enough to simply set all soldiers to captured // it is enough to simply set all soldiers to captured
firstid = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID;
lastid = gTacticalStatus.Team[ CIV_TEAM ].bLastID;
for ( uiCnt = firstid, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= lastid; ++uiCnt, ++pSoldier) for ( uiCnt = firstid, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= lastid; ++uiCnt, ++pSoldier)
{ {
if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) ) if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) )