From 7e74abf78f2de5bbb9a3f9e2e40a5d96d8a407b7 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 13 Jan 2026 14:23:02 +0800 Subject: [PATCH] Added settings about the mirrored shades to tweaks.ini Updated the description of Fallout1Behavior. --- artifacts/config_files/Tweaks.ini | 8 ++++++- artifacts/ddraw.ini | 8 +++---- sfall/Modules/EngineTweaks.cpp | 40 +++++++++++++++++++++++++++++++ sfall/Modules/MiscPatches.cpp | 4 ++-- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/artifacts/config_files/Tweaks.ini b/artifacts/config_files/Tweaks.ini index da1b3189..71182b00 100644 --- a/artifacts/config_files/Tweaks.ini +++ b/artifacts/config_files/Tweaks.ini @@ -2,7 +2,6 @@ [Main] - [Items] ;Override the PIDs of the standard healing drugs that AI will use in combat ;Set to -1 if you don't want AI to identify this item as a healing drug @@ -11,3 +10,10 @@ STIMPAK=40 SUPER_STIMPAK=144 HEALING_POWDER=273 + +;Overrides the PID of the item that grants a +1 stat bonus when placed in an active item slot +;Default is 433. Set to -1 to prevent any item from granting the bonus +MIRROR_SHADES_PID=433 +;The SPECIAL stat number (0..6) to which the bonus is applied +;Default is 3 (Charisma). Set to -1 to disable the item's effect +MIRROR_SHADES_STAT=3 diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 9593f6c8..dc3b8751 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -261,10 +261,10 @@ XltKey=0 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [Misc] ;Changes some of Fallout 2 engine functions to Fallout 1 behavior: -;- disables playing the final movie/credits after the endgame slideshow -;- disables halving the weight for power armor items -;- endgame_movie script function plays movie 10 or 11 based on the player's gender before the credits -;- the initial in-game time is 7:21 rather than 8:24 +;- the final movie/credits are not played after the endgame slideshow +;- the weight of power armor items is not halved +;- the endgame_movie script function plays movie 10 or 11 based on the player's gender before the credits +;- the initial in-game time is set to 7:21 Fallout1Behavior=0 ;Time limit in years. Must be between -3 and 13 diff --git a/sfall/Modules/EngineTweaks.cpp b/sfall/Modules/EngineTweaks.cpp index aef0a63a..8a352154 100644 --- a/sfall/Modules/EngineTweaks.cpp +++ b/sfall/Modules/EngineTweaks.cpp @@ -18,6 +18,7 @@ #include "..\main.h" #include "..\FalloutEngine\Fallout2.h" +#include "..\Utils.h" #include "..\Game\items.h" @@ -26,6 +27,36 @@ namespace sfall { +static long mirrorShadesPid = fo::PID_MIRROR_SHADES; +static long mirrorShadesStat = fo::STAT_ch; + +static long __fastcall MirrorShadesOverride(fo::GameObject* critter, long stat) { + if (stat == mirrorShadesStat) { + fo::GameObject* item = fo::func::inven_right_hand(critter); + if (item && item->protoId == mirrorShadesPid) return 1; + item = fo::func::inven_left_hand(critter); + if (item && item->protoId == mirrorShadesPid) return 1; + } + return 0; +} + +static __declspec(naked) void stat_level_hack_shades() { + __asm { + push ecx; + mov ecx, ebx; // critter (always obj_dude) + mov edx, esi; // stat + call MirrorShadesOverride; + pop ecx; + test eax, eax; + jz end; + inc ecx; // stat value +1 +end: // overwritten engine code + lea edi, [ecx + 1]; + test esi, esi; + retn; + } +} + void EngineTweaks::init() { auto tweaksFile = IniReader::GetConfigString("Misc", "TweaksFile", ""); if (!tweaksFile.empty()) { @@ -35,6 +66,15 @@ void EngineTweaks::init() { game::Items::SetHealingPID(0, IniReader::GetInt("Items", "STIMPAK", fo::PID_STIMPAK, cTweaksFile)); game::Items::SetHealingPID(1, IniReader::GetInt("Items", "SUPER_STIMPAK", fo::PID_SUPER_STIMPAK, cTweaksFile)); game::Items::SetHealingPID(2, IniReader::GetInt("Items", "HEALING_POWDER", fo::PID_HEALING_POWDER, cTweaksFile)); + + mirrorShadesPid = IniReader::GetInt("Items", "MIRROR_SHADES_PID", fo::PID_MIRROR_SHADES, cTweaksFile); + mirrorShadesStat = clamp(IniReader::GetInt("Items", "MIRROR_SHADES_STAT", fo::STAT_ch, cTweaksFile), -1, fo::STAT_lu); + if (mirrorShadesPid != fo::PID_MIRROR_SHADES || mirrorShadesStat != fo::STAT_ch) { + MakeCall(0x4AF10A, stat_level_hack_shades); + // Disable original handling + SafeWrite8(0x4AF1C3, CodeType::Jump); + SafeWrite32(0x4AF1C4, 487); // jmp 0x4AF3AF + } } } diff --git a/sfall/Modules/MiscPatches.cpp b/sfall/Modules/MiscPatches.cpp index e051e788..ad27ec12 100644 --- a/sfall/Modules/MiscPatches.cpp +++ b/sfall/Modules/MiscPatches.cpp @@ -771,9 +771,9 @@ static void F1EngineBehaviorPatch() { if (IniReader::GetConfigInt("Misc", "Fallout1Behavior", 0)) { dlogr("Applying Fallout 1 engine behavior patch.", DL_INIT); BlockCall(0x4A4343); // disable playing the final movie/credits after the endgame slideshow - SafeWrite8(0x477C71, CodeType::JumpShort); // disable halving the weight for power armor items + SafeWrite8(0x477C71, CodeType::JumpShort); // disable halving the weight of power armor items HookCall(0x43F872, endgame_movie_hook); // play movie 10 or 11 based on the player's gender before the credits - SafeWrite32(0x4A5201, 264600); // change the initial in-game time to 7:21 + SafeWrite32(0x4A5201, 264600); // set the initial in-game time to 7:21 } }