Skip to content

Scripting Entities

Dreamy Cecil edited this page Oct 25, 2026 · 1 revision

Constants

  • RT enum - Possible render types of entities:

    • RT.ILLEGAL
    • RT.NONE
    • RT.MODEL - Model entities (e.g. CModelHolder2, all the vanilla enemies).
    • RT.BRUSH - World geometry (e.g. CWorldBase).
    • RT.EDITORMODEL - Model entities only visible in the editor (e.g. CTrigger).
    • RT.VOID - Gameplay entity with no visual representation (e.g. CPlayerWeapons).
    • RT.FIELDBRUSH - Brushes only visible in the editor (e.g. CTouchField).
    • RT.SKAMODEL - Models with skeletal animations.
    • RT.SKAEDITORMODEL - Models with skeletal animations only visible in the editor.
    • RT.TERRAIN - 1.07+ terrains.
  • SPF enum - Spawn flags for entities:

    • SPF.EASY
    • SPF.NORMAL
    • SPF.HARD
    • SPF.EXTREME
    • SPF.TOURIST
    • SPF.MASK_DIFFICULTY - Mask containing difficulty flags above.
    • SPF.SINGLEPLAYER
    • SPF.DEATHMATCH
    • SPF.COOPERATIVE
    • SPF.FLYOVER
    • SPF.MASK_GAMEMODE - Mask containing gamemode flags above.
  • ENF enum - Generic flags of entities:

    • ENF.SELECTED
    • ENF.ZONING
    • ENF.DELETED
    • ENF.ALIVE
    • ENF.INRENDERING
    • ENF.VALIDSHADINGINFO
    • ENF.SEETHROUGH
    • ENF.FOUNDINGRIDSEARCH
    • ENF.CLUSTERSHADOWS
    • ENF.BACKGROUND
    • ENF.ANCHORED
    • ENF.HASPARTICLES
    • ENF.INVISIBLE
    • ENF.DYNAMICSHADOWS
    • ENF.NOTIFYLEVELCHANGE
    • ENF.CROSSESLEVELS
    • ENF.PREDICTABLE
    • ENF.PREDICTOR
    • ENF.PREDICTED
    • ENF.WILLBEPREDICTED
    • ENF.TEMPPREDICTOR
    • ENF.HIDDEN
    • ENF.NOSHADINGINFO
  • EPF enum - Physics flags of entities:

    • EPF.ORIENTEDBYGRAVITY
    • EPF.TRANSLATEDBYGRAVITY
    • EPF.PUSHABLE
    • EPF.STICKYFEET
    • EPF.RT_SYNCHRONIZED
    • EPF.ABSOLUTETRANSLATE
    • EPF.NOACCELERATION
    • EPF.HASLUNGS
    • EPF.HASGILLS
    • EPF.MOVABLE
    • EPF.NOIMPACT
    • EPF.NOIMPACTTHISTICK
    • EPF.CANFADESPINNING
    • EPF.ONSTEEPSLOPE
    • EPF.ORIENTINGTOGRAVITY
    • EPF.FLOATING
    • EPF.FORCEADDED
    • EPF.ONBLOCK_MASK - Mask for only one of the "on block" type values below.
    • EPF.ONBLOCK_STOP
    • EPF.ONBLOCK_SLIDE
    • EPF.ONBLOCK_CLIMBORSLIDE
    • EPF.ONBLOCK_BOUNCE
    • EPF.ONBLOCK_PUSH
    • EPF.ONBLOCK_STOPEXACT
  • ECB enum - Collision bits for the collision mask:

    • ECB.COUNT
    • ECB.IS
    • ECB.TEST
    • ECB.PASS
  • ECF enum - Collision flags of entities:

    • ECF.MASK
    • ECF.ISMASK
    • ECF.TESTMASK
    • ECF.PASSMASK
    • ECF.IGNOREBRUSHES
    • ECF.IGNOREMODELS
  • EPT enum - Types of entity properties:

    • EPT.ENUM - Same as EPT.INDEX but for specifying a value from a specific enum list.
    • EPT.BOOL - Boolean value that is either true or false.
    • EPT.FLOAT - Number with a fraction (single-precision floating point).
    • EPT.COLOR - Color in the 32-bit RGBA format.
    • EPT.STRING - String property.
    • EPT.RANGE - Same as EPT.FLOAT but for specifying radius.
    • EPT.ENTITYPTR - Pointer to another entity.
    • EPT.FILENAME - Path to a specific file.
    • EPT.INDEX - Signed 32-bit integer value.
    • EPT.ANIMATION - Same as EPT.INDEX but for specifying an animation index of some model.
    • EPT.ILLUMINATIONTYPE - Same as EPT.INDEX but for specifying illumination type for a light source.
    • EPT.FLOATAABBOX3D - Box areas.
    • EPT.ANGLE - Same as EPT.FLOAT but for specifying rotation angles.
    • EPT.FLOAT3D - Vector value for specifying a position in 3D space.
    • EPT.ANGLE3D - Same as EPT.FLOAT3D but for specifying Euler angles for rotation in 3D space.
    • EPT.FLOATplane3D - Plane normal definition.
    • EPT.MODELOBJECT - Vertex models.
    • EPT.PLACEMENT3D - Position and rotation in 3D space.
    • EPT.ANIMOBJECT - Generic animatable object.
    • EPT.FILENAMENODEP - Same as EPT.STRING but for specifying paths to files without explicit dependencies on them.
    • EPT.SOUNDOBJECT - Object for playing sounds in 3D space from that entity.
    • EPT.STRINGTRANS - Same as EPT.STRING but for translateable strings.
    • EPT.FLOATQUAT3D - Quaternion rotation.
    • EPT.FLOATMATRIX3D - Rotation matrix.
    • EPT.FLAGS - Same as EPT.INDEX but for specifying a bit mask of flags.
    • EPT.MODELINSTANCE - SKA models. Only starting with The Second Encounter v1.07.
  • EVENTCODE enum - Available entity events for CEntityEvent class setup:

    • EVENTCODE.EInternal - Internal entity event from the engine.
    • EVENTCODE.EVoid - Default dummy entity event.
    • EVENTCODE.EReturn - Internal entity event from the engine.
    • EVENTCODE.EBegin - Internal entity event from the engine.
    • EVENTCODE.ETimer - Internal entity event from the engine.
    • EVENTCODE.ETouch - Internal entity event from the engine; usually sent when CMovableEntity touches another entity in its way.
    • EVENTCODE.EPass - Internal entity event from the engine; usually sent when CMovableEntity passes through another entity in its way.
    • EVENTCODE.EBlock - Internal entity event from the engine; usually sent when CMovableEntity movement is blocked by some other entity in its way.
    • EVENTCODE.EWouldFall - Internal entity event from the engine.
    • EVENTCODE.ETeleport - Internal entity event from the engine.
    • EVENTCODE.EPreLevelChange - Internal entity event from the engine; sent to entities that carry over from one world to another before changing levels.
    • EVENTCODE.EPostLevelChange - Internal entity event from the engine; sent to entities that carry over from one world to another after changing levels.
    • EVENTCODE.EFirstWorldBase - Internal entity event from the engine.
    • EVENTCODE.EDamage - Internal entity event from the engine; usually sent when CEntity receives damage.
    • EVENTCODE.EDeath - Internal entity event from the engine; usually sent when CLiveEntity dies.
    • EVENTCODE.ETakingBreath - Internal entity event from the engine; usually sent when CMovableEntity enters a sector it can breathe in.
    • EVENTCODE.EStop - Generic entity event sent by CTrigger.
    • EVENTCODE.EStart - Generic entity event sent by CTrigger.
    • EVENTCODE.EActivate - Generic entity event sent by CTrigger.
    • EVENTCODE.EDeactivate - Generic entity event sent by CTrigger.
    • EVENTCODE.EEnvironmentStart - Generic entity event sent by CTrigger.
    • EVENTCODE.EEnvironmentStop - Generic entity event sent by CTrigger.
    • EVENTCODE.EEnd - Internal entity event.
    • EVENTCODE.ETrigger - Generic entity event sent by CTrigger.
    • EVENTCODE.ETeleportMovingBrush - Generic entity event sent by CTrigger.
    • EVENTCODE.EReminder - Internal entity event sent by CReminder.
    • EVENTCODE.EStartAttack - Generic entity event sent by CTrigger.
    • EVENTCODE.EStopAttack - Generic entity event sent by CTrigger.
    • EVENTCODE.EStopBlindness - Generic entity event sent by CTrigger.
    • EVENTCODE.EStopDeafness - Generic entity event sent by CTrigger.
    • EVENTCODE.EReceiveScore - For CPlayer.
    • EVENTCODE.EKilledEnemy - For CPlayer.
    • EVENTCODE.ESecretFound - For CPlayer.
    • EVENTCODE.ESound - For entities derived from CEnemyBase.
    • EVENTCODE.EScroll - For CPlayer.
    • EVENTCODE.ETextFX - For CPlayer.
    • EVENTCODE.EHudPicFX - For CPlayer.
    • EVENTCODE.ECredits - For CPlayer.
    • EVENTCODE.ECenterMessage - For CPlayer.
    • EVENTCODE.EComputerMessage - For CPlayer.
    • EVENTCODE.EVoiceMessage - For CPlayer.
    • EVENTCODE.EHitBySpaceShipBeam - For CPlayer.
    • EVENTCODE.EAmmoItem - For receiving ammo by the player.
    • EVENTCODE.EAmmoPackItem - For receiving ammo packs by the player.
    • EVENTCODE.EArmor - For receiving armor by the player.
    • EVENTCODE.EHealth - For receiving health by the player.
    • EVENTCODE.EKey - For receiving keys by the player.
    • EVENTCODE.EMessageItem - For receiving messages by the player.
    • EVENTCODE.EPowerUp - For receiving powerups by the player.
    • EVENTCODE.EWeaponItem - For receiving weapons by the player.
    • EVENTCODE.ERestartAttack - For entities derived from CEnemyBase.
    • EVENTCODE.EReconsiderBehavior - For entities derived from CEnemyBase.
    • EVENTCODE.EForceWound - For entities derived from CEnemyBase.
    • EVENTCODE.ESelectWeapon - For CPlayerWeapons.
    • EVENTCODE.EBoringWeapon - For CPlayerWeapons.
    • EVENTCODE.EFireWeapon - For CPlayerWeapons.
    • EVENTCODE.EReleaseWeapon - For CPlayerWeapons.
    • EVENTCODE.EReloadWeapon - For CPlayerWeapons.
    • EVENTCODE.EWeaponChanged - For CPlayerWeapons.
    • EVENTCODE.EAirShockwave - For initializing CAirShockwave entities.
    • EVENTCODE.EAirWave - For initializing CAirWave entities.
    • EVENTCODE.ESpawnEffect - For initializing CBasicEffect entities.
    • EVENTCODE.ESpawnSpray - For initializing CBloodSpray entities.
    • EVENTCODE.EBulletInit - For initializing CBullet entities.
    • EVENTCODE.ELaunchCannonBall - For initializing CCannonBall entities.
    • EVENTCODE.ECyborgBike - For initializing CCyborgBike entities.
    • EVENTCODE.ESpawnDebris - For initializing CDebris entities.
    • EVENTCODE.EDevilProjectile - For initializing CDevilProjectile entities.
    • EVENTCODE.ESpawnEffector - For initializing CEffector entities.
    • EVENTCODE.EFlame - For initializing CFlame entities.
    • EVENTCODE.ELaunchLarvaOffspring - For initializing CLarvaOffspring entities.
    • EVENTCODE.EAnimatorInit - For initializing CPlayerAnimator entities.
    • EVENTCODE.EViewInit - For initializing CPlayerView entities.
    • EVENTCODE.EWeaponsInit - For initializing CPlayerWeapons entities.
    • EVENTCODE.EWeaponEffectInit - For initializing CPlayerWeaponsEffect entities.
    • EVENTCODE.ELaunchProjectile - For initializing CProjectile entities.
    • EVENTCODE.EReminderInit - For initializing CReminder entities.
    • EVENTCODE.ESeriousBomb - For initializing CSeriousBomb entities.
    • EVENTCODE.ESpawnerProjectile - For initializing CSpawnerProjectile entities.
    • EVENTCODE.ESpinnerInit - For initializing CSpinner entities.
    • EVENTCODE.ETwister - For initializing CTwister entities.
    • EVENTCODE.EWatcherInit - For initializing CWatcher entities.
    • EVENTCODE.EWater - For initializing CWater entities.
  • DMT enum - Available damage types:

    • DMT.EXPLOSION
    • DMT.PROJECTILE
    • DMT.CLOSERANGE
    • DMT.BULLET
    • DMT.DROWNING
    • DMT.IMPACT
    • DMT.BRUSH
    • DMT.BURNING
    • DMT.ACID
    • DMT.TELEPORT
    • DMT.FREEZING
    • DMT.CANNONBALL
    • DMT.CANNONBALL_EXPLOSION
    • DMT.SPIKESTAB
    • DMT.ABYSS
    • DMT.HEAT
    • DMT.DAMAGER
    • DMT.CHAINSAW
    • DMT.NONE

Classes

CEntityPointer

Class for holding a pointer to a specific entity in the world.

Metamethods

CEntityPointer(entity = null)

Constructs an entity pointer instance by copying a pointer from another entity pointer. If left unspecified, creates an instance that doesn't point to any specific entity (null).

Arguments:

  • entity (optional) - Another CEntityPointer to copy the pointer from.

tostring()

Returns entity instance formatted as (%s : %u) where %s is the name of the entity class and %u is the entity ID in the current world. If the entity pointer is null, it returns (none).

Return value: string

Methods

Equal(other)

Compares this entity pointer with another entity pointer. A helper method for the lack of the == operator overloading.

Arguments:

  • other - Another CEntityPointer to compare this one with (may be null).

Return value: bool


GetID()

Returns unique ID of the entity in the world.

Return value: integer


GetRenderType()

Returns current render type of the entity from the RT enum.

Return value: integer


GetFlags()

Returns a mask of current entity flags using flags from the ENF enum.

Return value: integer


GetSpawnFlags()

Returns a mask of entity spawn flags using flags from the SPF enum.

Return value: integer


GetPhysicsFlags()

Returns a mask of current entity physics flags using flags from the EPF enum.

Return value: integer


GetCollisionFlags()

Returns a mask of current entity collision flags using flags from the ECF enum.

Return value: integer


IsPredictor()

Checks whether this entity is a predictor for another entity, i.e. a "shadow copy" of the original entity used for predicting entity movement and state while playing with prediction turned on.
This function is equal to checking for its respective flag: GetFlags() & ENF.PREDICTOR.

Return value: bool


IsPredicted()

Checks whether this entity is being predicted, i.e. an original entity that currently has a "shadow copy" used for predicting its movement and state while playing with prediction turned on.
This function is equal to checking for its respective flag: GetFlags() & ENF.PREDICTED.

Return value: bool


IsPredictable()

Checks whether this entity can be predicted, i.e. able to create a "shadow copy" of itself at any point for predicting entity movement and state.
This function is equal to checking for its respective flag: GetFlags() & ENF.PREDICTABLE.

Return value: bool


GetPredictor()

Get the "shadow copy" of this original entity that's used for predicting its movement and state while playing with prediction turned on.

Return value: CEntityPointer


GetPredicted()

Get the original entity of this "shadow copy" for retrieving actual entity data instead of the predicted temporary data.

Return value: CEntityPointer


GetSpatialClassificationRadius()

Returns radius of a sphere that surrounds the spatial classification box around the entity.

Return value: float


GetSpatialClassificationBox()

Returns box area of the spatial classification around the entity.

Return value: FLOATaabbox3D


GetCollisionBoxIndex()

Returns index of the current collision box of the current model.

Return value: integer


GetCollisionBoxParameters(collision_index)

Returns parameters of the specified collision box of the current model entity.

Arguments:

  • collision_index - Index of the collision box to get the parameters of.

Return value: array with two elements:

  1. FLOATaabbox3D with the collision box area around the model
  2. integer with the "equality" type of the collision box (0 - height equals width; 1 - length equals width; 2 - length equals height)

GetBoundingBox()

Returns current bounding box around the entire entity at absolute world coordinates.

Return value: FLOATaabbox3D


GetSize()

Returns current size of the entity as a box that encompasses it relative to the entity position.

Return value: FLOATaabbox3D


GetNearestPolygon()

Returns the nearest possible brush polygon to this entity.

Return value: array with four elements:

  1. CBrushPolygon with the nearest polygon (may be none)
  2. FLOAT3D with the nearest point on the polygon
  3. FLOATplane3D with the normal plane of the polygon
  4. float with the distance to the point on the polygon

GetEntityPointRatio(ratio_vector, lerped = false)

Returns absolute position inside the entity based on the size ratio in each direction relative to it.

Arguments:

  • ratio_vector - FLOAT3D with the size ratios from 0.0 to 1.0 per dimension.
  • lerped (optional) - Whether to return absolute position relative to the visual placement instead of the physical placement.

Return value: FLOAT3D


GetEntityPointFixed(fixed_point)

Returns absolute position inside the entity based on the fixed point relative to it.

Arguments:

  • fixed_point - FLOAT3D with the relative point inside the entity in meters.

Return value: FLOAT3D


FindEntitiesInRange(area, only_colliding)

Searches for other entities within a certain area around this entity.

Arguments:

  • area - FLOATaabbox3D with the absolute area around the entity to search for entities in.
  • only_colliding - Whether to only search for entities in the area that are actively colliding with this entity.

Return value: array of CEntityPointer values with all found entities in the area (may be empty)


GetPlacement()

Returns current physical placement of the entity. Can be used for entity logic.

Return value: CPlacement3D


GetLerpedPlacement()

Returns current visual placement of the entity, which is typically lerped for the current frame between the last placement and the current placement between in-game ticks. Can be used for rendering logic.

Return value: CPlacement3D


GetRotationMatrix()

Returns pre-calculated rotation matrix based on the rotation angle of the current physical placement.

Return value: FLOATmatrix3D


GetViewpoint(lerped = false)

Returns the current absolute viewpoint of a player entity, i.e. the position of the eyes relative to the entity.
If used on an entity that isn't derived from CPlayerEntity class, it throws a runtime error.

Arguments:

  • lerped (optional) - Whether to return the lerped view placement used for rendering purposes instead of the physical view placement.

Return value: CPlacement3D


GetPlacementRelativeToParent()

Returns current physical placement of this entity relative to its parent entity. If parent entity doesn't exist, the placement value may be invalid.

Return value: CPlacement3D


GetParent()

Returns current parent entity of this entity (may be none).

Return value: CEntityPointer


GetChildOfClass(class_name)

Returns the first occurrence of a child entity of a specific class (may be none).

Arguments:

  • class_name - Name of a specific entity class to find a child entity with.

Return value: CEntityPointer


GetName()

Returns the current internal name of this entity that may be changed using a specific entity property associated with it. Depending on the entity, it may be an empty string.

Important

Not to be confused with GetClassName(), which is used for retrieving the common name of the entity class that cannot be changed.

Return value: string


GetDescription()

Returns the internal description of this entity that may be changed using a specific entity property associated with it. Depending on the entity, it may be an empty string.

Return value: string


GetTarget()

Returns primary target of this entity that may be changed using a specific entity property associated with it, if supported (may be none).

Return value: CEntityPointer


GetClassificationBoxStretch()

Returns additional stretch vector for the spatial classification box of the entity. If this method isn't redefined for an entity class, it always returns FLOAT3D(1, 1, 1).

Return value: FLOAT3D


GetHealth()

Returns current health of a living entity.
If used on an entity that isn't derived from CLiveEntity class, it throws a runtime error.

Return value: float


GetLastPlacement()

Returns cached last physical placement of a moving entity.
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Return value: CPlacement3D


GetPolygonUnderneath()

Returns brush polygon that the moving entity is currently standing on top of (may be none).
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Return value: CBrushPolygon


GetRelativeHeading(direction)

Calculates relative heading angle based on the specified direction vector. An inverse function of GetHeadingDirection().
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Arguments:

  • direction - FLOAT3D with the absolute direction vector.

Return value: float


GetRelativePitch(direction)

Calculates relative pitch angle based on the specified direction vector. An inverse function of GetPitchDirection().
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Arguments:

  • direction - FLOAT3D with the absolute direction vector.

Return value: float


GetReferenceHeadingDirection(reference_dir, angle)

Calculates absolute direction vector based on the specified heading angle relative to another direction vector.
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Arguments:

  • reference_dir - FLOAT3D with the reference direction.
  • angle - Heading angle relative to the current entity rotation.

Return value: FLOAT3D


GetHeadingDirection(angle)

Calculates absolute direction vector based on the specified heading angle. An inverse function of GetRelativeHeading().
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Arguments:

  • angle - Heading angle relative to the current entity rotation.

Return value: FLOAT3D


GetPitchDirection(angle)

Calculates absolute direction vector based on the specified pitch angle. An inverse function of GetRelativePitch().
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Arguments:

  • angle - Pitch angle relative to the current entity rotation.

Return value: FLOAT3D


MiscDamageInflictor()

Returns currently acceptible entity for use as an inflictor for miscellaneous damage, such as fall, heat and impact damage.
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Return value: CEntityPointer


IsStandingOnPolygon(polygon)

Checks whether the entity is currently standing on the specified brush polygon.
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Arguments:

  • polygon - CBrushPolygon with the polygon to check for.

Return value: bool


IsPolygonBelowPoint(polygon, point, max_distance)

Checks whether the specified brush polygon is below a specific absolute point.
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Arguments:

  • polygon - CBrushPolygon with the polygon to check for.
  • point - FLOAT3D with the point to check for the polygon below.
  • max_distance - Maximum distance to check for the polygon.

Return value: bool


WouldFallInNextPosition()

Checks whether the moving entity would be falling on the next position.
If used on an entity that isn't derived from CMovableEntity class, it throws a runtime error.

Return value: bool


GetClassFile()

Returns path to the ECL file that was used for creating an instance of this entity.

Return value: string


GetClassName()

Returns internal name of the entity class that was used for creating an instance of this entity. This same name can be used when looking up or checking entities based on their generic class name.

Important

Not to be confused with GetName(), which is used for retrieving the current name of this specific entity.

Return value: string


GetClassID()

Returns unique ID of the entity class that was used for creating an instance of this entity. This same ID can be used when looking up or checking entities based on their generic class ID.

Return value: integer


IsOfClass(class_name)

Checks whether this entity is of a specific class by its associated internal name.

Arguments:

  • class_name - Name of a generic entity class to check this entity for.

Return value: bool


IsDerivedFromClass(class_name)

Checks whether this entity is of a specific class or has been derived from that class by its associated internal name.

Arguments:

  • class_name - Name of a generic entity class to check this entity for.

Return value: bool


IsOfClassID(class_id)

Checks whether this entity is of a specific class by its associated internal ID.

Arguments:

  • class_id - ID of a generic entity class to check this entity for.

Return value: bool


IsDerivedFromID(class_id)

Checks whether this entity is of a specific class or has been derived from that class by its associated internal ID.

Arguments:

  • class_id - ID of a generic entity class to check this entity for.

Return value: bool


IsLiveEntity()

Checks whether this entity has been derived from CLiveEntity class.

Return value: bool


IsRationalEntity()

Checks whether this entity has been derived from CRationalEntity class.

Return value: bool


GetPropInfoByID(type, id, offset = -1)

Looks up an entity property inside this entity's generic class based on the desired property type, its internal ID and its byte offset.

Arguments:

  • type - Desired property type from the EPT enum.
  • id - Internal ID of the desired property.
  • offset (optional) - Byte offset of the desired property relative to the entity class as an optional fallback in case the internal ID doesn't match.

Return value: Entities.Property


GetPropInfoByName(type, name)

Looks up an entity property inside this entity's generic class based on the desired property type and its display name.

Arguments:

  • type - Desired property type from the EPT enum.
  • name - Display name of the desired property.

Return value: Entities.Property


GetPropInfoByVariable(class_name, variable_name)

Looks up an entity property inside this entity's generic class based on a variable inside a C++ class describing the vanilla entity class.

Arguments:

  • class_name - Name of the C++ class to search for the property in.
  • variable_name - Name of the C++ field of the specified class that's supposed to be referenced by the desired property.

Return value: Entities.Property


GetPropValue(property)

Returns current value of the specified entity property from this entity. Throws a runtime error if cannot return any value from the entity.

Arguments:

  • property - Entities.Property with the property to get the value of.

Return value: Depending on the property type: integer, bool, float, string, CEntityPointer, FLOATaabbox3D, FLOAT3D, FLOATplane3D, CPlacement3D, FLOATmatrix3D


GetPropValueByID(type, id, offset = -1)

Returns value from an entity property inside this entity's generic class based on the desired property type, its internal ID and its byte offset.
Auxiliary method for directly retrieving entity property values instead of generic property info as Entities.Property. If the property cannot be found or it's of an unsupported type, the method returns null instead of throwing a runtime error.

Note

This method may be slower than GetPropInfoByID() because it has to perform a lookup of the entity property every single time it needs to retrieve a value from it instead of using existing property info stored inside an Entities.Property instance.

Arguments:

  • type - Desired property type from the EPT enum.
  • id - Internal ID of the desired property.
  • offset (optional) - Byte offset of the desired property relative to the entity class as an optional fallback in case the internal ID doesn't match.

Return value: null on error, otherwise depending on the property type: integer, bool, float, string, CEntityPointer, FLOATaabbox3D, FLOAT3D, FLOATplane3D, CPlacement3D, FLOATmatrix3D


GetPropValueByName(type, name)

Returns value from an entity property inside this entity's generic class based on the desired property type and its display name.
Auxiliary method for directly retrieving entity property values instead of generic property info as Entities.Property. If the property cannot be found or it's of an unsupported type, the method returns null instead of throwing a runtime error.

Note

This method may be slower than GetPropInfoByName() because it has to perform a lookup of the entity property every single time it needs to retrieve a value from it instead of using existing property info stored inside an Entities.Property instance.

Arguments:

  • type - Desired property type from the EPT enum.
  • name - Display name of the desired property.

Return value: null on error, otherwise depending on the property type: integer, bool, float, string, CEntityPointer, FLOATaabbox3D, FLOAT3D, FLOATplane3D, CPlacement3D, FLOATmatrix3D


GetPropValueByVariable(class_name, variable_name)

Returns value from an entity property inside this entity's generic class based on a variable inside a C++ class describing the vanilla entity class.
Auxiliary method for directly retrieving entity property values instead of generic property info as Entities.Property. If the property cannot be found or it's of an unsupported type, the method returns null instead of throwing a runtime error.

Note

This method may be slower than GetPropInfoByVariable() because it has to perform a lookup of the entity property every single time it needs to retrieve a value from it instead of using existing property info stored inside an Entities.Property instance.

Arguments:

  • class_name - Name of the C++ class to search for the property in.
  • variable_name - Name of the C++ field of the specified class that's supposed to be referenced by the desired property.

Return value: null on error, otherwise depending on the property type: integer, bool, float, string, CEntityPointer, FLOATaabbox3D, FLOAT3D, FLOATplane3D, CPlacement3D, FLOATmatrix3D

Variables

CMovableEntity properties

These properties can only be read from entities derived from the CMovableEntity class, otherwise resulting in the runtime error.

They exist for convenience instead of having to manually look up these properties by variable name or internal ID because they are exactly the same across any entity that's derived from this engine class.

Variable Type Readable Writeable
en_vDesiredTranslationRelative FLOAT3D Yes No
en_aDesiredRotationRelative FLOAT3D Yes No
en_vCurrentTranslationAbsolute FLOAT3D Yes No
en_aCurrentRotationAbsolute FLOAT3D Yes No
en_penReference CEntityPointer Yes No
en_vReferencePlane FLOAT3D Yes No
en_iReferenceSurface integer Yes No
en_penLastValidReference CEntityPointer Yes No
en_tmLastSignificantVerticalMovement float Yes No
en_tmLastBreathed float Yes No
en_tmMaxHoldBreath float Yes No
en_fDensity float Yes No
en_tmLastSwimDamage float Yes No
en_iUpContent integer Yes No
en_iDnContent integer Yes No
en_fImmersionFactor float Yes No
en_vGravityDir FLOAT3D Yes No
en_fGravityA float Yes No
en_fGravityV float Yes No
en_vForceDir FLOAT3D Yes No
en_fForceA float Yes No
en_fForceV float Yes No
en_tmJumped float Yes No
en_tmMaxJumpControl float Yes No
en_fJumpControlMultiplier float Yes No
en_fAcceleration float Yes No
en_fDeceleration float Yes No
en_fStepUpHeight float Yes No
en_fStepDnHeight float Yes No
en_fBounceDampParallel float Yes No
en_fBounceDampNormal float Yes No
en_fCollisionSpeedLimit float Yes No
en_fCollisionDamageFactor float Yes No

CPlayerEntity properties

Properties that can only be read from entities derived from the CPlayerEntity class, otherwise resulting in the runtime error.

They exist for convenience instead of having to manually look up these properties by variable name or internal ID because they are exactly the same across any entity that's derived from this engine class.

Variable Type Readable Writeable
en_tmPing float Yes No

Entities.Property

Class for representing a single property of some entity class.

Metamethods

Entities.Property(property = N/A)

Constructs an entity property instance by copying data from another entity property. If left unspecified, creates an instance that doesn't point to any specific property (null).

Arguments:

  • property (optional) - Another Entities.Property to copy data from.

Methods

Equal(other)

Compares this entity property with another entity property. A helper method for the lack of the == operator overloading.

Arguments:

  • other - Another Entities.Property to compare this one with (may be null).

Return value: bool


GetEnumValueCount()

Returns amount of enum values for a property of the EPT.ENUM type, otherwise throws a runtime error.

Return value: integer


GetEnumValues()

Returns an array of all possible enum values for a property of the EPT.ENUM type, otherwise throws a runtime error.

Return value: array of other array values (e.g. [ [999, "Invalid type"], [1, "First type"], [2, "Second type"] ]):

  1. integer with the actual index of the enum value that can be used for setting new values to this property in some entity.
  2. string with the display name of the enum value for informational purposes (may be an empty string).

GetValue(entity)

Returns current value of this property from the specified instance of some entity class in the world. Throws a runtime error if cannot return any value from the entity.

Arguments:

  • entity - CEntityPointer with the entity to get the property value from.

Return value: Depending on the property type: integer, bool, float, string, CEntityPointer, FLOATaabbox3D, FLOAT3D, FLOATplane3D, CPlacement3D, FLOATmatrix3D

Variables

eptType

Specifies the property value type from the EPT enum. Equivalent to the engine's CEntityProperty::ep_eptType.

Type Readable Writeable
integer Yes No

ulID

Specifies the unique internal ID of the property that contains the ID of the associated entity class in the upper 24 bits (shifted by 8 bits to the left). Equivalent to the engine's CEntityProperty::ep_ulID.

Warning

Any property that has been declared with an ID above 255 in the entity source file clashes with the class ID and increases its value. This may introduce unintentional property clashes where some base entity class has property IDs above 255 (e.g. 260) and another class type derived from the base type has property IDs close to 0 (e.g. 4) but its class ID (e.g. 513) is just one number above the base class ID (e.g. 512). This results in the derived class having a property under the same exact internal ID as one of the properties in the base class (e.g. 131332).

Type Readable Writeable
integer Yes No

slOffset

Specifies the internal byte offset of the property relative to any instance of the same entity class or any derived class types. Equivalent to the engine's CEntityProperty::ep_slOffset.

Type Readable Writeable
integer Yes No

strName

Specifies the display name of the property, usually seen in Serious Editor. Internal/hidden properties always have an empty string for a name. Equivalent to the engine's CEntityProperty::ep_strName.

Type Readable Writeable
string Yes No

ulFlags

Specifies internal property flags. Practically unused in vanilla Serious Engine 1. Equivalent to the engine's CEntityProperty::ep_ulFlags.

Type Readable Writeable
integer Yes No

chShortcut

Specifies character code used as a shortcut for switching to this property in Serious Editor. When the property has no shortcut key, the value is 0. Equivalent to the engine's CEntityProperty::ep_chShortcut.

Type Readable Writeable
integer Yes No

colColor

Specifies the property color for special rendering in Serious Editor, such as targeting arrows of entity pointer properties. Equivalent to the engine's CEntityProperty::ep_colColor.

Type Readable Writeable
integer Yes No

CEntityEvent

Class for setting up event with specific data for sending signals to entities.

Metamethods

CEntityEvent(event = EVENTCODE.EVoid)

Constructs an empty entity event instance with the specified event code. If left unspecified, defaults to the EVoid event.

Arguments:

  • event (optional) - Another CEntityEvent to copy data from or an event code of a specific event type from the EVENTCODE enum.

Methods

SetArgs(values...)

Takes a variable amount of arguments, the values of which are set in the event sequentially. Accepted value types: null, integer, float, bool, string, FLOAT3D, CEntityPointer.

Warning

Each passed value must have an explicit type in order to set appropriate data to the event. For example, passing an integer where a float is expected will erroneously write the bytes of the number as a C++ int (SE1 INDEX), rather than a C++ float (SE1 FLOAT).

Arguments:

  • values... - A series of different values to set as event data.

Return value: null

Functions

Entities.Create(class, placement)

Creates a new entity somewhere in the world based on the class file.

Arguments:

  • class - Path to the ECL file with the class to create.
  • placement - CPlacement3D with the place to create the new entity at.

Return value: null


Entities.Delete(entity, same_class)

Deletes the specified entity or all entities of the same class type from the world.

Arguments:

  • entity - ID of the entity to delete.
  • same_class - Whether to delete all instances of the same class type instead of only the specified entity.

Return value: null


Entities.Copy(entity, copies)

Copies the specified entity a certain amount of times. Specifying 1 copy creates one new entity. Specifying 0 copies creates no new entities.

Arguments:

  • entity - ID of the entity to copy.
  • copies - Amount of copies to make at once from 0 to 31.

Return value: null


Entities.SendEvent(entity, event)

Sends previously set up event to the specified entity, such as EVENTCODE.ETrigger.

Arguments:

  • entity - ID of the entity to send the event to.
  • event - CEntityEvent to send.

Return value: null


Entities.ReceiveItem(entity, event)

Makes the specified entity receive a new item based on the set up event, such as EVENTCODE.EWeaponItem.

Arguments:

  • entity - ID of the entity to give the item to.
  • event - CEntityEvent with the item to receive.

Return value: null


Entities.Initialize(entity, event = CEntityEvent(EVENTCODE.EVoid))

Initializes a new entity after its initial creation or reinitializes it after it has already been initialized.

Warning

If you are creating an internal entity (i.e. an entity that cannot be normally placed in Serious Editor), you must pass a specific initialization event into the function that it requires (such as EVENTCODE.ESeriousBomb), otherwise initializing it with the wrong event (or an empty one - EVENTCODE.EVoid), it may crash the game!

Arguments:

  • entity - ID of the entity to (re)initialize.
  • event (optional) - CEntityEvent with the initialization event to use, if needed.

Return value: null


Entities.SetPos(entity, position, relative)

Sets new entity position in the world regardless of its rotation.

Arguments:

  • entity - ID of the entity to set the position of.
  • position - FLOAT3D with the new position to set.
  • relative - Whether to offset the entity by the specified position instead of setting new absolute position.

Return value: null


Entities.SetRot(entity, rotation, relative)

Sets new entity rotation in the world regardless of its position.

Arguments:

  • entity - ID of the entity to set the rotation of.
  • rotation - FLOAT3D with the new rotation to set.
  • relative - Whether to rotate the entity by the specified rotation instead of setting new absolute rotation.

Return value: null


Entities.Teleport(entity, placement, relative)

Sets new entity placement in the world, taking current position and rotation into account when setting relative placement.

Arguments:

  • entity - ID of the entity to teleport.
  • placement - CPlacement3D with the new placement to set.
  • relative - Whether to offset the entity by the specified placement instead of setting new absolute placement.

Return value: null


Entities.Parent(entity, parent_entity)

Parents the specified entity to another entity. Setting the parent entity ID to -1 or any other invalid ID, the specified entity becomes unparented.

Arguments:

  • entity - ID of the entity to parent.
  • parent_entity - ID of the parent entity to attach the specified entity to.

Return value: null


Entities.SetProperty(entity, property, value)

Sets new value to the specified entity property either by its display name (like in Serious Editor, e.g. "Type") or by its internal property index (e.g. (402 << 8) + 11 for vanilla CPlayerWeapons::m_iAvailableWeapons).

Arguments:

  • entity - ID of the entity to set the property value to.
  • property - Identifier of the entity property either as a display name (string) or as an internal property index (integer).
  • value - New property value to set as integer, float, bool or string.

Return value: null


Entities.SetHealth(entity, health)

Sets new health to an entity derived from the internal CLiveEntity class. Using this function on a non-living entity does nothing.

Arguments:

  • entity - ID of the entity to set the health to.
  • health - Amount of health to set.

Return value: null


Entities.SetFlags(entity, flags, remove)

Sets new entity flags to the specified entity. Instead of setting the entire flag mask at once, it either adds or removes bits of the specified mask using the current mask.

Arguments:

  • entity - ID of the entity to set the flags to.
  • flags - Entity flags to set from the ENF enum.
  • remove - Whether to remove the specified flags from the entity instead of adding them.

Return value: null


Entities.SetPhysicsFlags(entity, flags, remove)

Sets new entity physics flags to the specified entity. Instead of setting the entire flag mask at once, it either adds or removes bits of the specified mask using the current mask.

Arguments:

  • entity - ID of the entity to set the flags to.
  • flags - Entity flags to set from the EPF enum.
  • remove - Whether to remove the specified flags from the entity instead of adding them.

Return value: null


Entities.SetCollisionFlags(entity, flags, remove)

Sets new entity collision flags to the specified entity. Instead of setting the entire flag mask at once, it either adds or removes bits of the specified mask using the current mask.

Arguments:

  • entity - ID of the entity to set the flags to.
  • flags - Entity flags to set from the ECF enum.
  • remove - Whether to remove the specified flags from the entity instead of adding them.

Return value: null


Entities.Move(entity, speed_vector)

Sets new current movement speed to an entity derived from the internal CMovableEntity class. Using this function on a non-moving entity does nothing.

Arguments:

  • entity - ID of the entity to move.
  • speed_vector - FLOAT3D with the movement speed to set to the movable entity.

Return value: null


Entities.Rotate(entity, speed_vector)

Sets new current rotation speed to an entity derived from the internal CMovableEntity class. Using this function on a non-moving entity does nothing.

Arguments:

  • entity - ID of the entity to rotate.
  • speed_vector - FLOAT3D with the rotation speed to set to the movable entity.

Return value: null


Entities.GiveImpulse(entity, speed_vector)

Kicks an entity derived from the internal CMovableEntity class in the specified direction. Using this function on a non-moving entity does nothing.

Arguments:

  • entity - ID of the entity to give impulse to.
  • speed_vector - FLOAT3D with the direction and speed to launch the movable entity towards.

Return value: null


Entities.InflictDirectDamage(inflictor, target, damage_type, damage, hit_point, hit_direction)

Inflicts damage to a specific entity towards the specified direction.

Arguments:

  • inflictor - ID of the entity that inflicts the damage.
  • target - ID of the target entity to damage.
  • damage_type - Damage type from the DMT enum.
  • damage - Maximum amount of damage to deal.
  • hit_point - FLOAT3D with the absolute position of where the damage has been dealt.
  • hit_direction - FLOAT3D with the normalized vector of the direction of the damage (e.g. the direction of the bullet towards the target).

Return value: null


Entities.InflictRangeDamage(inflictor, damage_type, damage, center, fall_off, hot_spot)

Inflicts damage to all entities within the specified fall-off radius with the damage intensity decreasing further away from the hot-spot radius.

Arguments:

  • inflictor - ID of the entity that inflicts the damage.
  • damage_type - Damage type from the DMT enum.
  • damage - Maximum amount of damage to deal.
  • center - FLOAT3D with the center point of the damage.
  • fall_off - Fall-off distance from the center point where the damage can still be dealt.
  • hot_spot - Hot-spot distance from the center point where the damage value becomes maximum.

Return value: null


Entities.InflictBoxDamage(inflictor, damage_type, damage, area)

Inflicts damage to all entities within the specified box area.

Arguments:

  • inflictor - ID of the entity that inflicts the damage.
  • damage_type - Damage type from the DMT enum.
  • damage - Maximum amount of damage to deal.
  • area - FLOATaabbox3D with the area to deal damage within.

Return value: null

Clone this wiki locally