EntityFuncs - baso88/SC_AngelScript GitHub Wiki
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;
Methods
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. |
Returns the entity on success, false otherwise.
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.
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. |
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.
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.
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. |
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.
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.
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.
CreateGib
CGib@ CreateGib( const Vector& in vecOrigin, const Vector& in vecAngles)
Creates a server side gib.
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.
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.
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.
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.
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.
SpawnHeadGib
void SpawnHeadGib(entvars_t@ pevVictim)
Spawns a head gib for the target victim.
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). |
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.
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.
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. |
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
DispatchObjectCollisionBox
void DispatchObjectCollisionBox(edict_t@ entity)
Dispatches the initialization of the collision box of an entity.
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.
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.
Remove
void Remove(CBaseEntity@ pEntity)
Removes the given entity before the next frame starts.
IsValidEntity
bool IsValidEntity(edict_t@ pEntity)
Returns whether this is a valid entity.
EntIndex
int EntIndex(edict_t@ pEdict)
Gets the index for the given edict.
IndexEnt
edict_t@ IndexEnt(int iEdictNum)
Gets the edict for the given index.
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.
| 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.
RandomTargetname
CBaseEntity@ RandomTargetname(const string& in szTargetname)
Returns a randomly selected entity that has the given target name.
PrecacheMaterialSounds
void PrecacheMaterialSounds(const Materials material)
Precaches the sounds used by a particular material. See the Materials enum.