CthulhuMud Events
An event is an encapsulation of something that has happened within the mud. Events consist of a description of the occurrence combined with the context that the event occurred within.
Events are routed to all mobs in all involved rooms, all mobs monitoring those rooms and maybe some objects. Eventually the events wind up at mobs who view them and react to them. Players are shown the text within the event that is relevant to them (this is primarily how they receive all of their successful action notifications). Mobs pass the event through triggers, which may cause the mob to run a script in response to the event.
Information Contained in an Event
Each event contains the following:
- event type (integer)
- Indicates the general nature of the event.
- event subtype (integer)
- A more specific indication of the event’s nature.
- event context (context)
- Details of the mobs, objects, directions, location and other involved elements.
- actor’s message (string)
- Message sent to the actor (player only).
- victim’s message (string)
- Message sent to the victim (player only).
- observers’ message (string)
- Message sent to all observing players.
Master numbers for event types and subtypes are defined in the wev.h file.
Event Routing – Challenges and Reactions
Generating Events
Events are generated by actions, usually mobs attempting to do things. Parameters are resolved, a context is built, and a Challenge Event is issued.
Challenge Events
At this stage the action has not yet occurred. If any mob has a matching challenge trigger, the action is denied.
Action
If not denied, the action occurs.
Reaction Events
The completed event is issued again as a Reaction Event and routed to mobs and players for reactions and scripts.
Exceptions
- Arrival events have no challenge phase.
- Time and pulse events bypass room routing.
- OOC communication events go directly to players.
- Wide-area IC communication events are routed broadly.
- Combat attacks are challenge-only; results follow separately.
- Death events are reaction-only.
- Destruction of actors or objects is delayed until reactions complete.
Example Event Flow
Example: Chen enters a room, attacks an Orc, kills it, loots and sacrifices it. The following events are generated:
- Arrive, walking, Chen
- Look, room, Chen
- Look, mob, Chen, Orc
- Combat, attack, Chen, Orc (challenge)
- Combat, hit, Chen, Orc
- Damage, hurt, Orc
- Combat, attack, Orc, Chen (challenge)
- Combat, parry, Chen
- Combat, hit, Chen, Orc
- Damage, injured, Orc
- Death, slain, Orc
- Get, item_from_container
- Get, gold_from_container
- Sacrifice, npc_corpse
Performance Concerns
The system is efficient, relying on pointer manipulation and integer checks. Costs arise mainly when routing events to many rooms or mobs, or when extensive text processing is required.