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) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
HTML documentation can be found here. | HTML documentation can be found here. | ||
− | A single global instance exists: | + | A single global instance exists: <code>CEntityFuncs g_EntityFuncs;</code> |
− | + | === 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> | ||
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. | 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. | ||
− | + | ||
− | szClassName Class name of the entity to create. | + | * szClassName Class name of the entity to create. |
− | pDictionary Dictionary of keyvalues to initialize the entity with. | + | * pDictionary Dictionary of keyvalues to initialize the entity with. |
− | fSpawn Whether or not to call DispatchSpawn on the entity. | + | * fSpawn Whether or not to call DispatchSpawn on the entity. |
===== Create ===== | ===== Create ===== | ||
<nowiki>CBaseEntity@ Create(const string& in szClassname, const Vector& in vecOrigin, const Vector& in vecAngles, bool fCreateAndDontSpawn, edict_t@ entOwner = null)</nowiki> | <nowiki>CBaseEntity@ Create(const string& in szClassname, const Vector& in vecOrigin, const Vector& in vecAngles, bool fCreateAndDontSpawn, edict_t@ entOwner = null)</nowiki> | ||
− | Creates an entity by class name. | + | Creates an entity by class name. Returns the entity on success, false otherwise. |
− | + | * <code>szClassName</code>: Class name of the entity to create. | |
− | szClassName Class name of the entity to create. | + | * <code>vecOrigin</code>: Origin in the world to place the entity. |
− | vecOrigin Origin in the world to place the entity. | + | * <code>vecAngles</code>: Angles to set on the entity. |
− | vecAngles Angles to set on the entity. | + | * <code>fCreateAndDontSpawn</code>: If true, creates the entity but does not call DispatchSpawn on it. |
− | fCreateAndDontSpawn If true, creates the entity but does not call DispatchSpawn on it. | + | * <code>entOwner</code>: Entity that owns this entity. |
− | entOwner Entity that owns this entity | ||
− | |||
===== CreateDecal ===== | ===== CreateDecal ===== | ||
− | void CreateDecal(const string& in szDecalName, const Vector& in vecOrigin, const string& in szTargetName = "") | + | <nowiki>void CreateDecal(const string& in szDecalName, const Vector& in vecOrigin, const string& in szTargetName = "")</nowiki> |
Creates a decal with the specified name. Creating a decal with no name will only work correctly if done at map spawn time. | Creates a decal with the specified name. Creating a decal with no name will only work correctly if done at map spawn time. | ||
− | + | * <code>szDecalName</code>: Name of the decal texture. | |
− | szDecalName Name of the decal texture. | + | * <code>vecOrigin</code>: Origin in the world to place the decal. |
− | vecOrigin Origin in the world to place the decal. | + | * <code>szTargetName</code>: If not empty, the decal will not be applied immediately, but instead will be applied when triggered. |
− | szTargetName If not empty, the decal will not be applied immediately, but instead will be applied when triggered. | ||
===== CreateSprite ===== | ===== CreateSprite ===== | ||
− | CSprite@ CreateSprite(const string& in szSpriteName, const Vector& in vecOrigin, bool fAnimated, float flFrameRate = 10.0f) | + | <nowiki>CSprite@ CreateSprite(const string& in szSpriteName, const Vector& in vecOrigin, bool fAnimated, float flFrameRate = 10.0f)</nowiki> |
Creates a sprite. flFrameRate must be set to a valid value to animate the sprite. | Creates a sprite. flFrameRate must be set to a valid value to animate the sprite. | ||
− | + | * <code>szSpriteName</code>: Name of the sprite file to use. Must be precached. | |
− | szSpriteName Name of the sprite file to use. Must be precached. | + | * <code>vecOrigin</code>: Location in the world to place the sprite at. |
− | vecOrigin Location in the world to place the sprite at. | + | * <code>fAnimated</code>: If true, the sprite is animated. |
− | fAnimated If true, the sprite is animated. | + | * <code>flFrameRate</code>: Framerate for animated sprites. |
− | flFrameRate Framerate for animated sprites. | ||
Returns the sprite on success, null otherwise. | Returns the sprite on success, null otherwise. | ||
===== CreateBeam ===== | ===== CreateBeam ===== | ||
− | CBeam@ CreateBeam(const string& in szSpriteName, int width) | + | <nowiki>CBeam@ CreateBeam(const string& in szSpriteName, int width)</nowiki> |
Creates a beam entity with the given sprite and width set. | Creates a beam entity with the given sprite and width set. | ||
+ | Returns the beam on success, null otherwise. | ||
− | + | * szSpriteName Name of the sprite file to use. Must be precached. | |
− | szSpriteName Name of the sprite file to use. Must be precached. | + | * width Width of the beam in units. |
− | width Width of the beam in units | ||
− | |||
===== CreateExplosion ===== | ===== CreateExplosion ===== | ||
− | void CreateExplosion(const Vector& in vecCenter, const Vector& in vecAngles, edict_t@ pOwner, int iMagnitude, bool fDoDamage) | + | <nowiki>void CreateExplosion(const Vector& in vecCenter, const Vector& in vecAngles, edict_t@ pOwner, int iMagnitude, bool fDoDamage)</nowiki> |
Creates an explosion. | Creates an explosion. | ||
− | + | ||
− | vecCenter Center point of the explosion. | + | * vecCenter Center point of the explosion. |
− | vecAngles Angles of the explosion entity. | + | * vecAngles Angles of the explosion entity. |
− | pOwner Owner of the explosion. | + | * pOwner Owner of the explosion. |
− | iMagnitude Damage and radius of the explosion. Radius is 2.5 times the amount of damage. | + | * 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. | + | * fDoDamage Whether to do damage or not. Explosions that deal no damage will be a visual effect only. |
===== CreateDisplacerPortal ===== | ===== CreateDisplacerPortal ===== | ||
− | CBaseEntity@ CreateDisplacerPortal(const Vector& in vecOrigin, const Vector& in vecVelocity, edict_t@ pOwner, float flDamage, float flRadius) | + | <nowiki>CBaseEntity@ CreateDisplacerPortal(const Vector& in vecOrigin, const Vector& in vecVelocity, edict_t@ pOwner, float flDamage, float flRadius)</nowiki> |
Creates a displacer portal. | Creates a displacer portal. | ||
Line 80: | Line 73: | ||
===== CreateRPGRocket ===== | ===== CreateRPGRocket ===== | ||
− | CBaseEntity@ CreateRPGRocket(const Vector& in vecOrigin, const Vector& in vecAngles, edict_t@ pOwner) | + | <nowiki>CBaseEntity@ CreateRPGRocket(const Vector& in vecOrigin, const Vector& in vecAngles, edict_t@ pOwner)</nowiki> |
Creates an rpg rocket. | Creates an rpg rocket. | ||
Line 90: | Line 83: | ||
===== CreateRPGRocket ===== | ===== CreateRPGRocket ===== | ||
− | CBaseEntity@ CreateRPGRocket(const Vector& in vecOrigin, const Vector& in vecAngles, const Vector& in vecVelocity, edict_t@ pOwner) | + | <nowiki>CBaseEntity@ CreateRPGRocket(const Vector& in vecOrigin, const Vector& in vecAngles, const Vector& in vecVelocity, edict_t@ pOwner)</nowiki> |
Creates an rpg rocket with custom velocity. | Creates an rpg rocket with custom velocity. | ||
Line 103: | Line 96: | ||
===== CreateGib ===== | ===== CreateGib ===== | ||
− | CGib@ CreateGib( const Vector& in vecOrigin, const Vector& in vecAngles) | + | <pre>CGib@ CreateGib( const Vector& in vecOrigin, const Vector& in vecAngles)</pre> |
Creates a server side gib. | Creates a server side gib. | ||
===== ShootTimed ===== | ===== ShootTimed ===== | ||
− | CGrenade@ ShootTimed(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity, float flTime) | + | <nowiki>CGrenade@ ShootTimed(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity, float flTime)</nowiki> |
Spawns a timed (hand) grenade. | Spawns a timed (hand) grenade. | ||
Line 118: | Line 111: | ||
===== ShootContact ===== | ===== ShootContact ===== | ||
− | CGrenade@ ShootContact(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity) | + | <nowiki>CGrenade@ ShootContact(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity)</nowiki> |
Spawns a contact (AR) grenade. | Spawns a contact (AR) grenade. | ||
Line 128: | Line 121: | ||
===== ShootMortar ===== | ===== ShootMortar ===== | ||
− | CGrenade@ ShootMortar(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity) | + | <nowiki>CGrenade@ ShootMortar(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity)</nowiki> |
Spawns a mortar grenade. | Spawns a mortar grenade. | ||
Line 138: | Line 131: | ||
===== ShootBananaCluster ===== | ===== ShootBananaCluster ===== | ||
− | CGrenade@ ShootBananaCluster(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity) | + | <nowiki>CGrenade@ ShootBananaCluster(entvars_t@ pevOwner, const Vector& in vecStart, const Vector& in vecVelocity)</nowiki> |
Spawn a banana bomb. | Spawn a banana bomb. | ||
Line 148: | Line 141: | ||
===== UseSatchelCharges ===== | ===== UseSatchelCharges ===== | ||
− | void UseSatchelCharges(entvars_t@ pevOwner, SATCHELCODE code) | + | <nowiki>void UseSatchelCharges(entvars_t@ pevOwner, SATCHELCODE code)</nowiki> |
Triggers all satchel charges owned by pevOwner to either be released from ownership, or detonated. | Triggers all satchel charges owned by pevOwner to either be released from ownership, or detonated. | ||
Line 154: | Line 147: | ||
===== SpawnHeadGib ===== | ===== SpawnHeadGib ===== | ||
− | void SpawnHeadGib(entvars_t@ pevVictim) | + | <nowiki>void SpawnHeadGib(entvars_t@ pevVictim)</nowiki> |
Spawns a head gib for the target victim. | Spawns a head gib for the target victim. | ||
===== SpawnRandomGibs ===== | ===== SpawnRandomGibs ===== | ||
− | void SpawnRandomGibs(entvars_t@ pevVictim, int cGibs, int iHuman) | + | <nowiki>void SpawnRandomGibs(entvars_t@ pevVictim, int cGibs, int iHuman)</nowiki> |
Spawns random gibs for the target victim. | Spawns random gibs for the target victim. | ||
Line 167: | Line 160: | ||
===== SpawnStickyGibs ===== | ===== SpawnStickyGibs ===== | ||
− | void SpawnStickyGibs(entvars_t@ pevVictim, const Vector& in vecOrigin, int cGibs) | + | <nowiki>void SpawnStickyGibs(entvars_t@ pevVictim, const Vector& in vecOrigin, int cGibs)</nowiki> |
Spawns sticky gibs for the target victim. | Spawns sticky gibs for the target victim. | ||
Line 178: | Line 171: | ||
Sets the origin of an entity. | Sets the origin of an entity. | ||
− | ===== | + | ===== EjectBrass ===== |
− | void | + | <nowiki>void EjectBrass(const Vector& in vecOrigin, const Vector& in vecVelocity, float flRotation, int iModel, TE_BOUNCE soundtype)</nowiki> |
− | + | Tosses a brass shell from passed origin at passed velocity. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | === Finder Methods === | ||
===== FindEntityInSphere ===== | ===== FindEntityInSphere ===== | ||
− | CBaseEntity@ FindEntityInSphere(CBaseEntity@ pStartEntity, const Vector& in vecCenter, float flRadius, const string& in szValue = "", const string& in szKeyword = "targetname") | + | <nowiki>CBaseEntity@ FindEntityInSphere(CBaseEntity@ pStartEntity, const Vector& in vecCenter, float flRadius, const string& in szValue = "", const string& in szKeyword = "targetname")</nowiki> |
Finds an entity in a sphere. You can optionally filter by keyvalue. | Finds an entity in a sphere. You can optionally filter by keyvalue. | ||
Line 204: | Line 189: | ||
===== FindEntityByString ===== | ===== FindEntityByString ===== | ||
− | CBaseEntity@ FindEntityByString(CBaseEntity@ pStartEntity, const string& in szKeyword, const string& in szValue) | + | <nowiki>CBaseEntity@ FindEntityByString(CBaseEntity@ pStartEntity, const string& in szKeyword, const string& in szValue)</nowiki> |
Finds an entity based on a key value pair. | Finds an entity based on a key value pair. | ||
Line 214: | Line 199: | ||
===== FindEntityByClassname ===== | ===== FindEntityByClassname ===== | ||
− | CBaseEntity@ FindEntityByClassname(CBaseEntity@ startEntity, const string& in name) | + | <nowiki>CBaseEntity@ FindEntityByClassname(CBaseEntity@ startEntity, const string& in name)</nowiki> |
Finds an entity by class name. | Finds an entity by class name. | ||
Line 223: | Line 208: | ||
===== FindEntityTargetname ===== | ===== FindEntityTargetname ===== | ||
− | CBaseEntity@ FindEntityByTargetname(CBaseEntity@ startEntity, const string& in name) | + | <nowiki>CBaseEntity@ FindEntityByTargetname(CBaseEntity@ startEntity, const string& in name)</nowiki> |
Finds an entity by target name. | Finds an entity by target name. | ||
Line 232: | Line 217: | ||
===== FindEntityGeneric ===== | ===== FindEntityGeneric ===== | ||
− | CBaseEntity@ FindEntityGeneric(const string& in szName, const Vector& in vecSrc, float flRadius) | + | <nowiki>CBaseEntity@ FindEntityGeneric(const string& in szName, const Vector& in vecSrc, float flRadius)</nowiki> |
Finds an entity by target name in a sphere. | Finds an entity by target name in a sphere. | ||
Line 242: | Line 227: | ||
===== MonstersInSphere ===== | ===== MonstersInSphere ===== | ||
− | int MonstersInSphere(array<CBaseEntity@>@ pArray, const Vector& in vecCenter, float flRadius) | + | <nowiki>int MonstersInSphere(array<CBaseEntity@>@ pArray, const Vector& in vecCenter, float flRadius)</nowiki> |
Finds monsters in a sphere. | Finds monsters in a sphere. | ||
Line 252: | Line 237: | ||
===== EntitiesInBox ===== | ===== EntitiesInBox ===== | ||
− | int EntitiesInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs, int flagMask) | + | <nowiki>int EntitiesInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs, int flagMask)</nowiki> |
Finds entities in a box. | Finds entities in a box. | ||
Line 263: | Line 248: | ||
===== TargetsInBox ===== | ===== TargetsInBox ===== | ||
− | int TargetsInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs) | + | <nowiki>int TargetsInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs)</nowiki> |
Finds targets in a box. Anything that could be a target for a monster, like clients, monsters, or brush entities are considered. | Finds targets in a box. Anything that could be a target for a monster, like clients, monsters, or brush entities are considered. | ||
Line 273: | Line 258: | ||
===== BrushEntsInBox ===== | ===== BrushEntsInBox ===== | ||
− | int BrushEntsInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs) | + | <nowiki>int BrushEntsInBox(array<CBaseEntity@>@ pArray, const Vector& in mins, const Vector& in maxs)</nowiki> |
Finds brush entities in a box. | Finds brush entities in a box. | ||
Line 281: | Line 266: | ||
maxs Maximum bounds. | maxs Maximum bounds. | ||
Returns the number of entities it found. | Returns the number of entities it found. | ||
+ | |||
+ | ===== RandomTargetname ===== | ||
+ | <nowiki>CBaseEntity@ RandomTargetname(const string& in szTargetname)</nowiki> | ||
+ | Returns a randomly selected entity that has the given target name. | ||
+ | |||
+ | === Misc === | ||
+ | ===== SetModel ===== | ||
+ | <nowiki>void SetModel(CBaseEntity@ entity, const string& in szFileName)</nowiki> | ||
+ | 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. | ||
+ | |||
+ | ===== SetSize ===== | ||
+ | <nowiki>void SetSize(entvars_t@ pev, const Vector& in vecMin, const Vector& in vecMax)</nowiki> | ||
+ | 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. | ||
===== DispatchSpawn ===== | ===== DispatchSpawn ===== | ||
− | int DispatchSpawn(edict_t@ entity) | + | <nowiki>int DispatchSpawn(edict_t@ entity)</nowiki> |
Dispatches the spawning of an entity. | Dispatches the spawning of an entity. | ||
Line 289: | Line 292: | ||
===== DispatchKeyValue ===== | ===== DispatchKeyValue ===== | ||
− | bool DispatchKeyValue(edict_t@ entity, const string& in szKeyName, const string& in szValue) | + | <nowiki>bool DispatchKeyValue(edict_t@ entity, const string& in szKeyName, const string& in szValue)</nowiki> |
Dispatches the passing of a key value pair to an entity. | Dispatches the passing of a key value pair to an entity. | ||
===== EntvarsKeyvalue ===== | ===== EntvarsKeyvalue ===== | ||
− | bool EntvarsKeyvalue(edict_t@ entity, const string& in szKeyName, const string& in szValue) | + | <nowiki>bool EntvarsKeyvalue(edict_t@ entity, const string& in szKeyName, const string& in szValue)</nowiki> |
Handles the initialization of keyvalues located in the entity's entvars_t object. | Handles the initialization of keyvalues located in the entity's entvars_t object. | ||
Line 303: | Line 306: | ||
===== DispatchObjectCollisionBox ===== | ===== DispatchObjectCollisionBox ===== | ||
− | void DispatchObjectCollisionBox(edict_t@ entity) | + | <nowiki>void DispatchObjectCollisionBox(edict_t@ entity)</nowiki> |
Dispatches the initialization of the collision box of an entity. | Dispatches the initialization of the collision box of an entity. | ||
===== Instance ===== | ===== Instance ===== | ||
− | CBaseEntity@ Instance(edict_t@ edict) | + | <nowiki>CBaseEntity@ Instance(edict_t@ edict)</nowiki> |
Gets the entity instance of an edict instance. | Gets the entity instance of an edict instance. | ||
− | CBaseEntity@ Instance(entvars_t@ vars) | + | <nowiki>CBaseEntity@ Instance(entvars_t@ vars)</nowiki> |
Gets the entity instance of an entvars instance. | Gets the entity instance of an entvars instance. | ||
− | CBaseEntity@ Instance(int iEdictNum) | + | <nowiki>CBaseEntity@ Instance(int iEdictNum)</nowiki> |
Gets the entity instance based on an edict number. | Gets the entity instance based on an edict number. | ||
===== FireTargets ===== | ===== FireTargets ===== | ||
− | void FireTargets(const string& in szTargetName, CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue = 0.0f, float flDelay = 0.0f) | + | <nowiki>void FireTargets(const string& in szTargetName, CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue = 0.0f, float flDelay = 0.0f)</nowiki> |
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. | 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. | ||
Line 332: | Line 335: | ||
===== Remove ===== | ===== Remove ===== | ||
− | void Remove(CBaseEntity@ pEntity) | + | <nowiki>void Remove(CBaseEntity@ pEntity)</nowiki> |
Removes the given entity before the next frame starts. | Removes the given entity before the next frame starts. | ||
===== IsValidEntity ===== | ===== IsValidEntity ===== | ||
− | bool IsValidEntity(edict_t@ pEntity) | + | <nowiki>bool IsValidEntity(edict_t@ pEntity)</nowiki> |
Returns whether this is a valid entity. | Returns whether this is a valid entity. | ||
===== EntIndex ===== | ===== EntIndex ===== | ||
− | int EntIndex(edict_t@ pEdict) | + | <nowiki>int EntIndex(edict_t@ pEdict)</nowiki> |
Gets the index for the given edict. | Gets the index for the given edict. | ||
===== IndexEnt ===== | ===== IndexEnt ===== | ||
− | edict_t@ IndexEnt(int iEdictNum) | + | <nowiki>edict_t@ IndexEnt(int iEdictNum)</nowiki> |
Gets the edict for the given index. | Gets the edict for the given index. | ||
− | |||
− | |||
− | |||
− | |||
Argument Purpose | Argument Purpose | ||
Line 357: | Line 356: | ||
iModel Index of the model to use. | iModel Index of the model to use. | ||
soundtype Sound type to use. See the TE_BOUNCE enum. | soundtype Sound type to use. See the TE_BOUNCE enum. | ||
+ | |||
CastToScriptClass | CastToScriptClass | ||
− | ScriptClassInterface@ CastToScriptClass(CBaseEntity@ pEntity) | + | |
+ | <nowiki>ScriptClassInterface@ CastToScriptClass(CBaseEntity@ pEntity)</nowiki> | ||
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) | + | <nowiki>void PrecacheMaterialSounds(const Materials material)</nowiki> |
Precaches the sounds used by a particular material. See the Materials enum. | Precaches the sounds used by a particular material. See the Materials enum. | ||
+ | [[Category:Scripting]] |
Latest revision as of 10:25, 30 March 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.
- 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. Returns the entity on success, false otherwise.
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.
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.
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.
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. Returns the beam on success, null otherwise.
- szSpriteName Name of the sprite file to use. Must be precached.
- width Width of the beam in units.
1.6 CreateExplosion
void CreateExplosion(const Vector& in vecCenter, const Vector& in vecAngles, edict_t@ pOwner, int iMagnitude, bool fDoDamage)
Creates an explosion.
- 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.
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 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.
3.2 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.
3.3 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.4 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.5 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.6 DispatchObjectCollisionBox
void DispatchObjectCollisionBox(edict_t@ entity)
Dispatches the initialization of the collision box of an entity.
3.7 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.8 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.9 Remove
void Remove(CBaseEntity@ pEntity)
Removes the given entity before the next frame starts.
3.10 IsValidEntity
bool IsValidEntity(edict_t@ pEntity)
Returns whether this is a valid entity.
3.11 EntIndex
int EntIndex(edict_t@ pEdict)
Gets the index for the given edict.
3.12 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.13 PrecacheMaterialSounds
void PrecacheMaterialSounds(const Materials material)
Precaches the sounds used by a particular material. See the Materials enum.