9
3

KingDrayek.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. --[[
  2. Script Name : SpawnScripts/DrayeksChamber/KingDrayek.lua
  3. Script Author : Neveruary
  4. Script Date : 2022.07.17 09:07:46
  5. Script Purpose : Governs behavior of King Drayek in Drayek's Chamber (non-quest)
  6. : Drayek has two unique abilities: Strike of the Giant King and Giant's Kick. Giant's Kick is a huge knockback.
  7. : Drayek begins the encounter by allowing the frozen sentinels and vigilants to attack first. He then sends his wolves after the players, and finally engages.
  8. : At set intervals, he calls adds (his royal guards twice, and then his 'kings of old') and then the encounter ends.
  9. : Spell collects are pending.
  10. --]]
  11. frozenadds = {351396, 351398, 351399, 351401, 351404, 351405}
  12. wolves = {351408, 351406}
  13. guards = {133774010, 133774011, 133774013, 133774014, 133774015, 133774016}
  14. kings = {351427, 351428, 351429, 351430}
  15. function spawn(NPC) -- Define variables
  16. SetPlayerProximityFunction(NPC, 8, "InRange", "LeaveRange")
  17. SetTempVariable(NPC, "encounterstart", "0")
  18. SetTempVariable(NPC, "addsphase", "0")
  19. SetTempVariable(NPC, "encounterphase", "0")
  20. end
  21. function InRange(NPC, Spawn) -- Starts encounter
  22. if GetTempVariable(NPC, "encounterstart") == "0" then
  23. Say(NPC, "I see my feeble guard has failed me. Perhaps they have underestimated the threat? I will not be making the same mistake.")
  24. SetTempVariable(NPC, "encounterstart", "1")
  25. AddTimer(NPC, 10000, "addsSpawn", 1, Spawn)
  26. end
  27. end
  28. function healthchanged(NPC, Spawn) -- At a specific health value, spawn a specific group of mobs.
  29. local eighty = GetMaxHP(NPC) * 0.8
  30. local fifty = GetMaxHP(NPC) * 0.5
  31. local twenty = GetMaxHP(NPC) * 0.2
  32. local current = GetHP(NPC)
  33. if current < twenty and GetTempVariable(NPC, "encounterphase") == "3" then
  34. SetTempVariable(NPC, "addsphase", "3")
  35. SetTempVariable(NPC, "encounterphase", "4")
  36. AddTimer(NPC, 3000, "addsSpawn")
  37. elseif current < fifty and GetTempVariable(NPC, "encounterphase") == "2" then
  38. SetTempVariable(NPC, "addsphase", "2")
  39. SetTempVariable(NPC, "encounterphase", "3")
  40. AddTimer(NPC, 3000, "addsSpawn")
  41. elseif current < eighty and GetTempVariable(NPC, "encounterphase") == "0" then
  42. SetTempVariable(NPC, "addsphase", "2")
  43. SetTempVariable(NPC, "encounterphase", "2")
  44. AddTimer(NPC, 3000, "addsSpawn")
  45. end
  46. end
  47. function wolfDeath(NPC, Spawn) -- Attack after wolves are dead
  48. Say(NPC, "Prepare yourselves! Now, I must deal with you... personally.")
  49. SpawnSet(NPC, "attackable", "1")
  50. Attack(NPC, Spawn)
  51. end
  52. function addsSpawn(NPC, Spawn) -- Change add phases below to spawn different mobs
  53. local zone = GetZone(NPC)
  54. if GetTempVariable(NPC, "addsphase") == "0" then
  55. for k,v in pairs(frozenadds) do
  56. local frozen = GetSpawnByLocationID(zone, v)
  57. SpawnSet(frozen, "attackable", "1")
  58. Attack(frozen, Spawn)
  59. end
  60. elseif GetTempVariable(NPC, "addsphase") == "1" then
  61. local hated = GetMostHated(NPC)
  62. Say(NPC, "Enough of this! You can have them now my pets!")
  63. for k,v in pairs(wolves) do
  64. local wolf = GetSpawnByLocationID(zone, v)
  65. SpawnSet(wolf, "attackable", "1")
  66. Attack(wolf, Spawn)
  67. end
  68. elseif GetTempVariable(NPC, "addsphase") == "2" then
  69. local hated = GetMostHated(NPC)
  70. if GetTempVariable(NPC, "encounterphase") == "0" then
  71. Say(NPC, "Such insolence! Guards, to me!")
  72. elseif GetTempVariable(NPC, "encounterphase") == "2" then
  73. Say(NPC, "As much fun as this was, I grow tired of you all... Guards!!!")
  74. end
  75. for k,v in pairs(guards) do
  76. local guard = SpawnByLocationID(zone, v)
  77. Attack(guard, hated)
  78. end
  79. elseif GetTempVariable(NPC, "addsphase") == "3" then
  80. local hated = GetMostHated(NPC)
  81. Say(NPC, "Kings of old, I call to you now! Aid your King!!!!")
  82. for k,v in pairs(kings) do
  83. local king = SpawnByLocationID(zone, v)
  84. Attack(king, hated)
  85. end
  86. end
  87. end
  88. function respawn(NPC)
  89. spawn(NPC)
  90. end