diff --git a/artifacts/scripting/headers/define_extra.h b/artifacts/scripting/headers/define_extra.h index 6630a4e6..c9089d01 100644 --- a/artifacts/scripting/headers/define_extra.h +++ b/artifacts/scripting/headers/define_extra.h @@ -137,16 +137,20 @@ //#define RMOBJ_DROP_DYNAMITE 4666865 // same as RMOBJ_USE_OBJ #define RMOBJ_ITEM_DESTROYED 4543215 // (op_destroy_object_) #define RMOBJ_ITEM_REMOVED 4548572 // (op_rm_obj_from_inven_) -#define RMOBJ_ARMOR_EQUIPED 4651961 // (setup_inventory_) -#define RMOBJ_LEFT_HAND_EQUIPED 4651899 // (setup_inventory_) -#define RMOBJ_RIGHT_HAND_EQUIPED 4651934 // (setup_inventory_) +#define RMOBJ_ARMOR_EQUIPED 4651961 // removing armor from the player's slot when entering INVENTORY/LOOT/BARTER/USE inventory +#define RMOBJ_LEFT_HAND_EQUIPED 4651899 // removing item from the player's left slot when entering INVENTORY/LOOT/BARTER/USE inventory +#define RMOBJ_RIGHT_HAND_EQUIPED 4651934 // removing item from the player's right slot when entering INVENTORY/LOOT/BARTER/USE inventory #define RMOBJ_RM_MULT_OBJS 4563866 // (op_rm_mult_objs_from_inven_) #define RMOBJ_REPLACE_WEAPON 4658526 // (switch_hand_) #define RMOBJ_THROW 4266040 // (action_ranged_) -#define RMOBJ_SUB_CONTAINER 4683191 // search and remove the item from nested containers in the inventory (item_remove_mult_) -#define RMOBJ_AI_USE_DRUG_ON 4359920 // remove before AI uses the drug in combat (ai_check_drugs_) +#define RMOBJ_SUB_CONTAINER 4683191 // search and remove the item from nested containers in the inventory +#define RMOBJ_AI_USE_DRUG_ON 4359920 // removing before AI uses the drug in combat //#define RMOBJ_AI_USE_DRUG_ON_1 4359639 // same as RMOBJ_AI_USE_DRUG_ON (obsolete, use only for sfall before 4.3.1/3.8.31) //#define RMOBJ_AI_USE_DRUG_ON_2 4360176 // same as RMOBJ_AI_USE_DRUG_ON (obsolete, use only for sfall before 4.3.1/3.8.31) +#define RMOBJ_BARTER_ARMOR 4675656 // removing armor from NPC's slot before entering the barter screen +#define RMOBJ_BARTER_WEAPON 4675722 // removing weapon from NPC's slot before entering the barter screen +#define RMOBJ_INVEN_DROP_CAPS 4667295 // if money/caps are dropped manually by the player from the inventory screen +#define RMOBJ_DROP_INTO_CONTAINER 4678833 // when dropping items into a container item (bag/backpack) // common prototype offsets for get/set_proto_data #define PROTO_PID (1) diff --git a/sfall/Modules/BugFixes.cpp b/sfall/Modules/BugFixes.cpp index 96d5b775..5be27ced 100644 --- a/sfall/Modules/BugFixes.cpp +++ b/sfall/Modules/BugFixes.cpp @@ -553,6 +553,10 @@ static void __declspec(naked) invenWieldFunc_item_get_type_hook() { mov cl, byte ptr [edi + 0x27]; and cl, 0x3; xchg edx, eax; // eax = who, edx = item + push eax; + push -2; + call SetRemoveObjectType; // call addr for HOOK_REMOVEINVENOBJ + pop eax; call fo::funcoffs::item_remove_mult_; xchg ebx, eax; mov eax, esi; @@ -867,6 +871,10 @@ foundItem: inc esi; // No, need to change from_slot skip: mov edx, ebp; + push eax; + push 0x47659D; + call SetRemoveObjectType; // call addr for HOOK_REMOVEINVENOBJ + pop eax; call fo::funcoffs::item_remove_mult_; test eax, eax; // Have weapon been deleted from inventory? jnz end; // No @@ -1403,6 +1411,10 @@ static void __declspec(naked) switch_hand_hack() { xor ebx, ebx; inc ebx; mov edx, ebp; + push eax; + push 0x4715F3; + call SetRemoveObjectType; // call addr for HOOK_REMOVEINVENOBJ + pop eax; call fo::funcoffs::item_remove_mult_; skip: pop edx; // _inven_dude diff --git a/sfall/Modules/HookScripts/InventoryHs.cpp b/sfall/Modules/HookScripts/InventoryHs.cpp index 4e1b9d57..93f2c9ee 100644 --- a/sfall/Modules/HookScripts/InventoryHs.cpp +++ b/sfall/Modules/HookScripts/InventoryHs.cpp @@ -42,6 +42,8 @@ static void __declspec(naked) RemoveObjHook() { cmp rmObjType, -1; cmovne ecx, rmObjType; mov rmObjType, -1; + cmp ecx, -2; + je skipHook; HookBegin; mov args[0], eax; // source mov args[4], edx; // item @@ -51,8 +53,6 @@ static void __declspec(naked) RemoveObjHook() { xor ecx, 0x47761D; // from item_move_func_ cmovz esi, ebp; // target mov args[16], esi; - push edi; - push ebp; push eax; push edx; } @@ -62,10 +62,13 @@ static void __declspec(naked) RemoveObjHook() { EndHook(); __asm { - pop edx; - pop eax; - sub esp, 0x0C; - jmp RemoveObjHookRet; + pop edx; + pop eax; +skipHook: + push edi; + push ebp; + sub esp, 0x0C; + jmp RemoveObjHookRet; } } @@ -232,8 +235,14 @@ skipHook: capsMultiDrop: if (dropResult == -1) { nextHookDropSkip = 1; - __asm call fo::funcoffs::item_remove_mult_; - __asm retn; + __asm { + push eax; + push 0x47379F; + call SetRemoveObjectType; // call addr for HOOK_REMOVEINVENOBJ + pop eax; + call fo::funcoffs::item_remove_mult_; + retn; + } } __asm add esp, 4; __asm jmp InvenActionObjDropRet; // no caps drop