Difference between revisions of "DelayEvent"
From Dragon Age Toolset Wiki
m (→Examples: removed unnecessary includes, fixed target and added comments) |
(→Examples) |
||
Line 55: | Line 55: | ||
// schedule a delayed event on this object to call this script again | // schedule a delayed event on this object to call this script again | ||
DelayEvent(6.0, OBJECT_SELF, Event(EVENT_TYPE_HEARTBEAT), "event_heartbeat"); | DelayEvent(6.0, OBJECT_SELF, Event(EVENT_TYPE_HEARTBEAT), "event_heartbeat"); | ||
+ | |||
break; | break; | ||
} | } |
Revision as of 00:02, 9 December 2009
Signals a delayed event to the specified object.
- Parameters:
- fSeconds
- The number of seconds for which to delay the event
- oObject
- The object to signal the event to
- evEvent
- The event to signal
- scriptname
- If specified overides the default script
- Returns:
- Nothing.
- Source:
- script.ldf
Description
Signals a delayed event to the target object.
Remarks
With a negative or zero time in fSeconds, the event will run on the next AI update.
The scriptname
parameter does not work for an area.
Examples
DelayEvent
can be used to create a heartbeat event that is sent to an object at regular intervals. For example, if you created the following script named "event_heartbeat" it would fire every six seconds after it has been initiated.
#include "events_h" void main() { // extract event type from current event event ev = GetCurrentEvent(); int nEventType = GetEventType(ev); switch(nEventType) { case EVENT_TYPE_HEARTBEAT: { // insert whatever code you need to execute on every heartbeat here // schedule a delayed event on this object to call this script again DelayEvent(6.0, OBJECT_SELF, Event(EVENT_TYPE_HEARTBEAT), "event_heartbeat"); break; } } }
To associate a heartbeat with a particular object you can use that object's event-handling script and omit the scriptname
parameter.