Difference between revisions of "Global Scripts"

2,389 bytes added ,  09:26, 11 January 2009
Major Edit : Merged with the Quest Scripts article.
imported>Kkuhlmann
imported>Shademe
(Major Edit : Merged with the Quest Scripts article.)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Overview==
{{FeatNom}}
If you're used to [[scripting]] in [http://www.elderscrolls.com/games/morrowind_overview.htm The Elder Scrolls III: Morrowind], you may be familiar with a concept known as "global scripts".  In Morrowind, the way to run a global script — at least if you have the [http://www.elderscrolls.com/games/tribunal_overview.htm Tribunal] or [http://www.elderscrolls.com/games/bloodmoon_overview.htm Bloodmoon] expansions, or if you have the [http://www.elderscrolls.com/games/goty_overview.htm Morrowind Game of the Year Edition] — is to create your script as normal, then specify it is a Start Script in the Construction Set.


If you're used to [[scripting]] in [http://www.elderscrolls.com/games/morrowind_overview.htm The Elder Scrolls III: Morrowind], you may be familiar with a concept known as "global scripts". In Morrowind, the way to run a global script — at least if you have the [http://www.elderscrolls.com/games/tribunal_overview.htm Tribunal] or [http://www.elderscrolls.com/games/bloodmoon_overview.htm Bloodmoon] expansions, or if you have the [http://www.elderscrolls.com/games/goty_overview.htm Morrowind Game of the Year Edition] — is to create your script as normal, then specify it is a Start Script in the Construction Set.
In Oblivion, however, all scripts must be attached to objects of some kind. This, of course, presents a problem: how can an object, which must be always be persistent in memory and running its script, be created? The answer, of course, is by creating a [[quest]], then defining your script as a quest script.


In Oblivion, however, all scripts must be attached to objects of some kind.  This, of course, presents a problem: how can you create an object which is always persistent in memory and always running its script?  The answer, of course, is by creating a [[quest]], then defining your script as a [[quest script]].


==What is a Global or a Quest script?==


==What is a global script?==
A Global script ( which will be called as Quest script from this point onwards )is a script that needs to be running all the time in order to perform advanced scripting techniques.  The actual uses for this vary a great deal, but reasons include: alterations of the locations of objects above and beyond the Havok physics engine; dynamic placement of creatures and objects; and modifications of NPCs on a grand scale (for instance, making every single NPC in the game burst into flames...).


A global script is a script that needs to be running all the time in order to perform advanced scripting techniques.  The actual uses for this vary a great deal, but reasons include: alterations of the locations of objects above and beyond the Havok physics engine; dynamic placement of creatures and objects; and modifications of NPCs on a grand scale (for instance, making every single NPC in the game burst into flames...).
Quest scripts can be designed to run immediately, from the very start of the game.  This is distinct from some of the scripts on, for example, side quests. Those scripts are triggered and executed only while the quest is in play.  


Global scripts are designed to be running immediately from the very start of the game. This is distinct from other kinds of quest scripts which are triggered and only executed as the quest is in play.
Quest scripts can be created by selecting ''Quest script'' type in the script editing window. They must be designated as quest scripts in order to be attached to [[:Category:Quests|quests]].  


A few basic facts about quest scripts and their interaction with [[:Category:Quests|quests]] :
* Quest scripts run only when the quest is running (which can be determined in-game by using sqv QUEST_NAME in the [[Glossary#C|Console]]). Quests can be started and stopped using the [[StartQuest]] and [[StopQuest]] script commands. Note that this is independent of a quest being complete or not. Completing a quest means that it is moved to the Completed Quest tab in the player's journal -- It will still be running unless a StopQuest command is used to turn it off.
* The rate at which a Quest script is processed can be changed by defining the [[fQuestDelayTime]] variable of the script. Each Quest can have its own fQuestDelayTime variable.
**The '''fQuestDelayTime''' variable of a particular Quest script may be set from another script by addressing the quest, e.g. '''set MyQuest.fQuestDelayTime to 0.01'''.
** Since quest scripts run based on time intervals, they will not necessarily frame sync, even when '''fQuestDelayTime''' is set to a very low value. For some effects (e.g. those using [[SetPos]]), this can have undesired effects. In such cases, Object or/and Magic scripts may be more appropriate to achieve an effect smoothly.
*Quest scripts are [[non-reference scripts]] and are therefore somewhat restricted in the function syntax they can use.
* Quest scripts are the only scripts which actually process a [[MenuMode]] block while  the player is resting or using fast travel.
* In general, quests should be stopped when they are completed, in order to keep their scripts from processing. If there is need to keep a completed quest running (for some post-quest dialogue or script processing), the task of creating a second quest can be considered.
* Quest variables can still be accessed and modified when a quest is not running. When a quest is stopped, it's script will stop being processed, but it will still exist and the state of it's variables will remain intact.
* Quests automatically turn on when an entry is written to the player's journal. So if the line ''[[SetStage]] QUESTNAME 10'' is executed and the entry 10 has journal text, the corresponding Quest will start automatically.


==Should I use a global script?==
==Should I use a Quest script?==


If you have to ask, then the answer is a very emphatic '''''no'''''!
If you have to ask, then the answer is a very emphatic '''''no'''''!


Global scripts are inefficient and are ''not'' the recommended solution to most problems.  If you find yourself considering using a global script, try to see if you can find some way to reduce the scope of your script somewhat — e.g., if your script only affects [[Actor]]s inside a certain inn, you could easily get away with a script attached to an [[Activator]] instead, then place that Activator inside each cell of that inn.
Quest scripts are inefficient and are ''not'' the recommended solution to most problems.  However, if the creation of a quest script is necessary, the scope of the script should be reduced to prevent the wastage of CPU cycles.
 
Global scripts, by their very nature, must run all the time — unless they're actually performing calculations every single time your screen updates, this means that you're wasting many "ticks" of your computer's processor, which could be better spent drawing the beautiful game environment of Oblivion!


''For example'' : If your script only affects [[Actor]]s inside a certain inn, you could easily get the job done by using an [[Activator]], with a script attached to it, and placing it inside each cell of that inn '''or''' include provisions in your quest script to stop it's processing once the job is done.


==Step by Step Process:==
==Creating a Quest script:==


===Create a Quest===
===Create a Quest===
Line 72: Line 82:
Congratulations!  You now have a global script.
Congratulations!  You now have a global script.


==See Also==
* [[Simulating new functions]]
* [[Remote Activators]]


[[Category: Useful Code]]
[[Category: Solutions]]
[[Category: Solutions]]
Anonymous user