An event is an encapsualtion of something that has happened within the mud. Events consists of a description of the occurance combined with the context that the event occured 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 relevent 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.
Each event contains the following:
The master numbers for event types and subtypes are defined in the wev.h file.
Events are generated by things happening, generally mobs trying to do things.
When a mob attempts an action, its parms are processed and resolved. A context describing the involved parties and the parameters of the action is then created. An event is then created, based upon the context, but adding the event description and the messages. The event is then issued as a Challange Event.
At this point the action described has not happened and if any mob in the room (or monitoring the room) has a challange trigger which matches it, the action will be denied. That is to say that the action will not occur and the command processing will simply end.
It is up to the mob whose challange trigger matched the event to run a script and provide an explanation to the player of why their action was disallowed. The MPSTOP command can be useful here.
If action was not denied it will now occur.
The event will then be issued again, this time as a Reaction Event.
The reaction event describes the completed event and will be sent to all mobs in the room (and who are monitoring the room). Players will be sent the appropriate formatted message, while mobs get to run the events through their reaction triggers to see if they want to react to it.
There are, of couse a number of exceptions to the above flows.
This arrival reaction event is in addition to the depart reaction event that was issued in the rom that the moving mob left.
In this example a character (Chen) walks into a room containg a mob (Orc) whom he then attacks. He injures the Orc, parries the Orcs blow and then kills the Orc before looting and sacrificing its corpse.
The events generated are:
The damage, hurt events are issued when a mob takes damage greater than 25% of its hit points (the number is the ammount of damage the mob suffered). The Damage, injured events are issued when a mob has less than 25% of its hit points left (the number is the number of hit points the mob has left). Not that for these events 9and the death event), then actor and victim roles are switched from the attack that caused the wound. This is because the acts here are being seriously injured and dieing.
Yes, this is a lot of work. But it runs very efficiently, being mainly pointer manipulation and integer comparisons. The triggers and scripts are considerably more efficient than many other mobprog implementations (no interpreted progs to parse). Memory thrashing is avoided by reusing the same blocks of memory over and over. Typically the entire mud will have only ever allocate 2 or 3 event or context structures.
It gets expensive when: