User Tools

Site Tools


scripting:reference:entities

Scripted Entities Reference

Scripts run on the server can create and modify 'Entities' (i.e. 'things') that (generally) appear in the world for connected players. There are also (potentially) entities that do special things like, for instance, controlling the game camera.

Please note this system is experimental, is quite complicated, can cause lots of problems if misused, much of it isn't working right or at all (so no surprise there then) and may change significantly in the future.

Procedure for creating Entities

The server script for using scripted entities will usually follow this process:

1. Create a new entity (using EntityCreate )
2. Set parameters, graphics and behaviours for the entity (using EntitySetPosition, EntitySetValue etc)
3. Add the entity to the world. (using EntityAddToWorld - This bit actually broadcasts the entity to the connected players).

Entity Types

The second parameter when calling EntityCreate defines the 'Main Type' of the entity - which defines how the entity is replicated and persists within the world. Options for the Main Type are:

LOCAL (Default) : This entity is 'owned' by and appears only for the specified player, and is deleted when they leave.
PUBLIC : This entity is 'owned' by the specific playerID and is deleted when they leave, but everyone sees it.
GLOBAL : This entity stays around until the server asks to delete it (or it is destroyed by a player).

Entity Behaviours

The third parameter to the 'EntityCreate' call determines the general behaviour of the entity. This ranges from 'Scripted' (where the entity basically does nothing unless told to be the server script) to more custom behaviours such as 'SUICIDE_ATTACK' (where the entity heads towards its target until..)

The current list of valid behaviours are:

SCRIPTED : No default behaviour - server script needs to relay individual actions
PET : Behaviour coded into client - follows player about, idles etc
TRACK : Maintains a fixed distance between entity and target
PROJECTILE : Moves according to Newtonian physics.
HUNT : Will track towards the target, maintaining a minimum distance
STATIC : Doesn't move (unless told to do so by script) - Can still rotate towards a target if 'FaceTarget' flag is used
SUICIDE_ATTACK : Heads towards a target and explodes when it gets there
EVADE : Avoid the target
PATH : Follow a specified path
ATTACH : Moves with the player, entity or weapon specified. Pos is used as an offset

Scripted Entity Commands

EntityCreate

Parameters Player ID, Type, Behaviour
Returns A handle to the entity
Example $hEntity = EntityCreate( $gPlayerID, “LOCAL”, “TRACK” )
Description Creates a new entity on the server.

EntityAddToWorld

Parameters Entity Handle
Example EntityAddToWorld( $hEntity )
Description Adds an entity to the world - broadcasting it to the appropriate players.

EntitySetValue

Parameters Entity Handle, Field Name, Value
Example EntitySetValue( $hCamEntity, “FaceTarget”, 1 )
Description Sets the parameter value of an entity. (Currently only works prior to the entity being added to the world)


Values for the 'Field Name' :
Health
ZOffset
Target
Weapon
ProxRange
TargetDist
MoveSpeed
RotateSpeed
MoveAcc
TargetLead
AutoExpire
AttachTo
DeathDelay

Flag values (Can only be 0 or 1) :
FaceTarget
DontStickToFloor
TakeDamage
AttackTarget
AttackProx
DieOnTargetDeath
IsCamera
TargetEntity
TargetLastWeapon
TargetLastLocalWeapon
AttachEntity
AttachLastWeapon
AttachLastLocalWeapon

EntitySetPosition

EntitySetRotation

EntitySetModel

EntitySetAnimation

EntityMoveTo

EntitySetBehaviour

EntityDelete

EntityDeleteAll

EntityCommandCode

EntitySetControlFlag

EntityActivateUpdateEvent

EntitySetGraphics

scripting/reference/entities.txt · Last modified: 2020/01/28 17:50 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki