Add m_bCanShootOverride member (#527)

Add m_bCanShootOverride member
Allow to override m_bCanShoot, for example able to fire at freeze time
This commit is contained in:
fl0werD 2020-05-02 14:11:49 +04:00 committed by GitHub
parent 895dabc3a1
commit 4f7252525e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 5 deletions

View File

@ -1,3 +1,3 @@
majorVersion=5
minorVersion=15
minorVersion=16
maintenanceVersion=0

View File

@ -537,6 +537,7 @@ void CCSPlayer::Reset()
m_vecOldvAngle = g_vecZero;
m_iWeaponInfiniteAmmo = 0;
m_iWeaponInfiniteIds = 0;
m_bCanShootOverride = false;
}
void CCSPlayer::OnSpawn()

View File

@ -4894,7 +4894,12 @@ void EXT_FUNC UpdateClientData(const edict_t *ent, int sendweapons, struct clien
cd->m_flNextAttack = pPlayer->m_flNextAttack;
int iUser3 = 0;
if (pPlayer->m_bCanShoot && !pPlayer->m_bIsDefusing)
if (
#ifdef REGAMEDLL_API
pPlayer->CSPlayer()->m_bCanShootOverride ||
#endif
(pPlayer->m_bCanShoot && !pPlayer->m_bIsDefusing))
iUser3 |= PLAYER_CAN_SHOOT;
if (g_pGameRules->IsFreezePeriod())

View File

@ -948,7 +948,11 @@ void CBasePlayerWeapon::ItemPostFrame()
// Can't shoot during the freeze period
// Always allow firing in single player
if ((m_pPlayer->m_bCanShoot && g_pGameRules->IsMultiplayer() && !g_pGameRules->IsFreezePeriod() && !m_pPlayer->m_bIsDefusing) || !g_pGameRules->IsMultiplayer())
if (
#ifdef REGAMEDLL_API
m_pPlayer->CSPlayer()->m_bCanShootOverride ||
#endif
(m_pPlayer->m_bCanShoot && g_pGameRules->IsMultiplayer() && !g_pGameRules->IsFreezePeriod() && !m_pPlayer->m_bIsDefusing) || !g_pGameRules->IsMultiplayer())
{
PrimaryAttack();
}

View File

@ -44,7 +44,8 @@ public:
m_flRespawnPending(0),
m_flSpawnProtectionEndTime(0),
m_iWeaponInfiniteAmmo(0),
m_iWeaponInfiniteIds(0)
m_iWeaponInfiniteIds(0),
m_bCanShootOverride(false)
{
m_szModel[0] = '\0';
}
@ -121,6 +122,7 @@ public:
Vector m_vecOldvAngle;
int m_iWeaponInfiniteAmmo;
int m_iWeaponInfiniteIds;
bool m_bCanShootOverride;
};
// Inlines

View File

@ -38,7 +38,7 @@
#include <API/CSInterfaces.h>
#define REGAMEDLL_API_VERSION_MAJOR 5
#define REGAMEDLL_API_VERSION_MINOR 15
#define REGAMEDLL_API_VERSION_MINOR 16
// CBasePlayer::Spawn hook
typedef IHookChainClass<void, class CBasePlayer> IReGameHook_CBasePlayer_Spawn;