Skitter.lua 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. --[[
  2. Script Name : SpawnScripts/TempleSt/Skitter.lua
  3. Script Author : Dorbin
  4. Script Date : 2023.10.24 08:10:17
  5. Script Purpose :
  6. :
  7. --]]
  8. local Speed1 = nil
  9. local Speed2 = nil
  10. require "SpawnScripts/Generic/CombatModule"
  11. function spawn(NPC)
  12. AddTimer(NPC,MakeRandomInt(3000,6000),"ChefCheck")
  13. AddTimer(NPC,MakeRandomInt(3000,6000),"waypoints")
  14. SetPlayerProximityFunction(NPC, 7, "InRange", "LeaveRange")
  15. SetTempVariable(NPC,"HissTimer", "0")
  16. end
  17. function InRange(NPC,Spawn)
  18. if not IsInCombat(NPC) and GetTempVariable(NPC,"HissTimer")~="1" then
  19. local Choice = MakeRandomInt(0,100)
  20. if GetRace(Spawn)== 13 then
  21. if Choice <=75 then
  22. InRange_Attack(NPC,Spawn)
  23. end
  24. elseif Choice <= 40 then
  25. InRange_Attack(NPC,Spawn)
  26. end
  27. end
  28. end
  29. function InRange_Attack(NPC,Spawn)
  30. local Choice = MakeRandomInt(1,2)
  31. if Choice == 1 then
  32. FaceTarget(NPC,Spawn)
  33. AddTimer(NPC,1000,"HissAttack",1,Spawn)
  34. else
  35. AddTimer(NPC,500,"Hiss",1,Spawn)
  36. end
  37. SetTempVariable(NPC,"HissTimer", "1")
  38. AddTimer(NPC,25000,"HissReset",1,Spawn)
  39. end
  40. function HissAttack(NPC,Spawn)
  41. PlayFlavor(NPC,"","","attack",0,0)
  42. end
  43. function Hiss(NPC,Spawn)
  44. local Choice = MakeRandomInt(1,2)
  45. if Choice == 1 then
  46. PlaySound(NPC,"sounds/critters/cat/cat_hiss001.wav",GetX(NPC), GetY(NPC), GetZ(NPC))
  47. else
  48. PlaySound(NPC,"sounds/critters/cat/cat_hiss002.wav",GetX(NPC), GetY(NPC), GetZ(NPC))
  49. end
  50. SetTarget(NPC,nil)
  51. end
  52. function HissReset(NPC,Spawn)
  53. SetTempVariable(NPC,"HissTimer", "0")
  54. end
  55. function ChefCheck(NPC,Spawn)
  56. if IsAlive(NPC) then
  57. AddTimer(NPC,MakeRandomInt(4000,7000),"ChefCheck")
  58. local zone = GetZone(NPC)
  59. local Chef = GetSpawnByLocationID(zone,420550)
  60. if not IsInCombat(NPC) and Chef~= nil and not IsInCombat(Chef)then
  61. local Distance = GetDistance(NPC,Chef,1)
  62. if Distance <=4 then
  63. Attack(Chef,NPC)
  64. Attack(NPC,Chef)
  65. local x = GetX(Chef)
  66. local y = GetY(Chef)
  67. local z = GetZ(Chef)
  68. SetFollowTarget(Chef,NPC)
  69. SetFollowTarget(NPC,Chef)
  70. ToggleFollow(Chef)
  71. ToggleFollow(NPC)
  72. SetTarget(Chef,NPC)
  73. FaceTarget(Chef,NPC)
  74. FaceTarget(NPC,Chef)
  75. PlayFlavor(NPC,"","","attack",0,0)
  76. AddTimer(NPC,MakeRandomInt(2500,4500),"kill",1,Spawn)
  77. end
  78. end
  79. end
  80. end
  81. function kill (NPC,Spawn)
  82. ApplySpellVisual(NPC,51)
  83. local zone = GetZone(NPC)
  84. local Chef = GetSpawnByLocationID(zone,420550)
  85. PlayFlavor(Chef,"","","1h_sword_attack",0,0)
  86. KillSpawn(NPC)
  87. AddTimer(Chef,2500,"scoop")
  88. AddTimer(NPC,3000,"Despawning")
  89. end
  90. function Despawning(NPC,Spawn)
  91. Despawn(NPC)
  92. end
  93. function scoop(NPC,Spawn)
  94. local zone = GetZone(NPC)
  95. local Chef = GetSpawnByLocationID(zone,420550)
  96. PlayFlavor(Chef,"","","gathering_success",0,0)
  97. Despawn(NPC)
  98. end
  99. function respawn(NPC)
  100. spawn(NPC)
  101. end
  102. function waypoints(NPC)
  103. local choice = MakeRandomInt(1,2)
  104. if choice == 1 then
  105. SetTempVariable(NPC,"Speed1_Set", "1")
  106. SetTempVariable(NPC,"Speed2_Set", "6")
  107. else
  108. SetTempVariable(NPC,"Speed1_Set", "6")
  109. SetTempVariable(NPC,"Speed2_Set", "1")
  110. end
  111. local Speed1 = GetTempVariable(NPC,"Speed1_Set")
  112. local Speed2 = GetTempVariable(NPC,"Speed2_Set")
  113. MovementLoopAddLocation(NPC, -4.01, 3, 114.66, 1, 0)
  114. MovementLoopAddLocation(NPC, -4.01, 3, 114.66, Speed1, 0)
  115. MovementLoopAddLocation(NPC, 0.54, 3.00, 110.66, 1, 0)
  116. MovementLoopAddLocation(NPC, 0.63, 3, 110.73, Speed1, 0)
  117. MovementLoopAddLocation(NPC, -4.22, 3, 100.21, Speed1, 0)
  118. MovementLoopAddLocation(NPC, -7, 3, 91.34, Speed1, 0)
  119. MovementLoopAddLocation(NPC, -10.22, 3, 82.31, Speed1, 0)
  120. MovementLoopAddLocation(NPC, -10.22, 3, 82.31, Speed2, 0)
  121. MovementLoopAddLocation(NPC, -8.57, 3, 77.81, Speed1, 0)
  122. MovementLoopAddLocation(NPC, 0.25, 3, 72.69, Speed2, 0)
  123. MovementLoopAddLocation(NPC, 7.1, 3, 69.48, Speed2, 0)
  124. MovementLoopAddLocation(NPC, 7.1, 3, 69.48, Speed2, 0)
  125. MovementLoopAddLocation(NPC, 13.57, 3, 71.59, Speed1, 0)
  126. MovementLoopAddLocation(NPC, 21.57, 2.96, 76.43, Speed1, 0)
  127. MovementLoopAddLocation(NPC, 19.41, 3, 86.01, Speed1, 12)
  128. MovementLoopAddLocation(NPC, 25.5, 2.99, 57, Speed1, 0)
  129. MovementLoopAddLocation(NPC, 25.5, 2.99, 57, Speed2, 0)
  130. MovementLoopAddLocation(NPC, 25.5, 2.99, 57, Speed2, 10)
  131. MovementLoopAddLocation(NPC, 32.82, 3, 73.14, Speed2, 0)
  132. MovementLoopAddLocation(NPC, 45.29, 3, 81.61, Speed2, 0)
  133. MovementLoopAddLocation(NPC, 49.39, 3, 92.25, Speed2, 0)
  134. MovementLoopAddLocation(NPC, 51.92, 3, 99.67, Speed1, 0)
  135. MovementLoopAddLocation(NPC, 51.92, 3, 99.67, Speed2, 0)
  136. MovementLoopAddLocation(NPC, 46.89, 3, 105.05, Speed2, 0)
  137. MovementLoopAddLocation(NPC, 35.42, 3, 109.79, Speed2, 0)
  138. MovementLoopAddLocation(NPC, 33.42, 3, 107.62, Speed2, 0)
  139. MovementLoopAddLocation(NPC, 25.28, 3, 94.82, Speed2, 0)
  140. MovementLoopAddLocation(NPC, 21.82, 3, 92.27, Speed2, 10)
  141. MovementLoopAddLocation(NPC, 21.79, 3, 91.48, Speed1, 0)
  142. MovementLoopAddLocation(NPC, 21.79, 3, 91.48, Speed1, 0)
  143. MovementLoopAddLocation(NPC, 16.18, 3, 83.15, Speed2, 0)
  144. MovementLoopAddLocation(NPC, 5.03, 3, 85.76, Speed2, 0)
  145. MovementLoopAddLocation(NPC, -3.76, 3, 89.72, Speed1, 0)
  146. MovementLoopAddLocation(NPC, -7, 3, 92.01, Speed1, 0)
  147. MovementLoopAddLocation(NPC, -8.2, 3, 89.87, Speed1, 4)
  148. MovementLoopAddLocation(NPC, -8.2, 3, 89.87, Speed2, 0)
  149. MovementLoopAddLocation(NPC, -7.59, 3, 89.21, 6, 0)
  150. MovementLoopAddLocation(NPC, -12.05, 3, 79.9, Speed1, 0,"Rat_1")
  151. MovementLoopAddLocation(NPC, -12.38, 3, 79.3, Speed2, 1)
  152. MovementLoopAddLocation(NPC, -12.38, 3, 79.3, Speed2, 1,"Rat_1_Target")
  153. MovementLoopAddLocation(NPC, -12.38, 3, 79.3, Speed2, 1,"Rat_1_Attack")
  154. MovementLoopAddLocation(NPC, -12.38, 3, 79.3, Speed2, 1)
  155. MovementLoopAddLocation(NPC, -22.81, 3, 83.91, 6, 1,"Rat_1_Run")
  156. MovementLoopAddLocation(NPC, -12.18, 3, 79.22, 6, 0)
  157. MovementLoopAddLocation(NPC, -6.65, 3, 89.24, 6, 0)
  158. MovementLoopAddLocation(NPC, -4.77, 3, 99.87, 6, 0)
  159. MovementLoopAddLocation(NPC, -12.57, 3, 104.86, 6, 0)
  160. MovementLoopAddLocation(NPC, -17.18, 2.97, 105.37, 6, 0)
  161. MovementLoopAddLocation(NPC, -32.7, 3, 112.34, 6, 0)
  162. MovementLoopAddLocation(NPC, -35.23, 2.84, 114.18, 6, 0)
  163. MovementLoopAddLocation(NPC, -60.02, 2.84, 128.2, 6, 0)
  164. MovementLoopAddLocation(NPC, -47.68, 2.84, 120.5, 6, 0)
  165. MovementLoopAddLocation(NPC, -39.01, 2.83, 116.71, 6, 0)
  166. MovementLoopAddLocation(NPC, -34.13, 2.84, 121.18, 6, 0)
  167. MovementLoopAddLocation(NPC, -36.74, 2.83, 119.12, 6, 0)
  168. MovementLoopAddLocation(NPC, -44.02, 2.83, 105.2, 6, 0)
  169. MovementLoopAddLocation(NPC, -44.02, 2.83, 105.2, 6, 0)
  170. MovementLoopAddLocation(NPC, -44.02, 2.83, 105.2, 6, 1)
  171. MovementLoopAddLocation(NPC, -44.02, 2.83, 105.2, 6, 7,"Rat1_Kill")
  172. MovementLoopAddLocation(NPC, -39.18, 2.81, 112.46, 1, 0)
  173. MovementLoopAddLocation(NPC, -33.88, 2.93, 112.57, 1, 0)
  174. MovementLoopAddLocation(NPC, -23.41, 2.81, 103.94, 1, 0)
  175. MovementLoopAddLocation(NPC, -18.63, 3, 101.25, 1, 0)
  176. MovementLoopAddLocation(NPC, -17.31, 3, 99.16, 1, 10)
  177. MovementLoopAddLocation(NPC, -17.48, 3, 100.27, 1, 0)
  178. MovementLoopAddLocation(NPC, -14.73, 3, 104.05, Speed1, 0)
  179. MovementLoopAddLocation(NPC, -13.85, 3, 104.15, Speed1, 0)
  180. MovementLoopAddLocation(NPC, -4.4, 3, 100.16, Speed1, 0)
  181. MovementLoopAddLocation(NPC, -1.56, 3, 103.09, Speed2, 0)
  182. MovementLoopAddLocation(NPC, 0.56, 3, 107.36, Speed2, 0)
  183. MovementLoopAddLocation(NPC, 1.58, 3, 110.59, Speed1, 0)
  184. MovementLoopAddLocation(NPC, -3.78, 3, 114.94, Speed2, 0)
  185. MovementLoopAddLocation(NPC, -3.78, 3, 114.94, Speed2, 6)
  186. end
  187. function Rat_1(NPC,Spawn)
  188. local zone = GetZone(NPC)
  189. local Rat1 = GetSpawnByLocationID(zone,420316)
  190. if Rat1 == nil or not IsAlive(Rat1) then
  191. SpawnByLocationID(zone,420316)
  192. end
  193. SetTempVariable(NPC,"HissTimer", "1")
  194. end
  195. function Rat_1_Run(NPC,Spawn)
  196. local zone = GetZone(NPC)
  197. local Rat1 = GetSpawnByLocationID(zone,420316)
  198. if Rat1 ~= nil then
  199. waypoints2(Rat1)
  200. end
  201. end
  202. function Rat_1_Target(NPC)
  203. local zone = GetZone(NPC)
  204. local Rat1 = GetSpawnByLocationID(zone,420316)
  205. if Rat1 ~= nil then
  206. SetTarget(NPC,Rat1)
  207. FaceTarget(NPC,Rat1)
  208. PlayFlavor(NPC,"","","attack",0,0)
  209. end
  210. end
  211. function Rat_1_Attack(NPC)
  212. local zone = GetZone(NPC)
  213. local Rat1 = GetSpawnByLocationID(zone,420316)
  214. if Rat1 ~= nil then
  215. PlayFlavor(Rat1,"","","attack",0,0)
  216. end
  217. end
  218. function Rat1_Kill(NPC)
  219. local zone = GetZone(NPC)
  220. local Rat1 = GetSpawnByLocationID(zone,420316)
  221. if Rat1 ~= nil then
  222. PlayFlavor(NPC,"","","attack",0,0)
  223. KillSpawn(Rat1)
  224. SetTempVariable(NPC,"HissTimer", "0")
  225. end
  226. end
  227. function waypoints2(NPC)
  228. if GetSpawnLocationID(NPC) ==420316 then
  229. local zone = GetZone(NPC)
  230. local Rat1 = GetSpawnByLocationID(zone,420316)
  231. MovementLoopAddLocation(Rat1, -22.81, 3, 83.91, 6, 0)
  232. MovementLoopAddLocation(Rat1, -12.18, 3, 79.22, 6, 0)
  233. MovementLoopAddLocation(Rat1, -6.65, 3, 89.24, 6, 0)
  234. MovementLoopAddLocation(Rat1, -4.77, 3, 99.87, 6, 0)
  235. MovementLoopAddLocation(Rat1, -12.57, 3, 104.86, 6, 0)
  236. MovementLoopAddLocation(Rat1, -17.18, 2.97, 105.37, 6, 0)
  237. MovementLoopAddLocation(Rat1, -32.7, 3, 112.34, 6, 0)
  238. MovementLoopAddLocation(Rat1, -35.23, 2.84, 114.18, 6, 0)
  239. MovementLoopAddLocation(Rat1, -60.02, 2.84, 128.2, 6, 0)
  240. MovementLoopAddLocation(Rat1, -47.68, 2.84, 120.5, 6, 0)
  241. MovementLoopAddLocation(Rat1, -39.01, 2.83, 116.71, 6, 0)
  242. MovementLoopAddLocation(Rat1, -34.13, 2.84, 121.18, 6, 0)
  243. MovementLoopAddLocation(Rat1, -36.74, 2.83, 119.12, 6, 0)
  244. MovementLoopAddLocation(Rat1, -44.02, 2.83, 105.2, 6, 0)
  245. MovementLoopAddLocation(Rat1, -44.02, 2.83, 105.2, 6, 1)
  246. MovementLoopAddLocation(Rat1, -44.02, 2.83, 105.2, 6, 1)
  247. MovementLoopAddLocation(Rat1, -44.02, 2.83, 105.2, 6, 12)
  248. MovementLoopAddLocation(Rat1, -39.18, 2.81, 112.46, 1, 0)
  249. end
  250. end