Difference between revisions of "CUtility"

From Sven Co-op
Jump to navigation Jump to search
(Created page with "The CUtility class contains global utility related methods. A single global Instance exists with the following declaration: <code>CUtility g_Utility;</code> This class only...")
 
m
Line 6: Line 6:
  
 
This class only contains methods.
 
This class only contains methods.
 
+
== Effects ==
 
{| 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 50: Line 50:
 
| void BubbleTrail(const Vector& in vecFrom, const Vector& in vecTo, int iCount)
 
| void BubbleTrail(const Vector& in vecFrom, const Vector& in vecTo, int iCount)
 
| style="vertical-align:middle;" | Creates a trail of bubbles
 
| style="vertical-align:middle;" | Creates a trail of bubbles
 +
|}
 +
== Numerical Operations ==
 +
{| class="wikitable"
 +
|- style="font-weight:bold; text-align:center; vertical-align:middle;"
 +
! Declaration
 +
! Description
 
|-
 
|-
 
| void StringToVector(Vector& out vecVector, const string& in szString, const char delimiter = char(' '))
 
| void StringToVector(Vector& out vecVector, const string& in szString, const char delimiter = char(' '))
Line 68: Line 74:
 
| bool IsString3DVec(const string& in szString)
 
| bool IsString3DVec(const string& in szString)
 
| style="vertical-align:middle;" | Returns whether the given string is a 3D vector
 
| style="vertical-align:middle;" | Returns whether the given string is a 3D vector
 +
|-
 +
| void GetCircularGaussianSpread(float& out x, float& out y) const
 +
| style="vertical-align:middle;" | Gets circular gaussian spread.
 +
|}
 +
== Tracing methods ==
 +
{| class="wikitable"
 +
|- style="font-weight:bold; text-align:center; vertical-align:middle;"
 +
! Declaration
 +
! Description
 
|-
 
|-
 
| void TraceLine(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,edict_t@ pEntIgnore, TraceResult& out ptr)
 
| void TraceLine(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,edict_t@ pEntIgnore, TraceResult& out ptr)
Line 89: Line 104:
 
| string TraceTexture(edict_t@ pEntity, const Vector& in vecStart, const Vector& in vecEnd)
 
| string TraceTexture(edict_t@ pEntity, const Vector& in vecStart, const Vector& in vecEnd)
 
| style="vertical-align:middle;" | Trace texture
 
| style="vertical-align:middle;" | 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)
 +
| style="vertical-align:middle;" | Finds the hull intersection from a traceline in a given set of bounds. The bounds are relative to the input traceline's endpoint.<br />The given entity is the entity performing the traceline.
 
|-
 
|-
 
| CBaseEntity@ FindEntityForward(CBaseEntity@ pLooker, float flMaxDistance)
 
| CBaseEntity@ FindEntityForward(CBaseEntity@ pLooker, float flMaxDistance)
Line 98: Line 116:
 
| TraceResult GetGlobalTrace()
 
| TraceResult GetGlobalTrace()
 
| 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 ==
 +
{| class="wikitable"
 +
|- style="font-weight:bold; text-align:center; vertical-align:middle;"
 +
! Declaration
 +
! Description
 
|-
 
|-
 
| bool IsPlayerInVolume(CBasePlayer@ pPlayer, CBaseEntity@ pEntityVolume)
 
| bool IsPlayerInVolume(CBasePlayer@ pPlayer, CBaseEntity@ pEntityVolume)
 
| style="vertical-align:middle;" | Returns whether the given player is in the given volume.
 
| style="vertical-align:middle;" | Returns whether the given player is in the given volume.
|-
 
| bool VoteActive() const
 
| style="vertical-align:middle;" | Returns whether a vote is active. This only covers the votes started using the in-game vote menu, trigger_vote and the Vote class.
 
|-
 
| void GetCircularGaussianSpread(float& out x, float& out y) const
 
| style="vertical-align:middle;" | Gets circular gaussian spread.
 
 
|-
 
|-
 
| int CountPlayersInBrushVolume(const bool fIgnoreDeadPlayers, CBaseEntity@ pBrushVolume,int& out iOutPlayersInsideVolume, int& out iOutPlayersOutsideVolume, PlayerInVolumeListener@ pListener)
 
| int CountPlayersInBrushVolume(const bool fIgnoreDeadPlayers, CBaseEntity@ pBrushVolume,int& out iOutPlayersInsideVolume, int& out iOutPlayersOutsideVolume, PlayerInVolumeListener@ pListener)
 
| style="vertical-align:middle;" | Counts the number of players inside and outside a brush volume.
 
| style="vertical-align:middle;" | Counts the number of players inside and outside a brush volume.
 
|-
 
|-
| 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)
+
| bool VoteActive() const
| style="vertical-align:middle;" | Finds the hull intersection from a traceline in a given set of bounds. The bounds are relative to the input traceline's endpoint.<br />The given entity is the entity performing the traceline.
+
| style="vertical-align:middle;" | 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
 
| string BuildEntityLogString(const string& in szName, const string& in szUserID = NULL, const string& in szAuthID = NULL, const string& in szTeam = NULL) const

Revision as of 19:32, 14 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.