Skip to content

Commit d9ee190

Browse files
committed
Added a new value to InstantWeaponEquip
Tweaked the animation sequence when interacting with scenery or using an item on an object.
1 parent b4495f0 commit d9ee190

3 files changed

Lines changed: 37 additions & 13 deletions

File tree

artifacts/ddraw.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,8 @@ ActiveGeigerMsgs=1
689689
;Set to 1 to fix the bug of being unable to sell used geiger counters or stealth boys
690690
CanSellUsedGeiger=1
691691

692-
;Set to 1 to skip weapon equip/unequip animations when performing various actions
692+
;Set to 1 to skip weapon equip/unequip animations during various actions
693+
;Set to 2 to skip these animations only when interacting with objects
693694
InstantWeaponEquip=0
694695

695696
;To add additional game msg files, uncomment the next line and set a comma-delimited list of filenames without .msg extension

sfall/Modules/Animations.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,13 @@ static __declspec(naked) void action_climb_ladder_hook() {
475475
}
476476
}
477477

478+
static __declspec(naked) void action_use_an_item_on_object_hook() {
479+
__asm {
480+
dec ebx; // set delay to -1
481+
jmp fo::funcoffs::register_object_animate_;
482+
}
483+
}
484+
478485
static __declspec(naked) void art_alias_fid_hack() {
479486
static const DWORD art_alias_fid_Ret = 0x419A6D;
480487
using namespace fo;
@@ -665,12 +672,16 @@ void Animations::init() {
665672
// Fix crash when the critter goes through a door with animation trigger
666673
MakeJump(0x41755E, object_move_hack);
667674

668-
// Allow playing the "magic hands" animation when using an item on an object
669-
SafeWrite16(0x4120B8, 0x9090); // action_use_an_item_on_object_
670-
671675
// Fix for the player stuck at "climbing" frame after ladder climbing animation
672676
HookCall(0x411E1F, action_climb_ladder_hook);
673677

678+
// Allow playing the "magic hands" animation when using an item on an object
679+
SafeWrite16(0x4120B8, 0x9090); // action_use_an_item_on_object_
680+
// Change the animation sequence to be in line with action_get_an_object_
681+
// ANIM_put_away animation only plays for "stairs" type scenery (SFX only for all other cases)
682+
HookCall(0x41206D, action_use_an_item_on_object_hook);
683+
SafeWrite32(0x4120BB, 0); // delay for "magic hands" animation
684+
674685
// Add ANIM_charred_body/ANIM_charred_body_sf animations to art aliases
675686
MakeCall(0x419A17, art_alias_fid_hack);
676687

sfall/Modules/MiscPatches.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -577,19 +577,31 @@ static void InstantWeaponEquipPatch() {
577577
const DWORD PutAwayWeapon[] = {
578578
0x411EA2, // action_climb_ladder_
579579
0x412046, // action_use_an_item_on_object_
580-
0x41224A, // action_get_an_object_
580+
0x41224A // action_get_an_object_
581+
};
582+
const DWORD PutAwayWeaponExtra[] = {
581583
0x4606A5, // intface_change_fid_animate_
582-
0x472996, // invenWieldFunc_
584+
0x472996 // invenWieldFunc_
583585
};
584586

585-
if (IniReader::GetConfigInt("Misc", "InstantWeaponEquip", 0)) {
586-
//Skip weapon equip/unequip animations
587+
int skipAnims = IniReader::GetConfigInt("Misc", "InstantWeaponEquip", 0);
588+
if (skipAnims) {
589+
// Skip weapon equip/unequip animations
587590
dlogr("Applying instant weapon equip patch.", DL_INIT);
588-
SafeWriteBatch<BYTE>(CodeType::JumpShort, PutAwayWeapon); // jmps
589-
BlockCall(0x472AD5); //
590-
BlockCall(0x472AE0); // invenUnwieldFunc_
591-
BlockCall(0x472AF0); //
592-
MakeJump(0x415238, register_object_take_out_hack);
591+
SafeWriteBatch<BYTE>(CodeType::JumpShort, PutAwayWeapon);
592+
if (skipAnims == 1) {
593+
SafeWriteBatch<BYTE>(CodeType::JumpShort, PutAwayWeaponExtra);
594+
BlockCall(0x472AD5); //
595+
BlockCall(0x472AE0); // invenUnwieldFunc_
596+
BlockCall(0x472AF0); //
597+
MakeJump(0x415238, register_object_take_out_hack);
598+
} else {
599+
HookCalls(register_object_take_out_hack, {
600+
0x411F18, // action_climb_ladder_
601+
0x412102, // action_use_an_item_on_object_
602+
0x4122FA // action_get_an_object_
603+
});
604+
}
593605
}
594606
}
595607

0 commit comments

Comments
 (0)