mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +02:00
2. USE_XML_TILESETS moved from JA2.ini to JA2Options.ini 3. New Feature - Ctrl+Click on an item with an item in hand to auto-attach/merge them. Attach works with stacks. Merge only works on single items, for now at least. 4. New Feature - To accompany Quiet Training, there are now Quiet Repairing and Quiet Doctoring options. 5. Bugfix - inseparable attachments of attachments were getting lost again when using ctrl+f/the map screen button to remove attachments 6. Bugfix - INT8 overflow error causing vehicle repair to actually lower its status 7. GasMask tag in items.xml can now be applied to helmets as well as face items. 8. Bugfix - AI code was referencing hard coded GASMASK item number instead of looking for the tag 9. Bugfix - "break;" was removed in Explosion Control.cpp, thereby causing mustard gas to deal out fire damage. (Not sure if this was deliberate? But the new implementation differs from the JA2 standard, so it should be added to JA2Options.ini at least) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5320 3b4a5df2-a311-0410-b5c6-a8a6f20db521
693 lines
22 KiB
C++
693 lines
22 KiB
C++
#ifdef PRECOMPILEDHEADERS
|
|
#include "Tactical All.h"
|
|
#else
|
|
#include "sgp.h"
|
|
#include "soldier control.h"
|
|
#include "soldier profile.h"
|
|
#include "drugs and alcohol.h"
|
|
#include "items.h"
|
|
#include "morale.h"
|
|
#include "points.h"
|
|
#include "message.h"
|
|
#include "GameSettings.h" // SANDRO - had to add this, dammit!
|
|
#include "Random.h"
|
|
#include "Text.h"
|
|
#include "Interface.h"
|
|
#endif
|
|
|
|
//forward declarations of common classes to eliminate includes
|
|
class OBJECTTYPE;
|
|
class SOLDIERTYPE;
|
|
|
|
|
|
/*UINT8 ubDrugTravelRate[] = { 4, 2 };
|
|
UINT8 ubDrugWearoffRate[] = { 2, 2 };
|
|
UINT8 ubDrugEffect[] = { 15, 8 };
|
|
UINT8 ubDrugSideEffect[] = { 20, 10 };
|
|
UINT8 ubDrugSideEffectRate[] = { 2, 1 };*/
|
|
|
|
INT32 giDrunkModifier[] =
|
|
{
|
|
100, // Sober
|
|
75, // Feeling good,
|
|
65, // Bporderline
|
|
50, // Drunk
|
|
100, // HungOver
|
|
};
|
|
|
|
#define HANGOVER_AP_REDUCE 5
|
|
#define HANGOVER_BP_REDUCE 200
|
|
|
|
|
|
BOOLEAN ApplyDrugs( SOLDIERTYPE *pSoldier, OBJECTTYPE *pObject )
|
|
{
|
|
UINT32 ubDrugType;
|
|
INT8 bRegenPointsGained;
|
|
UINT16 usItem;
|
|
|
|
usItem = pObject->usItem;
|
|
|
|
// Determine what type of drug....
|
|
ubDrugType = Item[usItem].drugtype;
|
|
|
|
// If not a drug, return
|
|
if ( ubDrugType == 0 )
|
|
{
|
|
return( FALSE );
|
|
}
|
|
|
|
// do switch for Larry!!
|
|
if ( pSoldier->ubProfile == LARRY_NORMAL )
|
|
{
|
|
pSoldier = SwapLarrysProfiles( pSoldier );
|
|
}
|
|
else if ( pSoldier->ubProfile == LARRY_DRUNK )
|
|
{
|
|
gMercProfiles[ LARRY_DRUNK ].bNPCData = 0;
|
|
}
|
|
|
|
// Flugente: we have to check for every single type of drug ( a drug applied may consist of several 'pure' drug types)
|
|
for (UINT8 i = DRUG_TYPE_ADRENALINE; i < DRUG_TYPE_MAX; ++i)
|
|
{
|
|
UINT32 drugtestflag = (1 << i); // comparing with this flag will determine the drug
|
|
|
|
// we do not actually test for DRUG_REGENERATION, because that is checked afterwards separately
|
|
if ( (drugtestflag & DRUG_REGENERATION ) != 0 )
|
|
continue;
|
|
|
|
if ( (ubDrugType & drugtestflag) != 0 )
|
|
{
|
|
// Add effects
|
|
if ( ( pSoldier->drugs.bFutureDrugEffect[ i ] + Drug[i].ubDrugEffect ) < 127 )
|
|
{
|
|
pSoldier->drugs.bFutureDrugEffect[ i ] += Drug[i].ubDrugEffect;
|
|
}
|
|
pSoldier->drugs.bDrugEffectRate[ i ] = Drug[i].ubDrugTravelRate;
|
|
|
|
// Reset once we sleep...
|
|
pSoldier->drugs.bTimesDrugUsedSinceSleep[ i ]++;
|
|
|
|
// Increment side effects..
|
|
if ( ( pSoldier->drugs.bDrugSideEffect[ i ] + Drug[i].ubDrugSideEffect ) < 127 )
|
|
{
|
|
pSoldier->drugs.bDrugSideEffect[ i ] += ( Drug[i].ubDrugSideEffect );
|
|
}
|
|
// Stop side effects until were done....
|
|
pSoldier->drugs.bDrugSideEffectRate[ i ] = 0;
|
|
|
|
// ATE: Make guy collapse from heart attack if too much stuff taken....
|
|
if ( pSoldier->drugs.bDrugSideEffectRate[ i ] > ( Drug[i].ubDrugSideEffect * 3 ) )
|
|
{
|
|
// Keel over...
|
|
DeductPoints( pSoldier, 0, 10000 );
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// SANDRO - if our stat is damaged through facility event, make it healable
|
|
// Permanently lower certain stats...
|
|
if ( gGameOptions.fNewTraitSystem )
|
|
{
|
|
// WISDOM decrease
|
|
if ( pSoldier->stats.bWisdom > 5 )
|
|
{
|
|
pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_WISDOM ] += 5;
|
|
pSoldier->stats.bWisdom -= 5;
|
|
}
|
|
else
|
|
{
|
|
pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_WISDOM ] += (pSoldier->stats.bWisdom - 1);
|
|
pSoldier->stats.bWisdom = 1;
|
|
}
|
|
// DEXTERITY decrease
|
|
if ( pSoldier->stats.bDexterity > 5 )
|
|
{
|
|
pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_DEXTERITY ] += 5;
|
|
pSoldier->stats.bDexterity -= 5;
|
|
}
|
|
else
|
|
{
|
|
pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_DEXTERITY ] += (pSoldier->stats.bDexterity - 1);
|
|
pSoldier->stats.bDexterity = 1;
|
|
}
|
|
// STRENGTH decrease
|
|
if ( pSoldier->stats.bStrength > 5 )
|
|
{
|
|
pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_STRENGTH ] += 5;
|
|
pSoldier->stats.bStrength -= 5;
|
|
}
|
|
else
|
|
{
|
|
pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_STRENGTH ] += (pSoldier->stats.bStrength - 1);
|
|
pSoldier->stats.bStrength = 1;
|
|
}
|
|
// AGILITY decrease
|
|
if ( pSoldier->stats.bAgility > 5 )
|
|
{
|
|
pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_AGILITY ] += 5;
|
|
pSoldier->stats.bAgility -= 5;
|
|
}
|
|
else
|
|
{
|
|
pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_AGILITY ] += (pSoldier->stats.bAgility - 1);
|
|
pSoldier->stats.bAgility = 1;
|
|
}
|
|
}
|
|
else // old system
|
|
{
|
|
pSoldier->stats.bAgility = __max(1, pSoldier->stats.bWisdom-5);
|
|
pSoldier->stats.bDexterity = __max(1, pSoldier->stats.bDexterity-5);
|
|
pSoldier->stats.bStrength = __max(1, pSoldier->stats.bStrength-5);
|
|
pSoldier->stats.bAgility = __max(1, pSoldier->stats.bAgility-5);
|
|
|
|
// make those stats RED for a while...
|
|
// SANDRO - we don't need to do this with new system, as we simply show all damaged stats in red until healed
|
|
pSoldier->timeChanges.uiChangeWisdomTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp &= ~( WIS_INCREASE );
|
|
pSoldier->timeChanges.uiChangeDexterityTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp &= ~( DEX_INCREASE );
|
|
pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp &= ~( STRENGTH_INCREASE );
|
|
pSoldier->timeChanges.uiChangeAgilityTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp &= ~( AGIL_INCREASE );
|
|
}
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// export stat changes to profile
|
|
gMercProfiles[ pSoldier->ubProfile ].bWisdom = pSoldier->stats.bWisdom;
|
|
gMercProfiles[ pSoldier->ubProfile ].bDexterity = pSoldier->stats.bDexterity;
|
|
gMercProfiles[ pSoldier->ubProfile ].bStrength = pSoldier->stats.bStrength;
|
|
gMercProfiles[ pSoldier->ubProfile ].bAgility = pSoldier->stats.bAgility;
|
|
|
|
// SANDRO - merc records - stat damaged
|
|
gMercProfiles[ pSoldier->ubProfile ].records.usTimesStatDamaged++;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( (ubDrugType & DRUG_REGENERATION) != 0 )
|
|
{
|
|
// each use of a regen booster over 1, each day, reduces the effect
|
|
bRegenPointsGained = REGEN_POINTS_PER_BOOSTER * (*pObject)[0]->data.objectStatus / 100;
|
|
// are there fractional %s left over?
|
|
if ( ( (*pObject)[0]->data.objectStatus % (100 / REGEN_POINTS_PER_BOOSTER ) ) != 0 )
|
|
{
|
|
// chance of an extra point
|
|
if ( PreRandom( 100 / REGEN_POINTS_PER_BOOSTER ) < (UINT32) ( (*pObject)[0]->data.objectStatus % (100 / REGEN_POINTS_PER_BOOSTER ) ) )
|
|
{
|
|
bRegenPointsGained++;
|
|
}
|
|
}
|
|
|
|
bRegenPointsGained -= pSoldier->bRegenBoostersUsedToday;
|
|
if (bRegenPointsGained > 0)
|
|
{
|
|
// can't go above the points you get for a full boost
|
|
pSoldier->bRegenerationCounter = __min( pSoldier->bRegenerationCounter + bRegenPointsGained, REGEN_POINTS_PER_BOOSTER );
|
|
}
|
|
pSoldier->bRegenBoostersUsedToday++;
|
|
}
|
|
|
|
// ATE: use kit points...
|
|
if ( usItem == ALCOHOL )
|
|
UseKitPoints( pObject, 10, pSoldier );
|
|
else if ( usItem == WINE )
|
|
UseKitPoints( pObject, 20, pSoldier );
|
|
else if ( usItem == BEER )
|
|
UseKitPoints( pObject, 100, pSoldier );
|
|
else
|
|
{
|
|
// remove object
|
|
pObject->RemoveObjectsFromStack(1);
|
|
|
|
if ( gMercProfiles[ pSoldier->ubProfile ].ubNumTimesDrugUseInLifetime != 255 )
|
|
{
|
|
gMercProfiles[ pSoldier->ubProfile ].ubNumTimesDrugUseInLifetime++;
|
|
}
|
|
}
|
|
|
|
if ( (ubDrugType & DRUG_TYPE_ALCOHOL) != 0 )
|
|
{
|
|
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_DRANK_SOME ], pSoldier->name, ShortItemNames[ usItem ] );
|
|
}
|
|
else
|
|
{
|
|
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMessageStrings[ MSG_MERC_TOOK_DRUG ], pSoldier->name );
|
|
}
|
|
|
|
// Dirty panel
|
|
fInterfacePanelDirty = DIRTYLEVEL2;
|
|
|
|
return( TRUE );
|
|
}
|
|
|
|
void HandleEndTurnDrugAdjustments( SOLDIERTYPE *pSoldier )
|
|
{
|
|
INT32 cnt, cnt2;
|
|
INT32 iNumLoops;
|
|
|
|
// We test for every 'pure' drug separately
|
|
for (cnt = DRUG_TYPE_ADRENALINE; cnt < DRUG_TYPE_MAX; ++cnt)
|
|
{
|
|
UINT32 drugtestflag = (1 << cnt); // comparing with this flag will determine the drug
|
|
|
|
// we do not actually test for DRUG_REGENERATION, because that is checked afterwards separately
|
|
if ( (drugtestflag & DRUG_REGENERATION ) != 0 )
|
|
continue;
|
|
|
|
// If side effect aret is non-zero....
|
|
if ( pSoldier->drugs.bDrugSideEffectRate[ cnt ] > 0 )
|
|
{
|
|
// Subtract some...
|
|
pSoldier->drugs.bDrugSideEffect[ cnt ] -= pSoldier->drugs.bDrugSideEffectRate[ cnt ];
|
|
|
|
// If we're done, we're done!
|
|
if ( pSoldier->drugs.bDrugSideEffect[ cnt ] <= 0 )
|
|
{
|
|
pSoldier->drugs.bDrugSideEffect[ cnt ] = 0;
|
|
pSoldier->drugs.bDrugSideEffectRate[ cnt ] = 0;
|
|
fInterfacePanelDirty = DIRTYLEVEL1;
|
|
}
|
|
}
|
|
|
|
// IF drug rate is -ve, it's being worn off...
|
|
if ( pSoldier->drugs.bDrugEffectRate[ cnt ] < 0 )
|
|
{
|
|
pSoldier->drugs.bDrugEffect[ cnt ] -= ( -1 * pSoldier->drugs.bDrugEffectRate[ cnt ] );
|
|
|
|
// Have we run out?
|
|
if ( pSoldier->drugs.bDrugEffect[ cnt ] <= 0 )
|
|
{
|
|
pSoldier->drugs.bDrugEffect[ cnt ] = 0;
|
|
|
|
// Dirty panel
|
|
fInterfacePanelDirty = DIRTYLEVEL2;
|
|
|
|
// Start the bad news!
|
|
pSoldier->drugs.bDrugSideEffectRate[ cnt ] = Drug[cnt].ubDrugSideEffectRate;
|
|
|
|
// The drug rate is 0 now too
|
|
pSoldier->drugs.bDrugEffectRate[ cnt ] = 0;
|
|
|
|
// morale downer only if side effect exists and this effect is allowed for a drug
|
|
if ( Drug[cnt].ubDrugSideEffect > 0 && Drug[cnt].ubMoralBacklash > 0 )
|
|
{
|
|
// Once for each 'level' of crash....
|
|
iNumLoops = ( pSoldier->drugs.bDrugSideEffect[ cnt ] / Drug[cnt].ubDrugSideEffect ) + 1;
|
|
|
|
for ( cnt2 = 0; cnt2 < iNumLoops; ++cnt2 )
|
|
{
|
|
// OK, give a much BIGGER morale downer
|
|
if ( cnt == DRUG_TYPE_ALCOHOL )
|
|
{
|
|
HandleMoraleEvent( pSoldier, MORALE_ALCOHOL_CRASH, pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ );
|
|
}
|
|
else
|
|
{
|
|
HandleMoraleEvent( pSoldier, MORALE_DRUGS_CRASH, pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Add increase ineffect....
|
|
if ( pSoldier->drugs.bDrugEffectRate[ cnt ] > 0 )
|
|
{
|
|
// Seap some in....
|
|
pSoldier->drugs.bFutureDrugEffect[ cnt ] -= pSoldier->drugs.bDrugEffectRate[ cnt ];
|
|
pSoldier->drugs.bDrugEffect[ cnt ] += pSoldier->drugs.bDrugEffectRate[ cnt ];
|
|
|
|
// Refresh morale w/ new drug value...
|
|
RefreshSoldierMorale( pSoldier );
|
|
|
|
// Check if we need to stop 'adding'
|
|
if ( pSoldier->drugs.bFutureDrugEffect[ cnt ] <= 0 )
|
|
{
|
|
pSoldier->drugs.bFutureDrugEffect[ cnt ] = 0;
|
|
// Change rate to -ve..
|
|
pSoldier->drugs.bDrugEffectRate[ cnt ] = -Drug[cnt].ubDrugWearoffRate;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( pSoldier->bRegenerationCounter > 0)
|
|
{
|
|
// bBandaged = BANDAGED( pSoldier );
|
|
|
|
// increase life
|
|
pSoldier->bPoisonLife = max(pSoldier->bPoisonSum, pSoldier->bPoisonLife + pSoldier->stats.bLife - __min( pSoldier->stats.bLife + LIFE_GAIN_PER_REGEN_POINT, pSoldier->stats.bLifeMax ) );
|
|
pSoldier->stats.bLife = __min( pSoldier->stats.bLife + LIFE_GAIN_PER_REGEN_POINT, pSoldier->stats.bLifeMax );
|
|
|
|
//SANDRO - Insta-healable injury reduction
|
|
if( pSoldier->iHealableInjury > 0 )
|
|
{
|
|
pSoldier->iHealableInjury = max(0, (pSoldier->iHealableInjury - (100 * LIFE_GAIN_PER_REGEN_POINT)));
|
|
}
|
|
|
|
if ( pSoldier->stats.bLife == pSoldier->stats.bLifeMax )
|
|
{
|
|
pSoldier->bBleeding = 0;
|
|
pSoldier->bPoisonBleeding = 0;
|
|
pSoldier->iHealableInjury = 0;
|
|
}
|
|
else if ( pSoldier->bBleeding + pSoldier->stats.bLife > pSoldier->stats.bLifeMax )
|
|
{
|
|
// got to reduce amount of bleeding
|
|
pSoldier->bBleeding = (pSoldier->stats.bLifeMax - pSoldier->stats.bLife);
|
|
pSoldier->bPoisonBleeding = min(pSoldier->bPoisonBleeding, (pSoldier->stats.bLifeMax - pSoldier->stats.bLife));
|
|
}
|
|
|
|
// decrement counter
|
|
pSoldier->bRegenerationCounter--;
|
|
}
|
|
|
|
// Flugente: always do the following checks. Thereby, if the effect runs out, our stats will be back to normal
|
|
// only do the checks for the player team, as soldiers do not have a gMercProfiles
|
|
if ( pSoldier->bTeam == gbPlayerNum)
|
|
{
|
|
// Flugente 2012-05-25: the status drugs cause weird behaviour with the stat repairing behaviour of doctoring, so this is commented out till a working solution has been found
|
|
/*
|
|
//////////////// STRENGTH ////////////////
|
|
// strength we would normally have right now
|
|
INT8 strength = gMercProfiles[ pSoldier->ubProfile ].bStrength;// Madd: commenting out this part b/c it breaks doctoring! - pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_STRENGTH ];
|
|
|
|
INT8 strengthmodifier = pSoldier->drugs.bDrugEffect[ DRUG_TYPE_STRENGTH ] - pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_STRENGTH ];
|
|
|
|
// cap modifier at 25, as currently stats cant go above 127 (INT8)
|
|
strengthmodifier = min(25, strengthmodifier);
|
|
|
|
UINT32 newstrength = max(1, strength + strengthmodifier);
|
|
newstrength = min(126, newstrength);
|
|
|
|
pSoldier->stats.bStrength = (INT8)newstrength;
|
|
|
|
if ( strengthmodifier > 0 )
|
|
{
|
|
pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp |= ( STRENGTH_INCREASE );
|
|
}
|
|
else if ( strengthmodifier < 0 )
|
|
{
|
|
pSoldier->timeChanges.uiChangeStrengthTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp &= ~( STRENGTH_INCREASE );
|
|
}
|
|
|
|
//////////////// DEXTERITY ////////////////
|
|
// dexterity we would normally have right now
|
|
INT8 dexterity = gMercProfiles[ pSoldier->ubProfile ].bDexterity;// Madd: commenting out this part b/c it breaks doctoring! - pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_DEXTERITY ];
|
|
|
|
INT8 dexteritymodifier = pSoldier->drugs.bDrugEffect[ DRUG_TYPE_DEXTERITY ] - pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_DEXTERITY ];
|
|
|
|
// cap modifier at 25, as currently stats cant go above 127 (INT8)
|
|
dexteritymodifier = min(25, dexteritymodifier);
|
|
|
|
UINT32 newdexterity = max(1, dexterity + dexteritymodifier);
|
|
newdexterity = min(126, newdexterity);
|
|
|
|
pSoldier->stats.bDexterity = newdexterity;
|
|
|
|
if ( dexteritymodifier > 0 )
|
|
{
|
|
pSoldier->timeChanges.uiChangeDexterityTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp |= ( DEX_INCREASE );
|
|
}
|
|
else if ( dexteritymodifier < 0 )
|
|
{
|
|
pSoldier->timeChanges.uiChangeDexterityTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp &= ~( DEX_INCREASE );
|
|
}
|
|
|
|
//////////////// AGILITY ////////////////
|
|
// agility we would normally have right now
|
|
INT8 agility = gMercProfiles[ pSoldier->ubProfile ].bAgility;// Madd: commenting out this part b/c it breaks doctoring! - pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_AGILITY ];
|
|
|
|
INT8 agilitymodifier = pSoldier->drugs.bDrugEffect[ DRUG_TYPE_AGILITY ] - pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_AGILITY ];
|
|
|
|
// cap modifier at 25, as currently stats cant go above 127 (INT8)
|
|
agilitymodifier = min(25, agilitymodifier);
|
|
|
|
UINT32 newagility = max(1, agility + agilitymodifier);
|
|
newagility = min(126, newagility);
|
|
|
|
pSoldier->stats.bAgility = newagility;
|
|
|
|
if ( agilitymodifier > 0 )
|
|
{
|
|
pSoldier->timeChanges.uiChangeAgilityTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp |= ( AGIL_INCREASE );
|
|
}
|
|
else if ( agilitymodifier < 0 )
|
|
{
|
|
pSoldier->timeChanges.uiChangeAgilityTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp &= ~( AGIL_INCREASE );
|
|
}
|
|
|
|
//////////////// WISDOM ////////////////
|
|
// wisdom we would normally have right now
|
|
INT8 wisdom = gMercProfiles[ pSoldier->ubProfile ].bWisdom;// Madd: commenting out this part b/c it breaks doctoring! - pSoldier->ubCriticalStatDamage[ DAMAGED_STAT_WISDOM ];
|
|
|
|
INT8 wisdommodifier = pSoldier->drugs.bDrugEffect[ DRUG_TYPE_WISDOM ] - pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_WISDOM ];
|
|
|
|
// cap modifier at 25, as currently stats cant go above 127 (INT8)
|
|
wisdommodifier = min(25, wisdommodifier);
|
|
|
|
UINT32 newwisdom = max(1, wisdom + wisdommodifier);
|
|
newwisdom = min(126, newwisdom);
|
|
|
|
pSoldier->stats.bWisdom = newwisdom;
|
|
|
|
if ( wisdommodifier > 0 )
|
|
{
|
|
pSoldier->timeChanges.uiChangeWisdomTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp |= ( WIS_INCREASE );
|
|
}
|
|
else if ( wisdommodifier < 0 )
|
|
{
|
|
pSoldier->timeChanges.uiChangeWisdomTime = GetJA2Clock();
|
|
pSoldier->usValueGoneUp &= ~( WIS_INCREASE );
|
|
}*/
|
|
|
|
// if our sideeffect count is 1 (which should occur a while AFTER we took the drug), we suddenly become blind for a few turns...
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_BLIND ] == 0 && pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_BLIND ] == 1 )
|
|
{
|
|
pSoldier->bBlindedCounter = 3;
|
|
}
|
|
|
|
// if our sideeffect count is 1 (which should occur a while AFTER we took the drug), we get a heart-attack and get knocked out...
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_KNOCKOUT ] == 0 && pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_KNOCKOUT ] == 1 )
|
|
{
|
|
// Keel over...
|
|
DeductPoints( pSoldier, 0, 20000 );
|
|
}
|
|
|
|
// if we have a life damaging effect, deduct life points
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_LIFEDAMAGE ] == 0 && pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_LIFEDAMAGE ] > 0 )
|
|
{
|
|
if ( pSoldier->stats.bLife > OKLIFE )
|
|
{
|
|
INT8 lifepointdamage = pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_LIFEDAMAGE ];
|
|
|
|
INT8 applieddamage = pSoldier->stats.bLife;
|
|
|
|
pSoldier->stats.bLife = max(OKLIFE - 1, pSoldier->stats.bLife - lifepointdamage);
|
|
|
|
applieddamage -= pSoldier->stats.bLife;
|
|
|
|
pSoldier->iHealableInjury += (applieddamage * 100);
|
|
}
|
|
}
|
|
|
|
// if we took an antidote, reduce poisoning
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_CUREPOISON ] > 0 )
|
|
{
|
|
if ( pSoldier->bPoisonSum > 0 )
|
|
{
|
|
if ( pSoldier->bPoisonBleeding > 0 )
|
|
{
|
|
pSoldier->bPoisonBleeding--;
|
|
}
|
|
else if ( pSoldier->bPoisonLife > 0 )
|
|
{
|
|
pSoldier->bPoisonLife--;
|
|
}
|
|
|
|
pSoldier->bPoisonSum--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
INT8 GetDrugEffect( SOLDIERTYPE *pSoldier, UINT8 ubDrugType )
|
|
{
|
|
return( pSoldier->drugs.bDrugEffect[ ubDrugType ] );
|
|
}
|
|
|
|
|
|
INT8 GetDrugSideEffect( SOLDIERTYPE *pSoldier, UINT8 ubDrugType )
|
|
{
|
|
// If we have a o-positive effect
|
|
if ( pSoldier->drugs.bDrugEffect[ ubDrugType ] > 0 )
|
|
{
|
|
return( 0 );
|
|
}
|
|
else
|
|
{
|
|
return( pSoldier->drugs.bDrugSideEffect[ ubDrugType ] );
|
|
}
|
|
}
|
|
|
|
void HandleAPEffectDueToDrugs( SOLDIERTYPE *pSoldier, INT16 *pubPoints )
|
|
{
|
|
INT8 bDrunkLevel;
|
|
INT16 sPoints = (*pubPoints);
|
|
|
|
// Are we in a side effect or good effect?
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_ADRENALINE ] )
|
|
{
|
|
// Adjust!
|
|
sPoints += pSoldier->drugs.bDrugEffect[ DRUG_TYPE_ADRENALINE ];
|
|
}
|
|
else if ( pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_ADRENALINE ] )
|
|
{
|
|
// Adjust!
|
|
sPoints -= pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_ADRENALINE ];
|
|
|
|
if ( sPoints < APBPConstants[APBPConstants[APBPConstants[AP_MINIMUM]]] )
|
|
{
|
|
sPoints = APBPConstants[APBPConstants[APBPConstants[AP_MINIMUM]]];
|
|
}
|
|
}
|
|
|
|
bDrunkLevel = GetDrunkLevel( pSoldier );
|
|
|
|
if ( bDrunkLevel == HUNGOVER )
|
|
{
|
|
// Reduce....
|
|
sPoints -= HANGOVER_AP_REDUCE;
|
|
|
|
if ( sPoints < APBPConstants[APBPConstants[APBPConstants[AP_MINIMUM]]] )
|
|
{
|
|
sPoints = APBPConstants[APBPConstants[APBPConstants[AP_MINIMUM]]];
|
|
}
|
|
}
|
|
|
|
(*pubPoints) = sPoints;
|
|
}
|
|
|
|
|
|
void HandleBPEffectDueToDrugs( SOLDIERTYPE *pSoldier, INT16 *psPointReduction )
|
|
{
|
|
INT8 bDrunkLevel;
|
|
|
|
// Are we in a side effect or good effect?
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_ADRENALINE ] )
|
|
{
|
|
// Adjust!
|
|
(*psPointReduction) -= ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_ADRENALINE ] * APBPConstants[BP_RATIO_RED_PTS_TO_NORMAL] );
|
|
}
|
|
else if ( pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_ADRENALINE ] )
|
|
{
|
|
// Adjust!
|
|
(*psPointReduction) += ( pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_ADRENALINE ] * APBPConstants[BP_RATIO_RED_PTS_TO_NORMAL] );
|
|
}
|
|
|
|
bDrunkLevel = GetDrunkLevel( pSoldier );
|
|
|
|
if ( bDrunkLevel == HUNGOVER )
|
|
{
|
|
// Reduce....
|
|
(*psPointReduction) += HANGOVER_BP_REDUCE;
|
|
}
|
|
}
|
|
|
|
void HandleDamageResistanceEffectDueToDrugs( SOLDIERTYPE *pSoldier, INT32 *psPointReduction )
|
|
{
|
|
// Are we in a side effect or good effect?
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_RESISTANCE ] )
|
|
{
|
|
// Adjust!
|
|
(*psPointReduction) += pSoldier->drugs.bDrugEffect[ DRUG_TYPE_RESISTANCE ];
|
|
}
|
|
else if ( pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_RESISTANCE ] )
|
|
{
|
|
// Adjust!
|
|
(*psPointReduction) -= pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_RESISTANCE ];
|
|
}
|
|
}
|
|
|
|
|
|
INT8 GetDrunkLevel( SOLDIERTYPE *pSoldier )
|
|
{
|
|
INT8 bNumDrinks;
|
|
|
|
// If we have a -ve effect ...
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_ALCOHOL ] == 0 && pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_ALCOHOL ] == 0 )
|
|
{
|
|
return( SOBER );
|
|
}
|
|
|
|
if ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_ALCOHOL ] == 0 && pSoldier->drugs.bDrugSideEffect[ DRUG_TYPE_ALCOHOL ] != 0 )
|
|
{
|
|
return( HUNGOVER );
|
|
}
|
|
|
|
// Calculate how many dinks we have had....
|
|
bNumDrinks = ( pSoldier->drugs.bDrugEffect[ DRUG_TYPE_ALCOHOL ] / Drug[DRUG_TYPE_ALCOHOL].ubDrugEffect );
|
|
|
|
if ( bNumDrinks <= 3 )
|
|
{
|
|
return( FEELING_GOOD );
|
|
}
|
|
else if ( bNumDrinks <= 4 )
|
|
{
|
|
return( BORDERLINE );
|
|
}
|
|
else
|
|
{
|
|
return( DRUNK );
|
|
}
|
|
}
|
|
|
|
|
|
INT32 EffectStatForBeingDrunk( SOLDIERTYPE *pSoldier, INT32 iStat )
|
|
{
|
|
return( ( iStat * giDrunkModifier[ GetDrunkLevel( pSoldier ) ] / 100 ) );
|
|
}
|
|
|
|
|
|
BOOLEAN MercUnderTheInfluence( SOLDIERTYPE *pSoldier )
|
|
{
|
|
for (UINT8 cnt = DRUG_TYPE_ADRENALINE; cnt < DRUG_TYPE_MAX; ++cnt)
|
|
{
|
|
// Are we in a side effect or good effect?
|
|
if ( pSoldier->drugs.bDrugEffect[ cnt ] )
|
|
{
|
|
return( TRUE );
|
|
}
|
|
else if ( pSoldier->drugs.bDrugSideEffect[ cnt ] )
|
|
{
|
|
return( TRUE );
|
|
}
|
|
}
|
|
|
|
return( FALSE );
|
|
}
|
|
|
|
BOOLEAN MercUnderTheInfluence( SOLDIERTYPE *pSoldier, UINT8 aDrugType )
|
|
{
|
|
// in case of wrong inout, stay safe
|
|
if ( aDrugType >= DRUG_TYPE_MAX )
|
|
return( FALSE );
|
|
|
|
// Are we in a side effect or good effect?
|
|
if ( pSoldier->drugs.bDrugEffect[ aDrugType ] )
|
|
{
|
|
return( TRUE );
|
|
}
|
|
else if ( pSoldier->drugs.bDrugSideEffect[ aDrugType ] )
|
|
{
|
|
return( TRUE );
|
|
}
|
|
|
|
return( FALSE );
|
|
}
|