Skip to content
Closed
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
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CNetAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,7 @@ void CNetAPI::WritePlayerPuresync(CClientPlayer* pPlayerModel, NetBitStreamInter
flags.data.bHasAWeapon = (pPlayerWeapon != NULL);
flags.data.bSyncingVelocity = (!flags.data.bIsOnGround || (pPlayerModel->GetPlayerSyncCount() % 4) == 0);
flags.data.bStealthAiming = (pPlayerModel->IsStealthAiming() == true);
flags.data.bReloadingWeapon = (pPlayerModel->IsReloadingWeapon() == true);

if (pPlayerWeapon->GetSlot() > 15)
flags.data.bHasAWeapon = false;
Expand Down
4 changes: 4 additions & 0 deletions Server/mods/deathmatch/logic/CPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ class CPed : public CElement
unsigned short GetWeaponTotalAmmo(unsigned char ucSlot = 0xFF);
void SetWeaponTotalAmmo(unsigned short usTotalAmmo, unsigned char ucSlot = 0xFF);

bool IsReloadingWeapon() { return m_bReloadingWeapon; };
void SetReloadingWeapon(bool bReloadingWeapon) { m_bReloadingWeapon = bReloadingWeapon; };

float GetMaxHealth();
float GetHealth() { return m_fHealth; }
void SetHealth(float fHealth) { m_fHealth = fHealth; }
Expand Down Expand Up @@ -306,6 +309,7 @@ class CPed : public CElement
bool m_bFrozen;
bool m_bStealthAiming;
CVehicle* m_pJackingVehicle;
bool m_bReloadingWeapon;

CVehicle* m_pVehicle;
unsigned int m_uiVehicleSeat;
Expand Down
4 changes: 3 additions & 1 deletion Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4391,8 +4391,10 @@ bool CStaticFunctionDefinitions::reloadPedWeapon(CElement* pElement)

if (IS_PED(pElement))
{
CPed* pPed = static_cast<CPed*>(pElement);
CBitStream BitStream;
CPed* pPed = static_cast<CPed*>(pElement);
pPed->SetReloadingWeapon(true);

m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(pPed, RELOAD_PED_WEAPON, *BitStream.pBitStream));
return true;
}
Expand Down
9 changes: 9 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*****************************************************************************/

#include "StdInc.h"
#include "lua/CLuaFunctionParser.h"

void CLuaPedDefs::LoadFunctions()
{
Expand Down Expand Up @@ -75,6 +76,7 @@ void CLuaPedDefs::LoadFunctions()
{"takeAllWeapons", TakeAllWeapons},
{"giveWeaponAmmo", GiveWeapon},
{"takeWeaponAmmo", TakeWeapon},
{"isPedReloadingWeapon", ArgumentParser<IsPedReloadingWeapon>},
};

// Add functions
Expand Down Expand Up @@ -114,6 +116,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "isFrozen", "isPedFrozen");
lua_classfunction(luaVM, "isHeadless", "isPedHeadless");
lua_classfunction(luaVM, "isWearingJetpack", "isPedWearingJetpack"); // introduced in 1.5.5-9.13846
lua_classfunction(luaVM, "isReloadingWeapon", "isPedReloadingWeapon");

lua_classfunction(luaVM, "getArmor", "getPedArmor");
lua_classfunction(luaVM, "getFightingStyle", "getPedFightingStyle");
Expand Down Expand Up @@ -165,6 +168,7 @@ void CLuaPedDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "vehicle", "warpPedIntoVehicle", "getPedOccupiedVehicle", OOP_WarpPedIntoVehicle, GetPedOccupiedVehicle);
lua_classvariable(luaVM, "walkingStyle", "setPedWalkingStyle", "getPedWalkingStyle");
lua_classvariable(luaVM, "jetpack", "setPedWearingJetpack", "isPedWearingJetpack"); // introduced in 1.5.5-9.13846
lua_classvariable(luaVM, "reloadingWeapon", nullptr, "isPedReloadingWeapon");

// TODO(qaisjp): setting this to any value will kill the ped. add OOP_KillPed that only allows `true`.
lua_classvariable(luaVM, "dead", "killPed", "isPedDead");
Expand Down Expand Up @@ -1613,3 +1617,8 @@ int CLuaPedDefs::TakeAllWeapons(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}

bool CLuaPedDefs::IsPedReloadingWeapon(CPed* const ped)
{
return ped->IsReloadingWeapon();
}
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaPedDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ class CLuaPedDefs : public CLuaDefs
LUA_DECLARE(SetPedHeadless);
LUA_DECLARE(SetPedFrozen);
LUA_DECLARE(reloadPedWeapon);

static bool IsPedReloadingWeapon(CPed* const ped);
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool CPlayerPuresyncPacket::Read(NetBitStreamInterface& BitStream)
pSourcePlayer->SetAkimboArmUp(flags.data.bAkimboTargetUp);
pSourcePlayer->SetOnFire(flags.data.bIsOnFire);
pSourcePlayer->SetStealthAiming(flags.data.bStealthAiming);
pSourcePlayer->SetReloadingWeapon(flags.data.bReloadingWeapon);

// Contact element
CElement* pContactElement = NULL;
Expand Down Expand Up @@ -298,6 +299,7 @@ bool CPlayerPuresyncPacket::Write(NetBitStreamInterface& BitStream) const
flags.data.bHasAWeapon = (ucWeaponSlot != 0);
flags.data.bSyncingVelocity = (!flags.data.bIsOnGround || pSourcePlayer->IsSyncingVelocity());
flags.data.bStealthAiming = (pSourcePlayer->IsStealthAiming() == true);
flags.data.bReloadingWeapon = (pSourcePlayer->IsReloadingWeapon() == true);

CVector vecPosition = pSourcePlayer->GetPosition();
if (pContactElement)
Expand Down
3 changes: 2 additions & 1 deletion Shared/sdk/net/SyncStructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ struct SPlayerPuresyncFlags : public ISyncStructure
{
enum
{
BITCOUNT = 12
BITCOUNT = 13
};

bool Read(NetBitStreamInterface& bitStream) { return bitStream.ReadBits((char*)&data, BITCOUNT); }
Expand All @@ -558,6 +558,7 @@ struct SPlayerPuresyncFlags : public ISyncStructure
bool bHasAWeapon : 1;
bool bSyncingVelocity : 1;
bool bStealthAiming : 1;
bool bReloadingWeapon : 1;
} data;
};

Expand Down