mirror of
https://github.com/ENSL/NS.git
synced 2024-11-29 07:41:53 +00:00
add cl_weaponswap
-refactored from alienbird's autoswap with new features
This commit is contained in:
parent
ff051cab8e
commit
3117a9f990
4 changed files with 35 additions and 6 deletions
|
@ -219,6 +219,7 @@ void CHud :: Init( void )
|
||||||
CVAR_CREATE( "cl_icong", "149", FCVAR_ARCHIVE);
|
CVAR_CREATE( "cl_icong", "149", FCVAR_ARCHIVE);
|
||||||
CVAR_CREATE( "cl_iconb", "221", FCVAR_ARCHIVE);
|
CVAR_CREATE( "cl_iconb", "221", FCVAR_ARCHIVE);
|
||||||
|
|
||||||
|
CVAR_CREATE("cl_weaponswap", "2", FCVAR_ARCHIVE | FCVAR_USERINFO);
|
||||||
m_pSpriteList = NULL;
|
m_pSpriteList = NULL;
|
||||||
|
|
||||||
// Clear any old HUD list
|
// Clear any old HUD list
|
||||||
|
|
|
@ -502,7 +502,8 @@ bool AvHBasePlayerWeapon::GetHasMuzzleFlash() const
|
||||||
|
|
||||||
bool AvHBasePlayerWeapon::GetIsCapableOfFiring() const
|
bool AvHBasePlayerWeapon::GetIsCapableOfFiring() const
|
||||||
{
|
{
|
||||||
return !this->UsesAmmo() || (this->m_iClip > 0);
|
//return !this->UsesAmmo() || (this->m_iClip > 0);
|
||||||
|
return !this->UsesAmmo() || (this->m_iClip > 0 || this->m_iDefaultAmmo > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -517,9 +517,9 @@ void AvHGamerules::RewardPlayerForKill(AvHPlayer* inPlayer, CBaseEntity* inTarge
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int theMin = BALANCE_VAR(kKillRewardMin);
|
int theMin = BALANCE_VAR(kKillRewardMin);
|
||||||
int theMax = BALANCE_VAR(kKillRewardMax);
|
int theMax = BALANCE_VAR(kKillRewardMax);
|
||||||
theResourceValue = RANDOM_LONG(theMin, theMax);
|
theResourceValue = RANDOM_LONG(theMin, theMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(theResourceValue > 0)
|
if(theResourceValue > 0)
|
||||||
|
@ -636,10 +636,22 @@ BOOL AvHGamerules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWea
|
||||||
int theCurrentFlag = (theWeaponFlags & (PRIMARY_WEAPON | SECONDARY_WEAPON));
|
int theCurrentFlag = (theWeaponFlags & (PRIMARY_WEAPON | SECONDARY_WEAPON));
|
||||||
CBasePlayerItem* theCurrentItem = NULL;
|
CBasePlayerItem* theCurrentItem = NULL;
|
||||||
bool theHasWeaponWithFlag = pPlayer->HasItemWithFlag(theCurrentFlag, theCurrentItem);
|
bool theHasWeaponWithFlag = pPlayer->HasItemWithFlag(theCurrentFlag, theCurrentItem);
|
||||||
|
|
||||||
if(theHasWeaponWithFlag)
|
if(theHasWeaponWithFlag)
|
||||||
{
|
{
|
||||||
if(theCurrentItem->iWeight() < pWeapon->iWeight())
|
int playerAutoSwapWeapon = 1;
|
||||||
|
bool newWeaponCanFire = true;
|
||||||
|
|
||||||
|
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(pPlayer);
|
||||||
|
if(thePlayer)
|
||||||
|
playerAutoSwapWeapon = thePlayer->GetAutoWeapSwapValue();
|
||||||
|
|
||||||
|
AvHBasePlayerWeapon* theNewWeapon = dynamic_cast<AvHBasePlayerWeapon*>(pWeapon);
|
||||||
|
if (theNewWeapon)
|
||||||
|
newWeaponCanFire = theNewWeapon->GetIsCapableOfFiring();
|
||||||
|
|
||||||
|
//if (theCurrentItem->iWeight() < pWeapon->iWeight())
|
||||||
|
if(theCurrentItem->iWeight() < pWeapon->iWeight() && (playerAutoSwapWeapon == 1 || (playerAutoSwapWeapon == 2 && newWeaponCanFire)))
|
||||||
{
|
{
|
||||||
theCanHaveIt = TRUE;
|
theCanHaveIt = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -851,6 +863,16 @@ void AvHGamerules::ClientKill( edict_t *pEntity )
|
||||||
void AvHGamerules::ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer)
|
void AvHGamerules::ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer)
|
||||||
{
|
{
|
||||||
// NOTE: Not currently calling down to parent CHalfLifeTeamplay
|
// NOTE: Not currently calling down to parent CHalfLifeTeamplay
|
||||||
|
|
||||||
|
const char* theAutoWeapSwapValue = g_engfuncs.pfnInfoKeyValue(infobuffer, "cl_weaponswap");
|
||||||
|
|
||||||
|
if (theAutoWeapSwapValue) {
|
||||||
|
|
||||||
|
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(pPlayer);
|
||||||
|
if (thePlayer) {
|
||||||
|
thePlayer->SetAutoWeapSwapValue(atoi(theAutoWeapSwapValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvHGamerules::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib )
|
void AvHGamerules::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTeamName, BOOL bKill, BOOL bGib )
|
||||||
|
|
|
@ -477,6 +477,9 @@ public:
|
||||||
void SetUsedKilled(bool bKilled ) { mUsedKilled = bKilled; }
|
void SetUsedKilled(bool bKilled ) { mUsedKilled = bKilled; }
|
||||||
void ClearOrders() { mClientOrders.clear(); }
|
void ClearOrders() { mClientOrders.clear(); }
|
||||||
|
|
||||||
|
int GetAutoWeapSwapValue() { return mAutoWeapSwapValue; }
|
||||||
|
void SetAutoWeapSwapValue(int autoSwap) { mAutoWeapSwapValue = autoSwap; }
|
||||||
|
|
||||||
// : 0000953
|
// : 0000953
|
||||||
bool JoinTeamCooledDown(float inCoolDownTime);
|
bool JoinTeamCooledDown(float inCoolDownTime);
|
||||||
//
|
//
|
||||||
|
@ -861,6 +864,8 @@ private:
|
||||||
|
|
||||||
bool mUsedKilled;
|
bool mUsedKilled;
|
||||||
|
|
||||||
|
int mAutoWeapSwapValue;
|
||||||
|
|
||||||
//TODO: remove this system from AvHPlayer and create an
|
//TODO: remove this system from AvHPlayer and create an
|
||||||
// explicit balance forwarding class registered to each
|
// explicit balance forwarding class registered to each
|
||||||
// client instead. This functionality is tangential to
|
// client instead. This functionality is tangential to
|
||||||
|
|
Loading…
Reference in a new issue