Re: [circ] Universal object?

From: Erwin S. Andreasen (erwin@PIP.DKNET.DK)
Date: 01/19/98


On Mon, 19 Jan 1998, Chris Jacobson wrote:

> Besides, imagine the mess of code you would have... probably best to just
> go C++ with those 3 classes... on my MUD, obj_to_room has become member
> to_room of ObjData... if I were to make a meta class that all 3 primary
> classes would inherit from, it would at most contain memory management
> and the "id" member, which is the only member in common.

If you want to go that way, an idea would be to use message-based
programming.

The idea we are currently implementing is that there is an Entity class,
that is a generic thing that responds to messages and may contain other
Entities.

A character would be a specialized entity. An affect would as well.

A command like say, would first send out a message to nearby Entities
asking for "permission" to say.

A mute spell cast on a character would catch that message and block it,
telling the character he is mute.

If the message is blocked, nothing further is done. If it is not, a
message saying taht the character is actually saying something is sent
out.

It is now up to each entity that receives that message to display
something, or perhaps trigger some trigger.

This results in very easily extendibility. For example, our perform_speech
code currently has checks for at least 14 different conditions: triggers
on the room, on mobiles, on objects, speechstones, whatnot. All this in
one central place. And, to add new behaviour, this central function needs
to be modified.

With message-based programming, adding a new type of spell that silences
everyone in the room is just a matter of creating an affect that catches
speech messages and displays something useful.

This does not have to extend just to actions: for example, most other
actions would also send a message and let the target handle the action.
For example, the default response to a GET message for a character could
be that he's too heavy, but you could then a mob that COULD be picked up
by overriding that message on that mob - without having to modify do_get
at all.

In fact, since all code modifications are done within the classes that
provide the message-handling functions themselves, they can easily be
fully put into some online softcoded language.


Right now, our move to Entities is in design phase still, but Bjorn Sparta
(sp) and others have made a working server that works this way. The
softcode is java.


 =============================================================================
Erwin Andreasen   Herlev, Denmark <erwin@pip.dknet.dk>  UNIX System Programmer
<URL:http://www.abandoned.org/drylock/>     <*>         (not speaking for) DDE
 =============================================================================


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST