Manual:Zone Manual/The Room Section/DIL functions for rooms

From DikuMUD Wiki
< Manual:Zone Manual‎ | The Room Section
Revision as of 06:27, 15 November 2026 by Agent-mud (talk | contribs) (checked against the current code (wiki review 2026-11-15))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

DIL functions for rooms

DIL is the language for giving rooms, NPCs and objects behaviour of their own. This manual is about building zones, so it doesn't teach you to write DIL; the DIL manual does. The zones that come with the server contain many DIL templates you can use without writing any DIL yourself. This page lists the ones made for rooms.

You put a template on a room with dilcopy, the template's name, the zone it is in, and its arguments:

dilcopy death_room@function(PULSE_SEC * 15, 60, "Flames shoot up from the floor.");

The ; at the end is required. vmc checks neither the name nor the arguments: a wrong name or a missing argument compiles without a word and shows up only at boot or when the script runs, in vme.log. Check them against the template's dilbegin line in its zone file (in vme/zone/).

Times are given in ticks of a quarter of a second. PULSE_SEC (4) from vme.h makes them easier to read: PULSE_SEC * 15 is 15 seconds.

Death room

dilbegin death_room(tick : integer, damage : integer, act_s : string);    // function.zon

Hurts the players in the room: every tick ticks (at least 12, three seconds), each player in it loses damage hit points and sees act_s (or "You bleed from your wounds." when it is ""). A player whose hit points run out dies. It can kill slowly, like a smoky cave, or at once, like open space. Gods are not hurt.

NPCs are spared, unless the room has an extra named $death room for mobs; then NPCs are hurt too, except those with an extra $no death room.

dilcopy death_room@function(PULSE_SEC * 60, 60,
   "Flames shoot up from the floor, burning your feet.");

This does 60 hit points of damage every minute.

Force move

dilbegin force_move(tick : integer, strings : string, random : integer);    // function.zon

Moves everything in the room to another room without anyone typing a command: rivers, quicksand, transporters.

  • tick: how often, in ticks (at least 12, three seconds).
  • strings: one string with the destination room as symbol@zone, a !, and the message shown to whoever is moved: "river2@riverzon!You float down the river.". Without the ! and a message, or with a room that doesn't exist, the script writes an error to vme.log and stops.
  • random: FALSE (0) moves at a steady rate; TRUE varies each wait by up to half of tick either way.

Players, NPCs and objects in the room are all moved, except rooms inside it and anything with an extra named $no force move. Each sees the message, players see the new room, and the others there see "Someone has arrived."

dilcopy force_move@function(PULSE_SEC * 30, "river2@riverzon!You float down the river.", FALSE);

Keep the string on one line in the zone file, and put <br/> in the message where it should break. The old &n code doesn't work in DIL arguments.

Water current

dilbegin watercurrent(dir : integer, messages : stringlist, beats : integer);    // basemove.zon

A river or stream that carries players, NPCs and objects downstream, a little at a time. About every five seconds everything in the room counts one beat; after beats beats it is carried out through the exit dir (DIR_EAST and so on from vme.h; the exit must exist). Players and NPCs make a swimming check against that exit's difficulty first and swallow water, losing hit points, when they fail; they are carried along either way. Whoever sits in a boat drifts with the boat.

messages holds four messages:

  1. to the one carried away;
  2. to the others in the room left behind;
  3. to the one being carried, every second beat while waiting;
  4. to the others in the room it arrives in.
dilcopy watercurrent@basemove(DIR_EAST,
   {"The river current gently takes you east.", "$1n gently flows away to the east.",
    "You gently flow further eastwards.", "$1n flows in from the west."}, 6);

This, from cypress.zon, carries everything east after about 30 seconds. Give the room movement SECT_WATER_SWIM so that walking in and out of it means swimming too.

Scrambled exits

dilbegin scramble(a_exit : string);    // function.zon

For mazes: when a player types one of the directions named in a_exit, they are taken out through a random exit of the room instead, together with their followers. Only north, east, south, west, up and down are used, also for the random pick, and a closed door doesn't stop it. Gods and NPCs walk normally.

dilcopy scramble@function("north east south west");

The template also means to refuse drag and ride in the room, but doesn't: those commands still work.

Blocking commands

dilbegin block_cmd(blockcmds : stringlist, actvict : string, actrest : string);    // function.zon

Made for guards, but it works on a room too: the commands in blockcmds do nothing in the room, for anyone. actvict is shown to the one who tried, actrest to the others in the room; either can be "".

dilcopy block_cmd@function({"bury", "dig"}, "The floor is solid rock.", "");

Seasonal zones

dilbegin season(startm : integer, startd : integer, endm : integer, endd : integer,
                minutes : integer, syms : stringlist, hook : string);    // function.zon

Put on one room of a zone with reset RESET_NEVER, it resets the zone every minutes minutes between two dates of the real calendar (a Christmas or Halloween event), and removes the units in syms when the season ends. The comment above it in function.zon explains the arguments; hallows23.zon uses it.

safe_room

dilcopy safe_room@function();

Refuses attacks in the room: kill, hit, backstab, kick, bash, trip, disarm, rescue, drag, steal, filch, pickpocket, cast, use and recite get "Spells and attacks are not allowed in safe rooms." It only looks at commands whose last word names a unit in the room, so a spell cast without a target (an area spell, say) gets through. NPCs without a master are not checked, anyone may act on the character they follow, and members of the police academy quest may attack outlaws. See Game Mechanics: Rooms.

Templates you won't find

Older versions of this page and of the manual list templates that are gone or never existed:

  • death@function is death_room@function, and its damage is in hit points, not percent.
  • climb@function still exists but does nothing: climbing is now set with the EX_CLIMB exit flag, see Climbing.
  • The old special SFUN_DEATH_ROOM and SFUN_FORCE_MOVE were replaced by the two templates above.

To write a template of your own, start with dilbegin and the room's events: a room script is woken by the commands typed in it (SFB_CMD) and by its heartbeat (SFB_TICK), and moves units about with link().

Previous: Compiling and debugging your first room
Next: A more complex set of rooms