Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // weapons.h - In the "private" section of the "CMP5" class
- void Cooldown( void ); // Shepard : Core of the cool down system
- float m_flCooldownTime; // Shepard : Time to cool down
- int m_iHeat; // Shepard : Amount of heat
- // player.cpp - At the beginning of the file
- int gmsgOverheat = 0; // Shepard : Overheat message
- // player.cpp - In LinkUserMessages method
- gmsgOverheat = REG_USER_MSG( "Overheat", 1 ); // Shepard : Overheat message
- // mp5.cpp - After the includes
- extern int gmsgOverheat; // Shepard : Overheat message
- // mp5.cpp - End of "CMP5::Spawn"
- m_iHeat = 0; // Shepard : 0% of heat on weapon spawn
- // mp5.cpp - Beginning of "PrimaryAttack", "SecondaryAttack", "Reload", "WeaponIdle" of "CMP5"
- Cooldown(); // Shepard : Cool down our weapon (if we can)
- // mp5.cpp - "PrimaryAttack" and "SecondaryAttack", after the condition that detect if we are underwater
- // Shepard : Deny attack if our weapon has overheated
- if ( m_iHeat >= 100 )
- {
- PlayEmptySound();
- m_flNextSecondaryAttack = 0.15f;
- return;
- }
- // mp5.cpp - At the end of "PrimaryAttack" and "SecondaryAttack"
- m_flCooldownTime = gpGlobals->time + 3.0f; // Shepard : Wait 3 seconds to start the weapon cool down
- // mp5.cpp - Between "CMP5::WeaponIdle" and the "CMP5AmmoClip" class
- // Shepard : Core of the cool down system
- void CMP5::Cooldown( void )
- {
- // Our weapon is already at 0%, just make sure we don't have negative values
- if ( m_iHeat <= 0 )
- {
- m_iHeat = 0;
- return;
- }
- // Perform the real cool down
- while ( m_iHeat > 0 && m_flCooldownTime < gpGlobals->time )
- {
- m_iHeat--; // Remove 1% from heating
- m_flCooldownTime += 0.5f; // Decrease 1% every 0,5 seconds
- }
- #ifndef CLIENT_DLL
- // Send the new heat value to the client's HUD
- MESSAGE_BEGIN( MSG_ONE, gmsgOverheat, NULL, m_pPlayer->pev );
- WRITE_BYTE( m_iHeat );
- MESSAGE_END();
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement