enderalse/source/scripts/_00e_agnodelevator01script.psc

108 lines
3.1 KiB
Plaintext

Scriptname _00E_AgnodElevator01Script extends ObjectReference
; SCRIPT AUTHOR DENNIS MAY 2014
; ====================================================================================
; EVENTS
; ====================================================================================
Event OnActivate(ObjectReference akActionRef)
if ( ElevatorStatus == 0 )
ControlDoors(false, "elevated")
soundcont_Move = OBJDwemerGearsMultipleLP.Play(Self)
Utility.Wait(0.2)
MoveElevator( _00E_AgnodElevatorUpXMarkerREF, 100 )
ElevatorStatus = 1
elseif ( ElevatorStatus == 2 )
ControlDoors(false, "elevated")
soundcont_Move = OBJDwemerGearsMultipleLP.Play(Self)
Utility.Wait(0.2)
MoveElevator( _00E_AgnodElevatorDownXMarkerREF, 150 )
ElevatorStatus = -1
endif
EndEvent
Event OnTranslationComplete()
if ( ElevatorStatus == 1 ) ;Elevator reached upper level
ControlDoors(true, "upper")
soundcont_MoveEnd = _00E_OBJDwemerGearsStuck.Play(Self)
Sound.StopInstance(soundcont_Move)
ElevatorStatus = 2
elseif ( ElevatorStatus == -1 ) ;Elevator reached lower level
ControlDoors(true, "lower")
soundcont_MoveEnd = _00E_OBJDwemerGearsStuck.Play(Self)
Sound.StopInstance(soundcont_Move)
ElevatorStatus = 0
endif
EndEvent
; ====================================================================================
; FUNCTIONS
; ====================================================================================
function ControlDoors(bool open, string floor)
int iSize = _00E_Agnod_LiftList.GetSize() - 1 ;Get the count of doors in formlist
int doorsToProceed = 0 ;Objects
; Sets the numbers of doors in the formlist we need to process
if ( floor == "elevated" )
doorsToProceed = 0
elseif ( floor == "upper" )
doorsToProceed = 1
elseif ( floor == "lower" )
doorsToProceed = 0
iSize = 0
endif
While ( iSize >= doorsToProceed )
ObjectReference DoorToOpen = _00E_Agnod_LiftList.GetAt(iSize) as ObjectReference
if ( open == false ) ;We want close and lock the doors
if ( DoorToOpen.GetOpenState() == 1 || DoorToOpen.GetOpenState() == 2)
DoorToOpen.SetOpen(False)
endif
DoorToOpen.SetLockLevel(255)
DoorToOpen.Lock()
else ;We want unlock the doors
DoorToOpen.Lock(False)
EndIf
iSize -= 1
EndWhile
Return
EndFunction
function MoveElevator(ObjectReference actionRef, int speed)
Self.TranslateToRef( actionRef, speed )
Return
EndFunction
; ====================================================================================
; PROPERTIES
; ====================================================================================
Formlist Property _00E_Agnod_LiftList Auto
int ElevatorStatus = 0
objectReference property _00E_AgnodElevatorDownXMarkerREF auto
{Points to Down Marker}
objectReference property _00E_AgnodElevatorUpXMarkerREF auto
{Points to Up Marker}
int soundcont_Move
Sound property OBJDwemerGearsMultipleLP auto
{Points to Elevator Move Sound}
int soundcont_MoveEnd
Sound property _00E_OBJDwemerGearsStuck auto
{Points to Elevator Move End Sound}