Last active
August 29, 2015 14:11
-
-
Save Langerz82/2f6be9eb062356031b00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ Intermittent Object Reference is a generic script that enables | |
+ simplification of child scripts. Say you want to lock/unlock an | |
+ object every 5 minutes, this is a generic script to simplify such | |
+ a task. If you want it to only work when in view set useLooking. | |
+ Override the OnTimeElapsed Event in order to | |
+ modify the ObjectReference. | |
+ | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
ScriptName ObjectReferenceInterval extends ObjectReference | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ PROPERTIES | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
Bool Property useLooking Auto ; Should we take into account Line of Sight or not. | |
Int Property fMinutesInterval Auto ; Desired Minutes Interval /10.0 (minutes) ex. | |
GlobalVariable Property GameHour Auto ; The Games Hour leave default. | |
Float fLastTime | |
Bool gIsLooking = false | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ GENERAL FUNCTIONS | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
; Function - Checks when Object elapses Minutes Interval. | |
Function ObjectCheck() | |
If (Self.isDisabled()) | |
return | |
EndIf | |
If (useLooking && !gIsLooking) | |
return | |
EndIf | |
If (fLastTime + ((fMinutesInterval) as float / 60.0) <= GameHour.GetValue()) | |
fLastTime = GameHour.GetValue() | |
OnTimeElapsed() | |
EndIf | |
EndFunction | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ OVERRIDE FUNCTIONS | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
; Override Event - When Object exceeds elapsed time. | |
Event OnTimeElapsed() | |
;Debug.Notification("ObjectReferenceInterval(Event:OnTimeElapsed)") | |
EndEvent | |
;/++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
+ EVENTS | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/; | |
Event OnUpdate() | |
;Debug.Notification("ObjectReferenceInterval(func:OnUpdate)") | |
RegisterForSingleUpdate(fMinutesInterval*3) | |
ObjectCheck() | |
EndEvent | |
Event OnInit() | |
;Debug.Notification("ObjectReferenceInterval(func:OnInit)") | |
RegisterForSingleLOSGain(Game.GetPlayer(), Self) | |
fLastTime = GameHour.GetValue() | |
RegisterForSingleUpdate(fMinutesInterval*3) | |
ObjectCheck() | |
EndEvent | |
Event OnGainLOS(Actor akViewer, ObjectReference akTarget) | |
;Debug.Notification("ObjectReferenceInterval(func:OnGainLOS)") | |
If (useLooking) | |
RegisterForSingleLOSLost(Game.GetPlayer(), Self) | |
gIsLooking = true | |
EndIf | |
EndEvent | |
Event OnLostLOS(Actor akViewer, ObjectReference akTarget) | |
;Debug.Notification("ObjectReferenceInterval(func:OnLostLOS)") | |
If (useLooking) | |
RegisterForSingleLOSGain(Game.GetPlayer(), Self) | |
gIsLooking = false | |
EndIf | |
EndEvent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment