stoneharry

stoneharry

Mar 13th, 2011
856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.24 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------
  2. -- By Stoneharry
  3. -- Variable Decleration
  4. -------------------------------------------------------------------------------------------------
  5.  
  6. local DarrowID, TrishID, GarrashID, LachdananID = 280211, 280214, 280213, 280212
  7. local TrigAID, TrigBID, TrigCID, CrownID = 116860, 116861, 116862, 116863
  8. local TrigA, TrigB, TrigC, Crown = nil, nil, nil, nil
  9. local AddA, AddB, AddC, AddD = 179701, 179702, 179703, 179704
  10. local Trish, Garrash, Lachdanan = nil, nil, nil
  11.  
  12. local OBJECT_END = 0x0006
  13. local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044 -- Size: 1, Type: BYTES, Flags: PUBLIC
  14. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
  15. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26    33554432  cannot select the unit
  16.  
  17. -------------------------------------------------------------------------------------------------
  18.  
  19. function Evil_King_Darrow_OnSpawn(pUnit, Event)
  20.     pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 0)
  21.     pUnit:SetFaction(35)
  22.     pUnit:RegisterEvent("Check_For_Players_KingDarrow", 2000, 0)
  23. end
  24.  
  25. function Check_For_Players_KingDarrow(pUnit)
  26.     local plr = pUnit:GetClosestPlayer()
  27.     if plr ~= nil then
  28.         if pUnit:GetDistanceYards(plr) < 20 then
  29.             if Trish ~= nil and Garrash ~= nil and Lachdanan ~= nil then
  30.                 if Trish:IsAlive() and Garrash:IsAlive() and Lachdanan:IsAlive() then
  31.                     pUnit:RemoveEvents()
  32.                     pUnit:SendChatMessage(14,0,"You think you can kill me?! Knights defend me!")
  33.                     pUnit:RegisterEvent("Delay_Going_Underground_Timer_Darrow", 1500, 1)
  34.                     pUnit:RegisterEvent("Spawn_Npcs_One_at_A_Time_T", math.random(3000, 5000), 1)
  35.                     pUnit:RegisterEvent("Spawn_Npcs_One_at_A_Time_G", math.random(3000, 5000), 1)
  36.                     pUnit:RegisterEvent("Spawn_Npcs_One_at_A_Time_L", math.random(3000, 5000), 1)
  37.                     pUnit:RegisterEvent("All_Go_Hostile_And_Watch_The_Fireworks", 9000, 1)
  38.                     pUnit:RegisterEvent("Checkforalladdsdead_Knightsdefendme", 5000, 0)
  39.                 end
  40.             end
  41.         end
  42.     end
  43. end
  44.  
  45. function Delay_Going_Underground_Timer_Darrow(pUnit)
  46.     pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 9)
  47. end
  48.  
  49. function Spawn_Npcs_One_at_A_Time_T(pUnit)
  50.     pUnit:CastSpellAoF(Trish:GetX(), Trish:GetY(), Trish:GetZ(), 55719)
  51.     Trish:SetUInt32Value(UNIT_FIELD_BYTES_1, 0)
  52. end
  53.  
  54. function Spawn_Npcs_One_at_A_Time_G(pUnit)
  55.     pUnit:CastSpellAoF(Garrash:GetX(), Garrash:GetY(), Garrash:GetZ(), 55719)
  56.     Garrash:SetUInt32Value(UNIT_FIELD_BYTES_1, 0)
  57. end
  58.  
  59. function Spawn_Npcs_One_at_A_Time_L(pUnit)
  60.     pUnit:CastSpellAoF(Lachdanan:GetX(), Lachdanan:GetY(), Lachdanan:GetZ(), 55719)
  61.     Lachdanan:SetUInt32Value(UNIT_FIELD_BYTES_1, 0)
  62. end
  63.  
  64. RegisterUnitEvent(DarrowID, 18, "Evil_King_Darrow_OnSpawn")
  65.  
  66. function King_Evil_Death_Of_King(pUnit, Event)
  67.     TrigA:RemoveAura(72405)
  68.     pUnit:RemoveEvents()
  69.     pUnit:Unroot()
  70. end
  71.  
  72. RegisterUnitEvent(DarrowID, 4, "King_Evil_Death_Of_King")
  73.  
  74. function King_Evil_Leave_Of_King(pUnit, Event)
  75.     pUnit:RemoveEvents()
  76.     pUnit:Unroot()
  77. end
  78.  
  79. RegisterUnitEvent(DarrowID, 2, "King_Evil_Leave_Of_King")
  80.  
  81. function All_Go_Hostile_And_Watch_The_Fireworks(pUnit)
  82.     Trish:SetFaction(21)
  83.     Garrash:SetFaction(21)
  84.     Lachdanan:SetFaction(21)
  85. end
  86.  
  87. function Checkforalladdsdead_Knightsdefendme(pUnit)
  88.     if Trish ~= nil and Garrash ~= nil and Lachdanan ~= nil then
  89.         if Trish:IsAlive() == false and Garrash:IsAlive() == false and Lachdanan:IsAlive() == false then
  90.             pUnit:RemoveEvents()
  91.             pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 0)
  92.             pUnit:SendChatMessage(14,0,"You may have defeated my knights, but you shall never defeat me!")
  93.             pUnit:RegisterEvent("Go_Hostile_Darrow_Guy", 5000, 1)
  94.         end
  95.     end
  96. end
  97.  
  98. SetDBCSpellVar(17467, "c_is_flags", 0x01000)
  99.  
  100. function Go_Hostile_Darrow_Guy(pUnit)
  101.     pUnit:SetFaction(21)
  102.     pUnit:CastSpell(17467) -- Aura
  103.     pUnit:RegisterEvent("Phase_Two_Darrow_King", 2000, 0)
  104.     --pUnit:RegisterEvent("SpawnCreatures_ThatWillHelp", 20000, 0)
  105.     pUnit:RegisterEvent("Mean_Buff_King", 2000, 0)
  106. end
  107.  
  108. function Mean_Buff_King(pUnit)
  109.     local plr = pUnit:GetClosestPlayer()
  110.     if plr ~= nil then
  111.         pUnit:FullCastSpellOnTarget(48423, plr)
  112.     end
  113. end
  114.  
  115. function Phase_Two_Darrow_King(pUnit)
  116.     if pUnit:GetHealthPct() < 90 then
  117.         pUnit:SendChatMessage(14,0,"You will all burn!")
  118.         pUnit:RemoveEvents()
  119.         pUnit:Root()
  120.         pUnit:SetCombatCapable(1)
  121.         pUnit:CastSpell(54306) -- Protective bubble
  122.         pUnit:ChannelSpell(30742, TrigB)
  123.         TrigB:ChannelSpell(64367, TrigA)
  124.         TrigA:ChannelSpell(40447, TrigB)
  125.         pUnit:RegisterEvent("Spam_Explosions_On_People_Tehe_Darrow", 3000, 1)
  126.         pUnit:RegisterEvent("Wait_thirty_seconds_For_next_phase", 33000, 1)
  127.     end
  128. end
  129.  
  130. function Spam_Explosions_On_People_Tehe_Darrow(pUnit)
  131.     pUnit:RegisterEvent("Spam_Explosions_On_People_Tehe_Darrow", math.random(100, 1000), 1)
  132.     local plr = pUnit:GetRandomPlayer(0)
  133.     if plr ~= nil then
  134.         pUnit:SpawnCreature(TrigCID, plr:GetX()+math.random(0,3), plr:GetY()-math.random(0,3), plr:GetZ()+math.random(0,6), 0, 21, 0)
  135.     end
  136. end
  137.  
  138. function Spam_Explosions_On_People_Tehe_Darrow_B(pUnit)
  139.     pUnit:RegisterEvent("Spam_Explosions_On_People_Tehe_Darrow_B", math.random(500, 8000), 1)
  140.     local plr = pUnit:GetRandomPlayer(0)
  141.     if plr ~= nil then
  142.         pUnit:SpawnCreature(TrigCID, plr:GetX()+math.random(0,3), plr:GetY()-math.random(0,3), plr:GetZ()+math.random(0,6), 0, 21, 0)
  143.     end
  144. end
  145.  
  146. function TrigC_OnSpawnDoShizzle(pUnit, Event)
  147.     pUnit:RegisterEvent("boom_tehe_TrigCSpawned", math.random(500, 7000), 1)
  148.     pUnit:Root()
  149.     pUnit:SetCombatCapable(1)
  150.     pUnit:SetFlying()
  151.     pUnit:CastSpell(72262) -- Fun visual
  152.     --pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  153. end
  154.  
  155. function boom_tehe_TrigCSpawned(pUnit)
  156.     pUnit:CastSpell(9433) -- Damage
  157.     pUnit:CastSpell(48582) -- Visual
  158.     pUnit:Despawn(3000, 0)
  159. end
  160.  
  161. RegisterUnitEvent(TrigCID, 18, "TrigC_OnSpawnDoShizzle")
  162.  
  163. function Wait_thirty_seconds_For_next_phase(pUnit)
  164.     pUnit:RemoveEvents()
  165.     TrigA:StopChannel()
  166.     TrigB:StopChannel()
  167.     pUnit:StopChannel()
  168.     pUnit:Unroot()
  169.     pUnit:SetCombatCapable(0)
  170.     pUnit:RegisterEvent("SpawnCreatures_ThatWillHelp", 25000, 0)
  171.     pUnit:RegisterEvent("SHADOWBOLT_BOOM", 5000, 0)
  172.     pUnit:RegisterEvent("DeathAndDecay_Boss_king", math.random(12000,18000), 0)
  173.     pUnit:RegisterEvent("Knockback_Of_Doom_Phase", 2000, 0)
  174. end
  175.  
  176. function Knockback_Of_Doom_Phase(pUnit)
  177.     if pUnit:GetHealthPct() < 50 then
  178.         pUnit:SendChatMessage(14,0,"Enough! I grow tired of this.")
  179.         pUnit:Root()
  180.         pUnit:RemoveEvents()
  181.         for a, plrs in pairs(pUnit:GetInRangePlayers()) do
  182.             plrs:CastSpell(37968) -- Soaring
  183.         end
  184.         pUnit:RegisterEvent("Spam_Shadow_Bolts_Tehe", 500, 0)
  185.         pUnit:RegisterEvent("resetbacktonormal", 20000, 0)
  186.     end
  187. end
  188.  
  189. function Spam_Shadow_Bolts_Tehe(pUnit)
  190.     pUnit:FullCastSpell(17228)
  191. end
  192.  
  193. function resetbacktonormal(pUnit)
  194.     pUnit:RemoveEvents()
  195.     for a, plrs in pairs(pUnit:GetInRangePlayers()) do
  196.         plrs:Teleport(plrs:GetMapId(), pUnit:GetX(), pUnit:GetY(), pUnit:GetZ())
  197.         plrs:CastSpell(64446) -- Teleport visual
  198.     end
  199.     pUnit:FullCastSpell(51110)
  200.     pUnit:SendChatMessage(42,0,"King Darrow casts \124cff71d5ff\124Hspell:51110\124h[Empowered Arcane Explosion]\124h\124r!")
  201.     pUnit:RegisterEvent("Reset_this_time_I_mean_seriously", 9000, 1)
  202. end
  203.  
  204. function Reset_this_time_I_mean_seriously(pUnit)
  205.     pUnit:RemoveEvents()
  206.     pUnit:SendChatMessage(14,0,"I am invincible!")
  207.     local pla = pUnit:GetRandomPlayer(0)
  208.     if pla ~= nil then
  209.         pUnit:FullCastSpellOnTarget(41272, pla) -- Charge
  210.     end
  211.     pUnit:Unroot()
  212.     pUnit:RegisterEvent("SpawnCreatures_ThatWillHelp", 25000, 0)
  213.     pUnit:RegisterEvent("SHADOWBOLT_BOOM", 5000, 0)
  214.     pUnit:RegisterEvent("DeathAndDecay_Boss_king", math.random(12000,18000), 0)
  215.     pUnit:RegisterEvent("Spam_Explosions_On_People_Tehe_Darrow_B", 3000, 1)
  216.     pUnit:RegisterEvent("Mean_Buff_King", 6000, 0)
  217.     pUnit:RegisterEvent("Final_Phase", 5000, 0)
  218. end
  219.  
  220. function SHADOWBOLT_BOOM(pUnit)
  221.     local plr = pUnit:GetRandomPlayer(0)
  222.     if plr ~= nil then
  223.         if math.random(1,2) == 1 then
  224.             pUnit:FullCastSpellOnTarget(39026, plr) -- Shadow Bolt
  225.         else
  226.             pUnit:FullCastSpellOnTarget(51131, plr) -- Strangulate
  227.         end
  228.     end
  229. end
  230.  
  231. function DeathAndDecay_Boss_king(pUnit)
  232.     local plr = pUnit:GetRandomPlayer(0)
  233.     if plr ~= nil then
  234.         pUnit:CastSpellAoF(plr:GetX(), plr:GetY(), plr:GetZ(), 39658) -- Death and decay
  235.     end
  236. end
  237.  
  238. function SpawnCreatures_ThatWillHelp(pUnit)
  239.     local i = 0
  240.     while i ~= 4 do
  241.         i = i + 1
  242.         local plr = pUnit:GetRandomPlayer(0)
  243.         if plr ~= nil then
  244.             local choice = math.random(1,4)
  245.             if choice == 1 then
  246.                 pUnit:SpawnCreature(AddA, plr:GetX()+math.random(0,3), plr:GetY()-math.random(0,3), plr:GetZ()+math.random(0,2), plr:GetO(), 21, 120000)
  247.             elseif choice == 2 then
  248.                 pUnit:SpawnCreature(AddB, plr:GetX()+math.random(0,3), plr:GetY()+math.random(0,3), plr:GetZ()+math.random(0,3), plr:GetO(), 21, 120000)
  249.             elseif choice == 3 then
  250.                 pUnit:SpawnCreature(AddC, plr:GetX()+math.random(0,3), plr:GetY()+math.random(0,3), plr:GetZ()+math.random(0,3), plr:GetO(), 21, 120000)
  251.             elseif choice == 4 then
  252.                 pUnit:SpawnCreature(AddD, plr:GetX()+math.random(0,3), plr:GetY()+math.random(0,3), plr:GetZ()+math.random(0,3), plr:GetO(), 21, 120000)
  253.             end
  254.         end
  255.     end
  256. end
  257.  
  258. function AddsSpawn(pUnit, Event)
  259.     pUnit:Root()
  260.     pUnit:RegisterEvent("Wait_For_VISUAL", 750, 1)
  261.     pUnit:EquipWeapons(5742,0,39296)
  262. end
  263.  
  264. function Wait_For_VISUAL(pUnit)
  265.     pUnit:Unroot()
  266.     pUnit:CastSpell(39180) -- Visual
  267. end
  268.  
  269. RegisterUnitEvent(AddA, 18, "AddsSpawn")
  270. RegisterUnitEvent(AddB, 18, "AddsSpawn")
  271. RegisterUnitEvent(AddC, 18, "AddsSpawn")
  272. RegisterUnitEvent(AddD, 18, "AddsSpawn")
  273.  
  274. function Final_Phase(pUnit)
  275.     if pUnit:GetHealthPct() < 20 then
  276.         pUnit:Root()
  277.         pUnit:SendChatMessage(14,0,"You cannot defeat me! Not while my source of power still thrives...")
  278.         pUnit:SetCombatCapable(1)
  279.         pUnit:RemoveEvents()
  280.         pUnit:CastSpell(22663) -- Invincible
  281.         pUnit:SpawnCreature(CrownID, TrigA:GetX(), TrigA:GetY(), TrigA:GetZ(), 0, 21, 0)
  282.         pUnit:RegisterEvent("Wait_For_Crown_To_Define_Ololololol", 2000, 1)
  283.         pUnit:RegisterEvent("Check_Crown_Health", 2000, 0)
  284.     end
  285. end
  286.  
  287. function Wait_For_Crown_To_Define_Ololololol(pUnit)
  288.     Crown:CastSpell(64446) -- Teleport Visual
  289.     Crown:CastSpell(55928) -- Crown shield visual
  290.     Crown:SetCombatCapable(1)
  291.     Crown:Root()
  292.     Crown:SetScale(2)
  293.     pUnit:ChannelSpell(30742, TrigB)
  294.     TrigB:ChannelSpell(64367, TrigA)
  295.     TrigA:ChannelSpell(40447, TrigB)
  296. end
  297.  
  298. function Check_Crown_Health(pUnit)
  299.     if Crown:IsAlive() == false then
  300.         pUnit:SendChatMessage(14,0,"How is this possible?!")
  301.         pUnit:Unroot()
  302.         pUnit:RemoveEvents()
  303.         pUnit:RemoveAura(22663) -- invincible
  304.         pUnit:SetCombatCapable(0)
  305.         pUnit:StopChannel()
  306.         TrigA:StopChannel()
  307.         TrigB:StopChannel()
  308.         pUnit:RegisterEvent("Spam_Explosions_On_People_Tehe_Darrow", 5000, 1)
  309.     end
  310. end
  311.  
  312. -------------------------------------------------------------------------------------------------
  313.  
  314. function Define_Trish_OnSpawn(pUnit, Event)
  315.     pUnit:SetFaction(35)
  316.     pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 9)
  317.     Trish = pUnit
  318. end
  319.  
  320. function Define_Trish_OnDeath(pUnit, Event)
  321.     pUnit:RemoveEvents()
  322. end
  323.  
  324. RegisterUnitEvent(TrishID, 18, "Define_Trish_OnSpawn")
  325. RegisterUnitEvent(TrishID, 4, "Define_Trish_OnDeath")
  326.  
  327. function Define_Trish_OnLeave(pUnit, Event)
  328.     pUnit:RemoveEvents()
  329. end
  330.  
  331. RegisterUnitEvent(TrishID, 2, "Define_Trish_OnLeave")
  332.  
  333. function Define_Garrash_OnSpawn(pUnit, Event)
  334.     pUnit:SetFaction(35)
  335.     pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 9)
  336.     Garrash = pUnit
  337. end
  338.  
  339. function Define_Garrash_OnDeath(pUnit, Event)
  340.     pUnit:RemoveEvents()
  341. end
  342.  
  343. function Define_Garrosh_OnLeave(pUnit, Event)
  344.     pUnit:RemoveEvents()
  345. end
  346.  
  347. RegisterUnitEvent(GarrashID, 2, "Define_Garrosh_OnLeave")
  348.  
  349. RegisterUnitEvent(GarrashID, 4, "Define_Garrash_OnDeath")
  350. RegisterUnitEvent(GarrashID, 18, "Define_Garrash_OnSpawn")
  351.  
  352. function Define_Lachdanan_OnSpawn(pUnit, Event)
  353.     pUnit:SetFaction(35)
  354.     pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 9)
  355.     Lachdanan = pUnit
  356. end
  357.  
  358. function Define_Lachdanan_OnDeath(pUnit, Event)
  359.     pUnit:RemoveEvents()
  360. end
  361.  
  362. RegisterUnitEvent(LachdananID, 4, "Define_Lachdanan_OnDeath")
  363. RegisterUnitEvent(LachdananID, 18, "Define_Lachdanan_OnSpawn")
  364.  
  365. function Define_Lachdanan_OnLeave(pUnit, Event)
  366.     pUnit:RemoveEvents()
  367. end
  368.  
  369. RegisterUnitEvent(LachdananID, 2, "Define_Lachdanan_OnLeave")
  370.  
  371. -------------------------------------------------------------------------------------------------
  372.  
  373. function Define_Lachdanan_OnCombat(pUnit, Event) -- Warrior
  374.     pUnit:RegisterEvent("Cast_A_Spell_Lachdanan", math.random(5000, 15000), 1)
  375. end
  376.  
  377. function Cast_A_Spell_Lachdanan(pUnit)
  378.     if math.random(1,2) == 1 then
  379.         pUnit:FullCastSpell(36132) -- Whirlwind
  380.         pUnit:RegisterEvent("Cast_A_Spell_Lachdanan", math.random(5000, 15000), 1)
  381.     else
  382.         pUnit:FullCastSpellOnTarget(58504, pUnit:GetMainTank()) -- Strike
  383.         pUnit:RegisterEvent("Cast_A_Spell_Lachdanan", math.random(2000, 10000), 1)
  384.     end
  385. end
  386.  
  387. function Define_Trish_OnCombat(pUnit, Event) -- Mage
  388.     pUnit:Root()
  389.     pUnit:RegisterEvent("Cast_A_Spell_Trish", 1000, 0)
  390. end
  391.  
  392. function Cast_A_Spell_Trish(pUnit)
  393.     pUnit:CastSpell(52662) -- Visual
  394.     pUnit:FullCastSpell(17228) -- Shadowbolt Volley
  395. end
  396.  
  397. function Define_Garrash_OnCombat(pUnit, Event) -- Paladin
  398.     pUnit:CastSpell(51126) -- Shadowform visual
  399.     pUnit:RegisterEvent("HealAllies_Lol_PallY", 6000, 0)
  400. end
  401.  
  402. function HealAllies_Lol_PallY(pUnit)
  403.     if Trish:GetHealthPct() < 50 and Trish:IsAlive() then
  404.         pUnit:FullCastSpellOnTarget(58153, Trish) -- Heal
  405.     elseif Lachdanan:GetHealthPct() < 50 and Lachdanan:IsAlive() then
  406.         pUnit:FullCastSpellOnTarget(58153, Lachdanan) -- Heal
  407.     end
  408. end
  409.  
  410. RegisterUnitEvent(TrishID, 1, "Define_Trish_OnCombat")
  411. RegisterUnitEvent(LachdananID, 1, "Define_Lachdanan_OnCombat")
  412. RegisterUnitEvent(GarrashID, 1, "Define_Garrash_OnCombat")
  413.  
  414. -------------------------------------------------------------------------------------------------
  415.  
  416. function TrigA_SpawnDefine(pUnit, Event)
  417.     pUnit:CastSpell(72405)
  418.     TrigA = pUnit
  419. end
  420.  
  421. RegisterUnitEvent(TrigAID, 18, "TrigA_SpawnDefine")
  422.  
  423. function TrigB_SpawnDefine(pUnit, Event)
  424.     TrigB = pUnit
  425. end
  426.  
  427. RegisterUnitEvent(TrigBID, 18, "TrigB_SpawnDefine")
  428.  
  429. function Crown_Spawn_Define(pUnit, Event)
  430.     pUnit:Root()
  431.     Crown = pUnit
  432. end
  433.  
  434. RegisterUnitEvent(CrownID, 18, "Crown_Spawn_Define")
  435.  
  436. -------------------------------------------------------------------------------------------------
  437. -------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment