From ede1bacf2b8fc4acb172e994dece3fb5a65b74eb Mon Sep 17 00:00:00 2001 From: phobos2077 Date: Mon, 13 Mar 2017 00:17:50 +0700 Subject: [PATCH] Added new arguments to barter price hook from Crafty (slightly modified) #76 --- artifacts/scripting/hookscripts.txt | 5 ++++- sfall/Modules/HookScripts.cpp | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/artifacts/scripting/hookscripts.txt b/artifacts/scripting/hookscripts.txt index 3ada112a..157da348 100644 --- a/artifacts/scripting/hookscripts.txt +++ b/artifacts/scripting/hookscripts.txt @@ -235,9 +235,12 @@ Runs whenever the value of goods being purchased is calculated critter arg1 - the critter doing the bartering (either dude_obj or inven_dude) critter arg2 - the critter being bartered with int arg3 - the default value of the goods -critter arg4 - the barter critter (has all of the goods being traded in its inventory) +critter arg4 - table of requested goods (being bought from NPC) int arg5 - the amount of actual caps in the barter stack (as opposed to goods) int arg6 - the value of all goods being traded before skill modifications +critter arg7 - table of offered goods (being sold to NPC) +int arg8 - the total cost of the goods offered by the player +int arg9 - set 1 if the "offers" button was pressed(not for a party member), otherwise 0 int ret1 - the modified value of all of the goods diff --git a/sfall/Modules/HookScripts.cpp b/sfall/Modules/HookScripts.cpp index 5789f413..f7a49cba 100644 --- a/sfall/Modules/HookScripts.cpp +++ b/sfall/Modules/HookScripts.cpp @@ -534,20 +534,30 @@ static void __declspec(naked) RemoveObjHook() { static void __declspec(naked) BarterPriceHook() { __asm { - hookbegin(6); + hookbegin(9); mov args[0], eax; mov args[4], edx; - call fo::funcoffs::barter_compute_value_ - mov edx, ds:[FO_VAR_btable] + call fo::funcoffs::barter_compute_value_; + mov edx, ds:[FO_VAR_btable]; mov args[8], eax; mov args[12], edx; xchg eax, edx; - call fo::funcoffs::item_caps_total_ + call fo::funcoffs::item_caps_total_; mov args[16], eax; mov eax, ds:[FO_VAR_btable] - call fo::funcoffs::item_total_cost_ + call fo::funcoffs::item_total_cost_; mov args[20], eax; - mov eax, edx; + mov eax, ds:[FO_VAR_ptable]; + mov args[24], eax; + call fo::funcoffs::item_total_cost_; + mov args[28], eax; + xor eax, eax; + mov edx, [esp]; // check offers button + cmp edx, 0x474D51; // last address on call stack + jne skip; + inc eax; +skip: + mov args[32], eax; pushad; push HOOK_BARTERPRICE; call RunHookScript;