New Feature: Drug System Overhaul. The drug system has been completely overhauled.

Requires GameDir >= r2257.

For more info, see http://thepit.ja-galaxy-forum.com/index.php?t=msg&goto=341541&#msg_341541

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@7896 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2015-06-28 17:47:25 +00:00
parent ceea35b0e9
commit 4d9140da57
61 changed files with 1667 additions and 871 deletions
+31 -19
View File
@@ -70,6 +70,7 @@
#include "Disease.h" // added by Flugente
#include "Queen Command.h" // added by Flugente
#include "PMC.h" // added by Flugente
#include "Drugs And Alcohol.h" // added by Flugente for DoesMercHaveDisability( ... )
#endif
#include <vector>
#include <queue>
@@ -2738,14 +2739,15 @@ UINT16 CalculateHealingPointsForDoctor(SOLDIERTYPE *pDoctor, UINT16 *pusMaxPts,
usHealPts += usHealPts * gSkillTraitValues.usDODoctorAssignmentBonus * NUM_SKILL_TRAITS( pDoctor, DOCTOR_NT ) / 100;
*pusMaxPts += *pusMaxPts * gSkillTraitValues.usDODoctorAssignmentBonus * NUM_SKILL_TRAITS( pDoctor, DOCTOR_NT ) / 100;
}
// penalty for aggressive people
if ( gMercProfiles[ pDoctor->ubProfile ].bCharacterTrait == CHAR_TRAIT_AGGRESSIVE )
if ( DoesMercHavePersonality( pDoctor, CHAR_TRAIT_AGGRESSIVE ) )
{
usHealPts -= usHealPts / 10;
*pusMaxPts -= *pusMaxPts / 10;
}
// bonus for phlegmatic people
else if ( gMercProfiles[ pDoctor->ubProfile ].bCharacterTrait == CHAR_TRAIT_PHLEGMATIC )
else if ( DoesMercHavePersonality( pDoctor, CHAR_TRAIT_PHLEGMATIC ) )
{
usHealPts += usHealPts / 20;
*pusMaxPts += *pusMaxPts / 20;
@@ -2831,14 +2833,15 @@ UINT8 CalculateRepairPointsForRepairman(SOLDIERTYPE *pSoldier, UINT16 *pusMaxPts
usRepairPts += usRepairPts * gSkillTraitValues.usTERepairSpeedBonus * (NUM_SKILL_TRAITS( pSoldier, TECHNICIAN_NT )) / 100;
*pusMaxPts += *pusMaxPts * gSkillTraitValues.usTERepairSpeedBonus * (NUM_SKILL_TRAITS( pSoldier, TECHNICIAN_NT )) / 100;
}
// Penalty for aggressive people
if ( gMercProfiles[ pSoldier->ubProfile ].bCharacterTrait == CHAR_TRAIT_AGGRESSIVE )
if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_AGGRESSIVE ) )
{
usRepairPts -= usRepairPts / 10; // -10%
*pusMaxPts -= *pusMaxPts / 10;
}
// Bonus for phlegmatic people
else if ( gMercProfiles[ pSoldier->ubProfile ].bCharacterTrait == CHAR_TRAIT_PHLEGMATIC )
else if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_PHLEGMATIC ) )
{
usRepairPts += usRepairPts / 20; // +5%
*pusMaxPts += *pusMaxPts / 20;
@@ -3015,10 +3018,11 @@ UINT32 CalculateSnitchGuardValue(SOLDIERTYPE *pSoldier, UINT16 *pusMaxPts )
usValue += 25 * NUM_SKILL_TRAITS( pSoldier, STEALTHY_OT );
}
if( gMercProfiles[ pSoldier->ubProfile ].bDisability == DEAF )
if ( DoesMercHaveDisability( pSoldier, DEAF ) )
{
usValue = usValue/2;
}
// adjust for fatigue
ReducePointsForFatigue( pSoldier, &usValue );
@@ -3136,7 +3140,7 @@ UINT32 CalculateSnitchInterrogationValue(SOLDIERTYPE *pSoldier, UINT16 *pusMaxPt
if ( gGameOptions.fNewTraitSystem )
{
if ( gMercProfiles[pSoldier->ubProfile].bCharacterTrait == CHAR_TRAIT_ASSERTIVE )
if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_ASSERTIVE ) )
friendlyvalue += 30;
}
@@ -5092,8 +5096,9 @@ void FatigueCharacter( SOLDIERTYPE *pSoldier )
{
bMaxBreathLoss = (bMaxBreathLoss * (100 - gSkillTraitValues.ubSVBreathForTravellingReduction * NUM_SKILL_TRAITS( pSoldier, SURVIVAL_NT )) / 100);
}
// primitive people get exhausted slower
if ( gMercProfiles[pSoldier->ubProfile].bCharacterTrait == CHAR_TRAIT_PRIMITIVE )
if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_PRIMITIVE ) )
{
switch ( pSoldier->bAssignment )
{
@@ -5121,8 +5126,8 @@ void FatigueCharacter( SOLDIERTYPE *pSoldier )
break;
}
}
// Picifist actually gain morale, when on peaceful assignments
else if ( gMercProfiles[pSoldier->ubProfile].bCharacterTrait == CHAR_TRAIT_PACIFIST )
// Pacifists actually gain morale, when on peaceful assignments
else if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_PACIFIST ) )
{
switch ( pSoldier->bAssignment )
{
@@ -5537,9 +5542,12 @@ void HandleDiseaseDiagnosis()
for ( int i = 0; i < NUM_DISEASES; ++i )
{
// if teammember has disease, but this is not yet known
if ( pTeamSoldier->sDiseasePoints[i] > 0 && !(pTeamSoldier->sDiseaseFlag[i] & SOLDIERDISEASE_DIAGNOSED) )
if ( pTeamSoldier->sDiseasePoints[i] > 0 && !(pTeamSoldier->sDiseaseFlag[i] & SOLDIERDISEASE_DIAGNOSED) && Disease[i].sInfectionPtsOutbreak > 0 )
{
if ( Chance( skill ) )
// whether an infection is diagnosed also depends on how high it is compared to an outbreak
FLOAT infectedfraction = ((FLOAT)pTeamSoldier->sDiseasePoints[i] / (FLOAT)Disease[i].sInfectionPtsOutbreak);
if ( infectedfraction > 0.0f && Chance((UINT32)(100 * infectedfraction)) && Chance( skill ) )
{
// doctor discovered a disease - make it known
pTeamSoldier->AnnounceDisease( i );
@@ -5763,7 +5771,7 @@ void HandleGatheringInformationBySoldier( SOLDIERTYPE* pSoldier )
FLOAT fBaseChance = ( EffectiveLeadership(pSoldier) + EffectiveWisdom(pSoldier) + EffectiveExpLevel(pSoldier) * 10 ) / 3000.0f;
if( gMercProfiles[ pSoldier->ubProfile ].bDisability == DEAF )
if ( DoesMercHaveDisability( pSoldier, DEAF ) )
{
fBaseChance /= 2.0;
}
@@ -6146,16 +6154,18 @@ INT16 GetSoldierTrainingPts( SOLDIERTYPE *pSoldier, INT8 bTrainStat, UINT16 *pus
bTrainingBonus += gSkillTraitValues.ubTGBonusOnPractising;
//sTrainingPts += (sTrainingPts * gSkillTraitValues.ubTGBonusOnPractising / 100);
}
// bonus for practising for intellectuals
if ( gMercProfiles[pSoldier->ubProfile].bCharacterTrait == CHAR_TRAIT_INTELLECTUAL )
if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_INTELLECTUAL ) )
{
// +10%
*pusMaxPts += (*pusMaxPts / 10);
bTrainingBonus += 10;
//sTrainingPts += (sTrainingPts / 10);
}
// bonus for practising for intellectuals
if ( gMercProfiles[pSoldier->ubProfile].bCharacterTrait == CHAR_TRAIT_AGGRESSIVE )
if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_AGGRESSIVE ) )
{
switch (bTrainStat)
{
@@ -6268,16 +6278,18 @@ INT16 GetSoldierStudentPts( SOLDIERTYPE *pSoldier, INT8 bTrainStat, UINT16 *pusM
bTrainingBonus += gSkillTraitValues.ubTGBonusOnPractising;
//sTrainingPts += (sTrainingPts * gSkillTraitValues.ubTGBonusOnPractising / 100);
}
// bonus for practising for intellectuals
if ( gMercProfiles[pSoldier->ubProfile].bCharacterTrait == CHAR_TRAIT_INTELLECTUAL )
if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_INTELLECTUAL ) )
{
// +10%
*pusMaxPts += (*pusMaxPts / 10);
bTrainingBonus += 10;
//sTrainingPts += (sTrainingPts / 10);
}
// bonus for practising for intellectuals
if ( gMercProfiles[pSoldier->ubProfile].bCharacterTrait == CHAR_TRAIT_AGGRESSIVE )
if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_AGGRESSIVE ) )
{
switch (bTrainStat)
{
@@ -7388,17 +7400,17 @@ INT16 GetTownTrainPtsForCharacter( SOLDIERTYPE *pTrainer, UINT16 *pusMaxPts )
sTrainingBonus += gSkillTraitValues.ubTGBonusToTrainMilitia;
}
// +10% for Assertive people
if ( gMercProfiles[pTrainer->ubProfile].bCharacterTrait == CHAR_TRAIT_ASSERTIVE )
if ( DoesMercHavePersonality( pTrainer, CHAR_TRAIT_ASSERTIVE ) )
{
sTrainingBonus += 10;
}
// -5% for Aggressive people
else if ( gMercProfiles[pTrainer->ubProfile].bCharacterTrait == CHAR_TRAIT_AGGRESSIVE )
else if ( DoesMercHavePersonality( pTrainer, CHAR_TRAIT_AGGRESSIVE ) )
{
sTrainingBonus -= 5;
}
// +5% for Phlegmatic people
else if ( gMercProfiles[pTrainer->ubProfile].bCharacterTrait == CHAR_TRAIT_PHLEGMATIC )
else if ( DoesMercHavePersonality( pTrainer, CHAR_TRAIT_PHLEGMATIC ) )
{
sTrainingBonus += 5;
}
+7 -3
View File
@@ -1840,9 +1840,13 @@ void HandleRisksForSoldierFacilityAssignment( SOLDIERTYPE *pSoldier, UINT8 ubFac
}
// Add effects
pSoldier->AddDrugValues( DRUG_TYPE_ALCOHOL, Drug[DRUG_TYPE_ALCOHOL].ubDrugEffect, Drug[DRUG_TYPE_ALCOHOL].ubDrugTravelRate, Drug[DRUG_TYPE_ALCOHOL].ubDrugSideEffect );
CreateItem( ALCOHOL, Item[ALCOHOL].usPortionSize, &gTempObject );
ApplyConsumable( pSoldier, &gTempObject, TRUE, FALSE );
// ATE: Make guy collapse from heart attack if too much stuff taken....
//pSoldier->AddDrugValues( DRUG_TYPE_ALCOHOL, Drug[DRUG_TYPE_ALCOHOL].ubDrugEffect, Drug[DRUG_TYPE_ALCOHOL].ubDrugTravelRate, Drug[DRUG_TYPE_ALCOHOL].ubDrugSideEffect );
/*// ATE: Make guy collapse from heart attack if too much stuff taken....
if ( pSoldier->drugs.bDrugSideEffectRate[ DRUG_TYPE_ALCOHOL ] > ( Drug[DRUG_TYPE_ALCOHOL].ubDrugSideEffect * 3 ) )
{
if ( pSoldier->ubProfile == LARRY_NORMAL )
@@ -1938,7 +1942,7 @@ void HandleRisksForSoldierFacilityAssignment( SOLDIERTYPE *pSoldier, UINT8 ubFac
gMercProfiles[ pSoldier->ubProfile ].records.usTimesStatDamaged++;
gMercProfiles[ pSoldier->ubProfile ].records.usFacilityAccidents++;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
}*/
break;
case RISK_LOYALTY_LOCAL:
Result *= GAIN_PTS_PER_LOYALTY_PT; // Transform points into actual loyalty.
+38 -19
View File
@@ -20,6 +20,7 @@
#include "Strategic AI.h"
#include "Tactical Save.h" // added by Flugente
#include "DynamicDialogue.h" // added by Flugente for HandleDynamicOpinions()
#include "Drugs And Alcohol.h" // added by Flugente for HourlyDrugUpdate()
#endif
#include "Luaglobal.h"
@@ -41,6 +42,7 @@
void HourlyQuestUpdate();
void HourlyLarryUpdate();
void HourlySmokerUpdate();
void HourlyStealUpdate(); // Flugente: certain characters might steal equipment (backgrounds)
void HourlySnitchUpdate(); // anv: decreasing cooldown after exposition
@@ -60,8 +62,6 @@ void HourlyHelicopterRepair();
void HourlyGatheringInformation();
void UpdateRegenCounters( void );
void HandleMinuteUpdate()
{
}
@@ -117,6 +117,8 @@ CHAR16 zString[128];
HourlyLarryUpdate();
HourlySmokerUpdate( );
HourlyStealUpdate();
HourlySnitchUpdate();
@@ -139,10 +141,7 @@ CHAR16 zString[128];
HourlyHelicopterRepair();
#endif
if ( GetWorldHour() % 6 == 0 ) // 4 times a day
{ UpdateRegenCounters();
}
HourlyDrugUpdate();
// WANNE: This check should avoid the resaving of a loaded auto-save game, when entering tactical
BOOLEAN doAutoSave = TRUE;
@@ -255,19 +254,6 @@ CHAR16 zString[128];
}
}
void UpdateRegenCounters( void )
{
UINT8 ubID;
for ( ubID = gTacticalStatus.Team[ gbPlayerNum ].bFirstID; ubID <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; ubID++ )
{
if ( MercPtrs[ ubID ]->bRegenBoostersUsedToday > 0 )
{
MercPtrs[ ubID ]->bRegenBoostersUsedToday--;
}
}
}
void HandleQuarterHourUpdate()
{
//if the game hasnt even started yet ( we havent arrived in the sector ) dont process this
@@ -528,6 +514,39 @@ void HourlyLarryUpdate()
}
}
}
#include "Interface.h"
// Flugente: mercs that are smokers occasionally consume smokes if they have some in their inventory
void HourlySmokerUpdate( )
{
SOLDIERTYPE * pSoldier = NULL;
OBJECTTYPE* pObj = NULL;
for ( UINT32 cnt = gTacticalStatus.Team[OUR_TEAM].bFirstID; cnt <= gTacticalStatus.Team[OUR_TEAM].bLastID; ++cnt )
{
pSoldier = MercPtrs[cnt];
if ( pSoldier && pSoldier->bActive && !pSoldier->flags.fMercAsleep )
{
// if we are a smoker, there is a chance that we will look fo cigarettes in our inventory, and consume them if we find any
if ( Chance(33) && pSoldier->GetBackgroundValue( BG_SMOKERTYPE ) == 1 )
{
INT8 invsize = (INT8)pSoldier->inv.size( ); // remember inventorysize, so we don't call size() repeatedly
for ( INT8 bLoop = 0; bLoop < invsize; ++bLoop ) // ... for all items in our inventory ...
{
if ( pSoldier->inv[bLoop].exists( ) && Item[pSoldier->inv[bLoop].usItem].cigarette )
{
pObj = &(pSoldier->inv[bLoop]);
if ( ApplyConsumable( pSoldier, pObj, FALSE, FALSE ) )
{
break;
}
}
}
}
}
}
}
// anv: decrease exposed snitch cooldown (for simplified exposition handling)
void HourlySnitchUpdate()
+27 -59
View File
@@ -2351,7 +2351,7 @@ void DrawCharStats( INT16 sCharNum )
SetFontBackground(FONT_BLACK);
// strength
swprintf( sString, L"%d", pSoldier->stats.bStrength);
swprintf( sString, L"%d", pSoldier->stats.bStrength + pSoldier->bExtraStrength );
// SANDRO - if damaged stat we could regain, show in red until repaired
if ( ( gGameOptions.fNewTraitSystem && ( pSoldier->ubCriticalStatDamage[DAMAGED_STAT_STRENGTH] > 0 )) || (gGameOptions.fFoodSystem && pSoldier->usStarveDamageStrength > 0) )
@@ -2369,6 +2369,10 @@ void DrawCharStats( INT16 sCharNum )
SetFontForeground( FONT_RED );
}
}
else if ( pSoldier->bExtraStrength )
{
SetRGBFontForeground( 250, 5, 250 );
}
else
{
SetFontForeground(CHAR_TEXT_FONT_COLOR);
@@ -2379,7 +2383,7 @@ void DrawCharStats( INT16 sCharNum )
DrawString(sString,usX, STR_Y,CHAR_FONT );
// dexterity
swprintf( sString, L"%d", pSoldier->stats.bDexterity );
swprintf( sString, L"%d", pSoldier->stats.bDexterity + pSoldier->bExtraDexterity );
// SANDRO - if damaged stat we could regain, show in red until repaired
if( gGameOptions.fNewTraitSystem && ( pSoldier->ubCriticalStatDamage[DAMAGED_STAT_DEXTERITY] > 0 ))
@@ -2397,6 +2401,10 @@ void DrawCharStats( INT16 sCharNum )
SetFontForeground( FONT_RED );
}
}
else if ( pSoldier->bExtraDexterity )
{
SetRGBFontForeground( 250, 5, 250 );
}
else
{
SetFontForeground(CHAR_TEXT_FONT_COLOR);
@@ -2407,7 +2415,7 @@ void DrawCharStats( INT16 sCharNum )
DrawString(sString,usX, DEX_Y,CHAR_FONT );
// agility
swprintf( sString, L"%d", pSoldier->stats.bAgility );
swprintf( sString, L"%d", pSoldier->stats.bAgility + pSoldier->bExtraAgility );
// SANDRO - if damaged stat we could regain, show in red until repaired
if( gGameOptions.fNewTraitSystem && ( pSoldier->ubCriticalStatDamage[DAMAGED_STAT_AGILITY] > 0 ))
@@ -2425,6 +2433,10 @@ void DrawCharStats( INT16 sCharNum )
SetFontForeground( FONT_RED );
}
}
else if ( pSoldier->bExtraAgility )
{
SetRGBFontForeground( 250, 5, 250 );
}
else
{
SetFontForeground(CHAR_TEXT_FONT_COLOR);
@@ -2435,7 +2447,7 @@ void DrawCharStats( INT16 sCharNum )
DrawString(sString,usX, AGL_Y,CHAR_FONT );
// wisdom
swprintf( sString, L"%d", pSoldier->stats.bWisdom );
swprintf( sString, L"%d", pSoldier->stats.bWisdom + pSoldier->bExtraWisdom );
// SANDRO - if damaged stat we could regain, show in red until repaired
if( gGameOptions.fNewTraitSystem && ( pSoldier->ubCriticalStatDamage[DAMAGED_STAT_WISDOM] > 0 ))
@@ -2453,6 +2465,10 @@ void DrawCharStats( INT16 sCharNum )
SetFontForeground( FONT_RED );
}
}
else if ( pSoldier->bExtraWisdom )
{
SetRGBFontForeground( 250, 5, 250 );
}
else
{
SetFontForeground(CHAR_TEXT_FONT_COLOR);
@@ -2491,7 +2507,7 @@ void DrawCharStats( INT16 sCharNum )
DrawString(sString,usX, LDR_Y,CHAR_FONT );
// experience level
swprintf( sString, L"%d", pSoldier->stats.bExpLevel );
swprintf( sString, L"%d", pSoldier->stats.bExpLevel + pSoldier->bExtraExpLevel );
if( ( GetJA2Clock() < CHANGE_STAT_RECENTLY_DURATION + pSoldier->timeChanges.uiChangeLevelTime)&&( pSoldier->timeChanges.uiChangeLevelTime != 0 ) )
{
@@ -2504,6 +2520,10 @@ void DrawCharStats( INT16 sCharNum )
SetFontForeground( FONT_RED );
}
}
else if ( pSoldier->bExtraExpLevel )
{
SetRGBFontForeground( 250, 5, 250 );
}
else
{
SetFontForeground(CHAR_TEXT_FONT_COLOR);
@@ -9535,50 +9555,12 @@ void MAPInvClickCamoCallback( MOUSE_REGION *pRegion, INT32 iReason )
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 ( ApplyConsumable( pSoldier, gpItemPointer, FALSE, TRUE ) )
{
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;
UpdateMercBodyRegionHelpText( );
}
else
{
@@ -9595,20 +9577,6 @@ void MAPInvClickCamoCallback( MOUSE_REGION *pRegion, INT32 iReason )
//EndItemPointer( );
MAPEndItemPointer( );
}
if ( fGoodAPs )
{
// Dirty
fInterfacePanelDirty = DIRTYLEVEL2;
UpdateMercBodyRegionHelpText( );
}
if ( fDoSound )
{
// Say OK acknowledge....
pSoldier->DoMercBattleSound( BATTLE_SOUND_COOL1 );
}
}
}
}