Advertisement
Shepard62700FR

TWHL - Abbadon - Server

Jan 31st, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. // weapons.h - In the "private" section of the "CMP5" class
  2.  
  3. void Cooldown( void ); // Shepard : Core of the cool down system
  4.  
  5. float m_flCooldownTime; // Shepard : Time to cool down
  6. int m_iHeat; // Shepard : Amount of heat
  7.  
  8. // player.cpp - At the beginning of the file
  9.  
  10. int gmsgOverheat = 0; // Shepard : Overheat message
  11.  
  12. // player.cpp - In LinkUserMessages method
  13.  
  14. gmsgOverheat = REG_USER_MSG( "Overheat", 1 ); // Shepard : Overheat message
  15.  
  16. // mp5.cpp - After the includes
  17.  
  18. extern int gmsgOverheat; // Shepard : Overheat message
  19.  
  20. // mp5.cpp - End of "CMP5::Spawn"
  21.  
  22. m_iHeat = 0; // Shepard : 0% of heat on weapon spawn
  23.  
  24. // mp5.cpp - Beginning of "PrimaryAttack", "SecondaryAttack", "Reload", "WeaponIdle" of "CMP5"
  25.  
  26. Cooldown(); // Shepard : Cool down our weapon (if we can)
  27.  
  28. // mp5.cpp - "PrimaryAttack" and "SecondaryAttack", after the condition that detect if we are underwater
  29.  
  30. // Shepard : Deny attack if our weapon has overheated
  31. if ( m_iHeat >= 100 )
  32. {
  33.     PlayEmptySound();
  34.     m_flNextSecondaryAttack = 0.15f;
  35.     return;
  36. }
  37.  
  38. // mp5.cpp - At the end of "PrimaryAttack" and "SecondaryAttack"
  39.  
  40. m_flCooldownTime = gpGlobals->time + 3.0f; // Shepard : Wait 3 seconds to start the weapon cool down
  41.  
  42. // mp5.cpp - Between "CMP5::WeaponIdle" and the "CMP5AmmoClip" class
  43.  
  44. // Shepard : Core of the cool down system
  45. void CMP5::Cooldown( void )
  46. {
  47.     // Our weapon is already at 0%, just make sure we don't have negative values
  48.     if ( m_iHeat <= 0 )
  49.     {
  50.         m_iHeat = 0;
  51.         return;
  52.     }
  53.  
  54.     // Perform the real cool down
  55.     while ( m_iHeat > 0 && m_flCooldownTime < gpGlobals->time )
  56.     {
  57.         m_iHeat--; // Remove 1% from heating
  58.         m_flCooldownTime += 0.5f; // Decrease 1% every 0,5 seconds
  59.     }
  60.  
  61. #ifndef CLIENT_DLL
  62.     // Send the new heat value to the client's HUD
  63.     MESSAGE_BEGIN( MSG_ONE, gmsgOverheat, NULL, m_pPlayer->pev );
  64.         WRITE_BYTE( m_iHeat );
  65.     MESSAGE_END();
  66. #endif
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement