Manual:DIL Manual/UNIT ST ROOM
Jump to navigation
Jump to search
UNIT_ST_ROOM
Constant (integer, vme.h: 0x04).
A room. u.type == UNIT_ST_ROOM. The type of a unit is in its type field; the four unit types are bits, so they can be combined with |.
Fields
Only rooms have: exit_names, exit_info, exit_key, exit_diff, exit_to, roomflags, movement, mapx, mapy. The exit fields take a direction as index, from NORTH (0) to MAX_EXIT (9) (vme.h).
Notes
- Every unit, whatever its type, has the general fields: name, names, title, descr, outside_descr, inside_descr, extra, type, symname, nameidx, zoneidx, zone, key, outside, inside, next, gnext, gprevious, flags, manipulate, openflags, opendiff, weight, baseweight, capacity, height, light, bright, illum, minv, alignment, hp, max_hp, loadcount, hasfunc, spells.
spells[]on a room is its magic resistance; the index is not used.- A room can be inside another room.
self.outsideof a room is the room around it, or null. - Reading a field the unit doesn't have fails, and a failed value is false in every comparison: test the type first.
Example
dilbegin integer exits(room : unitptr);
var
i : integer;
n : integer;
code
{
if (room.type != UNIT_ST_ROOM)
return (0);
i := 0;
n := 0;
while (i <= MAX_EXIT)
{
if (room.exit_to[i] != null)
n := n + 1;
i := i + 1;
}
return (n);
}
dilend
Counts a room's exits.