[MUD-Dev] Object Models

John Robert Arras johna at wam.umd.edu
Mon Nov 20 08:40:26 CET 2000


Ben wrote:

> For example I have an object that is both a key and a monster.

I started out coding on a Diku, and found there were a few big
deficiencies in the way it was coded. I didn't like the way rooms/
objs/mobs were split. As I was thinking about it, I first tried
to go with "room_data/obj_data/mob_data" all contained within a
thing, and so if you wanted to have a "room/obj" (like a boat),
you had to add in the room data and the obj data. This didn't work
out well at all. So, I decided to break down the attributes of
all of these things into their simplest components, and just
add these attributes to things one by one, as needed.


My perspective comes from trying to make stuff in a MUD work, not from
trying to implement a MUD using a certain programming technique. The base
structure of the world is such that everything is contained in something,
contains other things, and can be in the same thing as something else. 
Generally, a thing can only "impact" the thing it is in,
the things it contains, and the things which are in the same things as
itself. It is very hierarchical and makes the database recursive and
easy to work with.


What are the main categories of "things"? Room/obj/mob? But what are
these things? It mostly comes down to how things can manipulate other
things: mobs can generally talk, fight, can't be moved by other things, 
and can move themselves and other things. Objects generally can't
do much except get moved around by other things. Rooms can manipulate
things inside of themselves. So, each thing just gets flags set
which determine whether or not it can engage in certain kinds of
manipulations, and also how it can be manipulated.


The extra attributes you want an object to have like exits/portals/lids/
guards/shops/weapons/armor/food/scrolls/casting_spells/keys etc..are just
added as little chunks of data in a linked list. It is also possible to
add whatever flags you want to whatever thing you want, and sometimes
the flags have different purposes on different things. Such as, a "fish
mob" has a ROOM_WATERY flag set and so when an area resets the fish, it 
gets put into a random room with a "ROOM_WATERY" flag set.

So, the "key/monster" thing I would set up by making a monster, then
make it so you can pick up the monster, then make it so you can
wield/hold the monster, then add a "key" chunk of data, and then add some
information to that chunk (some flag) that says "if this key is used in
the wrong door, attack the user". I would then add a small
piece of code to the "unlock" function which says if the key can fight
and if this flag is set, and the door is wrong, the key leaps from your
hand and attacks you.


At any rate, this method is really really simple. Stuff just
falls into place and works without me putting in much effort.


John






_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the mud-dev-archive mailing list