From 91bdc131bebd56eb8d68d37d30f443f2f8eaed6f Mon Sep 17 00:00:00 2001 From: Flugente Date: Thu, 6 Dec 2012 00:47:59 +0000 Subject: [PATCH] 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 --- Tactical/Overhead.cpp | 101 +++++++++++++++++++++++++++++++++++ Tactical/Overhead.h | 2 + Tactical/Soldier Control.cpp | 13 ++++- Utils/Text.h | 1 + Utils/_ChineseText.cpp | 1 + Utils/_DutchText.cpp | 1 + Utils/_EnglishText.cpp | 1 + Utils/_FrenchText.cpp | 1 + Utils/_GermanText.cpp | 1 + Utils/_ItalianText.cpp | 1 + Utils/_PolishText.cpp | 1 + Utils/_RussianText.cpp | 1 + Utils/_TaiwaneseText.cpp | 1 + 13 files changed, 124 insertions(+), 2 deletions(-) diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index c7050c8d..e1443793 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -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 ); +} diff --git a/Tactical/Overhead.h b/Tactical/Overhead.h index b66175cd..7c184b37 100644 --- a/Tactical/Overhead.h +++ b/Tactical/Overhead.h @@ -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 \ No newline at end of file diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 8e4d7868..81fa9234 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -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 ); + } } } diff --git a/Utils/Text.h b/Utils/Text.h index bdca280a..a113fac9 100644 --- a/Utils/Text.h +++ b/Utils/Text.h @@ -915,6 +915,7 @@ enum WEAPON_CLEANING_STR, PRISONER_NO_PRISONS_STR, PRISONER_DECIDE_STR, + PRISONER_OFFER_SURRENDER, TEXT_NUM_TACTICAL_STR }; diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index 9c668fc0..b7628c4b 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -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. diff --git a/Utils/_DutchText.cpp b/Utils/_DutchText.cpp index 5c31db39..a7396e00 100644 --- a/Utils/_DutchText.cpp +++ b/Utils/_DutchText.cpp @@ -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. diff --git a/Utils/_EnglishText.cpp b/Utils/_EnglishText.cpp index b30e52ac..b06862de 100644 --- a/Utils/_EnglishText.cpp +++ b/Utils/_EnglishText.cpp @@ -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. diff --git a/Utils/_FrenchText.cpp b/Utils/_FrenchText.cpp index 4bd22e34..2b674654 100644 --- a/Utils/_FrenchText.cpp +++ b/Utils/_FrenchText.cpp @@ -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. diff --git a/Utils/_GermanText.cpp b/Utils/_GermanText.cpp index 99eeedee..da5569db 100644 --- a/Utils/_GermanText.cpp +++ b/Utils/_GermanText.cpp @@ -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. diff --git a/Utils/_ItalianText.cpp b/Utils/_ItalianText.cpp index 23b24923..0bbce29b 100644 --- a/Utils/_ItalianText.cpp +++ b/Utils/_ItalianText.cpp @@ -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. diff --git a/Utils/_PolishText.cpp b/Utils/_PolishText.cpp index 2b34e6e6..fe61537c 100644 --- a/Utils/_PolishText.cpp +++ b/Utils/_PolishText.cpp @@ -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. diff --git a/Utils/_RussianText.cpp b/Utils/_RussianText.cpp index c29ffbdd..fa6f2db6 100644 --- a/Utils/_RussianText.cpp +++ b/Utils/_RussianText.cpp @@ -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. diff --git a/Utils/_TaiwaneseText.cpp b/Utils/_TaiwaneseText.cpp index e02d4d48..229869e7 100644 --- a/Utils/_TaiwaneseText.cpp +++ b/Utils/_TaiwaneseText.cpp @@ -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.