mirror of
https://github.com/ENSL/NS.git
synced 2025-02-01 21:51:03 +00:00
fix pistol firing when closing game menu or tabbing in
This commit is contained in:
parent
5636d7a103
commit
0688b2ef65
13 changed files with 49 additions and 63 deletions
|
@ -185,6 +185,7 @@ cl_bob "0.006"
|
||||||
cl_bobcycle "0.85"
|
cl_bobcycle "0.85"
|
||||||
cl_bobup "0.5"
|
cl_bobup "0.5"
|
||||||
cl_weaponswap "2"
|
cl_weaponswap "2"
|
||||||
|
cl_pistoltrigger "1"
|
||||||
|
|
||||||
+mlook
|
+mlook
|
||||||
exec userconfig.cfg
|
exec userconfig.cfg
|
||||||
|
|
|
@ -525,7 +525,9 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_pPlayer->pev->button & IN_ATTACK || this->m_bAttackQueued) && (!(m_pPlayer->pev->button & IN_ATTACK2) || gHUD.GetHUDUser3() == AVH_USER3_ALIEN_PLAYER3))
|
bool pistolAttackUp = ((CVAR_GET_FLOAT("cl_pistoltrigger") != 0) && m_pPlayer->m_afButtonLast & IN_ATTACK && m_pPlayer->m_afButtonReleased & IN_ATTACK && ii.iId == AVH_WEAPON_PISTOL);
|
||||||
|
|
||||||
|
if ((m_pPlayer->pev->button & IN_ATTACK || this->m_bAttackQueued || pistolAttackUp) && (!(m_pPlayer->pev->button & IN_ATTACK2) || gHUD.GetHUDUser3() == AVH_USER3_ALIEN_PLAYER3))
|
||||||
{
|
{
|
||||||
if (GetCanUseWeapon())
|
if (GetCanUseWeapon())
|
||||||
{
|
{
|
||||||
|
@ -574,12 +576,12 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
||||||
//#ifdef AVH_CLIENT
|
//#ifdef AVH_CLIENT
|
||||||
//if((m_iClip == 0) && ?
|
//if((m_iClip == 0) && ?
|
||||||
//#endif
|
//#endif
|
||||||
PrimaryAttack();
|
PrimaryAttack(pistolAttackUp);
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QueueAttack();
|
QueueAttack(pistolAttackUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -826,32 +826,6 @@ void IN_AttackUpForced(void)
|
||||||
KeyUpForced( &in_attack );
|
KeyUpForced( &in_attack );
|
||||||
}
|
}
|
||||||
|
|
||||||
void IN_AttackHandlerDown(void)
|
|
||||||
{
|
|
||||||
if (gHUD.GetCurrentWeaponID() == AVH_WEAPON_PISTOL && cl_pistoltrigger && cl_pistoltrigger->value)
|
|
||||||
{
|
|
||||||
IN_AttackDown();
|
|
||||||
IN_AttackUp();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IN_AttackDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void IN_AttackHandlerUp(void)
|
|
||||||
{
|
|
||||||
if (gHUD.GetCurrentWeaponID() == AVH_WEAPON_PISTOL && cl_pistoltrigger && cl_pistoltrigger->value)
|
|
||||||
{
|
|
||||||
IN_AttackDown();
|
|
||||||
IN_AttackUp();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
IN_AttackUp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special handling
|
// Special handling
|
||||||
void IN_Cancel(void)
|
void IN_Cancel(void)
|
||||||
{
|
{
|
||||||
|
@ -1565,8 +1539,6 @@ void NsPreset(void)
|
||||||
char execText[1024];
|
char execText[1024];
|
||||||
//char localizedText[1024];
|
//char localizedText[1024];
|
||||||
|
|
||||||
inGameAdditional = gViewPort ? " See console for details." : "";
|
|
||||||
|
|
||||||
switch (presetChoice)
|
switch (presetChoice)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1650,8 +1622,8 @@ void InitInput (void)
|
||||||
gEngfuncs.pfnAddCommand ("-moveright", IN_MoverightUp);
|
gEngfuncs.pfnAddCommand ("-moveright", IN_MoverightUp);
|
||||||
gEngfuncs.pfnAddCommand ("+speed", IN_SpeedDown);
|
gEngfuncs.pfnAddCommand ("+speed", IN_SpeedDown);
|
||||||
gEngfuncs.pfnAddCommand ("-speed", IN_SpeedUp);
|
gEngfuncs.pfnAddCommand ("-speed", IN_SpeedUp);
|
||||||
gEngfuncs.pfnAddCommand ("+attack", IN_AttackHandlerDown);
|
gEngfuncs.pfnAddCommand ("+attack", IN_AttackDown);
|
||||||
gEngfuncs.pfnAddCommand ("-attack", IN_AttackHandlerUp);
|
gEngfuncs.pfnAddCommand ("-attack", IN_AttackUp);
|
||||||
//gEngfuncs.pfnAddCommand ("+movement", IN_Attack2Down);
|
//gEngfuncs.pfnAddCommand ("+movement", IN_Attack2Down);
|
||||||
//gEngfuncs.pfnAddCommand ("-movement", IN_Attack2Up);
|
//gEngfuncs.pfnAddCommand ("-movement", IN_Attack2Up);
|
||||||
gEngfuncs.pfnAddCommand ("+use", IN_UseDown);
|
gEngfuncs.pfnAddCommand ("+use", IN_UseDown);
|
||||||
|
@ -1735,7 +1707,7 @@ void InitInput (void)
|
||||||
cl_chatbeep = gEngfuncs.pfnRegisterVariable ("cl_chatbeep", "1", FCVAR_ARCHIVE);
|
cl_chatbeep = gEngfuncs.pfnRegisterVariable ("cl_chatbeep", "1", FCVAR_ARCHIVE);
|
||||||
cl_mutemenu = gEngfuncs.pfnRegisterVariable ("cl_mutemenu", "3", FCVAR_ARCHIVE);
|
cl_mutemenu = gEngfuncs.pfnRegisterVariable ("cl_mutemenu", "3", FCVAR_ARCHIVE);
|
||||||
cl_weaponcfgs = gEngfuncs.pfnRegisterVariable ("cl_weaponcfgs", "1", FCVAR_ARCHIVE);
|
cl_weaponcfgs = gEngfuncs.pfnRegisterVariable ("cl_weaponcfgs", "1", FCVAR_ARCHIVE);
|
||||||
cl_pistoltrigger = gEngfuncs.pfnRegisterVariable ("cl_pistoltrigger", "1", FCVAR_ARCHIVE);
|
cl_pistoltrigger = gEngfuncs.pfnRegisterVariable ("cl_pistoltrigger", "1", FCVAR_ARCHIVE | FCVAR_USERINFO);
|
||||||
|
|
||||||
// Initialize third person camera controls.
|
// Initialize third person camera controls.
|
||||||
CAM_Init();
|
CAM_Init();
|
||||||
|
|
|
@ -361,6 +361,9 @@ public:
|
||||||
// Added by mmcguire.
|
// Added by mmcguire.
|
||||||
virtual bool GetCanUseWeapon() const { return true; }
|
virtual bool GetCanUseWeapon() const { return true; }
|
||||||
|
|
||||||
|
// Networked user options
|
||||||
|
int m_iAutoWeaponSwap;
|
||||||
|
int m_iPistolTrigger;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define AUTOAIM_2DEGREES 0.0348994967025
|
#define AUTOAIM_2DEGREES 0.0348994967025
|
||||||
|
|
|
@ -951,6 +951,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
||||||
{
|
{
|
||||||
// Block attacks during +movement except for lerk.
|
// Block attacks during +movement except for lerk.
|
||||||
bool theAttackPressed = (m_pPlayer->pev->button & IN_ATTACK) && (!(m_pPlayer->pev->button & IN_ATTACK2) || m_pPlayer->pev->iuser3 == AVH_USER3_ALIEN_PLAYER3);
|
bool theAttackPressed = (m_pPlayer->pev->button & IN_ATTACK) && (!(m_pPlayer->pev->button & IN_ATTACK2) || m_pPlayer->pev->iuser3 == AVH_USER3_ALIEN_PLAYER3);
|
||||||
|
bool pistolAttackUp = (m_pPlayer->m_iPistolTrigger && m_pPlayer->m_afButtonLast & IN_ATTACK && m_pPlayer->m_afButtonReleased & IN_ATTACK && m_iId == AVH_WEAPON_PISTOL);
|
||||||
|
|
||||||
bool theWeaponPrimes = (this->GetWeaponPrimeTime() > 0.0f);
|
bool theWeaponPrimes = (this->GetWeaponPrimeTime() > 0.0f);
|
||||||
bool theWeaponIsPriming = this->GetIsWeaponPriming();
|
bool theWeaponIsPriming = this->GetIsWeaponPriming();
|
||||||
|
@ -989,7 +990,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
||||||
else
|
else
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( (theAttackPressed || m_bAttackQueued) && m_pPlayer->GetCanUseWeapon())
|
if ( (theAttackPressed || m_bAttackQueued || pistolAttackUp) && m_pPlayer->GetCanUseWeapon())
|
||||||
{
|
{
|
||||||
if ((m_fInSpecialReload == 1 || m_fInSpecialReload == 2) && m_iClip != 0)
|
if ((m_fInSpecialReload == 1 || m_fInSpecialReload == 2) && m_iClip != 0)
|
||||||
{
|
{
|
||||||
|
@ -1004,11 +1005,11 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pPlayer->TabulateAmmo();
|
m_pPlayer->TabulateAmmo();
|
||||||
PrimaryAttack();
|
PrimaryAttack(pistolAttackUp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QueueAttack();
|
QueueAttack(pistolAttackUp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (m_pPlayer->pev->button & IN_ATTACK2)
|
else if (m_pPlayer->pev->button & IN_ATTACK2)
|
||||||
|
|
|
@ -353,8 +353,8 @@ public:
|
||||||
|
|
||||||
virtual void ItemPostFrame( void ); // called each frame by the player PostThink
|
virtual void ItemPostFrame( void ); // called each frame by the player PostThink
|
||||||
// called by CBasePlayerWeapons ItemPostFrame()
|
// called by CBasePlayerWeapons ItemPostFrame()
|
||||||
virtual void PrimaryAttack( void ) { return; } // do "+ATTACK"
|
virtual void PrimaryAttack( bool fireOnAttackUp = false ) { return; } // do "+ATTACK"
|
||||||
virtual void QueueAttack(void) { return; } // queue an attack
|
virtual void QueueAttack( bool fireOnAttackUp = false ) { return; } // queue an attack
|
||||||
virtual void SecondaryAttack( void ) { return; } // do "+ATTACK2"
|
virtual void SecondaryAttack( void ) { return; } // do "+ATTACK2"
|
||||||
virtual void Reload( void ) { return; } // do "+RELOAD"
|
virtual void Reload( void ) { return; } // do "+RELOAD"
|
||||||
virtual void WeaponIdle( void ) { return; } // called when no buttons pressed
|
virtual void WeaponIdle( void ) { return; } // called when no buttons pressed
|
||||||
|
|
|
@ -180,6 +180,8 @@ AvHBasePlayerWeapon::AvHBasePlayerWeapon()
|
||||||
this->mIsPersistent = false;
|
this->mIsPersistent = false;
|
||||||
this->mLifetime = -1;
|
this->mLifetime = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
this->mFireOnAttackUp = false;
|
||||||
}
|
}
|
||||||
void AvHBasePlayerWeapon::PrintWeaponToClient(CBaseEntity *theAvHPlayer) {
|
void AvHBasePlayerWeapon::PrintWeaponToClient(CBaseEntity *theAvHPlayer) {
|
||||||
char msg[1024];
|
char msg[1024];
|
||||||
|
@ -779,7 +781,7 @@ bool AvHBasePlayerWeapon::ProcessValidAttack(void)
|
||||||
{
|
{
|
||||||
if((this->m_flNextPrimaryAttack <= 0) && !this->m_fInSpecialReload)
|
if((this->m_flNextPrimaryAttack <= 0) && !this->m_fInSpecialReload)
|
||||||
{
|
{
|
||||||
if(!this->GetMustPressTriggerForEachShot() || (!this->mAttackButtonDownLastFrame))
|
if(!this->GetMustPressTriggerForEachShot() || !this->mAttackButtonDownLastFrame || this->mFireOnAttackUp)
|
||||||
{
|
{
|
||||||
//ALERT(at_console, "trueattack1 primammo:%d primatype:%d secammo:%d secatype:%d\n", this->m_pPlayer->m_rgAmmo[this->m_iPrimaryAmmoType], this->m_iPrimaryAmmoType, this->m_pPlayer->m_rgAmmo[this->m_iSecondaryAmmoType], this->m_iSecondaryAmmoType);
|
//ALERT(at_console, "trueattack1 primammo:%d primatype:%d secammo:%d secatype:%d\n", this->m_pPlayer->m_rgAmmo[this->m_iPrimaryAmmoType], this->m_iPrimaryAmmoType, this->m_pPlayer->m_rgAmmo[this->m_iSecondaryAmmoType], this->m_iSecondaryAmmoType);
|
||||||
theAttackIsValid = true;
|
theAttackIsValid = true;
|
||||||
|
@ -1025,11 +1027,11 @@ void AvHBasePlayerWeapon::SetNextAttack(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AvHBasePlayerWeapon::PrimaryAttack(void)
|
void AvHBasePlayerWeapon::PrimaryAttack(bool fireOnAttackUp)
|
||||||
{
|
{
|
||||||
if (this->ProcessValidAttack())
|
if (this->ProcessValidAttack())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!this->mAttackButtonDownLastFrame)
|
if (!this->mAttackButtonDownLastFrame)
|
||||||
{
|
{
|
||||||
this->PlaybackEvent(this->mStartEvent);
|
this->PlaybackEvent(this->mStartEvent);
|
||||||
|
|
|
@ -177,7 +177,7 @@ public:
|
||||||
|
|
||||||
virtual void Precache();
|
virtual void Precache();
|
||||||
|
|
||||||
virtual void PrimaryAttack();
|
virtual void PrimaryAttack(bool fireOnAttackUp = false);
|
||||||
|
|
||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
|
|
||||||
|
@ -261,6 +261,8 @@ protected:
|
||||||
|
|
||||||
// sounds
|
// sounds
|
||||||
CStringList mFireSounds;
|
CStringList mFireSounds;
|
||||||
|
|
||||||
|
bool mFireOnAttackUp;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -643,9 +643,7 @@ BOOL AvHGamerules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWea
|
||||||
int playerAutoSwapWeapon = 1;
|
int playerAutoSwapWeapon = 1;
|
||||||
bool newWeaponCanFire = true;
|
bool newWeaponCanFire = true;
|
||||||
|
|
||||||
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(pPlayer);
|
playerAutoSwapWeapon = pPlayer->m_iAutoWeaponSwap;
|
||||||
if(thePlayer)
|
|
||||||
playerAutoSwapWeapon = thePlayer->GetAutoWeapSwapValue();
|
|
||||||
|
|
||||||
AvHBasePlayerWeapon* theNewWeapon = dynamic_cast<AvHBasePlayerWeapon*>(pWeapon);
|
AvHBasePlayerWeapon* theNewWeapon = dynamic_cast<AvHBasePlayerWeapon*>(pWeapon);
|
||||||
if (theNewWeapon)
|
if (theNewWeapon)
|
||||||
|
@ -866,13 +864,15 @@ 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");
|
const char* theAutoWeapSwapValue = g_engfuncs.pfnInfoKeyValue(infobuffer, "cl_weaponswap");
|
||||||
|
if (theAutoWeapSwapValue)
|
||||||
|
{
|
||||||
|
pPlayer->m_iAutoWeaponSwap = atoi(theAutoWeapSwapValue);
|
||||||
|
}
|
||||||
|
|
||||||
if (theAutoWeapSwapValue) {
|
const char* thePistolTriggerValue = g_engfuncs.pfnInfoKeyValue(infobuffer, "cl_pistoltrigger");
|
||||||
|
if (thePistolTriggerValue)
|
||||||
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(pPlayer);
|
{
|
||||||
if (thePlayer) {
|
pPlayer->m_iPistolTrigger = atoi(thePistolTriggerValue);
|
||||||
thePlayer->SetAutoWeapSwapValue(atoi(theAutoWeapSwapValue));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ BOOL AvHGrenade::IsUseable(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AvHGrenade::PrimaryAttack(void)
|
void AvHGrenade::PrimaryAttack(bool fireOnAttackUp)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (this->ProcessValidAttack())
|
if (this->ProcessValidAttack())
|
||||||
|
|
|
@ -233,9 +233,9 @@ public:
|
||||||
|
|
||||||
virtual void Precache(void);
|
virtual void Precache(void);
|
||||||
|
|
||||||
virtual void PrimaryAttack();
|
virtual void PrimaryAttack(bool fireOnAttackUp = false);
|
||||||
|
|
||||||
virtual void QueueAttack(void);
|
virtual void QueueAttack(bool fireOnAttackUp);
|
||||||
|
|
||||||
virtual void Spawn();
|
virtual void Spawn();
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ public:
|
||||||
|
|
||||||
virtual void WeaponIdle();
|
virtual void WeaponIdle();
|
||||||
|
|
||||||
virtual void PrimaryAttack(void);
|
virtual void PrimaryAttack(bool fireOnAttackUp = false);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -174,17 +174,24 @@ void AvHPistol::Precache()
|
||||||
this->mEvent = PRECACHE_EVENT(1, kHGEventName);
|
this->mEvent = PRECACHE_EVENT(1, kHGEventName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvHPistol::PrimaryAttack()
|
void AvHPistol::PrimaryAttack(bool fireOnAttackUp)
|
||||||
{
|
{
|
||||||
this->m_bAttackQueued = false;
|
this->m_bAttackQueued = false;
|
||||||
|
this->mFireOnAttackUp = fireOnAttackUp;
|
||||||
|
if (fireOnAttackUp)
|
||||||
|
{
|
||||||
|
this->m_iPlayEmptySound = true;
|
||||||
|
}
|
||||||
AvHMarineWeapon::PrimaryAttack();
|
AvHMarineWeapon::PrimaryAttack();
|
||||||
|
this->mFireOnAttackUp = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvHPistol::QueueAttack(void)
|
void AvHPistol::QueueAttack(bool fireOnAttackUp)
|
||||||
{
|
{
|
||||||
if (!this->mAttackButtonDownLastFrame)
|
if (!this->mAttackButtonDownLastFrame || fireOnAttackUp)
|
||||||
{
|
{
|
||||||
this->m_bAttackQueued = true;
|
this->m_bAttackQueued = true;
|
||||||
|
this->mAttackButtonDownLastFrame = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -477,9 +477,6 @@ 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);
|
||||||
//
|
//
|
||||||
|
@ -865,7 +862,6 @@ 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
|
||||||
|
|
Loading…
Reference in a new issue