mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Internal fix for HOOK_REMOVEINVENOBJ
This commit is contained in:
@@ -120,26 +120,29 @@
|
||||
#define MSGBOX_YESNO (0x10) // use YES/NO buttons instead of DONE
|
||||
#define MSGBOX_CLEAN (0x20) // no buttons
|
||||
|
||||
//remove inven obj defines
|
||||
#define RMOBJ_CONSUME_DRUG 4666772
|
||||
#define RMOBJ_CONTAINER 4683293 // same as RMOBJ_TRADE
|
||||
#define RMOBJ_USE_OBJ 4666865
|
||||
#define RMOBJ_EQUIP_ARMOR 4658121
|
||||
#define RMOBJ_EQUIP_WEAPON 4658675
|
||||
#define RMOBJ_UNLOAD_WEAPON 4667030
|
||||
//#define RMOBJ_LOAD_WEAPON 4831349 // same as RMOBJ_DROP
|
||||
#define RMOBJ_USE_DRUG_ON 4834866
|
||||
#define RMOBJ_STEAL_VIEW 4668206
|
||||
//#define RMOBJ_DROP_DYNAMITE 4666865 // same as USE_OBJ
|
||||
#define RMOBJ_ITEM_DESTROYED 4543215
|
||||
#define RMOBJ_ITEM_REMOVED 4548572
|
||||
#define RMOBJ_ARMOR_EQUIPED 4651961
|
||||
#define RMOBJ_LEFT_HAND_EQUIPED 4651899
|
||||
#define RMOBJ_RIGHT_HAND_EQUIPED 4651934
|
||||
#define RMOBJ_RM_MULT_OBJS 4563866
|
||||
#define RMOBJ_REPLACE_WEAPON 4658526
|
||||
#define RMOBJ_THROW 4266040
|
||||
#define RMOBJ_SUB_CONTAINER 4683191 // search and remove the item from nested containers in the inventory
|
||||
//remove inven obj defines for the 4th argument to hs_removeinvobj
|
||||
#define RMOBJ_CONSUME_DRUG 4666772 // (inven_action_cursor_)
|
||||
#define RMOBJ_CONTAINER 4683293 // same as RMOBJ_TRADE (item_move_func_)
|
||||
#define RMOBJ_USE_OBJ 4666865 // (inven_action_cursor_)
|
||||
#define RMOBJ_EQUIP_ARMOR 4658121 // (inven_pickup_)
|
||||
#define RMOBJ_EQUIP_WEAPON 4658675 // (switch_hand_)
|
||||
#define RMOBJ_UNLOAD_WEAPON 4667030 // (inven_action_cursor_)
|
||||
//#define RMOBJ_LOAD_WEAPON 4831349 // same as RMOBJ_DROP (obj_remove_from_inven_)
|
||||
#define RMOBJ_USE_DRUG_ON 4834866 // (obj_use_item_on_)
|
||||
#define RMOBJ_STEAL_VIEW 4668206 // (loot_container_)
|
||||
//#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_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_AI_USE_DRUG_ON_1 4359639 // same as RMOBJ_AI_USE_DRUG_ON (obsolete, use only for sfall before 4.3.1)
|
||||
//#define RMOBJ_AI_USE_DRUG_ON_2 4360176 // same as RMOBJ_AI_USE_DRUG_ON (obsolete, use only for sfall before 4.3.1)
|
||||
|
||||
// common prototype offsets for get/set_proto_data
|
||||
#define PROTO_PID (1)
|
||||
|
||||
@@ -128,7 +128,7 @@
|
||||
//Some possible values for the 4th argument to hs_removeinvobj
|
||||
#define RMOBJ_DROP (0x49B875) // If the object is dropped manually by the player from the inventory screen
|
||||
#define RMOBJ_TRADE (0x47761D) // If the object is offered up as a trade
|
||||
#define RMOBJ_DROPMULTI (0x45C1CF) //When dropping a part of a stack (RMOBJ_DROP occures first)
|
||||
#define RMOBJ_DROPMULTI (0x45C1CF) // When dropping a part of a stack (RMOBJ_DROP occurs first)
|
||||
|
||||
//Return values for "typeof"
|
||||
#define VALTYPE_NONE (0) // not used yet
|
||||
|
||||
@@ -77,7 +77,7 @@ void __stdcall CombatAI::ai_check_drugs(fo::GameObject* source) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (game::Items::IsHealingItem(itemFind) && !fo::func::item_remove_mult(source, itemFind, 1)) { // HOOK_REMOVEINVENOBJ
|
||||
if (game::Items::IsHealingItem(itemFind) && !game::Items::item_remove_mult(source, itemFind, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ
|
||||
if (!game::Items::UseDrugItemFunc(source, itemFind)) { // HOOK_USEOBJON
|
||||
drugWasUsed = true;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ void __stdcall CombatAI::ai_check_drugs(fo::GameObject* source) {
|
||||
// if the preference counter is less than 3, then AI can use the drug
|
||||
if (counter < 3) {
|
||||
// if the item is NOT a healing drug
|
||||
if (!game::Items::IsHealingItem(item) && !fo::func::item_remove_mult(source, item, 1)) { // HOOK_REMOVEINVENOBJ
|
||||
if (!game::Items::IsHealingItem(item) && !game::Items::item_remove_mult(source, item, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ
|
||||
if (!game::Items::UseDrugItemFunc(source, item)) { // HOOK_USEOBJON
|
||||
drugWasUsed = true;
|
||||
usedCount++;
|
||||
@@ -163,7 +163,7 @@ void __stdcall CombatAI::ai_check_drugs(fo::GameObject* source) {
|
||||
}
|
||||
}
|
||||
|
||||
if (lastItem && !fo::func::item_remove_mult(source, lastItem, 1)) { // HOOK_REMOVEINVENOBJ
|
||||
if (lastItem && !game::Items::item_remove_mult(source, lastItem, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ
|
||||
if (!game::Items::UseDrugItemFunc(source, lastItem)) lastItem = nullptr; // HOOK_USEOBJON
|
||||
|
||||
source->critter.decreaseAP(aiUseItemAPCost);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "..\FalloutEngine\Fallout2.h"
|
||||
|
||||
#include "..\Modules\HookScripts\CombatHs.h"
|
||||
#include "..\Modules\HookScripts\InventoryHs.h"
|
||||
#include "..\Modules\HookScripts\ObjectHs.h"
|
||||
#include "..\Modules\Perks.h"
|
||||
|
||||
@@ -22,7 +23,7 @@ namespace game
|
||||
|
||||
namespace sf = sfall;
|
||||
|
||||
static constexpr int reloadCostAP = 2; // engine default reload AP cost
|
||||
constexpr int reloadCostAP = 2; // engine default reload AP cost
|
||||
|
||||
static std::array<long, 3> healingItemPids = {fo::PID_STIMPAK, fo::PID_SUPER_STIMPAK, fo::PID_HEALING_POWDER};
|
||||
|
||||
@@ -67,6 +68,11 @@ long Items::item_d_take_drug(fo::GameObject* source, fo::GameObject* item) {
|
||||
return -1; // cancel the drug use
|
||||
}
|
||||
|
||||
long Items::item_remove_mult(fo::GameObject* source, fo::GameObject* item, long count, long rmType) {
|
||||
sf::SetRemoveObjectType(rmType);
|
||||
return fo::func::item_remove_mult(source, item, count);
|
||||
}
|
||||
|
||||
long Items::item_count(fo::GameObject* who, fo::GameObject* item) {
|
||||
for (int i = 0; i < who->invenSize; i++) {
|
||||
auto tableItem = &who->invenTable[i];
|
||||
|
||||
@@ -24,6 +24,8 @@ public:
|
||||
// Implementation of item_d_take_ engine function with the HOOK_USEOBJON hook
|
||||
static long item_d_take_drug(fo::GameObject* source, fo::GameObject* item);
|
||||
|
||||
static long item_remove_mult(fo::GameObject* source, fo::GameObject* item, long count, long rmType);
|
||||
|
||||
static long item_count(fo::GameObject* who, fo::GameObject* item);
|
||||
|
||||
static long item_weapon_range(fo::GameObject* source, fo::GameObject* weapon, long hitMode);
|
||||
|
||||
@@ -10,16 +10,44 @@
|
||||
|
||||
namespace sfall
|
||||
{
|
||||
/*
|
||||
static void RemoveInvenObjHook_Script(fo::GameObject* source, fo::GameObject* item, long count, long rmType) {
|
||||
BeginHook();
|
||||
argCount = 5;
|
||||
|
||||
args[0] = (DWORD)source;
|
||||
args[1] = (DWORD)item;
|
||||
args[2] = count;
|
||||
args[3] = rmType; // RMOBJ_*
|
||||
args[4] = 0; // target only from item_move_func_
|
||||
|
||||
RunHookScript(HOOK_REMOVEINVENOBJ);
|
||||
EndHook();
|
||||
}
|
||||
|
||||
void RemoveInvenObjHook_Invoke(fo::GameObject* source, fo::GameObject* item, long count, long rmType) {
|
||||
if (HookScripts::HookHasScript(HOOK_REMOVEINVENOBJ)) RemoveInvenObjHook_Script(source, item, count, rmType);
|
||||
}
|
||||
*/
|
||||
|
||||
static long rmObjType = -1;
|
||||
|
||||
void SetRemoveObjectType(long rmType) {
|
||||
rmObjType = rmType;
|
||||
}
|
||||
|
||||
static void __declspec(naked) RemoveObjHook() {
|
||||
static const DWORD RemoveObjHookRet = 0x477497;
|
||||
__asm {
|
||||
mov ecx, [esp + 8]; // call addr
|
||||
cmp rmObjType, -1;
|
||||
cmovne ecx, rmObjType;
|
||||
mov rmObjType, -1;
|
||||
HookBegin;
|
||||
mov args[0], eax; // source
|
||||
mov args[4], edx; // item
|
||||
mov args[8], ebx; // count
|
||||
mov args[12], ecx; // called func
|
||||
mov args[12], ecx; // RMOBJ_* (called func)
|
||||
xor esi, esi;
|
||||
xor ecx, 0x47761D; // from item_move_func_
|
||||
cmovz esi, ebp; // target
|
||||
|
||||
@@ -18,4 +18,6 @@ long InvenWieldHook_Invoke(fo::GameObject* critter, fo::GameObject* item, long f
|
||||
void InvenUnwield_HookDrop();
|
||||
void InvenUnwield_HookMove();
|
||||
|
||||
void SetRemoveObjectType(long rmType);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user