AI Script Commands

 

Once an script event occurs to an entity and the event block associated with it is run, the script commands inside that event block are executed. These commands are executed one at a time, with each command finishing before the next one is run. A script event block will continue to run until the last script command in it finishes executing. The script commands allow the customization of the entity and give control over it's behaviour. The following is a list of the supported script commands, the entities they apply to and a description of it's action.

Attributes Event Block

The attributes event uses special script commands that are not used anywhere else. These commands are used to set custom attribute values for each NPC in the level, overriding the standard attribute values for that type of NPC. Only the following commands can be used in the attributes event block.

health <value>

set the NPC health to <value>.

painfreq <value>

set the NPC pain frequency to <value>. The pain frequency is a value between 0 and 1 that determines how often the pain animation is shown when an NPC is in pain.

walkspeed <value>

set the walking speed of the NPC to <value>.

runspeed <value>

set the running speed of the NPC to <value>.

fov <value>

set the NPC field of view (in degrees) to <value>.

jumpheight <value>

set the NPC maximum jump height to <value>.

walkingrotationspeed <value>

set the NPC turning speed (degrees/second) when walking to <value>.

runningrotationspeed <value>

set the NPC turning speed (degrees/second) when running to <value>.

meleedist <value>

set the melee distance of the NPC to <value>.

meleedamage <value>

set the damage done per melee attack for the NPC to <value>.

fardamage <value>

set the NPC far damage amount to <value>.

aim_accuracy <value>

set the shooting accuracy of the NPC to <value>. This value ranges from 0 (poor) to 1 (good). Default is 0.9.

inner_detection_radius <value>

set the distance at which the NPC can hear or see a projectile to <value>. Default is 512.

alertness <value>

set the distance at which the NPC can hear a weapon being fired to <value>. Default is 1600.

ideal_dist <value>

the the distance the NPC wants to be away from it's enemy when doing a far attack to <value>.

hearing_scale <value>

set the hearing multiplier for the NPC to <value>. This value has a range of 0 to 999 and is used to multiply the alertness distance of the NPC. Default is 1.

skin <name>

change the NPC model to use the textures defined in a .skin file called <name> rather than the default texturing. This will override the skin key used in the entity definition.

All Other Event Blocks

The following script commands can be used in any script event block, except the attributes event block . If the command does not apply to the particular entity then it will be ignored without error.

Player Only

giveweapon <weapon>

Gives the player the weapon whose item classname or pickup name matches <weapon>.

takeweapon <weapon> or takeweapon all

Takes the weapon whose item classname or pickup name matches <weapon> from the player. If the all version is used it takes all weapons from the player.

setammo <name> <amount>

Gives the player <amount> ammo whose item classname or pickup name matches <name>.

giveinventory <name>

Give the player the predefined amount of the item whose pickup name matches <name>. These items can be holdable, powerup or armour.

 

Player and NPC

selectweapon <weapon>

For the player this command selects and readies the weapon whose item classname or pickup name matches <weapon>. For an NPC it changes the far attack weapon used to one whose name matches <weapon>. The weapon name must be one of the following :

  • fireball
  • batball
  • plasma
  • seabig
  • seasmall
  • bullet

 

All Entities

trigger <ainame> <name>

This causes a trigger event to occur for the entity whose ainame matches <ainame> and with a trigger name of <name>. If the entity has a script event block called trigger <name> then that event will be run.

print <string>

Print <string> to the console. The <string> text may contain spaces.

wait <duration>

Pause the execution of the script for <duration> milliseconds.

wait forever

Pause the execution of the script indefinitely.

lockplayer on/off

Set the lockplayer condition on or off. When the lockplayer condition is on the player's movement is frozen.

abort_if_loadgame

If the level was started from a loaded game then abort the rest of the script event block. This will cause the rest of the script commands in the event block to not be executed.

startcam <name>

Start a scripted camera whose name, without extension, matches <name>.

startcamblack <name>

Start a scripted camera whose name, without extension, matches <name>. The camera will startout with a black screen and fadein in 1.5 seconds.

stopcam

Stop the currently running scripted camera.

mu_start <music>

Sets the background music to the file whose name matches <music>. The file name requires a path and extension. This music file will be looped and play continuously.

mu_play <music>

Sets the background music to the file whose name matches <music>. The file name requires a path and extension. This music file will play only once.

mu_stop

Stop the currently playing background music.

playsound <sound>

Plays the sound file whose name matches <sound>. The file name requires a path and extension.

resetscript

This resets the status of the entity's script to allow the entity to start fresh again.

alertentity <name>

This causes the entity whose targetname or ainame matches <name> to be "used".

backupscript

Backs up the entity's script information.

restorescript

Restores a backed up script.

notarget on/off

Turns the notarget flag for the entity on or off. An entity with the notarget flag on can not be seen by other entities.

cvar <name> <value>

Set the cvar called <name> to <value>.

sethealth <value>

Set the entity's health to <value>.

knockback on/off

Sets the entity's knockback flag on or off. When this flag is on the entity will be moved by projectile impacts.

changelevel <level> or changelevel <level> persistent

Change the level to the map whose name (without extension) matches <level>. If persistent is included then the player's persistent data will be saved across the level change. If <level> is set to gamefinished then the game will be stopped and you will be returned to the end of game menu, or if that does not exist, the main menu.

endgame

The game will be stopped and you will be returned to the end of game menu, or if that does not exist, the main menu.

accum < index> <command> <parameter>

This script command is used to implement what-if statements in a script. Each script block has 8 accumulators (0 to 7) associated with it that are specified in the script command by the <index> value. The contents of the specified accumulator is modified by or tested against the <parameter> value by the <command>. The <command> are :

  • inc - add the parameter value to the accumulator
  • abort_if_less_than - abort the remaining commands in the script event block if the accumulator value is less than the parameter value.
  • abort_if_greater_than - abort the remaining commands in the script event block if the accumulator value is greater than the parameter value.
  • abort_if_equal - abort the remaining commands in the script event block if the accumulator value equals the parameter value.
  • abort_if_not_equal - abort the remaining commands in the script event block if the accumulator value is not equal to the parameter value.
  • set - set the accumulator to the parameter value.
  • bitset - set the bit of the accumulator ( 0 to 31) as specified by the parameter value to 1.
  • bitreset - set the bit of the accumulator ( 0 to 31) as specified by the parameter value to 0.
  • abort_if_bitset - abort the remaining commands in the script event block if the bit of the accumulator ( 0 to 31) as specified by the parameter value is 1.
  • abort_if_not_bitset - abort the remaining commands in the script event block if the bit of the accumulator ( 0 to 31) as specified by the parameter value is 0.
  • random - set the accumulator to a random value ranging from 0 to the parameter value minus one.

deletetarget <name>

Remove the entity whose targetname or ainame matches <name> from the level.

 

NPC Only

wait <duration> <target>

Pause the script for <duration> milliseconds and turn to face the entity whose targetname or ainame matches <target>.

wait forever <target>

Pause the script indefinitely and turn to face the entity whose targetname or ainame matches <target>.

playanim <animation> <duration>

Play the animation whose name matches <animation> and wait for <duration> milliseconds before executing the next script command. The animation names for an NPC are :

  1. death1
  2. death2
  3. death3
  4. taunt
  5. attackfar
  6. attackmelee
  7. idle
  8. idleactive
  9. walk
  10. run
  11. backpedal
  12. jump
  13. land
  14. pain
  15. special0
  16. special1
  17. special2
  18. special3
  19. special4
  20. special5
  21. special6
  22. special7
  23. special8
  24. special9

dropitem <name> <angle>

Drop the item whose pickup name matches <name> at an angle of <angle> degrees.

explicit_routing on/off

Turn the explict routing on or off. Explict routing is when an NPC is set, through the entity definition, to follow a path made up from npcpath entities. If this is set to off in the spawn event then the NPC will not follow the defined path.

nosight <duration>

Stop the NPC from being able to see any enemies for <duration> milliseconds.

nosight forever

Stop the NPC from being able to see any enemies indefinitely.

sight

Allow the NPC to see enemies again.

clearanim

Stop the current animation from playing.

noattack <duration>

Don't allow the NPC to attack anything for <duration> milliseconds.

attack

Allow the NPC to attack again.

attack <ainame>

Force the NPC to attack the entity whose ainame matches <ainame>.

movetype <type>

Set the movement type for the NPC to <type>. The movement type can be one of the following :

  • walk
  • run
  • fly
  • default

A default movement type uses the normal movement for the particular action the NPC is doing.

pushaway <ainame>

Push the entity whose ainame matches <ainame> away and to the side. The force of the push depends on the distance to the entity.

teleport <targetname>

Teleport the NPC to the location of the entity whose targetname matches <targetname>. Teleport effects will be shown at the start and end locations.

facetargetangles <targetname>

Turn the NPC so it faces the same direction as the entity whose targetname matches <targetname>.

noaidamage on/off

Set the noaidamage flag on or off. If this flag is on then the NPC can not receive damage from other NPCs.

fireattarget <name>

Turn the NPC so it faces the entity whose targetname or ainame matches <name> and fire its weaon at it once.

fireattarget <name> <duration>

Turn the NPC so it faces the entity whose targetname or ainame matches <name> and fire its weaon at it for <duration> milliseconds.

follownpc <ainame>

Use the current movement type and move towards and follow after the NPC whose ainame matches <ainame>. The NPC will continue to follow the other NPC until the script is reset or the stopfollow command is executed.

stopfollow

Stops the NPC from following another NPC.

gotomarker <marker>

Use the current movement type and move towards the npcpath entity whose targetname matches <marker>. The command does not end until the NPC reaches the npcpath entity location area.

gotomarker <marker> nostop

Use the current movement type and move towards the npcpath entity whose targetname matches <marker>. The command does not end until the NPC reaches the npcpath entity location. The nostop parameter increases the size of the npcpath entity location area so the NPC can turn smoothly to move to another location.

walktomarker <marker> and walktomarker <marker> nostop

The same as gotomarker except the movement type is walk.

runtomarker <marker> and runtomarker <marker> nostop

The same as gotomarker except the movement type is run.

gotonpc <ainame>

Use the current movement type and move towards the entity whose ainame matches <ainame>. The command does not end until the NPC reaches the entity location area.

gotonpc <ainame> nostop

Use the current movement type and move towards the entity whose ainame matches <ainame>. The command does not end until the NPC reaches the entity location. The nostop parameter increases the size of the entity location area so the NPC can turn smoothly to move to another location.

walktonpc <ainame> and walktonpc <ainame> nostop

The same as gotonpc except the movement type is walk.

runtonpc <ainame> and runtonpc <ainame> nostop

The same as gotonpc except the movement type is run.

deny and denyaction

These set the denyaction script flag to on. This flag is used by a number of script events to stop the NPC from performing an action you don't want. These commands can be included in the following script event blocks :

  • bulletimpact - don't investigate a bullet impact sound or sighting.
  • statechange - don't perform the behaviour state change.
  • inspectsoundstart - don't investigate this particular weapon sound.
  • inspectbulletstart - don't investigate this particular bullet impact.
  • inspectbodystart - don't investigate this particular corspe sighting.
  • inspectfriendlycombatstart - don't investigate this particular friendly who is fighting.
  • meleeattack - don't perform the melee attack.
  • farattack - don't perform the far attack.

painattacker

Cause the NPC to attack the entity that last caused it pain.

addevent <event>

Cause an event to happen whose name matches <event>. The following events can be used :

  • manexplode - shows a body gibbing with screen shake.

addeventremove <event>

The same as addevent except the NPC entity is removed from the level as well.

deathremove on/off

Set the NPC's deathremove flag on or off. If the deathremove flag is on the body of the corpse will sink into the ground after a short period of time.

jumpattack on/off

Set the jumpattack flag on or off. If the jumpattack flag is on the NPC will use a long jump melee attack rather than a weapon as it's far attack.

jumpmove on/off

Set the jumpmove flag on or off. If the jumpmove flag is on the NPC will move by jumping rather than walking.

statetype <type>

Change the behaviour state of the NPC to the state that matches <type>. The state can be one of the following :

  • relaxed
  • alert

 

Return to Home Page