Sprocket.lua 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. --[[
  2. Script Name : SpawnScripts/TempleSt/Sprocket.lua
  3. Script Author : Dorbin
  4. Script Date : 2023.10.23 04:10:27
  5. Script Purpose :
  6. :
  7. --]]
  8. require "SpawnScripts/Generic/CombatModule"
  9. local AttackTimer = false --TIMER FOR ATTACK RESPONSE (ATTACKS KERRAN)
  10. local FollowTimer = false --TIMER FOR FOLLOW SCRIPT
  11. function spawn(NPC)
  12. SetTempVariable(NPC,"BarkTimer", nil)
  13. AddTimer(NPC,MakeRandomInt(4000,7000),"ButtonCheck")
  14. AddTimer(NPC,MakeRandomInt(4000,7000),"SkitterCheck")
  15. AddTimer(NPC,MakeRandomInt(4000,7000),"PocketCheck")
  16. AddTimer(NPC,MakeRandomInt(4000,7000),"MethosCheck")
  17. AddTimer(NPC,MakeRandomInt(4000,7000),"CogCheck")
  18. if GetSpawnLocationID(NPC) == 420583 then
  19. waypoints(NPC)
  20. end
  21. SetPlayerProximityFunction(NPC, 4, "InRange", "LeaveRange")
  22. end
  23. function ButtonCheck(NPC,Spawn)
  24. if IsAlive(NPC) then
  25. AddTimer(NPC,MakeRandomInt(4000,7000),"ButtonCheck")
  26. if not IsInCombat(NPC) and GetSpawnByLocationID(zone,420594)~=nil then
  27. SetTempVariable(NPC,"BarkTimer", true)
  28. local zone = GetZone(NPC)
  29. local Cat = GetSpawnByLocationID(zone,420594)
  30. local Distance = GetDistance(NPC,Cat,1)
  31. if Distance <=4 then
  32. SetTarget(NPC,Cat)
  33. FaceTarget(Cat,NPC)
  34. FaceTarget(NPC,Cat)
  35. PlayFlavor(NPC,"","","attack",0,0)
  36. AddTimer(NPC,MakeRandomInt(2500,4500),"Attack2",1,Spawn)
  37. AddTimer(NPC,6000,"ResetStart",1,Spawn)
  38. AddTimer(Cat,6000,"Attack2",1,Spawn)
  39. AddTimer(Cat,6000,"ResetTimer",1,Spawn)
  40. end
  41. end
  42. end
  43. end
  44. function SkitterCheck(NPC,Spawn)
  45. if IsAlive(NPC) then
  46. AddTimer(NPC,MakeRandomInt(4000,7000),"SkitterCheck")
  47. if not IsInCombat(NPC) and GetSpawnByLocationID(zone,420680)~=nil then
  48. SetTempVariable(NPC,"BarkTimer", true)
  49. local zone = GetZone(NPC)
  50. local Cat = GetSpawnByLocationID(zone,420680)
  51. local Distance = GetDistance(NPC,Cat,1)
  52. if Distance <=4 then
  53. SetTarget(NPC,Cat)
  54. FaceTarget(Cat,NPC)
  55. FaceTarget(NPC,Cat)
  56. PlayFlavor(NPC,"","","attack",0,0)
  57. AddTimer(NPC,MakeRandomInt(2500,4500),"Attack2",1,Spawn)
  58. AddTimer(NPC,6000,"ResetStart",1,Spawn)
  59. AddTimer(Cat,6000,"Attack2",1,Spawn)
  60. AddTimer(Cat,6000,"ResetTimer",1,Spawn)
  61. end
  62. end
  63. end
  64. end
  65. function PocketCheck(NPC,Spawn)
  66. if IsAlive(NPC) then
  67. AddTimer(NPC,MakeRandomInt(4000,7000),"PocketCheck")
  68. if not IsInCombat(NPC) and GetSpawnByLocationID(zone,420680)~=nil then
  69. SetTempVariable(NPC,"BarkTimer", true)
  70. local zone = GetZone(NPC)
  71. local Cat = GetSpawnByLocationID(zone,420680)
  72. local Distance = GetDistance(NPC,Cat,1)
  73. if Distance <=4 then
  74. SetTarget(NPC,Cat)
  75. FaceTarget(Cat,NPC)
  76. FaceTarget(NPC,Cat)
  77. PlayFlavor(NPC,"","","attack",0,0)
  78. AddTimer(NPC,MakeRandomInt(2500,4500),"Attack2",1,Spawn)
  79. AddTimer(NPC,6000,"ResetStart",1,Spawn)
  80. AddTimer(Cat,6000,"Attack2",1,Spawn)
  81. AddTimer(Cat,6000,"ResetTimer",1,Spawn)
  82. end
  83. end
  84. end
  85. end
  86. function MethosCheck(NPC,Spawn)
  87. if IsAlive(NPC) then
  88. AddTimer(NPC,MakeRandomInt(4000,7000),"MethosCheck")
  89. if not IsInCombat(NPC) and GetSpawnByLocationID(zone,420494)~=nil then
  90. SetTempVariable(NPC,"BarkTimer", true)
  91. local zone = GetZone(NPC)
  92. local Cat = GetSpawnByLocationID(zone,420494)
  93. local Distance = GetDistance(NPC,Cat,1)
  94. if Distance <=4 then
  95. SetTarget(NPC,Cat)
  96. FaceTarget(Cat,NPC)
  97. FaceTarget(NPC,Cat)
  98. PlayFlavor(NPC,"","","attack",0,0)
  99. AddTimer(NPC,MakeRandomInt(2500,4500),"Attack2",1,Spawn)
  100. AddTimer(NPC,6000,"ResetStart",1,Spawn)
  101. AddTimer(Cat,6000,"Attack2",1,Spawn)
  102. AddTimer(Cat,6000,"ResetTimer",1,Spawn)
  103. end
  104. end
  105. end
  106. end
  107. function CogCheck(NPC,Spawn)
  108. if IsAlive(NPC) then
  109. AddTimer(NPC,MakeRandomInt(4000,7000),"CogCheck")
  110. if not IsInCombat(NPC) and GetSpawnByLocationID(zone,420519)~=nil then
  111. SetTempVariable(NPC,"BarkTimer", true)
  112. local zone = GetZone(NPC)
  113. local Pig = GetSpawnByLocationID(zone,420519)
  114. local Distance = GetDistance(NPC,Pig)
  115. if Distance <=5 then
  116. SetTarget(NPC,Pig)
  117. FaceTarget(Pig,NPC)
  118. FaceTarget(NPC,Pig)
  119. PlayFlavor(NPC,"","","attack",0,0)
  120. AddTimer(NPC,MakeRandomInt(2500,4500),"Attack2",1,Pig)
  121. AddTimer(NPC,6000,"ResetStart",1,Spawn)
  122. AddTimer(Pig,6000,"Attack2",1,Spawn)
  123. AddTimer(Pig,6000,"ResetTimer",1,Spawn)
  124. end
  125. end
  126. end
  127. end
  128. function Attack2 (NPC,Spawn)
  129. PlayFlavor(NPC,"","","attack",0,0)
  130. end
  131. function ResetStart (NPC,Spawn)
  132. AddTimer(NPC,2500,"ResetTimer")
  133. AddTimer(NPC,51000,"ResetBark")
  134. end
  135. function ResetTimer (NPC,Spawn)
  136. SetTarget(NPC,nil)
  137. PlayFlavor(NPC,"","","attack",0,0)
  138. end
  139. function ResetBark (NPC,Spawn)
  140. SetTempVariable(NPC,"BarkTimer", nil)
  141. end
  142. function hailed(NPC, Spawn)
  143. FaceTarget(NPC, Spawn)
  144. if GetRace(Spawn)==11 then --KERRAN RESPONSE
  145. local choice = math.random(1, 2)
  146. if choice == 1 then
  147. PlayFlavor(NPC, "", "", "attack", 0, 0,Spawn)
  148. SendMessage(Spawn, "Sprocket lunges at your tail threateningly.")
  149. elseif choice == 2 then
  150. SendMessage(Spawn, "Sprocket growls at you menecingly.")
  151. end
  152. end
  153. end
  154. function InRange(NPC, Spawn) --FOLLOW TARGET SCRIPT IS TOO SLOW. DOG WALKS, BUT SPEED IS NOT ADJUSTABLE.
  155. if GetRace(Spawn)==11 or GetFactionAmount(Spawn,12)<-10000 then --KERRAN RESPONSE
  156. if AttackTimer == false then
  157. if FollowTimer == false then
  158. FollowTimer = true
  159. FaceTarget(NPC, Spawn)
  160. PlayFlavor(NPC, "", "", "attack", 0, 0)
  161. local choice = math.random(1, 2)
  162. if choice == 1 then
  163. SendMessage(Spawn, "Sprocket snarls and eyes you closely.")
  164. elseif choice == 2 then
  165. SendMessage(Spawn, "Sprocket leers at you with a quivering jowl.")
  166. end
  167. AddTimer(NPC,10000,"ResetFollow",1,Spawn)
  168. AddTimer(NPC,45000,"ResetFollowTimer",1,Spawn)
  169. end
  170. end
  171. end
  172. end
  173. function ResetFollow(NPC)
  174. if IsFollowing(NPC) then
  175. SetTarget(NPC,nil)
  176. ToggleFollow(NPC)
  177. AttackTimer = false
  178. end
  179. end
  180. function ResetFollowTimer(NPC)
  181. FollowTimer = false
  182. SetTarget(NPC,nil)
  183. end
  184. function respawn(NPC)
  185. spawn(NPC)
  186. end
  187. function Sleep(NPC)
  188. local choice = math.random(1,2)
  189. if choice == 1 then
  190. SpawnSet(NPC, "action_state", 540)
  191. AddTimer(NPC, 22000, "Wake")
  192. AttackTimer = true
  193. elseif choice ==2 then
  194. end
  195. end
  196. function Wake(NPC)
  197. SpawnSet(NPC, "action_state", 0)
  198. AttackTimer = false
  199. end
  200. function waypoints(NPC)
  201. MovementLoopAddLocation(NPC, 89.77, -4.57, 96.68, 1, MakeRandomInt(7,12))
  202. MovementLoopAddLocation(NPC, 87.3, -4.57, 100.58, 1, 0)
  203. MovementLoopAddLocation(NPC, 84.12, -4.57, 99.11, 1, 0)
  204. MovementLoopAddLocation(NPC, 80.06, -4.57, 94.6, 1, 0)
  205. MovementLoopAddLocation(NPC, 76.63, -3.97, 87.12, 1, 0)
  206. MovementLoopAddLocation(NPC, 71.63, -0.7, 79.47, 1, 0)
  207. MovementLoopAddLocation(NPC, 71.43, 0.82, 73.9, 1, 0)
  208. MovementLoopAddLocation(NPC, 69.25, 1.76, 70.83, 1, 0)
  209. MovementLoopAddLocation(NPC, 64.34, 2.79, 69.93, 1, 0)
  210. MovementLoopAddLocation(NPC, 55.05, 3, 68.57, 1, 0)
  211. MovementLoopAddLocation(NPC, 46.3, 3, 73.43, 1, 0)
  212. MovementLoopAddLocation(NPC, 39.4, 3, 79.12, 1, MakeRandomInt(7,12))
  213. MovementLoopAddLocation(NPC, 39.62, 3, 78.25, 1, 0)
  214. MovementLoopAddLocation(NPC, 40.67, 3, 78.6, 1, 0)
  215. MovementLoopAddLocation(NPC, 45.23, 3, 81.01, 1, 0)
  216. MovementLoopAddLocation(NPC, 48.78, 3, 90.17, 1, 0)
  217. MovementLoopAddLocation(NPC, 52.21, 3, 97.46, 1, 0)
  218. MovementLoopAddLocation(NPC, 52.94, 3, 100.06, 1, 0)
  219. MovementLoopAddLocation(NPC, 45.58, 3, 106.06, 1, 0)
  220. MovementLoopAddLocation(NPC, 34.06, 3, 109.56, 1, 0)
  221. MovementLoopAddLocation(NPC, 27.19, 3, 98.39, 1, 0)
  222. MovementLoopAddLocation(NPC, 22.51, 3, 88.38, 1, 0)
  223. MovementLoopAddLocation(NPC, 22.58, 3, 85.36, 1, 0)
  224. MovementLoopAddLocation(NPC, 28.79, 3, 79.44, 1, 0)
  225. MovementLoopAddLocation(NPC, 24.23, 3, 74.6, 1, 0)
  226. MovementLoopAddLocation(NPC, 3.07, 3, 67.34, 1, 0)
  227. MovementLoopAddLocation(NPC, -2.13, 3, 62.05, 1, 0)
  228. MovementLoopAddLocation(NPC, -6.39, 3, 55.57, 1, MakeRandomInt(7,12))
  229. MovementLoopAddLocation(NPC, -1.46, 3, 60.62, 1, 0)
  230. MovementLoopAddLocation(NPC, 2.71, 3, 68.49, 1, 0)
  231. MovementLoopAddLocation(NPC, 1.4, 3, 72.9, 1, 0)
  232. MovementLoopAddLocation(NPC, -13.52, 3, 79.71, 1, 0)
  233. MovementLoopAddLocation(NPC, -17.93, 3, 81.95, 1, MakeRandomInt(7,12))
  234. MovementLoopAddLocation(NPC, -20.3, 3, 83.25, 1, 0)
  235. MovementLoopAddLocation(NPC, -20.63, 3, 82.64, 1, 0)
  236. MovementLoopAddLocation(NPC, -20.07, 3, 81.42, 1, 0)
  237. MovementLoopAddLocation(NPC, -9.95, 3, 80.6, 1, 0)
  238. MovementLoopAddLocation(NPC, -5.36, 3, 88.08, 1, 0)
  239. MovementLoopAddLocation(NPC, 10.34, 3, 83.84, 1, 0)
  240. MovementLoopAddLocation(NPC, 35.83, 3, 75.19, 1, 0)
  241. MovementLoopAddLocation(NPC, 43.81, 3, 72.25, 1, 0)
  242. MovementLoopAddLocation(NPC, 53.42, 3, 67.52, 1, 0)
  243. MovementLoopAddLocation(NPC, 65, 2.74, 68.47, 1, 0)
  244. MovementLoopAddLocation(NPC, 72.36, 0.83, 73.05, 1, 0)
  245. MovementLoopAddLocation(NPC, 72.4, -0.63, 78.62, 1, 0)
  246. MovementLoopAddLocation(NPC, 75.75, -2.78, 83.79, 1, 0)
  247. MovementLoopAddLocation(NPC, 82.04, -4.57, 91.56, 1, 0)
  248. MovementLoopAddLocation(NPC, 86.52, -4.57, 98.96, 1, 0)
  249. MovementLoopAddLocation(NPC, 95.74, -4.57, 105.36, 1, 0)
  250. MovementLoopAddLocation(NPC, 105.53, -4.57, 107.28, 1, 0)
  251. MovementLoopAddLocation(NPC, 107.37, -4.57, 108.58, 1, MakeRandomInt(7,12))
  252. MovementLoopAddLocation(NPC, 92.92, -4.57, 100.77, 1, 0)
  253. end