Scrably.lua 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. --[[
  2. Script Name : SpawnScripts/Nettleville/Scrably.lua
  3. Script Author : Dorbin
  4. Script Date : 2022.06.20 01:06:39
  5. Script Purpose :
  6. :
  7. --]]
  8. local AttackTimer = false
  9. function spawn(NPC)
  10. waypoints(NPC)
  11. SetPlayerProximityFunction(NPC,3, "InRange", "LeaveRange")
  12. end
  13. function hailed(NPC, Spawn)
  14. if AttackTimer == false then
  15. AttackTimer = true
  16. FaceTarget(NPC,Spawn)
  17. PlayFlavor(NPC, "", "", "attack", 0, 0)
  18. AddTimer(NPC,10000,"AttackTimerReset")
  19. end
  20. end
  21. function InRange(NPC,Spawn)
  22. if AttackTimer == false then
  23. if math.random(1,100) <=20 then
  24. AttackTimer = true
  25. FaceTarget(NPC,Spawn)
  26. PlayFlavor(NPC, "", "", "attack", 0, 0)
  27. AddTimer(NPC,25000,"AttackTimerReset")
  28. end
  29. end
  30. end
  31. function Sleep(NPC)
  32. local choice = math.random(1,2)
  33. if choice == 1 then
  34. SpawnSet(NPC, "action_state", 540)
  35. AddTimer(NPC, 22000, "Wake")
  36. AttackTimer = true
  37. elseif choice ==2 then
  38. end
  39. end
  40. function Wake(NPC)
  41. SpawnSet(NPC, "action_state", 0)
  42. AttackTimer = false
  43. end
  44. function AttackTimerReset(NPC,Spawn)
  45. AttackTimer = false
  46. end
  47. function respawn(NPC)
  48. spawn(NPC)
  49. end
  50. function waypoints(NPC)
  51. MovementLoopAddLocation(NPC, 655.97, -20.34, 275, 1, 2)
  52. MovementLoopAddLocation(NPC, 655.97, -20.34, 275, 1, 25,"Sleep")
  53. MovementLoopAddLocation(NPC, 659.88, -20.35, 280.41, 1, 0)
  54. MovementLoopAddLocation(NPC, 663, -20.12, 288.99, 1, 0)
  55. MovementLoopAddLocation(NPC, 661.02, -20.22, 291.91, 1, 2)
  56. MovementLoopAddLocation(NPC, 661.02, -20.22, 291.91, 1, 25,"Sleep")
  57. MovementLoopAddLocation(NPC, 661.06, -20.32, 294.6, 1, 0)
  58. MovementLoopAddLocation(NPC, 660.11, -20.43, 308.92, 1, 0)
  59. MovementLoopAddLocation(NPC, 662.44, -20.46, 315.29, 1, 0)
  60. MovementLoopAddLocation(NPC, 664.94, -20.44, 317.96, 1, 0)
  61. MovementLoopAddLocation(NPC, 668, -20.43, 318.55, 1, 0)
  62. MovementLoopAddLocation(NPC, 673.61, -20.43, 318.87, 1, 0)
  63. MovementLoopAddLocation(NPC, 677.71, -20.31, 318.36, 1, 0)
  64. MovementLoopAddLocation(NPC, 680.58, -20.26, 316.52, 1, 0)
  65. MovementLoopAddLocation(NPC, 679.22, -20.24, 311.99, 1, 1)
  66. MovementLoopAddLocation(NPC, 679.22, -20.24, 311.99, 1, 1)
  67. MovementLoopAddLocation(NPC, 679.22, -20.24, 311.99, 1, 2)
  68. MovementLoopAddLocation(NPC, 679.22, -20.24, 311.99, 1, 25,"Sleep")
  69. MovementLoopAddLocation(NPC, 676.74, -20.38, 309.91, 1, 0)
  70. MovementLoopAddLocation(NPC, 675.48, -20.25, 306.54, 1, 0)
  71. MovementLoopAddLocation(NPC, 675.83, -20.25, 301.27, 1, 0)
  72. MovementLoopAddLocation(NPC, 672.49, -19.93, 291.35, 1, 0)
  73. MovementLoopAddLocation(NPC, 659, -20.33, 281.43, 1, 0)
  74. MovementLoopAddLocation(NPC, 656.52, -20.34, 274.4, 1, 0)
  75. MovementLoopAddLocation(NPC, 652.63, -20.31, 273.86, 1, 0)
  76. MovementLoopAddLocation(NPC, 641.44, -20.17, 274.44, 1, 15)
  77. MovementLoopAddLocation(NPC, 630.81, -20.23, 277.46, 1, 0)
  78. MovementLoopAddLocation(NPC, 630.79, -20.34, 278.48, 6, 1)
  79. MovementLoopAddLocation(NPC, 630.79, -20.34, 278.48, 1, 1,"AttackRat")
  80. MovementLoopAddLocation(NPC, 630.79, -20.34, 278.48, 1, 1,"Rat")
  81. MovementLoopAddLocation(NPC, 630.79, -20.34, 278.48, 1, 1)
  82. MovementLoopAddLocation(NPC, 632.51, -20.37, 286.38, 6, 0)
  83. MovementLoopAddLocation(NPC, 634.08, -20.41, 291.28, 6, 0)
  84. MovementLoopAddLocation(NPC, 636.51, -20.67, 303.06, 6, 0)
  85. MovementLoopAddLocation(NPC, 625.45, -20.56, 309.72, 6, 0)
  86. MovementLoopAddLocation(NPC, 618.02, -20.49, 315.42, 6, 0)
  87. MovementLoopAddLocation(NPC, 606.96, -20.62, 331.81, 6, 0)
  88. MovementLoopAddLocation(NPC, 603.96, -20.81, 342.72, 6, 0)
  89. MovementLoopAddLocation(NPC, 602.86, -20.8, 344.14, 6, 0)
  90. MovementLoopAddLocation(NPC, 598.72, -20.54, 347.16, 6, 0)
  91. MovementLoopAddLocation(NPC, 589.45, -20.27, 345.05, 6, 0)
  92. MovementLoopAddLocation(NPC, 587.24, -20.26, 345.44, 6, 1)
  93. MovementLoopAddLocation(NPC, 587.24, -20.26, 345.44, 6, 2,"AttackRat")
  94. MovementLoopAddLocation(NPC, 587.24, -20.26, 345.44, 1, 2,"DespawnRat")
  95. MovementLoopAddLocation(NPC, 585.81, -20.2, 347.21, 1, 15)
  96. MovementLoopAddLocation(NPC, 587.01, -20.25, 346.04, 1, 0)
  97. MovementLoopAddLocation(NPC, 596.06, -20.27, 346.87, 1, 0)
  98. MovementLoopAddLocation(NPC, 601.8, -20.74, 347.22, 1, 0)
  99. MovementLoopAddLocation(NPC, 613.59, -20.64, 325.33, 1, 0)
  100. MovementLoopAddLocation(NPC, 625.27, -20.41, 313.72, 1, 0)
  101. MovementLoopAddLocation(NPC, 636.57, -20.67, 302.92, 1, 0)
  102. MovementLoopAddLocation(NPC, 661.58, -20.21, 291.62, 1, 2)
  103. MovementLoopAddLocation(NPC, 661.58, -20.21, 291.62, 1, 25,"Sleep")
  104. MovementLoopAddLocation(NPC, 664.54, -20.05, 291.26, 1, 0)
  105. MovementLoopAddLocation(NPC, 665.01, -20.03, 293.01, 1, 0)
  106. MovementLoopAddLocation(NPC, 675.26, -20.25, 305.05, 1, 0)
  107. MovementLoopAddLocation(NPC, 675.57, -20.35, 308.36, 1, 2)
  108. MovementLoopAddLocation(NPC, 675.57, -20.35, 308.36, 1, 25,"Sleep")
  109. MovementLoopAddLocation(NPC, 672.45, -20.41, 310.59, 1, 0)
  110. MovementLoopAddLocation(NPC, 671.2, -20.42, 311.45, 1, 0)
  111. MovementLoopAddLocation(NPC, 672.17, -20.42, 315.84, 1, 0)
  112. MovementLoopAddLocation(NPC, 673.42, -20.42, 316.4, 1, 0)
  113. MovementLoopAddLocation(NPC, 675.13, -20.42, 316.9, 1, 0)
  114. MovementLoopAddLocation(NPC, 678.75, -20.29, 319.64, 1, 2)
  115. MovementLoopAddLocation(NPC, 678.75, -20.29, 319.64, 1, 25)
  116. MovementLoopAddLocation(NPC, 678.86, -20.33, 321.02, 1, 0)
  117. MovementLoopAddLocation(NPC, 678.46, -20.38, 321.64, 1, 0)
  118. MovementLoopAddLocation(NPC, 677.44, -20.43, 321.54, 1, 0)
  119. MovementLoopAddLocation(NPC, 675.86, -20.41, 318.55, 1, 0)
  120. MovementLoopAddLocation(NPC, 676.56, -20.39, 309.96, 1, 2)
  121. MovementLoopAddLocation(NPC, 676.56, -20.39, 309.96, 1, 25,"Sleep")
  122. MovementLoopAddLocation(NPC, 675.6, -20.26, 306.59, 1, 0)
  123. MovementLoopAddLocation(NPC, 676.31, -20.25, 302.45, 1, 0)
  124. MovementLoopAddLocation(NPC, 672.31, -20.08, 296.39, 1, 0)
  125. MovementLoopAddLocation(NPC, 665.67, -20.12, 296.66, 1, 0)
  126. MovementLoopAddLocation(NPC, 652.03, -20.4, 300.45, 1, 0)
  127. MovementLoopAddLocation(NPC, 645.17, -20.25, 304.89, 1, 0)
  128. MovementLoopAddLocation(NPC, 642.51, -20.29, 306.4, 1, 15)
  129. MovementLoopAddLocation(NPC, 635.93, -20.48, 298.19, 1, 0)
  130. MovementLoopAddLocation(NPC, 633.21, -20.41, 291.29, 1, 0)
  131. MovementLoopAddLocation(NPC, 630.32, -20.41, 286.19, 1, 15)
  132. MovementLoopAddLocation(NPC, 631.48, -20.4, 280.11, 1, 0)
  133. MovementLoopAddLocation(NPC, 636.7, -20.29, 275.74, 1, 0)
  134. MovementLoopAddLocation(NPC, 646.95, -20.29, 275.27, 1, 0)
  135. MovementLoopAddLocation(NPC, 656.29, -20.02, 270.19, 1, 0)
  136. MovementLoopAddLocation(NPC, 657.25, -20.17, 270.53, 1, 15)
  137. end
  138. function AttackRat(NPC,Spawn)
  139. AttackTimer = true
  140. PlayFlavor(NPC,"","","attack",0,0)
  141. AddTimer(NPC,30000,"AttackTimerReset")
  142. end
  143. function Rat(NPC,Spawn)
  144. local rat = GetSpawn(NPC,2330139)
  145. if rat ~=nil then
  146. SetTarget(NPC,rat)
  147. PlayFlavor(rat,"","","attack",0,0)
  148. MovementLoopAddLocation(rat, 632.51, -20.37, 286.38, 6, 0)
  149. MovementLoopAddLocation(rat, 634.08, -20.41, 291.28, 6, 0)
  150. MovementLoopAddLocation(rat, 636.51, -20.67, 303.06, 6, 0)
  151. MovementLoopAddLocation(rat, 625.45, -20.56, 309.72, 6, 0)
  152. MovementLoopAddLocation(rat, 618.02, -20.49, 315.42, 6, 0)
  153. MovementLoopAddLocation(rat, 606.96, -20.62, 331.81, 6, 0)
  154. MovementLoopAddLocation(rat, 603.96, -20.81, 342.72, 6, 0)
  155. MovementLoopAddLocation(rat, 602.86, -20.8, 344.14, 6, 0)
  156. MovementLoopAddLocation(rat, 598.72, -20.54, 347.16, 6, 0)
  157. MovementLoopAddLocation(rat, 589.45, -20.27, 345.05, 6, 0)
  158. MovementLoopAddLocation(rat, 587.24, -20.26, 345.44, 6, 30)
  159. end
  160. end
  161. function DespawnRat(NPC,Spawn)
  162. local rat = GetSpawn(NPC,2330139)
  163. if rat ~=nil then
  164. KillSpawn(rat,NPC)
  165. end
  166. end