mirror of
https://github.com/ENSL/NS.git
synced 2024-11-10 07:11:38 +00:00
reload while using armory
This commit is contained in:
parent
6351afad0c
commit
ea279fb321
3 changed files with 39 additions and 11 deletions
|
@ -1087,14 +1087,29 @@ bool AvHBasePlayerWeapon::Resupply()
|
|||
this->m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = min(theCurrentPrimary + theAmountToAdd, theMaxPrimary);
|
||||
|
||||
const float theDelay = 1.0f;
|
||||
//bugfix - don't let resupply shorten reload time
|
||||
this->m_pPlayer->m_flNextAttack = max(this->m_pPlayer->m_flNextAttack,UTIL_WeaponTimeBase() + theDelay);
|
||||
|
||||
if (this->m_iId != AVH_WEAPON_SONIC && this->m_iId != AVH_WEAPON_GRENADE_GUN)
|
||||
{
|
||||
this->m_flNextPrimaryAttack = max(this->m_flNextPrimaryAttack, (UTIL_WeaponTimeBase() + (theDelay * 2)));// Delay*2 because nextprimary attack gets decremented twice.
|
||||
}
|
||||
else
|
||||
{
|
||||
bool startingReload = (this->m_pPlayer->pev->button & IN_RELOAD && (this->m_iClip < this->GetClipSize()));
|
||||
//Some edge cases here but it allows staged reload to start or continue while resupplying and adds resupply delay if not reloading.
|
||||
if ((this->m_fInSpecialReload == 0 && !startingReload) || (this->m_fInSpecialReload >= 2 && this->m_iClip >= (this->GetClipSize() - 1)))
|
||||
this->m_flNextPrimaryAttack = max(this->m_flNextPrimaryAttack, (UTIL_WeaponTimeBase() + (theDelay * 2)));
|
||||
}
|
||||
this->mTimeOfLastResupply = UTIL_WeaponTimeBase() + theDelay;
|
||||
}
|
||||
|
||||
return theResupplied;
|
||||
}
|
||||
|
||||
float AvHBasePlayerWeapon::GetResupplyTimer() const
|
||||
{
|
||||
return this->mTimeOfLastResupply;
|
||||
}
|
||||
|
||||
void AvHBasePlayerWeapon::SendWeaponAnim(int inAnimation, int skiplocal, int body)
|
||||
{
|
||||
if(inAnimation >= 0)
|
||||
|
|
|
@ -140,6 +140,8 @@ public:
|
|||
|
||||
virtual float GetRateOfFire() const;
|
||||
|
||||
virtual float GetResupplyTimer() const;
|
||||
|
||||
virtual char* GetPlayerModel() const;
|
||||
|
||||
virtual char* GetPrimeSound() const;
|
||||
|
|
|
@ -151,19 +151,30 @@ void AvHReloadableMarineWeapon::Reload(void)
|
|||
if (this->m_fInSpecialReload == kSpecialReloadPump)
|
||||
{
|
||||
//pump the shotgun to end the reload if attack is pressed during a reload
|
||||
//ALERT(at_console, "reloadpump3\n");
|
||||
this->SendWeaponAnim(this->GetEndReloadAnimation());
|
||||
|
||||
//float theEndReloadAnimationTime = this->GetEndReloadAnimationTime();
|
||||
//this->m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + theEndReloadAnimationTime;
|
||||
//this->m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + theEndReloadAnimationTime;
|
||||
//this->m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + theEndReloadAnimationTime;
|
||||
|
||||
//+1 is the average of the gotoreload and shellreload times previously used to limit primary attack and matches the marine putting his hand on the gun. Actual time is half these values in seconds because timers get decremented twice.
|
||||
const float theEndReloadTime = 1.0f;
|
||||
|
||||
//this->m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0f;
|
||||
this->m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f;
|
||||
this->m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0f;
|
||||
this->m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0f;
|
||||
|
||||
//Server code is a bug fix for being able to beat the resupply shoot delay timer.
|
||||
//Only the server tracks resupply time but it has 500ms here to update the client's m_flNextPrimaryAttack. If it's buggy then remove it and the resupply code that adds to primary attack, network the resupply timer, and check it alongside m_flNextPrimaryAttack in AvHBasePlayerWeapon::ProcessValidAttack.
|
||||
#ifdef AVH_SERVER
|
||||
float resupplyTimer = this->GetResupplyTimer();
|
||||
if (resupplyTimer > 0.0f)
|
||||
{
|
||||
this->m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + max(theEndReloadTime,(resupplyTimer * 2.0f));
|
||||
this->m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + max(theEndReloadTime,(resupplyTimer * 2.0f));
|
||||
this->m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + max(theEndReloadTime,(resupplyTimer * 2.0f));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
this->m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + theEndReloadTime;
|
||||
this->m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + theEndReloadTime;
|
||||
this->m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + theEndReloadTime;
|
||||
}
|
||||
|
||||
this->m_pPlayer->SetAnimation(PLAYER_RELOAD_END);
|
||||
this->m_fInSpecialReload = kSpecialReloadNone;
|
||||
|
|
Loading…
Reference in a new issue