HOOK_STEAL: add ret0 value 2 to fail "silently"

This commit is contained in:
phobos2077
2023-07-22 13:43:23 +02:00
parent f267224428
commit 5394352bf0
3 changed files with 12 additions and 5 deletions
+1 -1
View File
@@ -377,7 +377,7 @@
int arg3 - 0 when stealing, 1 when planting
int arg4 - quantity of items being stolen
int ret0 - overrides hard-coded handler (1 - force success, 0 - force fail, -1 - use engine handler)
int ret0 - overrides hard-coded handler (2 - force fail without closing window, 1 - force success, 0 - force fail, -1 - use engine handler)
int ret1 - overrides experience points gained for stealing this item
```
+1 -1
View File
@@ -480,7 +480,7 @@ Item arg2 - Item being stolen/planted
int arg3 - 0 when stealing, 1 when planting
int arg4 - quantity of items being stolen
int ret0 - overrides hard-coded handler (1 - force success, 0 - force fail, -1 - use engine handler)
int ret0 - overrides hard-coded handler (2 - force fail without closing window, 1 - force success, 0 - force fail, -1 - use engine handler)
int ret1 - overrides experience points gained for stealing this item
```
+10 -3
View File
@@ -225,6 +225,7 @@ end:
}
static void __declspec(naked) StealCheckHook() {
static const unsigned long StealSkip_addr = 0x474B18;
__asm {
HookBegin;
mov args[0], eax; // thief
@@ -242,16 +243,22 @@ static void __declspec(naked) StealCheckHook() {
__asm {
popadc;
cmp cRet, 1;
jl defaultHandler;
jl defaultHandler; // no return values, use vanilla path
cmp cRet, 2;
jl skipExpOverride;
push eax;
mov eax, rets[4];
mov eax, rets[4]; // override experience points for steal
mov stealExpOverride, eax;
pop eax;
skipExpOverride:
cmp rets[0], -1;
cmp rets[0], -1; // if <= -1, use vanilla path
jle defaultHandler;
cmp rets[0], 2; // 2 - steal failed but didn't get cought
jnz normalReturn;
HookEnd;
pop eax;
jmp StealSkip_addr;
normalReturn:
mov eax, rets[0];
HookEnd;
retn;