From 700073aa62762eea3ae352caad65d367c98bd1b7 Mon Sep 17 00:00:00 2001 From: Flugente Date: Thu, 23 Apr 2015 20:58:05 +0000 Subject: [PATCH] Items can now be applied on mercs in Strategic AI.patch(food/camo/drugs/...) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7833 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/mapscreen.cpp | 112 ++++++++++++++++- Tactical/Interface Items.cpp | 99 ++++++++++++++- Tactical/Interface Items.h | 3 + Tactical/Interface Panels.cpp | 225 +++++++++------------------------- 4 files changed, 269 insertions(+), 170 deletions(-) diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 1f50e9af..37e0b015 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -111,6 +111,8 @@ // HEADROCK HAM 4: Include Militia Squads for Manual Militia Restrictions toggle. #include "MilitiaSquads.h" #include "Auto Bandage.h" // added by Flugente + #include "Food.h" // added by Flugente + #include "Drugs And Alcohol.h" // added by Flugente #endif #include "connect.h" //hayden @@ -137,6 +139,8 @@ BOOLEAN fPlotForMilitia = FALSE; UINT32 gMilitiaPlotStartSector = 0; +extern INT8 gbCompatibleApplyItem; + #define MAX_SORT_METHODS 6 // Cursors @@ -9514,8 +9518,104 @@ void HandleCursorOverRifleAmmo( ) void MAPInvClickCamoCallback( MOUSE_REGION *pRegion, INT32 iReason ) { + if ( iReason & MSYS_CALLBACK_REASON_INIT ) + { + return; + } + if ( iReason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) + { + // Apply camo ( if we have something in cursor... ) + // If we do not have an item in hand, start moving it + SOLDIERTYPE* pSoldier = NULL; + if( (bSelectedInfoChar != -1) && (gCharactersList[bSelectedInfoChar].fValid == TRUE) ) + { + pSoldier = MercPtrs[gCharactersList[bSelectedInfoChar].usSolID]; + } + + if ( gpItemPointer && pSoldier ) + { + BOOLEAN fGoodAPs = FALSE; + BOOLEAN fDoSound = FALSE; + // We are doing this ourselve, continue + if ( pSoldier->stats.bLife >= CONSCIOUSNESS ) + { + // Try to apply camo.... + if ( ApplyCammo( pSoldier, gpItemPointer, &fGoodAPs ) ) + { + if ( fGoodAPs ) + { + fDoSound = TRUE; + + // WANNE: We should only delete the face, if there was a camo we applied. + // This should fix the bug and crashes with missing faces + if ( gGameExternalOptions.fShowCamouflageFaces ) + { + // Flugente: refresh face regardless of result of SetCamoFace(), otherwise applying a rag will not clean the picture + SetCamoFace( pSoldier ); + DeleteSoldierFace( pSoldier );// remove face + gpItemPointerSoldier->iFaceIndex = InitSoldierFace( pSoldier );// create new face + } + } + } + else if ( !gGameOptions.fFoodSystem && ApplyCanteen( pSoldier, gpItemPointer, &fGoodAPs, TRUE ) ) + { + ; + } + else if ( ApplyElixir( pSoldier, gpItemPointer, &fGoodAPs ) ) + { + fDoSound = TRUE; + } + else if ( ApplyDrugs( pSoldier, gpItemPointer ) ) + { + fGoodAPs = TRUE; + fDoSound = TRUE; + } + else if ( gGameOptions.fFoodSystem && ApplyFood( pSoldier, gpItemPointer, FALSE, FALSE ) ) + { + fGoodAPs = TRUE; + } + else if ( ApplyClothes( pSoldier, gpItemPointer ) ) + { + fGoodAPs = TRUE; + } + else + { + // Send message + //Heinz: 23.02.09 BUGFIX: Don't send message when SKI is on + if ( !(guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE) ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[CANNOT_DO_INV_STUFF_STR] ); + } + + // Check if it's the same now! + if ( !gpItemPointer->exists( ) ) + { + gbCompatibleApplyItem = FALSE; + //EndItemPointer( ); + MAPEndItemPointer( ); + } + + if ( fGoodAPs ) + { + // Dirty + fInterfacePanelDirty = DIRTYLEVEL2; + + UpdateMercBodyRegionHelpText( ); + } + + if ( fDoSound ) + { + // Say OK acknowledge.... + pSoldier->DoMercBattleSound( BATTLE_SOUND_COOL1 ); + } + } + } + } + else if ( iReason & MSYS_CALLBACK_REASON_RBUTTON_DWN ) + { + + } } void MAPInvMoveCamoCallback( MOUSE_REGION *pRegion, INT32 iReason ) @@ -13608,15 +13708,17 @@ void PrevInventoryMapBtnCallback( GUI_BUTTON *btn, INT32 reason ) { if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) { - btn->uiFlags|=(BUTTON_CLICKED_ON); + btn->uiFlags|=(BUTTON_CLICKED_ON); } else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP ) { - if (btn->uiFlags & BUTTON_CLICKED_ON) + if (btn->uiFlags & BUTTON_CLICKED_ON) { btn->uiFlags&= ~(BUTTON_CLICKED_ON); fResetMapCoords = TRUE; GoToPrevCharacterInList( ); + + UpdateMercBodyRegionHelpText(); } } } @@ -13626,15 +13728,17 @@ void NextInventoryMapBtnCallback( GUI_BUTTON *btn, INT32 reason ) { if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) { - btn->uiFlags|=(BUTTON_CLICKED_ON); + btn->uiFlags|=(BUTTON_CLICKED_ON); } else if(reason & MSYS_CALLBACK_REASON_LBUTTON_UP ) { - if (btn->uiFlags & BUTTON_CLICKED_ON) + if (btn->uiFlags & BUTTON_CLICKED_ON) { btn->uiFlags&= ~(BUTTON_CLICKED_ON); fResetMapCoords = TRUE; GoToNextCharacterInList( ); + + UpdateMercBodyRegionHelpText( ); } } } diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 7e3a0efd..dd64de00 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -568,7 +568,7 @@ UINT16 us16BPPItemCyclePlacedItemColors[ 20 ]; // Kaiden: Vehicle Inventory change - Increase this from 4-2 to 5-2 UINT32 guiBodyInvVO[ 5 ][ 2 ]; UINT32 guiGoldKeyVO; -INT8 gbCompatibleApplyItem = FALSE; +INT8 gbCompatibleApplyItem = FALSE; // HEADROCK HAM 4: New region coordinate tables for UDB INV_DESC_REGIONS gItemDescLBEBackground[4]; // Coordinates for displaying LBE background image @@ -1471,8 +1471,10 @@ BOOLEAN InitInvSlotInterface( INV_REGION_DESC *pRegionDesc , INV_REGION_DESC *pC // Add region MSYS_AddRegion( &gSMInvCamoRegion ); + UpdateMercBodyRegionHelpText(); + // Add regions for inventory slots - for ( cnt = 0; cnt < NUM_INV_SLOTS; cnt++ ) + for ( cnt = 0; cnt < NUM_INV_SLOTS; ++cnt ) { // set inventory pocket coordinates from the table passed in gSMInvData[ cnt ].sX = pRegionDesc[ cnt ].sX; @@ -14443,4 +14445,97 @@ BOOLEAN CheckPocketEmpty( SOLDIERTYPE *pSoldier, INT16 sPocket ) } } return bResult; +} + +// Flugente: update merc info text on merc body silhouette in strategic view +void UpdateMercBodyRegionHelpText( ) +{ + if ( !(gSMInvCamoRegion.uiFlags & MSYS_REGION_EXISTS) ) + return; + + if ( (bSelectedInfoChar != -1) && (gCharactersList[bSelectedInfoChar].fValid == TRUE) ) + { + CHAR16 sString[6000]; + CHAR16 pMoraleStr[128]; + SOLDIERTYPE *pSoldier = NULL; + + wcscpy( sString, L"" ); + + // valid soldier selected + pSoldier = MercPtrs[gCharactersList[bSelectedInfoChar].usSolID]; + + // health/energy/morale + if ( pSoldier->bAssignment != ASSIGNMENT_POW ) + { + if ( pSoldier->stats.bLife != 0 ) + { + if ( AM_A_ROBOT( pSoldier ) ) + { + // robot (condition only) + swprintf( sString, L"%s: %d/%d", pMapScreenStatusStrings[3], pSoldier->stats.bLife, pSoldier->stats.bLifeMax ); + } + else if ( Menptr[gCharactersList[bSelectedInfoChar].usSolID].flags.uiStatusFlags & SOLDIER_VEHICLE ) + { + // vehicle (condition/fuel) + swprintf( sString, L"%s: %d/%d, %s: %d/%d", + pMapScreenStatusStrings[3], pSoldier->stats.bLife, pSoldier->stats.bLifeMax, + pMapScreenStatusStrings[4], pSoldier->bBreath, pSoldier->bBreathMax ); + } + else + { + // person (health/energy/morale) + GetMoraleString( pSoldier, pMoraleStr ); + + if ( gGameOptions.fFoodSystem ) + { + if ( pSoldier->bPoisonSum ) + { + INT8 bPoisonBandaged = pSoldier->bPoisonSum - pSoldier->bPoisonBleeding - pSoldier->bPoisonLife; + swprintf( sString, L"%s: %d/%d, %s: %d/%d/%d - %d, %s: %d/%d, %s: %s, %s: %d%s, %s: %d%s", + pMapScreenStatusStrings[0], pSoldier->stats.bLife, pSoldier->stats.bLifeMax, + pMapScreenStatusStrings[5], pSoldier->bPoisonBleeding, bPoisonBandaged, pSoldier->bPoisonLife, pSoldier->bPoisonSum, + pMapScreenStatusStrings[1], pSoldier->bBreath, pSoldier->bBreathMax, + pMapScreenStatusStrings[2], pMoraleStr, + pMapScreenStatusStrings[6], (INT32)(100 * (pSoldier->bDrinkLevel - FOOD_MIN) / FOOD_HALF_RANGE), sSpecialCharacters[0], + pMapScreenStatusStrings[7], (INT32)(100 * (pSoldier->bFoodLevel - FOOD_MIN) / FOOD_HALF_RANGE), sSpecialCharacters[0] ); + } + else + { + swprintf( sString, L"%s: %d/%d, %s: %d/%d, %s: %s, %s: %d%s, %s: %d%s", + pMapScreenStatusStrings[0], pSoldier->stats.bLife, pSoldier->stats.bLifeMax, + pMapScreenStatusStrings[1], pSoldier->bBreath, pSoldier->bBreathMax, + pMapScreenStatusStrings[2], pMoraleStr, + pMapScreenStatusStrings[6], (INT32)(100 * (pSoldier->bDrinkLevel - FOOD_MIN) / FOOD_HALF_RANGE), sSpecialCharacters[0], + pMapScreenStatusStrings[7], (INT32)(100 * (pSoldier->bFoodLevel - FOOD_MIN) / FOOD_HALF_RANGE), sSpecialCharacters[0] ); + } + } + else + { + if ( pSoldier->bPoisonSum ) + { + INT8 bPoisonBandaged = pSoldier->bPoisonSum - pSoldier->bPoisonBleeding - pSoldier->bPoisonLife; + swprintf( sString, L"%s: %d/%d, %s: %d/%d/%d - %d, %s: %d/%d, %s: %s", + pMapScreenStatusStrings[0], pSoldier->stats.bLife, pSoldier->stats.bLifeMax, + pMapScreenStatusStrings[5], pSoldier->bPoisonBleeding, bPoisonBandaged, pSoldier->bPoisonLife, pSoldier->bPoisonSum, + pMapScreenStatusStrings[1], pSoldier->bBreath, pSoldier->bBreathMax, + pMapScreenStatusStrings[2], pMoraleStr ); + } + else + { + swprintf( sString, L"%s: %d/%d, %s: %d/%d, %s: %s", + pMapScreenStatusStrings[0], pSoldier->stats.bLife, pSoldier->stats.bLifeMax, + pMapScreenStatusStrings[1], pSoldier->bBreath, pSoldier->bBreathMax, + pMapScreenStatusStrings[2], pMoraleStr ); + } + } + + { + pSoldier->PrintDiseaseDesc( sString, TRUE ); + } + } + } + } + + SetRegionFastHelpText( &gSMInvCamoRegion, sString ); + } } \ No newline at end of file diff --git a/Tactical/Interface Items.h b/Tactical/Interface Items.h index 1ebd241f..b23b54b9 100644 --- a/Tactical/Interface Items.h +++ b/Tactical/Interface Items.h @@ -364,4 +364,7 @@ void addRocketAmmoToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* po void addMiscToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* popup ); void addKitsToPocketPopup( SOLDIERTYPE *pSoldier, INT16 sPocket, POPUP* popup ); +// Flugente: update merc info text on merc body silhouette in strategic view +void UpdateMercBodyRegionHelpText( ); + #endif diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index b1e59c3f..71328ae7 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -3319,10 +3319,6 @@ void SMInvMoveCammoCallback( MOUSE_REGION * pRegion, INT32 iReason ) void SMInvClickCamoCallback( MOUSE_REGION * pRegion, INT32 iReason ) { - //UINT16 usNewItemIndex; - UINT8 ubSrcID, ubDestID; - BOOLEAN fGoodAPs; - if (iReason & MSYS_CALLBACK_REASON_INIT) { return; @@ -3332,177 +3328,78 @@ void SMInvClickCamoCallback( MOUSE_REGION * pRegion, INT32 iReason ) { // Apply camo ( if we have something in cursor... ) // If we do not have an item in hand, start moving it - - if ( gpItemPointer != NULL ) + if ( gpItemPointer ) { - // ATE: OK, get source, dest guy if different... check for and then charge appropriate APs - ubSrcID = gpSMCurrentMerc->ubID; - ubDestID = gpItemPointerSoldier->ubID; + BOOLEAN fGoodAPs = FALSE; + BOOLEAN fDoSound = FALSE; - //if ( ubSrcID == ubDestID ) + // We are doing this ourselve, continue + if ( gpSMCurrentMerc->stats.bLife >= CONSCIOUSNESS ) { - // We are doing this ourselve, continue - if ( gpSMCurrentMerc->stats.bLife >= CONSCIOUSNESS ) + // Try to apply camo.... + if ( ApplyCammo( gpSMCurrentMerc, gpItemPointer, &fGoodAPs ) ) { - //usNewItemIndex = gpItemPointer->usItem; - - // Try to apply camo.... - if ( ApplyCammo( gpSMCurrentMerc, gpItemPointer, &fGoodAPs ) ) + if ( fGoodAPs ) { - if ( fGoodAPs ) + fDoSound = TRUE; + + // WANNE: We should only delete the face, if there was a camo we applied. + // This should fix the bug and crashes with missing faces + if (gGameExternalOptions.fShowCamouflageFaces ) { - // WANNE: Old method for applying camo - /* - if (gGameExternalOptions.fShowCamouflageFaces == TRUE ) - { - if ( gpSMCurrentMerc->bCamo > 0 ) - { - gCamoFace[gpSMCurrentMerc->ubProfile].gCamoface = TRUE; - DeleteSoldierFace( gpSMCurrentMerc );// remove face - gpSMCurrentMerc->iFaceIndex = InitSoldierFace( gpSMCurrentMerc );// create new face - } - if ( gpSMCurrentMerc->urbanCamo > 0 ) - { - gCamoFace[gpSMCurrentMerc->ubProfile].gUrbanCamoface = TRUE; - DeleteSoldierFace( gpSMCurrentMerc );// remove face - gpSMCurrentMerc->iFaceIndex = InitSoldierFace( gpSMCurrentMerc );// create new face - } - if ( gpSMCurrentMerc->desertCamo > 0) - { - gCamoFace[gpSMCurrentMerc->ubProfile].gDesertCamoface = TRUE; - DeleteSoldierFace( gpSMCurrentMerc );// remove face - gpSMCurrentMerc->iFaceIndex = InitSoldierFace( gpSMCurrentMerc );// create new face - } - if ( gpSMCurrentMerc->snowCamo > 0) - { - gCamoFace[gpSMCurrentMerc->ubProfile].gSnowCamoface = TRUE; - DeleteSoldierFace( gpSMCurrentMerc );// remove face - gpSMCurrentMerc->iFaceIndex = InitSoldierFace( gpSMCurrentMerc );// create new face - } - } - */ - - // WANNE: We should only delete the face, if there was a camo we applied. - // This should fix the bug and crashes with missing faces - if (gGameExternalOptions.fShowCamouflageFaces == TRUE ) - { - // Flugente: refresh face regardless of result of SetCamoFace(), otherwise applying a rag will not clean the picture - SetCamoFace( gpSMCurrentMerc ); - DeleteSoldierFace( gpSMCurrentMerc );// remove face - gpSMCurrentMerc->iFaceIndex = InitSoldierFace( gpSMCurrentMerc );// create new face - } - - - // Dirty - fInterfacePanelDirty = DIRTYLEVEL2; - - // Check if it's the same now! - if ( gpItemPointer->exists() == false ) - { - gbCompatibleApplyItem = FALSE; - EndItemPointer( ); - } - - // Say OK acknowledge.... - gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); - } - } - else if ( !gGameOptions.fFoodSystem && ApplyCanteen( gpSMCurrentMerc, gpItemPointer, &fGoodAPs, TRUE ) ) - { - // Dirty - if ( fGoodAPs ) - { - fInterfacePanelDirty = DIRTYLEVEL2; - - // Check if it's the same now! - if ( gpItemPointer->exists() == false ) - { - gbCompatibleApplyItem = FALSE; - EndItemPointer( ); - } + // Flugente: refresh face regardless of result of SetCamoFace(), otherwise applying a rag will not clean the picture + SetCamoFace( gpSMCurrentMerc ); + DeleteSoldierFace( gpSMCurrentMerc );// remove face + gpSMCurrentMerc->iFaceIndex = InitSoldierFace( gpSMCurrentMerc );// create new face } } - else if ( ApplyElixir( gpSMCurrentMerc, gpItemPointer, &fGoodAPs ) ) - { - if ( fGoodAPs ) - { - // Dirty - fInterfacePanelDirty = DIRTYLEVEL2; + } + else if ( !gGameOptions.fFoodSystem && ApplyCanteen( gpSMCurrentMerc, gpItemPointer, &fGoodAPs, TRUE ) ) + { + ; + } + else if ( ApplyElixir( gpSMCurrentMerc, gpItemPointer, &fGoodAPs ) ) + { + fDoSound = TRUE; + } + else if ( ApplyDrugs( gpSMCurrentMerc, gpItemPointer ) ) + { + fGoodAPs = TRUE; + fDoSound = TRUE; + } + else if ( gGameOptions.fFoodSystem && ApplyFood( gpSMCurrentMerc, gpItemPointer, FALSE, FALSE ) ) + { + fGoodAPs = TRUE; + } + else if ( ApplyClothes( gpSMCurrentMerc, gpItemPointer ) ) + { + fGoodAPs = TRUE; + } + else + { + // Send message + //Heinz: 23.02.09 BUGFIX: Don't send message when SKI is on + if( !( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ CANNOT_DO_INV_STUFF_STR ] ); + } - // Check if it's the same now! - if ( gpItemPointer->exists() == false ) - { - gbCompatibleApplyItem = FALSE; - EndItemPointer( ); - } + // Check if it's the same now! + if ( !gpItemPointer->exists( ) ) + { + gbCompatibleApplyItem = FALSE; + EndItemPointer( ); + } - // Say OK acknowledge.... - gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); - } - } - else if ( ApplyDrugs( gpSMCurrentMerc, gpItemPointer ) ) - { - // Dirty - fInterfacePanelDirty = DIRTYLEVEL2; + if ( fGoodAPs ) + { + // Dirty + fInterfacePanelDirty = DIRTYLEVEL2; + } - // Check if it's the same now! - if ( gpItemPointer->exists() == false ) - { - gbCompatibleApplyItem = FALSE; - EndItemPointer( ); - } - - /* - // COMMENTED OUT DUE TO POTENTIAL SERIOUS PROBLEMS WITH STRATEGIC EVENT SYSTEM - - if ( gpSMCurrentMerc->ubProfile == LARRY_NORMAL ) - { - // Larry's taken something! - gpSMCurrentMerc = SwapLarrysProfiles( gpSMCurrentMerc ); - } - */ - - - // Say OK acknowledge.... - gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); - - } - else if ( gGameOptions.fFoodSystem && ApplyFood( gpSMCurrentMerc, gpItemPointer, FALSE, FALSE ) ) - { - // Dirty - fInterfacePanelDirty = DIRTYLEVEL2; - - // Check if it's the same now! - if ( gpItemPointer->exists() == false ) - { - gbCompatibleApplyItem = FALSE; - EndItemPointer( ); - } - - // Say OK acknowledge.... - gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); - } - else if ( ApplyClothes( gpSMCurrentMerc, gpItemPointer ) ) - { - // Dirty - fInterfacePanelDirty = DIRTYLEVEL2; - - // Check if it's the same now! - if ( gpItemPointer->exists() == false ) - { - gbCompatibleApplyItem = FALSE; - EndItemPointer( ); - } - - // Say OK acknowledge.... - gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); - } - else - { - // Send message - //Heinz: 23.02.09 BUGFIX: Don't send message when SKI is on - if( !( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) ) ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ CANNOT_DO_INV_STUFF_STR ] ); - } + if ( fDoSound ) + { + // Say OK acknowledge.... + gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); } } }