Contexts
A context is an internal data structure that is used to describe a situation that has occured within the mud. Contexts are mainly used in events, but they also turn up in a few other situations where conditions must be evaluated.
Note that contexts do not tell you what has happened, they simply contain details about the mobs, objects, and other details that are involved.
Information Contained in a Context
Each context can contain the following:
- observer (mob)
-
This is the mob who is observing the situation. The mob who is watching. It is different for each observer.
- actor (mob)
-
This is the mob that is the active party in the situation. The mob that is doing.
- victim (mob)
-
This is the mob that is the target of the actors action. The mob that is being done to.
- primary object (object)
-
This is the main object that the actor is manuiplating. The object that is being done with.
- secondary object (object)
-
This is the ancilliary object that the actor is involving. The object that is being done to.
- location (room)
-
This is the room where the action is happening. If the observer, actor and victim are in the same room, then it is that room. If they are in different rooms, then which room it is depends upon the situation.
- number (int)
-
This is a number associated with the situation. It is used in several different ways, depending upon the situation.
- text (string)
-
This is a test string associated with the situation. Again, there are several different ways it is used, depending upon the situation.
- wev (event)
-
If the context is generated as a part of an event, then this will be a pointer to that event. The event also has a pointer to the context. This allows conditions which are evaluated against the context to reference data from the event.
Sample Contexts
Situation - Leaving a Room
When a character walks out of a room, the following information is put into the context:
- The observer (each person in or monitoring the room, including the actor)
- The actor (the person leaving the room)
- The room (that is being left)
- The number (of the direction they left in)
- The text (long name of the direction they left in)
- The wev (for the DEPART_WALK event)
Situation - Hitting Someone
When one mob hits another mob, the following information is put into the context:
- The observer (each person in or monitoring the room, including the actor and the victim)
- The actor (the person doing the hitting)
- The victim (the person being hit)
- The room (where the fight is occuring)
- The number (of hps of damage caused)
- The wev (for the DAMAGE_BLOW event)
Situation - Putting a Sword into a Chest
When one mob puts an object inside another one, the following information is put into the context:
- The observer (each person in or monitoring the room, including the actor)
- The actor (the person doing the putting)
- The primary object (the one that is being put)
- The secondary object (the one that the primary object is being put into)
- The room (where the putting is occuring)
- The wev (for the PUT_ITEM_INTO event)
For details about the contexts provided for events that occur within the mud, see the events command which is available within OLC.