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 );
}
+2
View File
@@ -406,4 +406,6 @@ extern UINT8 NumEnemyInSector();
STR16 GetNewTraitStr(UINT8 aTrait); // Flugente: deal with the insane new trait to string stuff
void HandleSurrenderOffer( SOLDIERTYPE* pSoldier ); // Flugente: offer the enemy the chance to surrender
#endif
+11 -2
View File
@@ -16620,8 +16620,17 @@ BOOLEAN SOLDIERTYPE::PlayerSoldierStartTalking( UINT8 ubTargetID, BOOLEAN fValid
DeductPoints( this, sAPCost, 0, UNTRIGGERED_INTERRUPT );
apsDeducted = TRUE;
StartCivQuote( pTSoldier );
return( FALSE );
// Flugente: if we are talking to an enemy, we have the option to offer them surrendering
if ( pTSoldier->bTeam == ENEMY_TEAM && gGameExternalOptions.fEnemyCanSurrender )
{
HandleSurrenderOffer(pTSoldier);
return( FALSE );
}
else
{
StartCivQuote( pTSoldier );
return( FALSE );
}
}
}
+1
View File
@@ -915,6 +915,7 @@ enum
WEAPON_CLEANING_STR,
PRISONER_NO_PRISONS_STR,
PRISONER_DECIDE_STR,
PRISONER_OFFER_SURRENDER,
TEXT_NUM_TACTICAL_STR
};
+1
View File
@@ -2919,6 +2919,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners // TODO.Translate
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
+1
View File
@@ -2916,6 +2916,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners // TODO.Translate
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
+1
View File
@@ -2918,6 +2918,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
+1
View File
@@ -2918,6 +2918,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners // TODO.Translate
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
+1
View File
@@ -2921,6 +2921,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners // TODO.Translate
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
+1
View File
@@ -2911,6 +2911,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners // TODO.Translate
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
+1
View File
@@ -2926,6 +2926,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners // TODO.Translate
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
+1
View File
@@ -2919,6 +2919,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners // TODO.Translate
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
+1
View File
@@ -2920,6 +2920,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
// added by Flugente: decide what to do with prisoners // TODO.Translate
L"You have no prison for these prisoners, you have to let them go",
L"Yes - Send prisoners to jail No - Let them go",
L"Ask enemy for surrender?",
};
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.