From 7eab9ff3ce56af74ba3ce6c8cbd8a555e84a05cb Mon Sep 17 00:00:00 2001 From: NovaRain Date: Fri, 29 Jan 2021 10:51:26 +0800 Subject: [PATCH] Added SmallFrameFix option Code style edit: use !boolean instead of (boolean == false) for some checks. --- artifacts/ddraw.ini | 3 +++ sfall/Interface.cpp | 4 ++-- sfall/Perks.cpp | 44 ++++++++++++++++++++++++---------------- sfall/ScriptExtender.cpp | 4 ++-- 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 8bd3d726..714b21c8 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -531,6 +531,9 @@ RemoveCriticalTimelimits=0 ;3 - Fallout 1 original behavior: -1 AP cost for all weapons; aimed attacks are disabled FastShotFix=1 +;Set to 1 to fix the carry weight penalty of the Small Frame trait not being applied to bonus Strength points +SmallFrameFix=0 + ;Set to 1 to boost the maximum number of script names from 1450 to 10000 BoostScriptDialogLimit=0 diff --git a/sfall/Interface.cpp b/sfall/Interface.cpp index 898e9d10..01d06074 100644 --- a/sfall/Interface.cpp +++ b/sfall/Interface.cpp @@ -613,8 +613,8 @@ void Interface_Init() { } // Corrects the height of the black background for death screen subtitles - if (hrpIsEnabled == false) SafeWrite32(0x48134D, 38 - (640 * 3)); // main_death_scene_ (shift y-offset 2px up, w/o HRP) - if (hrpIsEnabled == false || hrpVersionValid) SafeWrite8(0x481345, 4); // main_death_scene_ + if (!hrpIsEnabled) SafeWrite32(0x48134D, 38 - (640 * 3)); // main_death_scene_ (shift y-offset 2px up, w/o HRP) + if (!hrpIsEnabled || hrpVersionValid) SafeWrite8(0x481345, 4); // main_death_scene_ if (hrpVersionValid) SafeWrite8(HRPAddress(0x10011738), 10); // Cosmetic fix for the background image of the character portrait on the player's inventory screen diff --git a/sfall/Perks.cpp b/sfall/Perks.cpp index b6d6fbea..44fb9a72 100644 --- a/sfall/Perks.cpp +++ b/sfall/Perks.cpp @@ -935,11 +935,13 @@ static void PerkSetup() { /////////////////////////// TRAIT FUNCTIONS /////////////////////////////////// +static bool smallFrameTraitFix = false; + static int __stdcall DudeGetBaseStat(DWORD statID) { return fo_stat_get_base_direct(*ptr_obj_dude, statID); } -static bool __stdcall CheckTrait(DWORD traitID) { +static __forceinline bool __stdcall CheckTrait(DWORD traitID) { return (!disableTraits[traitID] && (ptr_pc_trait[0] == traitID || ptr_pc_trait[1] == traitID)); } @@ -947,8 +949,10 @@ static int __stdcall trait_adjust_stat_override(DWORD statID) { if (statID > STAT_max_derived) return 0; int result = 0; - if (ptr_pc_trait[0] != -1) result += traitStatBonuses[statID * TRAIT_count + ptr_pc_trait[0]]; - if (ptr_pc_trait[1] != -1) result += traitStatBonuses[statID * TRAIT_count + ptr_pc_trait[1]]; + if (traitsEnable) { + if (ptr_pc_trait[0] != -1) result += traitStatBonuses[statID * TRAIT_count + ptr_pc_trait[0]]; + if (ptr_pc_trait[1] != -1) result += traitStatBonuses[statID * TRAIT_count + ptr_pc_trait[1]]; + } switch (statID) { case STAT_st: @@ -985,8 +989,13 @@ static int __stdcall trait_adjust_stat_override(DWORD statID) { break; case STAT_carry_amt: if (CheckTrait(TRAIT_small_frame)) { - int str = DudeGetBaseStat(STAT_st); - result -= str * 10; + int st; + if (smallFrameTraitFix) { + st = fo_stat_level(*ptr_obj_dude, STAT_st); + } else { + st = DudeGetBaseStat(STAT_st); + } + result -= st * 10; } break; case STAT_sequence: @@ -1025,15 +1034,13 @@ static void __declspec(naked) trait_adjust_stat_hack() { static int __stdcall trait_adjust_skill_override(DWORD skillID) { int result = 0; - if (ptr_pc_trait[0] != -1) { - result += traitSkillBonuses[skillID * TRAIT_count + ptr_pc_trait[0]]; - } - if (ptr_pc_trait[1] != -1) { - result += traitSkillBonuses[skillID * TRAIT_count + ptr_pc_trait[1]]; - } - if (CheckTrait(TRAIT_gifted)) { - result -= 10; + if (traitsEnable) { + if (ptr_pc_trait[0] != -1) result += traitSkillBonuses[skillID * TRAIT_count + ptr_pc_trait[0]]; + if (ptr_pc_trait[1] != -1) result += traitSkillBonuses[skillID * TRAIT_count + ptr_pc_trait[1]]; } + + if (CheckTrait(TRAIT_gifted)) result -= 10; + if (CheckTrait(TRAIT_good_natured)) { if (skillID <= SKILL_THROWING) { result -= 10; @@ -1068,10 +1075,6 @@ static void PerkAndTraitSetup() { if (!traitsEnable) return; - // Replace functions - MakeJump(trait_adjust_stat_, trait_adjust_stat_hack); // 0x4B3C7C - MakeJump(trait_adjust_skill_, trait_adjust_skill_hack); // 0x4B40FC - std::memcpy(traits, (void*)FO_VAR_trait_data, sizeof(TraitInfo) * TRAIT_count); // _trait_data @@ -1404,6 +1407,13 @@ void PerksAcceptCharScreen() { } void Perks_Init() { + // Replace functions + MakeJump(trait_adjust_stat_, trait_adjust_stat_hack); // 0x4B3C7C + MakeJump(trait_adjust_skill_, trait_adjust_skill_hack); // 0x4B40FC + + // Fix the carry weight penalty of the Small Frame trait not being applied to bonus Strength points + smallFrameTraitFix = (GetConfigInt("Misc", "SmallFrameFix", 0) != 0); + FastShotTraitFix(); // Disable losing unused perks diff --git a/sfall/ScriptExtender.cpp b/sfall/ScriptExtender.cpp index bf0f99ff..2cc43add 100644 --- a/sfall/ScriptExtender.cpp +++ b/sfall/ScriptExtender.cpp @@ -1543,7 +1543,7 @@ static DWORD HandleTimedEventScripts() { bool eventWasRunning = false; for (std::list::const_iterator timerIt = timerEventScripts.cbegin(); timerIt != timerEventScripts.cend(); ++timerIt) { - if (timerIt->isActive == false) continue; + if (!timerIt->isActive) continue; if (currentTime >= timerIt->time) { if (timedEvent) executeTimedEvents.push(timedEvent); // store a pointer to the currently running event @@ -1570,7 +1570,7 @@ static DWORD HandleTimedEventScripts() { timedEvent = nullptr; // delete all previously executed events for (std::list::const_iterator it = timerEventScripts.cbegin(); it != timerEventScripts.cend();) { - if (it->isActive == false) { + if (!it->isActive) { dev_printf("\n[TimedEventScripts] Remove event: %d", it->time); it = timerEventScripts.erase(it); } else {