### Character Script Commands

When the player enters the room, NPCs start performing the behavior you designate. There are four general classes of script commands, as follows:

1. Placement
2. Condition
3. Interaction
4. Queries
5. Decision making

Notes about using NPC scripts
Imperatives
Examples of branching code structures
Example of using the Special Command key
Example of using World Map commands
Predefined script vars
Threat clock display modes
List of player command input variables
Image Overlay commands

1. Placement - Change the NPC's location.

1. Appear - If not visible, the NPC will appear at the current square (i.e. it enters the room). This command does nothing if the NPC is already visible. If a monster or the player occupies the square it is appearing in, then the NPC will wait until the square is vacant to appear.
2. Appear at - Use this to have an invisible NPC enter the room at a designated square different from the one where the NPC is current located. After selecting this command, the room will temporarily appear. Click on a square to select where the NPC will enter the room. This command does nothing if the NPC is already visible. If a monster or the player occupies the square the NPC is to appear in, it will wait until the square becomes vacant to appear.
3. Disappear - Removes the NPC from the room, making him invisible. Use this to show an NPC leaving the room. Script commands continue to play while the character is invisible but the NPC will not physically interact with any room elements unless it Appears again.
4. Move to - The NPC will move to the indicated square (selected by clicking on a room square, as above). Optionally, one of the entity types listed in the adjacent list box may be selected as who the NPC should follow. Hold <Ctrl> while clicking to select and unselect multiple selections. Each turn, the NPC will attempt to move one square closer to its destination. It moves roughly in a straight line and won't move on a given turn if something is in its way. Enable "Forbid turning" if you don't want the monster turning to face the direction it is moving each step. Hint: If you want the NPC to move in a more complex fashion, such as following a twisting corridor, this can be accomplished with a sequence of Move to commands, one to navigate each twist in the corridor. This command finishes when the NPC arrives at the destination square. Enable "Single step" to have the NPC only attempt to make a single step toward the indicated destination before continuing to the next script command. If no move can be made, the next script command is executed immediately.
5. Move - Similar to Move to, except a relative number of tiles to move from the NPC's current location is specified. Positive numbers indicate movement south and east, and negative numbers are for moving north and west.
6. Face direction - Initially, the NPC faces the direction it is oriented when placed in the room. Use this command to turn the NPC in a different direction without moving (takes 1 turn).
7. Face towards like guard - Use this command to make the NPC change the direction they're facing towards a given point or entity just as the guard would.
   Single step: Setting this to on will make the character slowly turn towards the target direction. Off will make it turn immediately, just as face direction does.
   Targets: You can select zero, one or multiple targets from the list of entity groups - ctrl+click to deselect/select multiple. If no group is selected you will be asked to select a tile towards which the NPC should face.
   Using in conditions: This command can be used with if statements to check if the character is already facing the target direction.
   Using MyScript: This command supports the following MyScript parameter injections: X/Y - position in the room if no target group is selected; W - single step 0/1; F - bit map of the target groups.
8. Teleport to - Instantly moves the NPC to the indicated tile, as long as another entity is not occupying it.
9. Teleport player to - Instantly moves the player to the indicated tile processing all interactions: player will drown or fall into pit, potions will be drunk, the weapon will stab, pressure plates will toggle, etc.
   Interactions with potions: If the player is teleported multiple time during a single turn and they happen to land on one or more blocking potions (mimic, decoy and clone) then only the first of these potions will be consumed. However if the blocking potion is followed by non-blocking ones (invisiblity, speed, horns) they will be drunk. Horns are considered potions by the game. Avoid using this obscure mechanic in puzzles.
   Blocked teleports: This command will be silently ignored if you try to teleport the player: onto another monster/entity which can't be killed by stepping, to a location outside the room boundaries, onto the tile currently occupied by the player.
   Temporal recording: If the player gets teleported the quantum flux will reset and stop the temporal recording.
   Monsters on target tile: You can teleport onto a monster and instantly kill it if you are currently capable of killing that monster by stepping onto it. You can't teleport onto monsters that leave a pile behind, just like you can't step on them in the Slayer role or while wielding a dagger (in case of the dagger it's the stab that kills, you don't actually end up moving onto their space).
   Using MyScript: This command supports the following MyScript parameter injections: X/Y - position where the player should be teleported.

2. Condition - How the NPC functions.

1. Set appearance - Changes the NPC's "Graphic" and default properties to the specified entity type.
2. Turn into monster - Turns the NPC into a regular monster of the type indicated by its graphic. This ends script execution immediately and the NPC is permanently replaced by a regular monster.
3. Imperative - Sets a special status condition on the NPC (see Imperatives). Compatible imperatives may be combined.

3. Interaction - How the NPC interacts with its environment.

1. Activate item at - Activates the item at the room square you select. Items that can be activated are: orbs, pressure plates, lights and wall lights. Nothing will happen this turn if no relevant item is at the indicated square. Hint: Move the character next to orbs before striking them for more intuitive behavior. If no one is next to the orb when struck, it will appear that Beethro is using his portable orb.
2. Speech - Causes someone in the room to say something.
   Dialog text: Type the words that are said. This may be left blank in order to only play a sound effect.
   Speaker: who says the words. The text appears next to the person's figure in the room and their face appears on screen while they are speaking. Use "Custom" to have the NPC "throw its voice" to a different square in the room. If a monster or character is located at the indicated square when this command is executed, it will appear as if this monster or character is speaking. If speaker is set to "None", or the person indicated is not present in the room, then the words will appear next to the NPC.
   Mood: the face displays the indicated mood. Not all moods are available for all speaker types.
   Speech delay: How long, in milliseconds, the speech lasts for. If placing multiple lines of speech in sequence, this determines how much time passes until the next line of speech (and corresponding speaker) is displayed. Set this value to zero to have the game engine calculate how long to wait based on the length of the speech text.
   Add sound: A sound file (Wave or Ogg Vorbis format) on disk can be optionally attached to the speech. If a sound is specified, it will play along with the text and the next speech command will be played when the sound completes. Use a non-zero speech delay to force when the next line of speech will play regardless of how long the attached sound file plays.
   Exporting speech text: A hold's entire speech script can be exported to an HTML file on disk when exporting the hold by adding the line "ExportSpeech=1" to the "[Startup]" section of Data/drod.ini.
3. Flush Speech (on/off) - Tells the game to immediately process any previously queued speech that hasn't had time to play yet. If "On" is selected, these texts will appear immediately onscreen. If "Off" is selected, then text that hasn't played yet won't show at all. Hint: This command is used for dramatic effect, to ensure speech queued after this command will be immediately spoken, as intended. This command is not needed if it doesn't matter at what point in play speech texts are delivered.
4. Ambient sound - Plays a custom sound effect, imported from a sound file on disk. Select "Loop Off" to play the sound once, and "Loop On" to play the sound repeatedly. Selecting no sound file in conjunction with this command will silence any ambient sounds playing when the command is executed.
5. Ambient sound at - Plays a custom sound effect, imported from a sound file on disk, from the room location you specify. The sound will play from the direction the sound is coming to the player in the room and will be quieter the further the player is away from that room tile. Selecting no sound file in conjunction with this command will silence any ambient sounds currently playing at the room location you specify.
6. Build marker - Mark a region of the room for building a certain object by citizen builders. When a builder builds on a tile, the tile is unmarked. Each room tile can be marked only by a single object type at a time. Selecting "None" unmarks any existing build markers in the room region you specify.
7. Build - Instantly build the indicated object in the specified room region. You may also remove objects from the specified room layer.
8. Destroy trapdoor - Causes a trapdoor at the indicated location to drop down.
9. Go to level entrance - Sends the player immediately to any level entrance defined in the hold, or ends the hold.
10. Attack tile - Executes an attack of the designed damage type to the designated tile.
11. Play video - Plays a video file, imported from a video file on disk, at the specified screen coordinates. Sound tracks in video files are not supported, but sounds and music may be played concurrently with the proper script commands. Currently, only Ogg Theora video format is supported.
12. Set music - Set any of the available music themes to play. Additionally, custom music, imported from a music file on disk, may be played. Only Ogg Vorbis and Wave formats are supported. Custom music can be set to continue playing across rooms by executing this command on room entrance.
13. Player role - Indefinitely sets the player to play the role you indicate. In these roles, properties that apply to that entity type generally hold.
14. Set player stealth - Change the player's stealth property on room entrance to the indicated value indefinitely.
15. Set player weapon - Change the player's current weapon type, or enable or disable wielding a weapon indefinitely.
16. Cut scene - When set, room turns will proceed automatically at the rate you specify without player intervention. Invoke this command with a rate of "0" to end the cut scene and return movement control to the player. Hint: This command is used for dramatic effect, to have NPCs do things, such as move around the room, without requiring the player to take turns to allow the NPCs to likewise move. If on a given turn no NPCs are executing, the cut scene playing will automatically terminate, restoring control to the player.
17. Answer option - Provides a multiple choice option for a Question command (see below). A label from the list of defined Label commands in the script must be selected as the point from where the script will continue execution if the user selects this choice. Up to nine answer options are supported for a given Question. Any additional options are ignored.
18. Set var - Each hold you create contains a set of zero or more variables, named by you. Use these variables to track persistent game state information across rooms during play. To add a variable to a hold, type its name into the uppermost text box and click "Add".
    Syntax: Variable names must begin with a letter or period and not contain any punctuation except underscore ('_'). Starting a variable name with a period ('.') configures it as a local variable instead of a global. This means each NPC will have its own version of a variable with this name and there is no value sharing among them.
    Modifying variables: Select a hold variable from the list, choose an operation and a value. Variables may either store an integer or text. If the operation you specify is "Assign text" or "Add text", the variable you select will be set to store the text you provide. You may also reference other variables to insert into the given text. For operations dealing with numbers, if you provide the name of another variable, its value will be used (invalid names will be considered a value of 0). Otherwise, the number you provide is used. Use the text box on top to specify the text being assigned or added to the variable. For other operations, use the text box on the right to input a number or variable name. The variable will store a number.
    Using variables in text: In variable text assignments, Speech, Questions (see below), level entrance texts, and scroll text, type "$<var name>$" to insert the current value of the variable you name at this point in the text. Type "$\n$" to skip to the next line of text.
    Comprehensive variable reference list: In the Room Editor Screen, press F2 to output a comprehensive list of hold variables to the clipboard (use the paste option of your favorite text editor to view this text). This list shows all rooms and NPC (x,y) locations where the variable is referenced in a script throughout the hold. A number after the (x,y) location of the script indicates how many times the variable is referenced in that script.
    Monitoring variables during play: Press Ctrl-F7 while playing to turn on and off the variable monitor. Whenever a script changes a hold variable, you will be notified onscreen. This only works while playtesting, playing a hold you authored, or playing a CaravelNet hold in beta.
    Deleting variables: To permanently remove a hold variable, select it from the list box on the left and click "Remove". Note that this removes the variable completely from the hold and all NPC scripts that use it, not just from this particular script.
19. Set shallow water traversal - Sets how and under what conditions the player interacts with shallow water terrain.
20. Game effect - Display a visual effect at a specified room location. Particle effects may have a direction given them. Some effects may play an optional accompanying sound effect.
21. Image overlay - Input a custom set of commands for displaying a custom image effect in the game room.
22. Generate entity - Creates a new entity of the specified type at room location (x,y) and the indicated orientation once that room tile is vacant. Custom NPCs with a default script defined may be created where an entity already occupies the room tile, but begins as not visible. NPCs will begin executing their default script when created.
23. Start global script - Begin executing the specified NPC's default script. To use this command, first create a custom NPC role, then give it a default script. The global script will automatically run in each room you enter for the rest of the campaign, until an End command or variant is executed. Only one instance of each custom NPC may be run as a global script while in any given room.
24. Display filter - Display the room with the indicated graphic filter.
25. Flashing message - Flash a message onto the room area. By default, the text is displayed in bright yellow. You may specify an alternate color by providing a six-character RGB hexadecimal code, with each two-character pair indicating a color value between 0 and 255.
26. Challenge - Used for the CaravelNet achievement/trophy system. When executed, this indicates that a challenge with the given name has been completed by the player.
27. World Map Select - Select an overworld map for subsequent World Map commands to be performed with reference to. Without this command, the other World Map commands will do nothing.
28. World Map Music - Sets the music that plays on the previously selected map. This only need be executed once during a hold playthrough. Any subsequent executions will override the previous setting.
29. World Map Tile Icon - Places an icon on the previously selected map. You specify the position the icon appears on the map, its state, and if active, what level entrance or map it leads to when the player clicks on it from this map screen. Icons persist on the specified map from that moment for the entire playthrough. Placing an icon at the same position as another will override the first. Using icon type "Off" will remove an icon from the map. You can select a custom NPC with a looping animation speed in order to display an animated graphic on the map.
30. World Map Image Icon - Places an image on the previously selected map. Works in other respects as the "World Map Tile Icon" command.

4. Queries - Use queries to examine the state of the room and wait indefinitely until certain events occur.

1. Question - If one or more Answer option commands have been provided previously in script execution, this will ask the user a multiple choice question with the dialogue you specify and answer options previously provided. Script execution will continue from the label of the Answer option selected by the player. Once a Question has been asked, the list of Answer options is reset for the next Question.
   If no Answer option commands have been provided before this command is executed, the user will be asked a "Yes" or "No" question with the dialogue you specify. If a yes/no Question is executed as the condition for an If ... command, the corresponding script block will execute if the user answers "Yes".
2. Is tile open - Check whether the indicated tile is open for the NPC to move to from its current location.
3. Wait - This tells the NPC to do nothing until the number of game turns you specify has passed. Wait 0 will stop the script at the current point until the next turn.
4. Wait for event - The NPC waits until the specified game event has taken place.
5. Wait for entity - The NPC waits for any of the selected entity type (or entities) to enter the room region you specify. Hold <Ctrl> while clicking to select and unselect multiple selections. After selecting this command, the room will temporarily appear. Hold down the mouse button and drag the mouse cursor to select the area any of the entity or entities must enter before the NPC does anything else.
6. Wait while entity - Wait while any of the selected entity type remains in the room region that you select.
7. Wait for door to (open/close) - Waits for the door at the selected room square to either open or close.
8. Wait for turn - The NPC does nothing until at least the specified number of game turns has passed since the player entered the room.
9. Wait for clean room - Waits until the room is in a conquer-ready state (i.e. all kill-required monsters have been removed).
10. Wait for clean level - Waits until the level has been cleared (i.e. all required rooms have been cleared).
11. Wait for Entity Type - Wait for a specific entity type to be present in a specified room region.
12. Wait while Entity Type - Wait while a specific entity type is present in a specified room region.
13. Wait for player to face - Waits until the player turns in the specified direction.
14. Wait for player to input - Waits until the player inputs the specified command.
15. Wait for player to move - Waits until the player moves in the specified direction.
16. Wait for player to touch me - Waits until the player bumps into the NPC.
17. Wait for no building markers - Waits until no script-defined building markers exist in the room region you specify.
18. Wait until var - Waits until a hold variable meets the condition you specify.
19. Wait for item - Wait until the specified element is located in the marked room region.
20. Get natural target - Finds the position of the entity this character would target if it was a monster and stores it in two global variables, _ReturnX and _ReturnY.
    Targeting type: You can chose what type of targeting to use when finding the target. Currently supported is Regular monster which is the targeting used by unbrained roaches, goblins, etc.
    Results: Results from this function are stored in _ReturnX and _ReturnY which are global variables, accessible by all scripts.
    No target: If no target is found the character's current position will be returned.
    Using in conditions: This command cannot be used with an if statements.
    Using MyScript: This command supports the following MyScript parameter injections: X - type of targetting (0=Regular monster).
21. Get entity direction - Gets the direction an entity at a given position is facing and stores the result in _ReturnX.
    Direction values: NW=0, N=1, NE=2, W=3, No orientation=4, E=5, SW=6, S=7, SE=8.
    Results: Result from this function is stored in _ReturnX which is a global variables, accessible by all scripts.
    No target: If no entity is found the function returns No orientation. If player is found on the specified position, the player's direction is returned.
    Using in conditions: This command cannot be used with an if statements.
    Using MyScript: This command supports the following MyScript parameter injections: X/Y - position to check.

5. Decision making - Use the following commands to execute only a marked portion of script commands or to continue executing script commands from a different location in the script.

1. If ... - Use this command to optionally run a block of one or more script commands, based on a condition you specify in the next script command, which must be a query. If the query is immediately satisfied, then the script commands that follow after will be executed. An If End, Else or Else if command indicates the end of the optional code block. If the following query is not true, the script will continue after the following the next Else or If End command that marks the end of the optional code block.
2. If .... The end of the Else block is indicated with an If End command.
3. Else - Marks the beginning of a script section that is executed if the query condition following the If ... command is not satisfied. Else commands in conditional blocks are optional, but they must always follow somewhere after an If ... to be meaningful.
4. Else if can optionally be used instead of Else to avoid nesting script commands. It works exactly the same as nesting an If ... If End block inside an Else
5. If End - Marks the end of If ... and Else blocks.
   Notes:
   1. A "?" symbol displayed in front of a command in the script list means the command is not a recognized as a valid condition for an If ... command.
   2. If ... commands may be nested, i.e., an inner code block may be completely contained within an outer code block.
   3. A "!" symbol displayed in front of a command in the script list means that an If ... or Else block is not properly closed with an If End command at the end, or that an Else command is placed without an If ... coming first.
   4. See "Examples of branching code structures" below.
6. Label - marks a location in the script to continue executing commands from (used in conjunction with Go to and Answer option commands). Also, labels may be used to simply comment in normal language on what the following script commands do.
7. Go to - Select a label to continue executing commands from. Hint: Use "Go to" to make a loop in the script that repeats a sequence of commands over and over. Use a Wait 0 command as the last statement of a loop that is to be executed once each turn.
8. Gosub - Similar to "Go to", it continues execution from the indicated label. Used in conjunction with "Return" for more modular scripting.
9. Return - Continue executing commands from the most recent "Gosub" command executed. When multiple Gosub commands are executed, then multiple Return commands will jump back to these in order from most to least recent.
10. End on room exit - Removes the NPC for the rest of the current game once the player exits the room. If the room is restarted before exit, then the NPC script will begin executing again from the beginning. Hint: use this command to have the NPC continue executing commands.
11. End - Ends the character script immediately and will remove the NPC for the rest of the current game once the player exits the room. If the room is restarted before exit, then the NPC script will begin executing again from the beginning. Hint: use this command to stop the NPC from executing any more commands.

Notes about using NPC scripts

1. Each character script begins execution when the room is entered. Once a script runs to completion, the character stops functioning. If the NPC is still in the room when the script ends, it will remain where it is until the player exits the room. Upon reentry, the script will start again from the beginning.
2. NPCs are not used to determine room completion (conquer status). That is, NPCs with un-Ended scripts will continue to appear in a conquered room each time the player reenters it.
3. A script can be made to not start again when the player reenters the room by placing an End command at the end of the script or by executing an End on room exit command anywhere within the script. A character can be made to run only while the room is unconquered by placing an If <Wait for Clean Room> check at the beginning of the script and If End at the end.
4. An NPC can be turned into a regular monster with the Turn into monster command. In this case, it may need to be killed in order to conquer the room.

Imperatives - NPC/script properties that may be set with the Imperative command.

1. Vulnerable: Makes the NPC vulnerable to killing. This is the default setting for most NPC graphic types.
2. Invulnerable: Makes the NPC invincible so it cannot be killed by stabbing or other methods of inflicting damage. The NPC may still be killed by falling off a platform or by briar growth. Some NPC types, like Wubbas, are invulnerable by default.
3. Critical hero: When set, the room will restart if the NPC is ever killed. Some NPC types, like Beethro and Halph, are marked critical heros by default.
4. Required target: When set, the NPC must be killed in order to conquer the room. This command only applies when the room is not otherwise clean on entrance.
5. Safe: Forbids the NPC to step on the player and kill him (default).
6. Sword safe to player: Sword stabs from this NPC won't harm the player.
7. Deadly: Allows the NPC to step on the player and kill him. Also makes sword hits deadly to the player (default).
8. Die: Makes the NPC die with a blood splatter.
9. Die special: Makes the NPC perform a monster-specific death sequence, if applicable. Currently, this command applies to rock golems and fegundos. Rock golem NPCs will turn into a rock pile when this command is invoked. Fegundos will explode and turn into a regular fegundo ash monster. For other monster types, this acts identically to "Die".
10. End when killed: If the NPC is killed, mark the script as ended so it doesn't repeat when the room is reentered.
11. Direct-only beelining: When desired diagonal movement is blocked, then don't move at all.
12. Normal beelining: Move diagonally when desired and possible, otherwise move axially if possible, prefering vertical movement when both horizontal and vertical movements are open.
13. Flexible beelining: When a desired diagonal movement is blocked, choose the better of horizontal or vertical movement that will get closer to the destination (default).
14. Smart beelining: As flexible beelining, but also will move diagonally closer to the destination when a desired axial move is blocked.
15. Pathfinding (open only): The shortest path is calculated and taken to the destination. Whenever the currently calculated path becomes blocked, then a new shortest path is calculated. When no open path is found, no movement is made.
16. Pathfinding: The most intelligent movement option. The shortest path is calculated and taken to the destination. Whenever the currently calculated path becomes blocked, then a new shortest path is calculated. When no open path is found to the destination, then the path that has the fewest obstacles along the way is followed, defaulting to normal beelining whenever obstacles completely block the remaining path.
17. Brain pathmap obstacle: This NPC is perceived as an obstacle to brain pathmaps, and brained pathmaps will calculate paths around the NPC.
18. Not brain pathmap obstacle: This NPC is not perceived as an obstacle to brain pathmaps (default), and brained pathmaps will not calculate paths around the NPC.
19. NPC pathmap obstacle: This NPC is perceived as an obstacle to other NPCs using the Pathfinding imperative. Other NPC pathmaps will be calculated around this NPC.
20. Not NPC pathmap obstacle: This NPC is not perceived as an obstacle to other NPCs using the Pathfinding imperative. Other NPC pathmaps will not be calculated around this NPC.
21. Ghost display: When invisible this character will still be drawn to the screen. It will be drawn before (underneath) visible entities.
22. Ghost display overhead: Just like Ghost display above, except the NPC will be drawn over other characters and monsters.
23. No ghost display: Disables any previously activated Ghost display on this NPC.
24. Not pushable: Makes this NPC resistant to any kind of pushing, even with weapons which naturally allow pushing (eg. staff).
25. Default pushable behavior: Resets the pushability of the NPC to the default behavior.
26. Pushable by body: Makes the NPC pushable by the body of the player, mimics, constructs and human-role characters (if a given entity is able to push mirrors it will also be able to push an NPC with this imperative). Regular, non-NPC guards, stalwarts, slayers and soldiers can't push mirrors and thus won't be able to push an NPC with this imperative. The same goes for all monsters except constructs which can push mirrors.
27. Pushable by weapon: Makes the NPC pushable by any weapon effectively making it invulnerable to weapon attacks. It won't be able to push the NPC wielding dagger because dagger doesn't occupy a physical space. All other forms of attack still kill the NPC, including adders eating them, explosions, spike and fire traps.
28. Stunnable: Weapon pushes will stun this NPC.
29. Not stunnable: Weapon pushes will not stun this NPC, but it will not move on the turn it was pushed (unless it was pushed after it already moved).

Examples of branching code structures:

1. A single code branch:
   If ...
   <condition>
   some optional commands here
   If End
2. Two code branches:
   If ...
   <condition>
   some commands here
   Else
   some other commands here
   If End
3. Nested branches:
   If ...
   <condition>
   some commands here
   If ...
   <condition>
   some more commands here
   If End
   some different commands here
   If End

Example of using the Special Command key

Speech Halph "Press Special Command to make me say something."
Label "Loop"
Wait for event Player uses special command
Speech Happy Halph "You did it!"
Wait 0 turn(s)
Go to "Loop"

Example of using World Map commands

When a player moves close to a level exit that transitions to an overworld map, use a script that defines a couple of locations on the map (level entrances) that the player can travel to in this manner:

Wait for entity Player 22,24,22,24
World Map Select 1
World Map Music 0,0
World Map Tile Icon Halph,Level state,100,100,1
World Map Tile Icon Beethro,Level state,200,200,2
End

This script should typically only be executed once, hence the "End" command that runs last.

Predefined script vars

There are a number of predefined script vars that begin with an underscore. You may select these in variable commands to examine or set certain game states. For instance, you might query "_LevelName" in a global script to have it operate only in rooms on a certain level.
"_PlayerLightType" affects the player's light in dark rooms. Set it to a value <0 to turn off, 0 to turn on, and from 1-100 to use a flashlight beam. A higher value creates a more focused beam.
Set "_PlayerLight" to a value between 0 (default) through 128 to alter the player's light intensity and color, as follows:
16*(INTENSITY-1) + LIGHT_COLOR
where INTENSITY is from 1-8 and LIGHT_COLOR is from 1-16.
Variables prefixed with "_My" are connected to the state of the NPC, the "_*ImageX/Y" vars are tied to the defined origin for your room's custom images, and so forth.

Threat clock display modes

You may set the predefined "_ThreatClock" script variable to modify dynamically how the threat clock is displayed during play. The supported values are:
0: default
1: hide
2: always show
3: backwards time
100-129: display specific time (0-29)
200-229: display specific half-tick (0-29)

List of player command input variables

Predefined variable names may be provided in texts to output the player's current key binding for the respective command as text. To do this, provide a variable name of the form "$_CMD_<key>$", where <key> is one of the following:

1. MoveNorthwest
2. MoveNorth
3. MoveNortheast
4. MoveWest
5. Wait
6. MoveEast
7. MoveSouthwest
8. MoveSouth
9. MoveSoutheast
10. SwingClockwise
11. SwingCounterclockwise
12. Restart
13. Undo
14. Battle
15. UseCommand
16. CloneSwitch

Image overlay commands

In addition to selecting an image for display with the "Image overlay" command, you must provide a simple set of commands to define how the image will be displayed in-game. The list of supported (case-insensitive) commands for use in an Image Overlay script is as follows:
CancelAll -- remove all currently displaying image overlay effects. This command is typically run singly.
CancelLayer (layer #) -- remove image overlay effects on the specified display layer (0 through 3)
Center -- center the image within the room area
Display (ms) -- display the image in its current form for the specified duration
DisplayRect (x) (y) (w) (h) -- show this region of the source image
DisplaySize (w) (h) -- show this amount of the source image, in pixels
DisplayTurns (# turns) -- display the image in its current form for the indicated number of game turns
(p)FadeToAlpha (alpha) (ms) -- transition the image from its current alpha value to the indicated value over the specified time interval
(p)Grow (percent of original) (ms) -- scale the image by the indicated amount over the specified time interval
(p)Jitter (pixels) (ms) -- randomly shake the image off-center up to the indicated range for the specified time interval
Layer (layer) -- place the effect on the indicated display layer (0 through 3, generally corresponding to the menu tabs used for placing game elements in the room editor). Only the first instance of this command in a script is executed.
Loop (times) -- loop through the image command list this many times (-1 = infinite)
(p)Move (x pixels) (y pixels) (ms) -- translate the image's position by the indicated number of pixels over the indicated time interval
(p)MoveTo (x pixel) (y pixel) (ms) -- move the image from its current position to the indicated screen location over the course of the indicated time interval
(p)Rotate (degrees) (ms) -- rotate the image the indicated amount over the specified time interval
Scale (percent of original) -- scale the image to the indicated amount
SetAlpha (0-255) -- set the image's alpha transparency to the indicated value
SetAngle (degrees) -- set the image's angle of rotation
SetX (pixel) -- set the image's X coordinate
SetY (pixel) -- set the image's Y coordinate
SrcXY (x) (y) - show the source image starting from the indicated pixel position
As an example, you can make an image start invisible, fade in, display for a couple seconds, then fade out by providing the following command sequence:
setalpha 0 fadetoalpha 255 1000 display 2000 fadetoalpha 0 800
The text supports variable interpolation, so you can have parameters like "$.ImageX$" in the text. Any part of the command text may be inserted in this fashion.
Certain commands with time duration, marked above, may be optionally prefixed with the letter "p". This indicates that the command will not run to completion before any subsequent commands are executed, but rather will run in parallel with the next command. Multiple parallel commands may be executed concurrently.

Character Scripting
Room Editor
Level Editor
Contents