-
Notifications
You must be signed in to change notification settings - Fork 194
/
effects.h
506 lines (420 loc) · 13.9 KB
/
effects.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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
#define SF_SPRITE_STARTON BIT(0)
#define SF_SPRITE_ONCE BIT(1)
#define SF_SPRITE_TEMPORARY BIT(15)
class CSprite: public CPointEntity
{
public:
virtual void Spawn();
virtual void Precache();
virtual void Restart();
virtual int Save(CSave &save);
virtual int Restore(CRestore &restore);
virtual int ObjectCaps()
{
int flags = 0;
if (pev->spawnflags & SF_SPRITE_TEMPORARY)
flags = FCAP_DONT_SAVE;
return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
}
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public:
void EXPORT AnimateThink();
void EXPORT ExpandThink();
void Animate(float frames);
void Expand(float scaleSpeed, float fadeSpeed);
void SpriteInit(const char *pSpriteName, const Vector &origin);
void SetAttachment(edict_t *pEntity, int attachment)
{
if (pEntity)
{
pev->skin = ENTINDEX(pEntity);
pev->body = attachment;
pev->aiment = pEntity;
pev->movetype = MOVETYPE_FOLLOW;
}
}
void TurnOff();
void TurnOn();
float Frames() const { return m_maxFrame; }
void SetTransparency(int rendermode, int r, int g, int b, int a, int fx)
{
pev->rendermode = rendermode;
pev->rendercolor.x = r;
pev->rendercolor.y = g;
pev->rendercolor.z = b;
pev->renderamt = a;
pev->renderfx = fx;
}
void SetTexture(int spriteIndex) { pev->modelindex = spriteIndex; }
void SetScale(float scale) { pev->scale = scale; }
void SetColor(int r, int g, int b) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
void SetBrightness(int brightness) { pev->renderamt = brightness; }
void AnimateAndDie(real_t framerate)
{
SetThink(&CSprite::AnimateUntilDead);
pev->framerate = framerate;
pev->dmgtime = gpGlobals->time + (m_maxFrame / framerate);
pev->nextthink = gpGlobals->time;
}
void EXPORT AnimateUntilDead();
static CSprite *SpriteCreate(const char *pSpriteName, const Vector &origin, BOOL animate);
static TYPEDESCRIPTION m_SaveData[];
private:
float m_lastTime;
float m_maxFrame;
};
#define SF_BEAM_STARTON BIT(0)
#define SF_BEAM_TOGGLE BIT(1)
#define SF_BEAM_RANDOM BIT(2)
#define SF_BEAM_RING BIT(3)
#define SF_BEAM_SPARKSTART BIT(4)
#define SF_BEAM_SPARKEND BIT(5)
#define SF_BEAM_DECALS BIT(6)
#define SF_BEAM_SHADEIN BIT(7)
#define SF_BEAM_SHADEOUT BIT(8)
#define SF_BEAM_TEMPORARY BIT(15)
class CBeam: public CBaseEntity
{
public:
virtual void Spawn();
virtual void Precache();
virtual int ObjectCaps()
{
int flags = 0;
if (pev->spawnflags & SF_BEAM_TEMPORARY)
flags = FCAP_DONT_SAVE;
return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | flags;
}
virtual Vector Center() { return (GetStartPos() + GetEndPos()) * 0.5f; }
public:
void EXPORT TriggerTouch(CBaseEntity *pOther);
void SetType(int type) { pev->rendermode = (pev->rendermode & 0xF0) | (type & 0x0F); }
void SetFlags(int flags) { pev->rendermode = (pev->rendermode & 0x0F) | (flags & 0xF0); }
void SetStartPos(const Vector &pos) { pev->origin = pos; }
void SetEndPos(const Vector &pos) { pev->angles = pos; }
void SetStartEntity(int entityIndex);
void SetEndEntity(int entityIndex);
void SetStartAttachment(int attachment) { pev->sequence = (pev->sequence & 0x0FFF) | ((attachment & 0xF) << 12); }
void SetEndAttachment(int attachment) { pev->skin = (pev->skin & 0x0FFF) | ((attachment & 0xF) << 12); }
void SetTexture(int spriteIndex) { pev->modelindex = spriteIndex; }
void SetWidth(int width) { pev->scale = width; }
void SetNoise(int amplitude) { pev->body = amplitude; }
void SetColor(int r, int g, int b) { pev->rendercolor.x = r; pev->rendercolor.y = g; pev->rendercolor.z = b; }
void SetBrightness(int brightness) { pev->renderamt = brightness; }
void SetFrame(float frame) { pev->frame = frame; }
void SetScrollRate(int speed) { pev->animtime = speed; }
int GetType() const { return pev->rendermode & 0x0F; }
int GetFlags() const { return pev->rendermode & 0xF0; }
int GetStartEntity() const { return pev->sequence & 0xFFF; }
int GetEndEntity() const { return pev->skin & 0xFFF; }
const Vector &GetStartPos();
const Vector &GetEndPos();
int GetTexture() const { return pev->modelindex; }
int GetWidth() const { return pev->scale; }
int GetNoise() const { return pev->body; }
int GetBrightness() const { return pev->renderamt; }
int GetFrame() const { return pev->frame; }
int GetScrollRate() const { return pev->animtime; }
void RelinkBeam();
void DoSparks(const Vector &start, const Vector &end);
CBaseEntity *RandomTargetname(const char *szName);
void BeamDamage(TraceResult *ptr);
void BeamInit(const char *pSpriteName, int width);
void PointsInit(const Vector &start, const Vector &end);
void PointEntInit(const Vector &start, int endIndex);
void EntsInit(int startIndex, int endIndex);
void HoseInit(const Vector &start, const Vector &direction);
static CBeam *BeamCreate(const char *pSpriteName, int width);
void LiveForTime(float time)
{
SetThink(&CBeam::SUB_Remove);
pev->nextthink = gpGlobals->time + time;
}
void BeamDamageInstant(TraceResult *ptr, float damage)
{
pev->dmg = damage;
pev->dmgtime = gpGlobals->time - 1;
BeamDamage(ptr);
}
};
class CLaser: public CBeam
{
public:
virtual void Spawn();
virtual void Precache();
virtual void KeyValue(KeyValueData *pkvd);
virtual int Save(CSave &save);
virtual int Restore(CRestore &restore);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
#ifdef REGAMEDLL_FIXES
virtual void Restart();
#endif
public:
void TurnOn();
void TurnOff();
int IsOn();
void FireAtPoint(TraceResult &point);
void EXPORT StrikeThink();
public:
static TYPEDESCRIPTION m_SaveData[];
CSprite *m_pSprite;
string_t m_iszSpriteName;
Vector m_firePosition;
};
#define SF_BUBBLES_STARTOFF BIT(0)
class CBubbling: public CBaseEntity
{
public:
virtual void Spawn();
virtual void Precache();
virtual void KeyValue(KeyValueData *pkvd);
virtual int Save(CSave &save);
virtual int Restore(CRestore &restore);
virtual int ObjectCaps() { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION); }
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public:
void EXPORT FizzThink();
public:
static TYPEDESCRIPTION m_SaveData[];
int m_density;
int m_frequency;
int m_bubbleModel;
int m_state;
};
class CLightning: public CBeam
{
public:
virtual void Spawn();
virtual void Precache();
virtual void KeyValue(KeyValueData *pkvd);
virtual int Save(CSave &save);
virtual int Restore(CRestore &restore);
virtual void Activate();
#ifdef REGAMEDLL_FIXES
virtual void Restart();
#endif
public:
void EXPORT StrikeThink();
void EXPORT DamageThink();
void RandomArea();
void RandomPoint(Vector &vecSrc);
void Zap(const Vector &vecSrc, const Vector &vecDest);
void EXPORT StrikeUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
void EXPORT ToggleUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
inline BOOL ServerSide() const
{
if (!m_life && !(pev->spawnflags & SF_BEAM_RING))
return TRUE;
return FALSE;
}
void BeamUpdateVars();
public:
static TYPEDESCRIPTION m_SaveData[];
BOOL m_active;
int m_iszStartEntity;
int m_iszEndEntity;
float m_life;
int m_boltWidth;
int m_noiseAmplitude;
int m_brightness;
int m_speed;
float m_restrike;
int m_spriteTexture;
int m_iszSpriteName;
int m_frameStart;
float m_radius;
};
class CGlow: public CPointEntity
{
public:
virtual void Spawn();
virtual int Save(CSave &save);
virtual int Restore(CRestore &restore);
virtual void Think();
void Animate(float frames);
public:
static TYPEDESCRIPTION m_SaveData[];
float m_lastTime;
float m_maxFrame;
};
class CBombGlow: public CSprite
{
public:
virtual void Spawn();
virtual void Think();
public:
float m_lastTime;
float m_tmBeepPeriod;
bool m_bSetModel;
};
#define SF_GIBSHOOTER_REPEATABLE BIT(0) // Allows a gibshooter to be refired
class CGibShooter: public CBaseDelay
{
public:
virtual void Spawn();
virtual void Precache();
virtual void KeyValue(KeyValueData *pkvd);
virtual int Save(CSave &save);
virtual int Restore(CRestore &restore);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
virtual CGib *CreateGib();
public:
void EXPORT ShootThink();
public:
static TYPEDESCRIPTION m_SaveData[];
int m_iGibs;
int m_iGibCapacity;
int m_iGibMaterial;
int m_iGibModelIndex;
float m_flGibVelocity;
float m_flVariance;
float m_flGibLife;
};
class CEnvShooter: public CGibShooter
{
public:
virtual void Precache();
virtual void KeyValue(KeyValueData *pkvd);
virtual CGib *CreateGib();
};
const int MAX_BEAM = 24;
class CTestEffect: public CBaseDelay
{
public:
virtual void Spawn();
virtual void Precache();
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public:
void EXPORT TestThink();
public:
int m_iLoop;
int m_iBeam;
CBeam *m_pBeam[MAX_BEAM];
float m_flBeamTime[MAX_BEAM];
float m_flStartTime;
};
#define SF_BLOOD_RANDOM BIT(0)
#define SF_BLOOD_STREAM BIT(1)
#define SF_BLOOD_PLAYER BIT(2)
#define SF_BLOOD_DECAL BIT(3)
class CBlood: public CPointEntity
{
public:
virtual void Spawn();
virtual void KeyValue(KeyValueData *pkvd);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public:
int Color() const { return pev->impulse; }
float BloodAmount() const { return pev->dmg; }
void SetColor(int color) { pev->impulse = color; }
void SetBloodAmount(float amount) { pev->dmg = amount; }
public:
Vector Direction();
Vector BloodPosition(CBaseEntity *pActivator);
};
#define SF_SHAKE_EVERYONE BIT(0) // Don't check radius
#define SF_SHAKE_DISRUPT BIT(1) // Disrupt controls
#define SF_SHAKE_INAIR BIT(2) // Shake players in air
class CShake: public CPointEntity
{
public:
virtual void Spawn();
virtual void KeyValue(KeyValueData *pkvd);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public:
float Amplitude() const { return pev->scale; }
float Frequency() const { return pev->dmg_save; }
float Duration() const { return pev->dmg_take; }
float Radius() const { return pev->dmg; }
void SetAmplitude(float amplitude) { pev->scale = amplitude; }
void SetFrequency(float frequency) { pev->dmg_save = frequency; }
void SetDuration(float duration) { pev->dmg_take = duration; }
void SetRadius(float radius) { pev->dmg = radius; }
};
#define SF_FADE_IN BIT(0) // Fade in, not out
#define SF_FADE_MODULATE BIT(1) // Modulate, don't blend
#define SF_FADE_ONLYONE BIT(2)
class CFade: public CPointEntity
{
public:
virtual void Spawn();
virtual void KeyValue(KeyValueData *pkvd);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public:
float Duration() const { return pev->dmg_take; }
float HoldTime() const { return pev->dmg_save; }
void SetDuration(float duration) { pev->dmg_take = duration; }
void SetHoldTime(float hold) { pev->dmg_save = hold; }
};
#define SF_MESSAGE_ONCE BIT(0) // Fade in, not out
#define SF_MESSAGE_ALL BIT(1) // Send to all clients
class CMessage: public CPointEntity
{
public:
virtual void Spawn();
virtual void Precache();
virtual void KeyValue(KeyValueData *pkvd);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
};
#define SF_FUNNEL_REVERSE BIT(0) // Funnel effect repels particles instead of attracting them
class CEnvFunnel: public CBaseDelay
{
public:
virtual void Spawn();
virtual void Precache();
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public:
int m_iSprite;
};
class CEnvBeverage: public CBaseDelay
{
public:
virtual void Spawn();
virtual void Precache();
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
};
class CItemSoda: public CBaseEntity
{
public:
virtual void Spawn();
virtual void Precache();
public:
void EXPORT CanThink();
void EXPORT CanTouch(CBaseEntity *pOther);
};
// Multiplayer intermission spots.
class CInfoIntermission: public CPointEntity
{
public:
virtual void Spawn();
virtual void Think();
};
int IsPointEntity(CBaseEntity *pEnt);