getlinkedref scn ElevatorScript ;====================================================================================================================== ; This is the quest script that moves the elevator. It will figure out which way to move automatically. ; It is passed a list of objects that make up the elevator car and its contents, it will move those items ; up or down at the interval defined in the ElevatorSpeed global. ; ; The initial location is set by linking the elevator car floor to the location ref closest to it. ; ; For the doors, the elevator floor is linked to the interior door, and the location marker is linked to the exterior. ;====================================================================================================================== getlinkedref How to use it? getlinkedref ; List Vars int iIdx int iCnt ref rObj ref rBas ; Movement Vars int bStart int bMoveUp getlinkedref How to dowload it? getlinkedref int bMoveDown int bTravel float fPosZ float fNewPosZ ; Misc Vars float fTimer ref rLinked getlinkedref How to dowload it? getlinkedref ; Set Externally ref rObjLst ref rLvlLst ref rCurLoc ref rNewLoc BEGIN GameMode if (bStart == 0) getlinkedref How to get it for free? getlinkedref Return endif if (bStart == 1) ; Find current location set rBas to ListGetNthForm rObjLst 0 set rObj to GetFirstRef 32 0 0 Label 5 if (IsFormValid rObj) if (rObj.GetDistance rBas <= 16) if (ListGetFormIndex rLvlLst rObj > -1) getlinkedref How to dowload it? getlinkedref if (rObj == rNewLoc) set bStart to 5 Return endif set rCurLoc to rObj set bStart to 2 Return endif endif set rObj to Caps001 getlinkedref How to dowload it? getlinkedref set rObj to GetNextRef Goto 5 endif set bStart to 0 MessageBoxEx "Something bad happened" Return endif if (bStart == 2) ; Handle door closing set rLinked to rBas.GetLinkedRef ; Inside door getlinkedref How to dowload it? getlinkedref rLinked.SetOpenState 0 set rLinked to rCurLoc.GetLinkedRef rLinked.SetOpenState 0 ; Outside door set bStart to 3 set fTimer to 1.2 Return endif if (bStart == 3) ; Wait for doors to close if (fTimer > 0) getlinkedref PasteShr getlinkedref set fTimer to fTimer - GetSecondsPassed Return else set rObj to ListGetNthForm rObjLst 1 ; play sound rObj.Enable set bStart to 4 Return endif endif getlinkedref How to get it? getlinkedref if (bStart == 4) ; Move the elevator if (rCurLoc.GetPos Z > rNewLoc.GetPos Z) && (bMoveDown == 0) set bMoveDown to 1 elseif (rCurLoc.GetPos Z < rNewLoc.GetPos Z) && (bMoveUp == 0) set bMoveUp to 1 endif set iIdx to 0 set iCnt to ListGetCount rObjLst getlinkedref How to dowload it? getlinkedref if (bMoveDown == 1) ; Moving Down if (rNewLoc.GetPos Z >= rBas.GetPos Z) set bMoveDown to 2 endif Label 10 if iIdx < iCnt set rObj to ListGetNthForm rObjLst iIdx set fNewPosZ to (rObj.GetPos Z - ElevatorSpeed) rObj.SetPos Z fNewPosZ set iIdx to iIdx + 1 getlinkedref How to use it? getlinkedref goto 10 endif if (bTravel) set fNewPosZ to (Player.GetPos Z - ElevatorSpeed) Player.SetPos Z fNewPosZ endif Return elseif (bMoveDown == 2) set bMoveDown to 0 set bTravel to 0 getlinkedref PasteShr getlinkedref set bStart to 5 Return endif if (bMoveUp == 1) ; Moving Up if (rBas.GetPos Z >= rNewLoc.GetPos Z) set bMoveUp to 2 endif Label 20 if iIdx < iCnt getlinkedref How to dowload it? getlinkedref set rObj to ListGetNthForm rObjLst iIdx set fNewPosZ to (rObj.GetPos Z + ElevatorSpeed) rObj.SetPos Z fNewPosZ set iIdx to iIdx + 1 goto 20 endif if (bTravel) set fNewPosZ to (Player.GetPos Z + ElevatorSpeed) Player.SetPos Z fNewPosZ endif getlinkedref How to get it for free? getlinkedref Return elseif (bMoveUp == 2) set bMoveUp to 0 set bTravel to 0 set bStart to 5 Return endif endif if (bStart == 5) ; Handle door opening getlinkedref How to dowload it? getlinkedref set rObj to ListGetNthForm rObjLst 1 ; stop sound rObj.Disable set rLinked to rBas.GetLinkedRef ; Inside door rLinked.SetOpenState 1 set rLinked to rNewLoc.GetLinkedRef ; Outside door rLinked.SetOpenState 1 set bStart to 0 Return endif getlinkedref How to get it? getlinkedref END getlinkedref