summaryrefslogtreecommitdiff
path: root/game/client/tf/tf_hud_passtime_reticle.cpp
blob: a6c26f000ad296429a4e786d853226180376f5d6 (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
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
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "c_func_passtime_goal.h"
#include "c_tf_passtime_logic.h"
#include "tf_hud_passtime_reticle.h"
#include "passtime_convars.h"
#include "tf_weapon_passtime_gun.h"
#include "c_tf_player.h"
#include "view.h"
#include "c_tf_playerresource.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

// The team colors from g_PR are wrong and I couldn't fix that fast enough.
// These colors were sampled from HUD art.
static Color GetTeamColor( int iTeam )
{
	switch( iTeam )
	{
	case TF_TEAM_RED: return Color(0xFF, 0x51, 0x51);
	case TF_TEAM_BLUE: return Color(0xA5, 0xDE, 0xFF);
	default: return Color(0xF5, 0xE7, 0xDE);
	};
}

//-----------------------------------------------------------------------------
// C_PasstimeReticle
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
C_PasstimeReticle::~C_PasstimeReticle() 
{
	for( int i = 0; i < m_pSprites.Count(); ++i )
	{
		clienteffects->RemoveEffect( m_pSprites[i] );
	}
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::OnClientThink()
{
	if ( !Update() )
	{
		SetAllAlphas( 0 );
	}
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::AddSprite( CFXQuad *pQuad )
{
	Assert( pQuad );
	m_pSprites.AddToTail( pQuad );
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetAllOrigins( const Vector &vec )
{
	for ( int i = 0; i < m_pSprites.Count(); ++i )
	{
		m_pSprites[i]->m_FXData.SetOrigin( vec );
	}
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetAllNormals( const Vector &vec )
{
	for ( int i = 0; i < m_pSprites.Count(); ++i )
	{
		m_pSprites[i]->m_FXData.SetNormal( vec );
	}
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetAllAlphas( byte iA )
{
	auto flA = iA / 255.0f;
	for ( int i = 0; i < m_pSprites.Count(); ++i )
	{
		m_pSprites[i]->m_FXData.SetAlpha( flA, flA );
	}
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetAllScales( float flScale )
{
	for ( int i = 0; i < m_pSprites.Count(); ++i )
	{
		m_pSprites[i]->m_FXData.SetScale( flScale, flScale );
	}
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetOrigin( int i, const Vector &vec )
{
	m_pSprites[i]->m_FXData.SetOrigin( vec );
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetNormal( int i, const Vector &normal )
{
	m_pSprites[i]->m_FXData.SetNormal( normal );
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetAlpha( int i, byte iA )
{
	auto flA = iA / 255.0f;
	m_pSprites[i]->m_FXData.SetAlpha( flA, flA );
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetRgba( int i, byte iR, byte iG, byte iB, byte iA )
{
	m_pSprites[i]->m_FXData.SetColor( iR / 255.0f, iG / 255.0f, iB / 255.0f );
	auto flA = iA / 255.0;
	m_pSprites[i]->m_FXData.SetAlpha( flA, flA );
}

//-----------------------------------------------------------------------------
void C_PasstimeReticle::SetScale( int i, float flScale )
{
	m_pSprites[i]->m_FXData.SetScale( flScale, flScale );
}


//-----------------------------------------------------------------------------
// C_PasstimeBallReticle
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
static const float k_flBallReticleSize = 64;
C_PasstimeBallReticle::C_PasstimeBallReticle()
{
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_piece_1", k_flBallReticleSize, 360 ) ); // the O
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_piece_2", k_flBallReticleSize, 360 ) ); // the ><
}

//-----------------------------------------------------------------------------
bool C_PasstimeBallReticle::Update()
{
	if ( !g_pPasstimeLogic || !g_pPasstimeLogic->GetBall() ) 
	{
		return false;
	}

	auto *pBall = g_pPasstimeLogic->GetBall();
	auto *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
	C_BaseEntity *pTarget = 0;
	auto bHomingActive = false;
	auto bHaveTarget = g_pPasstimeLogic->GetBallReticleTarget( &pTarget, &bHomingActive );
	if ( !pBall || !pLocalPlayer || !bHaveTarget )
	{
		return false;
	}
	
	auto vecTargetPos = pTarget->WorldSpaceCenter();
	SetAllOrigins( vecTargetPos );
	SetAllNormals( -MainViewForward() );
		
	auto teamColor = GetTeamColor( pTarget->GetTeamNumber() );
	auto iAlpha = ( bHomingActive || pLocalPlayer->m_Shared.IsTargetedForPasstimePass() )
		? (int)( (fmodf( gpGlobals->curtime * 3.0f, 1.0f )) * 255 )
		: 180;

	SetRgba( 0, teamColor.r(), teamColor.g(), teamColor.b(), iAlpha );
	SetRgba( 1, teamColor.r(), teamColor.g(), teamColor.b(), iAlpha );

	auto flDist = (vecTargetPos - MainViewOrigin()).Length();
	auto flScale = RemapValClamped( flDist, 768.0f, 4096.0f, 1.0f, 3.0f );
	flScale *= k_flBallReticleSize;
	if ( bHomingActive || pLocalPlayer->m_Shared.IsTargetedForPasstimePass() )
	{
		flScale *= 2;
	}
	SetScale( 0, flScale );
	SetScale( 1, flScale );

	return true;
}

//-----------------------------------------------------------------------------
// C_PasstimeGoalReticle
//-----------------------------------------------------------------------------


//-----------------------------------------------------------------------------
C_PasstimeGoalReticle::C_PasstimeGoalReticle( C_FuncPasstimeGoal *pGoal )
{
	Assert( pGoal );
	m_hGoal.Set( pGoal );
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_piece_1", 256, 50 ) );
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_piece_2", 128, 0 ) );
}

//-----------------------------------------------------------------------------
bool C_PasstimeGoalReticle::Update()
{
	if ( !g_pPasstimeLogic || !g_pPasstimeLogic->GetBall() )
	{
		return false;
	}

	// don't show if ball isn't being carried by local player
	auto *pEnt = g_pPasstimeLogic->GetBall()->GetCarrier();
	if ( !pEnt || (pEnt != C_BasePlayer::GetLocalPlayer()) )
	{
		return false;
	}

	auto *pGoal = m_hGoal.Get();
	if ( !g_pPasstimeLogic || !g_pPasstimeLogic->GetBall() || IsLocalPlayerSpectator() 
		|| !pGoal || pGoal->BGoalTriggerDisabled() || (pGoal->GetTeamNumber() != pEnt->GetTeamNumber()) )
	{
		return false;
	}

	auto teamColor = GetTeamColor( pEnt->GetTeamNumber() );

	auto vec = pGoal->WorldSpaceCenter();
	auto facingFrac = MainViewForward().Dot( (vec - MainViewOrigin()).Normalized() );
	if ( facingFrac < 0.6 )
	{
		return false;
	}
	facingFrac = RemapValClamped( facingFrac, 0.8f, 1.0f, 1.0f, 0.3f );

	// ring
	SetOrigin( 0, vec );
	auto flPulseSpeed = 10.0f;
	auto flPulseFrac = Clamp( FastCos( gpGlobals->curtime * flPulseSpeed ), 0.0f, 1.0f );
	SetRgba( 0, teamColor.r(), teamColor.g(), teamColor.b(), flPulseFrac * (120 * facingFrac) );
	
	// arrow
	float tmp;
	flPulseFrac = 1.0f - modff( gpGlobals->curtime, &tmp );
	SetOrigin( 1, vec + Vector(0, 0, flPulseFrac * 64) );
	SetAllNormals( -MainViewForward() );
	SetRgba( 1, teamColor.r(), teamColor.g(), teamColor.b(), flPulseFrac * (255 * facingFrac) );
	return true;
}


//-----------------------------------------------------------------------------
// C_PasstimePassReticle
//-----------------------------------------------------------------------------

const float kPassReticleScale = 64;
//-----------------------------------------------------------------------------
C_PasstimePassReticle::C_PasstimePassReticle() 
{
	m_flTargetScore = FLT_MAX;
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_passlock", kPassReticleScale, 100 ) ); // the *
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_piece_1", kPassReticleScale, 0 ) ); // the O
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_piece_2", kPassReticleScale, 0 ) ); // the ><
}

//-----------------------------------------------------------------------------
bool C_PasstimePassReticle::Update()
{
	if ( !g_pPasstimeLogic || !g_pPasstimeLogic->GetBall() || IsLocalPlayerSpectator() )
	{
		return false;
	}

	auto *pBallCarrier = g_pPasstimeLogic->GetBall()->GetCarrier();
	if ( !pBallCarrier )
	{
		return false;
	}
	if ( (pBallCarrier != C_BasePlayer::GetLocalPlayer()) )
	{
		return false;
	}
	
	SetAllNormals( -MainViewForward() );

	// the player's actual pass target always takes precedence, but if it's
	// not set, try to find a candidate and display a hint for that
	auto *pPassTarget = pBallCarrier->m_Shared.GetPasstimePassTarget();
	if ( pPassTarget )
	{
		m_hTarget = pPassTarget;
		auto vecTargetPos = pPassTarget->WorldSpaceCenter();
		SetAllOrigins( vecTargetPos );

		auto teamColor = GetTeamColor( pBallCarrier->GetTeamNumber() );
		auto neutralColor = GetTeamColor( TEAM_UNASSIGNED );
		auto iAlpha = (int)( (fmodf( gpGlobals->curtime * 3.0f, 1.0f )) * 255 );
		SetRgba( 0, teamColor.r(), teamColor.g(), teamColor.b(), iAlpha );
		SetRgba( 1, neutralColor.r(), neutralColor.g(), neutralColor.b(), 255 );
		SetRgba( 2, teamColor.r(), teamColor.g(), teamColor.b(), iAlpha );

		auto flDist = (vecTargetPos - MainViewOrigin()).Length();
		auto flScale = RemapValClamped( flDist, 768.0f, 8192.0f, 1.0f, 8.0f );
		SetAllScales( flScale * kPassReticleScale * 2 );
	}
	else
	{
		FindPassHintTarget( pBallCarrier );
		if ( !m_hTarget )
		{
			return false;
		}

		auto flPulseSpeed = 20;
		auto flPulseFrac = Clamp( FastCos( gpGlobals->curtime * flPulseSpeed ), 0.3f, 1.0f );
		auto iAlpha = 200 * flPulseFrac * Clamp( m_flTargetScore + 0.5f, 0.0f, 1.0f ); // higher flScore is better

		auto teamColor = GetTeamColor( TEAM_UNASSIGNED );
		auto neutralColor = GetTeamColor( TEAM_UNASSIGNED );
		SetRgba( 0, teamColor.r(), teamColor.g(), teamColor.b(), iAlpha );
		SetRgba( 1, neutralColor.r(), neutralColor.g(), neutralColor.b(), 80 );
		SetRgba( 2, teamColor.r(), teamColor.g(), teamColor.b(), iAlpha );
		
		auto vecTargetPos = m_hTarget->WorldSpaceCenter();
		SetAllOrigins( vecTargetPos );
	
		auto flDist = (vecTargetPos - MainViewOrigin()).Length();
		auto flScale = RemapValClamped( flDist, 768.0f, 8192.0f, 1.0f, 8.0f );
		SetAllScales( flScale * kPassReticleScale );
	}
	
	return true;
}

//-----------------------------------------------------------------------------
extern int HudTransform( const Vector &point, Vector &screen );
void C_PasstimePassReticle::FindPassHintTarget( C_TFPlayer *pLocalPlayer )
{
	m_hTarget = 0;
	m_flTargetScore = -FLT_MAX;

	auto flFovDeg = 70;
	auto flDotFov = cosf( DEG2RAD( flFovDeg / 2.0f ) );
	auto vecViewPos = MainViewOrigin();
	auto vecViewFwd = MainViewForward();

	auto flMaxPassDist = g_pPasstimeLogic->GetMaxPassRange() - 400; // arbitrary, based on TF_MAX_SPEED

	// for each player in front of the local player,
	for( int i = 1; i <= MAX_PLAYERS; i++ )
	{
		auto *pPlayer = ToTFPlayer( UTIL_PlayerByIndex( i ) );
		if ( !C_PasstimeGun::BValidPassTarget( pLocalPlayer, pPlayer ) )
		{
			continue;
		}

		auto vecTargetPos = pPlayer->EyePosition();
		auto vecToTarget = vecTargetPos - vecViewPos;
		if ( vecToTarget.NormalizeInPlace() > flMaxPassDist ) 
		{
			// the server may disagree on this, so the client is less permissive
			// when it guesses in order to prevent false positives
			continue; // too far away, probably
		}

		auto fDotTarget = vecToTarget.Dot( vecViewFwd );
		if ( fDotTarget <= flDotFov )
		{
			continue; // not in front
		}

		// determine player's distance from center of screen 
		Vector vecScreenPos;
		auto bBehindViewplane = HudTransform( vecTargetPos, vecScreenPos );
		if ( bBehindViewplane )
		{
			continue; // paranoia
		}
		auto flScore = 0.5f - vecScreenPos.Length2D();
		if ( flScore <= m_flTargetScore )
		{
			continue; // someone else already found that's closer
		}

		// trace to see if they are visible
		// this is the same trace the gun does
		trace_t tr;
		CTraceFilterSimple tracefilter( pLocalPlayer, COLLISION_GROUP_PROJECTILE );
		UTIL_TraceLine( vecViewPos, vecTargetPos, MASK_PLAYERSOLID, &tracefilter, &tr );
		if ( tr.m_pEnt != pPlayer )
		{
			continue; // not visible
		}
	
		m_flTargetScore = flScore;
		m_hTarget = pPlayer;
	}
}


//-----------------------------------------------------------------------------
// C_PasstimeBounceReticle
//-----------------------------------------------------------------------------
C_PasstimeBounceReticle::C_PasstimeBounceReticle()
{
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_passlock", 160, 0 ) ); // the *
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_ball_reticle_piece_1", 80, 200 ) ); // the O
}

void C_PasstimeBounceReticle::Show( const Vector &vec, const Vector &normal )
{
	SetOrigin( 0, vec );
	SetOrigin( 1, vec );//+ (normal * 16) );
	SetNormal( 0, normal );
	SetNormal( 1, -MainViewForward() );
	SetRgba( 0, 255, 255, 0, 200 );
	SetRgba( 1, 255, 255, 0, 200 );
}

void C_PasstimeBounceReticle::Hide()
{
	SetAllAlphas( 0 );
}

bool C_PasstimeBounceReticle::Update()
{
	return !IsLocalPlayerSpectator();
}

//-----------------------------------------------------------------------------
// C_PasstimePlayerReticle
//-----------------------------------------------------------------------------
C_PasstimePlayerReticle::C_PasstimePlayerReticle( C_TFPlayer *pPlayer )
{
	m_hPlayer.Set( pPlayer );
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_teamicon_red", 128, 0 ) );
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_teamicon_blue", 128, 0 ) );
}

//-----------------------------------------------------------------------------
bool C_PasstimePlayerReticle::Update()
{
	if ( !g_pPasstimeLogic ) 
	{
		return false;
	}

	auto *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
	auto *pPlayer = m_hPlayer.Get();
	if ( !pLocalPlayer || pLocalPlayer->IsPlayerDead() 
		|| !pPlayer || pPlayer->IsPlayerDead() )
	{
		return false;
	}

	if ( pPlayer->m_Shared.GetPercentInvisible() > 0 ) 
	{
		// dont' show because player is invisible, friend or foe
		return false;
	}

	auto iFriendsDetail = tf_passtime_player_reticles_friends.GetInt();
	auto iEnemiesDetail = tf_passtime_player_reticles_enemies.GetInt();

	auto bIsDisguisedEnemy = pPlayer->m_Shared.InCond( TF_COND_DISGUISED ) 
		&& ( pPlayer->m_Shared.GetDisguiseTeam() == pLocalPlayer->GetTeamNumber() )
		&& !pPlayer->m_Shared.IsFullyInvisible();

	auto bIsFriend = pLocalPlayer->InSameTeam( pPlayer ) || bIsDisguisedEnemy;

	if ( (bIsFriend && (iFriendsDetail <= 0)) 
		|| (!bIsFriend && (iEnemiesDetail <= 0)) )
	{
		// don't show because disabled
		return false;
	}

	if ( !pLocalPlayer->m_Shared.HasPasstimeBall()
		&& ((bIsFriend && (iFriendsDetail == 1)) 
			|| (!bIsFriend && (iEnemiesDetail == 1))))
	{
		// don't show because not visible unless have ball
		return false;
	}

	if ( pPlayer->IsDormant() )
	{
		// don't show because not getting updated from server for some reason
		// probably not in PVS
		return false;
	}

	auto nTeamNumber = pPlayer->GetTeamNumber();
	if ( !pLocalPlayer->InSameTeam( pPlayer ) && bIsFriend )	// they're not on my team but they're showing as a friend, they must be a spy so use my team color
	{
		nTeamNumber = pLocalPlayer->GetTeamNumber();
	}

	int iShowSprite, iHideSprite;
	if ( nTeamNumber == TF_TEAM_RED )
	{
		iShowSprite = 0;
		iHideSprite = 1;
	}
	else if ( nTeamNumber == TF_TEAM_BLUE )
	{
		iShowSprite = 1;
		iHideSprite = 0;
	}
	else
	{
		return false;
	}

	auto vecTarget = pPlayer->EyePosition();
	int iX, iY;
	auto bOnScreen = GetVectorInHudSpace( vecTarget, iX, iY );
	if ( !bOnScreen )
	{
		return false;
	}

	trace_t	tr;
	CTraceFilterIgnorePlayers tracefilter( pLocalPlayer, COLLISION_GROUP_PROJECTILE );
	UTIL_TraceLine( MainViewOrigin(), vecTarget, MASK_PLAYERSOLID, &tracefilter, &tr );
	if ( tr.fraction == 1 )
	{
		// made it all the way, the guy is visible so hide the icon
		return false;
	}

	auto flDist = (vecTarget - MainViewOrigin()).Length();
	auto flScale = RemapValClamped( flDist, 1024.0f, 4096.0f, 80, 128 );

	SetAlpha( iHideSprite, 0 );
	SetAlpha( iShowSprite, 100 );
	SetAllScales( flScale );
	SetAllOrigins( vecTarget );
	SetAllNormals( -MainViewForward() );
	return true;
}

//-----------------------------------------------------------------------------
// C_PasstimeAskForBallReticle
//-----------------------------------------------------------------------------
C_PasstimeAskForBallReticle::C_PasstimeAskForBallReticle( C_TFPlayer *pPlayer )
{
	m_hPlayer.Set( pPlayer );
	AddSprite( CreateReticleSprite( "passtime/hud/passtime_pass_to_me_prompt", 128, 0 ) );
	SetRgba( 0, 255, 255, 255, 200 );
}

//-----------------------------------------------------------------------------
bool C_PasstimeAskForBallReticle::Update()
{
	if ( !g_pPasstimeLogic ) 
	{
		return false;
	}

	auto *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
	auto *pPlayer = m_hPlayer.Get();

	if ( !pLocalPlayer || !pPlayer )
	{
		return false;
	}

	auto bLocalPlayerObserver = pLocalPlayer->IsObserver();
	if ( !bLocalPlayerObserver && pLocalPlayer->IsPlayerDead() )
	{
		return false;
	}

	if ( (pPlayer->m_Shared.AskForBallTime() < gpGlobals->curtime) || pPlayer->IsPlayerDead() )
	{
		return false;
	}

	if ( !bLocalPlayerObserver && !pLocalPlayer->m_Shared.HasPasstimeBall() && !pPlayer->InSameTeam( pLocalPlayer ) )
	{
		return false;
	}

	auto vecTarget = pPlayer->EyePosition();
	vecTarget.z += 16;
	int iX, iY;
	auto bOnScreen = GetVectorInHudSpace( vecTarget, iX, iY );
	if ( !bOnScreen )
	{
		return false;
	}

	auto flDist = (vecTarget - MainViewOrigin()).Length();
	auto flScale = RemapValClamped( flDist, 1024.0f, 4096.0f, 40, 200 );
	SetAllScales( flScale );
	SetAllOrigins( vecTarget );
	SetAllNormals( -MainViewForward() );
	SetRgba( 0, 255, 255, 255, (((int)(gpGlobals->curtime * 10)) & 1 ? 200 : 0) );
	return true;
}

//-----------------------------------------------------------------------------
// Functions
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
CFXQuad *CreateReticleSprite( const char *pModelName, float flScale, float flSpinSpeed )
{
	FXQuadData_t q;
	memset(&q, 0, sizeof(q));
	q.m_Color.Init(1,1,1);
	q.m_flDeltaYaw = flSpinSpeed;
	q.m_flDieTime = FLT_MAX;
	q.m_flEndAlpha = 1;
	q.m_flEndScale = flScale;
	q.m_flLifeTime = 0;
	q.m_flScaleBias = 0;
	q.m_flStartAlpha = 1;
	q.m_flStartScale = flScale;
	q.m_flYaw = 180;
	q.SetMaterial( pModelName );
	q.m_uiFlags = 0;
	q.m_vecNormal.Init(1,0,0);
	q.m_vecOrigin.Init(0,0,0);
	CFXQuad *pQuad = new CFXQuad(q);
	clienteffects->AddEffect( pQuad );
	return pQuad;
}