agoblin.lua 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. --[[
  2. Script Name : SpawnScripts/FarJourneyFreeport/a goblin.lua
  3. Script Author : LethalEncounter
  4. Script Date : 2020.07.02
  5. Script Purpose : Govern movement and spawn behavior of the goblin on the Far Journey.
  6. Script Notes : Re-wrote random behavior functions so they suck less. Neveruary 08/07/21
  7. --]]
  8. function spawn(NPC)
  9. AddTimer(NPC, 5000, "idle_loop")
  10. end
  11. function hailed(NPC, player)
  12. AddTimer(NPC, 100, "idle_loop")
  13. end
  14. function idle_loop(NPC)
  15. local states = {15, 217, 218, 883, 226, 296, 311, 315, 488, 519, 521, 524, 550, 632, 637, 717, 82}
  16. SendStateCommand(NPC, states[math.random(#states)])
  17. AddTimer(NPC, math.random(5000, 7000), "stop_animation")
  18. end
  19. function stop_animation(NPC)
  20. SendStateCommand(NPC, 0)
  21. if GetSpawn(NPC, 270011) == nil then
  22. AddTimer(NPC, 500, "run_around_loop_init")
  23. else
  24. AddTimer(NPC, math.random(3000, 10000), "idle_loop")
  25. end
  26. end
  27. function run_around_loop_init(NPC)
  28. MoveToLocation(NPC, 2.92, 0.57, 15.98, 5, "run_around_loop_init_pause", false)
  29. end
  30. function run_around_loop_init_pause(NPC)
  31. ClearRunningLocations(NPC)
  32. AddTimer(NPC, 700, "run_around_loop_init_continue")
  33. end
  34. function run_around_loop_init_continue(NPC)
  35. MoveToLocation(NPC, 3.23, -2.07, 10.83, 5, "run_around_loop_init_finished", false)
  36. end
  37. function run_around_loop_init_finished(NPC)
  38. ClearRunningLocations(NPC)
  39. AddTimer(NPC, 100, "run_around_loop")
  40. end
  41. function run_around_loop(NPC)
  42. MovementLoopAdd(NPC, -4.43, -2.07, 6.17, 5, 3, "run_around_loop_pause1")
  43. MovementLoopAdd(NPC, -5.23, -2.01, 0.39, 5, 3, "run_around_loop_pause2")
  44. MovementLoopAdd(NPC, -4.88, -2.06, 4.26, 5, 3, "run_around_loop_pause3")
  45. MovementLoopAdd(NPC, 3.94, -2.07, 0.66, 5, 3, "run_around_loop_pause4")
  46. MovementLoopAdd(NPC, 2.84, -2.07, -2.07, 5, 3, "run_around_loop_pause5")
  47. MovementLoopAdd(NPC, 3.41, -1.99, -7.42, 5, 3, "run_around_loop_pause6")
  48. end
  49. function run_around_loop_pause(NPC)
  50. local choice = {217, 226, 550, 717, 125, 125, 125, 125} -- update to retain intention of original script. mostly want threaten.
  51. SendStateCommand(NPC, states[math.random(#states)])
  52. AddTimer(NPC, 2800, "run_around_loop_stop_animation")
  53. end
  54. function run_around_loop_pause1(NPC)
  55. SendStateCommand(GetSpawn(NPC, 270005), 218)
  56. run_around_loop_pause(NPC)
  57. end
  58. function run_around_loop_pause2(NPC)
  59. SendStateCommand(GetSpawn(NPC, 270006), 525)
  60. run_around_loop_pause(NPC)
  61. end
  62. function run_around_loop_pause3(NPC)
  63. run_around_loop_pause(NPC)
  64. end
  65. function run_around_loop_pause4(NPC)
  66. SendStateCommand(GetSpawn(NPC, 270004), 535)
  67. run_around_loop_pause(NPC)
  68. end
  69. function run_around_loop_pause5(NPC)
  70. SendStateCommand(GetSpawn(NPC, 270001), 218)
  71. run_around_loop_pause(NPC)
  72. end
  73. function run_around_loop_pause6(NPC)
  74. run_around_loop_pause(NPC)
  75. end
  76. function run_around_loop_stop_animation(NPC)
  77. SendStateCommand(NPC, 0)
  78. end