101 lines
2.3 KiB
Plaintext
101 lines
2.3 KiB
Plaintext
|
Scriptname _00E_ActorPackageLookAtScript extends Actor
|
||
|
|
||
|
Package Property WatchPackage Auto
|
||
|
Keyword Property LinkLookAtTarget Auto
|
||
|
|
||
|
Bool bIsWorking
|
||
|
Bool bIsTrackingTarget
|
||
|
|
||
|
|
||
|
;=====================================================================================
|
||
|
; EVENTS
|
||
|
;=====================================================================================
|
||
|
|
||
|
Event OnLoad()
|
||
|
TryStartWorking(GetCurrentPackage())
|
||
|
EndEvent
|
||
|
|
||
|
Event OnUnload()
|
||
|
StopWorking()
|
||
|
EndEvent
|
||
|
|
||
|
Event OnPackageStart(Package akNewPackage)
|
||
|
If akNewPackage == WatchPackage
|
||
|
TryStartWorking(akNewPackage)
|
||
|
Else
|
||
|
StopWorking()
|
||
|
EndIf
|
||
|
EndEvent
|
||
|
|
||
|
Event OnPackageChange(Package akOldPackage)
|
||
|
If akOldPackage == WatchPackage
|
||
|
StopWorking()
|
||
|
EndIf
|
||
|
EndEvent
|
||
|
|
||
|
State Working
|
||
|
Event OnUpdate()
|
||
|
If UpdateLookAt()
|
||
|
If bIsWorking
|
||
|
RegisterForSingleUpdate(3.0)
|
||
|
EndIf
|
||
|
Else
|
||
|
StopWorking()
|
||
|
EndIf
|
||
|
EndEvent
|
||
|
EndState
|
||
|
|
||
|
|
||
|
;=====================================================================================
|
||
|
; FUNCTIONS
|
||
|
;=====================================================================================
|
||
|
|
||
|
Function TryStartWorking(Package akNewPackage)
|
||
|
If akNewPackage == WatchPackage && bIsWorking == False
|
||
|
bIsWorking = True
|
||
|
GoToState("Working")
|
||
|
RegisterForSingleUpdate(2.0)
|
||
|
EndIf
|
||
|
EndFunction
|
||
|
|
||
|
Function StopWorking()
|
||
|
If bIsWorking
|
||
|
bIsWorking = False
|
||
|
GoToState("")
|
||
|
_SetTrackingTarget(False, None)
|
||
|
EndIf
|
||
|
EndFunction
|
||
|
|
||
|
Bool Function UpdateLookAt()
|
||
|
If Is3DLoaded() == False || IsDead()
|
||
|
Return False
|
||
|
EndIf
|
||
|
|
||
|
ObjectReference lookAtTarget = GetLinkedRef(LinkLookAtTarget)
|
||
|
If (lookAtTarget == None) || (((lookAtTarget as Actor) != None) && (lookAtTarget as Actor).IsDead())
|
||
|
Return False
|
||
|
EndIf
|
||
|
|
||
|
GetCombatState()
|
||
|
If GetCombatState() == 0 && lookAtTarget.Is3DLoaded() && IsBleedingOut() == False && IsInDialogueWithPlayer() == False && GetCurrentPackage() == WatchPackage
|
||
|
If bIsWorking
|
||
|
_SetTrackingTarget(True, lookAtTarget)
|
||
|
EndIf
|
||
|
Else
|
||
|
_SetTrackingTarget(False, lookAtTarget)
|
||
|
EndIf
|
||
|
|
||
|
Return True
|
||
|
EndFunction
|
||
|
|
||
|
Function _SetTrackingTarget(Bool _IsTrackingTarget, ObjectReference lookAtTarget)
|
||
|
If bIsTrackingTarget != _IsTrackingTarget
|
||
|
bIsTrackingTarget = _IsTrackingTarget
|
||
|
If bIsTrackingTarget
|
||
|
SetLookAt(lookAtTarget)
|
||
|
Else
|
||
|
ClearLookAt()
|
||
|
EndIf
|
||
|
EndIf
|
||
|
EndFunction
|