This post explains how to set up switch effects in the map editor. (See the previous post for more details on the map editor.)
First of all, open up a segment containing some switches (e.g. A01.4) and take a look at the switches list (at the right-hand side of the editor window). Each switch is listed in the format “(x,y) [Effect]”, where (x,y) are the map coordinates of the switch and Effect is the effect itself (explained below). The coordinates start at the top left square (which is (0,0)) with x increasing to the right, and y increasing downwards.
Note that switch effects can be placed either on actual switches (in which case the effect is triggered when the switch is flipped up or down) or on floor tiles (in which case the effect is triggered when someone steps on the tile). Both are referred to as “switch effects” (or just “switches”) in the map editor.
The Effect can be one (or more) of the following:
Shoot(x, y, “direction”, item)
e.g. Shoot(0, -5, “north”, i_bolt_trap)
Used to set up bolt traps.
- x, y are relative coordinates of the point where the bolt should shoot out from. This usually points to a skull or wall tile. For example, Shoot(0, -5, …) means the bolt should start from a skull/wall square which is 5 squares to the south of the switch square. Shoot(-2, 3, …) means the starting square is 2 squares to the left of, and 3 squares above, the switch square. And so on.
- The “direction” can be “north”, “south”, “east” or “west” and indicates the direction the bolt will travel in.
- The “item” is always i_bolt_trap currently.
Activate(x,y) / Open(x,y) / Close(x,y)
e.g. Open(-2, 4)
Used to open/close doors etc. “Open” opens a door/pit/etc (or does nothing if it is already open), “Close” is the opposite, and “Activate” toggles a tile between open and closed.
- (x,y) give the relative coordinates of the tile to be activated, opened or closed. For example Close(1,2) closes a door one square to the right and two squares below the switch tile.
- The following tiles can be opened/closed/activated:
- doors (both wooden and iron)
- portcullises
- chests
- pits (NB there are three open pit tiles, and three closed pit tiles — note that the “wooden floor” tile is actually one of the closed pit tiles).
- pillars/crystal balls (“opening” a pillar turns it into a crystal ball, and “closing” turns it back into a pillar)
- pentagrams (“closing” a pentagram turns it into a dead pentagram that doesn’t do anything when stepped on, and “opening” it makes it active again).
TeleportTo(x,y)
e.g. TeleportTo(-1, 2)
This teleports the knight. Once again the (x,y) coordinates are relative, so the above example teleports the knight one square to the left and two down.
In addition, sound effects can be included, as follows:
- snd_click — A general clicking sound, used when a knight steps on a “pressure pad”.
- snd_crossbow — The sound of a bolt firing. Usually used together with “Shoot”.
- snd_door — The sound of a door opening/closing.
- snd_pentagram — The sound of a pentagram being used.
- snd_teleport — The sound of a knight being teleported. Usually used with TeleportTo.
Multiple effects can be combined, by enclosing the whole list in square brackets, and separating them by commas. For example, [Shoot(-3, 0, “east”, i_bolt_trap), snd_crossbow] would fire a bolt towards the knight and also play a crossbow sound, while [Open(-2,0), Open(3,2), Close(2,1)] would open and close several doors at the same time.
In a future version I might integrate the sound effects into the switch actions (so that “Shoot” always plays a sound as well as shooting a bolt) but for now you have to add any sound effects required as part of the switch definition.
To actually edit the switches you need to click the “Switches” button at the bottom (just below the main map area). Any existing switches will be highlighted on the map in red. To place a new switch, or edit an existing one, double click it and then type the switch effect you want. Note that you only type the part in square brackets, not the (x,y) coordinates. (So for example if a switch is listed in the switch list as (2,3) [Open(1,2)], you would enter this by double clicking on the square (2,3), and typing [Open(1,2)] into the dialog box.)
Switches can also be deleted by right-clicking them.
Don’t forget to test out your switches using the Test feature (Segment menu).
If you want to see examples of switches being used, have a look at the gnome book rooms (Z01.3 to Z09.3).
Finally, if you have questions, feel free to post them below, or ask on the Knights forum.
Happy editing 🙂