From 8967e95f0fc058f606b4653b9f424c58e73fcb3c Mon Sep 17 00:00:00 2001 From: NovaRain Date: Mon, 18 May 2026 14:03:36 +0800 Subject: [PATCH] Added a new value to InstantWeaponEquip Tweaked the animation sequence when interacting with scenery or using an item on an object. --- artifacts/ddraw.ini | 3 ++- sfall/Modules/Animations.cpp | 17 ++++++++++++++--- sfall/Modules/MiscPatches.cpp | 31 ++++++++++++++++++++++--------- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 0c099968..6d666b1c 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -707,7 +707,8 @@ ActiveGeigerMsgs=1 ;Set to 1 to fix the bug of being unable to sell used geiger counters or stealth boys CanSellUsedGeiger=1 -;Set to 1 to skip weapon equip/unequip animations when performing various actions +;Set to 1 to skip weapon equip/unequip animations during various actions +;Set to 2 to skip these animations only when interacting with objects InstantWeaponEquip=0 ;To add additional game msg files, uncomment the next line and set a comma-delimited list of filenames without .msg extension diff --git a/sfall/Modules/Animations.cpp b/sfall/Modules/Animations.cpp index 6b400ad3..8ee2ec8d 100644 --- a/sfall/Modules/Animations.cpp +++ b/sfall/Modules/Animations.cpp @@ -471,6 +471,13 @@ skip: } } +static __declspec(naked) void action_use_an_item_on_object_hook() { + __asm { + dec ebx; // set delay to -1 + jmp fo::funcoffs::register_object_animate_; + } +} + static __declspec(naked) void art_alias_fid_hack() { static const DWORD art_alias_fid_Ret = 0x419A6D; using namespace fo; @@ -663,12 +670,16 @@ void Animations::init() { // Fix crash when the critter goes through a door with animation trigger MakeJump(0x41755E, object_move_hack); - // Allow playing the "magic hands" animation when using an item on an object - SafeWrite16(0x4120B8, 0x9090); // action_use_an_item_on_object_ - // Fix for the player stuck at "climbing" frame after ladder climbing animation HookCall(0x411E1F, action_climb_ladder_hook); + // Allow playing the "magic hands" animation when using an item on an object + SafeWrite16(0x4120B8, 0x9090); // action_use_an_item_on_object_ + // Change the animation sequence to be in line with action_get_an_object_ + // ANIM_put_away animation only plays for "stairs" type scenery (SFX only for all other cases) + HookCall(0x41206D, action_use_an_item_on_object_hook); + SafeWrite32(0x4120BB, 0); // delay for "magic hands" animation + // Add ANIM_charred_body/ANIM_charred_body_sf animations to art aliases MakeCall(0x419A17, art_alias_fid_hack); diff --git a/sfall/Modules/MiscPatches.cpp b/sfall/Modules/MiscPatches.cpp index b8fc8bde..0968dbaf 100644 --- a/sfall/Modules/MiscPatches.cpp +++ b/sfall/Modules/MiscPatches.cpp @@ -608,19 +608,32 @@ static void InstantWeaponEquipPatch() { const DWORD PutAwayWeapon[] = { 0x411EA2, // action_climb_ladder_ 0x412046, // action_use_an_item_on_object_ - 0x41224A, // action_get_an_object_ + 0x41224A // action_get_an_object_ + }; + const DWORD PutAwayWeaponExtra[] = { 0x4606A5, // intface_change_fid_animate_ - 0x472996, // invenWieldFunc_ + 0x472996 // invenWieldFunc_ }; - if (IniReader::GetConfigInt("Misc", "InstantWeaponEquip", 0)) { - //Skip weapon equip/unequip animations + int skipAnims = IniReader::GetConfigInt("Misc", "InstantWeaponEquip", 0); + if (skipAnims) { + // Skip weapon equip/unequip animations dlogr("Applying instant weapon equip patch.", DL_INIT); - SafeWriteBatch(CodeType::JumpShort, PutAwayWeapon); // jmps - BlockCall(0x472AD5); // - BlockCall(0x472AE0); // invenUnwieldFunc_ - BlockCall(0x472AF0); // - MakeJump(0x415238, register_object_take_out_hack); + SafeWriteBatch(CodeType::JumpShort, PutAwayWeapon); + if (skipAnims == 1) { + SafeWriteBatch(CodeType::JumpShort, PutAwayWeaponExtra); + BlockCall(0x472AD5); // + BlockCall(0x472AE0); // invenUnwieldFunc_ + BlockCall(0x472AF0); // + MakeJump(0x415238, register_object_take_out_hack); + } else { + const DWORD TakeOutWeapon[] = { + 0x411F18, // action_climb_ladder_ + 0x412102, // action_use_an_item_on_object_ + 0x4122FA // action_get_an_object_ + }; + HookCalls(register_object_take_out_hack, TakeOutWeapon); + } } }