diff --git a/Client/game_sa/CGameSA.cpp b/Client/game_sa/CGameSA.cpp index bfd7341328..d9caa0438a 100644 --- a/Client/game_sa/CGameSA.cpp +++ b/Client/game_sa/CGameSA.cpp @@ -1141,6 +1141,29 @@ CWeaponStat* CGameSA::CreateWeaponStat(eWeaponType weaponType, eWeaponSkill weap return m_pWeaponStatsManager->CreateWeaponStatUnlisted(weaponType, weaponSkill); } +void CGameSA::SetWeaponRenderEnabled(bool enabled) +{ + if (!enabled) + { + // Disable calls to CVisibilityPlugins::RenderWeaponPedsForPC + MemSet((void*)0x53EAC4, 0x90, 5); // Idle + MemSet((void*)0x705322, 0x90, 5); // CPostEffects::Render + MemSet((void*)0x7271E3, 0x90, 5); // CMirrors::BeforeMainRender + } + else + { + // Restore original bytes + MemCpy((void*)0x53EAC4, "\xE8\x67\x44\x1F\x00", 5); + MemCpy((void*)0x705322, "\xE8\x09\xDC\x02\x00", 5); + MemCpy((void*)0x7271E3, "\xE8\x48\xBD\x00\x00", 5); + } +} + +bool CGameSA::IsWeaponRenderEnabled() const +{ + return *(unsigned char*)0x53EAC4 == 0xE8; +} + void CGameSA::OnPedContextChange(CPed* pPedContext) { m_pPedContext = pPedContext; diff --git a/Client/game_sa/CGameSA.h b/Client/game_sa/CGameSA.h index 4fc3d6f08a..54ab9597e4 100644 --- a/Client/game_sa/CGameSA.h +++ b/Client/game_sa/CGameSA.h @@ -287,6 +287,8 @@ class CGameSA : public CGame void SetupBrokenModels(); CWeapon* CreateWeapon(); CWeaponStat* CreateWeaponStat(eWeaponType weaponType, eWeaponSkill weaponSkill); + void SetWeaponRenderEnabled(bool enabled) override; + bool IsWeaponRenderEnabled() const override; void FlushPendingRestreamIPL(); void ResetModelLodDistances(); void ResetModelFlags(); diff --git a/Client/mods/deathmatch/logic/CClientGame.cpp b/Client/mods/deathmatch/logic/CClientGame.cpp index cf80781971..558a9a0de6 100644 --- a/Client/mods/deathmatch/logic/CClientGame.cpp +++ b/Client/mods/deathmatch/logic/CClientGame.cpp @@ -3428,9 +3428,6 @@ void CClientGame::Event_OnIngame() pHud->SetComponentVisible(HUD_VITAL_STATS, false); pHud->SetComponentVisible(HUD_AREA_NAME, false); - // Reset properties - CLuaPlayerDefs::ResetPlayerHudComponentProperty(HUD_ALL, eHudComponentProperty::ALL_PROPERTIES); - g_pMultiplayer->DeleteAndDisableGangTags(); g_pGame->GetBuildingRemoval()->ClearRemovedBuildingLists(); @@ -6114,6 +6111,16 @@ bool CClientGame::GetBirdsEnabled() return m_bBirdsEnabled; } +void CClientGame::SetWeaponRenderEnabled(bool enabled) +{ + g_pGame->SetWeaponRenderEnabled(enabled); +} + +bool CClientGame::IsWeaponRenderEnabled() const +{ + return g_pGame->IsWeaponRenderEnabled(); +} + #pragma code_seg(".text") bool CClientGame::VerifySADataFiles(int iEnableClientChecks) { diff --git a/Client/mods/deathmatch/logic/CClientGame.h b/Client/mods/deathmatch/logic/CClientGame.h index e887199fcd..b5819d8ee2 100644 --- a/Client/mods/deathmatch/logic/CClientGame.h +++ b/Client/mods/deathmatch/logic/CClientGame.h @@ -419,6 +419,9 @@ class CClientGame bool SetBirdsEnabled(bool bEnabled); bool GetBirdsEnabled(); + void SetWeaponRenderEnabled(bool enabled); + bool IsWeaponRenderEnabled() const; + void ResetWorldProperties(const ResetWorldPropsInfo& resetPropsInfo); CTransferBox* GetTransferBox() { return m_pTransferBox; }; diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWeaponDefs.cpp b/Client/mods/deathmatch/logic/luadefs/CLuaWeaponDefs.cpp index 3d3f53cee2..e75e0917df 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWeaponDefs.cpp +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWeaponDefs.cpp @@ -39,6 +39,8 @@ void CLuaWeaponDefs::LoadFunctions() {"getWeaponClipAmmo", GetWeaponClipAmmo}, {"setWeaponAmmo", SetWeaponAmmo}, {"setWeaponClipAmmo", SetWeaponClipAmmo}, + {"setWeaponRenderEnabled", ArgumentParser}, + {"isWeaponRenderEnabled", ArgumentParser} }; // Add functions @@ -979,3 +981,14 @@ int CLuaWeaponDefs::GetOriginalWeaponProperty(lua_State* luaVM) lua_pushboolean(luaVM, false); return 1; } + +bool CLuaWeaponDefs::SetWeaponRenderEnabled(bool enabled) +{ + g_pClientGame->SetWeaponRenderEnabled(enabled); + return true; +} + +bool CLuaWeaponDefs::IsWeaponRenderEnabled() +{ + return g_pClientGame->IsWeaponRenderEnabled(); +} diff --git a/Client/mods/deathmatch/logic/luadefs/CLuaWeaponDefs.h b/Client/mods/deathmatch/logic/luadefs/CLuaWeaponDefs.h index a1843a607b..dc1bfc7f70 100644 --- a/Client/mods/deathmatch/logic/luadefs/CLuaWeaponDefs.h +++ b/Client/mods/deathmatch/logic/luadefs/CLuaWeaponDefs.h @@ -11,6 +11,7 @@ #pragma once #include "CLuaDefs.h" +#include class CLuaWeaponDefs : public CLuaDefs { @@ -41,4 +42,6 @@ class CLuaWeaponDefs : public CLuaDefs LUA_DECLARE(GetWeaponClipAmmo); LUA_DECLARE(SetWeaponAmmo); LUA_DECLARE(SetWeaponClipAmmo); + static bool SetWeaponRenderEnabled(bool enabled); + static bool IsWeaponRenderEnabled(); }; diff --git a/Client/sdk/game/CGame.h b/Client/sdk/game/CGame.h index 60901293f7..b9e9e48f1d 100644 --- a/Client/sdk/game/CGame.h +++ b/Client/sdk/game/CGame.h @@ -237,6 +237,9 @@ class __declspec(novtable) CGame virtual CWeapon* CreateWeapon() = 0; virtual CWeaponStat* CreateWeaponStat(eWeaponType weaponType, eWeaponSkill weaponSkill) = 0; + virtual void SetWeaponRenderEnabled(bool enabled) = 0; + virtual bool IsWeaponRenderEnabled() const = 0; + virtual bool VerifySADataFileNames() = 0; virtual bool PerformChecks() = 0; virtual int& GetCheckStatus() = 0;