Angelscript Entity Utils

Sam edited this page Nov 5, 2016 · 2 revisions

The Entity namespace provides a number of utility functions and constants that relate to entities.

Functions

CBaseEntity@ Create(const string& in szClassname, const Vector& in vecOrigin, const Vector& in vecAngles, CBaseEntity@ pOwner = null, const bool bSpawnEntity = true)

Creates a new entity.

Parameter Description
szClassname Name of the entity to create
vecOrigin Origin in the world to place the entity at
vecAngles Rotation to set on the entity
pOwner Optional. The owner of this entity
bSpawnEntity Optional. Whether to call Spawn on the entity

Return value: If the entity was created, the entity. Otherwise, null.

CBaseEntity@ FindEntityByClassname(CBaseEntity@ pStartEntity, const string& in szClassname)

Finds an entity by its classname.

Parameter Description
pStartEntity Entity to start searching after. If null, starts from the beginning of the list of entities
szClassname Classname to search for

Return value: If found, the next entity that has the given classname. Otherwise, null.

CBaseEntity@ FindEntityByTargetname(CBaseEntity@ pStartEntity, const string& in szTargetname)

Finds an entity by its targetname.

Parameter Description
pStartEntity Entity to start searching after. If null, starts from the beginning of the list of entities
szTargetname Targetname to search for

Return value: If found, the next entity that has the given targetname. Otherwise, null.

CBaseEntity@ FindEntityByTarget(CBaseEntity@ pStartEntity, const string& in szTarget)

Finds an entity by its target.

Parameter Description
pStartEntity Entity to start searching after. If null, starts from the beginning of the list of entities
szTarget Target to search for

Return value: If found, the next entity that has the given target. Otherwise, null.

CBaseEntity@ FindEntityByString(CBaseEntity@ pStartEntity, const string& in szKeyword, const string& in szValue)

Finds an entity by matching a string. The keyword specifies an entity key whose value will be compared with the given value. The key specified by the keyword must be a string.

Parameter Description
pStartEntity Entity to start searching after. If null, starts from the beginning of the list of entities
szKeyword Key name whose value will be compared
szValue Value to compare with

Return value: If found, the next entity that has the given string value. Otherwise, null.

CBaseEntity@ FindEntityInSphere(CBaseEntity@ pStartEntity, const Vector& in vecSrc, const float flRadius)

Finds an entity whose bounds are within the given sphere's radius.

Parameter Description
pStartEntity Entity to start searching after. If null, starts from the beginning of the list of entities
vecSrc Center point of the sphere in the world
flRadius Sphere radius. Can be negative, will be made absolute

Return value: If found, the next entity that is within the sphere's radius. Otherwise, null.

CBaseEntity@ FindEntityGeneric(const string& in szName, const Vector& in vecSrc, const float flRadius)

Finds an entity whose targetname is the given name, or if no such entity could be found, searches for the first entity whose classname matches the given name and whose origin is within flRadius distance of the given position in the world.

Parameter Description
szName Entity to start searching after. If null, starts from the beginning of the list of entities
vecSrc Center point of the sphere in the world
flRadius Sphere radius. Can be negative, will be made absolute

Return value: If found, the entity that matches the given conditions. Otherwise, null.

CBaseEntity@ FindEntityForward(CBaseEntity@ pMe)

Finds the entity that the given entity is looking at. Modifies Globals vectors.

Parameter Description
pMe Entity whose view angles should be used to determine which entity it is looking at

Return value: If found, the entity that is being looked at. Otherwise, null.

CBaseEntity@ FindEntitiesInPVS(CBaseEntity@ pEntity)

Finds all entities that are in the PVS of the given entity. The entities are stored in a temporary list accessible through CBaseEntity::GetChain

Parameter Description
pEntity Entity to use for PVS testing

Return value: First entity in the chain of entities that are visible, or worldspawn if no entities are visible.

void Remove(CBaseEntity@ pEntity)

Flags the given entity for removal. The entity will be removed by the engine at a later point in time.

Parameter Description
pEntity Entity to remove

void MakeStatic(CBaseEntity@ pEntity)

Makes an entity static. Static entities are copied to the client side (visually only) and are removed on the server side. Only valid during map spawn.

The entity is removed right away, and can no longer be safely accessed.

Parameter Description
pEntity Entity to make static

bool EntIsOnFloor(CBaseEntity@ pEntity)

Checks whether the given entity is on the floor.

Parameter Description
pEntity Entity to check

Return value: Whether the given entity is on the floor.

DropToFloor::DropToFloor DropToFloor(CBaseEntity@ pEntity)

Drops the entity to the floor. The entity will be moved down to the floor, effectively being teleported.

Note: maximum drop distance is 256 units. If the floor is further than that away, the entity will not be moved.

Parameter Description
pEntity Entity to drop

Return value: DropToFloor::STUCK if the entity is stuck inside a solid object. DropToFloor::TOOFAR if the floor is further than 256 units away. DropToFloor::DROPPED if the entity was dropped to the floor.

bool WalkMove(CBaseEntity@ pEntity, float flYaw, float flDist, WalkMove::WalkMove mode)

Makes the entity walk.

The entity must be capable of flying (FL_FLY) or swimming (FL_SWIM), or be on the ground (FL_ONGROUND).

Parameter Description
pEntity Entity to move
flYaw Yaw distance. This is the entity's current movement direction in the XY plane
flDist Distance to move, in units
mode Movement type

Return value: true if the move succeeded (no obstacles in the way), false otherwise.

CBaseEntity@ EntityFromIndex(const int iIndex)

Gets the entity at the given entity index.

Parameter Description
iIndex Index of the entity to retrieve

Return value: If the index is valid, the entity at that index. Otherwise, null.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.