GoblinSaboteurFirepit.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. --[[
  2. Script Name : SpawnScripts/IsleRefuge1/GoblinSaboteurFirepit.lua
  3. Script Author : Dorbin
  4. Script Date : 2022.09.21 04:09:42
  5. Script Purpose :
  6. :
  7. --]]
  8. local saboteur = 5748
  9. function spawn(NPC)
  10. SetPlayerProximityFunction(NPC, 10, "InRange", "LeaveRange")
  11. end
  12. function respawn(NPC)
  13. spawn(NPC)
  14. end
  15. function InRange(NPC,Spawn)
  16. if GetQuestStep(Spawn,saboteur)==1 then
  17. SetStepComplete(Spawn,saboteur,1)
  18. end
  19. if GetQuestStep(Spawn,saboteur)==1 or GetQuestStep(Spawn,saboteur)==2 then
  20. local zone = GetZone(NPC)
  21. if GetSpawnByGroupID(zone, 1051222) ==nil then
  22. SpawnGroupByID(zone,1051222)
  23. -- Gob1 = SpawnByLocationID(zone,133776460)
  24. -- Gob2 = SpawnByLocationID(zone,133776463)
  25. -- Gob3 = SpawnByLocationID(zone,133776464)
  26. -- Gob4 = SpawnByLocationID(zone,133776458)
  27. -- Gob5 = SpawnByLocationID(zone,133776459)
  28. AddTimer(NPC,500,"Grouping")
  29. AddTimer(NPC,4000,"FacePlayer",1,Spawn)
  30. AddTimer(NPC,8200,"AttackPlayer",1,Spawn)
  31. AddTimer(NPC,8200,"SpawnCheck",1,Spawn)
  32. end
  33. end
  34. end
  35. function Grouping(NPC,Spawn)
  36. local zone = GetZone(NPC)
  37. Gob1 = GetSpawnByLocationID(zone,133776460)
  38. Gob2 = GetSpawnByLocationID(zone,133776463)
  39. Gob3 = GetSpawnByLocationID(zone,133776464)
  40. Gob4 = GetSpawnByLocationID(zone,133776458)
  41. Gob5 = GetSpawnByLocationID(zone,133776459)
  42. AddSpawnToGroup(Gob1,1051222)
  43. AddSpawnToGroup(Gob2,1051222)
  44. AddSpawnToGroup(Gob3,"1051222")
  45. AddSpawnToGroup(Gob4,"1051222")
  46. AddSpawnToGroup(Gob5,"1051222")
  47. end
  48. function FacePlayer(NPC,Spawn)
  49. local Gob1 = GetSpawnByLocationID(zone,133776460)
  50. local Gob2 = GetSpawnByLocationID(zone,133776463)
  51. local Gob3 = GetSpawnByLocationID(zone,133776464)
  52. local Gob4 = GetSpawnByLocationID(zone,133776458)
  53. local Gob5 = GetSpawnByLocationID(zone,133776459)
  54. if not IsInCombat(Gob1) then
  55. FaceTarget(Gob1,Spawn)
  56. FaceTarget(Gob2,Spawn)
  57. FaceTarget(Gob3,Spawn)
  58. FaceTarget(Gob4,Spawn)
  59. FaceTarget(Gob5,Spawn)
  60. end
  61. end
  62. function AttackPlayer(NPC,Spawn)
  63. local zone = GetZone(NPC)
  64. local Gob1 = GetSpawnByLocationID(zone,133776460)
  65. local Gob2 = GetSpawnByLocationID(zone,133776463)
  66. local Gob3 = GetSpawnByLocationID(zone,133776464)
  67. local Gob4 = GetSpawnByLocationID(zone,133776458)
  68. local Gob5 = GetSpawnByLocationID(zone,133776459)
  69. Attack(Gob1,Spawn)
  70. Attack(Gob2,Spawn)
  71. Attack(Gob3,Spawn)
  72. Attack(Gob4,Spawn)
  73. Attack(Gob5,Spawn)
  74. end
  75. function SpawnCheck(NPC,Spawn)
  76. local zone = GetZone(NPC)
  77. local Gob1 = GetSpawnByLocationID(zone,133776460)
  78. local Gob2 = GetSpawnByLocationID(zone,133776463)
  79. local Gob3 = GetSpawnByLocationID(zone,133776464)
  80. local Gob4 = GetSpawnByLocationID(zone,133776458)
  81. local Gob5 = GetSpawnByLocationID(zone,133776459)
  82. local Campfire = GetSpawnByLocationID(zone,133776522)
  83. if Campfire~=nil and IsAlive(Gob1)==true or IsAlive(Gob2)==true or IsAlive(Gob3)==true or IsAlive(Gob4)==true or IsAlive(Gob5)==true then -- States goblins are alive and campfire is active
  84. AddTimer(NPC,8000,"SpawnCheck",1,Spawn) -- Repeats spawn check
  85. elseif Campfire~=nil then -- Campfire despawns if goblins depspawn from leashing, which disables the update. Campfire does not despawn if goblins die by player.
  86. if GetQuestStep(Spawn,saboteur)==2 then
  87. SetStepComplete(Spawn,saboteur,2)
  88. end
  89. end
  90. end