when talking to an enemy, the player can offer them the option to surrender, thus capturing all enemies and ending the battle

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5714 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-12-06 00:47:59 +00:00
parent c68b5e482f
commit 91bdc131be
13 changed files with 124 additions and 2 deletions
+101
View File
@@ -10040,3 +10040,104 @@ STR16 GetNewTraitStr(UINT8 aTrait)
return gzMercSkillTextNew[ aTrait ];
}
static UINT8 prisonerdialoguetargetID = 0;
void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue )
{
if (ubExitValue == MSG_BOX_RETURN_YES)
{
// we determine the chance that enemy will surrender. This depends on the strength of our and their side
UINT32 playersidestrength = 0;
UINT32 enemysidestrength = 0;
SOLDIERTYPE *pSoldier = NULL;
UINT32 uiCnt=0;
// player team
UINT32 firstid = gTacticalStatus.Team[ OUR_TEAM ].bFirstID;
UINT32 lastid = gTacticalStatus.Team[ OUR_TEAM ].bLastID;
for ( uiCnt = firstid, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= lastid; ++uiCnt, ++pSoldier)
{
if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) )
{
// if he's training teammates in this stat
if( ( pSoldier->stats.bLife >= OKLIFE ) && !(pSoldier->bSoldierFlagMask & SOLDIER_POW) )
{
// player side counts double, to put more emphasize on overwhelming the enemy with mercs and not just militia
playersidestrength += 2;
}
}
}
// militia team
firstid = gTacticalStatus.Team[ MILITIA_TEAM ].bFirstID;
lastid = gTacticalStatus.Team[ MILITIA_TEAM ].bLastID;
for ( uiCnt = firstid, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= lastid; ++uiCnt, ++pSoldier)
{
if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) )
{
// if he's training teammates in this stat
if( ( pSoldier->stats.bLife >= OKLIFE ) && !(pSoldier->bSoldierFlagMask & SOLDIER_POW) )
{
++playersidestrength;
}
}
}
// enemy team
firstid = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID;
lastid = gTacticalStatus.Team[ ENEMY_TEAM ].bLastID;
for ( uiCnt = firstid, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= lastid; ++uiCnt, ++pSoldier)
{
if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) )
{
// if he's training teammates in this stat
if( ( pSoldier->stats.bLife >= OKLIFE ) && !(pSoldier->bSoldierFlagMask & SOLDIER_POW) )
{
++enemysidestrength;
}
}
}
// perhaps this can be fleshed out more, for now, let's see if this is acceptable behaviour
if ( playersidestrength >= 6 * enemysidestrength )
{
// it is enough to simply set all soldiers to captured
firstid = gTacticalStatus.Team[ ENEMY_TEAM ].bFirstID;
lastid = gTacticalStatus.Team[ ENEMY_TEAM ].bLastID;
for ( uiCnt = firstid, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= lastid; ++uiCnt, ++pSoldier)
{
if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) )
{
// if he's training teammates in this stat
if( ( pSoldier->stats.bLife >= OKLIFE ) && !(pSoldier->bSoldierFlagMask & SOLDIER_POW) )
{
pSoldier->bSoldierFlagMask |= SOLDIER_POW;
}
}
}
}
}
else
{
// normal dialog
StartCivQuote( MercPtrs[ prisonerdialoguetargetID ] );
}
ReduceAttackBusyCount( );
}
// Flugente: offer the enemy the chance to surrender
void HandleSurrenderOffer( SOLDIERTYPE* pSoldier )
{
// only for enemies...
if ( !pSoldier || pSoldier->bTeam != ENEMY_TEAM )
return;
// remember the target's ID
prisonerdialoguetargetID = pSoldier->ubID;
// open a dialogue box and see wether we really want to offer this, or just talk
DoMessageBox( MSG_BOX_BASIC_STYLE, TacticalStr[ PRISONER_OFFER_SURRENDER ], guiCurrentScreen, ( UINT8 )MSG_BOX_FLAG_YESNO, PrisonerSurrenderMessageBoxCallBack, NULL );
}