Multiplayer Interactive-Fiction Game-Design Blog



Download 8.87 Mb.
Page109/151
Date02.02.2017
Size8.87 Mb.
#15199
1   ...   105   106   107   108   109   110   111   112   ...   151

05 cDoor – Door objects


Tells you how to make doors and place them in rooms.


cDoor - Door objects

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.


Creating a new door

Here's how you create a door:





  1. 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.)





  2. Make sure the Automatically create as an object button

    is checked.



  3. 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.)



  4. 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.







  5. 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".


  6. 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".




  7. pDoorCounterpart will be filed in later. I'll

    explain below.





  8. 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.



  9. Now, switch to the room object that contains

    the door.



  10. 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:





  1. Return to the door object and

    switch to the Misc.





  2. Press the Duplicate this object button.

    This does exactly what it says.



  3. 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.





  4. In the "Properties" tab, change the

    door's pNLPNounName and pNLPParseName,

    usually changing "east" to "west", etc.





  5. 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.





  6. 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.



Locked doors

To create a locked door:





  1. 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.





  2. 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"].



  3. 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.



  4. You'll need to make the exact same changes to

    the door's other half, unless you want different behavior

    for each side.





  5. 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.




Download 8.87 Mb.

Share with your friends:
1   ...   105   106   107   108   109   110   111   112   ...   151




The database is protected by copyright ©ininet.org 2024
send message

    Main page