Difference between revisions of "CEntityFuncs"
Outerbeast (talk | contribs) (Created page with "The class CEntityFuncs provides an interface that can be used to access methods that operate on entities. HTML documentation can be found here. A single global instance exis...") |
Outerbeast (talk | contribs) m |
||
Line 6: | Line 6: | ||
<nowiki>CEntityFuncs g_EntityFuncs;</nowiki> | <nowiki>CEntityFuncs g_EntityFuncs;</nowiki> | ||
− | == | + | === Spawner methods === |
===== CreateEntity ===== | ===== CreateEntity ===== | ||
<nowiki>CBaseEntity@ CreateEntity(const string& in szClassName, dictionary@ pDictionary = null, bool fSpawn = true)</nowiki> | <nowiki>CBaseEntity@ CreateEntity(const string& in szClassName, dictionary@ pDictionary = null, bool fSpawn = true)</nowiki> | ||
Line 177: | Line 177: | ||
void SetOrigin(CBaseEntity@ entity, const Vector& in vecOrigin) | void SetOrigin(CBaseEntity@ entity, const Vector& in vecOrigin) | ||
Sets the origin of an entity. | Sets the origin of an entity. | ||
+ | |||
+ | ===== EjectBrass ===== | ||
+ | void EjectBrass(const Vector& in vecOrigin, const Vector& in vecVelocity, float flRotation, int iModel, TE_BOUNCE soundtype) | ||
+ | Tosses a brass shell from passed origin at passed velocity. | ||
===== SetModel ===== | ===== SetModel ===== | ||
Line 191: | Line 195: | ||
vecMax Maximum bounds to set. | vecMax Maximum bounds to set. | ||
+ | === Finder Methods === | ||
===== FindEntityInSphere ===== | ===== FindEntityInSphere ===== | ||
CBaseEntity@ FindEntityInSphere(CBaseEntity@ pStartEntity, const Vector& in vecCenter, float flRadius, const string& in szValue = "", const string& in szKeyword = "targetname") | CBaseEntity@ FindEntityInSphere(CBaseEntity@ pStartEntity, const Vector& in vecCenter, float flRadius, const string& in szValue = "", const string& in szKeyword = "targetname") | ||
Line 282: | Line 287: | ||
Returns the number of entities it found. | Returns the number of entities it found. | ||
+ | ===== RandomTargetname ===== | ||
+ | CBaseEntity@ RandomTargetname(const string& in szTargetname) | ||
+ | Returns a randomly selected entity that has the given target name. | ||
+ | |||
+ | === Misc === | ||
===== DispatchSpawn ===== | ===== DispatchSpawn ===== | ||
int DispatchSpawn(edict_t@ entity) | int DispatchSpawn(edict_t@ entity) | ||
Line 346: | Line 356: | ||
edict_t@ IndexEnt(int iEdictNum) | edict_t@ IndexEnt(int iEdictNum) | ||
Gets the edict for the given index. | Gets the edict for the given index. | ||
− | |||
− | |||
− | |||
− | |||
Argument Purpose | Argument Purpose | ||
Line 360: | Line 366: | ||
ScriptClassInterface@ CastToScriptClass(CBaseEntity@ pEntity) | ScriptClassInterface@ CastToScriptClass(CBaseEntity@ pEntity) | ||
Casts an CBaseEntity@ representing a custom entity to the ScriptClassBaseClass type. | Casts an CBaseEntity@ representing a custom entity to the ScriptClassBaseClass type. | ||
− | |||
− | |||
− | |||
− | |||
===== PrecacheMaterialSounds ===== | ===== PrecacheMaterialSounds ===== | ||
void PrecacheMaterialSounds(const Materials material) | void PrecacheMaterialSounds(const Materials material) | ||
Precaches the sounds used by a particular material. See the Materials enum. | Precaches the sounds used by a particular material. See the Materials enum. |
Revision as of 18:08, 14 February 2025
The class CEntityFuncs provides an interface that can be used to access methods that operate on entities.
HTML documentation can be found here.
A single global instance exists:
CEntityFuncs g_EntityFuncs;
1 Spawner methods
1.1 CreateEntity
CBaseEntity@ CreateEntity(const string& in szClassName, dictionary@ pDictionary = null, bool fSpawn = true)
Create an entity by class name. Pass keyvalues in using the dictionary, if any. Keyvalues must be strings. The class name can be either one of the entities included with the game or a custom entity. Argument Purpose szClassName Class name of the entity to create. pDictionary Dictionary of keyvalues to initialize the entity with. fSpawn Whether or not to call DispatchSpawn on the entity.
1.2 Create
CBaseEntity@ Create(const string& in szClassname, const Vector& in vecOrigin, const Vector& in vecAngles, bool fCreateAndDontSpawn, edict_t@ entOwner = null)
Creates an entity by class name.
Argument Purpose szClassName Class name of the entity to create. vecOrigin Origin in the world to place the entity. vecAngles Angles to set on the entity. fCreateAndDontSpawn If true, creates the entity but does not call DispatchSpawn on it. entOwner Entity that owns this entity. Returns the entity on success, false otherwise.
1.3 CreateDecal
void CreateDecal(const string& in szDecalName, const Vector& in vecOrigin, const string& in szTargetName = "") Creates a decal with the specified name. Creating a decal with no name will only work correctly if done at map spawn time.
Argument Purpose szDecalName Name of the decal texture. vecOrigin Origin in the world to place the decal. szTargetName If not empty, the decal will not be applied immediately, but instead will be applied when triggered.
1.4 CreateSprite
CSprite@ CreateSprite(const string& in szSpriteName, const Vector& in vecOrigin, bool fAnimated, float flFrameRate = 10.0f) Creates a sprite. flFrameRate must be set to a valid value to animate the sprite.
Argument Purpose szSpriteName Name of the sprite file to use. Must be precached. vecOrigin Location in the world to place the sprite at. fAnimated If true, the sprite is animated. flFrameRate Framerate for animated sprites. Returns the sprite on success, null otherwise.
1.5 CreateBeam
CBeam@ CreateBeam(const string& in szSpriteName, int width) Creates a beam entity with the given sprite and width set.
Argument Purpose szSpriteName Name of the sprite file to use. Must be precached. width Width of the beam in units. Returns the beam on success, null otherwise.
1.6 CreateExplosion
void CreateExplosion(const Vector& in vecCenter, const Vector& in vecAngles, edict_t@ pOwner, int iMagnitude, bool fDoDamage) Creates an explosion.
Argument Purpose vecCenter Center point of the explosion. vecAngles Angles of the explosion entity. pOwner Owner of the explosion. iMagnitude Damage and radius of the explosion. Radius is 2.5 times the amount of damage. fDoDamage Whether to do damage or not. Explosions that deal no damage will be a visual effect only.
1.7 CreateDisplacerPortal
CBaseEntity@ CreateDisplacerPortal(const Vector& in vecOrigin, const Vector& in vecVelocity, edict_t@ pOwner, float flDamage, float flRadius) Creates a displacer portal.
Argument Purpose vecOrigin Origin in the world of the displacer portal. vecVelocity Velocity of the portal. Determines the direction and speed. pOwner Owner of the portal. Can be null. flDamage Damage to deal on touch and on detonation. flRadius Radius of the detonation. Returns the portal entity on success, null otherwise.
1.8 CreateRPGRocket
CBaseEntity@ CreateRPGRocket(const Vector& in vecOrigin, const Vector& in vecAngles, edict_t@ pOwner) Creates an rpg rocket.
Argument Purpose vecOrigin Origin in the world to place the rocket. vecAngles Angles of the rocket. Converted to a velocity. pOwner Owner of the rocket. Returns the rocket entity on success, null otherwise.
1.9 CreateRPGRocket
CBaseEntity@ CreateRPGRocket(const Vector& in vecOrigin, const Vector& in vecAngles, const Vector& in vecVelocity, edict_t@ pOwner) Creates an rpg rocket with custom velocity.
Creates an rpg rocket.
Argument Purpose vecOrigin Origin in the world to place the rocket. vecAngles Angles of the rocket. vecVelocity Velocity of the rocket. pOwner Owner of the rocket. Returns the rocket entity on success, null otherwise.
1.10 CreateGib
CGib@ CreateGib( const Vector& in vecOrigin, const Vector& in vecAngles) Creates a server side gib.
1.11 ShootTimed
CGrenade@ ShootTimed(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity, float flTime) Spawns a timed (hand) grenade.
Argument Purpose pevOwner Owner of the grenade. vecStart Origin in the world to place the grenade. vecVelocity Velocity of the grenade. flTime Time in seconds until explosion. Returns the grenade entity on success, null otherwise.
1.12 ShootContact
CGrenade@ ShootContact(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity) Spawns a contact (AR) grenade.
Argument Purpose pevOwner Owner of the grenade. vecStart Origin in the world to place the grenade. vecVelocity Velocity of the grenade. Returns the grenade entity on success, null otherwise.
1.13 ShootMortar
CGrenade@ ShootMortar(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity) Spawns a mortar grenade.
Argument Purpose pevOwner Owner of the mortar. vecStart Origin in the world to place the mortar. vecVelocity Velocity of the mortar. Returns the mortar entity on success, null otherwise.
1.14 ShootBananaCluster
CGrenade@ ShootBananaCluster(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity) Spawn a banana bomb.
Argument Purpose pevOwner Owner of the bomb. vecStart Origin in the world to place the bomb. vecVelocity Velocity of the bomb. Returns the bomb entity on success, null otherwise.
1.15 UseSatchelCharges
void UseSatchelCharges(entvars_t@ pevOwner, SATCHELCODE code) Triggers all satchel charges owned by pevOwner to either be released from ownership, or detonated.
See the SATCHELCODE enum.
1.16 SpawnHeadGib
void SpawnHeadGib(entvars_t@ pevVictim) Spawns a head gib for the target victim.
1.17 SpawnRandomGibs
void SpawnRandomGibs(entvars_t@ pevVictim, int cGibs, int iHuman) Spawns random gibs for the target victim.
Argument Purpose pevVictim Entity to spawn gibs for. cGibs Ignored. iHuman Whether the gibs should be human (1) or alien (0).
1.18 SpawnStickyGibs
void SpawnStickyGibs(entvars_t@ pevVictim, const Vector& in vecOrigin, int cGibs) Spawns sticky gibs for the target victim.
Argument Purpose pevVictim Entity to spawn gibs for. vecOrigin Origin in the world to spawn the gibs at. cGibs Number of gibs to spawn. SetOrigin void SetOrigin(CBaseEntity@ entity, const Vector& in vecOrigin) Sets the origin of an entity.
1.19 EjectBrass
void EjectBrass(const Vector& in vecOrigin, const Vector& in vecVelocity, float flRotation, int iModel, TE_BOUNCE soundtype) Tosses a brass shell from passed origin at passed velocity.
1.20 SetModel
void SetModel(CBaseEntity@ entity, const string& in szFileName) Sets the model of an entity. Also sets the entity's bounds (entvars_t::mins and entvars_t::maxs). Call SetSize after this if you need to change the entity's bounds.
1.21 SetSize
void SetSize(entvars_t@ pev, const Vector& in vecMin, const Vector& in vecMax) Sets the size of an entity.
Argument Purpose pev Entity whose bounds will be set. vecMin Minimum bounds to set. vecMax Maximum bounds to set.
2 Finder Methods
2.1 FindEntityInSphere
CBaseEntity@ FindEntityInSphere(CBaseEntity@ pStartEntity, const Vector& in vecCenter, float flRadius, const string& in szValue = "", const string& in szKeyword = "targetname") Finds an entity in a sphere. You can optionally filter by keyvalue.
Argument Purpose pStartEntity if null, finds the first entity in the given sphere. Otherwise, finds the next entity after the given entity that is in the sphere. vecCenter Sphere center. flRadius Sphere radius. szValue Value to filter by. szKeyword Key to filter by. Returns the next entity, or null.
2.2 FindEntityByString
CBaseEntity@ FindEntityByString(CBaseEntity@ pStartEntity, const string& in szKeyword, const string& in szValue) Finds an entity based on a key value pair.
Argument Purpose pStartEntity if null, finds the first entity that matches the keyvalue pair. Otherwise, finds the next entity after the given entity. szKeyword Key to filter by. szValue Value to filter by. Returns the next entity, or null.
2.3 FindEntityByClassname
CBaseEntity@ FindEntityByClassname(CBaseEntity@ startEntity, const string& in name) Finds an entity by class name.
Argument Purpose pStartEntity if null, finds the first entity with the given classname. Otherwise, finds the next entity after the given entity. name Classname to filter by. Returns the next entity, or null.
2.4 FindEntityTargetname
CBaseEntity@ FindEntityByTargetname(CBaseEntity@ startEntity, const string& in name) Finds an entity by target name.
Argument Purpose pStartEntity if null, finds the first entity with the given targetname. Otherwise, finds the next entity after the given entity. name Targetname to filter by. Returns the next entity, or null.
2.5 FindEntityGeneric
CBaseEntity@ FindEntityGeneric(const string& in szName, const Vector& in vecSrc, float flRadius) Finds an entity by target name in a sphere.
Argument Purpose szName Targetname to filter by. vecSrc Sphere center. flRadius Sphere radius. Returns the first entity it finds, or null.
2.6 MonstersInSphere
int MonstersInSphere(array<CBaseEntity@>@ pArray, const Vector& in vecCenter, float flRadius) Finds monsters in a sphere.
Argument Purpose pArray Array of entity handles. This array must be resized to the maximum number of entities you wish to find. vecCenter Sphere center. flRadius Sphere radius. Returns the number of entities it found.
2.7 EntitiesInBox
int EntitiesInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs, int flagMask) Finds entities in a box.
Argument Purpose pArray Array of entity handles. This array must be resized to the maximum number of entities you wish to find. mins Minimum bounds. maxs Maximum bounds. flagMask Bit vector containing EdictFlags constants. Ignored if 0, if an entity does not have any of the flags contained in this mask, it is not added to the list. Returns the number of entities it found.
2.8 TargetsInBox
int TargetsInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs) Finds targets in a box. Anything that could be a target for a monster, like clients, monsters, or brush entities are considered.
Argument Purpose pArray Array of entity handles. This array must be resized to the maximum number of entities you wish to find. mins Minimum bounds. maxs Maximum bounds. Returns the number of entities it found.
2.9 BrushEntsInBox
int BrushEntsInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs) Finds brush entities in a box.
Argument Purpose pArray Array of entity handles. This array must be resized to the maximum number of entities you wish to find. mins Minimum bounds. maxs Maximum bounds. Returns the number of entities it found.
2.10 RandomTargetname
CBaseEntity@ RandomTargetname(const string& in szTargetname) Returns a randomly selected entity that has the given target name.
3 Misc
3.1 DispatchSpawn
int DispatchSpawn(edict_t@ entity) Dispatches the spawning of an entity.
Returns 0 if the entity was successfully spawned, -1 if it has been/should be deleted.
3.2 DispatchKeyValue
bool DispatchKeyValue(edict_t@ entity, const string& in szKeyName, const string& in szValue) Dispatches the passing of a key value pair to an entity.
3.3 EntvarsKeyvalue
bool EntvarsKeyvalue(edict_t@ entity, const string& in szKeyName, const string& in szValue) Handles the initialization of keyvalues located in the entity's entvars_t object.
Argument Purpose entity Entity to initialize a keyvalue for. szKeyName Key to initialize. szValue Value to initialize with. Returns true if the key existed and was initialized.
3.4 DispatchObjectCollisionBox
void DispatchObjectCollisionBox(edict_t@ entity) Dispatches the initialization of the collision box of an entity.
3.5 Instance
CBaseEntity@ Instance(edict_t@ edict) Gets the entity instance of an edict instance.
CBaseEntity@ Instance(entvars_t@ vars) Gets the entity instance of an entvars instance.
CBaseEntity@ Instance(int iEdictNum) Gets the entity instance based on an edict number.
3.6 FireTargets
void FireTargets(const string& in szTargetName, CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue = 0.0f, float flDelay = 0.0f) Triggers targets. If flDelay is nonzero, causes a temporary entity to be spawned to trigger the target at the given time. The temporary entity becomes the caller, not the entity passed in.
Argument Purpose szTargetName Name of the target(s) to trigger. pActivator Activator to pass to the target(s). pCaller Current caller. If flDelay is 0, this will become the caller for the target(s). useType Use type to pass to the target(s). flValue Value to pass to the target(s). flDelay Delay before fire. IsMasterTriggered bool IsMasterTriggered(const string& in szMaster, CBaseEntity@ pActivator) Returns whether the master with the given name would be triggered if activated by the given entity.
3.7 Remove
void Remove(CBaseEntity@ pEntity) Removes the given entity before the next frame starts.
3.8 IsValidEntity
bool IsValidEntity(edict_t@ pEntity) Returns whether this is a valid entity.
3.9 EntIndex
int EntIndex(edict_t@ pEdict) Gets the index for the given edict.
3.10 IndexEnt
edict_t@ IndexEnt(int iEdictNum) Gets the edict for the given index.
Argument Purpose vecOrigin Origin in the world to place the shell at. vecVelocity Direction and speed of the shell. flRotation Initial yaw rotation. iModel Index of the model to use. soundtype Sound type to use. See the TE_BOUNCE enum. CastToScriptClass ScriptClassInterface@ CastToScriptClass(CBaseEntity@ pEntity) Casts an CBaseEntity@ representing a custom entity to the ScriptClassBaseClass type.
3.11 PrecacheMaterialSounds
void PrecacheMaterialSounds(const Materials material) Precaches the sounds used by a particular material. See the Materials enum.