Enderal SE https://mod.pub/enderal-se/38-enderal-se
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.6 KiB
42 lines
1.6 KiB
4 months ago
|
Scriptname _00E_Func_SafeMove Hidden
|
||
|
|
||
|
Function SafeMoveTo(ObjectReference refToMove, ObjectReference targetRef, Bool bFadeIn = False) Global
|
||
|
|
||
|
; A safer way to move an object reference to another ref than just MoveTo.
|
||
|
; Mostly for actors to take their intended positions.
|
||
|
; It's better for the actor to be already running a package that moves them to targetRef at the moment this function is called.
|
||
|
|
||
|
refToMove.Disable()
|
||
|
refToMove.MoveTo(targetRef)
|
||
|
refToMove.Enable(bFadeIn)
|
||
|
|
||
|
EndFunction
|
||
|
|
||
|
Function SafeMoveTo_NoWait(ObjectReference refToMove, ObjectReference targetRef, Bool bFadeIn = False) Global
|
||
|
|
||
|
; A safer way to move an object reference to another ref than just MoveTo (without waiting for it to be fully enabled).
|
||
|
; Mostly for actors to take their intended positions.
|
||
|
; It's better for the actor to be already running a package that moves them to targetRef at the moment this function is called.
|
||
|
|
||
|
refToMove.Disable()
|
||
|
refToMove.MoveTo(targetRef)
|
||
|
refToMove.EnableNoWait(bFadeIn)
|
||
|
|
||
|
EndFunction
|
||
|
|
||
|
Bool Function DistanceFailsafeMoveTo(ObjectReference refToMove, ObjectReference targetRef, Float fTooFarDistance) Global
|
||
|
|
||
|
; Moves refToMove to targetRef if refToMove is not within fTooFarDistance from targetRef.
|
||
|
; Mostly for character travel failsafes in scenes.
|
||
|
|
||
|
; Debug.Trace("FailsafeMoveTo: refToMove = " + refToMove + "; d = " + refToMove.GetDistance(targetRef))
|
||
|
If refToMove.GetDistance(targetRef) >= fTooFarDistance
|
||
|
refToMove.MoveTo(targetRef)
|
||
|
; Debug.Trace("FailsafeMoveTo: refToMove = " + refToMove + " force-moved to marker")
|
||
|
Return True
|
||
|
Else
|
||
|
Return False
|
||
|
EndIf
|
||
|
|
||
|
EndFunction
|