Enemy Territory Scripting Definitions

Table of contents

Commands
Level interaction
Spawn related
Music related
Bot related
Game control
Accum registers
CVAR variables
Debugging
Controls tructures
Entity handling
Message System
Objective handling
Models and texture related
Movement related
Cinematics
Animations
Command post related
Tank related
Construction related
Sound
Symbols

Events
Complete list
Entities and the events they can trigger

TODO
Description of accum and cvar variables should be switched.

Commands

Level interaction

setglobalfog 0 <duration> <float:r> <float:g> <float:b> <float:depthForOpaque>
Changes the global fog in a map to a specific color and density.

setglobalfog 1 <duration>
Changes the global fog in a map.

spawnrubble <targetname>
Spawn rubble, use in combination with func_debris.

setautospawn <target_spawn> <team>
Set the autospawn of a team to 'target_spawn'. The 'target_spawn' string is the 'description' key on the team_WOLF_objective.

mu_fade <target_volume> <fade_time>
Fades the current music to 'target_volume' in 'fade_time' milliseconds. 'target_volume' is a floating point value between 0.0 and 1.0

mu_play <musicfile> [fade_time]
Plays 'musicfile', spending 'fade_time' milliseconds working its way up to the music level.
NOTE: 'fadeup_time' seems to be broken since the source code never attempts to read it.
NOTE: Have a look af mu_start instead which seems to do the same as mu_play but does use the 'fade_time'.
UNVERIFIED

mu_queue <musicfile>
Queues 'musicfile' for furture play.

mu_start <musicfile> <fade_time>
Plays 'musicfile', spending 'fade_time' milliseconds working its way up to the music level.

mu_stop <fade_time>
Stops the currently playing music, taking 'fade_time' to fade down.

aiscriptname
Does nothing.

disablemessage <targetname>
Sets s.aiState in the source code to 1, which I don't know what indicates.

removebot <botname>
Removes the bot called 'botname'.

setbotgoalpriority <name> <axis|allies|both> level <value>
Unknown use.

setbotgoalstate <name> <axis|allies|both> <active|inactive>
Unknown use.

setaasstate <name> <enabled|disabled|avoid>
Unknown use.

spawnbot [/param [value]] [/param [value]] ...
Spawns a bot into the game, with the given parameters. Where [/param [value]] may consist of:
/name [name]
/skill [0-4]
/team <axis|allies>
/class <class>
/weapon [weaponValue|none]
/spawnpoint [targetname]
/respawn [ON|OFF]
/scriptName [scriptName]
/character [character]
/rank [rank]
/skills [botskills]
/pow <yes/no>

Game control

wm_allied_respawntime <seconds>
Respawn time for the allied team.

wm_axis_respawntime <seconds>
Respawn time for the axis team.

wm_endround
Ends the current round.

wm_set_defending_team <team>
Sets defending team for stopwatch mode

wm_set_round_timelimit <minutes>
Sets the round timelimit to 'minutes'. If 5 minutes has elapsed, and the round timelimit is set to 10, there will be 5 minutes remaining.

wm_setwinner <team|-1>
Set the team thats declared the winner in the intermission screen. Use -1 to declare the match a tie.
NOTE: The timelimit_hit event in the gamemanager scriptblock is only triggered if wm_setwinner is set to a team.

Accum registers

The accum registers are buffers for 32 bit integer values.
Each scriptblock has its own private set of 10 registers, numbered 0-9. These are accessed via the accum command.
All scriptblocks shares a single set of 10 registers, numbered 0-9. These are accessed via the globalaccum command.

(global)accum <buffer_index> bitreset <bit_index>
Clears the number 'bit_index' bit in the buffer.

(global)accum <buffer_index> bitset <bit_index>
Sets the number 'bit_index' bit in the buffer.

(global)accum <buffer_index> inc <value>
Adds 'value' to the value of 'buffer_index'.
NOTE: Use negative value to decrease.

(global)accum <buffer_index> random <value>
Sets the value in 'buffer_index' to a random value between 0 and 'value'.

(global)accum <buffer_index> set <value>
Sets the value in 'buffer_index' to 'value'.

accum <buffer_index> set_to_dynamitecount <targetname>
Sets the value in 'buffer_index' to the number of dynamite sticks thats has been planted at 'targetname'.
NOTE: This is only available for the accum command.

CVAR variables

cvar <cvarName> bitreset <bit_index>
Clears the number 'bit_index' bit in the value of the cvar 'cvarName'.

cvar <cvarName> bitset <bit_index>
Sets the number 'bit_index' bit in the value of the cvar 'cvarName'.

cvar <cvarName> inc <value>
Adds 'value' to the value of the cvar 'cvarName'.
NOTE: Use negative value to decrease.

cvar <cvarName> random <value>
Sets the value of the cvar 'cvarName' to a random value between 0 and 'value'.

cvar <cvarName> set <value>
Sets the value of the cvar 'cvarName' to 'value'.

Debugging

botgebugging <ON|OFF>
Enables or disables bot debugging.
Note: That the spelling error in the command name, is also present in the source code.
UNVERIFIED

entityscriptname <scriptname>
Changes the cvar value of 'g_scriptname' to 'scriptname'. This value is then used instead of the map name, the next time the map is restarted.

print [/scriptdebuglevel] <text>
Prints 'text'. Mostly for debugging purposes. If the 'scriptdebuglevel' is specified, then the text will only get printed if the g_scriptdebuglevel cvar is above of equal.

printaccum <accumNumber>
Prints the value in 'accumNumber' to the console.

printglobalaccum <accumNumber>
Prints the value in 'accumNumber' to the console.

setdebuglevel <scriptdebuglevel>
Script command to set the cvar 'g_scriptDebugLevel' to 'value'

Controls tructures

abortifnotsingleplayer
Abort execution thread if the game isn't in single player mode.

abortifwarmup
Abort execution thread if the game is in warmup.

(global)accum <buffer_index> abort_if_bitset <bit_index>
Abort execution thread if the value of the cvar 'cvarName' has 'bit_index' bit set.

(global)accum <buffer_index> abort_if_equal <value>
Abort execution thread if the value of the cvar 'cvarName' is equal to 'value'.

(global)accum <buffer_index> abort_if_greater_than <value>
Abort execution thread if the value of the cvar 'cvarName' is greater than 'value'.

(global)accum <buffer_index> abort_if_less_than <value>
Abort execution thread if the value of the cvar 'cvarName' is less than 'value'.

(global)accum <buffer_index> abort_if_not_bitset <bit_index>
Abort execution thread if the value of the cvar 'cvarName' has 'bit_index' bit clear.

(global)accum <buffer_index> abort_if_not_equal <value>
Abort execution thread if the value of the cvar 'cvarName' is not equal to 'value'.

(global)accum <buffer_index> trigger_if_equal <value> <scriptblock> <trigger_event>
Call the trigger 'trigger_event' in 'scriptblock' if the value of the cvar 'cvarName' is equal to 'value'.

(global)accum <buffer_index> wait_while_equal <value>
Halts execution thread while the value of the cvar 'cvarName' is equal to 'value'.

cvar <cvarName> abort_if_bitset <bit_index>
Abort execution thread if the value in 'buffer_index' has 'bit_index' bit set.

cvar <cvarName> abort_if_equal <value>
Abort execution thread if the value in 'buffer_index' is equal to 'value'.

cvar <cvarName> abort_if_greater_than <value>
Abort execution thread if the value in 'buffer_index' is greater than 'value'.

cvar <cvarName> abort_if_less_than <value>
Abort execution thread if the value in 'buffer_index' is less than 'value'.

cvar <cvarName> abort_if_not_bitset <bit_index>
Abort execution thread if the value in 'buffer_index' has 'bit_index' bit clear.

cvar <cvarName> abort_if_not_equal <value>
Abort execution thread if the value in 'buffer_index' is not equal to 'value'.

cvar <cvarName> trigger_if_equal <value>
Call the trigger 'trigger_event' in 'scriptblock' if the value in 'buffer_index' is equal to 'value'.

cvar <cvarName> wait_while_equal <value>
Halts execution thread while the value in 'buffer_index' is equal to 'value'.

resetscript
Causes any currently running scripts to abort, in favour of the current script.

trigger <scriptblock> <trigger_event>
Calls the specified 'trigger_event' in 'scriptblock'.

trigger self <trigger_event>
Calls the specified 'trigger_event' in the current scriptblock.

trigger global <trigger_event>
Calls the specified 'trigger_event' in all scriptblocks.

trigger player <trigger_event>
Calls the specified 'trigger_event' for all players.

trigger activator <trigger_event>
Calls the specified 'trigger_event' for the activator (bots only).

wait <duration>
Stops execution for 'duration' milliseconds.

wait random <min> <max>
Stops execution for a random duration between 'min' and 'max' milliseconds.

Entity handling

alertentity <targetname>
Uses the entity 'targetname'.

kill <targetname>
Kill all entities with targetname set to 'targetname'.

remove
Schedule this entity to be freed on the next serverframe.

Message System

wm_announce <text>
Sends 'text' to all clients in the popup message area.

wm_announce_icon <icon_number> <text>
Sends 'text' to all clients in the popup message area. The icon used is specified by 'icon_number'.

wm_voiceannounce <team> <voice_message>
Broadcast a 'voice_message' to the specified 'team'.

wm_addteamvoiceannounce <team> <soundname>
Adds sound to the queue of sounds that a player gets to hear when he joins a team.

wm_removeteamvoiceannounce <team> <soundname>
Removes sound from the queue of sounds that a player gets to hear when he joins a team.

wm_teamvoiceannounce <team> <soundname>
Play a sound 'soundname' to the specified 'team'.

Objective handling

wm_objective_status <objective_number> <team> <objective_status>
Sets the tick or cross status overlay on the objective panel in the limbo menu for the specific objective, for the specified team.

wm_number_of_objectives <objectives>
Sets the number of objectives in the map.

wm_set_main_objective <objective_number> <team>
In the source code, this function does absolutely nothing at all.

attachtotag <targetname> <tagname>
Connect this entity onto the tag of another entity.

changemodel <modelname>
Change the model of this entity to 'modelname'. The 'modelname' is the path to the model.

remapshader <target_shader> <new_shader>
Schedules the replacement of a 'target_shader' by 'new_shader'.
NOTE: On subsequent calls the 'target_shader' should still be what it originally was.
NOTE: A maximum of 128 shaders can be remapped at one time.

remapshaderflush
Remapshaderflush executes all scheduled replacement.
NOTE: A maximum of 128 shaders can be remapped at one time.

setstate <targetname> <default|invisible|underconstruction>
Sets the state of an entity.

abortmove
Stops movement of the current entity.
TODO: Check if this breaks on spline paths, if you try to stop on a spline path and then resume.

attatchtotrain <targetname> <length>
Makes this entity follow another entity with a specified distance.
NOTE: Only works in combination with followpath.

faceangles <pitch> <yaw> <roll> <duration|gototime> [accel|deccel]
The entity will face the given angles, taking 'duration' milliseconds to turn. If the GOTOTIME is given instead of a timed duration, the duration calculated from the last gotomarker command will be used instead. Use accel or deccel to make the turning non-linear.

followpath <direction> <targetname> <speed> [wait] [length <value>]
Makes the entity follow the path/spline named 'targetname', in the 'direction' at a speed of 'speed' units per second. If wait is specified the execution thread will halt until the move has completed.
If length is specified, then the entity's angles will be offset 'value' units along the path.
NOTE: Followpath is required when attatchtotrain is used, otherwise use followspline.

followspline <direction|accum <buffer_index>|globalaccum <buffer_index>> <targetname> <speed> [wait] [length <value>] [roll <start_angle> <end_angle>] [dampin] [dampout]
This one is extending the syntax of followpath. In addition to a direction specified in the script, it can get its direction from either an accum or globalaccum register. It is also possible to specifiy a start and end roll angle. The entity will be interpolated between these two during its movement. And finally you can use the dampin and dampout keywords in combination with roll to make the roll no-linear.

gotomarker <targetname> <speed> [accel|deccel] [turntotarget] [wait] [relative <position_targetname>]
Moves the entity toward 'targetname' at a speed of 'speed' units per second. If accel or deccel is specified then the speed will be non-linear. If wait is specified the execution thread will halt until the move has completed. If turntotarget is specified then the entity will gradually turn towards its heading.
TODO: Check if specifying 'relative <position_targetname>' causes the entity to move in an imaginary line from targetname to position_targetname.

halt
Stops movement of the current entity.

setposition <targetname>
Moves entity to position of target entity.

setrotation <pitchspeed> <yawspeed> <rollspeed>
Sets the rotational velocity of an entity.

setspeed <x> <y> <z> [gravity|lowgravity]
Sets the directional velocity of an entity. Use gravity/lowgravity to use non-linear movement.

stoprotation
Stops the rotation of an entity.

Cinematics

SetInitialCamera <camera_filename> <black>
Unknown use.

startcam <camera_filename> <black>
Unknown use.

stopcam
Unknown use.

Animations

freezeanimation
ASSUMED: Freezes the animation of the current entity.
Source code: Sets ent->s.loopSound to 1.

playanim <startframe> <endframe> [looping <duration|untilreachmarker|forever>] [rate <FPS>]
Plays an animation from the current entitys model. Starting at 'startframe' and going to 'endframe'. If looping is specified it must be followed by a duration time in milliseconds or one of the symbols untilreachmarker or forever. If rate is specified it must be followed by a number specifying the rate at which the animation should be played.
NOTE: The source animation must be at 20fps.

startanimation <startframe> <framecount> <fps> [norandom|nolerp|noloop]
Plays an animation from the current entitys model. Starting at 'startframe' and playing 'framecount' frames, at 'fps' rate. If norandom is specified then the animation starts playing from frame 'startframe'. If noloop is specified then the animation will only play once.
TODO: Uncertain about what nolerp does. lerp is used for linear interpolation.

unfreezeanimation
ASSUMED: Unfreezes the animation of the current entity.
Source code: Sets ent->s.loopSound to 0.

Command post related

setchargetimefactor <team> <class> <factor>
Sets the chargetimefactor for the specified class and team. 'factor' is a value between 0.0 and 1.0

sethqstatus <team> <status>
Sets the hq bonus for a team.

addtankammo <targetname> <amount>
Adds 'amount' of ammo to 'targetname's ammo count.

allowtankenter <yes|no>
Allow player to mount the tanks.
NOTE: Sadly this settings is level wide.

allowtankexit <yes|no>
Allow player to unmount the current entity.
NOTE: Sadly this settings is level wide.

setdamagable <targetname> <status>
Set damagable status of target entity.

settankammo <targetname> <amount>
Sets targetname's ammo count to 'amount'.

construct <targetname>
Construct stage of target entity.

constructible_chargebarreq <fraction>
Sets how much of a chargebar is required to construct this entity. Use 0.5 for a half chargebar and etc.

constructible_class <construction_class>
Sets the class of constructible. This loads a set of values for the other characteristics.

constructible_constructxpbonus <value>
Give 'value' amount of XP to the player that finishes the construction.

constructible_destructxpbonus <value>
Give 'value' amount of XP to the player that destroys the construction.

constructible_duration <value>
Sets the time it takes in milliseconds to construct this entity.

constructible_health <value>
Sets the amount of health for the entity to 'value'.

constructible_weaponclass <weapon_class>
Sets the class of weapons that can damage this entity.

repairmg42 <targetname>
Repair target MG42.

setmodelfrombrushmodel <targetname> [useoriginforpvs] [nonsolid]
Sets the model of the current entity to the brushwork of 'targetname' which must be a func_brushmodel entity.

Sound

disablespeaker <speakername>
Disables the speaker named 'speakername'.

enablespeaker <speakername>
Enables the speaker named 'speakername'.

fadeallsounds <up|down> <time>
Fades all sounds up or down, going from the current level to max or zero in 'time' milliseconds.

playsound <soundname> [looping] [volume <sound_volume>]
Currently only allows playing on the VOICE channel, unless you use a sound script.
Use the optional looping paramater to attach the sound to the entities looping channel.
Use the optional volume parameter to set the volume to an integer value.

stopsound
Stops any looping sounds for this entity.

togglespeaker <speakername>
Toggles the speaker named 'spakername'.

Symbols

In the reference, there are a couple of symbols which represents valid values.
Symbol Values
team 0 = Axis
1 = Allies
objective_status 0 = Blank (no status)
1 = Tick (objective completed)
2 = Cross (objective failed)
icon_number 0 = Dynamite
1 = Construction
2 = Mines
3 = Death
4 = Message
5 = Objective
6 = Destruction
7 = Team
voice_message "SYS_NeedMedic"
"SYS_NeedEngineer"
"SYS_NeedLT"
"SYS_NeedCovertOps"
"SYS_MenDown"
"SYS_ObjCaptured"
"SYS_ObjLost"
"SYS_ObjDestroyed"
"SYS_ConstructComplete"
"SYS_ConstructFailed"
"SYS_Destroyed"
soundname The identifier strings are found in the <mapname>.sounds, vo_allies.sounds and vo_axis.sounds files in the /sound/scripts/ directory.
It can also be a path to the sound file itself.
direction 0 = Forward
1 = Backward
class soldier
medic
engineer
fieldops
covertops
status 0 = Disabled
1 = Enabled
construction_class
Construction Class Charge Bar Req. Construct XP Bonus Destruct XP Bonus Health Weapon Class Duration (msec) Icon
1 0.5 5 5 350 1 2500 Grenade
2 1 7.5 7.5 N/A 2 5000 Satchel Charge
3 1.5 10 10 N/A 3 2500 Dynamite
weapon_class 1 = All Explosives (Dynamite, Satchel Charge, Grenades, Panzerfaust, Mortars, Air Strike, etc.)
2 = Dynamite, Satchel Charge
3 = Dynamite Only
sound_volume 0 = No sound
127 = Half level
255 = Full
255+ = Amplified
speakername The speaker definitions are found in the <mapname>.sps files in the /sound/maps/ directory.

Events

Complete list

activate
Something has activated this entity.

activate <axis|allies>
Some player has activated this entity.

buildstart [final|stage1|stage2|stage3]
Called when the construction of a stage of a multistage constructible has started.

built [final|stage1|stage2|stage3]
Called when the construction of a stage of a multistage constructible has finished.

death
Entity was killed.

decayed [final|stage1|stage2|stage3]
Called when the construction of a stage of a multistage constructible isn't completed after a while.

defused
Called when a stick of dynamite is defused inside a trigger_objective_info entity.
Note: The TOI must target a func_constructible, for this event to be called.

destroyed [final|stage2|stage3]
Called when a stage of a multistage constructible (this entity) is destroyed.

dynamited
Called when a stick of dynamite is armed inside a trigger_objective_info entity.
Note: The TOI must target a func_constructible, for this event to be called.

failed
Called when the construction isn't completed after a while.

mg42 mount
Called when a player mounts the gun of a script_mover.

mg42 unmount
Called when a player unmounts the gun of a script_mover.

message
Contains a sequence of VO in a message

pain
Something hurt the entity. Two integer values are also used as parameters, however there is no way to use them in the script. The first integer is how much health it had before the attack, and the second is the amount of health after the attack.

playerstart
Called on client start.

rebirth
Called when the alertentity command is called with this entity as the target. Its health is restored.

spawn
Called as each entity is spawned into the game.

stopcam
Its commented out in the source code.

trigger <identifier>
Functions can trigger userdefined events via the trigger command. The game also uses this form for event calls for certain entities.

Entities and the events they can trigger

This table contains a list entities and the events they can trigger. NOTE: This table is still not complete.
Entity Event Comment
func_constructible spawn  
builtstart  
built  
decayed  
destroyed ?
death Doesn't get called unless its targeted by a TOI and have construtctible_weaponclass set to 3
func_destructible spawn  
death  
func_explosive spawn  
pain  
brushes w/health
NOTE: Need a proper entity name
spawn  
pain  
death  
func_invisible_user
trigger_multiple
trigger_once
spawn  
activate  
activate allies  
activate axis  
script_mover spawn  
pain Only if it has a health key.
death Only if it has a health key.
rebirth Only when its alerted through a script using alertentity.
mg42 mount Only if it has a mounted gun.
mg42 unmount Only if it has a mounted gun.
script_multiplayer spawn  
trigger allied_object_dropped Called when an allied objective is dropped.
trigger allied_object_returned Called when an allied objective is returned.
trigger allied_object_stolen Called when an axis objective is stolen.
trigger axis_object_dropped Called when an axis objective is dropped.
trigger axis_object_returned Called when an axis objective is returned.
trigger axis_object_stolen Called when an axis objective is stolen.
trigger timelimit_hit Called when the round timelimit is hit.
NOTE: The timelimit is only used if a team has been declared the winner with wm_setwinner.
trigger_objective_info dynamited  
defused The TOI must target a func_constructible.
team_CTF_checkpoint trigger allied_capture  
trigger axis_capture  
team_CTF_redflag
team_CTF_blueflag
trigger stolen  
trigger dropped  
trigger returned  
trigger captured  

Enemy Territory Scripting Definitions

By id Software and Splash Damage © 2003/2004. Slightly polished and re-uploaded by Loffy 2024.




Back to Loffy's Domain