- Drug effects on first aid kits can be applied during bandaging

- Drug consumption opinion event, Larry personality change and increase of 'drugs taken' counter only occur if a drug if genuine drug effects were applied. As a result purely disease-causing items no longer cause these events.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8649 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2019-01-24 21:38:08 +00:00
parent 0ab562c29e
commit 253db89460
3 changed files with 35 additions and 22 deletions
+29 -21
View File
@@ -42,6 +42,9 @@ BOOLEAN ApplyDrugs_New( SOLDIERTYPE *pSoldier, UINT16 usItem, UINT16 uStatusUsed
UINT32 drugused = Item[usItem].drugtype;
// to stop Larry from getting stoned via unsanitary bandages etc., note whether this is a 'real' drug
BOOL complainworthyeffects = FALSE;
// we might not use up the entire item, so reduce effects accordingly
FLOAT effectivepercentage = uStatusUsed / 100.0;
@@ -93,6 +96,8 @@ BOOLEAN ApplyDrugs_New( SOLDIERTYPE *pSoldier, UINT16 usItem, UINT16 uStatusUsed
pSoldier->newdrugs.duration[(*drug_effects_it).effect] = (*drug_effects_it).duration;
pSoldier->newdrugs.size[(*drug_effects_it).effect] = (*drug_effects_it).size * effectivepercentage;
}
complainworthyeffects = TRUE;
}
}
@@ -147,28 +152,31 @@ BOOLEAN ApplyDrugs_New( SOLDIERTYPE *pSoldier, UINT16 usItem, UINT16 uStatusUsed
}
}
}
// do switch for Larry!!
if ( pSoldier->ubProfile == LARRY_NORMAL )
{
SwapToProfile( pSoldier, LARRY_DRUNK );
gMercProfiles[LARRY_NORMAL].bNPCData = LARRY_FALLS_OFF_WAGON;
}
else if ( pSoldier->ubProfile == LARRY_DRUNK )
{
// NB store all drunkenness info in LARRY_NORMAL profile (to use same values)
// so long as he keeps consuming, keep number above level at which he cracked
gMercProfiles[LARRY_NORMAL].bNPCData += (INT8)Random( 5 );
// allow value to keep going up to 24 (about 2 days since we subtract Random( 2 ) when he has no access )
gMercProfiles[LARRY_NORMAL].bNPCData = __min( gMercProfiles[LARRY_NORMAL].bNPCData, 24 );
gMercProfiles[LARRY_NORMAL].bNPCData = __max( gMercProfiles[LARRY_NORMAL].bNPCData, LARRY_FALLS_OFF_WAGON );
}
if ( NewDrug[drugused].opinionevent )
if ( complainworthyeffects )
{
HandleDynamicOpinionChange( pSoldier, OPINIONEVENT_ADDICT, TRUE, TRUE );
// do switch for Larry!!
if ( pSoldier->ubProfile == LARRY_NORMAL )
{
SwapToProfile( pSoldier, LARRY_DRUNK );
gMercProfiles[LARRY_NORMAL].bNPCData = LARRY_FALLS_OFF_WAGON;
}
else if ( pSoldier->ubProfile == LARRY_DRUNK )
{
// NB store all drunkenness info in LARRY_NORMAL profile (to use same values)
// so long as he keeps consuming, keep number above level at which he cracked
gMercProfiles[LARRY_NORMAL].bNPCData += (INT8)Random( 5 );
// allow value to keep going up to 24 (about 2 days since we subtract Random( 2 ) when he has no access )
gMercProfiles[LARRY_NORMAL].bNPCData = __min( gMercProfiles[LARRY_NORMAL].bNPCData, 24 );
gMercProfiles[LARRY_NORMAL].bNPCData = __max( gMercProfiles[LARRY_NORMAL].bNPCData, LARRY_FALLS_OFF_WAGON );
}
if ( NewDrug[drugused].opinionevent )
{
HandleDynamicOpinionChange( pSoldier, OPINIONEVENT_ADDICT, TRUE, TRUE );
}
}
if ( Item[usItem].alcohol > 0.0f )
@@ -193,7 +201,7 @@ BOOLEAN ApplyDrugs_New( SOLDIERTYPE *pSoldier, UINT16 usItem, UINT16 uStatusUsed
// set flag: we are on non-alcoholic drugs
pSoldier->usSoldierFlagMask |= SOLDIER_DRUGGED;
if ( gMercProfiles[pSoldier->ubProfile].ubNumTimesDrugUseInLifetime != 255 )
if ( complainworthyeffects && gMercProfiles[pSoldier->ubProfile].ubNumTimesDrugUseInLifetime != 255 )
{
gMercProfiles[pSoldier->ubProfile].ubNumTimesDrugUseInLifetime++;
}
+4
View File
@@ -13044,6 +13044,10 @@ void SOLDIERTYPE::EVENT_SoldierBeginFirstAid( INT32 sGridNo, UINT8 ubDirection )
// Flugente: additional dialogue
AdditionalTacticalCharacterDialogue_CallsLua( this, ADE_BANDAGE_PERFORM_BEGIN, pTSoldier->ubProfile );
AdditionalTacticalCharacterDialogue_CallsLua( pTSoldier, ADE_BANDAGE_RECEIVE_BEGIN, this->ubProfile );
// Flugente: if the medkit we use has drug effects set, apply them
// as a kit is used up over time, applying it several times would screw with chance effects, so just apply once
ApplyDrugs_New( pTSoldier, this->inv[HANDPOS].usItem, ( ( this->inv[HANDPOS] ) )[0]->data.objectStatus );
}
}
+2 -1
View File
@@ -2884,7 +2884,8 @@ UINT8 GetActionModeCursor( SOLDIERTYPE *pSoldier )
}
// Flugente: apply misc items to other soldiers
if ( ItemCanBeAppliedToOthers( usInHand ) )
// exception: not for medical items (medkists can have drug effects that are applied during bandaging)
if ( ubCursor != AIDCURS && ItemCanBeAppliedToOthers( usInHand ) )
{
// if item is a bomb, only allow apply if hovering over a soldier (otherwise we cannot mine anymore)
if ( Item[ usInHand ].usItemClass & IC_BOMB )