Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

368 lines
8.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TF_WHEEL_OF_DOOM_H
  8. #define TF_WHEEL_OF_DOOM_H
  9. #pragma once
  10. #include "GameEventListener.h"
  11. // Client specific.
  12. #ifdef CLIENT_DLL
  13. #define CWheelOfDoom C_WheelOfDoom
  14. #endif
  15. enum eWheelOfDoomEffectSkinIndex
  16. {
  17. EFFECT_WHAMMY = 1,
  18. EFFECT_JUMP_HEIGHT,
  19. EFFECT_SMALL_HEAD,
  20. EFFECT_SPEED,
  21. EFFECT_LOW_GRAVITY,
  22. EFFECT_BIG_HEAD,
  23. EFFECT_UBER,
  24. EFFECT_CRITS,
  25. EFFECT_DANCE,
  26. EFFECT_BASEBALLS,
  27. EFFECT_DECAPITATE,
  28. EFFECT_BARS,
  29. EFFECT_BELLS,
  30. EFFECT_SEVENS,
  31. EFFECT_CHERRIES,
  32. EFFECT_COUNT
  33. };
  34. #ifdef GAME_DLL
  35. class CWheelOfDoomSpiral;
  36. //=============================================================================
  37. //
  38. // Wheel of doom class
  39. //
  40. class CWheelOfDoom : public CBaseAnimating, public CGameEventListener
  41. {
  42. public:
  43. DECLARE_CLASS( CWheelOfDoom, CBaseAnimating );
  44. DECLARE_DATADESC();
  45. CWheelOfDoom( void );
  46. ~CWheelOfDoom( void );
  47. // Initialization
  48. virtual void Spawn( void );
  49. virtual void Precache( void );
  50. // Thinks
  51. void IdleThink( void );
  52. void SpinThink( void );
  53. virtual void FireGameEvent( IGameEvent *gameEvent );
  54. void StartSpin( void );
  55. void Spin( inputdata_t& inputdata );
  56. void ClearAllEffects( inputdata_t& inputdata );
  57. bool IsDoneBoardcastingEffectSound() const;
  58. float GetDuration() const { return m_flDuration; }
  59. void DBG_ApplyEffectByName( const char* pszEffectName );
  60. private:
  61. enum eEffectProperty
  62. {
  63. PROPERTY_WHAMMY,
  64. PROPERTY_DOES_NOT_REAPPLY_ON_SPAWN
  65. };
  66. struct EffectData_t
  67. {
  68. CUtlVector<CTFPlayer*> m_vecPlayers;
  69. CWheelOfDoom* m_pWheel;
  70. };
  71. struct EffectManager;
  72. class WOD_BaseEffect
  73. {
  74. public:
  75. WOD_BaseEffect();
  76. virtual void InitEffect( float flDefaultDuration );
  77. virtual void ActivateEffect( EffectData_t& data ) {};
  78. virtual void UpdateEffect( EffectData_t& data ) {};
  79. virtual void DeactivateEffect( EffectData_t& data ) {};
  80. void SetListFlags( int iFlags );
  81. int GetListFlags() const { return m_iListFlags; }
  82. const char* GetName() { return m_pszName; }
  83. eWheelOfDoomEffectSkinIndex GetSkinIndex() const { return m_nSkin; }
  84. protected:
  85. eWheelOfDoomEffectSkinIndex m_nSkin;
  86. float m_flExpireTime;
  87. const char* m_pszEffectAnnouncementSound;
  88. int m_iListFlags;
  89. const char* m_pszName;
  90. friend struct EffectManager;
  91. };
  92. struct EffectManager
  93. {
  94. public:
  95. explicit EffectManager( CWheelOfDoom* pWheel ) { m_pWheel = pWheel; }
  96. ~EffectManager();
  97. int AddEffect( WOD_BaseEffect* pEffect, float flDefaultDuration );
  98. void ApplyAllEffectsToPlayer( CTFPlayer* pPlayer );
  99. void ClearEffects();
  100. bool UpdateAndClearExpiredEffects();
  101. void Precache();
  102. private:
  103. CWheelOfDoom* m_pWheel;
  104. CUtlVector<WOD_BaseEffect*> m_vecActiveEffects;
  105. } m_EffectManager;
  106. WOD_BaseEffect* GetRandomEffectWithFlags();
  107. void EndSpin();
  108. CUtlVector<WOD_BaseEffect*> m_vecEffects;
  109. void RegisterEffect( WOD_BaseEffect* pEffect, int nFlags = 0 );
  110. static void ApplyAttributeToAllPlayers( const char* pszAttribName, float flValue );
  111. static void ApplyAttributeToPlayer( CTFPlayer* pPlayer, const char* pszAttribName, float flValue );
  112. static void RemoveAttributeFromAllPlayers( const char* pszAttribName );
  113. static void RemoveAttributeFromPlayer( CTFPlayer* pPlayer, const char* pszAttribName );
  114. static void SpeakMagicConceptToAllPlayers( const char* pszEffect );
  115. WOD_BaseEffect* m_pChosenEffect;
  116. CWheelOfDoomSpiral* m_pSpiral;
  117. static const char* GetScreenModelName();
  118. float CalcNextTickTime() const;
  119. float CalcSpinCompletion() const;
  120. void SetSkin( int nSkin );
  121. void SetScale( float flScale );
  122. void PlaySound( const char* pszSound );
  123. bool m_bAnnounced;
  124. bool m_bHasSpiral;
  125. float m_flDuration;
  126. float m_flNextTickTime;
  127. float m_flNextAnnounceTime;
  128. float m_flStopSpinTime;
  129. CUtlVector<CWheelOfDoom*> m_vecOtherWODs;
  130. float m_flFinishBroadcastingEffectTime;
  131. COutputEvent m_EffectApplied;
  132. COutputEvent m_EffectExpired;
  133. //-----------------------------------------------------------------------
  134. // Effects
  135. class WOD_CritsEffect : public WOD_BaseEffect
  136. {
  137. public:
  138. WOD_CritsEffect()
  139. {
  140. m_pszName = "Crits";
  141. m_nSkin = EFFECT_CRITS;
  142. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelCrits";
  143. };
  144. void ActivateEffect( EffectData_t& data );
  145. };
  146. class WOD_UberEffect : public WOD_BaseEffect
  147. {
  148. public:
  149. WOD_UberEffect()
  150. {
  151. m_pszName = "Uber";
  152. m_nSkin = EFFECT_UBER;
  153. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelUber";
  154. };
  155. void InitEffect( float flDefaultExpireTime );
  156. void ActivateEffect( EffectData_t& data );
  157. };
  158. class WOD_SuperSpeedEffect : public WOD_BaseEffect
  159. {
  160. public:
  161. WOD_SuperSpeedEffect()
  162. {
  163. m_pszName = "Super Speed";
  164. m_nSkin = EFFECT_SPEED;
  165. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelSuperSpeed";
  166. };
  167. void ActivateEffect( EffectData_t& data );
  168. void DeactivateEffect( EffectData_t& data );
  169. };
  170. class WOD_SuperJumpEffect : public WOD_BaseEffect
  171. {
  172. public:
  173. WOD_SuperJumpEffect()
  174. {
  175. m_pszName = "Super Jump";
  176. m_nSkin = EFFECT_JUMP_HEIGHT;
  177. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelSuperJump";
  178. }
  179. void ActivateEffect( EffectData_t& data );
  180. void DeactivateEffect( EffectData_t& data );
  181. };
  182. class WOD_BigHeadEffect : public WOD_BaseEffect
  183. {
  184. public:
  185. WOD_BigHeadEffect()
  186. {
  187. m_pszName = "Big Head";
  188. m_nSkin = EFFECT_BIG_HEAD;
  189. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelBigHead";
  190. }
  191. void ActivateEffect( EffectData_t& data );
  192. void DeactivateEffect( EffectData_t& data );
  193. };
  194. class WOD_SmallHeadEffect : public WOD_BaseEffect
  195. {
  196. public:
  197. WOD_SmallHeadEffect()
  198. {
  199. m_pszName = "Small Head";
  200. m_nSkin = EFFECT_SMALL_HEAD;
  201. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelShrunkHead";
  202. }
  203. void ActivateEffect( EffectData_t& data );
  204. void DeactivateEffect( EffectData_t& data );
  205. };
  206. class WOD_LowGravityEffect : public WOD_BaseEffect
  207. {
  208. public:
  209. WOD_LowGravityEffect()
  210. {
  211. m_pszName = "Low Gravity";
  212. m_nSkin = EFFECT_LOW_GRAVITY;
  213. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelGravity";
  214. }
  215. void ActivateEffect( EffectData_t& data );
  216. void DeactivateEffect( EffectData_t& data );
  217. };
  218. class WOD_Pee : public WOD_BaseEffect
  219. {
  220. public:
  221. WOD_Pee()
  222. {
  223. m_pszName = "Pee";
  224. m_nSkin = EFFECT_WHAMMY;
  225. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelJarate";
  226. }
  227. void ActivateEffect( EffectData_t& data );
  228. void UpdateEffect( EffectData_t& data );
  229. private:
  230. float m_flNextPeeTime;
  231. CUtlVector<CBaseEntity*> m_vecClouds;
  232. };
  233. class WOD_Burn : public WOD_BaseEffect
  234. {
  235. public:
  236. WOD_Burn()
  237. {
  238. m_pszName = "Burn";
  239. m_nSkin = EFFECT_WHAMMY;
  240. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelBurn";
  241. }
  242. void InitEffect( float flDefaultDuration );
  243. void ActivateEffect( EffectData_t& data );
  244. };
  245. class WOD_Ghosts : public WOD_BaseEffect
  246. {
  247. public:
  248. WOD_Ghosts()
  249. {
  250. m_pszName = "Ghosts";
  251. m_nSkin = EFFECT_WHAMMY;
  252. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelGhosts";
  253. }
  254. void ActivateEffect( EffectData_t& data );
  255. void DeactivateEffect( EffectData_t& data );
  256. };
  257. class WOD_Dance : public WOD_BaseEffect
  258. {
  259. public:
  260. WOD_Dance()
  261. {
  262. m_pszName = "Dance";
  263. m_nSkin = EFFECT_DANCE;
  264. m_pszEffectAnnouncementSound = "Halloween.MerasmusWheelDance";
  265. m_flNextDanceTime = 0.f;
  266. }
  267. void InitEffect( float flExpireTime );
  268. void UpdateEffect( EffectData_t& data );
  269. void DeactivateEffect( EffectData_t& data );
  270. private:
  271. int GetNumOFTeamDancing( int nTeam ) const;
  272. void SlamPosAndAngles( CTFPlayer* pPlayer, const Vector& vPos, const QAngle& vAng );
  273. struct Dancer_t
  274. {
  275. Vector m_vecPos;
  276. QAngle m_vecAngles;
  277. CHandle<CTFPlayer> m_hPlayer;
  278. };
  279. CUtlVector<Dancer_t*> m_vecDancers;
  280. struct MerasmusCreateInfo_t
  281. {
  282. MerasmusCreateInfo_t( const Vector& p, const QAngle& ang ) : m_vecPos( p ), m_vecAngles( ang ) {}
  283. Vector m_vecPos;
  284. QAngle m_vecAngles;
  285. };
  286. CUtlVector< MerasmusCreateInfo_t > m_vecMerasmusDancerCreateInfos;
  287. int m_iCurrentMerasmusCreateInfo;
  288. CHandle<CMerasmusDancer> m_hMerasmusDancer;
  289. float m_flNextDanceTime;
  290. };
  291. };
  292. #endif // GAME_DLL
  293. #endif // TF_WHEEL_OF_DOOM_H