[dismiss]
This wiki is a copy of the original Oblivion CS wiki created and maintained by the UESP.net. See CSwiki:Copy Notice for more info.
Difference between revisions of "Script Processing"
Jump to navigation
Jump to search
imported>Skyranger-1 |
imported>UDUN |
||
Line 7: | Line 7: | ||
== Remote Ref Heartbeat == | == Remote Ref Heartbeat == | ||
Whenever a local variable on a persistent ref is set, the script of that reference will be run in the next frame. Hence if a script continually sets a variable on itself, then it will continue to run | Whenever a local variable on a persistent ref is set, the script of that reference will be run in the next frame. Hence if a script continually sets a variable on itself, then it will continue to run in every frame. | ||
;Positive: This can be used to effectively keep a remote reference in "high processing". E.g. if items are stored in a remote container, then ordinarily the OnDrop and OnUnequip blocks of those items will not be run since the container is not local, and thus not in high processing. But by "heartbeating" he remote container ref, the item blocks can be made to run. | ;Positive: This can be used to effectively keep a remote reference in "high processing". E.g. if items are stored in a remote container, then ordinarily the OnDrop and OnUnequip blocks of those items will not be run since the container is not local, and thus not in high processing. But by "heartbeating" he remote container ref, the item blocks can be made to run. |
Revision as of 20:05, 9 August 2009
How Often are Scripts Processed?
- Actors (Creatures and NPCs)
- Processed every time the actor's AI is processed. In high process (the loaded area around the player), this is every frame. When the actor is not in high, this is much less often (down to once every 15 minutes of game time at the lowest process level). But these are still the only scripts (aside from quest scripts) that are processed when the player is not around.
- Doors
- A bit of a special case, these scripts are processed like other scripts on references (every frame when loaded), but they will also be processed once any time an actor activates the door.
- Objects in Containers
- Processed when the container's script is processed -- so, items on actors are processed when the actor is processed; items in other containers are processed every frame when the cell is loaded.
- Quests
- Processed every 5 seconds (by default) when the quest is running. You can change how often quest scripts are processed by changing a default variable in the quest's script. When a game is first loaded there will be a brief period when quest scripts will not run, even if fQuestDelayTime is very small. The first time a game is loaded in a given game session this delay will be longer, perhaps 5 seconds or so. This does not happen for other script types.
- References
- Processed every frame when its cell is loaded, not at all when the cell is not loaded. So these scripts run only when the player is nearby (which means these are often a good place to put relatively expensive scripts, doing things like distance checks).
Remote Ref Heartbeat
Whenever a local variable on a persistent ref is set, the script of that reference will be run in the next frame. Hence if a script continually sets a variable on itself, then it will continue to run in every frame.
- Positive
- This can be used to effectively keep a remote reference in "high processing". E.g. if items are stored in a remote container, then ordinarily the OnDrop and OnUnequip blocks of those items will not be run since the container is not local, and thus not in high processing. But by "heartbeating" he remote container ref, the item blocks can be made to run.
- Negative
- Unintentional heartbeating of remote references will keep them permanently in high processing and thus hurt performance. Modders should ensure that script for persistent refs do not set a variable in every frame. (Be careful of this particularly in gameMode blocks, which are occasionally run even for out of scope persistent references.)
Notes/Questions
- This does not appear to happen for non-persistent refs.
- How about actors with no low level processing?
Sample Script
scn HeartbeatOS ;--Heartbeats a reference. Useful for remote containers. short heartbeat begin menuMode if heartbeat > 0 set heartbeat to heartbeat endif end begin gameMode if heartbeat > 0 set heartbeat to heartbeat - 1 endif end