Rooms

Muds have rooms where a player moves from room to room by typing a direction such as 'east'. The mud client, since it is connecting to a mud does the same thing and given the position of exits in a 3D room, the mud client will send a direction command (eg east) to the mud so that the player moves to a new room. The following is a scenario where a player using the mud client is in room number 1:

files/room3.jpg

In the scenario the player is a in a large 3D room in room 1. To the south is a doorway and to the east there is second mud room but in 3D there is no seperation of the rooms. When a player walks across an imaginary line to the east the 3D mud client will send an 'east' command to the mud and the player will move to 'room 2'.

Also if the player was in room 1 and walked through the doorway to the south then once he walked past the doorway the mud client will send a 'south' command to the mud and the player moves to 'room 3'.

The above diagram shows different ways in which the mud client can allow a player to move to different exits.

The mud can tell the mud client the positions of exits (though doesnt have to) using the room 3d tags. 3dtags for rooms start with 'r' character. For example: {rpx253.00y295.00,en0.2} to specify the the room centre is 253,295 and there is an north exit 0.2 units north of the room centre.

Room Centre
Rooms have a centre specified by a x,y position (can include z eg heaven). The position of objects and the position exits can be specified relative to the room centre. It is specified with the sub tag 'p'

{rpx253.00y295.00}

Objects can be specifed relative to the room centre such as {uprx0.1} means you are at position 0.1 east of the room centre. {odog,prx0.1,+} means a dog appears 0.1 mud units east of the room centre ie 253.1,295 if the above room centre is used.

Exit distance
In the above diagram the position of the imaginary line is 0.5 units east of the the room centre which is at 253.000,295.00

When a player moves past this imaginary line the player moves to the new room. The mud can specify the exit distance with the sub tag 'e' followed by the direction ('e') then follow by the distance (0.5) as specified in room 3d tags For example:

{rpx253.00y295.00,ee0.50}

is 0.5 units east of the room centre which 253.00, 295.00

This exit distance is calculated by default in SWLPC as halfway between two linked rooms. Room 2 is 1 unit east of room 1 thus the exit distance is 0.5. The exit distance can by overridden in SWLPC using the 'set_exitdist' roomlpc] function. For example 'set_exitdist("east",0.4)' will make the exit 0.4 units east of room 1 instead of 0.5.

Doorways
A reason to use a doorway as opposed to an exit distance is shown in the above diagram where a room might not be exactly rectangular as in 'room 1' which has a doorway at 252.5,294.7. The room continues south past the doorway a little to the east. If an exit distance was used then the mud client would think that they player had moved to the southern room if the player moved south past the doorway eg to position X in the diagram.

A doorway uses the sub tag 'd', followed by the exit direction (s) then the coordinate of the door:

{rpx253.00y295.00,dsx252.5y294.7}

Here there is a door to the south of the room at 252.5,294.7

The position of the door is specified in SWLPC using the 'set_doorxy' function. For example 'set_doorxy("south",252.5,294.7);'

A doorway has door width. Therefore in the above figure if the door width is 0.1 then if a player walks south between the points 252.45,294.7 and 252.55,294.7 then the player will go to the southern room. The default door width is specified in the config file room attribute 'doorwidth'. It can be overridden on SWLPC by adding a forth parameter to the set_doorxy function. For example:

set_doorxy("south",252.5,294.7,0.2);

will set the door width to 0.2 instead of 0.1;

Displaying Room centre and exits
The picture below shows the room centre (largest blue circle) with a the position of a doorway (small blue and green circles centre up) and to the right of the screenshot is an eastern exit specified by the blue wireframe square. The positions of the room centre and exits can be displayed by clicking on 'draw radius' in the control dialog.

files/roomradius.jpg


Room Radius
There are a few examples where the mud client uses a room parameter called the room radius. The room radius is the maximum distance of an exit from a room divided by 2. Thus if one room is at 200,300 and the room east of it is 201,300 then room radius of the first room is 0.5. It is used in staggeredposition when determining whether an object in the parent map is the one specified by the mud (eg {odog,+}). It is also used in the example below where if a player moves too far from the room centre the player can be stopped based upon the roomradius.

Distance a player can move from the room centre
This is the maximum distance of an exit from the room centre. In the above example it is 0.5 for room 1. This distance to the doorway is about 0.3. The room radius is used to determine how far a player can move from the room centre before being stopped. The distance a player can walk from a room centre before being stopped is the roomradius multiplied by the a factor called 'leeway' in the room element in the config file. For example if the 'leeway' is 1.5 and the room radius is 0.5 then a player can move 0.75 units from the room centre before being stopped.

When a player moves to a new room you can stop the player until you get a response back from the mud. Depending on latency this can take around 300ms leading to a player stopping as he moves between rooms. To stop this an attribute can be specified called 'rollgap' that is the distance a player can move outside of the room he has exited before waiting for a response from the mud. This can allow a player to keep moving in a room he hasn't yet arrived in on the mud itself.

Room Sound
The background sound that a room has can be specified as a room sub tag. For example the following means that the current room at position 253.00,295.00 has the sound of a street. It will play the sounds called 'street'.

{rpx253.00y295.00,sstreet}

The volume of the sound of a room can be specified in the config file room 'volume' attribute.

Room scripting in SWLPC
Scripting for rooms can be done in the mud mapper. It allows rooms to be positioned and rooms to be linked. The mud mapper by default uses the room centre in the filename of the script. For example:

c:\program files\mudclient\mudmapper\mlib\room\sanom\armourer253.820,300.120,0.lpc

This allows for the position of the room to be determined without needing to load the room. It allows SWLPC to estimate the exit distance of exits without needing the load the room at the other side of the exit.

The following is an example of a set of functions related to a room in a room script:

set_dest_dir ( ({
"room/sanom/road254.3,300.230,0","east",
"room/sanom/road252.987,300.230,0","west"
}));
set_xy(253.820,300.120);
set_exitdist("east",0.2);
set_doorxy("west",253.67,299.98);
set_sound("crowd");

set_dest_dir is an array of room files with the corresponding room exit
set_xy gives the room centre
set_exitdist gives the distance of the exit from the room centre
set_doorxy give the position of a doorway for an exit
set_sound is the sound you can hear in the room