From 3eb699c45fe160bff214aca8ff55319fd5945ab6 Mon Sep 17 00:00:00 2001 From: Sevenfm Date: Fri, 10 Apr 2020 21:20:05 +0000 Subject: [PATCH] Walkman: bonus 20% to morale when in head slot. Update soldier morale every turn. Update soldier morale when changing inventory. Improved code for 'l' hotkey. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8783 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/mapscreen.cpp | 3 +++ Tactical/Interface Panels.cpp | 3 +++ Tactical/Items.cpp | 14 ++++++-------- Tactical/Morale.cpp | 9 +++++++++ Tactical/Soldier Control.cpp | 3 +++ Tactical/Turn Based Input.cpp | 33 +-------------------------------- TacticalAI/Attacks.cpp | 2 -- 7 files changed, 25 insertions(+), 42 deletions(-) diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 4afc7a7c..68a69289 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -9881,6 +9881,9 @@ void MAPInvClickCallback( MOUSE_REGION *pRegion, INT32 iReason ) } } } + + // sevenfm: update morale, as we could add/remove walkman + RefreshSoldierMorale(pSoldier); } else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_DWN) { diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 0e02cf9e..f1a1691b 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -4005,6 +4005,9 @@ void SMInvClickCallback( MOUSE_REGION * pRegion, INT32 iReason ) // Flugente: we have to recheck our flashlights, as we changed items //gpSMCurrentMerc->usSoldierFlagMask |= SOLDIER_REDOFLASHLIGHT; gpSMCurrentMerc->HandleFlashLights(); + + // sevenfm: update morale, as we could add/remove walkman + RefreshSoldierMorale(gpSMCurrentMerc); } else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_DWN) { diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index c046ea9e..296f0b15 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -12254,19 +12254,17 @@ INT8 FindLocksmithKit( SOLDIERTYPE * pSoldier ) return( FoundKit ); } -INT8 FindWalkman( SOLDIERTYPE * pSoldier ) +INT8 FindWalkman(SOLDIERTYPE * pSoldier) { - for (INT8 bLoop = BODYPOSSTART; bLoop < BODYPOSFINAL; ++bLoop) + // sevenfm: walkman only works from head slot + for (INT8 bLoop = HEAD1POS; bLoop <= HEAD2POS; bLoop++) { - if (pSoldier->inv[bLoop].exists() ) + if (pSoldier->inv[bLoop].exists() && Item[pSoldier->inv[bLoop].usItem].walkman) { - if (Item[pSoldier->inv[bLoop].usItem].walkman ) - { - return( bLoop ); - } + return(bLoop); } } - return( NO_SLOT ); + return(NO_SLOT); } INT8 FindTrigger( SOLDIERTYPE * pSoldier ) diff --git a/Tactical/Morale.cpp b/Tactical/Morale.cpp index 5a106cbd..402a9466 100644 --- a/Tactical/Morale.cpp +++ b/Tactical/Morale.cpp @@ -391,6 +391,15 @@ void RefreshSoldierMorale( SOLDIERTYPE * pSoldier ) // Flugente: drug system has been redone iActualMorale += pSoldier->newdrugs.size[DRUG_EFFECT_MORALE]; + // sevenfm: bonus 20% to morale when using walkman + if (FindWalkman(pSoldier) != NO_SLOT && pSoldier->bDeafenedCounter == 0) + { + if (pSoldier->ubProfile != NO_PROFILE && gMercProfiles[pSoldier->ubProfile].bDisability == DEAF) + iActualMorale += iActualMorale / 10; + else + iActualMorale += iActualMorale / 5; + } + iActualMorale = __min( 100, iActualMorale ); iActualMorale = __max( 0, iActualMorale ); diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 2aba1b5b..4f2f85c2 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -7875,6 +7875,9 @@ void SOLDIERTYPE::EVENT_BeginMercTurn( BOOLEAN fFromRealTime, INT32 iRealTimeCou HandleEndTurnDrugAdjustments_New( this ); } + // sevenfm: update morale + RefreshSoldierMorale(this); + // ATE: Don't bleed if in AUTO BANDAGE! if ( !gTacticalStatus.fAutoBandageMode ) { diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 805cbca5..c4cf3028 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -3840,7 +3840,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) break; #endif } - if (fAlt ) + else if (fAlt ) { // used for quickloading } @@ -3849,37 +3849,6 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) // used for loading game } else - /* - if( fAlt ) - { - if ( !( gTacticalStatus.uiFlags & ENGAGED_IN_CONV ) ) - { - LeaveTacticalScreen( GAME_SCREEN ); - - DoQuickLoad(); - } - } - - else if( fCtrl ) - { - if ( !( gTacticalStatus.uiFlags & ENGAGED_IN_CONV ) ) - { - - gfSaveGame = FALSE; - gfCameDirectlyFromGame = TRUE; - - guiPreviousOptionScreen = GAME_SCREEN; - LeaveTacticalScreen( SAVE_LOAD_SCREEN ); - } - *//* - if ( INFORMATION_CHEAT_LEVEL( ) ) - { - *puiNewEvent = I_LEVELNODEDEBUG; - CountLevelNodes(); - } - *//* - } - else*/ { // nothing in hand and either not in SM panel, or the matching button is enabled if we are in SM panel if ( ( gpItemPointer == NULL ) && diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index df7eac0c..addc5344 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -2960,8 +2960,6 @@ void CheckIfShotPossible(SOLDIERTYPE *pSoldier, ATTACKTYPE *pBestShot) { INT16 ubMinAPcost; pBestShot->ubPossible = FALSE; - pBestShot->bWeaponIn = NO_SLOT; - pBestShot->bWeaponIn = FindAIUsableObjClass(pSoldier, IC_GUN); // if the soldier does have a gun