Backported the fix for TOHIT hook from 4.0 development branch (commit 7bbe84feef)

Updated credits.
This commit is contained in:
NovaRain
2017-03-19 08:29:27 +08:00
parent 659da227f4
commit 024b1dbf6f
3 changed files with 24 additions and 16 deletions
+3
View File
@@ -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
+1 -2
View File
@@ -61,9 +61,8 @@ static const char* ExtraLines[] = {
"MIB88",
"Rain man",
"Continuum",
"Fakeman",
"Drobovik",
"Mr.Stalin",
"Drobovik",
"Anyone who has used sfall in their own mods",
"The bug reporters and feature requesters",
""
+20 -14
View File
@@ -102,13 +102,19 @@ static void _stdcall RunHookScript(DWORD hook) {
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 determine_to_hit_func_
push [esp+4];
call determine_to_hit_func_;
mov args[0], eax;
pushad;
push HOOK_TOHIT;
@@ -1158,14 +1164,14 @@ static void HookScriptInit2() {
}
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);