This repository has been archived by the owner on May 4, 2022. It is now read-only.
forked from FWGS/hlsdk-portable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
effects.h
328 lines (274 loc) · 7.24 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
/***
*
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
*
* This product contains software technology licensed from Id
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
* All Rights Reserved.
*
* Use, distribution, and modification of this source code and/or resulting
* object code is restricted to non-commercial enhancements to products from
* Valve LLC. All other use, distribution, or modification is prohibited
* without written permission from Valve LLC.
*
****/
#pragma once
#ifndef EFFECTS_H
#define EFFECTS_H
#define SF_BEAM_STARTON 0x0001
#define SF_BEAM_TOGGLE 0x0002
#define SF_BEAM_RANDOM 0x0004
#define SF_BEAM_RING 0x0008
#define SF_BEAM_SPARKSTART 0x0010
#define SF_BEAM_SPARKEND 0x0020
#define SF_BEAM_DECALS 0x0040
#define SF_BEAM_SHADEIN 0x0080
#define SF_BEAM_SHADEOUT 0x0100
#define SF_BEAM_TEMPORARY 0x8000
#define SF_SPRITE_STARTON 0x0001
#define SF_SPRITE_ONCE 0x0002
#define SF_SPRITE_TEMPORARY 0x8000
class CSprite : public CPointEntity
{
public:
void Spawn( void );
void Precache( void );
int ObjectCaps( void )
{
int flags = 0;
if( pev->spawnflags & SF_SPRITE_TEMPORARY )
flags = FCAP_DONT_SAVE;
return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | flags;
}
void EXPORT AnimateThink( void );
void EXPORT ExpandThink( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
void Animate( float frames );
void Expand( float scaleSpeed, float fadeSpeed );
void SpriteInit( const char *pSpriteName, const Vector &origin );
inline 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 );
void TurnOn( void );
inline float Frames( void )
{
return m_maxFrame;
}
inline 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;
}
inline void SetTexture( int spriteIndex )
{
pev->modelindex = spriteIndex;
}
inline void SetScale( float scale )
{
pev->scale = scale;
}
inline void SetColor( int r, int g, int b )
{
pev->rendercolor.x = r;
pev->rendercolor.y = g;
pev->rendercolor.z = b;
}
inline void SetBrightness( int brightness )
{
pev->renderamt = brightness;
}
inline void AnimateAndDie( float framerate )
{
SetThink( &CSprite::AnimateUntilDead );
pev->framerate = framerate;
pev->dmgtime = gpGlobals->time + ( m_maxFrame / framerate );
pev->nextthink = gpGlobals->time;
}
void EXPORT AnimateUntilDead( void );
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
static CSprite *SpriteCreate( const char *pSpriteName, const Vector &origin, BOOL animate );
private:
float m_lastTime;
float m_maxFrame;
};
class CBeam : public CBaseEntity
{
public:
void Spawn( void );
void Precache( void );
int ObjectCaps( void )
{
int flags = 0;
if( pev->spawnflags & SF_BEAM_TEMPORARY )
flags = FCAP_DONT_SAVE;
return ( CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | flags;
}
void EXPORT TriggerTouch( CBaseEntity *pOther );
// These functions are here to show the way beams are encoded as entities.
// Encoding beams as entities simplifies their management in the client/server architecture
inline void SetType( int type )
{
pev->rendermode = ( pev->rendermode & 0xF0 ) | ( type & 0x0F );
}
inline void SetFlags( int flags )
{
pev->rendermode = ( pev->rendermode & 0x0F ) | ( flags & 0xF0 );
}
inline void SetStartPos( const Vector& pos )
{
pev->origin = pos;
}
inline void SetEndPos( const Vector& pos )
{
pev->angles = pos;
}
void SetStartEntity( int entityIndex );
void SetEndEntity( int entityIndex );
inline void SetStartAttachment( int attachment )
{
pev->sequence = ( pev->sequence & 0x0FFF ) | ( ( attachment & 0xF ) << 12 );
}
inline void SetEndAttachment( int attachment )
{
pev->skin = ( pev->skin & 0x0FFF ) | ( ( attachment & 0xF ) << 12 );
}
inline void SetTexture( int spriteIndex )
{
pev->modelindex = spriteIndex;
}
inline void SetWidth( int width )
{
pev->scale = width;
}
inline void SetNoise( int amplitude )
{
pev->body = amplitude;
}
inline void SetColor( int r, int g, int b )
{
pev->rendercolor.x = r;
pev->rendercolor.y = g;
pev->rendercolor.z = b;
}
inline void SetBrightness( int brightness )
{
pev->renderamt = brightness;
}
inline void SetFrame( float frame )
{
pev->frame = frame;
}
inline void SetScrollRate( int speed )
{
pev->animtime = speed;
}
inline int GetType( void )
{
return pev->rendermode & 0x0F;
}
inline int GetFlags( void )
{
return pev->rendermode & 0xF0;
}
inline int GetStartEntity( void )
{
return pev->sequence & 0xFFF;
}
inline int GetEndEntity( void )
{
return pev->skin & 0xFFF;
}
const Vector &GetStartPos( void );
const Vector &GetEndPos( void );
Vector Center( void ) { return (GetStartPos() + GetEndPos()) * 0.5; }; // center point of beam
inline int GetTexture( void )
{
return pev->modelindex;
}
inline int GetWidth( void )
{
return (int)pev->scale;
}
inline int GetNoise( void )
{
return pev->body;
}
/* inline void GetColor( int r, int g, int b )
{
pev->rendercolor.x = r;
pev->rendercolor.y = g;
pev->rendercolor.z = b;
}*/
inline int GetBrightness( void )
{
return (int)pev->renderamt;
}
inline int GetFrame( void )
{
return (int)pev->frame;
}
inline int GetScrollRate( void )
{
return (int)pev->animtime;
}
// Call after you change start/end positions
void RelinkBeam( void );
//void SetObjectCollisionBox( void );
void DoSparks( const Vector &start, const Vector &end );
CBaseEntity *RandomTargetname( const char *szName );
void BeamDamage( TraceResult *ptr );
// Init after BeamCreate()
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 );
inline void LiveForTime( float time )
{
SetThink( &CBaseEntity::SUB_Remove );
pev->nextthink = gpGlobals->time + time;
}
inline void BeamDamageInstant( TraceResult *ptr, float damage )
{
pev->dmg = damage;
pev->dmgtime = gpGlobals->time - 1;
BeamDamage( ptr );
}
};
#define SF_MESSAGE_ONCE 0x0001 // Fade in, not out
#define SF_MESSAGE_ALL 0x0002 // Send to all clients
class CLaser : public CBeam
{
public:
void Spawn( void );
void Precache( void );
void KeyValue( KeyValueData *pkvd );
void TurnOn( void );
void TurnOff( void );
int IsOn( void );
void FireAtPoint( TraceResult &point );
void EXPORT StrikeThink( void );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
virtual int Save( CSave &save );
virtual int Restore( CRestore &restore );
static TYPEDESCRIPTION m_SaveData[];
CSprite *m_pSprite;
string_t m_iszSpriteName;
Vector m_firePosition;
};
#endif //EFFECTS_H