Skip to content

Commit

Permalink
Fix #3659 weapon switching (scroll and Q+E) while using Jetpack (#3573)
Browse files Browse the repository at this point in the history
  • Loading branch information
FileEX authored Jul 16, 2024
1 parent bea4823 commit 180fbc0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,9 @@ void CMultiplayerSA::InitHooks()
MemSet((void*)0x7225F5, 0x90, 4);
MemCpy((void*)0x725DDE, "\xFF\x76\xB\x90\x90", 5);

// Allow switch weapon during jetpack task (#3569)
MemSetFast((void*)0x60D86F, 0x90, 19);

InitHooks_CrashFixHacks();

// Init our 1.3 hooks.
Expand Down
22 changes: 22 additions & 0 deletions Server/mods/deathmatch/logic/CPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,25 @@ void CPed::SetJackingVehicle(CVehicle* pVehicle)
if (m_pJackingVehicle)
m_pJackingVehicle->SetJackingPed(this);
}

void CPed::SetHasJetPack(bool bHasJetPack)
{
if (m_bHasJetPack == bHasJetPack)
return;

m_bHasJetPack = bHasJetPack;

if (!bHasJetPack)
return;

// Set weapon slot to 0 if weapon is disabled with jetpack to avoid HUD and audio bugs
eWeaponType weaponType = static_cast<eWeaponType>(GetWeaponType(GetWeaponSlot()));
if (weaponType <= WEAPONTYPE_UNARMED)
return;

bool weaponEnabled;
CStaticFunctionDefinitions::GetJetpackWeaponEnabled(weaponType, weaponEnabled);

if (!weaponEnabled)
CStaticFunctionDefinitions::SetPedWeaponSlot(this, 0);
}
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class CPed : public CElement
static const char* GetBodyPartName(unsigned char ucID);

bool HasJetPack() { return m_bHasJetPack; }
void SetHasJetPack(bool bHasJetPack) { m_bHasJetPack = bHasJetPack; }
void SetHasJetPack(bool bHasJetPack);

bool IsInWater() { return m_bInWater; }
void SetInWater(bool bInWater) { m_bInWater = bInWater; }
Expand Down

0 comments on commit 180fbc0

Please sign in to comment.