stoneharry

Untitled

Aug 12th, 2013
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.40 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 Tyranda, 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 Tyranda, 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, "Tyranda, 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, Tyranda. 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 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 Tyranda 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.         if id == nil then id = 1 end
  108.         CM[id] = CM[id] or {VAR={}}
  109.         if CM[id].VAR.MALFURION and CM[id].VAR.TYRANDE then
  110.             pUnit:SetNPCFlags(2)
  111.             CM[id].VAR.start = true
  112.         end
  113.     end
  114. end
  115.  
  116. RegisterUnitGossipEvent(90191, 1, "CM.VAR.GossipStartZ1")
  117. RegisterUnitGossipEvent(90191, 2, "CM.VAR.GossipStartZ2")
  118.  
  119. function CM.VAR.StartEvent(pUnit)
  120.     local id = pUnit:GetInstanceID() or 1
  121.     if id == nil then id = 1 end
  122.     if CM[id].VAR.start then
  123.         CM[id].VAR.start = false
  124.         CM[id].VAR.i = 0
  125.         pUnit:RemoveEvents()
  126.         PlayMessage(CM[id].VAR.MALFURION, 1)
  127.         pUnit:RegisterEvent("CM.VAR.CinematicIntro", 1000, 0)
  128.     end
  129. end
  130.  
  131. function CM.VAR.CinematicIntro(pUnit)
  132.     local id = pUnit:GetInstanceID() or 1
  133.     if id == nil then id = 1 end
  134.     CM[id].VAR.i = CM[id].VAR.i + 1
  135.     if CM[id].VAR.i == 1 then
  136.         PlayMessage(CM[id].VAR.MALFURION, 3)
  137.     elseif CM[id].VAR.i == 9 then
  138.         CM[id].VAR.druid = pUnit:SpawnCreature(134092, -14, 193.4, -3.3, 1.686005, 35, 54000, 1484, 0, 0)
  139.         CM[id].VAR.sent = pUnit:SpawnCreature(32074, -19, 196, -3.3, 1.686005, 35, 54000)
  140.     elseif CM[id].VAR.i == 10 then
  141.         PlayMessage(CM[id].VAR.TYRANDE, 4)
  142.         CM[id].VAR.druid:MoveTo(-15, 213, -4.9, 1.553163)
  143.         CM[id].VAR.sent:MoveTo(-19, 215, -4.9, 1.553163)
  144.         CM[id].VAR.sent:SetScale(1.5)
  145.     elseif CM[id].VAR.i == 15 then
  146.         PlayMessage(CM[id].VAR.druid, 5)
  147.         CM[id].VAR.TYRANDE:SetFacing(5.295580)
  148.         CM[id].VAR.MALFURION:SetFacing(4.266711)
  149.     elseif CM[id].VAR.i == 24 then
  150.         PlayMessage(CM[id].VAR.TYRANDE, 6)
  151.     elseif CM[id].VAR.i == 28 then
  152.         PlayMessage(CM[id].VAR.sent, 7)
  153.     elseif CM[id].VAR.i == 33 then
  154.         PlayMessage(CM[id].VAR.MALFURION, 8)
  155.     elseif CM[id].VAR.i == 38 then
  156.         PlayMessage(CM[id].VAR.sent, 9)
  157.     elseif CM[id].VAR.i == 50 then
  158.         PlayMessage(CM[id].VAR.TYRANDE, 10)
  159.         CM[id].VAR.TYRANDE:SetFacing(6.241991)
  160.         CM[id].VAR.sent:MoveTo(-17, 178, -3.45, 0)
  161.         CM[id].VAR.druid:MoveTo(-17, 178, -3.45, 0)
  162.         CM[id].VAR.sent = nil
  163.         CM[id].VAR.druid = nil
  164.     elseif CM[id].VAR.i == 56 then
  165.         PlayMessage(CM[id].VAR.MALFURION, 11)
  166.         CM[id].VAR.MALFURION:SetFacing(3.123958)
  167.     elseif CM[id].VAR.i == 59 then
  168.         PlayMessage(CM[id].VAR.TYRANDE, 12)
  169.     elseif CM[id].VAR.i == 63 then
  170.         PlayMessage(CM[id].VAR.MALFURION, 13)
  171.     elseif CM[id].VAR.i == 65 then
  172.         local plr = pUnit:GetClosestPlayer()
  173.         if not plr then
  174.             CM[id].VAR.i = CM[id].VAR.i - 1
  175.         else
  176.             pUnit:RemoveEvents()
  177.             CM[id].VAR.MALFURION:SetUnitToFollow(plr, 2, 1)
  178.             CM[id].VAR.TYRANDE:SetUnitToFollow(plr, 4, 5)
  179.             pUnit:RegisterEvent("CM.VAR.AI_COMBAT", 1000, 0)
  180.         end
  181.     end
  182. end
  183.  
  184. ---------------------------
  185. -- AI
  186. ---------------------------
  187.  
  188. function CM.VAR.AI_COMBAT(pUnit)
  189.     local id = pUnit:GetInstanceID() or 1
  190.     if id == nil then id = 1 end
  191.     AI_HANDLE(CM[id].VAR.MALFURION)
  192.     AI_HANDLE(CM[id].VAR.TYRANDE)
  193. end
  194.  
  195. function AI_HANDLE(pUnit)
  196.     if pUnit:IsInCombat() then
  197.         if pUnit:IsCasting() then
  198.             return
  199.         end
  200.         if pUnit:GetEntry() == 153621 then
  201.             if math.random(1,20) == 1 then
  202.                 local choice = math.random(1,3)
  203.                 if choice == 1 then
  204.                     PlayMessage(pUnit, 39)
  205.                 elseif choice == 2 then
  206.                     PlayMessage(pUnit, 43)
  207.                 elseif choice == 3 then
  208.                     PlayMessage(pUnit, 44)
  209.                 end
  210.             end
  211.             for _,v in pairs(pUnit:GetInRangePlayers()) do
  212.                 if not v:HasAura(48469) then
  213.                     v:FullCastSpellOnTarget(48469,v)
  214.                     return
  215.                 elseif v:GetHealthPct() < 75 then
  216.                     pUnit:FullCastSpellOnTarget(5189, v)
  217.                     return
  218.                 end
  219.             end
  220.         else
  221.             if math.random(1,20) == 1 then
  222.                 if math.random(1,2) == 1 then
  223.                     PlayMessage(pUnit, 45)
  224.                 else
  225.                     PlayMessage(pUnit, 40)
  226.                 end
  227.             end
  228.             local t = pUnit:GetSelection()
  229.             if t then
  230.                 if math.random(1,2) == 1 then
  231.                     pUnit:FullCastSpellOnTarget(9912, t)
  232.                 else
  233.                     pUnit:FullCastSpellOnTarget(8951, t)
  234.                 end
  235.             end
  236.         end
  237.     else
  238.         local p = pUnit:GetUnitToFollow()
  239.         if p then
  240.             if p:IsInCombat() then
  241.                 local t = p:GetSelection()
  242.                 if not t:IsPlayer() then
  243.                     pUnit:AttackReaction(t, 1, 0)
  244.                 end
  245.             end
  246.         else
  247.             local plr = pUnit:GetClosestPlayer()
  248.             if plr then
  249.                 if pUnit:GetEntry() == 153621 then
  250.                     pUnit:SetUnitToFollow(plr, 2, 1)
  251.                 else
  252.                     pUnit:SetUnitToFollow(plr, 4, 5)
  253.                 end
  254.             end
  255.         end
  256.     end
  257. end
  258.  
  259. ---------------------------
  260. -- Trash
  261. ---------------------------
  262.  
  263. function CM.VAR.IntroNaga(pUnit)
  264.     PlayMessage(pUnit, 42)
  265. end
  266.  
  267. function CM.VAR.ExtraNagaMessage(pUnit)
  268.     PlayMessage(pUnit, 39)
  269. end
  270.  
  271. function CM.VAR.NagaEvents(pUnit, Event)
  272.     if Event == 1 then
  273.         local id = pUnit:GetInstanceID() or 1
  274.         if id == nil then id = 1 end
  275.         if not CM.VAR.pn then
  276.             CM.VAR.pn = true
  277.             PlayMessage(CM.VAR.TYRANDE, 46)
  278.             pUnit:RegisterEvent("CM.VAR.IntroNaga", 4000, 1)
  279.             CM.VAR.TYRANDE:RegisterEvent("CM.VAR.ExtraNagaMessage", 10000, 1)
  280.         end
  281.         if pUnit:GetEntry() == 112571 then -- warrior
  282.             if math.random(1,10) == 1 then
  283.                 pUnit:SendChatMessage(14,0,"Crush the interlopers!")
  284.             end
  285.             if math.random(1,2) == 1 then
  286.                 for _,v in pairs(pUnit:GetInRangeUnits()) do
  287.                     if not v:IsInCombat() then
  288.                         if v:GetDistanceYards(pUnit) < 30 then
  289.                             v:AttackReaction(pUnit:GetSelection(), 1, 0)
  290.                         end
  291.                     end
  292.                 end
  293.             end
  294.             if math.random(1,2) == 1 then
  295.                 local t = pUnit:GetMainTank()
  296.                 if t then
  297.                     pUnit:FullCastSpellOnTarget(40602, t) -- charge
  298.                 else
  299.                     pUnit:CastSpell(27578)
  300.                 end
  301.             end
  302.             pUnit:RegisterEvent("CM.VAR.MeleeAI", 7000, 0)
  303.         else
  304.             if math.random(1,10) == 1 then
  305.                 pUnit:SendChatMessage(14,0,"You cannot harm us!")
  306.             end
  307.             if math.random(1,2) == 1 then
  308.                 pUnit:FullCastSpell(12544)
  309.             else
  310.                 pUnit:FullCastSpell(35064)
  311.             end
  312.             pUnit:RegisterEvent("CM.VAR.CasterNaga", 6000, 0)
  313.         end
  314.     else
  315.         pUnit:RemoveEvents()
  316.     end
  317. end
  318.  
  319. function CM.VAR.CasterNaga(pUnit)
  320.     if pUnit:IsCasting() then
  321.         return
  322.     end
  323.     for _,v in pairs(pUnit:GetInRangeUnits()) do
  324.         if v:GetHealthPct() < 70 then
  325.             pUnit:FullCastSpellOnTarget(48894,v)
  326.             return
  327.         end
  328.     end
  329.     local t = pUnit:GetMainTank()
  330.     if t then
  331.         pUnit:FullCastSpellOnTarget(16799,t)
  332.     end
  333. end
  334.  
  335. function CM.VAR.MeleeAI(pUnit)
  336.     local t = pUnit:GetMainTank()
  337.     if not t then
  338.         return
  339.     end
  340.     if t:GetDistanceYards(pUnit) > 6 then
  341.         return
  342.     end
  343.     if math.random(1,2) == 1 then
  344.         pUnit:FullCastSpellOnTarget(69651, t)
  345.     else
  346.         pUnit:FullCastSpellOnTarget(60590, t)
  347.     end
  348. end
  349.  
  350. RegisterUnitEvent(112571, 1, "CM.VAR.NagaEvents")
  351. RegisterUnitEvent(112571, 2, "CM.VAR.NagaEvents")
  352. RegisterUnitEvent(112571, 4, "CM.VAR.NagaEvents")
  353. RegisterUnitEvent(112572, 1, "CM.VAR.NagaEvents")
  354. RegisterUnitEvent(112572, 2, "CM.VAR.NagaEvents")
  355. RegisterUnitEvent(112572, 4, "CM.VAR.NagaEvents")
  356.  
  357. ---------------------------
  358. -- Misc Functions
  359. ---------------------------
  360.  
  361. function PlayMessage(u, s)
  362.     if not u then
  363.         return
  364.     end
  365.     local m = SOUNDS[s][2]
  366.     if m then
  367.         if SOUNDS[s][3] then
  368.             u:SendChatMessage(14,0,m)
  369.             u:Emote(5,0)
  370.         else
  371.             u:SendChatMessage(12,0,m)
  372.             u:Emote(1,0)
  373.         end
  374.         if SOUNDS[s][1] then
  375.             u:PlaySoundToSet(SOUNDS[s][1])
  376.         end
  377.     else
  378.         if SOUNDS[s][1] then
  379.             u:PlayMusicToSet(SOUNDS[s][1])
  380.         end
  381.     end
  382. end
Advertisement
Add Comment
Please, Sign In to add comment