Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CMP5::Spawn( )
- {
- // Spawn code here
- m_iHeat = 0; // Shepard : By default our weapon hasn't heated
- }
- void CMP5::PrimaryAttack()
- {
- // Shepard : Cool down our weapon if we can't fire
- Cooldown();
- // Check if firing underwater and gun is empty code here
- // Shepard : deny weapon firing if weapon has overheated
- if ( m_iHeat >= 100 )
- {
- PlayEmptySound();
- m_flNextPrimaryAttack = 0.15f;
- return;
- }
- // Shepard : Increment heating (and prevent to go higher than 100%)
- m_iHeat += 5;
- if ( m_iHeat > 100 )
- m_iHeat = 100;
- // Effects, event, firing, accuracy code here
- #ifndef CLIENT_DLL
- m_flCooldownTime = gpGlobals->time + 3.0f; // Shepard : This forces the player to wait 3 seconds for the weapon to cool down
- #endif
- }
- void CMP5::WeaponIdle( void )
- {
- // Shepard : Cool down the weapon (if we can)
- Cooldown();
- // Idle animation code here
- }
- // Shepard : Cool down the weapon
- void CMP5::Cooldown( void )
- {
- // For debugging purposes, you can remove that and replace by your HUD update code
- #ifndef CLIENT_DLL
- ALERT( at_console, "Heat = %d - Game time = %f - Cool down time = %2f\n", m_iHeat, gpGlobals->time, m_flCooldownTime );
- #endif
- // Disallow negative values
- if ( m_iHeat <= 0 )
- {
- //m_iHeat = 0; // If you decrement by 1%, that line is NOT needed, otherwise you'll need it (you don't want to have -1%)
- return;
- }
- // Perform the real cool down
- while ( m_iHeat > 0 && m_flCooldownTime < gpGlobals->time)
- {
- m_iHeat--;
- m_flCooldownTime += 0.5f;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement