mirror of
https://github.com/ENSL/NS.git
synced 2025-01-22 01:01:17 +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_bobup "0.5"
|
||||
cl_weaponswap "2"
|
||||
cl_pistoltrigger "1"
|
||||
|
||||
+mlook
|
||||
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())
|
||||
{
|
||||
|
@ -574,12 +576,12 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
|||
//#ifdef AVH_CLIENT
|
||||
//if((m_iClip == 0) && ?
|
||||
//#endif
|
||||
PrimaryAttack();
|
||||
PrimaryAttack(pistolAttackUp);
|
||||
//return;
|
||||
}
|
||||
else
|
||||
{
|
||||
QueueAttack();
|
||||
QueueAttack(pistolAttackUp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -826,32 +826,6 @@ void IN_AttackUpForced(void)
|
|||
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
|
||||
void IN_Cancel(void)
|
||||
{
|
||||
|
@ -1565,8 +1539,6 @@ void NsPreset(void)
|
|||
char execText[1024];
|
||||
//char localizedText[1024];
|
||||
|
||||
inGameAdditional = gViewPort ? " See console for details." : "";
|
||||
|
||||
switch (presetChoice)
|
||||
{
|
||||
case 1:
|
||||
|
@ -1650,8 +1622,8 @@ void InitInput (void)
|
|||
gEngfuncs.pfnAddCommand ("-moveright", IN_MoverightUp);
|
||||
gEngfuncs.pfnAddCommand ("+speed", IN_SpeedDown);
|
||||
gEngfuncs.pfnAddCommand ("-speed", IN_SpeedUp);
|
||||
gEngfuncs.pfnAddCommand ("+attack", IN_AttackHandlerDown);
|
||||
gEngfuncs.pfnAddCommand ("-attack", IN_AttackHandlerUp);
|
||||
gEngfuncs.pfnAddCommand ("+attack", IN_AttackDown);
|
||||
gEngfuncs.pfnAddCommand ("-attack", IN_AttackUp);
|
||||
//gEngfuncs.pfnAddCommand ("+movement", IN_Attack2Down);
|
||||
//gEngfuncs.pfnAddCommand ("-movement", IN_Attack2Up);
|
||||
gEngfuncs.pfnAddCommand ("+use", IN_UseDown);
|
||||
|
@ -1735,7 +1707,7 @@ void InitInput (void)
|
|||
cl_chatbeep = gEngfuncs.pfnRegisterVariable ("cl_chatbeep", "1", FCVAR_ARCHIVE);
|
||||
cl_mutemenu = gEngfuncs.pfnRegisterVariable ("cl_mutemenu", "3", 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.
|
||||
CAM_Init();
|
||||
|
|
|
@ -361,6 +361,9 @@ public:
|
|||
// Added by mmcguire.
|
||||
virtual bool GetCanUseWeapon() const { return true; }
|
||||
|
||||
// Networked user options
|
||||
int m_iAutoWeaponSwap;
|
||||
int m_iPistolTrigger;
|
||||
};
|
||||
|
||||
#define AUTOAIM_2DEGREES 0.0348994967025
|
||||
|
|
|
@ -951,6 +951,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
|||
{
|
||||
// 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 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 theWeaponIsPriming = this->GetIsWeaponPriming();
|
||||
|
@ -989,7 +990,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
|||
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)
|
||||
{
|
||||
|
@ -1004,11 +1005,11 @@ void CBasePlayerWeapon::ItemPostFrame( void )
|
|||
}
|
||||
|
||||
m_pPlayer->TabulateAmmo();
|
||||
PrimaryAttack();
|
||||
PrimaryAttack(pistolAttackUp);
|
||||
}
|
||||
else
|
||||
{
|
||||
QueueAttack();
|
||||
QueueAttack(pistolAttackUp);
|
||||
}
|
||||
}
|
||||
else if (m_pPlayer->pev->button & IN_ATTACK2)
|
||||
|
|
|
@ -353,8 +353,8 @@ public:
|
|||
|
||||
virtual void ItemPostFrame( void ); // called each frame by the player PostThink
|
||||
// called by CBasePlayerWeapons ItemPostFrame()
|
||||
virtual void PrimaryAttack( void ) { return; } // do "+ATTACK"
|
||||
virtual void QueueAttack(void) { return; } // queue an attack
|
||||
virtual void PrimaryAttack( bool fireOnAttackUp = false ) { return; } // do "+ATTACK"
|
||||
virtual void QueueAttack( bool fireOnAttackUp = false ) { return; } // queue an attack
|
||||
virtual void SecondaryAttack( void ) { return; } // do "+ATTACK2"
|
||||
virtual void Reload( void ) { return; } // do "+RELOAD"
|
||||
virtual void WeaponIdle( void ) { return; } // called when no buttons pressed
|
||||
|
|
|
@ -180,6 +180,8 @@ AvHBasePlayerWeapon::AvHBasePlayerWeapon()
|
|||
this->mIsPersistent = false;
|
||||
this->mLifetime = -1;
|
||||
#endif
|
||||
|
||||
this->mFireOnAttackUp = false;
|
||||
}
|
||||
void AvHBasePlayerWeapon::PrintWeaponToClient(CBaseEntity *theAvHPlayer) {
|
||||
char msg[1024];
|
||||
|
@ -779,7 +781,7 @@ bool AvHBasePlayerWeapon::ProcessValidAttack(void)
|
|||
{
|
||||
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);
|
||||
theAttackIsValid = true;
|
||||
|
@ -1025,11 +1027,11 @@ void AvHBasePlayerWeapon::SetNextAttack(void)
|
|||
}
|
||||
|
||||
|
||||
void AvHBasePlayerWeapon::PrimaryAttack(void)
|
||||
void AvHBasePlayerWeapon::PrimaryAttack(bool fireOnAttackUp)
|
||||
{
|
||||
if (this->ProcessValidAttack())
|
||||
{
|
||||
|
||||
|
||||
if (!this->mAttackButtonDownLastFrame)
|
||||
{
|
||||
this->PlaybackEvent(this->mStartEvent);
|
||||
|
|
|
@ -177,7 +177,7 @@ public:
|
|||
|
||||
virtual void Precache();
|
||||
|
||||
virtual void PrimaryAttack();
|
||||
virtual void PrimaryAttack(bool fireOnAttackUp = false);
|
||||
|
||||
virtual void Reload();
|
||||
|
||||
|
@ -261,6 +261,8 @@ protected:
|
|||
|
||||
// sounds
|
||||
CStringList mFireSounds;
|
||||
|
||||
bool mFireOnAttackUp;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -643,9 +643,7 @@ BOOL AvHGamerules::CanHavePlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pWea
|
|||
int playerAutoSwapWeapon = 1;
|
||||
bool newWeaponCanFire = true;
|
||||
|
||||
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(pPlayer);
|
||||
if(thePlayer)
|
||||
playerAutoSwapWeapon = thePlayer->GetAutoWeapSwapValue();
|
||||
playerAutoSwapWeapon = pPlayer->m_iAutoWeaponSwap;
|
||||
|
||||
AvHBasePlayerWeapon* theNewWeapon = dynamic_cast<AvHBasePlayerWeapon*>(pWeapon);
|
||||
if (theNewWeapon)
|
||||
|
@ -866,13 +864,15 @@ void AvHGamerules::ClientUserInfoChanged(CBasePlayer *pPlayer, char *infobuffer)
|
|||
// NOTE: Not currently calling down to parent CHalfLifeTeamplay
|
||||
|
||||
const char* theAutoWeapSwapValue = g_engfuncs.pfnInfoKeyValue(infobuffer, "cl_weaponswap");
|
||||
if (theAutoWeapSwapValue)
|
||||
{
|
||||
pPlayer->m_iAutoWeaponSwap = atoi(theAutoWeapSwapValue);
|
||||
}
|
||||
|
||||
if (theAutoWeapSwapValue) {
|
||||
|
||||
AvHPlayer* thePlayer = dynamic_cast<AvHPlayer*>(pPlayer);
|
||||
if (thePlayer) {
|
||||
thePlayer->SetAutoWeapSwapValue(atoi(theAutoWeapSwapValue));
|
||||
}
|
||||
const char* thePistolTriggerValue = g_engfuncs.pfnInfoKeyValue(infobuffer, "cl_pistoltrigger");
|
||||
if (thePistolTriggerValue)
|
||||
{
|
||||
pPlayer->m_iPistolTrigger = atoi(thePistolTriggerValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ BOOL AvHGrenade::IsUseable(void)
|
|||
}
|
||||
|
||||
|
||||
void AvHGrenade::PrimaryAttack(void)
|
||||
void AvHGrenade::PrimaryAttack(bool fireOnAttackUp)
|
||||
{
|
||||
|
||||
if (this->ProcessValidAttack())
|
||||
|
|
|
@ -233,9 +233,9 @@ public:
|
|||
|
||||
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();
|
||||
|
||||
|
@ -624,7 +624,7 @@ public:
|
|||
|
||||
virtual void WeaponIdle();
|
||||
|
||||
virtual void PrimaryAttack(void);
|
||||
virtual void PrimaryAttack(bool fireOnAttackUp = false);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -174,17 +174,24 @@ void AvHPistol::Precache()
|
|||
this->mEvent = PRECACHE_EVENT(1, kHGEventName);
|
||||
}
|
||||
|
||||
void AvHPistol::PrimaryAttack()
|
||||
void AvHPistol::PrimaryAttack(bool fireOnAttackUp)
|
||||
{
|
||||
this->m_bAttackQueued = false;
|
||||
this->mFireOnAttackUp = fireOnAttackUp;
|
||||
if (fireOnAttackUp)
|
||||
{
|
||||
this->m_iPlayEmptySound = true;
|
||||
}
|
||||
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->mAttackButtonDownLastFrame = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -477,9 +477,6 @@ public:
|
|||
void SetUsedKilled(bool bKilled ) { mUsedKilled = bKilled; }
|
||||
void ClearOrders() { mClientOrders.clear(); }
|
||||
|
||||
int GetAutoWeapSwapValue() { return mAutoWeapSwapValue; }
|
||||
void SetAutoWeapSwapValue(int autoSwap) { mAutoWeapSwapValue = autoSwap; }
|
||||
|
||||
// : 0000953
|
||||
bool JoinTeamCooledDown(float inCoolDownTime);
|
||||
//
|
||||
|
@ -865,7 +862,6 @@ private:
|
|||
|
||||
bool mUsedKilled;
|
||||
|
||||
int mAutoWeapSwapValue;
|
||||
|
||||
//TODO: remove this system from AvHPlayer and create an
|
||||
// explicit balance forwarding class registered to each
|
||||
|
|
Loading…
Reference in a new issue