- fix: combo food/drug items have to be eaten if drug effect was already attributed

- new food situation level for the transition from food refusal to dangerous levels
- more useful stat damage warings for food

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5468 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-08-13 21:25:51 +00:00
parent 660d8d126f
commit a61d724335
4 changed files with 33 additions and 17 deletions
+2 -2
View File
@@ -68,7 +68,7 @@ BOOLEAN ApplyDrugs( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject )
} }
BOOLEAN consumeitem = TRUE; 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; UINT32 foodtype = Item[pObject->usItem].foodtype;
// if not a food item, nothing to see here // if not a food item, nothing to see here
@@ -256,7 +256,7 @@ BOOLEAN ApplyDrugs( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject )
fInterfacePanelDirty = DIRTYLEVEL2; fInterfacePanelDirty = DIRTYLEVEL2;
if ( !consumeitem ) if ( !consumeitem )
ApplyFood( pSoldier, pObject, TRUE ); ApplyFood( pSoldier, pObject, TRUE, TRUE );
return( TRUE ); return( TRUE );
} }
+25 -12
View File
@@ -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!!! // 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] = FoodMoraleMod FoodMoraleMods[NUM_FOOD_MORALE_TYPES] =
{ {
{ 100000, -8, -2, -20, -35, 2}, // FOOD_STUFFED { 100000, -8, -3, -20, -35, 2}, // FOOD_STUFFED
{ 5000, -5, -2, -5, -5, 0}, // FOOD_EXTREMELY_FULL { 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 { 2500, 2, -1, -1, 0, 0}, // FOOD_FULL
{ 1000, 5, 0, 0, 0, 0}, // FOOD_SLIGHTLY_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 variables to remember the last food someone was forced to eat
static UINT8 lasteater = 0; static UINT8 lasteater = 0;
@@ -85,13 +86,13 @@ BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce )
type = AP_DRINK; type = AP_DRINK;
// return if we don't have enough APs // 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 ); return( FALSE );
} }
// check if we are willing to eat this: if we're filled, the merc refuses // 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! // Say quote!
TacticalCharacterDialogue( pSoldier, 61 ); TacticalCharacterDialogue( pSoldier, 61 );
@@ -103,7 +104,7 @@ BOOLEAN ApplyFood( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject, BOOLEAN fForce )
FLOAT foodcondition = (*pObject)[0]->data.bTemperature / OVERHEATING_MAX_TEMPERATURE; FLOAT foodcondition = (*pObject)[0]->data.bTemperature / OVERHEATING_MAX_TEMPERATURE;
// food in bad condition is harmful! // 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 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) ) if ( !fForce && ( lasteater != pSoldier->ubID || lastitem != pObject->usItem) )
@@ -363,7 +364,10 @@ void HourlyFoodSituationUpdate( SOLDIERTYPE *pSoldier )
pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock(); pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock();
pSoldier->usValueGoneUp &= ~( STRENGTH_INCREASE ); 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 // damage health
@@ -391,7 +395,10 @@ void HourlyFoodSituationUpdate( SOLDIERTYPE *pSoldier )
gMercProfiles[ pSoldier->ubProfile ].bLifeMax = pSoldier->stats.bLifeMax; gMercProfiles[ pSoldier->ubProfile ].bLifeMax = pSoldier->stats.bLifeMax;
gMercProfiles[ pSoldier->ubProfile ].records.usTimesStatDamaged++; 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... // if we fall below OKLIFE, we start bleeding...
// Reason for this is that // Reason for this is that
@@ -439,7 +446,10 @@ void HourlyFoodSituationUpdate( SOLDIERTYPE *pSoldier )
pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock(); pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock();
pSoldier->usValueGoneUp &= ~( STRENGTH_INCREASE ); 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 // damage health
@@ -467,7 +477,10 @@ void HourlyFoodSituationUpdate( SOLDIERTYPE *pSoldier )
gMercProfiles[ pSoldier->ubProfile ].bLifeMax = pSoldier->stats.bLifeMax; gMercProfiles[ pSoldier->ubProfile ].bLifeMax = pSoldier->stats.bLifeMax;
gMercProfiles[ pSoldier->ubProfile ].records.usTimesStatDamaged++; 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... // if we fall below OKLIFE, we start bleeding...
// Reason for this is that // Reason for this is that
@@ -620,7 +633,7 @@ void EatFromInventory( SOLDIERTYPE *pSoldier, BOOLEAN fcanteensonly )
if ( Item[pObj->usItem].drugtype > 0 ) if ( Item[pObj->usItem].drugtype > 0 )
ApplyDrugs( pSoldier, pObj ); ApplyDrugs( pSoldier, pObj );
else 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 we're full, finish
if ( pSoldier->bFoodLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold ) 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 ) if ( Item[pObj->usItem].drugtype > 0 )
ApplyDrugs( pSoldier, pObj ); ApplyDrugs( pSoldier, pObj );
else 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 we're full, finish
if ( pSoldier->bFoodLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold ) if ( pSoldier->bFoodLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold && pSoldier->bDrinkLevel > FoodMoraleMods[FOOD_MERC_START_CONSUME].bThreshold )
+4 -1
View File
@@ -20,6 +20,7 @@ typedef enum
{ {
FOOD_STUFFED, FOOD_STUFFED,
FOOD_EXTREMELY_FULL, FOOD_EXTREMELY_FULL,
FOOD_VERY_FULL,
FOOD_FULL, FOOD_FULL,
FOOD_SLIGHTLY_FULL, FOOD_SLIGHTLY_FULL,
FOOD_NORMAL, FOOD_NORMAL,
@@ -34,6 +35,7 @@ typedef enum
#define FOOD_MERC_START_CONSUME FOOD_EVEN_LOWER #define FOOD_MERC_START_CONSUME FOOD_EVEN_LOWER
#define FOOD_MERC_STOP_FACILITY FOOD_FULL #define FOOD_MERC_STOP_FACILITY FOOD_FULL
#define FOOD_MERC_REFUSAL FOOD_VERY_FULL
typedef struct typedef struct
{ {
@@ -73,7 +75,8 @@ typedef enum
} FoodSectorWaterSupply; } FoodSectorWaterSupply;
// eat a food object. if fForce = FALSE, the soldier can reject to eat this once // 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 GetFoodSituation( SOLDIERTYPE *pSoldier, UINT8* pFoodSituation, UINT8* pWaterSituation );
void FoodMaxMoraleModifiy( SOLDIERTYPE *pSoldier, UINT8* pubMaxMorale ); void FoodMaxMoraleModifiy( SOLDIERTYPE *pSoldier, UINT8* pubMaxMorale );
+1 -1
View File
@@ -3342,7 +3342,7 @@ void SMInvClickCamoCallback( MOUSE_REGION * pRegion, INT32 iReason )
gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 ); gpSMCurrentMerc->DoMercBattleSound( BATTLE_SOUND_COOL1 );
} }
else if ( gGameOptions.fFoodSystem && ApplyFood( gpSMCurrentMerc, gpItemPointer, FALSE ) ) else if ( gGameOptions.fFoodSystem && ApplyFood( gpSMCurrentMerc, gpItemPointer, FALSE, FALSE ) )
{ {
// Dirty // Dirty
fInterfacePanelDirty = DIRTYLEVEL2; fInterfacePanelDirty = DIRTYLEVEL2;