From d55a57007d9852c27929066561833c9ea23b5b89 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sat, 19 Jan 2013 20:22:51 +0000 Subject: [PATCH] When talking to an enemy, we can surrender to him if he hasn't asked us to before. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5793 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameSettings.cpp | 1 + GameSettings.h | 1 + Tactical/Overhead.cpp | 72 ++++++++++++++++++++++++++++++++---- Tactical/Soldier Control.cpp | 2 +- Utils/Text.h | 2 + Utils/_ChineseText.cpp | 3 ++ Utils/_DutchText.cpp | 3 ++ Utils/_EnglishText.cpp | 4 +- Utils/_FrenchText.cpp | 3 ++ Utils/_GermanText.cpp | 3 ++ Utils/_ItalianText.cpp | 3 ++ Utils/_PolishText.cpp | 3 ++ Utils/_RussianText.cpp | 3 ++ Utils/_TaiwaneseText.cpp | 3 ++ 14 files changed, 96 insertions(+), 10 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 119452843..c52772a43 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -1570,6 +1570,7 @@ void LoadGameExternalOptions() // Flugente: prisoner system gGameExternalOptions.fAllowPrisonerSystem = iniReader.ReadBoolean("Strategic Gameplay Settings","ALLOW_TAKE_PRISONERS", TRUE); gGameExternalOptions.fEnemyCanSurrender = iniReader.ReadBoolean("Strategic Gameplay Settings","ENEMY_CAN_SURRENDER", TRUE); + gGameExternalOptions.fPlayerCanAsktoSurrender = iniReader.ReadBoolean("Strategic Gameplay Settings","PLAYER_CAN_ASK_TO_SURRENDER", TRUE); gGameExternalOptions.ubPrisonerReturntoQueenChance = iniReader.ReadInteger("Strategic Gameplay Settings","PRISONER_RETURN_TO_ARMY_CHANCE", 50, 0, 100); gGameExternalOptions.ubPrisonerProcessDefectChance = iniReader.ReadInteger("Strategic Gameplay Settings","PRISONER_DEFECT_CHANCE", 10, 0, 100); gGameExternalOptions.ubPrisonerProcessInfoBaseChance = iniReader.ReadInteger("Strategic Gameplay Settings","PRISONER_INFO_BASECHANCE", 10, 0, 100); diff --git a/GameSettings.h b/GameSettings.h index bfc0999d7..583277774 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -1170,6 +1170,7 @@ typedef struct // Flugente: prisoner related settings BOOLEAN fAllowPrisonerSystem; BOOLEAN fEnemyCanSurrender; + BOOLEAN fPlayerCanAsktoSurrender; UINT8 ubPrisonerReturntoQueenChance; UINT8 ubPrisonerProcessDefectChance; UINT8 ubPrisonerProcessInfoBaseChance; diff --git a/Tactical/Overhead.cpp b/Tactical/Overhead.cpp index 913998a18..097fd53a4 100644 --- a/Tactical/Overhead.cpp +++ b/Tactical/Overhead.cpp @@ -10048,21 +10048,28 @@ static UINT8 prisonerdialoguetargetID = 0; void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue ) { - if (ubExitValue == MSG_BOX_RETURN_YES) + SOLDIERTYPE *pSoldier = NULL; + UINT32 uiCnt=0; + BOOLEAN success = FALSE; + + if ( ubExitValue == 1 ) { + if ( !gGameExternalOptions.fEnemyCanSurrender ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[ SRT_PRISONER_INI_SETTING_OFF ] ); + return; + } + // we have to remove the region, as we are calling a message from within a messagebox MSYS_RemoveRegion(&(gMsgBox.BackRegion) ); // 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; + UINT32 firstid = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; + UINT32 lastid = gTacticalStatus.Team[ gbPlayerNum ].bLastID; for ( uiCnt = firstid, pSoldier = MercPtrs[ uiCnt ]; uiCnt <= lastid; ++uiCnt, ++pSoldier) { if( pSoldier->bActive && ( pSoldier->sSectorX == gWorldSectorX ) && ( pSoldier->sSectorY == gWorldSectorY ) && ( pSoldier->bSectorZ == gbWorldSectorZ) ) @@ -10137,6 +10144,55 @@ void PrisonerSurrenderMessageBoxCallBack( UINT8 ubExitValue ) } } } + // we offered to surrender OURSELVES TO the enemy + else if ( ubExitValue == 2 ) + { + if ( !gGameExternalOptions.fPlayerCanAsktoSurrender ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[ SRT_PRISONER_INI_SETTING_OFF ] ); + return; + } + + // in order for this to work, there must be no militia present, the enemy must not already have offered asked you to surrender, and certain quests may not be active + if ( !( gTacticalStatus.fEnemyFlags & ENEMY_OFFERED_SURRENDER ) && gTacticalStatus.Team[ MILITIA_TEAM ].bMenInSector == 0 ) + { + if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTNOTSTARTED || ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTDONE && gubQuest[ QUEST_INTERROGATION ] == QUESTNOTSTARTED ) ) + { + gTacticalStatus.fEnemyFlags |= ENEMY_OFFERED_SURRENDER; + + // CJC Dec 1 2002: fix multiple captures + BeginCaptureSquence(); + + // Do capture.... + uiCnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; + for ( pSoldier = MercPtrs[ uiCnt ]; uiCnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ++uiCnt, ++pSoldier) + { + // Are we active and in sector..... + if ( pSoldier->bActive && pSoldier->bInSector ) + { + if ( pSoldier->stats.bLife != 0 ) + { + EnemyCapturesPlayerSoldier( pSoldier ); + + RemoveSoldierFromTacticalSector( pSoldier, TRUE ); + } + } + } + + EndCaptureSequence( ); + + gfSurrendered = TRUE; + SetCustomizableTimerCallbackAndDelay( 3000, CaptureTimerCallback, FALSE ); + + success = TRUE; + } + } + + if ( !success ) + { + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[ STR_PRISONER_REFUSE_TAKE_PRISONERS ] ); + } + } else { // normal dialog @@ -10157,5 +10213,5 @@ void HandleSurrenderOffer( SOLDIERTYPE* pSoldier ) 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 ); + DoMessageBox( MSG_BOX_BASIC_SMALL_BUTTONS, TacticalStr[ PRISONER_OFFER_SURRENDER ], guiCurrentScreen, ( UINT8 )MSG_BOX_FLAG_FOUR_NUMBERED_BUTTONS, PrisonerSurrenderMessageBoxCallBack, NULL ); } diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index d2fd4a426..3273364ae 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -16980,7 +16980,7 @@ BOOLEAN SOLDIERTYPE::PlayerSoldierStartTalking( UINT8 ubTargetID, BOOLEAN fValid apsDeducted = TRUE; // Flugente: if we are talking to an enemy, we have the option to offer them surrendering... but not on y levels >= 16 (no surrendering in the palace, as we have to kill, not capture, the queen) - if ( pTSoldier->bTeam == ENEMY_TEAM && gGameExternalOptions.fEnemyCanSurrender && gWorldSectorY < WORLD_MAP_X - 2 ) + if ( pTSoldier->bTeam == ENEMY_TEAM && (gGameExternalOptions.fEnemyCanSurrender || gGameExternalOptions.fPlayerCanAsktoSurrender) && gWorldSectorY < WORLD_MAP_X - 2 ) { HandleSurrenderOffer(pTSoldier); return( FALSE ); diff --git a/Utils/Text.h b/Utils/Text.h index 8e2c7faa4..e16093755 100644 --- a/Utils/Text.h +++ b/Utils/Text.h @@ -742,6 +742,8 @@ enum STR_PRISONER_RELEASED, STR_PRISONER_ARMY_FREED_PRISON, STR_PRISONER_REFUSE_SURRENDER, + STR_PRISONER_REFUSE_TAKE_PRISONERS, + SRT_PRISONER_INI_SETTING_OFF, TEXT_NUM_PRISONER_STR }; diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index 3de18f47e..2d6d3a580 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -2920,6 +2920,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = L"你现在没有可用的监狱关押这些俘虏,你不得不放他们走。", //L"You have no prison for these prisoners, you have to let them go", L"Yes - 将俘虏送入监狱 No - 放俘虏离开这里", //L"Yes - Send prisoners to jail No - Let them go", L"劝说敌人投降?", //L"Ask enemy for surrender?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", // TODO.Translate }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7507,6 +7508,8 @@ STR16 szPrisonerTextStr[]= L"俘虏已被释放!", //L"Prisoners have been released!", L"军队已占领 %s 监狱,俘虏已被释放!", //L"The army now occupies the prison in %s, the prisoners were freed!", L"这敌人丫宁死不从!",//L"The enemy refuses to surrender!", + L"The enemy refuses to take you as prisoners - they prefer you dead!", // TODO.Translate + L"This behaviour is set OFF in your ini settings.", }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_DutchText.cpp b/Utils/_DutchText.cpp index 1a2e3dd27..c6627d4af 100644 --- a/Utils/_DutchText.cpp +++ b/Utils/_DutchText.cpp @@ -2917,6 +2917,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = 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?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7505,6 +7506,8 @@ STR16 szPrisonerTextStr[]= L"Prisoners have been released!", L"The army now occupies the prison in %s, the prisoners were freed!", L"The enemy refuses to surrender!", + L"The enemy refuses to take you as prisoners - they prefer you dead!", // TODO.Translate + L"This behaviour is set OFF in your ini settings.", }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_EnglishText.cpp b/Utils/_EnglishText.cpp index 27f1b702b..5a7708bc2 100644 --- a/Utils/_EnglishText.cpp +++ b/Utils/_EnglishText.cpp @@ -2918,7 +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?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7492,6 +7492,8 @@ STR16 szPrisonerTextStr[]= L"Prisoners have been released!", L"The army now occupies the prison in %s, the prisoners were freed!", L"The enemy refuses to surrender!", + L"The enemy refuses to take you as prisoners - they prefer you dead!", + L"This behaviour is set OFF in your ini settings.", }; STR16 szMTATextStr[]= diff --git a/Utils/_FrenchText.cpp b/Utils/_FrenchText.cpp index 2b3c06ca4..968af1e7b 100644 --- a/Utils/_FrenchText.cpp +++ b/Utils/_FrenchText.cpp @@ -2924,6 +2924,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = 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?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", // TODO.Translate }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7484,6 +7485,8 @@ STR16 szPrisonerTextStr[]= L"Prisoners have been released!", L"The army now occupies the prison in %s, the prisoners were freed!", L"The enemy refuses to surrender!", + L"The enemy refuses to take you as prisoners - they prefer you dead!", // TODO.Translate + L"This behaviour is set OFF in your ini settings.", }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_GermanText.cpp b/Utils/_GermanText.cpp index 202504c5d..f3886ca43 100644 --- a/Utils/_GermanText.cpp +++ b/Utils/_GermanText.cpp @@ -2922,6 +2922,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = 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?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", // TODO.Translate }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7319,6 +7320,8 @@ STR16 szPrisonerTextStr[]= L"Gefangene freigelassen!", L"Die Armee hat das Gefängnis in %s besetzt, die Gefangenen wurden befreit!", L"Der Gegner weigert sich aufzugeben!", + L"Der Gegner will uns tot sehen!", + L"Dieses Feature ist in der ini auf AUS gesetzt.", }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_ItalianText.cpp b/Utils/_ItalianText.cpp index 454b1af71..2606854c6 100644 --- a/Utils/_ItalianText.cpp +++ b/Utils/_ItalianText.cpp @@ -2912,6 +2912,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = 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?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", // TODO.Translate }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7492,6 +7493,8 @@ STR16 szPrisonerTextStr[]= L"Prisoners have been released!", L"The army now occupies the prison in %s, the prisoners were freed!", L"The enemy refuses to surrender!", + L"The enemy refuses to take you as prisoners - they prefer you dead!", // TODO.Translate + L"This behaviour is set OFF in your ini settings.", }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_PolishText.cpp b/Utils/_PolishText.cpp index 6ce9ef869..96d179cc4 100644 --- a/Utils/_PolishText.cpp +++ b/Utils/_PolishText.cpp @@ -2927,6 +2927,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = 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?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", // TODO.Translate }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7506,6 +7507,8 @@ STR16 szPrisonerTextStr[]= L"Prisoners have been released!", L"The army now occupies the prison in %s, the prisoners were freed!", L"The enemy refuses to surrender!", + L"The enemy refuses to take you as prisoners - they prefer you dead!", // TODO.Translate + L"This behaviour is set OFF in your ini settings.", }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_RussianText.cpp b/Utils/_RussianText.cpp index d55556263..745072c16 100644 --- a/Utils/_RussianText.cpp +++ b/Utils/_RussianText.cpp @@ -2920,6 +2920,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = 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?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", // TODO.Translate }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7458,6 +7459,8 @@ STR16 szPrisonerTextStr[]= L"Prisoners have been released!", L"The army now occupies the prison in %s, the prisoners were freed!", L"The enemy refuses to surrender!", + L"The enemy refuses to take you as prisoners - they prefer you dead!", // TODO.Translate + L"This behaviour is set OFF in your ini settings.", }; STR16 szMTATextStr[]= // TODO.Translate diff --git a/Utils/_TaiwaneseText.cpp b/Utils/_TaiwaneseText.cpp index 1563a411b..daac71885 100644 --- a/Utils/_TaiwaneseText.cpp +++ b/Utils/_TaiwaneseText.cpp @@ -2921,6 +2921,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] = 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?", + L"1 - Ask enemy for surrender 2 - Surrender to enemy 3,4 - Talk", // TODO.Translate }; //Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface. @@ -7509,6 +7510,8 @@ STR16 szPrisonerTextStr[]= L"Prisoners have been released!", L"The army now occupies the prison in %s, the prisoners were freed!", L"The enemy refuses to surrender!", + L"The enemy refuses to take you as prisoners - they prefer you dead!", // TODO.Translate + L"This behaviour is set OFF in your ini settings.", }; STR16 szMTATextStr[]= // TODO.Translate