Difference between revisions of "CUtility"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
Outerbeast (talk | contribs) m  | 
				Outerbeast (talk | contribs)   | 
				||
| Line 78: | Line 78: | ||
| style="vertical-align:middle;" | Gets circular gaussian spread.  | | style="vertical-align:middle;" | Gets circular gaussian spread.  | ||
|}  | |}  | ||
| − | == Tracing methods ==  | + | == [[Tracing]] methods ==  | 
{| class="wikitable"    | {| class="wikitable"    | ||
|- style="font-weight:bold; text-align:center; vertical-align:middle;"  | |- style="font-weight:bold; text-align:center; vertical-align:middle;"  | ||
| Line 117: | Line 117: | ||
| style="vertical-align:middle;" | Gets the global trace data stored in g_Engine as a TraceResult object.  | | style="vertical-align:middle;" | Gets the global trace data stored in g_Engine as a TraceResult object.  | ||
|}  | |}  | ||
| + | |||
== Misc ==  | == Misc ==  | ||
{| class="wikitable"    | {| class="wikitable"    | ||
Revision as of 05:06, 20 February 2025
The CUtility class contains global utility related methods.
A single global Instance exists with the following declaration:
CUtility g_Utility;
This class only contains methods.
1 Effects
| Declaration | Description | 
|---|---|
void BloodStream(const Vector& in vecOrigin, const Vector& in vecDirection, int iColor, int iAmount)
 | 
Creates a blood stream. Use BLOOD_COLOR enum for the color. | 
void BloodDrips(const Vector& in vecOrigin, const Vector& in vecDirection, int iColor, int iAmount)
 | 
Creates blood drips. Use BLOOD_COLOR enum for the color. | 
Vector RandomBloodVector()
 | 
Returns a random blood direction vector | 
bool ShouldShowBlood(int iBloodColor)
 | 
Returns whether blood of the given type should be shown. | 
void BloodDecalTrace(TraceResult& in trace, int iBloodColor)
 | 
Applies blood decal to the trace hit location | 
void DecalTrace(TraceResult& in trace, int iDecalNumber)
 | 
Applies decal to the trace hit location | 
void PlayerDecalTrace(TraceResult& in trace, int iPlayerNum, int iDecalNumber, const bool bIsCustom)
 | 
Applies player decal to the trace hit location | 
void GunshotDecalTrace(TraceResult& in trace, int iDecalNumber)
 | 
Applies gunshot decal to the trace hit location | 
void Sparks(const Vector& in vecPosition)
 | 
Creates sparks at the given location | 
void Ricochet(const Vector& in vecPosition, float flScale)
 | 
Creates a ricochet at the given location | 
float WaterLevel(const Vector& in vecPosition, float minz, float maxz)
 | 
Determines the Z level at which a water surface level is, given a position to start searching from and a range to search. | 
void Bubbles(const Vector& in vecMins, const Vector& in vecMaxs, int iCount)
 | 
Creates a box filled with bubbles | 
void BubbleTrail(const Vector& in vecFrom, const Vector& in vecTo, int iCount)
 | 
Creates a trail of bubbles | 
2 Numerical Operations
| Declaration | Description | 
|---|---|
void StringToVector(Vector& out vecVector, const string& in szString, const char delimiter = char(' '))
 | 
Converts the given string to a vector | 
void StringToRGBA(RGBA& out rgba, const string& in szString, const char delimiter = char(' '))
 | 
Converts the given string to an RGBA (alpha component is optional) | 
bool IsStringInt(const string& in szString)
 | 
Returns whether the given string is an integer | 
bool IsStringFloat(const string& in szString)
 | 
Returns whether the given string is a float | 
bool IsWholeNumber(const float flNum, int& out iRounded)
 | 
Returns whether the given float is a whole number, and returns the rounded number | 
bool IsString3DVec(const string& in szString)
 | 
Returns whether the given string is a 3D vector | 
void GetCircularGaussianSpread(float& out x, float& out y) const
 | 
Gets circular gaussian spread. | 
3 Tracing methods
| Declaration | Description | 
|---|---|
void TraceLine(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,edict_t@ pEntIgnore, TraceResult& out ptr)
 | 
Calculates a trace along the given line, storing the results in ptr. | 
void TraceLine(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,IGNORE_GLASS ignoreGlass, edict_t@ pEntIgnore, TraceResult& out ptr)
 | 
Calculates a trace along the given line, storing the results in ptr. | 
void TraceHull(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,HULL_NUMBER hullNumber, edict_t@ pEntIgnore, TraceResult& out ptr)
 | 
Calculates a trace along the given line, storing the results in ptr, using the specified hull type. | 
void TraceToss(edict_t@ pEntity, edict_t@ pEntityToIgnore, TraceResult& out traceResult)
 | 
Trace toss | 
bool TraceMonsterHull(edict_t@ pEntity, const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon, edict_t@ pEntityToIgnore, TraceResult& out ptr)
 | 
Trace monster hull. Returns true if the trace was entirely in a solid object, or hit something. | 
void TraceModel(const Vector& in vecStart, const Vector& in vecEnd, int iHullNumber, edict_t@ pEntityToIgnore, TraceResult& out ptr)
 | 
TraceModel | 
string TraceTexture(edict_t@ pEntity, const Vector& in vecStart, const Vector& in vecEnd)
 | 
Trace texture | 
void FindHullIntersection(const Vector& in vecSrc, TraceResult& in inTr, TraceResult& out outTr, const Vector& in vecMins, const Vector& in vecMaxs, edict_t@ pEntity, float flDistance = 1e6f)
 | 
Finds the hull intersection from a traceline in a given set of bounds. The bounds are relative to the input traceline's endpoint. The given entity is the entity performing the traceline.  | 
CBaseEntity@ FindEntityForward(CBaseEntity@ pLooker, float flMaxDistance)
 | 
Convience function that finds the entity that the given entity is currently looking at. | 
CBaseEntity@ FindEntityForward(CBaseEntity@ pLooker)
 | 
Convience function that finds the entity that the given entity is currently looking at. Uses a maximum distance of 12048 units. | 
TraceResult GetGlobalTrace()
 | 
Gets the global trace data stored in g_Engine as a TraceResult object. | 
4 Misc
| Declaration | Description | 
|---|---|
bool IsPlayerInVolume(CBasePlayer@ pPlayer, CBaseEntity@ pEntityVolume)
 | 
Returns whether the given player is in the given volume. | 
int CountPlayersInBrushVolume(const bool fIgnoreDeadPlayers, CBaseEntity@ pBrushVolume,int& out iOutPlayersInsideVolume, int& out iOutPlayersOutsideVolume, PlayerInVolumeListener@ pListener)
 | 
Counts the number of players inside and outside a brush volume. | 
bool VoteActive() const
 | 
Returns whether a vote is active. This only covers the votes started using the in-game vote menu, trigger_vote and the Vote class. | 
string BuildEntityLogString(const string& in szName, const string& in szUserID = NULL, const string& in szAuthID = NULL, const string& in szTeam = NULL) const
 | 
Builds a generic entity log string. | 
string BuildPlayerLogString(const string& in szName, const string& in szUserID = NULL, const string& in szAuthID = NULL) const
 | 
Builds a generic player log string. | 
string GetPlayerLog(edict_t@ pPlayerEdict) const
 | 
Get a player log string. |