Difference between revisions of "DelayEvent"
From Dragon Age Toolset Wiki
m (→Examples: move "example" to talk because isn't of sufficient quality to be used as reference) |
BryanDerksen (Talk | contribs) (a fancied up and trimmed down version of the heartbeat example. Works for everyone?) |
||
| Line 32: | Line 32: | ||
With a negative or zero time in fSeconds, the event will run on the next AI update. | With a negative or zero time in fSeconds, the event will run on the next AI update. | ||
| − | + | == Examples == | |
<!-- This section contains examples transcluded from the snippet library. --> | <!-- This section contains examples transcluded from the snippet library. --> | ||
| + | |||
| + | This function can be used to create a "heartbeat" event that is sent to a script at regular intervals. For example, if you created the following script named "event_heartbeat": | ||
| + | |||
| + | <dascript> | ||
| + | #include "utility_h" | ||
| + | #include "wrappers_h" | ||
| + | #include "events_h" | ||
| + | |||
| + | void main() | ||
| + | { | ||
| + | event ev = GetCurrentEvent(); | ||
| + | int nEventType = GetEventType(ev); //extract event type from current event | ||
| + | switch(nEventType) | ||
| + | { | ||
| + | case EVENT_TYPE_HEARTBEAT: | ||
| + | { | ||
| + | //Insert whatever code you need to execute on heartbeats here | ||
| + | DelayEvent(6.0f, GetHero(), Event(EVENT_TYPE_HEARTBEAT), "event_heartbeat"); | ||
| + | break; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </dascript> | ||
| + | |||
| + | This event would fire every six seconds. To associate a heartbeat with a particular creature you can use that creature's event-handling script and omit the scriptname parameter. | ||
<!-- == See also == --> | <!-- == See also == --> | ||
Revision as of 18:52, 8 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.
Examples
This function can be used to create a "heartbeat" event that is sent to a script at regular intervals. For example, if you created the following script named "event_heartbeat":
#include "utility_h" #include "wrappers_h" #include "events_h" void main() { event ev = GetCurrentEvent(); int nEventType = GetEventType(ev); //extract event type from current event switch(nEventType) { case EVENT_TYPE_HEARTBEAT: { //Insert whatever code you need to execute on heartbeats here DelayEvent(6.0f, GetHero(), Event(EVENT_TYPE_HEARTBEAT), "event_heartbeat"); break; } } }
This event would fire every six seconds. To associate a heartbeat with a particular creature you can use that creature's event-handling script and omit the scriptname parameter.