stoneharry

Untitled

Aug 12th, 2013
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.27 KB | None | 0 0
  1.  
  2. CM = {}
  3. CM.VAR = {}
  4.  
  5. -- Format: [ID] = {sound ID, Message, Shout}
  6. local SOUNDS = {
  7.     -- Music
  8.     [1] = {50200, nil, nil}, -- NightElfX1 Music
  9.     [2] = {50201, nil, nil}, -- Persuit Theme Music
  10.     -- Intro Cinematic
  11.     [3] = {50202, "Nordrassil's roots seem to be healing well. I wish I could say the same for Felwood, I fear the Legion's corruption will scar the glade permanently.", false},
  12.     [4] = {50203, "Your druids will think of something. Perhaps Ysera or Alexstrasza could lend their-", false},
  13.     [5] = {50204, "Your pardon, Shando Stormrage and Priestess Tyrande, but she insisted that she be allowed to see you.", false},
  14.     [6] = {50205, "Who are you girl? What is so urgent?", false},
  15.     [7] = {50206, "I am a servent of the Warden, Maiev Shadowsong, she who pledged to hunt down the Betrayer, Illidan.", false},
  16.     [8] = {50207, "Illidan? Explain yourself.", false},
  17.     [9] = {50208, "Your pardon, Shando. But your brother has raised a dark army from the sea and stolen a powerful demonic artifact. Even now my mistress battles him on the broken isles, she requires immediate reinforcements.", false},
  18.     [10] = {50209, "I will go. I will lead the sentinels there myself.", false},
  19.     [11] = {50210, "No my love. The druids and I can handle-", false},
  20.     [12] = {50211, "I am the one who set him free. The responsibility is mine.", false},
  21.     [13] = {50212, "Then we shall both go. If this girls tale is true, Maiev wil need all the help she can get.", false},
  22.     -- Narrative
  23.     [14] = {50213, "My owls have already scouted ahead of us and found Maiev's location. She and her forces are under attack, but we will need to pass through the jungle to reach her.", false},
  24.     [15] = {50214, "We best make haste, I doubt Maiev's forces can hold out much longer.", false},
  25.     -- Reaching Maiev
  26.     [16] = {50215, "I'm glad we reached you in time, Maiev.", false},
  27.     [17] = {50216, "Elune be praised! I knew you would come, Shando Stormrage.", false},
  28.     [18] = {50217, "Priestess Tyrande, I'm surprised you came in person. Are you here to solve your guilty conscience?", false},
  29.     [19] = {50218, "I did what I had to do, Maiev! You are in no position to judge ME.", true},
  30.     [20] = {50219, "What you did was murder MY watchers and set the Betrayer free! It is you who should be locked in a cage.", false},
  31.     [21] = {50220, "Stop this, both of you! We're not out of danger yet. Maiev, what's the situation here?", false},
  32.     [22] = {50221, "We've wasted too much time. The longer we wait to attack the stronger Illidan's forces become. We must strike soon, Shando.", false},
  33.     [23] = {50222, "Very well, let's get moving then.", false},
  34.     -- Illidan Encounter
  35.     [24] = {50223, "Tyrande, what are you doing here? This battle does not concern you.", false},
  36.     [25] = {50224, "I was wrong to set you free, Illidan. I can see that now. You've become a monster.", false},
  37.     [26] = {50225, "Monster? Is that what you think of me? I have -always- cared for you, Tyrande. I sought only to improve my worthiness, my power.", false},
  38.     [27] = {50226, "Raw power is no substitute for true strength, Illidan. That is why I chose your brother over you.", false},
  39.     [28] = {50227, "Still you refuse to see me for what I truly am! You believe me to be a villian, an enemy! But soon now you will see our enemies are the same.", false},
  40.     [29] = {50228, "Brother! What are you doing here?", false},
  41.     [30] = {50229, "I've come to stop you, Illidan. Instead of banishing you, I should have returned you to your cage when I had the chance. I was weak then - but no longer.", false},
  42.     [31] = {50230, "I have sworn allegiance to a new master, brother. I have a great task to perform in his service. I'm sorry, but I cannot allow you to stand in my way.", false},
  43.     [32] = {50231, "I can scarcely believe you survived. You are more resourceful than I imagined, little warden.", false},
  44.     [33] = {50232, "I am the hand of justice, Illidan. Long ago I swore an oath to keep you chained, and by all the gods I shall!", true},
  45.     [34] = {50233, "Not yet, my little priestess. A pity you couldn't see things my way. Now you and the whole world will understand just what I am capable of! ASKAROF!", true},
  46.     -- Outro Cinematic
  47.     [35] = {50234, "Show yourself, Illidan! It's over!", true},
  48.     [36] = {50235, "This battle is far from over, Maiev. Illidan has yet to be accounted for, and I've seen no sign of Tyrande either.", false},
  49.     [37] = {50236, "Victory is ours! It has been an honour to fight at your side, Shando.", false},
  50.     [38] = {50237, "Don't worry my love. We'll find Illidan wherever he runs. We'll find him.", false},
  51.     -- Misc
  52.     [39] = {50238, "We'll have to fight our way through the naga to reach Maiev!", false},
  53.     [40] = {50239, "Maiev's forces wont hold out much longer.", false},
  54.     [41] = {50240, "The jungle here is impassable. I'll need to use force of nature to clear a path for us.", false},
  55.     [42] = {50241, "Wretched night elves, we are the naga. We are the future!", true},
  56.     [43] = {50242, "We must move quickly to save Maiev!", false},
  57.     [44] = {50243, "We must reach the warden's base quickly!", false},
  58.     [45] = {50244, "We're running out of time, we must reach Maiev quickly!", false},
  59.     [46] = {50245, "What are these vile serpents?", false},
  60. }
  61.  
  62. ---------------------------
  63. -- Setup creatures
  64. ---------------------------
  65.  
  66. function CM.VAR.VariableiseCreatures(pUnit, Event)
  67.     local id = pUnit:GetInstanceID() or 1
  68.     CM[id] = CM[id] or {VAR={}}
  69.     if Event == 18 then
  70.         if pUnit:GetEntry() == 153621 then
  71.             CM[id].VAR.MALFURION = pUnit
  72.             pUnit:RegisterEvent("CM.VAR.StartEvent", 4000, 0)
  73.         else
  74.             CM[id].VAR.TYRANDE = pUnit
  75.         end
  76.     else
  77.         pUnit:RemoveEvents()
  78.         pUnit:SendChatMessage(42,0,pUnit:GetName().." has died!")
  79.         for _,v in pairs(pUnit:GetInRangeUnits()) do
  80.             v:RemoveEvents()
  81.             v:Despawn(1,0)
  82.         end
  83.     end
  84. end
  85.  
  86. RegisterUnitEvent(153621, 18, "CM.VAR.VariableiseCreatures")
  87. RegisterUnitEvent(153622, 18, "CM.VAR.VariableiseCreatures")
  88. RegisterUnitEvent(153621, 4, "CM.VAR.VariableiseCreatures")
  89. RegisterUnitEvent(153622, 4, "CM.VAR.VariableiseCreatures")
  90.  
  91. ---------------------------
  92. -- Gossip Start & Intro
  93. ---------------------------
  94.  
  95. function CM.VAR.GossipStartZ1(pUnit, event, player)
  96.     pUnit:GossipCreateMenu(1, player, 0)
  97.     pUnit:GossipMenuAddItem(9, "Let us begin.", 424, 0)
  98.     pUnit:GossipMenuAddItem(0, "Nevermind.", 526, 0)
  99.     pUnit:GossipSendMenu(player)
  100. end
  101.  
  102.  
  103. function CM.VAR.GossipStartZ2(pUnit, event, player, id, intid, code)
  104.     player:GossipComplete()
  105.     if(intid == 424) then
  106.         local id = pUnit:GetInstanceID() or 1
  107.         CM[id] = CM[id] or {VAR={}}
  108.         if CM[id].VAR.MALFURION and CM[id].VAR.TYRANDE then
  109.             pUnit:SetNPCFlags(2)
  110.             CM[id].VAR.start = true
  111.         end
  112.     end
  113. end
  114.  
  115. RegisterUnitGossipEvent(90191, 1, "CM.VAR.GossipStartZ1")
  116. RegisterUnitGossipEvent(90191, 2, "CM.VAR.GossipStartZ2")
  117.  
  118. function CM.VAR.StartEvent(pUnit)
  119.     local id = pUnit:GetInstanceID() or 1
  120.     CM[id] = CM[id] or {VAR={}}
  121.     if CM[id].VAR.start then
  122.         CM[id].VAR.start = false
  123.         CM[id].VAR.i = 0
  124.         pUnit:RemoveEvents()
  125.         PlayMessage(CM[id].VAR.MALFURION, 1)
  126.         pUnit:RegisterEvent("CM.VAR.CinematicIntro", 1000, 0)
  127.     end
  128. end
  129.  
  130. function CM.VAR.CinematicIntro(pUnit)
  131.     local id = pUnit:GetInstanceID() or 1
  132.     CM[id] = CM[id] or {VAR={}}
  133.     CM[id].VAR.i = CM[id].VAR.i + 1
  134.     if CM[id].VAR.i == 1 then
  135.         PlayMessage(CM[id].VAR.MALFURION, 3)
  136.     elseif CM[id].VAR.i == 9 then
  137.         CM[id].VAR.druid = pUnit:SpawnCreature(134092, -14, 193.4, -3.3, 1.686005, 35, 54000, 1484, 0, 0)
  138.         CM[id].VAR.sent = pUnit:SpawnCreature(32074, -19, 196, -3.3, 1.686005, 35, 54000)
  139.     elseif CM[id].VAR.i == 10 then
  140.         PlayMessage(CM[id].VAR.TYRANDE, 4)
  141.         CM[id].VAR.druid:MoveTo(-15, 213, -4.9, 1.553163)
  142.         CM[id].VAR.sent:MoveTo(-19, 215, -4.9, 1.553163)
  143.         CM[id].VAR.sent:SetScale(1.5)
  144.     elseif CM[id].VAR.i == 15 then
  145.         PlayMessage(CM[id].VAR.druid, 5)
  146.         CM[id].VAR.TYRANDE:SetFacing(5.295580)
  147.         CM[id].VAR.MALFURION:SetFacing(4.266711)
  148.     elseif CM[id].VAR.i == 24 then
  149.         PlayMessage(CM[id].VAR.TYRANDE, 6)
  150.     elseif CM[id].VAR.i == 28 then
  151.         PlayMessage(CM[id].VAR.sent, 7)
  152.     elseif CM[id].VAR.i == 33 then
  153.         PlayMessage(CM[id].VAR.MALFURION, 8)
  154.     elseif CM[id].VAR.i == 38 then
  155.         PlayMessage(CM[id].VAR.sent, 9)
  156.     elseif CM[id].VAR.i == 50 then
  157.         PlayMessage(CM[id].VAR.TYRANDE, 10)
  158.         CM[id].VAR.TYRANDE:SetFacing(6.241991)
  159.         CM[id].VAR.sent:MoveTo(-17, 178, -3.45, 0)
  160.         CM[id].VAR.druid:MoveTo(-17, 178, -3.45, 0)
  161.         CM[id].VAR.sent = nil
  162.         CM[id].VAR.druid = nil
  163.     elseif CM[id].VAR.i == 56 then
  164.         PlayMessage(CM[id].VAR.MALFURION, 11)
  165.         CM[id].VAR.MALFURION:SetFacing(3.123958)
  166.     elseif CM[id].VAR.i == 59 then
  167.         PlayMessage(CM[id].VAR.TYRANDE, 12)
  168.     elseif CM[id].VAR.i == 63 then
  169.         PlayMessage(CM[id].VAR.MALFURION, 13)
  170.     elseif CM[id].VAR.i == 65 then
  171.         local plr = pUnit:GetClosestPlayer()
  172.         if not plr then
  173.             CM[id].VAR.i = CM[id].VAR.i - 1
  174.         else
  175.             pUnit:RemoveEvents()
  176.             CM[id].VAR.MALFURION:SetUnitToFollow(plr, 2, 1)
  177.             CM[id].VAR.TYRANDE:SetUnitToFollow(plr, 4, 5)
  178.             CM[id].VAR.MALFURION:SetFaction(plr:GetFaction())
  179.             CM[id].VAR.TYRANDE:SetFaction(plr:GetFaction())
  180.             pUnit:RegisterEvent("CM.VAR.AI_COMBAT", 1000, 0)
  181.             pUnit:RegisterEvent("CM.VAR.MoreMessages", 6000, 1)
  182.             pUnit:RegisterEvent("CM.VAR.MoreMessage2s", 15000, 1)
  183.         end
  184.     end
  185. end
  186.  
  187. function CM.VAR.MoreMessages(pUnit)
  188.     local id = pUnit:GetInstanceID() or 1
  189.     PlayMessage(CM[id].VAR.TYRANDE, 14)
  190. end
  191.  
  192. function CM.VAR.MoreMessage2s(pUnit)
  193.     local id = pUnit:GetInstanceID() or 1
  194.     PlayMessage(CM[id].VAR.TYRANDE, 15)
  195. end
  196.  
  197. ---------------------------
  198. -- AI
  199. ---------------------------
  200.  
  201. function CM.VAR.AI_COMBAT(pUnit)
  202.     local id = pUnit:GetInstanceID() or 1
  203.     AI_HANDLE(CM[id].VAR.MALFURION)
  204.     AI_HANDLE(CM[id].VAR.TYRANDE)
  205. end
  206.  
  207. function AI_HANDLE(pUnit)
  208.     if pUnit:IsInCombat() then
  209.         if pUnit:IsCasting() then
  210.             return
  211.         end
  212.         if pUnit:GetEntry() == 153621 then
  213.             if math.random(1,40) == 1 then
  214.                 local choice = math.random(1,3)
  215.                 if choice == 1 then
  216.                     PlayMessage(pUnit, 39)
  217.                 elseif choice == 2 then
  218.                     PlayMessage(pUnit, 43)
  219.                 elseif choice == 3 then
  220.                     PlayMessage(pUnit, 44)
  221.                 end
  222.             end
  223.             for _,v in pairs(pUnit:GetInRangePlayers()) do
  224.                 if not v:HasAura(48469) then
  225.                     v:FullCastSpellOnTarget(48469,v)
  226.                     return
  227.                 elseif v:GetHealthPct() < 75 then
  228.                     pUnit:FullCastSpellOnTarget(5189, v)
  229.                     return
  230.                 end
  231.             end
  232.         else
  233.             if math.random(1,40) == 1 then
  234.                 if math.random(1,2) == 1 then
  235.                     PlayMessage(pUnit, 45)
  236.                 else
  237.                     PlayMessage(pUnit, 40)
  238.                 end
  239.             end
  240.             local t = pUnit:GetSelection()
  241.             if t then
  242.                 if math.random(1,2) == 1 then
  243.                     pUnit:FullCastSpellOnTarget(9912, t)
  244.                 else
  245.                     pUnit:FullCastSpellOnTarget(8951, t)
  246.                 end
  247.             end
  248.         end
  249.     else
  250.         local p = pUnit:GetUnitToFollow()
  251.         if p then
  252.             if p:IsInCombat() then
  253.                 local t = p:GetSelection()
  254.                 if t and not t:IsPlayer() and not t:GetEntry() == 153621 and not t:GetEntry() == 153622 then
  255.                     pUnit:AttackReaction(t, 1, 0)
  256.                 end
  257.             end
  258.         else
  259.             local plr = pUnit:GetClosestPlayer()
  260.             if plr then
  261.                 if pUnit:GetEntry() == 153621 then
  262.                     pUnit:SetUnitToFollow(plr, 2, 1)
  263.                 else
  264.                     pUnit:SetUnitToFollow(plr, 4, 5)
  265.                 end
  266.             end
  267.         end
  268.     end
  269. end
  270.  
  271. ---------------------------
  272. -- Maiev
  273. ---------------------------
  274.  
  275. function CM.VAR.Maiev(pUnit, Event)
  276.     pUnit:RegisterEvent("CM.VAR.MaievC", 1000, 0)
  277. end
  278.  
  279. function CM.VAR.MaievC(pUnit)
  280.     local id = pUnit:GetInstanceID() or 1
  281.     CM[id] = CM[id] or {VAR={}}
  282.     if CM[id].VAR.IEZ then
  283.         return
  284.     end
  285.     if CM[id].VAR.MALFURION and CM[id].VAR.TYRANDE then
  286.         if CM[id].VAR.TYRANDE:GetDistanceYards(pUnit) < 20 and CM[id].VAR.MALFURION:GetDistanceYards(pUnit) < 20 then
  287.             pUnit:RemoveEvents()
  288.             CM[id].VAR.IEZ = true
  289.             pUnit:SetFacing(1.6)
  290.             CM[id].VAR.MALFURION:RemoveEvents()
  291.             CM[id].VAR.TYRANDE:RemoveEvents()
  292.             PlayMessage(CM[id].VAR.MALFURION, 16)
  293.             CM[id].VAR.MAIEV = pUnit
  294.             CM[id].VAR.i = 0
  295.             pUnit:RegisterEvent("CM.VAR.MaievCin", 1000, 0)
  296.         end
  297.     end
  298. end
  299.  
  300. RegisterUnitEvent(231971, 18, "CM.VAR.Maiev")
  301.  
  302. function CM.VAR.MaievCin(pUnit)
  303.     local id = pUnit:GetInstanceID() or 1
  304.     CM[id].VAR.i = CM[id].VAR.i + 1
  305.     if CM[id].VAR.i == 4 then
  306.         PlayMessage(pUnit, 17)
  307.     elseif CM[id].VAR.i == 9 then
  308.         PlayMessage(pUnit, 18)
  309.     elseif CM[id].VAR.i == 16 then
  310.         PlayMessage(CM[id].VAR.TYRANDE, 19)
  311.     elseif CM[id].VAR.i == 24 then
  312.         PlayMessage(pUnit, 20)
  313.     elseif CM[id].VAR.i == 32 then
  314.         PlayMessage(CM[id].VAR.MALFURION, 21)
  315.     elseif CM[id].VAR.i == 38 then
  316.         PlayMessage(pUnit, 22)
  317.     elseif CM[id].VAR.i == 46 then
  318.         PlayMessage(CM[id].VAR.MALFURION, 23)
  319.     elseif CM[id].VAR.i == 48 then
  320.         local plr = pUnit:GetClosestPlayer()
  321.         if plr then
  322.             pUnit:RemoveEvents()
  323.             pUnit:SetUnitToFollow(plr, 2, 1)
  324.             pUnit:SetFaction(plr:GetFaction())
  325.             for _,v in pairs(pUnit:GetInRangeUnits()) do
  326.                 if v:GetEntry() == 133271 then
  327.                     if v:IsInCombat() then
  328.                         v:SetHealth(1)
  329.                     else
  330.                         v:Kill(v)
  331.                     end
  332.                 end
  333.             end
  334.         else
  335.             CM[id].VAR.i = CM[id].VAR.i - 1
  336.         end
  337.     end
  338. end
  339.  
  340. ---------------------------
  341. -- Illidan Cinematic
  342. ---------------------------
  343.  
  344. function CM.VAR.IllidanCinematic(pUnit, Event)
  345.     pUnit:RegisterEvent("CM.VAR.WFAUS", 2000, 0) -- wait for all units
  346. end
  347.  
  348. function CM.VAR.WFAUS(pUnit)
  349.     local id = pUnit:GetInstanceID() or 1
  350.     CM[id] = CM[id] or {VAR={}}
  351.     if CM[id].VAR.MALFURION and CM[id].VAR.TYRANDE and CM[id].VAR.MAIEV then
  352.         if CM[id].VAR.TYRANDE:GetDistanceYards(pUnit) < 40 and CM[id].VAR.MALFURION:GetDistanceYards(pUnit) < 40 and CM[id].VAR.MAIEV:GetDistanceYards(pUnit) < 40 then
  353.             pUnit:RemoveEvents()
  354.             CM[id].VAR.MAIEV:RemoveEvents()
  355.             CM[id].VAR.TYRANDE:RemoveEvents()
  356.             CM[id].VAR.MALFURION:RemoveEvents()
  357.             CM[id].VAR.MAIEV:Despawn(1,0)
  358.             CM[id].VAR.TYRANDE:Despawn(1,0)
  359.             CM[id].VAR.MALFURION:Despawn(1,0)
  360.             CM[id].VAR.i = 0
  361.             CM[id].VAR.TYRANDE = pUnit:SpawnCreature(153622, 789, 475, 37.4, 0.2, 35, 0)
  362.             pUnit:RegisterEvent("CM.VAR.IECine", 1000, 0)
  363.         end
  364.     end
  365. end
  366.  
  367. function CM.VAR.IECine(pUnit)
  368.     local id = pUnit:GetInstanceID() or 1
  369.     CM[id].VAR.i = CM[id].VAR.i + 1
  370.     if CM[id].VAR.i == 1 then
  371.         CM[id].VAR.TYRANDE:MoveTo(810.2, 479, 37.4, 0.204502)
  372.     elseif CM[id].VAR.i == 2 then
  373.         PlayMessage(pUnit, 24)
  374.     elseif CM[id].VAR.i == 8 then
  375.         PlayMessage(CM[id].VAR.TYRANDE, 25)
  376.     elseif CM[id].VAR.i == 14 then
  377.         PlayMessage(pUnit, 26)
  378.     elseif CM[id].VAR.i == 25 then
  379.         PlayMessage(CM[id].VAR.TYRANDE, 27)
  380.     elseif CM[id].VAR.i == 32 then
  381.         PlayMessage(pUnit, 28)
  382.         CM[id].VAR.MALFURION = pUnit:SpawnCreature(153621, 791, 488, 37.4, 6.1, 35, 0)
  383.     elseif CM[id].VAR.i == 33 then
  384.         CM[id].VAR.MALFURION:MoveTo(809, 484, 37.4, 6.271404)
  385.     elseif CM[id].VAR.i == 42 then
  386.         PlayMessage(pUnit, 29)
  387.         pUnit:SetFacing(6.27 - math.pi)
  388.     elseif CM[id].VAR.i == 46 then
  389.         PlayMessage(CM[id].VAR.MALFURION, 30)
  390.     elseif CM[id].VAR.i == 58 then
  391.         PlayMessage(pUnit, 31)
  392.     elseif CM[id].VAR.i == 62 then
  393.         CM[id].VAR.MAIEV = pUnit:SpawnCreature(231971, 796, 455, 37.4, 0.720997, 35, 0)
  394.     elseif CM[id].VAR.i == 63 then
  395.         CM[id].VAR.MAIEV:MoveTo(811.8, 473, 37.4, 0.581194)
  396.     elseif CM[id].VAR.i == 69 then
  397.         PlayMessage(pUnit, 32)
  398.         pUnit:SetFacing(0.581194 + math.pi)
  399.     elseif CM[id].VAR.i == 74 then
  400.         PlayMessage(CM[id].VAR.MAIEV, 33)
  401.     elseif CM[id].VAR.i == 84 then
  402.         PlayMessage(pUnit, 34)
  403.     elseif CM[id].VAR.i == 98 then
  404.         pUnit:RemoveEvents()
  405.         PlaySound(pUnit, 2) -- music
  406.     end
  407. end
  408.  
  409. RegisterUnitEvent(500911, 18, "CM.VAR.IllidanCinematic")
  410.  
  411. ---------------------------
  412. -- Trash
  413. ---------------------------
  414.  
  415. --[[function CM.VAR.IntroNaga(pUnit)
  416.     PlayMessage(pUnit, 42)
  417. end
  418.  
  419. function CM.VAR.ExtraNagaMessage(pUnit)
  420.     local id = pUnit:GetInstanceID() or 1
  421.     PlayMessage(CM.VAR.TYRANDE, 39)
  422. end]]
  423.  
  424. function CM.VAR.NagaEvents(pUnit, Event)
  425.     if Event == 1 then
  426.         --[[local id = pUnit:GetInstanceID() or 1
  427.         CM[id] = CM[id] or {VAR={}}
  428.         if not CM.VAR.pn then
  429.             local p = pUnit:GetClosestPlayer()
  430.             if p and p:GetDistanceYards(pUnit) < 50 then
  431.                 CM.VAR.pn = true
  432.                 PlayMessage(CM.VAR.TYRANDE, 46)
  433.                 pUnit:RegisterEvent("CM.VAR.IntroNaga", 4000, 1)
  434.                 pUnit:RegisterEvent("CM.VAR.ExtraNagaMessage", 10000, 1)
  435.             end
  436.         end]]
  437.         if pUnit:GetEntry() == 112571 then -- warrior
  438.             local t = pUnit:GetMainTank()
  439.             if t and not t:IsPlayer() then
  440.                 if t:GetEntry() == 133271 then
  441.                     return
  442.                 end
  443.             end
  444.             if math.random(1,10) == 1 then
  445.                 PlayMessage(pUnit, 42)
  446.             end
  447.             if math.random(1,2) == 1 then
  448.                 for _,v in pairs(pUnit:GetInRangeUnits()) do
  449.                     if not v:IsInCombat() then
  450.                         if v:GetDistanceYards(pUnit) < 30 then
  451.                             v:AttackReaction(pUnit:GetSelection(), 1, 0)
  452.                         end
  453.                     end
  454.                 end
  455.             end
  456.             if math.random(1,2) == 1 then
  457.                 local t = pUnit:GetMainTank()
  458.                 if t then
  459.                     pUnit:FullCastSpellOnTarget(40602, t) -- charge
  460.                 else
  461.                     pUnit:CastSpell(27578)
  462.                 end
  463.             end
  464.             pUnit:RegisterEvent("CM.VAR.MeleeAI", 7000, 0)
  465.         else
  466.             if math.random(1,10) == 1 then
  467.                 pUnit:SendChatMessage(14,0,"You cannot harm us!")
  468.             end
  469.             if math.random(1,2) == 1 then
  470.                 pUnit:FullCastSpell(12544)
  471.             else
  472.                 pUnit:FullCastSpell(35064)
  473.             end
  474.             pUnit:RegisterEvent("CM.VAR.CasterNaga", 6000, 0)
  475.         end
  476.     else
  477.         pUnit:RemoveEvents()
  478.     end
  479. end
  480.  
  481. function CM.VAR.CasterNaga(pUnit)
  482.     if pUnit:IsCasting() then
  483.         return
  484.     end
  485.     for _,v in pairs(pUnit:GetInRangeUnits()) do
  486.         if v:GetHealthPct() < 70 then
  487.             pUnit:FullCastSpellOnTarget(48894,v)
  488.             return
  489.         end
  490.     end
  491.     local t = pUnit:GetMainTank()
  492.     if t then
  493.         pUnit:FullCastSpellOnTarget(16799,t)
  494.     end
  495. end
  496.  
  497. function CM.VAR.MeleeAI(pUnit)
  498.     local t = pUnit:GetMainTank()
  499.     if not t then
  500.         return
  501.     end
  502.     if t:GetDistanceYards(pUnit) > 6 then
  503.         return
  504.     end
  505.     if math.random(1,2) == 1 then
  506.         pUnit:FullCastSpellOnTarget(69651, t)
  507.     else
  508.         pUnit:FullCastSpellOnTarget(60590, t)
  509.     end
  510. end
  511.  
  512. RegisterUnitEvent(112571, 1, "CM.VAR.NagaEvents")
  513. RegisterUnitEvent(112571, 2, "CM.VAR.NagaEvents")
  514. RegisterUnitEvent(112571, 4, "CM.VAR.NagaEvents")
  515. RegisterUnitEvent(112572, 1, "CM.VAR.NagaEvents")
  516. RegisterUnitEvent(112572, 2, "CM.VAR.NagaEvents")
  517. RegisterUnitEvent(112572, 4, "CM.VAR.NagaEvents")
  518.  
  519. function CM.VAR.SentinelS(pUnit, Event)
  520.     pUnit:RegisterEvent("CM.VAR.AttNeaNaga", 1000, 0)
  521. end
  522.  
  523. function CM.VAR.AttNeaNaga(pUnit)
  524.     if pUnit:IsInCombat() then
  525.         local plr = pUnit:GetClosestPlayer()
  526.         if plr and pUnit:GetDistanceYards(plr) < 40 then
  527.             pUnit:RemoveEvents()
  528.             return
  529.         end
  530.         local t = pUnit:GetSelection()
  531.         if t then
  532.             if t:GetHealthPct() < 50 then
  533.                 t:SetHealth(t:GetMaxHealth())
  534.             end
  535.         end
  536.         if pUnit:GetHealthPct() < 50 then
  537.             pUnit:SetHealth(pUnit:GetMaxHealth())
  538.         end
  539.     else
  540.         local distance = 5000
  541.         local t = nil
  542.         for _,v in pairs(pUnit:GetInRangeUnits()) do
  543.             if v:GetEntry() == 112571 or v:GetEntry() == 112572 and not v:IsInCombat() then
  544.                 local d = pUnit:GetDistanceYards(v)
  545.                 if d < distance then
  546.                     distance = d
  547.                     t = v
  548.                 end
  549.             end
  550.         end
  551.         if t then
  552.             pUnit:AttackReaction(t, 1, 0)
  553.             t:AttackReaction(pUnit, 1, 0)
  554.         end
  555.     end
  556. end
  557.  
  558. RegisterUnitEvent(133271, 18, "CM.VAR.SentinelS")
  559.  
  560. ---------------------------
  561. -- Misc Functions
  562. ---------------------------
  563.  
  564. function PlayMessage(u, s)
  565.     if not u then
  566.         return
  567.     end
  568.     local m = SOUNDS[s][2]
  569.     if m then
  570.         if SOUNDS[s][3] then
  571.             u:SendChatMessage(14,0,m)
  572.             u:Emote(5,0)
  573.         else
  574.             u:SendChatMessage(12,0,m)
  575.             u:Emote(1,0)
  576.         end
  577.         if SOUNDS[s][1] then
  578.             u:PlaySoundToSet(SOUNDS[s][1])
  579.         end
  580.     else
  581.         if SOUNDS[s][1] then
  582.             u:PlayMusicToSet(SOUNDS[s][1])
  583.         end
  584.     end
  585. end
Advertisement
Add Comment
Please, Sign In to add comment