mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed TOHIT hook issues: added 3 missing hook arguments, fixed incorrect attack type argument being passed to vanilla function, thus potentially breaking vanilla to hit calculations, even when not using any scripts at all
This commit is contained in:
@@ -84,6 +84,9 @@ int arg1 - The unmodified hit chance
|
||||
critter arg2 - The attacker
|
||||
critter arg3 - The target of the attack
|
||||
int arg4 - The targeted bodypart
|
||||
int arg5 - Source tile (may differ from attacker's tile, when AI is considering potential fire position)
|
||||
int arg6 - Attack Type (one of ATKTYPE_*)
|
||||
int arg7 - Ranged flag (0 or 1, actually passed 1 even for unarmed attacks, may be a vanilla bug)
|
||||
|
||||
int ret1 - the new hit chance
|
||||
|
||||
|
||||
@@ -112,13 +112,19 @@ static void _stdcall RunHookScript(DWORD hook) {
|
||||
// TODO: move specific hook scripts into separate files
|
||||
static void __declspec(naked) ToHitHook() {
|
||||
__asm {
|
||||
hookbegin(4);
|
||||
mov args[4], eax;
|
||||
mov args[8], ebx;
|
||||
mov args[12], ecx;
|
||||
hookbegin(7);
|
||||
mov args[4], eax; // attacker
|
||||
mov args[8], ebx; // target
|
||||
mov args[12], ecx; // body part
|
||||
mov args[16], edx; // source tile
|
||||
mov eax, [esp+4]; // attack type
|
||||
mov args[20], eax;
|
||||
mov eax, [esp+8]; // is ranged
|
||||
mov args[24], eax;
|
||||
mov eax, args[4];
|
||||
push [esp+8];
|
||||
push [esp+8];
|
||||
call fo::funcoffs::determine_to_hit_func_
|
||||
push [esp+4];
|
||||
call fo::funcoffs::determine_to_hit_func_;
|
||||
mov args[0], eax;
|
||||
pushad;
|
||||
push HOOK_TOHIT;
|
||||
@@ -1167,14 +1173,14 @@ static void HookScriptInit2() {
|
||||
dlogr("Loading hook scripts", DL_HOOK|DL_INIT);
|
||||
|
||||
LoadHookScript("hs_tohit", HOOK_TOHIT);
|
||||
HookCall(0x421686, &ToHitHook);
|
||||
HookCall(0x4231D9, &ToHitHook);
|
||||
HookCall(0x42331F, &ToHitHook);
|
||||
HookCall(0x4237FC, &ToHitHook);
|
||||
HookCall(0x424379, &ToHitHook);
|
||||
HookCall(0x42438D, &ToHitHook);
|
||||
HookCall(0x42439C, &ToHitHook);
|
||||
HookCall(0x42679A, &ToHitHook);
|
||||
HookCall(0x421686, &ToHitHook); // combat_safety_invalidate_weapon_func_
|
||||
HookCall(0x4231D9, &ToHitHook); // check_ranged_miss_
|
||||
HookCall(0x42331F, &ToHitHook); // shoot_along_path_
|
||||
HookCall(0x4237FC, &ToHitHook); // compute_attack_
|
||||
HookCall(0x424379, &ToHitHook); // determine_to_hit_
|
||||
HookCall(0x42438D, &ToHitHook); // determine_to_hit_no_range_
|
||||
HookCall(0x42439C, &ToHitHook); // determine_to_hit_from_tile_
|
||||
HookCall(0x42679A, &ToHitHook); // combat_to_hit_
|
||||
|
||||
LoadHookScript("hs_afterhitroll", HOOK_AFTERHITROLL);
|
||||
MakeCall(0x423893, &AfterHitRollHook, true);
|
||||
|
||||
Reference in New Issue
Block a user