stoneharry

Untitled

Nov 19th, 2011
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.33 KB | None | 0 0
  1.  
  2. DM = {}
  3. DM.VAR = {}
  4.  
  5. local OBJECT_END = 0x0006
  6. local GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B
  7. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
  8. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26    33554432  cannot select the unit
  9. local UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0044
  10.  
  11. SetDBCSpellVar(47591, "c_is_flags", 0x01000)
  12.  
  13. -- First Boss -----------------------------------------------------------------------------
  14.  
  15. function DM.VAR.FirstBossCombat(pUnit, Event)
  16.     local id = pUnit:GetInstanceID()
  17.     if id == nil then id = 1 end
  18.     DM[id] = DM[id] or {VAR={}}
  19.     pUnit:SetScale(1.2)
  20.     pUnit:SendChatMessage(12,0,"The entertainment has arrived!")
  21.     pUnit:PlaySoundToSet(13472)
  22.     pUnit:RegisterEvent("DM.VAR.CheckHealthPctFirst", 2500, 0)
  23.     pUnit:RegisterEvent("DM.VAR.Firstbossrandomspells", 2000, 0)
  24. end
  25.  
  26. function DM.VAR.SpawnCatapult(pUnit, event)
  27.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- Untargetable
  28. end
  29.  
  30. RegisterUnitEvent(27881, 18, "DM.VAR.SpawnCatapult")
  31.  
  32. function DM.VAR.CheckHealthPctFirst(pUnit)
  33.     if pUnit:GetHealthPct() < 50 then
  34.         pUnit:SetScale(1)
  35.         pUnit:SendChatMessage(12,0,"Say hello to some little friends of mine!")
  36.         pUnit:PlaySoundToSet(13476)
  37.         pUnit:RemoveEvents()
  38.         --pUnit:SpawnCreature(116862, -192, -451, 55, 0, 35, 360000)
  39.         local id = pUnit:GetInstanceID()
  40.         if id == nil then id = 1 end
  41.         DM[id] = DM[id] or {VAR={}}
  42.         pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- unattackable
  43.         pUnit:DisableMelee(true)
  44.         local vehicle = pUnit:GetCreatureNearestCoords(-204.6, -446, 53.8, 27881)
  45.         vehicle:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- Targetable
  46.         pUnit:EnterVehicle(vehicle, 1000)
  47.         vehicle:RegisterEvent("DM.VAR.launchmissilesvehicle", 4000, 0)
  48.         pUnit:RegisterEvent("DM.VAR.THrowbombsAtPlayersFirst", 7500, 0)
  49.     end
  50. end
  51.  
  52. --[[function visualslimespawn(pUnit, event)
  53.     pUnit:FullCastSpell(70343) -- visual
  54.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- Untargetable
  55.     pUnit:RegisterEvent("CastVisualsetcfaeo", 1000, 1)
  56. end
  57.  
  58. function CastVisualsetcfaeo(pUnit)
  59.     pUnit:CastSpell(70343) -- visual
  60.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- Untargetable
  61. end
  62.  
  63. RegisterUnitEvent(116862, 18, "visualslimespawn")]]
  64.  
  65. function DM.VAR.launchmissilesvehicle(pUnit)
  66.     if pUnit then
  67.         if pUnit:IsAlive() then
  68.             local plr = pUnit:GetRandomPlayer(0)
  69.             if plr ~= nil then
  70.                 pUnit:CastSpellOnTarget(9796, plr) -- poison
  71.                 pUnit:FullCastSpellOnTarget(48211, plr) -- fire at target
  72.             end
  73.         else
  74.             pUnit:RemoveEvents()
  75.             pUnit:Despawn(2000, 0)
  76.         end
  77.     end
  78. end
  79.  
  80. function DM.VAR.THrowbombsAtPlayersFirst(pUnit)
  81.     if pUnit:GetVehicleBase() == nil then
  82.         pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- attackable
  83.         pUnit:DisableMelee(false)
  84.         pUnit:RemoveEvents()
  85.         pUnit:PlaySoundToSet(13473)
  86.         pUnit:SendChatMessage(12,0,"The fun is just beginning!")
  87.         pUnit:CastSpell(53212) -- visual
  88.         pUnit:SetScale(1.2)
  89.         pUnit:RegisterEvent("DM.VAR.Firstbossrandomspells", 5000, 0)
  90.     else
  91.         if pUnit:GetVehicleBase():IsAlive() then
  92.             local pla = pUnit:GetRandomPlayer(0)
  93.             if pla ~= nil then
  94.                 --pUnit:CastSpellOnTarget(4068, plr) -- grenade
  95.                 pUnit:CastSpellAoF(pla:GetX(), pla:GetY(), pla:GetZ(), 4068)
  96.             end
  97.         else
  98.             pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- attackable
  99.             pUnit:DisableMelee(false)
  100.             pUnit:RemoveEvents()
  101.             pUnit:ExitVehicle()
  102.             pUnit:PlaySoundToSet(13473)
  103.             pUnit:SendChatMessage(12,0,"The fun is just beginning!")
  104.             pUnit:CastSpell(53212) -- visual
  105.             pUnit:SetScale(1.2)
  106.             pUnit:RegisterEvent("DM.VAR.Firstbossrandomspells", 3000, 0)
  107.         end
  108.     end
  109. end
  110.  
  111. function DM.VAR.Firstbossrandomspells(pUnit)
  112.     local choice = math.random(1,3)
  113.     if choice == 1 then
  114.         local plr = pUnit:GetRandomPlayer(0)
  115.         if plr ~= nil then
  116.             pUnit:CastSpellOnTarget(3396, plr) -- poison
  117.         end
  118.     elseif choice == 2 then
  119.         local plr = pUnit:GetRandomPlayer(0)
  120.         if plr ~= nil then
  121.             pUnit:CastSpellOnTarget(744, plr) -- poison
  122.         end
  123.     elseif choice == 3 then
  124.         local plr = pUnit:GetRandomPlayer(0)
  125.         if plr ~= nil then
  126.             pUnit:CastSpellOnTarget(5208, plr) -- poison
  127.         end
  128.     end
  129. end
  130.  
  131. function DM.VAR.FirstBossDone(pUnit, Event)
  132.     --if Event == 2 then
  133.     if pUnit:IsAlive() then
  134.         pUnit:RemoveEvents()
  135.         pUnit:Despawn(3000, 4000)
  136.         pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- attackable
  137.         pUnit:DisableMelee(false)
  138.         --[[local slime = pUnit:GetCreatureNearestCoords(-192, -451, 54.5, 116862)
  139.         slime:RemoveAura(70343) -- visual]]
  140.         if pUnit:GetVehicleBase() ~= nil then
  141.             pUnit:GetVehicleBase():RemoveEvents()
  142.             pUnit:GetVehicleBase():SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  143.             pUnit:ExitVehicle()
  144.         end
  145.     else
  146.         pUnit:RemoveEvents()
  147.         pUnit:GetGameObjectNearestCoords(-191.6, -456.4, 54.5, 13965):SetByte(GAMEOBJECT_BYTES_1,0,0) -- open door
  148.         --[[pUnit:GetCreatureNearestCoords(-192, -451, 54.5, 116862):RemoveAura(70343) -- visual
  149.         pUnit:GetCreatureNearestCoords(-192, -451, 54.5, 116862):Despawn(5000, 0)]]
  150.         pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- attackable
  151.         pUnit:DisableMelee(false)
  152.         local slime = pUnit:GetCreatureNearestCoords(-192, -451, 54.5, 116862)
  153.         slime:RemoveAura(70343) -- visual
  154.         if pUnit:GetVehicleBase() ~= nil then
  155.             pUnit:GetVehicleBase():RemoveEvents()
  156.             pUnit:GetVehicleBase():SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  157.             pUnit:ExitVehicle()
  158.         end
  159.     end
  160. end
  161.  
  162. RegisterUnitEvent(253201, 1, "DM.VAR.FirstBossCombat")
  163. RegisterUnitEvent(253201, 2, "DM.VAR.FirstBossDone")
  164. RegisterUnitEvent(253201, 4, "DM.VAR.FirstBossDone")
  165.  
  166. -- Second boss -----------------------------------------------------------------------------
  167.  
  168. function DM.VAR.SecondBossCombat(pUnit, Event)
  169.     pUnit:RegisterEvent("DM.VAR.FreezeCurrentTarget", 8000, 0)
  170.     pUnit:RegisterEvent("DM.VAR.PullTargetToSpider", 5000, 0)
  171.     pUnit:RegisterEvent("DM.VAR.FreezeAllTargetsSpider", 17000, 0)
  172.     pUnit:RegisterEvent("DM.VAR.StompNearbyPlayers", math.random(1000, 21000), 1)
  173.     pUnit:RegisterEvent("DM.VAR.TrapPlayerInCoCoon", 25000, 0)
  174.     pUnit:RegisterEvent("DM.VAR.ENrangeNearLowHealth", 5000, 0)
  175. end
  176.  
  177. function DM.VAR.FreezeCurrentTarget(pUnit)
  178.     local plr = pUnit:GetRandomPlayer(0)
  179.     if plr ~= nil then
  180.         pUnit:FullCastSpellOnTarget(15471, plr) -- Stun for 8 seconds
  181.     end
  182. end
  183.  
  184. function DM.VAR.PullTargetToSpider(pUnit)
  185.     local plr = pUnit:GetRandomPlayer(0)
  186.     if plr ~= nil then
  187.         local cacoon = pUnit:GetCreatureNearestCoords(plr:GetX(), plr:GetY(), plr:GetZ(), 249252)
  188.         if cacoon ~= nil then
  189.             if plr:GetDistanceYards(cacoon) < 3 then
  190.                 -- do nothing
  191.             else
  192.                 pUnit:FullCastSpellOnTarget(28434, plr) -- Pull player to npc
  193.             end
  194.         else
  195.             pUnit:FullCastSpellOnTarget(28434, plr) -- Pull player to npc
  196.         end
  197.     end
  198. end
  199.  
  200. function DM.VAR.FreezeAllTargetsSpider(pUnit)
  201.     pUnit:CastSpell(56632) -- Freeze all nearby (root)
  202. end
  203.  
  204. function DM.VAR.StompNearbyPlayers(pUnit)
  205.     pUnit:CastSpell(11681) -- damage nearby players (hellfire effect)
  206.     pUnit:RegisterEvent("DM.VAR.StompNearbyPlayers", math.random(1000, 21000), 1)
  207. end
  208.  
  209. function DM.VAR.ENrangeNearLowHealth(pUnit)
  210.     if pUnit:GetHealthPct() < 30 then
  211.         pUnit:CastSpell(42705) -- Enrage (stacks)
  212.         pUnit:CastSpell(30494) -- damage nearby people and slow
  213.         pUnit:CastSpell(56741) -- visual
  214.     end
  215. end
  216.  
  217. function DM.VAR.TrapPlayerInCoCoon(pUnit)
  218.     local plr = pUnit:GetRandomPlayer(0)
  219.     if plr ~= nil then
  220.         local cacoon = pUnit:GetCreatureNearestCoords(plr:GetX(), plr:GetY(), plr:GetZ(), 249252)
  221.         if cacoon ~= nil then
  222.             if plr:GetDistanceYards(cacoon) < 3 then
  223.                 -- Re-register?
  224.             else
  225.                 pUnit:SendChatMessage(42,0, plr:GetName().." has been trapped in a cacoon!")
  226.                 plr:Root()
  227.                 plr:SetScale(0.5)
  228.                 plr:SetPlayerLock(true)
  229.                 pUnit:SpawnCreature(249252, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 21, 120000)
  230.             end
  231.         else
  232.             pUnit:SendChatMessage(42,0, plr:GetName().." has been trapped in a cacoon!")
  233.             plr:Root()
  234.             plr:SetScale(0.5)
  235.             plr:SetPlayerLock(true)
  236.             pUnit:SpawnCreature(249252, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 21, 120000)
  237.         end
  238.     end
  239. end
  240.  
  241. -- Cocoon
  242.  
  243. function DM.VAR.TrappedCheckerRegisterTLDR(pUnit, Event)
  244.     pUnit:RegisterEvent("DM.VAR.TrappedPlayerSpawnCheckTLDR", 1000, 0)
  245. end
  246.  
  247. function DM.VAR.TrappedPlayerSpawnCheckTLDR(pUnit)
  248.     local plr = pUnit:GetClosestPlayer()
  249.     if plr ~= nil then
  250.         if ((pUnit:GetHealthPct() < 5) or (not plr:IsAlive())) then
  251.             pUnit:RemoveEvents()
  252.             plr:Unroot()
  253.             plr:SetScale(1)
  254.             plr:SetPlayerLock(false)
  255.             pUnit:Emote(387, 1000)
  256.             pUnit:Despawn(100, 0)
  257.         else
  258.             pUnit:Strike(plr, 2, 70569, 40, 80, 1.2)
  259.         end
  260.     end
  261. end
  262.  
  263. RegisterUnitEvent(249252, 18, "DM.VAR.TrappedCheckerRegisterTLDR")
  264.  
  265. function DM.VAR.SeocndBossDone(pUnit, Event)
  266.     pUnit:RemoveEvents()
  267.     if (Event == 4) then
  268.         pUnit:GetGameObjectNearestCoords(-290.4, -535.8, 49.5, 16400):SetByte(GAMEOBJECT_BYTES_1,0,0) -- open door
  269.     end
  270. end
  271.  
  272. RegisterUnitEvent(279761, 1, "DM.VAR.SecondBossCombat")
  273. RegisterUnitEvent(279761, 2, "DM.VAR.SeocndBossDone")
  274. RegisterUnitEvent(279761, 4, "DM.VAR.SeocndBossDone")
  275.  
  276. -- Third boss -----------------------------------------------------------------------------
  277.  
  278. function DM.VAR.FORGE_SHOCKWAVE(pUnit,Event)
  279. pUnit:RemoveEvents()
  280. local id = pUnit:GetInstanceID()
  281.     if id == nil then id = 1 end
  282.     DM[id] = DM[id] or {VAR={}}
  283. DM[id].VAR.Shock = pUnit:GetRandomPlayer(0)
  284. if pUnit:GetDistanceYards(DM[id].VAR.Shock) < 30 then
  285. if DM[id].VAR.Shock:IsDead() == false then
  286. pUnit:SetFacing(DM[id].VAR.Shock:GetO())
  287. pUnit:SendChatMessageToPlayer(42,0,"Forgemaster Arkvoth Targets YOU!", DM[id].VAR.Shock)
  288. pUnit:SendChatMessage(42,0,"Forgemaster Arkvoth Begins to Cast \124cff71d5ff\124Hspell:58977\124h[Shockwave]\124h\124r")
  289. pUnit:Root()
  290. pUnit:RegisterEvent("DM.VAR.FORGE_SHOCKWAVECAST", 2000,1)
  291. else
  292. DM[id].VAR.Shock = nil
  293. end
  294. end
  295. end
  296.  
  297. function DM.VAR.FORGE_SHOCKWAVECAST(pUnit,Event)
  298. local id = pUnit:GetInstanceID()
  299.     if id == nil then id = 1 end
  300.     DM[id] = DM[id] or {VAR={}}
  301. pUnit:SetFacing(0)
  302. pUnit:CastSpellOnTarget(58977,DM[id].VAR.Shock)
  303. DM[id].VAR.Shock = nil
  304.  pUnit:RegisterEvent("DM.VAR.FORGE_Unroot", 1000,1)
  305.  pUnit:RegisterEvent("DM.VAR.FORGE_SHOCKWAVE", 16000,0)
  306. pUnit:RegisterEvent("DM.VAR.FORGE_FIREPATCH", 6000,0)
  307. pUnit:RegisterEvent("DM.VAR.FORGE_FIRECHARGE", 10000,0)
  308. pUnit:RegisterEvent("DM.VAR.FORGE_MELTARMOR", 15000,1)
  309. pUnit:RegisterEvent("DM.VAR.FORGE_HASAURA", 1000,0)
  310. end
  311.  
  312. function DM.VAR.FORGE_Unroot(pUnit,Event)
  313. pUnit:Unroot()
  314. pUnit:SetFacing(1)
  315. end
  316.  
  317. function DM.VAR.FORGE_DEAD(pUnit,Event)
  318. pUnit:RemoveEvents()
  319. pUnit:Unroot()
  320. pUnit:GetGameObjectNearestCoords(-169.5, -580.5, 19.31, 16399):SetByte(GAMEOBJECT_BYTES_1,0,0)
  321. end
  322.  
  323. function DM.VAR.FORGE_COMBAT(pUnit,Event)
  324. pUnit:RegisterEvent("DM.VAR.FORGE_SHOCKWAVE", 16000,0)
  325. pUnit:RegisterEvent("DM.VAR.FORGE_FIREPATCH", 6000,0)
  326. pUnit:RegisterEvent("DM.VAR.FORGE_FIRECHARGE", 10000,0)
  327. pUnit:RegisterEvent("DM.VAR.FORGE_MELTARMOR", 4000,1)
  328. pUnit:RegisterEvent("DM.VAR.FORGE_HASAURA", 5000,0)
  329. end
  330.  
  331. function DM.VAR.FORGE_LEAVE(pUnit,Event)
  332. pUnit:RemoveEvents()
  333. pUnit:Unroot()
  334.  pUnit:Despawn(3000,4000)
  335.  for place,creatures in pairs(pUnit:GetInRangeUnits()) do
  336.     if creatures:GetEntry() == 6899 then
  337.     creatures:Despawn(1,0)
  338.     end
  339.  end
  340.     end
  341.  
  342. function DM.VAR.FORGE_FIREPATCH(pUnit,Event)
  343. pUnit:CastSpell(19823)
  344.  pUnit:SpawnCreature(6805, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 15000)
  345. end
  346.  
  347. function DM.VAR.FORGE_MELTARMOR(pUnit,Event)
  348. local tank = pUnit:GetMainTank()
  349.     if tank ~= nil then
  350.         if pUnit:GetDistanceYards(tank) < 12 then
  351.         pUnit:CastSpellOnTarget(61509,tank)
  352.         end
  353.     end
  354. end
  355.  
  356.  
  357. function DM.VAR.FORGE_FIRECHARGE(pUnit,Event)
  358. local plr = pUnit:GetRandomPlayer(7)
  359.     if plr ~= nil then
  360.         if pUnit:GetDistanceYards(plr) < 30 then
  361.             if plr:IsDead() == false then
  362.             pUnit:FullCastSpellOnTarget(33971,plr)
  363.             pUnit:RegisterEvent("DM.VAR.FORGE_FIRECHARGEPLANT", 1500,1)
  364.             end
  365.         end
  366.     end
  367. end
  368.  
  369. function DM.VAR.FORGE_FIRECHARGEPLANT(pUnit,Event)
  370. pUnit:CastSpell(60290)
  371. pUnit:SpawnCreature(6805, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 15000)
  372. end
  373.  
  374.  RegisterUnitEvent(6888, 1, "DM.VAR.FORGE_COMBAT")
  375. RegisterUnitEvent(6888, 2, "DM.VAR.FORGE_LEAVE")
  376. RegisterUnitEvent(6888, 4, "DM.VAR.FORGE_DEAD")
  377.  
  378.  
  379.  
  380. function DM.VAR.STEAMSURGE_DEAD(pUnit,Event)
  381. pUnit:RemoveEvents()
  382. pUnit:SpawnCreature(6812, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 15000)
  383. pUnit:SpawnCreature(6805, pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 0, 35, 18000)
  384. end
  385.  
  386. RegisterUnitEvent(6899, 4, "DM.VAR.STEAMSURGE_DEAD")
  387.  
  388. function DM.VAR.FireDummyDamage(pUnit,Event)
  389.  pUnit:CastSpell(42345)
  390. local PlayersAllAround = pUnit:GetInRangePlayers()
  391.   for a, players in pairs(PlayersAllAround) do
  392.     if pUnit:GetDistanceYards(players) < 3.5 then
  393.         if players:IsDead() == false then
  394.         pUnit:Strike(players,1,5679,300,450,1)
  395.         end
  396.     end
  397.  end
  398. end
  399.  
  400.  
  401.   function DM.VAR.FireDummyENEMY(pUnit,Event)
  402. local Forge = pUnit:GetCreatureNearestCoords(pUnit:GetX(),pUnit:GetY(),pUnit:GetZ(), 6888)
  403.     if Forge ~= nil then
  404.         if pUnit:GetDistanceYards(Forge) < 5 then
  405.             if Forge:IsAlive() then
  406.             local tank = Forge:GetMainTank()
  407.                 if tank ~= nil then
  408.                 tank:CastSpellOnTarget(61509,Forge)
  409.                 end
  410.             end
  411.         end
  412.     end
  413.  end
  414.  
  415.   function DM.VAR.FireDummySpawn(pUnit,Event)
  416.   pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  417.   pUnit:RegisterEvent("DM.VAR.FireDummyDamage",1000,0)
  418.    pUnit:RegisterEvent("DM.VAR.FireDummyENEMY",4000,0)
  419.   pUnit:CastSpell(42345)
  420.   end
  421.  
  422.  function DM.VAR.FORGE_HASAURA(pUnit,Event)
  423.     local id = pUnit:GetInstanceID()
  424.     if id == nil then id = 1 end
  425.     DM[id] = DM[id] or {VAR={}}
  426.     if DM[id].VAR.Stacks == nil then DM[id].VAR.Stacks = 0 end
  427.     -- if he has aura
  428.         if pUnit:HasAura(61509) == true then
  429.         -- add to stacks
  430.         DM[id].VAR.Stacks = DM[id].VAR.Stacks + 1
  431.         -- if stacks more than 0, cast spell
  432.         pUnit:SendChatMessage(12,0,"I have "..DM[id].VAR.Stacks.." stacks!")
  433.             if DM[id].VAR.Stacks >= 1 then
  434.             -- cast spell
  435.                 local PlayersAllAround = pUnit:GetInRangePlayers()
  436.                 for a, players in pairs(PlayersAllAround) do
  437.                     if pUnit:GetDistanceYards(players) < 20 then
  438.                         if players:IsAlive() == true then
  439.                             pUnit:CastSpellOnTarget(13878,players)
  440.                         end
  441.                     end
  442.                 end
  443.             else
  444.         -- if more than one stack, spawn adds
  445.             pUnit:SendChatMessage(12,0,"Do I have the aura?")
  446.             if pUnit:HasAura(61509) == false then
  447.             pUnit:SendChatMessage(12,0,"I don't have the aura! Do I have stacks?")
  448.                 if DM[id].VAR.Stacks >= 1 then
  449.                 pUnit:SendChatMessage(12,0,"Passed stack check!")
  450.             -- spawn creature on nearby players
  451.                 DM[id].VAR.Stacks = 0
  452.                 local PlayersAllAround = pUnit:GetInRangePlayers()
  453.                 for a, players in pairs(PlayersAllAround) do
  454.                     if pUnit:GetDistanceYards(players) < 40 then
  455.                     pUnit:SendChatMessage(12,0,"Spawning creatures!")
  456.                         pUnit:SpawnCreature(6899, players:GetX(), players:GetY(), players:GetZ(), 0, 35, 320000)
  457.                         pUnit:SpawnCreature(6812, players:GetX(), players:GetY(), players:GetZ(), 0, 35, 15000)
  458.                     end
  459.                 end
  460.             end
  461.         end
  462.     end
  463.  end
  464.  end
  465.  
  466.   RegisterUnitEvent(6805, 18, "DM.VAR.FireDummySpawn")
  467.  
  468. -- Last Boss - Dragon --------------------------------------------------------------------
  469.  
  470. function DM.VAR.LastBossSPAWNS(pUnit, Event)
  471.     if pUnit:HasAura(60534) then
  472.         pUnit:RemoveAura(60534) -- flying
  473.     end
  474.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- Unkillable
  475.     pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 3) -- Sleep
  476.     pUnit:RegisterEvent("DM.VAR.SpamEmoteForPlayersWhoAreDelayed", 1000, 0)
  477. end
  478.  
  479. function DM.VAR.SpamEmoteForPlayersWhoAreDelayed(pUnit)
  480.     local plr = pUnit:GetClosestPlayer()
  481.     if plr ~= nil then
  482.         if plr:IsAlive() then
  483.             if pUnit:GetDistanceYards(plr) < 30 then
  484.                 pUnit:RemoveEvents()
  485.                 pUnit:PlaySoundToSet(17311) -- epic music
  486.                 pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 0) -- Get Up
  487.                 pUnit:SetMovementFlags(2) -- This creature flies
  488.                 pUnit:RegisterEvent("DM.VAR.FinalBossFlyIntoAirVisual", 4000, 1)
  489.                 pUnit:RegisterEvent("DM.VAR.FinalBossFlyIntoAirPermanent", 6950, 1)
  490.             else
  491.                 pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- Unkillable
  492.                 pUnit:SetUInt32Value(UNIT_FIELD_BYTES_1, 3) -- Sleep
  493.             end
  494.         end
  495.     end
  496. end
  497.  
  498. function DM.VAR.FinalBossFlyIntoAirVisual(pUnit)
  499.     pUnit:Emote(448, 3000) -- Fly into the air
  500. end
  501.  
  502. function DM.VAR.FinalBossFlyIntoAirPermanent(pUnit)
  503.     pUnit:CastSpell(60534)
  504.     pUnit:SetPosition(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+15, pUnit:GetO())
  505.     pUnit:MoveTo(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+0.1, 0)
  506.     local id = pUnit:GetInstanceID()
  507.     if id == nil then id = 1 end
  508.     DM[id] = DM[id] or {VAR={}}
  509.     DM[id].VAR.finali = 0
  510.     pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 500, 1)
  511. end
  512.  
  513. function DM.VAR.HandleEventsAsTheyHappenLast(pUnit)
  514.     local id = pUnit:GetInstanceID()
  515.     if id == nil then id = 1 end
  516.     DM[id] = DM[id] or {VAR={}}
  517.     if DM[id].VAR.finali == nil then
  518.         DM[id].VAR.finali = 0
  519.     end
  520.     if DM[id].VAR.finali == 0 then
  521.         pUnit:SetMovementFlags(2)
  522.         pUnit:FullCastSpell(3129) -- Frost breath
  523.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 500, 1)
  524.     elseif DM[id].VAR.finali == 1 then
  525.         for place,players in pairs(pUnit:GetInRangePlayers()) do
  526.             players:CastSpell(47591) -- Freeze self
  527.         end
  528.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 2000, 1)
  529.     elseif DM[id].VAR.finali == 2 then
  530.         pUnit:MoveTo(64.7, -763.6, 142, 0)
  531.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 5000, 1)
  532.     elseif DM[id].VAR.finali == 3 then
  533.         pUnit:MoveTo(82.8, -765, 140, 0)
  534.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 5000, 1)
  535.     elseif DM[id].VAR.finali == 4 then
  536.         for place,players in pairs(pUnit:GetInRangePlayers()) do
  537.             if players:HasAura(47591) then
  538.                 players:RemoveAura(47591) -- Freeze self
  539.             end
  540.         end
  541.         pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0) -- Attackable
  542.         DM[id].VAR.dragon = pUnit
  543.         pUnit:RegisterEvent("DM.VAR.IceLancePeopleFinalBoss", 5000, 0)
  544.         pUnit:RegisterEvent("DM.VAR.CheckifWipedLastBoss", 2000, 0)
  545.         pUnit:RegisterEvent("DM.VAR.SpawnCyclonesLastBoss", 45000, 1)
  546.         pUnit:RegisterEvent("DM.VAR.CheckForPlayerPhaseTwoFinal", 1000, 0)
  547.         pUnit:RegisterEvent("DM.VAR.FinalSpawnBlizzards", 5000, 0)
  548.         pUnit:RegisterEvent("DM.VAR.finalplaydramaticmusic", 5000, 1)
  549.     elseif DM[id].VAR.finali == 6 then -- 5 is for cyclone
  550.         pUnit:MoveTo(98, -789, 131.6, 0)
  551.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 4000, 1)
  552.     elseif DM[id].VAR.finali == 7 then
  553.         local plr = pUnit:GetClosestPlayer()
  554.         if plr ~= nil then
  555.             if plr:IsOnVehicle() then
  556.                 plr:ExitVehicle()
  557.             end
  558.         end
  559.         pUnit:Emote(447, 3000) -- land
  560.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 2950, 1)
  561.     elseif DM[id].VAR.finali == 8 then
  562.         pUnit:RemoveAura(60534)
  563.         pUnit:SetMovementFlags(1)
  564.         pUnit:MoveTo(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+0.1, 0)
  565.         pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0)
  566.         pUnit:MoveTo(96.8, -753, 131.6, 0)
  567.         pUnit:RegisterEvent("DM.VAR.CheckifWipedLastBoss", 2000, 0)
  568.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 5000, 1)
  569.     elseif DM[id].VAR.finali == 9 then
  570.         pUnit:SendChatMessage(42,0,"The Queen prepares to blast everyone in front of her!")
  571.         pUnit:FullCastSpell(16094) -- ice breath
  572.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 2000, 1)
  573.     elseif DM[id].VAR.finali == 10 then
  574.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 4000, 1)
  575.     elseif DM[id].VAR.finali == 11 then
  576.         pUnit:CastSpell(15531) -- frost nova
  577.         pUnit:ChannelSpell(7083, pUnit)
  578.         local d = 0
  579.         while d ~= 6 do
  580.             local plr = pUnit:GetRandomPlayer(0)
  581.             if plr ~= nil then
  582.                 pUnit:SpawnCreature(30419, plr:GetX(), plr:GetY(), plr:GetZ(), plr:GetO(), 21, 30000)
  583.                 plr:CastSpell(69665) -- visual
  584.             end
  585.             d = d + 1
  586.         end
  587.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 30000, 1)
  588.     elseif DM[id].VAR.finali == 12 then
  589.         pUnit:RemoveEvents()
  590.         pUnit:StopChannel()
  591.         pUnit:Emote(448, 3000) -- Fly into the air
  592.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 2950, 1)
  593.     elseif DM[id].VAR.finali == 13 then
  594.         pUnit:CastSpell(60534) -- flying
  595.         pUnit:SetPosition(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+15, pUnit:GetO())
  596.         pUnit:MoveTo(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ()+0.1, 0)
  597.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 2000, 1)
  598.     elseif DM[id].VAR.finali == 14 then
  599.         pUnit:SetMovementFlags(2)
  600.         pUnit:MoveTo(64.7, -763.6, 142, 0)
  601.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 5000, 1)
  602.     elseif DM[id].VAR.finali == 15 then
  603.         pUnit:MoveTo(82.8, -765, 140, 0)
  604.         pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 5000, 1)
  605.     elseif DM[id].VAR.finali == 16 then
  606.         pUnit:RegisterEvent("DM.VAR.IceLancePeopleFinalBoss", 5000, 0)
  607.         pUnit:RegisterEvent("DM.VAR.CheckifWipedLastBoss", 2000, 0)
  608.         --pUnit:RegisterEvent("DM.VAR.SpawnCyclonesLastBoss", 45000, 1)
  609.         --pUnit:RegisterEvent("DM.VAR.CheckForPlayerPhaseTwoFinal", 1000, 0)
  610.         pUnit:RegisterEvent("DM.VAR.FinalSpawnBlizzards", 5000, 0) 
  611.     end
  612.     DM[id].VAR.finali = DM[id].VAR.finali + 1
  613. end
  614.  
  615. function DM.VAR.finalplaydramaticmusic(pUnit)
  616.     pUnit:PlaySoundToSet(17288) -- Dramatic music
  617. end
  618.  
  619. function DM.VAR.IceLancePeopleFinalBoss(pUnit)
  620.     if math.random(1,4) == 4 then
  621.         pUnit:FullCastSpell(8398) -- frostobolt volley
  622.     else
  623.         local plr = pUnit:GetRandomPlayer(0)
  624.         if plr ~= nil then
  625.             if (not plr:IsOnVehicle()) then
  626.                 pUnit:CastSpellOnTarget(42913, plr) -- ice lance
  627.             end
  628.         end
  629.     end
  630. end
  631.  
  632. function DM.VAR.FinalSpawnBlizzards(pUnit)
  633.     local plr = pUnit:GetRandomPlayer(0)
  634.     if plr ~= nil then
  635.         pUnit:SpawnCreature(232159, plr:GetX(), plr:GetY(), plr:GetZ(), 0, 21, 15000)
  636.     end
  637. end
  638.  
  639. function DM.VAR.BlizzardSPawnDa(pUnit, Event)
  640.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- Untargetable
  641.     pUnit:RegisterEvent("DM.VAR.CastBlizzardSpellDinal", 1000, 1)
  642. end
  643.  
  644. function DM.VAR.CastBlizzardSpellDinal(pUnit)
  645.     pUnit:CastSpellAoF(pUnit:GetX(), pUnit:GetY(), pUnit:GetZ(), 19099)
  646.     pUnit:RegisterEvent("DM.VAR.CastBlizzardSpellDamage", 1000, 9)
  647. end
  648.  
  649. function DM.VAR.CastBlizzardSpellDamage(pUnit)
  650.     for k,plrs in pairs(pUnit:GetInRangePlayers()) do
  651.         if plrs:IsAlive() then
  652.             if plrs:GetDistanceYards(pUnit) < 10 then
  653.                 pUnit:Strike(plrs,1,19099,140,220,1.1)
  654.             end
  655.         end
  656.     end
  657. end
  658.  
  659. RegisterUnitEvent(232159, 18, "DM.VAR.BlizzardSPawnDa")
  660.  
  661. function DM.VAR.SpawnCyclonesLastBoss(pUnit)
  662.     pUnit:SendChatMessage(42,0,"A cyclone has appeared, use it!")
  663.     local id = pUnit:GetInstanceID()
  664.     if id == nil then id = 1 end
  665.     DM[id] = DM[id] or {VAR={}}
  666.     if DM[id].VAR.finali == 5 then
  667.         pUnit:SpawnCreature(323321, 90.225, -765.6, 131.6, 0, 35, 120000)
  668.     end
  669.     DM[id].VAR.finali = DM[id].VAR.finali + 1
  670. end
  671.  
  672. function DM.VAR.CheckForPlayerPhaseTwoFinal(pUnit)
  673.     local plr = pUnit:GetClosestPlayer()
  674.     if plr ~= nil then
  675.         if plr:IsOnVehicle() then
  676.             pUnit:RemoveEvents()
  677.             pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 2)
  678.             pUnit:MoveTo(63.9, -784.6, 140, 0)
  679.             pUnit:RegisterEvent("DM.VAR.HandleEventsAsTheyHappenLast", 2500, 1)
  680.         end
  681.     end
  682. end
  683.  
  684. function DM.VAR.CheckifWipedLastBoss(pUnit)
  685.     -- The boss cannot leave combat since it never enters combat - vehicle
  686.     local reset = true
  687.     for place,players in pairs(pUnit:GetInRangePlayers()) do
  688.         if players:IsAlive() then
  689.             reset = false
  690.         end
  691.     end
  692.     if reset then
  693.         pUnit:RemoveEvents()
  694.         pUnit:ReturnToSpawnPoint()
  695.         pUnit:RegisterEvent("DM.VAR.LastBossSPAWNS", 10000, 1)
  696.     end
  697. end
  698.  
  699. function DM.VAR.BossLeaveOrDeadFinal(pUnit, Event)
  700.     pUnit:RemoveEvents()
  701.     -- spawn chest with loot
  702. end
  703.  
  704. RegisterUnitEvent(30609, 18, "DM.VAR.LastBossSPAWNS")
  705. RegisterUnitEvent(30609, 4, "DM.VAR.BossLeaveOrDeadFinal")
  706.  
  707. function DM.VAR.CycleJumpToCreatureVisual(pUnit, Event)
  708.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE) -- Untargetable
  709.     pUnit:RegisterEvent("DM.VAR.CycloneVisualPrepare", 1000, 1)
  710. end
  711.  
  712. function DM.VAR.CycloneVisualPrepare(pUnit)
  713.     pUnit:CastSpell(32332) -- cyclone visual
  714.     pUnit:RegisterEvent("DM.VAR.Cyclevisualchancetospawn", 1000, 0)
  715. end
  716.  
  717. function DM.VAR.Cyclevisualchancetospawn(pUnit)
  718.     local plr = pUnit:GetClosestPlayer()
  719.     if plr ~= nil then
  720.         if plr:GetDistanceYards(pUnit) < 5 then
  721.             local id = pUnit:GetInstanceID()
  722.             if id == nil then id = 1 end
  723.             DM[id] = DM[id] or {VAR={}}
  724.             if DM[id].VAR.dragon ~= nil then
  725.                 pUnit:RemoveEvents()
  726.                 plr:EnterVehicle(DM[id].VAR.dragon, 1000)
  727.                 pUnit:Despawn(1000, 0)
  728.             end
  729.         end
  730.     end
  731. end
  732.  
  733. RegisterUnitEvent(323321, 18, "DM.VAR.CycleJumpToCreatureVisual")
  734.  
  735. ------------------------------------------------------------------------------------------
  736.  
Advertisement
Add Comment
Please, Sign In to add comment