diff --git a/artifacts/scripting/hookscripts.txt b/artifacts/scripting/hookscripts.txt index 3aafa6a5..c7e8ceb5 100644 --- a/artifacts/scripting/hookscripts.txt +++ b/artifacts/scripting/hookscripts.txt @@ -248,6 +248,7 @@ Obj arg1 - the owner that the object is being removed from item arg2 - the item that is being removed int arg3 - the number of items to remove int arg4 - The reason the object is being removed (see RMOBJ_* constants) +Obj arg5 - The destination object when the item is moved to another object, otherwise 0 ------------------------------------------- diff --git a/sfall/HookScripts.cpp b/sfall/HookScripts.cpp index 9bcc7adc..3871b3ed 100644 --- a/sfall/HookScripts.cpp +++ b/sfall/HookScripts.cpp @@ -572,22 +572,24 @@ end: static const DWORD RemoveObjHookRet = 0x477497; static void __declspec(naked) RemoveObjHook() { __asm { - push ecx; - mov ecx, [esp+4]; - hookbegin(4); - mov args[0], eax; - mov args[4], edx; - mov args[8], ebx; + mov ecx, [esp + 8]; // call addr + hookbegin(5); + mov args[0], eax; // source + mov args[4], edx; // item + mov args[8], ebx; // count mov args[12], ecx; + xor esi, esi; + xor ecx, 0x47761D; // from item_move_func_ + cmovz esi, ebp; // target + mov args[16], esi; + push edi; + push ebp; pushad; push HOOK_REMOVEINVENOBJ; call RunHookScript; popad; hookend; - push esi; - push edi; - push ebp; - sub esp, 0xc; + sub esp, 0x0C; jmp RemoveObjHookRet; } } @@ -1321,7 +1323,7 @@ static void HookScriptInit2() { HookCall(0x473573, &UseObjOnHook_item_d_take_drug); // inven_action_cursor LoadHookScript("hs_removeinvenobj", HOOK_REMOVEINVENOBJ); - MakeJump(0x477490, RemoveObjHook); + MakeJump(0x477492, RemoveObjHook); // old 0x477490 LoadHookScript("hs_barterprice", HOOK_BARTERPRICE); HookCall(0x474D4C, &BarterPriceHook);