mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Updated hook script document for new arguments of hs_barterprice.
Changed BarterPriceHook() to be in line with the version in 4.0 branch. Fixed incorrect GlobalVar struct size leading to load game crashes and corrupted saves (from 4.0 development branch)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
+1
-2
@@ -386,7 +386,6 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void __declspec(naked) loot_container_hack() {
|
||||
__asm {
|
||||
mov eax, [esp+0x114+0x4]
|
||||
@@ -1033,7 +1032,7 @@ void __declspec(naked) ItemCountFix() {
|
||||
static void __declspec(naked) Save_as_ASCII_hack() {
|
||||
__asm {
|
||||
mov edx, STAT_sequence;
|
||||
mov ebx, 626; // in EDITOR.MSG
|
||||
mov ebx, 626; // line index in EDITOR.MSG
|
||||
push 0x4396FC; // call stat_level_
|
||||
retn;
|
||||
}
|
||||
|
||||
+21
-14
@@ -88,6 +88,7 @@ static void _stdcall RunSpecificHookScript(sHookScript *hook) {
|
||||
else
|
||||
RunScriptProc(&hook->prog, start);
|
||||
}
|
||||
|
||||
static void _stdcall RunHookScript(DWORD hook) {
|
||||
if (hooks[hook].size()) {
|
||||
dlog_f("Running hook %d, which has %0d entries attached\r\n", DL_HOOK, hook, hooks[hook].size());
|
||||
@@ -121,6 +122,7 @@ end:
|
||||
retn 8;
|
||||
}
|
||||
}
|
||||
|
||||
static const DWORD AfterHitRollAddr=0x423898;
|
||||
static void __declspec(naked) AfterHitRollHook() {
|
||||
__asm {
|
||||
@@ -177,6 +179,7 @@ end:
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
// this is for using non-weapon items, always 2 AP in vanilla
|
||||
static void __declspec(naked) CalcApCostHook2() {
|
||||
__asm {
|
||||
@@ -268,6 +271,7 @@ aend:
|
||||
retn 8;
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) CalcDeathAnimHook2() {
|
||||
__asm {
|
||||
hookbegin(5);
|
||||
@@ -293,6 +297,7 @@ skip:
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) CombatDamageHook() {
|
||||
__asm {
|
||||
push edx;
|
||||
@@ -523,27 +528,27 @@ static void __declspec(naked) BarterPriceHook() {
|
||||
hookbegin(9);
|
||||
mov args[0], eax;
|
||||
mov args[4], edx;
|
||||
call barter_compute_value_
|
||||
call barter_compute_value_;
|
||||
mov edx, ds:[_btable]
|
||||
mov args[8], eax;
|
||||
mov args[12], edx;
|
||||
xchg eax, edx;
|
||||
call item_caps_total_
|
||||
call item_caps_total_;
|
||||
mov args[16], eax;
|
||||
mov eax, ds:[_btable]
|
||||
call item_total_cost_
|
||||
mov eax, ds:[_btable];
|
||||
call item_total_cost_;
|
||||
mov args[20], eax;
|
||||
mov eax, ds:[_ptable]
|
||||
mov args[24], eax
|
||||
call item_total_cost_
|
||||
mov args[28], eax
|
||||
xor eax, eax
|
||||
cmp edi, args[0] // check offers button
|
||||
jne skip
|
||||
inc eax
|
||||
mov eax, ds:[_ptable];
|
||||
mov args[24], eax;
|
||||
call 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
|
||||
mov eax, edx;
|
||||
mov args[32], eax;
|
||||
pushad;
|
||||
push HOOK_BARTERPRICE;
|
||||
call RunHookScript;
|
||||
@@ -746,6 +751,7 @@ void __declspec(naked) AmmoCostHookWrapper() {
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
void _stdcall KeyPressHook( DWORD dxKey, bool pressed, DWORD vKey )
|
||||
{
|
||||
BeginHook();
|
||||
@@ -1087,6 +1093,7 @@ void _stdcall SetHSReturn(DWORD d) {
|
||||
if (cRetTmp > cRet)
|
||||
cRet = cRetTmp;
|
||||
}
|
||||
|
||||
void _stdcall RegisterHook( DWORD script, DWORD id, DWORD procNum )
|
||||
{
|
||||
if (id >= numHooks) return;
|
||||
|
||||
@@ -27,9 +27,11 @@ enum SfallDataType {
|
||||
DATATYPE_STR
|
||||
};
|
||||
|
||||
#pragma pack(8)
|
||||
struct sGlobalVar {
|
||||
__int64 id;
|
||||
int val;
|
||||
__int32 val;
|
||||
__int32 unused;
|
||||
};
|
||||
|
||||
#define SCRIPT_PROC_MAX (27)
|
||||
|
||||
Reference in New Issue
Block a user