Return To Castle Wolfenstein Scripting Definitions


AI Attributes

running_speed: 220

Sets the AI's running speed. Default: 220 Range: 1 – 300

walking_speed: 90

Sets the AI's walking speed. Default: 90 Range: 1 – 300

crouching_speed: 80

Sets the AI's crouching-moving speed. Default: 80 Range: 1 – 300

fov: 240

This sets the FIELD OF VIEW for the AI. Default: 240 Range: 1 – 360

yaw_speed: 300

How fast they turn around. Default: 300 Range: 1 – 300

leader: 0.0

Not fully functional. It is suppose to change the AI's personality and behavior. Default: 0 Range: 0.0 – 1.0

aim_skill: 0.5

Sets the AI's ability to shoot at specific targets. Default: 0.5 Range: 0.0 – 1.0

aim_accuracy: 0.5

Sets the AI's accuracy. Default: 0.5 Range: 0.0 – 1.0

attack_skill: 0.75

Sets the AI's weaponry tactics. Grenades VS. Machine Gun, etc. Default: 0.75 Range: 0.0 – 1.0

reaction_time: 0.5

Sets the AI's reaction time in seconds. Default: 0.5 Range: 0.0 – 1.0

attack_crouch: 0.4

Sets the AI's frequency to crouch while attacking. Default: 0.4 Range: 0.0 – 1.0

idle_crouch: 0.0

Sets the AI's frequency to crouch while in idle. Default: 0.0 Range: 0.0 – 1.0

agression: 0.5

Sets the AI's aggression, good for charging its enemies. Default: 0.5 Range: 0.0 – 1.0

tactical: 0.8

Sets the AI's tactical abilities, using the environment for protection. Default: 0.8 Range: 0.0 – 1.0

camper: 0.0

Sets the AI's camping abilities. Default: 0.0 Range: 0.0 – 1.0

alertness: 16000

Sets the AI's sight distance in pixel units. Default: 16000 Range: 0 – 999999

starting_health: 100

Sets the AI's health when spawning in. Default: 100 Range: 0 – 99999

hearing_scale: 1.0

Sets the AI's hearing. Default: 1.0 Range: 0.0 – 10

inner_detection_radius: 512

Sets the Inner Detection Radius (IDR) for the AI in pixel units. The IDR will make the AI react to several things. Example: Bullet impacts within the IDR will affect the AI.


AI Scripting Events

    Key:
    [word/number], for example "enemysight [ainame]" = This is optional. For example: "enemysight player".
    <word/number>, for example "pain <threshold>" = This is mandatory. For example: "pain 50".
  

Attributes

Sets the AI's behavior when they first spawn in.

spawn

Will run all of the commands within this event upon spawning.

enemysight [ainame]

This event will trigger when they see an enemy AI for the first time (once only). If AINAME is used, then this will only trigger upon sight of the matching enemy AI.

sight [ainame]

This event will trigger when they see a friendly AI for the first time (once only). If AINAME is used, then this will only trigger upon sight of the matching friendly AI.

enemydead <ainame>

This event will trigger when the enemy AI (with corresponding AINAME) dies.

trigger <event>

This event will trigger when called upon, either by another script calling on this, or when going through a trigger brush.

pain <threshold>

This event will trigger when the AI is at a certain health.

death

This event will trigger once the AI dies. NOTE: All of the commands within this event must not take any think-time. For example, you cannot have a WAIT command in this event. If you do, it will crash.


AI Attributes

activate <ainame (usually player)>

This event will trigger when the player uses/activates this AI.

enemysightcorpse [ainame]

This event will trigger when the AI sees an enemy corpse.

friendlysightcorpse

This event will trigger when the AI sees a friendly corpse for the first time.

avoiddanger [weapon]

This event will trigger when trying to avoid a weapon.

blocked <ainame (usually player)>

This event will trigger when the player is blocking the AI from proceeding.

statechange <current state> <result state>

bulletimpact

This event will trigger when the AI detects a bullet within their IDR.

inspectbodystart [ainame]

When the AI first sees a dead body this will trigger. You are able to put an ainame following the command which will only trigger when that AI is dead. You can place a "DENY" in this event to stop the AI from inspecting the body.

inspectbodyend

This will trigger when the AI reaches the dead body.


Additional AI Events

inspectsoundstart

This will trigger when the AI hears a sound. He will then go and investigate that sound. You can place a "DENY" in this event to stop the AI from inspecting the sound.

inspectsoundend

This will trigger when the AI has reached the location of the sound.

playerstart

This will trigger once the player clicks on the 'next (arrow) button just after the loading.

fakedeath

This is triggered when the ZOMBIE does his "fake death."

attacksound

If used, then once the AI starts to attack the player and make a noise, this will trigger. Able to put "Deny" in order to prevent the AI from using generic sounds.

bulletimpactsound

If you want to have the AI say something when bulletimpact is triggered, use this event. Do not use "bulletimpact."

inspectfriendlycombatstart

This is triggered when the AI sees a friendly AI in combat.



AI Scripting Commands

gotomarker <targetname> [firetarget] [noattack] [nostop]

Tells the AI to go to an AI_MARKER using the current "MOTETYPE"; FIRETARGET- Shoots at this target while moving; NOATTACK- Does not attack while moving, may be used with firetarget so the AI faces/tracks a certain target while moving. NOSTOP- increases the AI_MARKER size by 32 pixels so that it gives a nice transition from 1 marker to the next.

runtomarker <targetname> [firetarget] [noattack] [nostop]

Tells the AI to run to an AI_MARKER. FIRETARGET- Shoots at this target while moving; NOATTACK- Does not attack while moving, may be used with firetarget so the AI faces/tracks a certain target while moving. NOSTOP- increases the AI_MARKER size by 32 pixels so that it gives a nice transition from 1 marker to the next.

walktomarker <targetname> [firetarget] [noattack] [nostop]

Tells the AI to walk to an AI_MARKER. FIRETARGET- Shoots at this target while moving; NOATTACK- Does not attack while moving, may be used with firetarget so the AI faces/tracks a certain target while moving. NOSTOP- increases the AI_MARKER size by 32 pixels so that it gives a nice transition from 1 marker to the next.

crouchtomarker <targetname> [firetarget] [noattack] [nostop]

Tells the AI to crouch to an AI_MARKER. FIRETARGET- Shoots at this target while moving; NOATTACK- Does not attack while moving, may be used with firetarget so the AI faces/tracks a certain target while moving. NOSTOP- increases the AI_MARKER size by 32 pixels so that it gives a nice transition from 1 marker to the next.

gotocast <ainame> [firetarget] [noattack]

Tells the AI to go to an AI character using the current MOVETYPE. FIREATTARGET- Shoots at this target while moving; NOATTACK- Does not attack while moving, may be used with firetarget so the AI faces/tracks a certain target while moving.

runtocast <ainame> [firetarget] [noattack]

Tells the AI to run to an AI character. FIREATTARGET- Shoots at this target while moving; NOATTACK- Does not attack while moving, may be used with firetarget so the AI faces/tracks a certain target while moving.


Additional AI Scripting Commands

walktocast <ainame> [firetarget] [noattack]

Tells the AI to walk to an AI character. FIREATTARGET- Shoots at this target while moving; NOATTACK- Does not attack while moving, may be used with firetarget so the AI faces/tracks a certain target while moving.

crouchtocast <ainame> [firetarget] [noattack]

Tells the AI to crouch to an AI character. FIREATTARGET- Shoots at this target while moving; NOATTACK - Does not attack while moving, may be used with firetarget so the AI faces/tracks a certain target while moving.

wait <duration> [moverange] [facetarget]

Tells the AI to wait for a certain duration. MOVERANGE- Used to set the amount of mobility the AI is able to use while waiting. FACETARGET- Used to track/look at a target.

trigger <ainame/scriptname> <event>

This will call/trigger an AI or Script_mover to run its "trigger <event>".

followcast <ainame>

This will tell the AI to follow an AI Character.

playsound <soundname OR scriptname>

This will play a sound.wav or a script name in one of the .sounds files.

noattack <duration>

This will tell the AI not to attack for the duration.

attack [ainame]

This will tell the AI to attack an AI.

playanim <animation> [legs/torso/both]

This will tell the AI to play a certain animation once. LEGS- Only to play the LEGS animation. TORSO- Only to play the torso animation. BOTH- Play both LEGS and TORSO.

setammo <pickupname> <count>

Sets the amount of ammo given to the AI.

selectweapon <pickupname>

Tells the AI to select a certain weapon.

giveweapon <pickupname>

Tells the AI to give him/herself a certain weapon.


Additional AI Scripting Commands

givearmor <pickupname>

Tells the AI to give him/herself armor.

giveinventory <pickupname>

Tells the AI to give him/herself an inventory item.

takeweapon <pickupname>

Tells the AI to get rid of a certain weapon.

movetype <walk/run/crouch/default>

Tells the AI to either walk/run/crouch everywhere. Default=run.

alertentity <targetname>

This will trigger/activate certain entities in the map. Usually just TARGET_RELAYS.

savegame

This will save the game for the player.

fireattarget <targetname> [duration]

This will tell the AI to fire at a specific target once. If you add a DURATION you the AI will shoot for the duration.

godmode <on/off>

This will give the AI invincibility.


Additional AI Scripting Commands

accum <buffer_index> <command> <parameter>

Accum is used for "what if" statements. Accums store integers which are used to trigger scripts.

missionfailed

This is used to fail the PLAYER from completing his mission objectives.

objectivemet <n>

This is used to tell the player and update the journal that he/she has completed their objective.

objectiveneeded <n>

This is used in the "player" spawn to tell the player how many objectives he/she needs to complete the mission.

noaidamage <on/off>

This tells the AI not to take damage from any other AI.

print <text>

This will PRINT text up on the screen/console.

facetargetangles <targetname>

This will tell the AI to match the same angle as the Target. The target's angle is determined within Radiant.


Additional AI Scripting Commands

resetscript

This will tell the AI to FORGET everything he is doing and everything he has done and either continue the script or go into dynamic mode.

mount <targetname>

This will tell the AI to mount a fixed weapon. Must have a fixed weapon nearby.

unmount

This will tell the AI to dismount the fixed weapon he is currently on.

savepersistant <next_mapname>

Saves (retains) data between certain levels for example the player's inventory and health. Not calling this routine before changing levels, is the equivalent of resetting the player's inventory, health, et cetera.

changelevel <mapname> [nostats] [persistant]

This will change the map to the "mapname." NOSTATS- This will not display the PLAYERS score/kills. PERSISTANT- This will bring all of the items

teleport <targetname>

This will teleport the AI to the origin of the "targetname" instantly.

foundsecret

This will increase the "Found Secrets" on the score board by 1.

nosight <duration>

This will make the AI blind for a duration.

sight

This will make the AI see again, if the AI is already blind.

avoid

This will tell the AI to avoid other AI, the player, and script_movers.
Note: By default, this is always on unless you tell it to "noavoid."

noavoid

This will tell the AI not to avoid anything. Including other AI, the player, and script_movers.

attrib <attribute> <value>

This will change any of the AI's attributes during a scripted event.
Note: STARTING_HEALTH cannot be used in this command.
See SETHEALTH for details.


Additional AI Scripting Commands

denyaction ("activate" Event only.)

This will deny the player from hitting his "use/activate" button on this particular AI.

headlook <on/off>

This will turn on/off the head look for the AI. This is an ambient head motion.
NOTE: The AI's tactical must be set to 0.5+

deny ("avoiddanger" event only)

This will tell the AI to not avoid danger. Example, when a bazooka is fired at this AI he will not avoid the rocket.

backupscript

This will backup the last script running for the AI.

restorescript

This will restore the last script the AI was running. Must have backupscript before restorescript can function.

statetype <alert>

This changes the AI's STATE. Currently, there's only ALERT.

knockback <on/off>

This enables/disables knockback, by default, it's ON. Knockback is the ability to knock the AI backwards due to a bullet hitting them.

clearanim

This stops the current animation the AI is playing and resets them to their default animation, depending on their state.

zoom <on/off>

This enables/disables the AI to use his binoculars. This also increases their IDR by 10 times the set amount. It also decreases their FOV by 80%.

parachute <on/off>

This enables/disables the AI to use a PARACHUTE movetype. This will enable them to play the parachute animation and shoot at the same time. As PLAYANIM is not able to do this, yet.

cigarette <on/off>

This enables/disables the AI to have a cigarette in his left hand or not.

sethealth <n>

Since "attrib starting_health" does not work, we added this command so it does work.

notarget <on/off>

This will enable notarget for the AI, just like notarget is for the player.

startcam <camera file>

This is used to call a camera and have it play.

startcamblack <camera file>

This is used to start a camera and have it play with a fade-up from black.

stopcam

This immediately stops the current camera.

cvar <cvarname> <value>

This is used to set "ROM" cvar commands.

mu_start <wav file> <n>

This is used to start the music file. The wav file is located in the main/music folder. <n> is the time you want to fade-up.

mu_stop <n>

This is used to stop the music file.

mu_fade <wav file> <n>

This is used to start the music file. The wav file is located in the main/music folder. <n> is the time you want to fade-up.

mu_queue <wav file>

This is used to start the next sound track right as soon as the current one stops playing.

explicit_routing <on/off>

This is used to turn on/off the AI's ability to dynamically navigate. Default, it's on.

lockplayer <on/off>

This is used to lock the player's movement. However, the player is still able to look around.

pushaway <ainame>

This is used to push the entity away, that is in front of the AI. Example; village1 when Kessler pushes the player out of the way, if the player tried to block him.

catchfire

This will instantly catch the AI on fire. This was used to prevent a bug from happening on faster machines in crypt2, where the guy comes around the corner on fire and then dies.



Brush Scripting Events

spawn

Will run all of the commands within this event upon spawning.

trigger <event>

Will run all of the commands within this event when called/trigger upon.

death (NOTE: Must have a "health" specified in entity.)

Will run all of the commands within this event when this AI dies. NOTE: You cannot use "wait"



Brush Scripting

gotomarker <targetname> <speed> [accel/deccel] [turntotarget] [wait]

This will tell the SCRIPT_MOVER to move to a target, usually a Path_corner. Targetname is "name" of the PATH_CORNER; SPEED is used for how fast the SCRIPT_MOVER will move to the PATH_CORNER; ACCEL/DECCEL are used to accelerate/decelerate to a PATH_CORNER. NOTE: For ACCEL, the SCRIPT_MOVER needs to start at speed of 0, and DECCEL needs to end at a speed of 0; TURNTOTARGET will face towards the target (PATH_CORNER) depending on the angle; WAIT is used so that the script will not read ahead until the SCRIPT_MOVER has reached the TARGETNAME.

wait <duration>

This will tell the SCRIPT_MOVER to not move for the duration.

trigger <aiName/scriptName> <trigger>

This will call/trigger an AI or Script_mover to run its "trigger <event>"

playsound <soundname OR scriptname> [LOOPING]

This will play a sound.wav or a script name in one of the .sounds files. LOOPING will loop the sound until "STOPSOUND" is used.

playanim <startframe> <endframe> [looping forever/duration] [rate FPS]

This will play an animation that the model has. STARTFRAME is the frame number you want to start on. ENDFRAME is the last frame number you want to play. LOOP FOREVER/DURATION is used if you want the animation to loop forever, or for a duration. RATE is used so that you can slow down the FPS.

alertentity <targetname>

This will trigger/activate certain entities in the map. Usually just TARGET_RELAYS.

accum <buffer_index> <command> <paramater>

Accum is used for "what if" statements. Accums store integers which are used to trigger scripts.

accum <n> inc <m>

This is used to "increase"/add to value already stored in the accum.

accum <n> abort_if_less_than <m>

This is used to abort the script if the value of accum <n> is less than <m>.

accum <n> abort_if_greater_than <m>

This is used to abort the script if the value of accum <n> is greater than <m>.

accum <n> set <m>

This is used to set the value of accum <n> to <m>.

accum <n> bitset <m>

This will set accum n's bitset of 0-31 to ON or 1, whichever you prefer.

accum <n> bitreset <m>

This will set accum n's biteset of 0-31 to OFF or 0, whichever you prefer.

accum <n> abort_if_bitset <m>

This will abort if the bitset is ON or 1. So, the bitset needs to be OFF or 0.

accum <n> abort_if_not_bitset <m>

This will abort if the bitset is OFF or 0. So, the bitset needs to be ON or 1.

accum <n> random <m>

This is used so that accum <n> will randomly choose a number.

missionfailed

This is used to fail the PLAYER from completing his mission objectives.

missionsuccess <mission_level>

This is used to tell the PLAYER he/she has completed the mission.

print <text>

This will PRINT text up on the screen/console.

faceangles <pitch> <yaw> <roll> <duration/GOTOTIME>

This will tell the SCRIPT_MOVER to rotate. DURATION/GOTOTIME, Duration will determine how long it takes the SCRIPT_MOVER to get to the ANGLES you inputted. GOTOTIME will calculate the time it takes for the SCRIPT_MOVER to reach its target (PATH_CORNER).

resetscript

This will tell the AI to FORGET everything he is doing and everything he has done and either continue the script or go into dynamic mode.

attachtotag <targetname/scriptname> <tagname>

This will attach this SCRIPT_MOVER to the TAG on another SCRIPT_MOVER. NOTE: The SCRIPT_MOVER you will attach to must have a TAG with a TAGNAME. The modeller (Jason) will do this for you.

stopsound

This will stop the sound the SCRIPT_MOVER is playing.

halt

This will stop the SCRIPT_MOVER in its tracks.

backupscript

This will backup the last script running for the script_mover.

restorescript

This will restore the last script the script_mover was running. Must have backupscript before restorescript can function.

sethealth <n>

This resets the health of the script_mover to <n>.




Scripting Structures

Basic Player Scripting structure

    
      player
      {
        spawn
        {
        }

        trigger <event>
        {
        }

        death
        {
        }
      }
    
  

Basic AI Scripting structure

    
      ainame
      {
        attributes
        {
        }

        spawn
        {
        }

        trigger <event>
        {
        }

        pain <threshold>
        {
        }

        death
        {
        }

        enemysight
        {
        }
      }
    
  

Basic AI Marching Loop

    
      nazi1
      {
        attributes
        {
          aim_accuracy 0.75
          attack_crouch 0.1
          idle_crouch 0.1
        }

        spawn
        {
          trigger nazi1 marchloop // This will begin the Marching loop.
        }

        trigger marchloop
        {
          walktomarker n1spot1
          walktomarker n1spot2
          facetargetangles n1spot2
          wait 4000
          walktomarker n1spot3
          walktomarker n1spot4
          facetargetangles n1spot4
          wait 4000
          trigger nazi1 marchloop // Restarts the marching loop.
        }

        death
        {
        }

        enemysight
        {
        }
      }
    
  

Basic Brush Scripting Structure

    
      scriptname
      {
        spawn
        {
        }

        trigger <event>
        {
        }

        death
        {
        }
      }
    
  

Basic Brush Scripting Clock Arm Rotating.

    
      clockarm1
      {
        spawn
        {
          trigger clockarm1 rotateloop // Begins the rotate loop.
        }

        trigger rotateloop
        {
          faceangles -90 0 0 1000
          faceangles -180 0 0 1000
          faceangles -270 0 0 1000
          faceangles -360 0 0 1000
          trigger clockarm1 rotateloop // Triggers the rotate loop over again.
        }

        death
        {
        }
      }
    
  


Return to Castle Wolfenstein Scripting Definitions

By Gray Matter Scripting Team © 2000 Gray Matter Interactive Studios. Original HTML adaptation by GtkRadiant team 2002, slightly polished and re-uploaded by Loffy 2024.




Back to Loffy's Domain