agoblin.lua 7.3 KB

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