enderalse/scripts/source/_00e_liftplayerhookscript.psc

93 lines
3.1 KiB
Plaintext

scriptName _00E_LiftPlayerHookScript extends ObjectReference
{Place this on a lift platform (and follow the tutorial in the comments!) to make a platform move when a trigger is activated.}
;-- Properties --------------------------------------
Float property MovementSpeed = 100.000 auto
{How fast the platform should move - Start at 100.0 and work your way up! 1 is barely visible to the human eye.}
sound property _00E_SternenstadtLifeSoundMarker auto
sound property DRSStoneRotatingDiscLPM auto
ObjectReference property LiftMarkerTop auto
{The X-Marker Reference where the lift will stop moving at the top}
Bool property DisablePlayerControlsDuringRide auto
{Should the player controls be disabled once the switch has been hit?}
ObjectReference property LiftMarkerBottom auto
{The X-Marker Reference where the lift will stop moving at the bottom (Set this XMarker's coordinates to match the platforms coordinates!}
Bool property MechanicalLift = false auto
{Set this to true if the lift should play a mechanical sound instead of a "crumbling stone"-sound}
Bool property UpDownHeuristic = false auto
{Set this to true if you want the lift to figure out its UpDown value by getDistance heuristic}
;-- Variables ---------------------------------------
Int MoveSound
Int UpDown
Bool bTranslationOnGoing = false
;-- Functions ---------------------------------------
; Skipped compiler generated GetState
Event OnTranslationAlmostComplete()
If DisablePlayerControlsDuringRide == true
Game.EnablePlayerControls()
EndIf
bTranslationOnGoing = false
sound.StopInstance(MoveSound)
If UpDown == 0
UpDown = 1
ElseIf UpDown == 1
UpDown = 0
EndIf
EndEvent
; Skipped compiler generated GotoState
Event OnActivate(ObjectReference akActionRef)
bTranslationOnGoing = true
If DisablePlayerControlsDuringRide == true
Game.DisablePlayerControls()
EndIf
If UpDownHeuristic
; decide whether to go up or down
If self.getDistance(LiftMarkerTop) < self.getDistance(LiftMarkerBottom)
UpDown = 1
Else
UpDown = 0
Endif
Endif
If UpDown == 0
LiftMarkerTop.SetAngle(self.GetAngleX(), self.GetAngleY(), self.GetAngleZ())
self.TranslateToRef(LiftMarkerTop, MovementSpeed, 10.0000)
ElseIf UpDown == 1
self.TranslateToRef(LiftMarkerBottom, MovementSpeed, 10.0000)
LiftMarkerBottom.SetAngle(self.GetAngleX(), self.GetAngleY(), self.GetAngleZ())
EndIf
If MechanicalLift == true
MoveSound = _00E_SternenstadtLifeSoundMarker.Play(self as ObjectReference)
Else
MoveSound = DRSStoneRotatingDiscLPM.Play(self as ObjectReference)
EndIf
EndEvent
Event OnCellDetach()
If bTranslationOnGoing == true
Self.StopTranslation() ; stop translation? is this even necessary?
EndIf
EndEvent
Event OnCellAttach()
; there seems to be some kind of bug where lifts get disabled(or their 3D model is no longer loaded?) for some reason
; couldn't reproduce it but there were reports (might actually have something do to with them being translated?)
Self.Enable()
If bTranslationOnGoing == true
; resume translation in case they were mid translation when the player exited the cell
Self.Activate(Self)
EndIf
EndEvent