9
3

najenaelevatorcontrol.lua 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. --[[
  2. Script Name : SpawnScripts/Lavastorm/najenaElevatorcontrol.lua
  3. Script Author : smash
  4. Script Date : 2016.01.14 09:01:52
  5. Script Purpose :
  6. :
  7. --]]
  8. function spawn(NPC)
  9. end
  10. function casted_on(NPC, Caster, SpellName)
  11. --Say(NPC, SpellName)
  12. MoveElevator(NPC, SpellName)
  13. end
  14. --There are three possible locations for this Elevator - top, middle, bottom - it can be raised or lowered
  15. function MoveElevator(NPC, Direction)
  16. local Elevator = GetSpawn(NPC, 1710230)
  17. if GetTempVariable(Elevator, "moving") == "true" then
  18. return
  19. end
  20. local current_pos = GetTempVariable(Elevator, "current_pos")
  21. if Direction == "Raise Elevator" then
  22. if current_pos == "middle" then
  23. AddTimer(NPC, 3000, "MoveElevatorToTop", 1, Elevator)
  24. SetElevatorMoving(NPC, Elevator)
  25. elseif current_pos == "bottom" then
  26. AddTimer(NPC, 3000, "MoveElevatorToMiddle", 1, Elevator)
  27. SetElevatorMoving(NPC, Elevator)
  28. end
  29. elseif Direction == "Lower Elevator" then
  30. --Say(NPC, "Lower Elevator branch")
  31. if current_pos == "top" then
  32. --Say(NPC, "Lower - top")
  33. AddTimer(NPC, 3000, "MoveElevatorToMiddle", 1, Elevator)
  34. SetElevatorMoving(NPC, Elevator)
  35. elseif current_pos == "middle" then
  36. --Say(NPC, "Lower - middle")
  37. AddTimer(NPC, 3000, "MoveElevatorToBottom", 1, Elevator)
  38. SetElevatorMoving(NPC, Elevator)
  39. end
  40. end
  41. end
  42. --The trip from top->middle takes about 18 seconds, middle->bottom about 17 seconds - add 3 seconds to account for delay
  43. function MoveElevatorToTop(NPC, Elevator)
  44. MoveToLocation(Elevator, -37.9433, -127.518, 205.8)
  45. SetTempVariable(Elevator, "current_pos", "top")
  46. AddTimer(NPC, 21000, "SetElevatorNotMoving", 1, Elevator)
  47. end
  48. function MoveElevatorToMiddle(NPC, Elevator)
  49. --Say(NPC, "MoveElevatorToMiddle function")
  50. local current_pos = GetTempVariable(Elevator, "current_pos")
  51. MoveToLocation(Elevator, -37.9433, -212.726, 205.8)
  52. SetTempVariable(Elevator, "current_pos", "middle")
  53. if current_pos == "top" then
  54. AddTimer(NPC, 21000, "SetElevatorNotMoving", 1, Elevator)
  55. else
  56. AddTimer(NPC, 20000, "SetElevatorNotMoving", 1, Elevator)
  57. end
  58. end
  59. function MoveElevatorToBottom(NPC, Elevator)
  60. MoveToLocation(Elevator, -37.9433, -294.3962, 205.8)
  61. SetTempVariable(Elevator, "current_pos", "bottom")
  62. AddTimer(NPC, 20000, "SetElevatorNotMoving", 1, Elevator)
  63. end
  64. function SetElevatorMoving(NPC, Elevator)
  65. SetTempVariable(Elevator, "moving", "true")
  66. end
  67. function SetElevatorNotMoving(NPC, Elevator)
  68. --Say(NPC, "Done moving")
  69. SetTempVariable(Elevator, "moving", nil)
  70. end