Mission events

The core of the mission system isn't the script engine; it's the events that trigger sections of script to be executed. In Death Dawn these events take two forms - events tied to entities, and timed events.

Entity events

Each entity (ped, car, object) has an array of event pointers as part of its definition. Each element in that is for a specific event, and each pointer is a pointer to the head of a linked list of attached handlers. When the entity detects a script-monitorable event, it calls the code in events.c to trigger the execution of the appropriate script routine(s). When the script is called, the EVENTOBJ and EVENTTARG statements can be used to find what entity the event is attached to, and what entity caused it to be triggered. Scripts can attach and remove events using the EVENT and REMEVENT statements.

Timed events

Timed events are a way of scheduling script code to be called at a specific gametime (or as near as possible to that time). By default they do not auto-repeat, but a simple call to AFTER or AT from within the script is all that's needed to queue the event again for repeating. Timed events are managed by timeevents.c. At present, no parameters are passed to the event to indicate what event is being serviced; the only identifier is the code label. There is also no way of removing a pending event.

TODO:
CODE: QUICK: Add way of removing pending timed events.
CODE: DELAYED: Map zone triggers, as in mapstructure doc
CODE: MED: Check how AT, AFTER, EVENT, etc. work with label/string arrays
CODE: UNKNOWN: Finish adding event trigger code (whatever the missing code may be)
CODE: UNKNOWN: Add script func to set up callback for each time a respect value is set/modified. Or just call .setrespect, .modrespect functions if they happen to exist? Would also need a new framework for passing the variables, etc. The funcs will take bitflags as input, so they can use boolean operations to quickly determine if it's an event they're interested in. Would also need extra funcs for when disrespect is fully implemented, so mission script can track when somethings' disrespect value changes
DOCS: UNKNOWN: Recursive event triggering - is it possible? should it be countered? Queue up the events, etc. Only downside is that it would require more code to track ent references (incase it's an object and it gets deleted before the event fires) Alternatively, fix object code to always use OBJECT_REMOVE flag to remove stuff
???
Profit!