An entity refers to a point in a map where a specific object exists. These objects are defined by the entities definition file supplied with the editor tools. Entities can be made of models, specific objects or brushes.
Some entities require that they are made from brushes. Some special brushwork entities require they are painted with texture/shaders from the common directory. For example: A trigger_once entity would be painted with the 'trigger' shader from the common directory.
All brushwork entities should contain 'origin' brushes.
Brushwork entities can also be areas in a map which the player can enter and the game performs a certain event depending on what the entity does.
All entities have keys which define characteristics of the entity. Examples of these keys are classname, targetname, target , etc.
All entity keys should have a value by default, whether it is a number or string. These values are usually defined / explained in the entities description box of the editor.
A special key defined by a particular set of check boxes in the entity definition dialog box. The selection of the checkboxes usually represents binary values in the final key value.
Triggering an Entity
To trigger an entity is to activate a certain state / specific function and it varies from entity to entity. With spawnpoint entities they will be turn on or off, while a func_explosion will simple explode and be removed from the game. The only disadvantage to triggering entities is that you cannot set the state of an entity to a specific value with the trigger function.
In order to trigger an entity it must have a targetname key/value so that the script system can refer to it. It's a good idea to make the targetname values more meaningful and not rely on the default 'txxxx' name system of the editor. It can help with debugging of the map / script later on.
PVS (Potentially Visible Set)
PVS is the set (group) of areas in a map which may or may not be visible from the position at which you are currently standing. Each area is a convex volume, the same as a brush is.
Scripting - Routine
The script file is made up of routines which define what various entities do and how they react to game events. Each entity in the map has the possibility to run a routine in the script file. To enable an entity to run a routine in the script file give the entity a targetname and scriptname key with relevant values.
Scripting - Function
Each entity routine is broken down into functions which are triggered by various events which affect the entity. For example: The function 'spawn' is triggered when the entity is spawned into the map at the beginning of the game. Certain functions exist for all entities regardless of what type they are. The standard functions are 'spawn', 'trigger', 'pain', 'death'. Some entities have further functions which are specific to what they do in game. For example: The func_constructible entity has the following unique functions: 'built', 'buildstart', 'decayed', 'destroyed' which are used when certain events happen involving that entity type in game.
Scripting - Variables
The scripting system supports the ability to keep track of variables or values. The system has local and global variables and each are referenced differently. The scripting system refers the keywords accum and globalaccum to mean variables. There is plenty of ways of testing these variables and making scripting decisions based on their values.
Each routine can define 8 local variables (accum) which can be used by the routine for keeping track of local conditions. For example, if the entity routine is a button, a local variable could keep track of if the button is on or off. No other routines in the script can access these local variables (accum ).
Each script can define 10 global variables (globalaccum) which can be used by any routine within the script. For example, the Battery script keeps track of the door generators by use of a global variable. Several routines in the script reference the state of this variable (globalaccum ) to determine what state the generator is in. Built or destroyed.