Methos.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. --[[
  2. Script Name : SpawnScripts/TempleSt/Methos.lua
  3. Script Author : Dorbin
  4. Script Date : 2023.10.23 08:10:25
  5. Script Purpose :
  6. :
  7. --]]
  8. require "SpawnScripts/Generic/CombatModule"
  9. function spawn(NPC)
  10. AddTimer(NPC,MakeRandomInt(3000,6000),"ChefCheck")
  11. waypoints(NPC)
  12. SetPlayerProximityFunction(NPC, 7, "InRange", "LeaveRange")
  13. SetTempVariable(NPC,"HissTimer", "0")
  14. end
  15. function InRange(NPC,Spawn)
  16. if not IsInCombat(NPC) and GetTempVariable(NPC,"HissTimer")~="1" then
  17. local Choice = MakeRandomInt(0,100)
  18. if GetRace(Spawn)== 13 then
  19. if Choice <=75 then
  20. InRange_Attack(NPC,Spawn)
  21. end
  22. elseif Choice <= 40 then
  23. InRange_Attack(NPC,Spawn)
  24. end
  25. end
  26. end
  27. function InRange_Attack(NPC,Spawn)
  28. local Choice = MakeRandomInt(1,2)
  29. if Choice == 1 then
  30. FaceTarget(NPC,Spawn)
  31. AddTimer(NPC,1000,"HissAttack",1,Spawn)
  32. elseif Choice == 2 then
  33. AddTimer(NPC,500,"Hiss",1,Spawn)
  34. end
  35. SetTempVariable(NPC,"HissTimer", "1")
  36. AddTimer(NPC,25000,"HissReset",1,Spawn)
  37. end
  38. function HissAttack(NPC,Spawn)
  39. PlayFlavor(NPC,"","","attack",0,0)
  40. end
  41. function Hiss(NPC,Spawn)
  42. local Choice = MakeRandomInt(1,2)
  43. if Choice == 1 then
  44. PlaySound(NPC,"sounds/critters/cat/cat_hiss001.wav",GetX(NPC), GetY(NPC), GetZ(NPC))
  45. else
  46. PlaySound(NPC,"sounds/critters/cat/cat_hiss002.wav",GetX(NPC), GetY(NPC), GetZ(NPC))
  47. end
  48. end
  49. function HissReset(NPC,Spawn)
  50. SetTempVariable(NPC,"HissTimer", "0")
  51. end
  52. function ChefCheck(NPC,Spawn)
  53. if IsAlive(NPC) then
  54. AddTimer(NPC,MakeRandomInt(4000,7000),"ChefCheck")
  55. local zone = GetZone(NPC)
  56. local Chef = GetSpawnByLocationID(zone,420550)
  57. if not IsInCombat(NPC) and Chef~= nil and not IsInCombat(Chef)then
  58. local Distance = GetDistance(NPC,Chef,1)
  59. if Distance <=4 then
  60. Attack(Chef,NPC)
  61. Attack(NPC,Chef)
  62. local x = GetX(Chef)
  63. local y = GetY(Chef)
  64. local z = GetZ(Chef)
  65. SetFollowTarget(Chef,NPC)
  66. SetFollowTarget(NPC,Chef)
  67. ToggleFollow(Chef)
  68. ToggleFollow(NPC)
  69. SetTarget(Chef,NPC)
  70. FaceTarget(Chef,NPC)
  71. FaceTarget(NPC,Chef)
  72. PlayFlavor(NPC,"","","attack",0,0)
  73. AddTimer(NPC,MakeRandomInt(2500,4500),"kill",1,Spawn)
  74. end
  75. end
  76. end
  77. end
  78. function kill (NPC,Spawn)
  79. ApplySpellVisual(NPC,51)
  80. local zone = GetZone(NPC)
  81. local Chef = GetSpawnByLocationID(zone,420550)
  82. PlayFlavor(Chef,"","","1h_sword_attack",0,0)
  83. KillSpawn(NPC)
  84. AddTimer(Chef,2500,"scoop")
  85. AddTimer(NPC,3000,"Despawning")
  86. end
  87. function Despawning(NPC,Spawn)
  88. Despawn(NPC)
  89. end
  90. function scoop(NPC,Spawn)
  91. local zone = GetZone(NPC)
  92. local Chef = GetSpawnByLocationID(zone,420550)
  93. PlayFlavor(Chef,"","","gathering_success",0,0)
  94. Despawn(NPC)
  95. end
  96. function respawn(NPC)
  97. spawn(NPC)
  98. end
  99. function Rat_1(NPC,Spawn)
  100. local zone = GetZone(NPC)
  101. local Rat1 = GetSpawnByLocationID(zone,420362)
  102. SetTempVariable(NPC,"HissTimer", "1")
  103. if Rat1 == nil or not IsAlive(Rat1) then
  104. SpawnByLocationID(zone,420362)
  105. end
  106. SetTempVariable(NPC,"HissTimer", "1")
  107. end
  108. function Rat_1_Run(NPC,Spawn)
  109. local zone = GetZone(NPC)
  110. local Rat1 = GetSpawnByLocationID(zone,420362)
  111. if Rat1 ~= nil then
  112. waypoints2(Rat1)
  113. end
  114. end
  115. function Rat_2(NPC,Spawn)
  116. local zone = GetZone(NPC)
  117. local Rat1 = GetSpawnByLocationID(zone,420349)
  118. if Rat1 == nil or not IsAlive(Rat1) then
  119. SpawnByLocationID(zone,420349)
  120. end
  121. SetTempVariable(NPC,"HissTimer", "1")
  122. end
  123. function Rat_2_Run(NPC,Spawn)
  124. local zone = GetZone(NPC)
  125. local Rat1 = GetSpawnByLocationID(zone,420349)
  126. if Rat1 ~= nil then
  127. waypoints2(Rat1)
  128. end
  129. end
  130. function waypoints(NPC)
  131. MovementLoopAddLocation(NPC, 20.33, 2.97, 66.86, 1, 10,"Rat_1")
  132. MovementLoopAddLocation(NPC, 25.7, 3, 60.61, 1, 1,"Rat_1_Attack")
  133. MovementLoopAddLocation(NPC, 25.7, 3, 60.61, 1, 1,"Rat_1_Target")
  134. MovementLoopAddLocation(NPC, 25.7, 3, 60.61, 1, 1,"Rat_1_Run")
  135. MovementLoopAddLocation(NPC, 33.51, 3, 54.06, 6, 0)
  136. MovementLoopAddLocation(NPC, 43.49, 3, 50.18, 6, 0)
  137. MovementLoopAddLocation(NPC, 49.45, 3, 59.19, 6, 0)
  138. MovementLoopAddLocation(NPC, 54.14, 3, 65.87, 6, 0)
  139. MovementLoopAddLocation(NPC, 54.13, 3, 67.46, 2, 2,"ResetTarget")
  140. MovementLoopAddLocation(NPC, 55.9, 3, 70.62, 1, 10,"HissReset")
  141. MovementLoopAddLocation(NPC, 54.97, 3, 68.39, 1, 0)
  142. MovementLoopAddLocation(NPC, 50.84, 3, 69.56, 1, 0)
  143. MovementLoopAddLocation(NPC, 30.72, 3, 80.32, 1, 0)
  144. MovementLoopAddLocation(NPC, 17.47, 3, 83.09, 1, 0)
  145. MovementLoopAddLocation(NPC, 5.62, 3, 85.79, 1, 0)
  146. MovementLoopAddLocation(NPC, -8.84, 3, 90.24, 1, 10)
  147. MovementLoopAddLocation(NPC, -4.75, 3, 97.83, 1, 0)
  148. MovementLoopAddLocation(NPC, -8.6, 3, 103.47, 1, 0)
  149. MovementLoopAddLocation(NPC, -13.18, 3, 105.48, 1, 0)
  150. MovementLoopAddLocation(NPC, -16.99, 2.95, 105.93, 1, 0)
  151. MovementLoopAddLocation(NPC, -23.67, 2.86, 109.81, 1, 10)
  152. MovementLoopAddLocation(NPC, -32.72, 3, 112.67, 1, 0)
  153. MovementLoopAddLocation(NPC, -38.92, 2.82, 118.37, 1, 0)
  154. MovementLoopAddLocation(NPC, -46.56, 2.85, 122.92, 1, 10)
  155. MovementLoopAddLocation(NPC, -46.05, 2.83, 123.62, 1, 0)
  156. MovementLoopAddLocation(NPC, -45.97, 2.84, 121.85, 1, 0)
  157. MovementLoopAddLocation(NPC, -43.41, 2.83, 116.29, 1, 0)
  158. MovementLoopAddLocation(NPC, -33.61, 3.05, 112.1, 1, 0)
  159. MovementLoopAddLocation(NPC, -20, 2.93, 101.64, 1, 0)
  160. MovementLoopAddLocation(NPC, -14.33, 3, 103.85, 1, 0)
  161. MovementLoopAddLocation(NPC, -9.9, 3, 102.08, 1, 0)
  162. MovementLoopAddLocation(NPC, -1.38, 3, 101.98, 1, 10)
  163. MovementLoopAddLocation(NPC, -4.73, 3, 100.74, 1, 0)
  164. MovementLoopAddLocation(NPC, -7.38, 3, 90.48, 1, 0)
  165. MovementLoopAddLocation(NPC, -11.83, 3, 80.74, 1, 0)
  166. MovementLoopAddLocation(NPC, -7.38, 3, 74.43, 1, 10)
  167. MovementLoopAddLocation(NPC, -4.46, 3, 75.04, 1, 0)
  168. MovementLoopAddLocation(NPC, 7.12, 3.00, 70.82, 1, 0)
  169. MovementLoopAddLocation(NPC, 21.02, 2.92, 68.72, 1, 0)
  170. MovementLoopAddLocation(NPC, 37.33, 3, 50.02, 1, 0)
  171. MovementLoopAddLocation(NPC, 48.79, 3, 47.82, 1, 10)
  172. MovementLoopAddLocation(NPC, 46.46, 3, 49.22, 1, 0)
  173. MovementLoopAddLocation(NPC, 49.76, 3, 60.07, 1, 0)
  174. MovementLoopAddLocation(NPC, 52.88, 3, 65.32, 1, 0)
  175. MovementLoopAddLocation(NPC, 53.27, 3, 68.01, 1, 0)
  176. MovementLoopAddLocation(NPC, 47.97, 3, 72.59, 1, 0)
  177. MovementLoopAddLocation(NPC, 30.27, 3, 80.25, 1, 1,"Rat_2")
  178. MovementLoopAddLocation(NPC, 29.25, 3, 79.81, 1, 1)--Rat2
  179. MovementLoopAddLocation(NPC, 29.25, 3, 79.81, 1, 3,"Rat_2_Target")--Rat2
  180. MovementLoopAddLocation(NPC, 29.25, 3, 79.81, 1, 3,"Rat_2_Attack")--Rat2
  181. MovementLoopAddLocation(NPC, 29.25, 3, 79.81, 1, 1,"Rat_2_Run")--Rat2
  182. MovementLoopAddLocation(NPC, 30.93, 3, 69.23, 6, 0)
  183. MovementLoopAddLocation(NPC, 28.76, 3, 61.79, 6, 0)
  184. MovementLoopAddLocation(NPC, 24.7, 3, 61.78, 6, 0)
  185. MovementLoopAddLocation(NPC, 21.63, 2.93, 66.95, 6, 0)
  186. MovementLoopAddLocation(NPC, 17.96, 3.01, 72.13, 6, 0)
  187. MovementLoopAddLocation(NPC, 5.76, 3, 67.83, 6, 0)
  188. MovementLoopAddLocation(NPC, -2.09, 3, 61.88, 6, 0)
  189. MovementLoopAddLocation(NPC, -1.3, 3, 57.67, 6, 0)
  190. MovementLoopAddLocation(NPC, -5.37, 3, 56.58, 6, 0)
  191. MovementLoopAddLocation(NPC, -6.35, 3, 58.17, 6, 0)
  192. MovementLoopAddLocation(NPC, -6.35, 3, 58.17, 6, 1)
  193. MovementLoopAddLocation(NPC, -6.35, 3, 58.17, 6, 12,"Rat2_Kill")
  194. MovementLoopAddLocation(NPC, 0.26, 3, 63.21, 1, 0,"ResetTarget")
  195. MovementLoopAddLocation(NPC, 2.94, 3, 66.56, 1, 0)
  196. MovementLoopAddLocation(NPC, 12.27, 3, 70.02, 1, 0)
  197. MovementLoopAddLocation(NPC, 20.24, 2.99, 69.4, 1, 0)
  198. end
  199. function Rat_1_Attack(NPC)
  200. local zone = GetZone(NPC)
  201. local Rat1 = GetSpawnByLocationID(zone,420362)
  202. if Rat1 ~= nil then
  203. PlayFlavor(Rat1,"","","attack",0,0)
  204. end
  205. end
  206. function Rat_1_Target(NPC)
  207. local zone = GetZone(NPC)
  208. local Rat1 = GetSpawnByLocationID(zone,420362)
  209. if Rat1 ~= nil then
  210. SetTarget(NPC,Rat1)
  211. FaceTarget(NPC,Rat1)
  212. PlayFlavor(NPC,"","","attack",0,0)
  213. end
  214. end
  215. function Rat_2_Attack(NPC)
  216. local zone = GetZone(NPC)
  217. local Rat2 = GetSpawnByLocationID(zone,420349)
  218. if Rat2 ~= nil then
  219. PlayFlavor(Rat2,"","","attack",0,0)
  220. end
  221. end
  222. function Rat_2_Target(NPC)
  223. local zone = GetZone(NPC)
  224. local Rat2 = GetSpawnByLocationID(zone,420349)
  225. if Rat2 ~= nil then
  226. SetTarget(NPC,Rat2)
  227. FaceTarget(NPC,Rat2)
  228. PlayFlavor(NPC,"","","attack",0,0)
  229. end
  230. end
  231. function Rat2_Kill(NPC)
  232. local zone = GetZone(NPC)
  233. local Rat2 = GetSpawnByLocationID(zone,420349)
  234. if Rat2 ~= nil then
  235. PlayFlavor(NPC,"","","attack",0,0)
  236. KillSpawn(Rat2)
  237. end
  238. SetTempVariable(NPC,"HissTimer", "0")
  239. end
  240. function ResetTarget(NPC)
  241. SetTarget(NPC,nil)
  242. end
  243. function waypoints2(NPC)
  244. if GetSpawnLocationID(NPC) ==420362 then
  245. local zone = GetZone(NPC)
  246. local Rat1 = GetSpawnByLocationID(zone,420362)
  247. MovementLoopAddLocation(Rat1, 31.95, 3, 55.2, 6, 0)
  248. MovementLoopAddLocation(Rat1, 39.86, 3, 50.85, 6, 0)
  249. MovementLoopAddLocation(Rat1, 44.76, 3, 52.29, 6, 0)
  250. MovementLoopAddLocation(Rat1, 50.85, 3, 60.83, 6, 0)
  251. MovementLoopAddLocation(Rat1, 54.89, 3, 64.29, 6, 0)
  252. MovementLoopAddLocation(Rat1, 63.8, 2.77, 67.88, 6, 0)
  253. MovementLoopAddLocation(Rat1, 70.13, 1.63, 70.44, 6, 0)
  254. MovementLoopAddLocation(Rat1, 72.76, 0.37, 74.76, 4, 0)
  255. MovementLoopAddLocation(Rat1, 75.94, -2.87, 84.52, 4, 0)
  256. MovementLoopAddLocation(Rat1, 81.62, -4.57, 92.12, 4, 0)
  257. MovementLoopAddLocation(Rat1, 81.83, -4.57, 101.89, 4, 0)
  258. MovementLoopAddLocation(Rat1, 76.4, -4.57, 109.38, 4, 0)
  259. MovementLoopAddLocation(Rat1, 74.74, -4.57, 119.51, 4, 0)
  260. MovementLoopAddLocation(Rat1, 79.26, -4.57, 129.48, 4, 0)
  261. MovementLoopAddLocation(Rat1, 81.52, -4.57, 129.65, 4, 0)
  262. MovementLoopAddLocation(Rat1, 80.34, -4.57, 127.54, 4, 30)
  263. MovementLoopAddLocation(Rat1, 76.3, -4.57, 119.97, 1, 0)
  264. MovementLoopAddLocation(Rat1, 75.12, -4.57, 112.32, 1, 0)
  265. MovementLoopAddLocation(Rat1, 75.38, -4.57, 108.35, 1, 10)
  266. MovementLoopAddLocation(Rat1, 79.18, -4.57, 103.91, 1, 0)
  267. MovementLoopAddLocation(Rat1, 80.15, -4.57, 100.38, 1, 0)
  268. MovementLoopAddLocation(Rat1, 77.45, -4.56, 94.18, 1, 0)
  269. MovementLoopAddLocation(Rat1, 73.76, -3.52, 87.56, 1, 0)
  270. MovementLoopAddLocation(Rat1, 73.33, -3.11, 86.74, 1, 5)
  271. MovementLoopAddLocation(Rat1, 71.66, -0.27, 77.96, 4, 0)
  272. MovementLoopAddLocation(Rat1, 71.52, 0.81, 73.98, 4, 0)
  273. MovementLoopAddLocation(Rat1, 70.47, 1.33, 72.3, 4, 0)
  274. MovementLoopAddLocation(Rat1, 64.81, 2.71, 69.86, 4, 0)
  275. MovementLoopAddLocation(Rat1, 63.46, 3, 61.49, 4, 10)
  276. MovementLoopAddLocation(Rat1, 59.5, 3, 60.81, 1, 0)
  277. MovementLoopAddLocation(Rat1, 53, 3, 66.82, 4, 0)
  278. MovementLoopAddLocation(Rat1, 47.39, 3, 72.82, 4, 0)
  279. MovementLoopAddLocation(Rat1, 38.52, 3, 76.35, 4, 0)
  280. MovementLoopAddLocation(Rat1, 34.5, 3, 68.86, 4, 0)
  281. MovementLoopAddLocation(Rat1, 36.18, 3, 64.02, 1, 0,"Despawning_1")
  282. MovementLoopAddLocation(Rat1, 36.18, 3, 64.02, 1, 8,"Despawning_1")
  283. elseif GetSpawnLocationID(NPC) ==420349 then
  284. local zone = GetZone(NPC)
  285. local Rat2 = GetSpawnByLocationID(zone,420349)
  286. MovementLoopAddLocation(Rat2, 30.93, 3, 69.23, 3, 1)
  287. MovementLoopAddLocation(Rat2, 28.76, 3, 61.79, 3, 0)
  288. MovementLoopAddLocation(Rat2, 24.7, 3, 61.78, 6, 0)
  289. MovementLoopAddLocation(Rat2, 21.63, 2.93, 66.95, 6, 0)
  290. MovementLoopAddLocation(Rat2, 17.96, 3.01, 72.13, 6, 0)
  291. MovementLoopAddLocation(Rat2, 5.76, 3, 67.83, 6, 0)
  292. MovementLoopAddLocation(Rat2, -2.09, 3, 61.88, 6, 0)
  293. MovementLoopAddLocation(Rat2, -1.3, 3, 57.67, 6, 0)
  294. MovementLoopAddLocation(Rat2, -5.37, 3, 56.58, 6, 0)
  295. MovementLoopAddLocation(Rat2, -6.35, 3, 58.17, 6, 0)
  296. MovementLoopAddLocation(Rat2, -6.35, 3, 58.17, 6, 10)
  297. MovementLoopAddLocation(Rat2, -0.77, 3.00, 57.48, 1, 0)
  298. MovementLoopAddLocation(Rat2, 4.15, 3.00, 52.91, 6, 999)
  299. end
  300. end
  301. function Despawning_1(NPC)
  302. -- local zone = GetZone(NPC)
  303. -- local Rat1 = GetSpawnByLocationID(zone,420362)
  304. -- if Rat1 ~= nil then
  305. -- Despawn(Rat1)
  306. Despawn(NPC)
  307. -- end
  308. end