Skip to content

Commit e36e109

Browse files
FileEXDutchman101tederis
authored
Fix ignorefirestate behaviour (#4195)
* Add new glitch * Move to special world property * Update CGameSA.cpp * Update SyncStructures.h * Update SyncStructures.h * Fix bug --------- Co-authored-by: Dutchman101 <12105539+Dutchman101@users.noreply.github.com> Co-authored-by: TEDERIs <xcplay@gmail.com>
1 parent 2493f07 commit e36e109

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

Client/multiplayer_sa/CMultiplayerSA.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,7 @@ void CMultiplayerSA::InitHooks()
15961596

15971597
InitHooks_Postprocess();
15981598
InitHooks_Explosions();
1599+
InitHooks_Tasks();
15991600
}
16001601

16011602
// Used to store copied pointers for explosions in the FxSystem

Client/multiplayer_sa/CMultiplayerSA.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class CMultiplayerSA : public CMultiplayer
8282
void InitHooks_Postprocess();
8383
void InitHooks_DeviceSelection();
8484
void InitHooks_Explosions();
85+
void InitHooks_Tasks();
8586
CRemoteDataStorage* CreateRemoteDataStorage();
8687
void DestroyRemoteDataStorage(CRemoteDataStorage* pData);
8788
void AddRemoteDataStorage(CPlayerPed* pPed, CRemoteDataStorage* pData);
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*****************************************************************************
2+
*
3+
* PROJECT: Multi Theft Auto
4+
* LICENSE: See LICENSE in the top level directory
5+
* FILE: multiplayer_sa/CMultiplayerSA_Tasks.cpp
6+
*
7+
* Multi Theft Auto is available from https://www.multitheftauto.com/
8+
*
9+
*****************************************************************************/
10+
#include "StdInc.h"
11+
12+
//////////////////////////////////////////////////////////////////////////////////////////
13+
//
14+
// CTaskSimplePlayerOnFoot::MakeAbortable
15+
//
16+
// If ignorefirestate is enabled, we need this hook to avoid tweaking the aiming animation
17+
// and the chainsaw turning off when entering fire
18+
//
19+
//////////////////////////////////////////////////////////////////////////////////////////
20+
static bool __IsIgnoreFireStateEnabled()
21+
{
22+
return pGameInterface->IsIgnoreFireStateEnabled();
23+
}
24+
25+
#define HOOKPOS_CTaskSimplePlayerOnFoot__MakeAbortable 0x68584D
26+
#define HOOKSIZE_CTaskSimplePlayerOnFoot__MakeAbortable 6
27+
static constexpr std::uintptr_t RETURN_CTaskSimplePlayerOnFoot__MakeAbortable = 0x68585F;
28+
static constexpr std::uintptr_t SKIP_CTaskSimplePlayerOnFoot__MakeAbortable = 0x685855;
29+
static void _declspec(naked) HOOK_CTaskSimplePlayerOnFoot__MakeAbortable()
30+
{
31+
_asm
32+
{
33+
// return false and keep task alive
34+
call dword ptr [eax+8]
35+
cmp eax, 3Dh
36+
jl skip
37+
38+
// if eventPriority == 66 (EventOnFire) && IsIgnoreFireStateEnabled()
39+
cmp eax, 42h
40+
jne continue_logic
41+
42+
call __IsIgnoreFireStateEnabled
43+
test al, al
44+
jz continue_logic
45+
46+
// return true but keep task alive
47+
pop edi
48+
pop esi
49+
pop ebx
50+
mov al, 1
51+
retn 0Ch
52+
53+
continue_logic:
54+
jmp RETURN_CTaskSimplePlayerOnFoot__MakeAbortable
55+
56+
skip:
57+
jmp SKIP_CTaskSimplePlayerOnFoot__MakeAbortable
58+
}
59+
}
60+
61+
//////////////////////////////////////////////////////////////////////////////////////////
62+
//
63+
// CMultiplayerSA::InitHooks_Tasks
64+
//
65+
// Setup hooks
66+
//
67+
//////////////////////////////////////////////////////////////////////////////////////////
68+
void CMultiplayerSA::InitHooks_Tasks()
69+
{
70+
EZHookInstall(CTaskSimplePlayerOnFoot__MakeAbortable);
71+
}

0 commit comments

Comments
 (0)