There are several kinds of events that scripts will receive, based on the script's event mask. Every event object has a type member, and one or more other members describing the event. Event constants are defined in include/eventid.inc
type | Description | Context |
EVID_SPEECH | PC Speech near an object or NPC | NPC, or script registered with RegisterForSpeechEvents |
EVID_ENGAGED | Someone has double-clicked an NPC while in war-mode | NPC |
EVID_DISENGAGED | Someone who had set an NPC as their opponent has exited war-mode. | NPC |
EVID_DAMAGED | something has damaged an NPC | NPC |
EVID_ENTEREDAREA | A mobile has entered the area near an NPC | NPC |
EVID_LEFTAREA | A mobile has left the area near an NPC | NPC |
EVID_ITEM_GIVEN | An PC has dragged an item onto an NPC | NPC |
Event type: EVID_SPEECH | ||
Members: | type | EVID_SPEECH |
source | character who spoke | |
text | spoken text |
Event type: EVID_DAMAGED | ||
Members: | type | EVID_DAMAGED |
source | character doing the damage, if known. Zero if unknown. | |
damage | amount of damage done | |
Notes: | damage may be zero. This indicates all damage was
absorbed by armor. Source will be unknown if damage is due to a ApplyDamage or ApplyRawDamage call. |
Event type: EVID_ENGAGED | ||
Members: | type | EVID_ENGAGED |
source | character engaging to attack |
Event type: EVID_DISENGAGED | ||
Members: | type | EVID_DISENGAGED |
source | character disengaging from attack |
Event type: EVID_ENTEREDAREA | ||
Members: | type | EVID_ENTEREDAREA |
source | mobile that entered the area near the NPC | |
Notes: | The range parameter passed to EnableEvents() when this event was enabled specifies how close a mobile must be to fall within the NPC's interest. |
Event type: EVID_LEFTAREA | ||
Members: | type | EVID_LEFTAREA |
source | mobile that left the area near the NPC | |
Notes: | The range parameter passed to EnableEvents() when this event was enabled specifies how close a mobile must be to fall within the NPC's interest. |
Event type: EVID_ITEM_GIVEN | ||
Members: | type | EVID_ITEM_GIVEN |
source | PC that dragged the item onto the NPC | |
item | item that was dragged onto the NPC | |
Notes: | The NPC AI script should do something with the item - move it into the
NPC's backpack, onto the ground, destroy it, give it back to the PC, etc. The item is stored in a container in a Storage Area until something is done with it. If the NPC AI script does not do anything with the item - for example, if the NPC is killed before its script has a chance to process the item - the item will be placed in the PC's backpack if the PC is alive, or dropped to the PCs feet if the PC is dead or has no backpack. This cleanup is done when the 'event' object is destroyed - either by going out of scope or by the variable being assigned a new value. |