9
3

agoblin.lua 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. --[[
  2. Script Name : SpawnScripts/FarJourneyFreeport/a goblin.lua
  3. Script Author : LethalEncounter
  4. Script Date : 2020.07.02
  5. Script Purpose :
  6. :
  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. choice = math.random(0, 15)
  16. if choice == 0 then
  17. SendStateCommand(NPC, 217)
  18. elseif choice == 1 then
  19. SendStateCommand(NPC, 218)
  20. elseif choice == 2 then
  21. SendStateCommand(NPC, 883)
  22. elseif choice == 3 then
  23. SendStateCommand(NPC, 226)
  24. elseif choice == 4 then
  25. SendStateCommand(NPC, 296)
  26. elseif choice == 5 then
  27. SendStateCommand(NPC, 311)
  28. elseif choice == 6 then
  29. SendStateCommand(NPC, 315)
  30. elseif choice == 7 then
  31. SendStateCommand(NPC, 488)
  32. elseif choice == 8 then
  33. SendStateCommand(NPC, 519)
  34. elseif choice == 9 then
  35. SendStateCommand(NPC, 521)
  36. elseif choice == 10 then
  37. SendStateCommand(NPC, 524)
  38. elseif choice == 11 then
  39. SendStateCommand(NPC, 550)
  40. elseif choice == 12 then
  41. SendStateCommand(NPC, 632)
  42. elseif choice == 13 then
  43. SendStateCommand(NPC, 637)
  44. elseif choice == 14 then
  45. SendStateCommand(NPC, 717)
  46. else
  47. SendStateCommand(NPC, 82)
  48. end
  49. AddTimer(NPC, math.random(5000, 7000), "stop_animation")
  50. end
  51. function stop_animation(NPC)
  52. SendStateCommand(NPC, 0)
  53. if GetSpawn(NPC, 270011) == Nil then
  54. AddTimer(NPC, 500, "run_around_loop_init")
  55. else
  56. AddTimer(NPC, math.random(3000, 10000), "idle_loop")
  57. end
  58. end
  59. function run_around_loop_init(NPC)
  60. MoveToLocation(NPC, 2.92, 0.57, 15.98, 5, "run_around_loop_init_pause", false)
  61. end
  62. function run_around_loop_init_pause(NPC)
  63. ClearRunningLocations(NPC)
  64. AddTimer(NPC, 700, "run_around_loop_init_continue")
  65. end
  66. function run_around_loop_init_continue(NPC)
  67. MoveToLocation(NPC, 3.23, -2.07, 10.83, 5, "run_around_loop_init_finished", false)
  68. end
  69. function run_around_loop_init_finished(NPC)
  70. ClearRunningLocations(NPC)
  71. AddTimer(NPC, 100, "run_around_loop")
  72. end
  73. function run_around_loop(NPC)
  74. MovementLoopAdd(NPC, -4.43, -2.07, 6.17, 5, 3, "run_around_loop_pause1")
  75. MovementLoopAdd(NPC, -5.23, -2.01, 0.39, 5, 3, "run_around_loop_pause2")
  76. MovementLoopAdd(NPC, -4.88, -2.06, 4.26, 5, 3, "run_around_loop_pause3")
  77. MovementLoopAdd(NPC, 3.94, -2.07, 0.66, 5, 3, "run_around_loop_pause4")
  78. MovementLoopAdd(NPC, 2.84, -2.07, -2.07, 5, 3, "run_around_loop_pause5")
  79. MovementLoopAdd(NPC, 3.41, -1.99, -7.42, 5, 3, "run_around_loop_pause6")
  80. end
  81. function run_around_loop_pause(NPC)
  82. choice = math.random(0, 7) --[ mostly get threaten (125) this way ]--
  83. if choice == 0 then
  84. SendStateCommand(NPC, 217)
  85. elseif choice == 1 then
  86. SendStateCommand(NPC, 226)
  87. elseif choice == 2 then
  88. SendStateCommand(NPC, 550)
  89. elseif choice == 3 then
  90. SendStateCommand(NPC, 717)
  91. else
  92. SendStateCommand(NPC, 125)
  93. end
  94. AddTimer(NPC, 2800, "run_around_loop_stop_animation")
  95. end
  96. function run_around_loop_pause1(NPC)
  97. SendStateCommand(GetSpawn(NPC, 270005), 218)
  98. run_around_loop_pause(NPC)
  99. end
  100. function run_around_loop_pause2(NPC)
  101. SendStateCommand(GetSpawn(NPC, 270006), 525)
  102. run_around_loop_pause(NPC)
  103. end
  104. function run_around_loop_pause3(NPC)
  105. run_around_loop_pause(NPC)
  106. end
  107. function run_around_loop_pause4(NPC)
  108. SendStateCommand(GetSpawn(NPC, 270004), 535)
  109. run_around_loop_pause(NPC)
  110. end
  111. function run_around_loop_pause5(NPC)
  112. SendStateCommand(GetSpawn(NPC, 270001), 218)
  113. run_around_loop_pause(NPC)
  114. end
  115. function run_around_loop_pause6(NPC)
  116. run_around_loop_pause(NPC)
  117. end
  118. function run_around_loop_stop_animation(NPC)
  119. SendStateCommand(NPC, 0)
  120. end