random_pattern_small.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. --[[
  2. Script Name : SpawnScripts/Generic/random_pattern_small.lua
  3. Script Purpose : chooses a random route of a particular pattern
  4. Script Author : theFoof
  5. Script Date : 2013.5.16
  6. Script Notes : If the coords are out of bounds then the spawn will still go there.
  7. --]]
  8. function spawn(NPC)
  9. ChooseMovement(NPC)
  10. end
  11. function ChooseMovement(NPC)
  12. local route = math.random(1,4)
  13. if route == 1 then
  14. RouteOne(NPC, Spawn)
  15. elseif route == 2 then
  16. RouteTwo(NPC, Spawn)
  17. elseif route == 3 then
  18. RouteThree(NPC, Spawn)
  19. elseif route == 4 then
  20. RouteFour(NPC, Spawn)
  21. end
  22. end
  23. function RouteOne(NPC, Spawn)
  24. local X = GetX(NPC)
  25. local Y = GetY(NPC)
  26. local Z = GetZ(NPC)
  27. MovementLoopAddLocation(NPC, X, Y, Z, 2, math.random(2,10))
  28. MovementLoopAddLocation(NPC, X + 4, Y, Z, 2, math.random(20,45))
  29. MovementLoopAddLocation(NPC, X + 4, Y, Z + 4, 2, math.random(20,45))
  30. MovementLoopAddLocation(NPC, X + 7, Y, Z, 2, math.random(20,45))
  31. MovementLoopAddLocation(NPC, X + 4, Y, Z + 4, 2, math.random(20,45))
  32. MovementLoopAddLocation(NPC, X, Y, Z, 2, math.random(20,45))
  33. end
  34. function RouteTwo(NPC, Spawn)
  35. local X = GetX(NPC)
  36. local Y = GetY(NPC)
  37. local Z = GetZ(NPC)
  38. MovementLoopAddLocation(NPC, X, Y, Z, 2, math.random(2,10))
  39. MovementLoopAddLocation(NPC, X - 4, Y, Z, 2, math.random(20,45))
  40. MovementLoopAddLocation(NPC, X - 4, Y, Z - 4, 2, math.random(20,45))
  41. MovementLoopAddLocation(NPC, X - 7, Y, Z, 2, math.random(20,45))
  42. MovementLoopAddLocation(NPC, X - 4, Y, Z - 4, 2, math.random(20,45))
  43. MovementLoopAddLocation(NPC, X, Y, Z, 1, math.random(20,45))
  44. end
  45. function RouteThree(NPC, Spawn)
  46. local X = GetX(NPC)
  47. local Y = GetY(NPC)
  48. local Z = GetZ(NPC)
  49. MovementLoopAddLocation(NPC, X, Y, Z, 2, math.random(2,10))
  50. MovementLoopAddLocation(NPC, X + 4, Y, Z, 2, math.random(20,45))
  51. MovementLoopAddLocation(NPC, X + 4, Y, Z - 4, 2, math.random(20,45))
  52. MovementLoopAddLocation(NPC, X + 7, Y, Z, 2, math.random(20,45))
  53. MovementLoopAddLocation(NPC, X + 4, Y, Z - 4, 2, math.random(20,45))
  54. MovementLoopAddLocation(NPC, X, Y, Z, 2, math.random(20,45))
  55. end
  56. function RouteFour(NPC, Spawn)
  57. local X = GetX(NPC)
  58. local Y = GetY(NPC)
  59. local Z = GetZ(NPC)
  60. MovementLoopAddLocation(NPC, X, Y, Z, 2, math.random(2,10))
  61. MovementLoopAddLocation(NPC, X - 4, Y, Z, 2, math.random(20,45))
  62. MovementLoopAddLocation(NPC, X - 4, Y, Z + 4, 2, math.random(20,45))
  63. MovementLoopAddLocation(NPC, X - 7, Y, Z, 2, math.random(20,45))
  64. MovementLoopAddLocation(NPC, X - 4, Y, Z + 4, 2, math.random(20,45))
  65. MovementLoopAddLocation(NPC, X, Y, Z, 2, math.random(20,45))
  66. end
  67. function respawn(NPC, Spawn)
  68. spawn(NPC)
  69. end
  70. function hailed(NPC, Spawn)
  71. FaceTarget(NPC, Spawn)
  72. end