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.

224 lines
6.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #ifndef TF_WEAPON_SPELLBOOK_H
  7. #define TF_WEAPON_SPELLBOOK_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "GameEventListener.h"
  12. #include "tf_weapon_jar.h"
  13. #include "tf_weapon_throwable.h"
  14. #include "tf_shareddefs.h"
  15. #include "tf_viewmodel.h"
  16. #include "econ_item_view.h"
  17. #ifdef CLIENT_DLL
  18. #include <vgui_controls/EditablePanel.h>
  19. #include "hudelement.h"
  20. #include "econ_controls.h"
  21. #include "c_tf_projectile_rocket.h"
  22. #include "econ_notifications.h"
  23. #include "vgui_controls/ImagePanel.h"
  24. #define CTFSpellBook C_TFSpellBook
  25. #define CTFProjectile_SpellFireball C_TFProjectile_SpellFireball
  26. #define CTFProjectile_SpellBats C_TFProjectile_SpellBats
  27. #define CTFProjectile_SpellSpawnZombie C_TFProjectile_SpellSpawnZombie
  28. #define CTFProjectile_SpellSpawnHorde C_TFProjectile_SpellSpawnHorde
  29. #define CTFProjectile_SpellMirv C_TFProjectile_SpellMirv
  30. #define CTFProjectile_SpellPumpkin C_TFProjectile_SpellPumpkin
  31. #define CTFProjectile_SpellSpawnBoss C_TFProjectile_SpellSpawnBoss
  32. #define CTFProjectile_SpellMeteorShower C_TFProjectile_SpellMeteorShower
  33. #define CTFProjectile_SpellTransposeTeleport C_TFProjectile_SpellTransposeTeleport
  34. #define CTFProjectile_SpellLightningOrb C_TFProjectile_SpellLightningOrb
  35. #define CTFProjectile_SpellVortex C_TFProjectile_SpellVortex
  36. #define CTFProjectile_SpellKartOrb C_TFProjectile_SpellKartOrb
  37. #define CTFProjectile_SpellKartBats C_TFProjectile_SpellKartBats
  38. #define CTFProjectile_SpellKartMirv C_TFProjectile_SpellKartMirv
  39. #define CTFProjectile_SpellKartPumpkin C_TFProjectile_SpellKartPumpkin
  40. #else
  41. #include "tf_projectile_rocket.h"
  42. #endif
  43. #ifdef CLIENT_DLL
  44. // For testing, hijack this basic menu but replace it later with TF specific UI
  45. class CHudSpellMenu : public CHudElement, public vgui::EditablePanel
  46. {
  47. DECLARE_CLASS_SIMPLE( CHudSpellMenu, EditablePanel );
  48. public:
  49. CHudSpellMenu( const char *pElementName );
  50. virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
  51. virtual bool ShouldDraw( void );
  52. virtual void FireGameEvent( IGameEvent *event ) OVERRIDE;
  53. virtual void OnTick( void ) OVERRIDE;
  54. void UpdateSpellText( int iSpellIndex, int iCharges );
  55. private:
  56. vgui::ImagePanel *m_pSpellIcon;
  57. CExLabel *m_pKeyBinding;
  58. int m_iPrevSelectedSpell;
  59. float m_iNextRollTime;
  60. float m_flRollTickGap;
  61. bool m_bTickSoundA;
  62. bool m_bKillstreakMeterDrawing;
  63. };
  64. //=============================================================================
  65. class CEquipSpellbookNotification : public CEconNotification
  66. {
  67. public:
  68. CEquipSpellbookNotification() : CEconNotification()
  69. {
  70. m_bHasTriggered = false;
  71. }
  72. ~CEquipSpellbookNotification()
  73. {
  74. if ( !m_bHasTriggered )
  75. {
  76. m_bHasTriggered = true;
  77. }
  78. }
  79. virtual void MarkForDeletion()
  80. {
  81. m_bHasTriggered = true;
  82. CEconNotification::MarkForDeletion();
  83. }
  84. virtual EType NotificationType() { return eType_AcceptDecline; }
  85. virtual bool BShowInGameElements() const { return true; }
  86. virtual void Accept();
  87. virtual void Trigger() { Accept(); }
  88. virtual void Decline() { MarkForDeletion(); }
  89. virtual void UpdateTick();
  90. static bool IsNotificationType( CEconNotification *pNotification ) { return dynamic_cast< CEquipSpellbookNotification *>( pNotification ) != NULL; }
  91. private:
  92. bool m_bHasTriggered;
  93. };
  94. #endif // CLIENT_DLL
  95. #ifdef GAME_DLL
  96. void RemoveAll2013HalloweenTeleportSpellsInMidFlight( void );
  97. #endif
  98. //=============================================================================
  99. //
  100. // CTFSpellBook class.
  101. //
  102. class CTFSpellBook : public CTFThrowable
  103. {
  104. public:
  105. DECLARE_CLASS( CTFSpellBook, CTFThrowable );
  106. DECLARE_NETWORKCLASS();
  107. DECLARE_PREDICTABLE();
  108. CTFSpellBook();
  109. virtual int GetWeaponID( void ) const { return TF_WEAPON_SPELLBOOK; }
  110. virtual const char* GetEffectLabelText( void ) { return "#TF_KART"; }
  111. virtual void Precache( void );
  112. virtual void PrimaryAttack();
  113. virtual void ItemPostFrame( void );
  114. virtual void ItemBusyFrame( void );
  115. virtual void ItemHolsterFrame( void );
  116. virtual bool ShowHudElement () { return false; }
  117. virtual bool VisibleInWeaponSelection( void ) { return false; }
  118. virtual bool CanBeSelected( void ) { return false; }
  119. bool HasASpellWithCharges();
  120. virtual CBaseEntity *FireJar( CTFPlayer *pPlayer ) OVERRIDE;
  121. bool CanCastSpell( CTFPlayer *pPlayer );
  122. void PaySpellCost( CTFPlayer *pPlayer );
  123. void ClearSpell();
  124. // Hack for infinite ammo
  125. virtual bool IsEnergyWeapon( void ) const { return true; }
  126. float Energy_GetMaxEnergy( void ) const { return 500; }
  127. float Energy_GetEnergy( void ) const { return 500; }
  128. bool Energy_FullyCharged( void ) const { return true; }
  129. bool Energy_HasEnergy( void ) { return true; }
  130. #ifdef GAME_DLL
  131. void SaveLastWeapon( CBaseCombatWeapon *pWpn ) { m_pStoredLastWpn = pWpn; }
  132. // Projectile Creation
  133. virtual void TossJarThink( void );
  134. virtual void CreateSpellRocket( const Vector &position, const QAngle &angles, const Vector &velocity,
  135. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo );
  136. virtual void CreateSpellJar( const Vector &position, const QAngle &angles, const Vector &velocity,
  137. const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo );
  138. // Spell Helpers
  139. // Think
  140. void RollNewSpell( int iTier, bool bForceReroll = false );
  141. void SetSelectedSpell( int index );
  142. void SpeakSpellConceptIfAllowed();
  143. // Spells
  144. void CastKartSpell();
  145. bool CastSpell( CTFPlayer *pPlayer, int iSpellIndex );
  146. CHandle<CBaseCombatWeapon> m_pStoredLastWpn;
  147. void RollNewSpellFinish( void );
  148. int m_iNextSpell;
  149. int m_iPreviouslyCastSpell;
  150. #endif
  151. virtual bool CanThrowUnderWater( void ){ return true; }
  152. #ifdef CLIENT_DLL
  153. float m_flTimeNextErrorSound;
  154. EHANDLE m_hHandEffectWeapon;
  155. HPARTICLEFFECT m_hHandEffect;
  156. #endif // CLIENT_DLL
  157. // Self Cast Spells
  158. static bool CastSelfHeal( CTFPlayer *pPlayer );
  159. static bool CastRocketJump( CTFPlayer *pPlayer );
  160. static bool CastSelfSpeedBoost( CTFPlayer *pPlayer );
  161. static bool CastSelfStealth( CTFPlayer *pPlayer );
  162. static bool CastKartRocketJump( CTFPlayer *pPlayer );
  163. static bool CastKartUber( CTFPlayer *pPlayer );
  164. static bool CastKartBombHead( CTFPlayer *pPlayer );
  165. static const char* GetHandEffect( CEconItemView *pItem, int iTier );
  166. CNetworkVar( float, m_flTimeNextSpell );
  167. CNetworkVar( int, m_iSelectedSpellIndex );
  168. CNetworkVar( int, m_iSpellCharges );
  169. CNetworkVar( bool, m_bFiredAttack );
  170. };
  171. #ifdef GAME_DLL
  172. CBaseEntity* CreateSpellSpawnZombie( CBaseCombatCharacter *pCaster, const Vector& vSpawnPosition, int nSkeletonType );
  173. #endif
  174. #endif // TF_WEAPON_SPELLBOOK_H