Skip to content

Fix setPedOnFire(ped, false) doesn't cancel TASK_SIMPLE_PLAYER_ON_FIRE (again) #4188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions Client/game_sa/CFireSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "CFireSA.h"
#include "CGameSA.h"
#include "CPoolsSA.h"
#include <game/CTaskManager.h>
#include <game/TaskTypes.h>

extern CGameSA* pGame;

Expand Down Expand Up @@ -209,3 +211,43 @@ void CFireSA::SetNumGenerationsAllowed(char generations)
{
internalInterface->nNumGenerationsAllowed = generations;
}

////////////////////////////////////////////////////////////////////////
// CFire::Extinguish
//
// Fix GH #3249 (PLAYER_ON_FIRE task is not aborted after the fire is extinguished)
////////////////////////////////////////////////////////////////////////
static void AbortFireTask(CEntitySAInterface* entityOnFire)
{
auto ped = pGame->GetPools()->GetPed(reinterpret_cast<DWORD*>(entityOnFire));
if (!ped || !ped->pEntity)
return;

CTaskManager* taskManager = ped->pEntity->GetPedIntelligence()->GetTaskManager();
if (!taskManager)
return;

taskManager->RemoveTaskSecondary(TASK_SECONDARY_PARTIAL_ANIM, TASK_SIMPLE_PLAYER_ON_FIRE);
}

#define HOOKPOS_CFire_Extinguish 0x539429
#define HOOKSIZE_CFire_Extinguish 6
static constexpr std::uintptr_t CONTINUE_CFire_Extinguish = 0x53942F;
static void _declspec(naked) HOOK_CFire_Extinguish()
{
_asm
{
mov [eax+730h], edi

push eax
call AbortFireTask
add esp, 4

jmp CONTINUE_CFire_Extinguish
}
}

void CFireSA::StaticSetHooks()
{
EZHookInstall(CFire_Extinguish);
}
2 changes: 2 additions & 0 deletions Client/game_sa/CFireSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ class CFireSA : public CFire
void SetStrength(float fStrength);
void SetNumGenerationsAllowed(char generations);
CFireSAInterface* GetInterface() { return internalInterface; }

static void StaticSetHooks();
};
1 change: 1 addition & 0 deletions Client/game_sa/CGameSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ CGameSA::CGameSA()
CVehicleSA::StaticSetHooks();
CCheckpointSA::StaticSetHooks();
CHudSA::StaticSetHooks();
CFireSA::StaticSetHooks();
CPtrNodeSingleLinkPoolSA::StaticSetHooks();
CVehicleAudioSettingsManagerSA::StaticSetHooks();
}
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2520,7 +2520,7 @@ bool CLuaElementDefs::SetLowLodElement(lua_State* luaVM, CClientEntity* pEntity,

bool CLuaElementDefs::SetElementOnFire(CClientEntity* entity, bool onFire) noexcept
{
if (!entity->IsLocalEntity())
if (!entity->IsLocalEntity() && entity != CStaticFunctionDefinitions::GetLocalPlayer())
return false;

return entity->SetOnFire(onFire);
Expand Down
Loading