MrButtons.lua 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. --[[
  2. Script Name : SpawnScripts/TempleSt/MrButtons.lua
  3. Script Author : Dorbin
  4. Script Date : 2023.10.24 07:10:04
  5. Script Purpose :
  6. :
  7. --]]
  8. require "SpawnScripts/Generic/CombatModule"
  9. function spawn(NPC)
  10. AddTimer(NPC,MakeRandomInt(3000,6000),"ChefCheck")
  11. AddTimer(NPC,MakeRandomInt(3000,6000),"PocketCheck")
  12. AddTimer(NPC,MakeRandomInt(1000,4000),"waypoints")
  13. SetTempVariable(NPC,"PocketFollow", nil)
  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. end
  51. function HissReset(NPC,Spawn)
  52. SetTempVariable(NPC,"HissTimer", "0")
  53. end
  54. function ChefCheck(NPC,Spawn)
  55. if IsAlive(NPC) then
  56. AddTimer(NPC,MakeRandomInt(4000,7000),"ChefCheck")
  57. local zone = GetZone(NPC)
  58. local Chef = GetSpawnByLocationID(zone,420550)
  59. if not IsInCombat(NPC) and Chef~= nil and not IsInCombat(Chef)then
  60. local Distance = GetDistance(NPC,Chef,1)
  61. if Distance <=4 then
  62. if GetTempVariable(NPC,"Speed_Set")~= nil then
  63. Reset(NPC,Spawn)
  64. end
  65. Attack(Chef,NPC)
  66. Attack(NPC,Chef)
  67. local x = GetX(Chef)
  68. local y = GetY(Chef)
  69. local z = GetZ(Chef)
  70. SetFollowTarget(Chef,NPC)
  71. SetFollowTarget(NPC,Chef)
  72. ToggleFollow(Chef)
  73. ToggleFollow(NPC)
  74. SetTarget(Chef,NPC)
  75. FaceTarget(Chef,NPC)
  76. FaceTarget(NPC,Chef)
  77. PlayFlavor(NPC,"","","attack",0,0)
  78. AddTimer(NPC,MakeRandomInt(2500,4500),"kill",1,Spawn)
  79. end
  80. end
  81. end
  82. end
  83. function PocketCheck(NPC,Spawn)
  84. if IsAlive(NPC) then
  85. AddTimer(NPC,MakeRandomInt(4000,7000),"PocketCheck")
  86. if not IsInCombat(NPC) then
  87. local zone = GetZone(NPC)
  88. local Pocket = GetSpawnByLocationID(zone,420615)
  89. local Distance = GetDistance(NPC,Pocket,1)
  90. if Pocket ~= nil and IsAlive(Pocket) and Distance <=5 then
  91. SetTarget(Pocket,NPC)
  92. FaceTarget(Pocket,NPC)
  93. PlayFlavor(Pocket,"","","attack",0,0)
  94. AddTimer(NPC,2300,"AttackBack",1,Spawn)
  95. AddTimer(NPC,4000,"ResetFollow",1,Spawn)
  96. end
  97. end
  98. end
  99. end
  100. function AttackBack(NPC,Spawn)
  101. local zone = GetZone(NPC)
  102. local Pocket = GetSpawnByLocationID(zone,420615)
  103. SetTarget(NPC,Pocket)
  104. FaceTarget(NPC,Pocket)
  105. PlayFlavor(NPC,"","","attack",0,0)
  106. end
  107. function ResetFollow(NPC,Spawn)
  108. local zone = GetZone(NPC)
  109. local Pocket = GetSpawnByLocationID(zone,420615)
  110. SetTarget(Pocket,nil)
  111. SetTarget(NPC,nil)
  112. end
  113. function kill (NPC,Spawn)
  114. ApplySpellVisual(NPC,51)
  115. local zone = GetZone(NPC)
  116. local Chef = GetSpawnByLocationID(zone,420550)
  117. PlayFlavor(Chef,"","","1h_sword_attack",0,0)
  118. KillSpawn(NPC)
  119. AddTimer(Chef,2500,"scoop")
  120. AddTimer(NPC,3000,"Despawning")
  121. end
  122. function Despawning(NPC,Spawn)
  123. Despawn(NPC)
  124. end
  125. function scoop(NPC,Spawn)
  126. local zone = GetZone(NPC)
  127. local Chef = GetSpawnByLocationID(zone,420550)
  128. PlayFlavor(Chef,"","","gathering_success",0,0)
  129. Despawn(NPC)
  130. end
  131. function respawn(NPC)
  132. spawn(NPC)
  133. end
  134. function waypoints(NPC)
  135. local choice = MakeRandomInt(1,2)
  136. if choice == 1 then
  137. SetTempVariable(NPC,"Speed1_Set", "1")
  138. SetTempVariable(NPC,"Speed2_Set", "4")
  139. else
  140. SetTempVariable(NPC,"Speed1_Set", "4")
  141. SetTempVariable(NPC,"Speed2_Set", "1")
  142. end
  143. local Speed1 = GetTempVariable(NPC,"Speed1_Set")
  144. local Speed2 = GetTempVariable(NPC,"Speed2_Set")
  145. MovementLoopAddLocation(NPC, -40.34, 2.85, 109.71, Speed1, MakeRandomInt(10,20))
  146. MovementLoopAddLocation(NPC, -40.34, 2.85, 109.71, Speed1, 0)
  147. MovementLoopAddLocation(NPC, -39.29, 2.83, 111.9, Speed1, 0)
  148. MovementLoopAddLocation(NPC, -35.56, 2.86, 112.69, Speed1, 0)
  149. MovementLoopAddLocation(NPC, -32.78, 3, 111.84, Speed1, 0)
  150. MovementLoopAddLocation(NPC, -24.57, 2.95, 103.39, Speed2, MakeRandomInt(10,20))
  151. MovementLoopAddLocation(NPC, -14.75, 3, 105.05, Speed2, 0)
  152. MovementLoopAddLocation(NPC, -6.7, 3, 101.13, Speed2, 0)
  153. MovementLoopAddLocation(NPC, -5.31, 3, 99.57, Speed2, 0)
  154. MovementLoopAddLocation(NPC, -5.88, 3, 95.16, Speed2, 0)
  155. MovementLoopAddLocation(NPC, -6.67, 3, 91.92, Speed1, 0)
  156. MovementLoopAddLocation(NPC, -2.53, 3, 86.87, Speed1, MakeRandomInt(10,20))
  157. MovementLoopAddLocation(NPC, 6.97, 3, 85.46, Speed2, 0)
  158. MovementLoopAddLocation(NPC, 12.42, 3, 82.94, Speed2, 0)
  159. MovementLoopAddLocation(NPC, 13.67, 3, 82.38, Speed1, 0)
  160. MovementLoopAddLocation(NPC, 18.89, 3, 82.26, Speed1, 0)
  161. MovementLoopAddLocation(NPC, 20.96, 3.01, 85.75, Speed1, 0)
  162. MovementLoopAddLocation(NPC, 22.52, 3, 93.18, Speed2, 0)
  163. MovementLoopAddLocation(NPC, 28.35, 3, 98.92, Speed2, 0)
  164. MovementLoopAddLocation(NPC, 33.44, 3, 107.7, Speed1, 0)
  165. MovementLoopAddLocation(NPC, 35.22, 3, 108.91, Speed1, 0)
  166. MovementLoopAddLocation(NPC, 42.42, 3, 104.99, Speed2, MakeRandomInt(10,20))
  167. MovementLoopAddLocation(NPC, 45.43, 3, 106.06, Speed1, 0)
  168. MovementLoopAddLocation(NPC, 47.23, 3, 104.46, Speed1, 0)
  169. MovementLoopAddLocation(NPC, 52.91, 3, 97.03, Speed2, 0)
  170. MovementLoopAddLocation(NPC, 51.36, 3, 93.29, Speed2, 0)
  171. MovementLoopAddLocation(NPC, 47.05, 3, 91.65, Speed2, 0)
  172. MovementLoopAddLocation(NPC, 45.07, 3, 87.42, Speed1, 0)
  173. MovementLoopAddLocation(NPC, 45.77, 3, 84.02, Speed2, 0)
  174. MovementLoopAddLocation(NPC, 43.63, 3, 79.92, Speed1, 0)
  175. MovementLoopAddLocation(NPC, 42.39, 3, 76.24, Speed1, 0)
  176. MovementLoopAddLocation(NPC, 43.08, 3, 73.6, Speed1, 0)
  177. MovementLoopAddLocation(NPC, 46.37, 3, 70.84, Speed1, 0)
  178. MovementLoopAddLocation(NPC, 51.05, 3, 67.69, Speed2, 0)
  179. MovementLoopAddLocation(NPC, 52.91, 3, 66.66, Speed1, 0)
  180. MovementLoopAddLocation(NPC, 51.32, 3, 61.04, Speed1, 0)
  181. MovementLoopAddLocation(NPC, 49.44, 3, 53.32, Speed2, MakeRandomInt(10,20))
  182. MovementLoopAddLocation(NPC, 49.22, 3, 54.19, Speed2, 0)
  183. MovementLoopAddLocation(NPC, 46.34, 3, 54.15, Speed2, 0)
  184. MovementLoopAddLocation(NPC, 44.25, 3, 51.21, Speed1, 0)
  185. MovementLoopAddLocation(NPC, 43.59, 3, 50.29, Speed1, 0)
  186. MovementLoopAddLocation(NPC, 37.61, 3, 50.02, Speed2, 0)
  187. MovementLoopAddLocation(NPC, 35.14, 3, 48.26, Speed2, 0)
  188. MovementLoopAddLocation(NPC, 29.54, 2.92, 40.43, Speed1, 0)
  189. MovementLoopAddLocation(NPC, 20.89, 2.92, 37.17, Speed1, 0)
  190. MovementLoopAddLocation(NPC, 20.86, 2.92, 33.7, Speed2, 0)
  191. MovementLoopAddLocation(NPC, 22.07, 2.92, 31.26, Speed1, 0)
  192. MovementLoopAddLocation(NPC, 25.56, 2.92, 18.56, Speed2, MakeRandomInt(10,20))
  193. MovementLoopAddLocation(NPC, 25.65, 2.92, 28.88, Speed2, 0)
  194. MovementLoopAddLocation(NPC, 28.68, 2.92, 36.04, Speed2, 0)
  195. MovementLoopAddLocation(NPC, 32.98, 2.96, 45.45, Speed2, 0)
  196. MovementLoopAddLocation(NPC, 35.64, 3, 50.86, Speed1, 0)
  197. MovementLoopAddLocation(NPC, 31.76, 3, 57.23, Speed1, 0)
  198. MovementLoopAddLocation(NPC, 29.22, 3, 60.28, Speed1, 0)
  199. MovementLoopAddLocation(NPC, 32.33, 3, 70.17, Speed1, 0)
  200. MovementLoopAddLocation(NPC, 34.91, 3, 76.39, Speed2, 0)
  201. MovementLoopAddLocation(NPC, 35.88, 3, 81.96, Speed2, 0)
  202. MovementLoopAddLocation(NPC, 33.94, 3, 83.37, Speed2, MakeRandomInt(10,20))
  203. MovementLoopAddLocation(NPC, 32, 3, 82.55, Speed1, 0)
  204. MovementLoopAddLocation(NPC, 25.46, 3, 78.68, Speed1, 0)
  205. MovementLoopAddLocation(NPC, 10.6, 3, 68.32, Speed1, 0)
  206. MovementLoopAddLocation(NPC, 4.46, 3, 66.63, Speed1, 0)
  207. MovementLoopAddLocation(NPC, 0.33, 3, 63.68, Speed2, 0)
  208. MovementLoopAddLocation(NPC, -2.91, 3, 57.43, Speed2, 0)
  209. MovementLoopAddLocation(NPC, 1.2, 3, 57.36, Speed2, MakeRandomInt(10,20))
  210. MovementLoopAddLocation(NPC, 1.1, 3, 63.22, Speed1, 0)
  211. MovementLoopAddLocation(NPC, 1.68, 3, 64.72, Speed1, 0)
  212. MovementLoopAddLocation(NPC, 11.43, 3, 68.74, Speed2, 0)
  213. MovementLoopAddLocation(NPC, 15.45, 3, 78.29, Speed1, 0)
  214. MovementLoopAddLocation(NPC, 13.9, 3, 82.29, Speed2, 0)
  215. MovementLoopAddLocation(NPC, 6.56, 3, 86.1, Speed1, 0)
  216. MovementLoopAddLocation(NPC, 3.54, 3, 86.31, Speed1, 0)
  217. MovementLoopAddLocation(NPC, -6.38, 3, 92.01, Speed2, 0)
  218. MovementLoopAddLocation(NPC, -6.26, 3, 93.36, Speed1, 0)
  219. MovementLoopAddLocation(NPC, -4.45, 3, 99.69, Speed2, 0)
  220. MovementLoopAddLocation(NPC, 0.69, 3, 107.84, Speed1, 0)
  221. MovementLoopAddLocation(NPC, 3.3, 3, 109.38, Speed2, 0)
  222. MovementLoopAddLocation(NPC, 12.44, 3, 105.52, Speed2, MakeRandomInt(10,20))
  223. MovementLoopAddLocation(NPC, 6.9, 3, 109.4, Speed1, 0)
  224. MovementLoopAddLocation(NPC, 2.71, 3, 109.76, Speed1, 0)
  225. MovementLoopAddLocation(NPC, -1.77, 3, 105.77, Speed1, 0)
  226. MovementLoopAddLocation(NPC, -4.29, 3, 101.88, Speed2, 0)
  227. MovementLoopAddLocation(NPC, -12.07, 3, 104.58, Speed2, 0)
  228. MovementLoopAddLocation(NPC, -17.08, 2.95, 105.62, Speed1, 0)
  229. MovementLoopAddLocation(NPC, -34.72, 2.81, 113.72, Speed1, 0)
  230. MovementLoopAddLocation(NPC, -35.34, 2.84, 116.06, Speed2, 0)
  231. MovementLoopAddLocation(NPC, -62.29, 2.85, 130.63, Speed2, MakeRandomInt(10,20))
  232. MovementLoopAddLocation(NPC, -55.3, 2.83, 124.78, Speed1, 0)
  233. MovementLoopAddLocation(NPC, -42.09, 2.84, 119.14, Speed1, 0)
  234. MovementLoopAddLocation(NPC, -41.07, 2.83, 106.76, Speed1, MakeRandomInt(10,20))
  235. end