Skip to content

Commit

Permalink
Add m_bCanShootOverride member (#527)
Browse files Browse the repository at this point in the history
Add m_bCanShootOverride member
Allow to override m_bCanShoot, for example able to fire at freeze time
  • Loading branch information
fl0werD authored May 2, 2020
1 parent 895dabc commit 4f72525
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
majorVersion=5
minorVersion=15
minorVersion=16
maintenanceVersion=0
1 change: 1 addition & 0 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ void CCSPlayer::Reset()
m_vecOldvAngle = g_vecZero;
m_iWeaponInfiniteAmmo = 0;
m_iWeaponInfiniteIds = 0;
m_bCanShootOverride = false;
}

void CCSPlayer::OnSpawn()
Expand Down
7 changes: 6 additions & 1 deletion regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
6 changes: 5 additions & 1 deletion regamedll/dlls/weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 3 additions & 1 deletion regamedll/public/regamedll/API/CSPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class CCSPlayer: public CCSMonster {
m_flRespawnPending(0),
m_flSpawnProtectionEndTime(0),
m_iWeaponInfiniteAmmo(0),
m_iWeaponInfiniteIds(0)
m_iWeaponInfiniteIds(0),
m_bCanShootOverride(false)
{
m_szModel[0] = '\0';
}
Expand Down Expand Up @@ -121,6 +122,7 @@ class CCSPlayer: public CCSMonster {
Vector m_vecOldvAngle;
int m_iWeaponInfiniteAmmo;
int m_iWeaponInfiniteIds;
bool m_bCanShootOverride;
};

// Inlines
Expand Down
2 changes: 1 addition & 1 deletion regamedll/public/regamedll/regamedll_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4f72525

Please sign in to comment.