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