agoblin.lua 7.1 KB

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