Tells you how to make doors and place them in rooms.
The cDoor class is used to create doors that connect rooms.
You don't need to connect rooms with doors, but if you
want an obstacle (such as a locked door)
between the rooms, you'll need to add a cDoor.
If you haven't read the tutorial on cRoom - Room
objects then you should do that now.
Here's how you create a door:
-
Just as described in the "cObject" tutorial, create
a new object, but instead of deriving
your room off cObject, derive it from cDoor.
(cDoor is a subclass of cObject, so by deriving from cRoom
you are also deriving from cObject.)
-
Make sure the Automatically create as an object button
is checked.
-
Underneath the checkbox, select the room that
the door will be in. (A door is usually "in" two rooms at
once, since it straddles the two. I'll get to this later. For
now just pick one of the rooms.)
-
In the object's properties tab, you'll find a
number of properties that were automatically added when
you selected the "cDoor" class. You'll need to fill these in.
-
pNLPParseName and pNLPNounName will
need to be filled in. See How command parsing
works and Noun cases and noun-verb agreement.
Generally, pNLPParseName will be something like "[east] door",
and pNLPNounName "east door". You can provide more exciting
names, of course, but most people will expect doors to be called
"door".
Note: You don't have to fill in pNLPParseName
and pNLPNounName for doors since a name will automatically
be creasted by the door's exit within the room, such
as "northeast door".
-
pDoorCounterpart will be filed in later. I'll
explain below.
-
Doors do not usually have a pVisual property
because they aren't evey drawn (as a separate object in the
room) since they usually appear in the 3D model of the room.
If you want your door to be drawn as an object separate from
the room you'll need to provide a pVisual and
set pDontListInRoom to FALSE.
-
Now, switch to the room object that contains
the door.
-
Add a pExitXXXDoor property, where XXX is the
wall that the door is on, such as pExitEastDoor. Type
in the door's name, such as oDoorEast.
You're not done though. You have only created half a door.
Doors provide an unusual dilemma since they're an object that
must appear in two rooms at once, which isn't possible
with MIFL. Therefore, you need to create two door objects,
one for each room its in.
You have already created the first door object. Now you need to
create the second:
-
Return to the door object and
switch to the Misc.
-
Press the Duplicate this object button.
This does exactly what it says.
-
Modify the door's duplicate, chaning the room it
appears in, and the ID... you don't need to make
an entirely new number. Just change the rightmost digit.
-
In the "Properties" tab, change the
door's pNLPNounName and pNLPParseName,
usually changing "east" to "west", etc.
-
In both the doors, add
the pDoorCounterpart property. The value for
each should be the door's opposite. Setting this property
ensures that when one (half of the) door is opened, so is
the other (half of the) door.
-
Visit the object definition for the other room,
and set the pExitXXXDoor to the duplicate door.
That's it. You now have two doors that appear as one.
Normally you'd leave the duplication to the last moment, after
you had set and extra door properties, such as the ability
to lock it. By duplicating after all the lock properties have
been added you save yourself some work.
To create a locked door:
-
In the door's property tab, add the pLock property.
Set it to TRUE. This defaults to the door being
locked... which makes sense from a game point-of-view.
-
Also add the pLockShape tab, and type in
a string the identifies the shape of key that will
open the door, such as "SkeletonKey12". Some
keys may fit to several shapes, allowing them to open
several types of locks, just as master keys do. Conversely,
you can have a door accept several key shapes by
setting pLockShape to a list, like ["SkeletonKey12",
"SkeletonKey54"].
-
If you want your door to automatically lock itself after
it has been unlocked, set pLockAutoLock to
the number of seconds delay before it locks. This feature
is extremely handy for multi-user interactive fiction,
causing the door puzzle to reset. If you use automatic
locking you may also wish to set pOpenAutoClose to
have the door automatically close itself... a locked
door does not good if it's left open.
-
You'll need to make the exact same changes to
the door's other half, unless you want different behavior
for each side.
-
You'll need to create a key object that
supports pKeyShape with "SkeletonKey12".
See the tutorial, cObject - Generic objects for
information on general-purpose objects.
That's it. Now, players (and NPCs) will have to unlock the
door before walking through it.
Other properties and methods
Doors support some other properties and methods, such
as ways to make the doors see-through. For more information
see the documentation.
Share with your friends: |