Skip to content

Commit

Permalink
Fixed func_tanklaser to stop its laser if player go away or die when …
Browse files Browse the repository at this point in the history
…fire from tank.
  • Loading branch information
LevShisterov committed Jul 7, 2013
1 parent 6ade46a commit fd29683
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion dlls/func_tank.cpp
Expand Up @@ -93,6 +93,7 @@ class CFuncTank : public CBaseEntity
BOOL StartControl( CBasePlayer* pController );
void StopControl( void );
void ControllerPostFrame( void );
virtual void StopFire(void) { }


protected:
Expand Down Expand Up @@ -373,6 +374,8 @@ BOOL CFuncTank :: StartControl( CBasePlayer *pController )

void CFuncTank :: StopControl()
{
StopFire();

// TODO: bring back the controllers current weapon
if ( !m_pController )
return;
Expand Down Expand Up @@ -409,7 +412,7 @@ void CFuncTank :: ControllerPostFrame( void )
m_fireLast = gpGlobals->time - (1/m_fireRate) - 0.01; // to make sure the gun doesn't fire too many bullets

Fire( BarrelPosition(), vecForward, m_pController->pev );

// HACKHACK -- make some noise (that the AI can hear)
if ( m_pController && m_pController->IsPlayer() )
((CBasePlayer *)m_pController)->m_iWeaponVolume = LOUD_GUN_VOLUME;
Expand Down Expand Up @@ -776,6 +779,8 @@ class CFuncTankLaser : public CFuncTank
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];

virtual void StopFire(void);

private:
CLaser *m_pLaser;
float m_laserTime;
Expand Down Expand Up @@ -882,6 +887,13 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva
}
}

void CFuncTankLaser::StopFire(void)
{
if (m_pLaser)
m_pLaser->TurnOff();
}


class CFuncTankRocket : public CFuncTank
{
public:
Expand Down

0 comments on commit fd29683

Please sign in to comment.