Difference between revisions of "CUtility"
Jump to navigation
Jump to search
Outerbeast (talk | contribs) m |
Outerbeast (talk | contribs) m |
||
Line 57: | Line 57: | ||
! Description | ! Description | ||
|- | |- | ||
− | | void StringToVector(Vector& out vecVector, const string& in szString, const char delimiter = char(' ')) | + | | <code>void StringToVector(Vector& out vecVector, const string& in szString, const char delimiter = char(' ')) |
| style="vertical-align:middle;" | Converts the given string to a vector | | style="vertical-align:middle;" | Converts the given string to a vector | ||
|- | |- | ||
− | | void StringToRGBA(RGBA& out rgba, const string& in szString, const char delimiter = char(' ')) | + | | <code>void StringToRGBA(RGBA& out rgba, const string& in szString, const char delimiter = char(' ')) |
| style="vertical-align:middle;" | Converts the given string to an RGBA (alpha component is optional) | | style="vertical-align:middle;" | Converts the given string to an RGBA (alpha component is optional) | ||
|- | |- | ||
− | | bool IsStringInt(const string& in szString) | + | | <code>bool IsStringInt(const string& in szString) |
| style="vertical-align:middle;" | Returns whether the given string is an integer | | style="vertical-align:middle;" | Returns whether the given string is an integer | ||
|- | |- | ||
− | | bool IsStringFloat(const string& in szString) | + | | <code>bool IsStringFloat(const string& in szString) |
| style="vertical-align:middle;" | Returns whether the given string is a float | | style="vertical-align:middle;" | Returns whether the given string is a float | ||
|- | |- | ||
− | | bool IsWholeNumber(const float flNum, int& out iRounded) | + | | <code>bool IsWholeNumber(const float flNum, int& out iRounded) |
| style="vertical-align:middle;" | Returns whether the given float is a whole number, and returns the rounded number | | style="vertical-align:middle;" | Returns whether the given float is a whole number, and returns the rounded number | ||
|- | |- | ||
− | | bool IsString3DVec(const string& in szString) | + | | <code>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 | + | | <code>void GetCircularGaussianSpread(float& out x, float& out y) const |
| style="vertical-align:middle;" | Gets circular gaussian spread. | | style="vertical-align:middle;" | Gets circular gaussian spread. | ||
|} | |} | ||
Line 84: | Line 84: | ||
! Description | ! Description | ||
|- | |- | ||
− | | void TraceLine(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,edict_t@ pEntIgnore, TraceResult& out ptr) | + | | <code>void TraceLine(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,edict_t@ pEntIgnore, TraceResult& out ptr) |
| style="vertical-align:middle;" | Calculates a trace along the given line, storing the results in ptr. | | style="vertical-align:middle;" | 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) | + | | <code>void TraceLine(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,IGNORE_GLASS ignoreGlass, edict_t@ pEntIgnore, TraceResult& out ptr) |
| style="vertical-align:middle;" | Calculates a trace along the given line, storing the results in ptr. | | style="vertical-align:middle;" | 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) | + | | <code>void TraceHull(const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon,HULL_NUMBER hullNumber, edict_t@ pEntIgnore, TraceResult& out ptr) |
| style="vertical-align:middle;" | Calculates a trace along the given line, storing the results in ptr, using the specified hull type. | | style="vertical-align:middle;" | 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) | + | | <code>void TraceToss(edict_t@ pEntity, edict_t@ pEntityToIgnore, TraceResult& out traceResult) |
| style="vertical-align:middle;" | Trace toss | | style="vertical-align:middle;" | Trace toss | ||
|- | |- | ||
− | | bool TraceMonsterHull(edict_t@ pEntity, const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon, edict_t@ pEntityToIgnore, TraceResult& out ptr) | + | | <code>bool TraceMonsterHull(edict_t@ pEntity, const Vector& in vecStart, const Vector& in vecEnd, IGNORE_MONSTERS igmon, edict_t@ pEntityToIgnore, TraceResult& out ptr) |
| style="vertical-align:middle;" | Trace monster hull. Returns true if the trace was entirely in a solid object, or hit something. | | style="vertical-align:middle;" | 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) | + | | <code>void TraceModel(const Vector& in vecStart, const Vector& in vecEnd, int iHullNumber, edict_t@ pEntityToIgnore, TraceResult& out ptr) |
| style="vertical-align:middle;" | TraceModel | | style="vertical-align:middle;" | TraceModel | ||
|- | |- | ||
− | | string TraceTexture(edict_t@ pEntity, const Vector& in vecStart, const Vector& in vecEnd) | + | | <code>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) | + | | <code>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. | | 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) | + | | <code>CBaseEntity@ FindEntityForward(CBaseEntity@ pLooker, float flMaxDistance) |
| style="vertical-align:middle;" | Convience function that finds the entity that the given entity is currently looking at. | | style="vertical-align:middle;" | Convience function that finds the entity that the given entity is currently looking at. | ||
|- | |- | ||
− | | CBaseEntity@ FindEntityForward(CBaseEntity@ pLooker) | + | | <code>CBaseEntity@ FindEntityForward(CBaseEntity@ pLooker) |
| style="vertical-align:middle;" | Convience function that finds the entity that the given entity is currently looking at. Uses a maximum distance of 12048 units. | | style="vertical-align:middle;" | Convience function that finds the entity that the given entity is currently looking at. Uses a maximum distance of 12048 units. | ||
|- | |- | ||
− | | TraceResult GetGlobalTrace() | + | | <code>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. | ||
|} | |} | ||
Line 123: | Line 123: | ||
! Description | ! Description | ||
|- | |- | ||
− | | bool IsPlayerInVolume(CBasePlayer@ pPlayer, CBaseEntity@ pEntityVolume) | + | | <code>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. | ||
|- | |- | ||
− | | int CountPlayersInBrushVolume(const bool fIgnoreDeadPlayers, CBaseEntity@ pBrushVolume,int& out iOutPlayersInsideVolume, int& out iOutPlayersOutsideVolume, PlayerInVolumeListener@ pListener) | + | | <code>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. | ||
|- | |- | ||
− | | bool VoteActive() const | + | | <code>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. | | 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 | + | | <code>string BuildEntityLogString(const string& in szName, const string& in szUserID = NULL, const string& in szAuthID = NULL, const string& in szTeam = NULL) const |
| style="vertical-align:middle;" | Builds a generic entity log string. | | style="vertical-align:middle;" | Builds a generic entity log string. | ||
|- | |- | ||
− | | string BuildPlayerLogString(const string& in szName, const string& in szUserID = NULL, const string& in szAuthID = NULL) const | + | | <code>string BuildPlayerLogString(const string& in szName, const string& in szUserID = NULL, const string& in szAuthID = NULL) const |
| style="vertical-align:middle;" | Builds a generic player log string. | | style="vertical-align:middle;" | Builds a generic player log string. | ||
|- | |- | ||
− | | string GetPlayerLog(edict_t@ pPlayerEdict) const | + | | <code>string GetPlayerLog(edict_t@ pPlayerEdict) const |
| style="vertical-align:middle;" | Get a player log string. | | style="vertical-align:middle;" | Get a player log string. | ||
|} | |} | ||
[[Category:Scripting]] | [[Category:Scripting]] |
Revision as of 19:52, 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. |