diff --git a/Tactical/Drugs And Alcohol.cpp b/Tactical/Drugs And Alcohol.cpp index db136396..6d1caf5a 100644 --- a/Tactical/Drugs And Alcohol.cpp +++ b/Tactical/Drugs And Alcohol.cpp @@ -68,7 +68,7 @@ BOOLEAN ApplyDrugs( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject ) } BOOLEAN consumeitem = TRUE; - // if item is also a food iem, don't use it up here, it will be consumed in ApplyFood, which will be called afterwards + // if item is also a food item, don't use it up here, it will be consumed in ApplyFood, which will be called afterwards UINT32 foodtype = Item[pObject->usItem].foodtype; // if not a food item, nothing to see here @@ -256,7 +256,7 @@ BOOLEAN ApplyDrugs( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject ) fInterfacePanelDirty = DIRTYLEVEL2; if ( !consumeitem ) - ApplyFood( pSoldier, pObject, TRUE ); + ApplyFood( pSoldier, pObject, TRUE, TRUE ); return( TRUE ); } diff --git a/Tactical/Food.cpp b/Tactical/Food.cpp index f9dd99bc..b8ef6404 100644 --- a/Tactical/Food.cpp +++ b/Tactical/Food.cpp @@ -43,8 +43,9 @@ extern BOOLEAN GetSectorFlagStatus( INT16 sMapX, INT16 sMapY, UINT8 bMapZ, UINT3 // apart from the ubStatDamageChance values, be careful not to set any modifiers below -50 or above 0 unless you know what you are doing!!! FoodMoraleMod FoodMoraleMods[NUM_FOOD_MORALE_TYPES] = { - { 100000, -8, -2, -20, -35, 2}, // FOOD_STUFFED - { 5000, -5, -2, -5, -5, 0}, // FOOD_EXTREMELY_FULL + { 100000, -8, -3, -20, -35, 2}, // FOOD_STUFFED + { 7500, -5, -2, -5, -5, 0}, // FOOD_EXTREMELY_FULL + { 5000, 0, -1, -2, -2, 0}, // FOOD_VERY_FULL { 2500, 2, -1, -1, 0, 0}, // FOOD_FULL { 1000, 5, 0, 0, 0, 0}, // FOOD_SLIGHTLY_FULL @@ -59,7 +60,7 @@ FoodMoraleMod FoodMoraleMods[NUM_FOOD_MORALE_TYPES] = }; -BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce ) +BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce, BOOLEAN fForceFromDrugs ) { // static variables to remember the last food someone was forced to eat static UINT8 lasteater = 0; @@ -85,13 +86,13 @@ BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce ) type = AP_DRINK; // return if we don't have enough APs - if (!EnoughPoints( pSoldier, APBPConstants[type], 0, TRUE ) ) + if ( !fForceFromDrugs && !EnoughPoints( pSoldier, APBPConstants[type], 0, TRUE ) ) { return( FALSE ); } // check if we are willing to eat this: if we're filled, the merc refuses - if ( ( ( Food[foodtype].bFoodPoints > 0 && pSoldier->bFoodLevel > FoodMoraleMods[FOOD_EXTREMELY_FULL].bThreshold ) || Food[foodtype].bFoodPoints <= 0 ) && ( ( Food[foodtype].bDrinkPoints > 0 && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_EXTREMELY_FULL].bThreshold ) || Food[foodtype].bDrinkPoints <= 0 ) ) + if ( !fForceFromDrugs && ( ( Food[foodtype].bFoodPoints > 0 && pSoldier->bFoodLevel > FoodMoraleMods[FOOD_MERC_REFUSAL].bThreshold ) || Food[foodtype].bFoodPoints <= 0 ) && ( ( Food[foodtype].bDrinkPoints > 0 && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_MERC_REFUSAL].bThreshold ) || Food[foodtype].bDrinkPoints <= 0 ) ) { // Say quote! TacticalCharacterDialogue( pSoldier, 61 ); @@ -103,7 +104,7 @@ BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce ) FLOAT foodcondition = (*pObject)[0]->data.bTemperature / OVERHEATING_MAX_TEMPERATURE; // food in bad condition is harmful! - if ( foodcondition < FOOD_BAD_THRESHOLD ) + if ( !fForceFromDrugs && foodcondition < FOOD_BAD_THRESHOLD ) { // if we can choose to reject a food and haven't yet done so with this type of bad food, do so. Works only once if ( !fForce && ( lasteater != pSoldier->ubID || lastitem != pObject->usItem) ) @@ -363,7 +364,10 @@ void HourlyFoodSituationUpdate( SOLDIERTYPE *pSoldier ) pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock(); pSoldier->usValueGoneUp &= ~( STRENGTH_INCREASE ); - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's strength was damaged due to lack of nutrition!", pSoldier->name ); + if ( foodsituation > FOOD_NORMAL ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's strength was damaged due to being overfed!", pSoldier->name ); + else + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's strength was damaged due to lack of nutrition!", pSoldier->name ); } // damage health @@ -390,8 +394,11 @@ void HourlyFoodSituationUpdate( SOLDIERTYPE *pSoldier ) // Update Profile gMercProfiles[ pSoldier->ubProfile ].bLifeMax = pSoldier->stats.bLifeMax; gMercProfiles[ pSoldier->ubProfile ].records.usTimesStatDamaged++; - - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's health was damaged due to lack of nutrition!", pSoldier->name ); + + if ( foodsituation > FOOD_NORMAL ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's health was damaged due to being overfed!", pSoldier->name ); + else + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's health was damaged due to lack of nutrition!", pSoldier->name ); // if we fall below OKLIFE, we start bleeding... // Reason for this is that @@ -439,7 +446,10 @@ void HourlyFoodSituationUpdate( SOLDIERTYPE *pSoldier ) pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock(); pSoldier->usValueGoneUp &= ~( STRENGTH_INCREASE ); - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's strength was damaged due to lack of nutrition!", pSoldier->name ); + if ( watersituation > FOOD_NORMAL ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's strength was damaged due to excessive drinking!", pSoldier->name ); + else + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's strength was damaged due to lack of water!", pSoldier->name ); } // damage health @@ -467,7 +477,10 @@ void HourlyFoodSituationUpdate( SOLDIERTYPE *pSoldier ) gMercProfiles[ pSoldier->ubProfile ].bLifeMax = pSoldier->stats.bLifeMax; gMercProfiles[ pSoldier->ubProfile ].records.usTimesStatDamaged++; - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's health was damaged due to lack of nutrition!", pSoldier->name ); + if ( watersituation > FOOD_NORMAL ) + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's health was damaged due to excessive drinking!", pSoldier->name ); + else + ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%s's health was damaged due to lack of water!", pSoldier->name ); // if we fall below OKLIFE, we start bleeding... // Reason for this is that @@ -620,7 +633,7 @@ void EatFromInventory( SOLDIERTYPE *pSoldier, BOOLEAN fcanteensonly ) if ( Item[pObj->usItem].drugtype > 0 ) ApplyDrugs( pSoldier, pObj ); else - ApplyFood( pSoldier, pObj, TRUE ); // cannot reject to eat this, we chose to eat this ourself! + ApplyFood( pSoldier, pObj, TRUE, FALSE ); // cannot reject to eat this, we chose to eat this ourself! // if we're full, finish if ( pSoldier->bFoodLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold ) @@ -659,7 +672,7 @@ void EatFromInventory( SOLDIERTYPE *pSoldier, BOOLEAN fcanteensonly ) if ( Item[pObj->usItem].drugtype > 0 ) ApplyDrugs( pSoldier, pObj ); else - ApplyFood( pSoldier, pObj, TRUE ); // cannot reject to eat this, we chose to eat this ourself! + ApplyFood( pSoldier, pObj, TRUE, FALSE ); // cannot reject to eat this, we chose to eat this ourself! // if we're full, finish if ( pSoldier->bFoodLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold ) diff --git a/Tactical/Food.h b/Tactical/Food.h index a1fd5087..01cdbed7 100644 --- a/Tactical/Food.h +++ b/Tactical/Food.h @@ -20,6 +20,7 @@ typedef enum { FOOD_STUFFED, FOOD_EXTREMELY_FULL, + FOOD_VERY_FULL, FOOD_FULL, FOOD_SLIGHTLY_FULL, FOOD_NORMAL, @@ -34,6 +35,7 @@ typedef enum #define FOOD_MERC_START_CONSUME FOOD_EVEN_LOWER #define FOOD_MERC_STOP_FACILITY FOOD_FULL +#define FOOD_MERC_REFUSAL FOOD_VERY_FULL typedef struct { @@ -73,7 +75,8 @@ typedef enum } FoodSectorWaterSupply; // eat a food object. if fForce = FALSE, the soldier can reject to eat this once -BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce ); +// if fForceFromDrugs = TRUE, we HAVE to eat this, because we already got the effects from the ApplyDrugs-function (item is both drug and food) +BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce, BOOLEAN fForceFromDrugs ); void GetFoodSituation( SOLDIERTYPE *pSoldier, UINT8* pFoodSituation, UINT8* pWaterSituation ); void FoodMaxMoraleModifiy( SOLDIERTYPE *pSoldier, UINT8* pubMaxMorale ); diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 01efe0d6..1af9d602 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -3342,7 +3342,7 @@ void SMInvClickCamoCallback( MOUSE_REGION * pRegion, INT32 iReason ) gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); } - else if ( gGameOptions.fFoodSystem && ApplyFood( gpSMCurrentMerc, gpItemPointer, FALSE ) ) + else if ( gGameOptions.fFoodSystem && ApplyFood( gpSMCurrentMerc, gpItemPointer, FALSE, FALSE ) ) { // Dirty fInterfacePanelDirty = DIRTYLEVEL2;