summaryrefslogtreecommitdiff
path: root/game/client/hl1/hl1_fx_gauss.cpp
blob: 0a9c28c53e8c29c85b168096a9553e568fd617a1 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//


#include "cbase.h"
#include "fx.h"
#include "c_te_effect_dispatch.h"
#include "c_te_legacytempents.h"
#include "tempent.h"
#include "c_te_basebeam.h"
#include "iviewrender_beams.h"
#include "c_baseplayer.h"
#include "beam_shared.h"


#define GAUSS_GLOW_SPRITE	"sprites/hotglow.vmt"
#define GAUSS_BEAM_SPRITE	"sprites/smoke.vmt"


int	m_nGlowIndex;
int	m_nBeamIndex;


void PrecacheGaussEffects(void *pUser)
{
	m_nGlowIndex = modelinfo->GetModelIndex( GAUSS_GLOW_SPRITE );
	m_nBeamIndex = modelinfo->GetModelIndex( GAUSS_BEAM_SPRITE );
}
PRECACHE_REGISTER_FN(PrecacheGaussEffects);


void HL1GaussBeam( const CEffectData &data )
{
	// beam expects ent + attach to be encoded in the entity index (legacy system)
	int		nStartEntity	= data.entindex() | ((1 & 0xF)<<12);

	C_BaseEntity * pEnt = cl_entitylist->GetEnt( BEAMENT_ENTITY(nStartEntity) );

	if ( !pEnt->IsPlayer() )
		return;

	C_BasePlayer * pPlayer = static_cast<C_BasePlayer*>(pEnt);
	int nStartAttachment = -1;

	if ( pPlayer->IsLocalPlayer() )
	{
		nStartEntity = pPlayer->GetViewModel()->entindex();
	}
	else
	{
		if ( !pPlayer->GetActiveWeapon() )		// TODO : make sure we have the gauss gun
			return;

		nStartEntity = pPlayer->GetActiveWeapon()->entindex();
		nStartAttachment = 2;
	}

	nStartEntity |= ((1 & 0xF)<<12);

	Vector	vecEndPoint		= data.m_vOrigin;
	bool	fIsPrimaryFire	= data.m_fFlags;
	float	flStartWidth;
	float	flEndWidth;
	color32	beamColor;

	if ( fIsPrimaryFire )	// primary attack
	{
		flStartWidth	= 1.0;
		flEndWidth		= 1.0;

		beamColor.r		= 255;
		beamColor.g		= 255;
		beamColor.b		= 0;
		beamColor.a		= 255;
	}
	else					// secondary
	{
		flStartWidth	= 2.5;
		flEndWidth		= 2.5;

		beamColor.r		= 255;
		beamColor.g		= 255;
		beamColor.b		= 255;
		beamColor.a		= 255;
	}

	beams->CreateBeamEntPoint(
		nStartEntity,				// start ent
		NULL,						// start pos
		0,							// end ent
		&vecEndPoint,				// end pos
		m_nBeamIndex,				// model index
		NULL,						// halo index
		0.0,						// halo scale
		0.1,						// life
		flStartWidth,				// startwidth
		flEndWidth,					// endwidth
		0.0,						// fade length
		0,							// amplitude
		beamColor.a,				// brightness
		0,							// speed
		0,							// startframe
		0,							// framerate
		beamColor.r,				// R
		beamColor.g,				// G
		beamColor.b				// B
	);

	//ADRIANHL1MP
}
DECLARE_CLIENT_EFFECT( "HL1GaussBeam", HL1GaussBeam );


void HL1GaussBeamReflect( const CEffectData &data )
{
	Vector	vecStartPoint	= data.m_vStart;
	Vector	vecEndPoint		= data.m_vOrigin;
	bool	fIsPrimaryFire	= data.m_fFlags;
	float	flStartWidth;
	float	flEndWidth;
	color32	beamColor;

	if ( fIsPrimaryFire )	// primary attack
	{
		flStartWidth	= 1.0;
		flEndWidth		= 1.0;

		beamColor.r		= 255;
		beamColor.g		= 255;
		beamColor.b		= 0;
		beamColor.a		= 255;
	}
	else					// secondary
	{
		flStartWidth	= 2.5;
		flEndWidth		= 2.5;

		beamColor.r		= 255;
		beamColor.g		= 255;
		beamColor.b		= 255;
		beamColor.a		= 255;
	}

	beams->CreateBeamPoints(
		vecStartPoint,				// start pos
		vecEndPoint,				// end pos
		m_nBeamIndex,				// model index
		NULL,						// halo index
		0.0,						// halo scale
		0.1,						// life
		flStartWidth,				// startwidth
		flEndWidth,					// endwidth
		0.0,						// fade length
		0,							// amplitude
		beamColor.a,				// brightness
		0,							// speed
		0,							// startframe
		0,							// framerate
		beamColor.r,				// R
		beamColor.g,				// G
		beamColor.b					// B
	);
}
DECLARE_CLIENT_EFFECT( "HL1GaussBeamReflect", HL1GaussBeamReflect );


void HL1GaussReflect( const CEffectData &data )
{
	Vector	vecStart	= data.m_vOrigin;
	Vector	vecNormal	= data.m_vNormal;
	float	flMagnitude	= data.m_flMagnitude;

	tempents->TempSprite( vecStart, vec3_origin, 0.2, m_nGlowIndex, kRenderGlow, kRenderFxNoDissipation, flMagnitude / 255.0, flMagnitude * 0.05, FTENT_FADEOUT );

	Vector vecForward;
	VectorAdd( vecStart, vecNormal, vecForward );

	tempents->Sprite_Trail( vecStart, vecForward, m_nGlowIndex, 3, 0.1, random->RandomFloat( 0.1, 0.2 ), 100, 255, 100 );
}
DECLARE_CLIENT_EFFECT( "HL1GaussReflect", HL1GaussReflect );


void HL1GaussWallPunchEnter( const CEffectData &data )
{
	Vector	vecStart	= data.m_vOrigin;
	Vector	vecNormal	= data.m_vNormal;

	Vector vecForward;
	VectorSubtract( vecStart, vecNormal, vecForward );

	tempents->Sprite_Trail( vecStart, vecForward, m_nGlowIndex, 3, 0.1, random->RandomFloat( 0.1, 0.2 ), 100, 255, 100 );
}
DECLARE_CLIENT_EFFECT( "HL1GaussWallPunchEnter", HL1GaussWallPunchEnter );


void HL1GaussWallPunchExit( const CEffectData &data )
{
	Vector	vecStart	= data.m_vOrigin;
	Vector	vecNormal	= data.m_vNormal;
	float	flMagnitude	= data.m_flMagnitude;

	tempents->TempSprite( vecStart, vec3_origin, 0.1, m_nGlowIndex, kRenderGlow, kRenderFxNoDissipation, flMagnitude * 1.2 / 255.0, 6.0, FTENT_FADEOUT );

	Vector vecForward;
	VectorSubtract( vecStart, vecNormal, vecForward );

	tempents->Sprite_Trail( vecStart, vecForward, m_nGlowIndex, flMagnitude * 0.3, 0.1, random->RandomFloat( 0.1, 0.2 ), 200, 255, 40 );
}
DECLARE_CLIENT_EFFECT( "HL1GaussWallPunchExit", HL1GaussWallPunchExit );


void HL1GaussWallImpact1( const CEffectData &data )
{
	Vector	vecStart	= data.m_vOrigin;
	float	flMagnitude	= data.m_flMagnitude;

	tempents->TempSprite( vecStart, vec3_origin, 1, m_nGlowIndex, kRenderGlow, kRenderFxNoDissipation, flMagnitude / 255.0, 6.0, FTENT_FADEOUT );
}
DECLARE_CLIENT_EFFECT( "HL1GaussWallImpact1", HL1GaussWallImpact1 );


void HL1GaussWallImpact2( const CEffectData &data )
{
	Vector	vecStart	= data.m_vOrigin;
	Vector	vecNormal	= data.m_vNormal;

	tempents->TempSprite( vecStart, vec3_origin, 0.2, m_nGlowIndex, kRenderGlow, kRenderFxNoDissipation, 240.0 / 255.0, 0.3, FTENT_FADEOUT );

	Vector vecForward;
	VectorAdd( vecStart, vecNormal, vecForward );

	tempents->Sprite_Trail( vecStart, vecForward, m_nGlowIndex, 8, 0.6, random->RandomFloat( 0.1, 0.2 ), 100, 255, 200 );
}
DECLARE_CLIENT_EFFECT( "HL1GaussWallImpact2", HL1GaussWallImpact2 );