agoblin.lua 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. Script Notes : Created client versioning & added interactions between NPCs. MISSING INGRED CHASE AROUND BOAT, but not necessary. - Dorbin 08.14.22
  8. --]]
  9. local legacy = true -- Client check. True == DoF or Classic
  10. function spawn(NPC)
  11. -- AddTimer(NPC, 5000, "idle_loop")
  12. CageCollision(NPC)
  13. end
  14. function hailed(NPC, player)
  15. -- AddTimer(NPC, 100, "idle_loop")
  16. end
  17. function idle_loop(NPC)
  18. local states = {15, 217, 218, 883, 226, 296, 311, 315, 488, 519, 521, 524, 550, 632, 637, 717, 82}
  19. SendStateCommand(NPC, states[math.random(#states)])
  20. AddTimer(NPC, math.random(5000, 7000), "stop_animation")
  21. end
  22. function CageCollision(NPC)
  23. SpawnMob(GetZone(NPC),270011,-3.74,-0.57,15.74)
  24. end
  25. function stop_animation(NPC)
  26. SendStateCommand(NPC, 0)
  27. if GetSpawn(NPC, 270011) == nil then
  28. AddTimer(NPC, 500, "run_around_loop_init")
  29. else
  30. AddTimer(NPC, math.random(3000, 10000), "idle_loop")
  31. end
  32. end
  33. ----NON DOF VERSION
  34. function NonDoF_idle_loop(NPC)-- For NON DOF/CLASSIC CLIENTS
  35. local states = {11255 , 11256 , 883, 11287 , 11554 , 11663 , 11676 , 12081 , 12166 , 12172 , 12191 , 12325 , 12983 , 13015 , 13063 , 10844, 11880 }
  36. SendStateCommand(NPC, states[math.random(#states)])
  37. AddTimer(NPC, math.random(5000, 7000), "NonDoF_stop_animation")
  38. end
  39. function NonDoF_stop_animation(NPC)
  40. SendStateCommand(NPC, 0)
  41. legacy = false
  42. if GetSpawn(NPC, 270011) == nil then
  43. AddTimer(NPC, 500, "run_around_loop_init")
  44. else
  45. AddTimer(NPC, math.random(3000, 10000), "NonDoF_idle_loop")
  46. end
  47. end
  48. -----
  49. function run_around_loop_init(NPC)
  50. MoveToLocation(NPC, 2.92, 0.57, 15.98, 5, "run_around_loop_init_pause", false)
  51. end
  52. function run_around_loop_init_pause(NPC)
  53. ClearRunningLocations(NPC)
  54. AddTimer(NPC, 700, "run_around_loop_init_continue")
  55. end
  56. function run_around_loop_init_continue(NPC)
  57. MoveToLocation(NPC, 3.23, -2.07, 10.83, 5, "run_around_loop_init_finished", false)
  58. end
  59. function run_around_loop_init_finished(NPC)
  60. ClearRunningLocations(NPC)
  61. AddTimer(NPC, 100, "run_around_loop")
  62. end
  63. function run_around_loop(NPC)
  64. MovementLoopAdd(NPC, -4.43, -2.07, 6.17, 5, 1)
  65. MovementLoopAdd(NPC, -4.43, -2.07, 6.17, 5, 3, "run_around_loop_pause1")
  66. MovementLoopAdd(NPC, -4.43, -2.07, 6.17, 5, 0)
  67. MovementLoopAdd(NPC, -5.23, -2.01, 0.39, 5, 1)
  68. MovementLoopAdd(NPC, -5.23, -2.01, 0.39, 5, 3, "run_around_loop_pause2")
  69. MovementLoopAdd(NPC, -5.23, -2.01, 0.39, 5, 0)
  70. MovementLoopAdd(NPC, -4.88, -2.06, 4.26, 5, 1)
  71. MovementLoopAdd(NPC, -4.88, -2.06, 4.26, 5, 3, "run_around_loop_pause3")
  72. MovementLoopAdd(NPC, -4.88, -2.06, 4.26, 5, 0)
  73. MovementLoopAdd(NPC, 3.94, -2.07, 0.66, 5, 1)
  74. MovementLoopAdd(NPC, 3.94, -2.07, 0.66, 5, 3, "run_around_loop_pause4")
  75. MovementLoopAdd(NPC, 3.94, -2.07, 0.66, 5, 0)
  76. MovementLoopAdd(NPC, 2.84, -2.07, -2.07, 5, 1)
  77. MovementLoopAdd(NPC, 2.84, -2.07, -2.07, 5, 3, "run_around_loop_pause5")
  78. MovementLoopAdd(NPC, 2.84, -2.07, -2.07, 5, 0)
  79. MovementLoopAdd(NPC, 3.41, -1.99, -7.42, 5, 1)
  80. MovementLoopAdd(NPC, 3.41, -1.99, -7.42, 5, 3, "run_around_loop_pause6")
  81. MovementLoopAdd(NPC, 3.41, -1.99, -7.42, 5, 0)
  82. MovementLoopAdd(NPC, -2.75, -2.02, -5.82, 5, 0)
  83. MovementLoopAdd(NPC, -2.63, 1.21, -18.11,5,1)
  84. MovementLoopAdd(NPC, -2.63, 1.21, -18.11,5,3,"run_around_loop_pause7")
  85. MovementLoopAdd(NPC, -2.63, 1.21, -18.11,3,0)
  86. MovementLoopAdd(NPC, -2.75, -2.02, -5.82, 5, 0)
  87. end
  88. function run_around_loop_pause(NPC)
  89. local choice = {217, 226, 550, 717, 125, 125, 125, 125} -- update to retain intention of original script. mostly want threaten.
  90. SendStateCommand(NPC, choice[math.random(#choice)])
  91. AddTimer(NPC, 3000, "run_around_loop_stop_animation")
  92. end
  93. function run_around_loop_pauseNonDoF(NPC)
  94. local choice = {11255, 11287, 12325, 13063, 13063, 13063, 12153, 125,11757,11880}
  95. SendStateCommand(NPC, choice[math.random(#choice)])
  96. AddTimer(NPC, 3000, "run_around_loop_stop_animation")
  97. end
  98. function run_around_loop_pause1(NPC)
  99. SetTarget(GetSpawn(NPC, 270005),NPC)
  100. FaceTarget(GetSpawn(NPC, 270005), NPC)
  101. SetTarget(NPC,GetSpawn(NPC, 270005))
  102. FaceTarget(NPC,GetSpawn(NPC, 270005))
  103. if legacy == true then --DoF or Classic Client
  104. SendStateCommand(GetSpawn(NPC, 270005), 218) --CRINGE
  105. run_around_loop_pause(NPC)
  106. else
  107. SendStateCommand(GetSpawn(NPC, 270005), 11256)
  108. run_around_loop_pauseNonDoF(NPC)
  109. end
  110. end
  111. function run_around_loop_pause2(NPC)
  112. SetTarget(GetSpawn(NPC, 270006),NPC)
  113. SetTarget(NPC,GetSpawn(NPC, 270006))
  114. FaceTarget(GetSpawn(NPC, 270006), NPC)
  115. FaceTarget(NPC,GetSpawn(NPC, 270006))
  116. if legacy == true then --DoF or Classic Client
  117. SendStateCommand(GetSpawn(NPC, 270006), 525) --SCREAM
  118. run_around_loop_pause(NPC)
  119. else
  120. SendStateCommand(GetSpawn(NPC, 270006), 12192)
  121. run_around_loop_pauseNonDoF(NPC)
  122. end
  123. end
  124. function run_around_loop_pause3(NPC)
  125. run_around_loop_pause(NPC)
  126. end
  127. function run_around_loop_pause4(NPC)
  128. SetTarget(GetSpawn(NPC, 270004),NPC)
  129. FaceTarget(GetSpawn(NPC, 270004), NPC)
  130. SetTarget(NPC,GetSpawn(NPC, 270004))
  131. FaceTarget(NPC,GetSpawn(NPC, 270004))
  132. if legacy == true then --DoF or Classic Client
  133. SendStateCommand(GetSpawn(NPC, 270004), 717) --THREATEN
  134. run_around_loop_pause(NPC)
  135. else
  136. SendStateCommand(GetSpawn(NPC, 270004), 13063)
  137. run_around_loop_pauseNonDoF(NPC)
  138. end
  139. end
  140. function run_around_loop_pause5(NPC)
  141. SetTarget(GetSpawn(NPC, 270001),NPC)
  142. FaceTarget(GetSpawn(NPC, 270001), NPC)
  143. SetTarget(NPC,GetSpawn(NPC, 270001))
  144. FaceTarget(NPC,GetSpawn(NPC, 270001))
  145. if legacy == true then --DoF or Classic Client
  146. SendStateCommand(GetSpawn(NPC, 270001), 218) --CRINGE
  147. run_around_loop_pause(NPC)
  148. else
  149. SendStateCommand(GetSpawn(NPC, 270001), 11256)
  150. run_around_loop_pauseNonDoF(NPC)
  151. end
  152. end
  153. function run_around_loop_pause6(NPC)
  154. run_around_loop_pause(NPC)
  155. end
  156. function run_around_loop_pause7(NPC)
  157. SetTarget(GetSpawn(NPC, 270002),NPC)
  158. SetTarget(NPC,GetSpawn(NPC, 270002))
  159. FaceTarget(GetSpawn(NPC, 270002), NPC)
  160. FaceTarget(NPC,GetSpawn(NPC, 270002))
  161. if legacy == true then --DoF or Classic Client
  162. SendStateCommand(GetSpawn(NPC, 270002), 528) --Shakefist
  163. run_around_loop_pause(NPC)
  164. else
  165. SendStateCommand(GetSpawn(NPC, 270002), 12214)
  166. run_around_loop_pauseNonDoF(NPC)
  167. end
  168. end
  169. function run_around_loop_stop_animation(NPC)
  170. SendStateCommand(NPC, 0)
  171. SetTarget(NPC,nil)
  172. SetTarget(GetSpawn(NPC, 270001),nil)
  173. SetTarget(GetSpawn(NPC, 270002),nil)
  174. SetTarget(GetSpawn(NPC, 270003),nil)
  175. SetTarget(GetSpawn(NPC, 270004),nil)
  176. SetTarget(GetSpawn(NPC, 270005),nil)
  177. SetTarget(GetSpawn(NPC, 270006),nil)
  178. SetTarget(NPC,nil)
  179. end
  180. function death(NPC,Spawn)
  181. -- AddTimer(GetSpawn(NPC, 270008), 100, "idle_loop")
  182. end