stoneharry

Untitled

May 27th, 2016
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.25 KB | None | 0 0
  1.  
  2. local _debug = true
  3. local AI_COUNT = 0
  4. local WALKING_SPEED = 0.4
  5.  
  6. -- Starting creatures
  7.  
  8. local function WaitForSpawn(_, _, _, pUnit)
  9.     -- 90005
  10.     local t = pUnit:GetPlayersInRange(60)
  11.     if #t == 0 then
  12.         return
  13.     end
  14.     PerformIngameSpawn(2, 90005, 0, 0, -9137, 412, 94, 5.055)
  15.     PerformIngameSpawn(2, 90005, 0, 0, -9114.8, 352.9, 93, 1.98421)
  16.     PerformIngameSpawn(2, 90005, 0, 0, -9126.4, 347.9, 93.4, 1.886035)
  17.     local spawns = {
  18.         {-9107.34,378.771,93.7351,1.19195},
  19.         {-9148.14,381.923,90.8808,4.05001},
  20.         {-9139.4,391.125,90.9324,5.54541},
  21.         {-9124.53,379.778,90.9475,1.43307},
  22.         {-9125.97,380.123,90.8001,1.22022},
  23.         {-9126.15,352.181,93.5358,1.83677},
  24.         {-9128.88,351.219,93.4407,1.64827},
  25.         {-9114.75,357.097,93.3318,2.05747},
  26.         {-9136.23,408.33,94.4238,5.17581},
  27.         {-9134.04,408.899,94.3046,5.13514}
  28.     }
  29.     for _,t in pairs(spawns) do
  30.         local entry
  31.         if math.random(1,2) == 1 then
  32.             entry = 90066
  33.         else
  34.             entry = 90064
  35.         end
  36.         pUnit:SpawnCreature(entry, t[1], t[2], t[3], t[4])
  37.     end
  38.     pUnit:RemoveEvents()
  39. end
  40.  
  41. local function CheckCanSpawn(_, _, _, pUnit)
  42.     if GetSiegeStage() == 1 then
  43.         local a,b = GetResourceData(12)
  44.         if a == b then
  45.             pUnit:RemoveEvents()
  46.             pUnit:SetFaction(814)
  47.             pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 0)
  48.             if pUnit:GetEntry() == 90072 then
  49.                 pUnit:SetDisplayId(16012)
  50.                 pUnit:SetEquipmentSlots(28905, 28754, 0)
  51.             else
  52.                 pUnit:SetNPCFlags(1)
  53.                 pUnit:SetDisplayId(10469)
  54.                 pUnit:SetEquipmentSlots(13316, 0, 0)
  55.                 pUnit:RegisterEvent(WaitForSpawn, 1000, 0)
  56.             end
  57.             pUnit:Mount(28918)
  58.         end
  59.     end
  60. end
  61.  
  62. local function StartSpawn(event, pUnit)
  63.     pUnit:SetNPCFlags(0)
  64.     pUnit:SetDisplayId(15294)
  65.     pUnit:SetFaction(35)
  66.     pUnit:SetEquipmentSlots(0, 0, 0)
  67.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FIELD_FLAG_UNTARGETABLE)
  68.     pUnit:RegisterEvent(CheckCanSpawn, 10000, 0)
  69. end
  70.  
  71. RegisterCreatureEvent(90071, 5, StartSpawn)
  72. RegisterCreatureEvent(90072, 5, StartSpawn)
  73.  
  74. -- spawning scourge
  75.  
  76. local function ScourgeboltSpam(_, _, _, pUnit)
  77.     local plr = pUnit:GetAITarget(0) -- random target
  78.     if plr then
  79.         pUnit:CastSpell(plr, 90032)
  80.     end
  81. end
  82.  
  83. local function CombatAbberation(event, pUnit)
  84.     pUnit:RegisterEvent(ScourgeboltSpam, 8000, 0)
  85. end
  86.  
  87. local function DespawnSelf(event, pUnit)
  88.     pUnit:RemoveEvents()
  89.     pUnit:DespawnOrUnsummon(5000)
  90. end
  91.  
  92. local function LookingForPlayers(_, _, _, pUnit)
  93.     if pUnit:IsInCombat() then
  94.         return
  95.     end
  96.     local p = pUnit:GetNearestPlayer(40)
  97.     if p then
  98.         pUnit:AttackStart(p)
  99.     end
  100. end
  101.  
  102. local function ContinueMove(_,_,_, pUnit)
  103.     pUnit:MoveTo(0, -math.random(9029, 9030), math.random(455,465), 93.8)
  104. end
  105.  
  106. local function ScourgeSpawn(event, pUnit)
  107.     pUnit:SetHomePosition(-math.random(9029, 9030), math.random(455,465), 93.8, 0)
  108.     pUnit:MoveTo(0, -math.random(8942, 8965), math.random(513, 528), 96.4)
  109.     pUnit:RegisterEvent(ContinueMove, 12000, 1)
  110.     if pUnit:GetEntry() == 90075 then
  111.         pUnit:RegisterEvent(LookingForPlayers, 1000, 0)
  112.     end
  113. end
  114.  
  115. RegisterCreatureEvent(90073, 5, ScourgeSpawn)
  116. RegisterCreatureEvent(90075, 5, ScourgeSpawn)
  117. RegisterCreatureEvent(90075, 4, DespawnSelf)
  118. RegisterCreatureEvent(90075, 1, CombatAbberation)
  119.  
  120. -- Event start
  121.  
  122. local function KillSelf(_, _, _, pUnit)
  123.     pUnit:Kill(pUnit)
  124.     pUnit:DespawnOrUnsummon(5000)
  125. end
  126.  
  127. local function SpawnScourgeSpam(_, _, _, pUnit)
  128.     local x,y
  129.     local z = 95
  130.     for i=1,math.random(1,6) do
  131.         x = -math.random(8928, 8929)
  132.         y = math.random(530, 549)
  133.         pUnit:SpawnCreature(90073, x, y, z, 0, 1, 60000)
  134.     end
  135.     local t = pUnit:GetCreaturesInRange(10, 90073)
  136.     for _,v in pairs(t) do
  137.         pUnit:CastSpell(v, 10689)
  138.         v:SetHealth(1)
  139.         v:RegisterEvent(KillSelf, 1900, 1)
  140.     end
  141. end
  142.  
  143. local function BeginAIMarch(_, _, _, pUnit)
  144.     if AI_COUNT == 5 then
  145.         pUnit:Emote(5)
  146.         pUnit:SendUnitYell("Today we take back Stormwind from the Scourge!", 0)
  147.     elseif AI_COUNT == 12 then
  148.         pUnit:SendUnitYell("For the Argent Dawn!", 0)
  149.         pUnit:Emote(25)
  150.         pUnit:SetSpeed(1, WALKING_SPEED)
  151.         pUnit:MoveTo(0, -9043.7, 451.1, 93.06)
  152.         local entry
  153.         for _,v in pairs(pUnit:GetNearObjects(30)) do
  154.             entry = v:GetEntry()
  155.             if entry == 90064 or entry == 90066 then
  156.                 v:MoveFollow(pUnit, math.random(4, 10), math.random(0, 360))
  157.             end
  158.         end
  159.         local c = GetCreature(10, 90072, pUnit)
  160.         c:SetSpeed(1, WALKING_SPEED)
  161.         c:MoveTo(0, -9041.56, 448.5, 93.06)
  162.     elseif AI_COUNT == 45 then
  163.         pUnit:PlayMusic(17313)
  164.         local c = GetCreature(10, 90072, pUnit)
  165.         c:SendUnitSay("Where are the Scourge? Why has the bloodshed not begun?")
  166.         c:Emote(1)
  167.     elseif AI_COUNT == 51 then
  168.         pUnit:Emote(1)
  169.         pUnit:SendUnitSay("I don't know, but I don't like it.")
  170.         pUnit:RegisterEvent(SpawnScourgeSpam, 1000, 0)
  171.     elseif AI_COUNT == 53 then
  172.         local c = pUnit:SpawnCreature(90074, -9004.24, 481.14, 96.57, 3.84628)
  173.         c:CastSpell(c, 26638)
  174.     elseif AI_COUNT == 54 then
  175.         local c = GetCreature(55, 90074, pUnit)
  176.         c:SendUnitYell("You have foolishly waltzed straight into my sanctuary. Now watch as your bravery leads to your demise!", 0)
  177.         c:Emote(5)
  178.     elseif AI_COUNT == 60 then
  179.         pUnit:SendUnitSay("Quick! Defend me and I'll hold them off. The light shall prevail!")
  180.         pUnit:Dismount()
  181.         local c = GetCreature(10, 90072, pUnit)
  182.         c:Dismount()
  183.         pUnit:MoveTo(0, -9032.7, 458.8, 93)
  184.     elseif AI_COUNT == 62 then
  185.         local c = GetCreature(55, 90074, pUnit)
  186.         c:CastSpell(c, 26638)
  187.         c:DespawnOrUnsummon(1000)
  188.         local entry
  189.         local x = -9042.4
  190.         local y = 460.8
  191.         for _,v in pairs(pUnit:GetNearObjects(30)) do
  192.             entry = v:GetEntry()
  193.             if entry == 90064 or entry == 90066 then
  194.                 v:SetSpeed(1, 1)
  195.                 v:MoveTo(0, x, y, 93.3)
  196.                 x = x + 1.1
  197.                 y = y - 1.1
  198.             end
  199.         end
  200.     elseif AI_COUNT == 65 then
  201.         pUnit:SpawnCreature(90075, -8927.5, 541.2, 94.31, 0, 1, 300000)
  202.         pUnit:CastSpell(pUnit, 63772)
  203.         pUnit:SetRooted(true)
  204.         local entry
  205.         for _,v in pairs(pUnit:GetNearObjects(20)) do
  206.             entry = v:GetEntry()
  207.             if entry == 90064 or entry == 90066 then
  208.                 v:SetInt32Value(UNIT_NPC_EMOTESTATE, 375)
  209.                 v:SetFacing(0.943)
  210.                 v:SetRooted(true)
  211.                 v:SetHomePosition(v:GetX(), v:GetY(), v:GetZ(), v:GetO())
  212.             end
  213.         end
  214.         local c = GetCreature(20, 90072, pUnit)
  215.         c:SendUnitSay("Hold back heroes, the Argent Dawn can take this fight. I fear that this is merely a distraction. Be on alert.")
  216.         c:Emote(1)
  217.         c:SetFaction(35)
  218.     elseif AI_COUNT == 74 then
  219.         pUnit:SendUnitSay("Heroes, I cannot stop that aberration - it is too big!")
  220.     elseif AI_COUNT == 80 then
  221.         local c = GetCreature(80, 90075, pUnit)
  222.         if c and c:IsAlive() then
  223.             AI_COUNT = AI_COUNT - 1
  224.         end
  225.     elseif AI_COUNT == 81 then
  226.         pUnit:SendUnitSay("One aberration dead, they cannot have the resources to send another.")
  227.         pUnit:SpawnCreature(90075, -8927.5, 541.2, 94.31, 0, 1, 300000)
  228.     elseif AI_COUNT == 88 then
  229.         pUnit:SendUnitSay("Blast, I see another coming. Watch out heroes!")
  230.     elseif AI_COUNT == 95 then
  231.         local c = GetCreature(80, 90075, pUnit)
  232.         if c and c:IsAlive() then
  233.             AI_COUNT = AI_COUNT - 1
  234.         end
  235.     elseif AI_COUNT == 96 then
  236.         pUnit:RemoveEvents()
  237.         pUnit:RegisterEvent(BeginAIMarch, 1000, 0)
  238.         pUnit:SendUnitSay("Let us hope that is the last of the aberrations.")
  239.         local t = pUnit:GetCreaturesInRange(10, 90073)
  240.         for _,v in pairs(t) do
  241.             pUnit:CastSpell(v, 10689)
  242.             v:SetHealth(1)
  243.             v:RegisterEvent(KillSelf, 1900, 1)
  244.         end
  245.     elseif AI_COUNT > 96 and AI_COUNT < 122 then
  246.         local t = pUnit:GetCreaturesInRange(10, 90073)
  247.         for _,v in pairs(t) do
  248.             pUnit:CastSpell(v, 10689)
  249.             v:SetHealth(1)
  250.             v:RegisterEvent(KillSelf, 1900, 1)
  251.         end
  252.     elseif AI_COUNT == 123 then
  253.         pUnit:RemoveAura(63772)
  254.         pUnit:SendUnitSay("That was exhausting. It makes the undead really seem endless.")
  255.         pUnit:Emote(1)
  256.     elseif AI_COUNT == 127 then
  257.         pUnit:SendUnitSay("Heroes, meet me near the trade district when you are ready to continue our assault on Stormwind.")
  258.         pUnit:Emote(1)
  259.     elseif AI_COUNT == 134 then
  260.         local entry
  261.         for _,v in pairs(pUnit:GetNearObjects(30)) do
  262.             entry = v:GetEntry()
  263.             if entry == 90064 or entry == 90066 or entry == 90072 then
  264.                 v:DespawnOrUnsummon(0)
  265.             end
  266.         end
  267.         pUnit:DespawnOrUnsummon(0)
  268.         pUnit:RemoveEvents()
  269.         SetSiegeStage(2)
  270.         return
  271.     end
  272.     AI_COUNT = AI_COUNT + 1
  273. end
  274.  
  275. local function StartEvent(_, _, _, pUnit)
  276.     pUnit:PlayMusic(17314)
  277.     pUnit:SendUnitYell("Men, form up!", 0)
  278.     pUnit:Emote(25)
  279.     local entry
  280.     for _,v in pairs(pUnit:GetNearObjects(50)) do
  281.         entry = v:GetEntry()
  282.         if entry == 90064 or entry == 90066 then
  283.             v:SetSpeed(1, WALKING_SPEED)
  284.             v:MoveTo(0, pUnit:GetRelativePoint(math.random(4, 10), math.random(0, 360)))
  285.         end
  286.     end
  287.     AI_COUNT = 0
  288.     pUnit:RegisterEvent(BeginAIMarch, 1000, 0)
  289. end
  290.  
  291. -- Gossip start
  292.  
  293. local function SiegeGossip1(event, player, pUnit)
  294.     player:GossipMenuAddItem(9, "We are ready.", 0, 1)
  295.     player:GossipMenuAddItem(0, "Nevermind.", 0, 0)
  296.     player:GossipSendMenu(90000, pUnit)
  297. end
  298.  
  299. local function SiegeGossip2(event, player, pUnit, sender, initid, code)
  300.     if initid == 1 then
  301.         local t = pUnit:GetPlayersInRange(40)
  302.         if #t >= 5 or _debug then
  303.             pUnit:SetNPCFlags(0)
  304.             pUnit:RegisterEvent(StartEvent, 1000, 1)
  305.         else
  306.             player:SendBroadcastMessage("There are not enough players nearby to start the event. There needs to be five people minimum.")
  307.         end
  308.     end
  309.     player:GossipComplete()
  310. end
  311.  
  312. RegisterCreatureGossipEvent(90071, 1, SiegeGossip1)
  313. RegisterCreatureGossipEvent(90071, 2, SiegeGossip2)
Advertisement
Add Comment
Please, Sign In to add comment