Fixed HOOK_REMOVEINVENOBJ to match RMOBJ_* defines

Edits to define_extra.h for RMOBJ_* defines
This commit is contained in:
NovaRain
2022-08-14 11:04:17 +08:00
parent 8b3a2bcead
commit ec5874a3c4
3 changed files with 38 additions and 13 deletions
+9 -5
View File
@@ -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)
+12
View File
@@ -569,6 +569,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;
@@ -883,6 +887,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
@@ -1419,6 +1427,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
+13 -4
View File
@@ -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;
}
@@ -64,6 +64,9 @@ static void __declspec(naked) RemoveObjHook() {
__asm {
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