Ground_Roam.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. --[[
  2. Script Name : SpawnScripts/General/Ground_Roam.lua
  3. Script Author : Dorbin
  4. Script Date : 2022.01.15
  5. Script Purpose : Ground Roaming
  6. :
  7. --]]
  8. function spawn(NPC)
  9. ChooseMovement(NPC)
  10. Action(NPC)
  11. end
  12. function ChooseMovement(NPC)
  13. local choice = math.random(1, 4)
  14. if choice == 1 then
  15. clockwise1(NPC)
  16. elseif choice == 2 then
  17. clockwise2(NPC)
  18. elseif choice == 3 then
  19. counter_clockwise1(NPC)
  20. elseif choice == 4 then
  21. counter_clockwise2(NPC)
  22. end
  23. end
  24. function respawn(NPC)
  25. spawn(NPC)
  26. end
  27. function clockwise1(NPC)
  28. local x = GetX(NPC)
  29. local y = GetY(NPC)
  30. local z = GetZ(NPC)
  31. MovementLoopAddLocation(NPC, x + 1.5 , y, z - 2 , 1, math.random(2, 15))
  32. MovementLoopAddLocation(NPC, x - .5 , y, z - 3, 1, math.random(2, 15))
  33. MovementLoopAddLocation(NPC, x - 3, y, z + 2.5 , 1, math.random(2, 15))
  34. MovementLoopAddLocation(NPC, x , y, z , 0 , math.random(5, 15))
  35. MovementLoopAddLocation(NPC, x + .5 , y, z + 2 , 1, math.random(2, 15))
  36. end
  37. function clockwise2(NPC)
  38. local x = GetX(NPC)
  39. local y = GetY(NPC)
  40. local z = GetZ(NPC)
  41. MovementLoopAddLocation(NPC, x + 1 , y, z - 2 , 1, math.random(2, 15))
  42. MovementLoopAddLocation(NPC, x - 3.5 , y, z - .5 , 1, math.random(2, 10))
  43. MovementLoopAddLocation(NPC, x , y, z + 1 , 1, math.random(2, 15))
  44. MovementLoopAddLocation(NPC, x , y, z , 0 , math.random(5, 15))
  45. MovementLoopAddLocation(NPC, x + 2.5 , y, z + .5 , 1, math.random(2, 10))
  46. end
  47. function counter_clockwise1(NPC)
  48. local x = GetX(NPC)
  49. local y = GetY(NPC)
  50. local z = GetZ(NPC)
  51. MovementLoopAddLocation(NPC, x - 1.5 , y, z + 1 , 1, math.random(2, 15))
  52. MovementLoopAddLocation(NPC, x , y, z , 0 , math.random(5, 15))
  53. MovementLoopAddLocation(NPC, x + .5 , y, z + 3, 1, math.random(2, 15))
  54. MovementLoopAddLocation(NPC, x + 2, y, z - 2.5 , 1, math.random(2, 10))
  55. MovementLoopAddLocation(NPC, x - .5 , y, z - 2 , 1, math.random(2, 10))
  56. end
  57. function counter_clockwise2(NPC)
  58. local x = GetX(NPC)
  59. local y = GetY(NPC)
  60. local z = GetZ(NPC)
  61. MovementLoopAddLocation(NPC, x - 1 , y, z + 2 , 1, math.random(2, 10))
  62. MovementLoopAddLocation(NPC, x + 1.5 , y, z + .5 , 1, math.random(2, 10))
  63. MovementLoopAddLocation(NPC, x , y, z - 1 , 1, math.random(2, 15))
  64. MovementLoopAddLocation(NPC, x , y, z , 0 , math.random(5, 15))
  65. MovementLoopAddLocation(NPC, x - 2.5 , y, z - .5 , 1, math.random(2, 10))
  66. end