-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.cpp
More file actions
106 lines (84 loc) · 2.37 KB
/
Copy pathutil.cpp
File metadata and controls
106 lines (84 loc) · 2.37 KB
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
/*
===== util.cpp ========================================================
Utility code. Really not optional after all.
*/
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#ifdef DEBUG
edict_t *DBG_EntOfVars( const entvars_t *pev )
{
if ( pev->pContainingEntity != NULL )
return (edict_t *)pev->pContainingEntity;
ALERT( at_log, "entvars_t pContainingEntity is NULL, calling into engine" );
edict_t *pent = ( *g_engfuncs.pfnFindEntityByVars )( (entvars_t *)pev );
if ( pent == NULL )
ALERT( at_log, "DAMN! Even the engine couldn't FindEntityByVars!" );
( (entvars_t *)pev )->pContainingEntity = pent;
return pent;
}
#endif //DEBUG
void UTIL_SetSize( entvars_t *pent, Vector &vecMin, Vector &vecMax )
{
SET_SIZE( ENT( pent ), vecMin, vecMax );
}
float UTIL_VecToYaw( Vector &vec )
{
return VEC_TO_YAW( vec );
}
Vector UTIL_VecToAngles( Vector &vec )
{
float rgflVecOut[3];
VEC_TO_ANGLES( vec, rgflVecOut );
return rgflVecOut;
}
void UTIL_MoveToOrigin( edict_t *pent, float x, float y, float z, float flDist, int iMoveType )
{
vec3_t vecGoal;
vecGoal[0] = x;
vecGoal[1] = y;
vecGoal[2] = z;
MOVE_TO_ORIGIN( pent, vecGoal, flDist, iMoveType );
}
edict_t *UTIL_FindRadius( Vector &vecOrigin, float flRadius )
{
return FIND_ENTITY_IN_RADIUS( vecOrigin, flRadius );
}
void UTIL_MakeVectors( Vector &vecAngles )
{
MAKE_VECTORS( vecAngles );
}
void UTIL_SetOrigin( entvars_t *pev, Vector &vecOrigin )
{
SET_ORIGIN( ENT( pev ), vecOrigin );
}
void UTIL_EmitAmbientSound( Vector &pos, char *samp, float vol, float attenuation )
{
EMIT_AMBIENT_SOUND( pos, samp, vol, attenuation );
}
void UTIL_TraceLine( Vector &vec1, Vector &vec2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr )
{
TRACE_LINE( vec1, vec2, fNoMonsters == 0, pentToSkip, ptr );
}
Vector UTIL_GetAimVector( edict_t *pent, float flSpeed )
{
float tmp[3];
GET_AIM_VECTOR( pent, flSpeed, tmp );
return tmp;
}
void UTIL_ParticleEffect( Vector &org, Vector &dir, unsigned int ulColor, unsigned int ulCount )
{
PARTICLE_EFFECT( org, dir, (float)ulColor, (float)ulCount );
}
float UTIL_RandomFloat( float flMin, float flMax )
{
return (double)( rand() & 0x7FFF ) * 0.000030518509 * ( flMax - flMin ) + flMin; // TODO(SanyaSho)
}
int UTIL_RandomLong( int nMin, int nMax )
{
return nMin + rand() % ( nMax - nMin + 1 ); // TODO(SanyaSho)
}
int UTIL_PointContents( Vector &vec )
{
return POINT_CONTENTS( vec );
}