Complete Example Scripts: Difference between revisions
Jump to navigation
Jump to search
no edit summary
imported>Fg109 |
imported>LukeH No edit summary |
||
| Line 696: | Line 696: | ||
*If you want it to look for targets nearby, set SpawnNode to false and put a formlist of the valid targets in the TargetTypeList. If no Formlist is given, it will default to trying to shoot the player. | *If you want it to look for targets nearby, set SpawnNode to false and put a formlist of the valid targets in the TargetTypeList. If no Formlist is given, it will default to trying to shoot the player. | ||
=== Script for a quest with time limit by [[User:LukeH|LukeH]] 17:37, 13 April 2012 (EDT) === | |||
<Source lang="Papyrus"> | |||
Scriptname LH_TimeLimitedQuest extends Quest | |||
GlobalVariable Property GlobalDays auto ;initial days to complete | |||
GlobalVariable Property GlobalTime auto ;counter for hours left | |||
Quest Property TimedQuest auto ;the quest (I used two scripts on same quest while cause I modified a vanilla one) | |||
int Property FailObjective auto ;objective that will fail when hours left reaches 0 | |||
int Property FailStage auto ;stage to set the quest to, faile whole quest from it's fragment or whatever | |||
Float endTime | |||
Event OnInit() | |||
if (TGRDays.GetValue()>0) | |||
;Debug.Notification("Starting countdown") | |||
GlobalTime.SetValue(GlobalDays.GetValue()*24) | |||
endTime = Utility.GetCurrentGameTime()+GlobalDays.GetValue() | |||
TimedQuest.UpdateCurrentInstanceGlobal(GlobalTime) | |||
RegisterForUpdateGameTime(0.10) | |||
EndIf | |||
EndEvent | |||
Event OnUpdateGameTime() | |||
if (!TimedQuest.IsRunning()) | |||
UnregisterForUpdateGameTime() | |||
EndIf | |||
float step = Math.Ceiling((endTime - Utility.GetCurrentGameTime())*24) - GlobalTime.GetValue() | |||
if (step != 0) | |||
if (0-step > GlobalTime.GetValue()) ;avoid displaying less then 0 | |||
step = 0 - GlobalTime.GetValue() | |||
EndIf | |||
if TimedQuest.ModObjectiveGlobal(step, GlobalTime, FailObjective, 0, false, false) | |||
GlobalTime.SetValue(0) | |||
TimedQuest.UpdateCurrentInstanceGlobal(GlobalTime) | |||
TimedQuest.SetStage(FailStage) | |||
UnregisterForUpdateGameTime() | |||
EndIf | |||
EndIf | |||
EndEvent | |||
</Source> | |||