stoneharry

Untitled

Nov 3rd, 2011
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.57 KB | None | 0 0
  1.  
  2. -- By Stoneharry
  3.  
  4. local Ulda = {}
  5.  
  6. local OBJECT_END = 0x0006
  7. local UNIT_FIELD_BYTES_2 = OBJECT_END + 0x0074 -- Size: 1, Type: BYTES, Flags: PUBLIC
  8. local UNIT_FIELD_FLAGS = OBJECT_END + 0x0035 -- Size: 1, Type: INT, Flags: PUBLIC
  9. local UNIT_FLAG_NOT_SELECTABLE = 0x02000000 -- 26    33554432  cannot select the unit
  10.  
  11. local ready = false
  12. local i = 0
  13.  
  14. local UldamanInfo = {}
  15.  
  16. UldamanLocations = { -- in format as x, y, z, o, registertime
  17.     {
  18.         {-6124.356445, -3313.370117, 266.941101, 0, 2000},
  19.         {-6146.251953, -3347.607666, 273.031586, 0, 6000},
  20.         {-6182.091797, -3362.557129, 274.688446, 0, 6000},
  21.         {-6223.678223, -3388.206787, 274.688446, 0, 7000},
  22.         {-6261.023926, -3442.613525, 274.688446, 0, 9000},
  23.         {-6294.992676, -3481.985352, 282.688446, 0, 7500},
  24.         {-6328.961426, -3521.356934, 282.688446, 0, 7000},
  25.         {-6383.515137, -3573.903320, 282.688446, 0, 10000},
  26.         {-6437.695801, -3607.957764, 282.688446, 0, 10000},
  27.         {-6488.143066, -3625.346191, 282.688446, 0, 9000},
  28.         {-6535.789551, -3631.161377, 282.688446, 0, 7000},
  29.         {-6569.892578, -3636.962891, 282.688446, 0, 4000},
  30.         {-6594.637207, -3657.114258, 274.688446, 0, 4000},
  31.         {-6606.420898, -3690.925049, 269.328461, 0, 5000},
  32.         {-6613.697754, -3710.938232, 269.328461, 0, 3000},
  33.         {1, 1, 1, 1, 1}
  34.     }
  35. }
  36.  
  37. -- Stone Titan - Handles mobs incoming and messages etc
  38.  
  39. function MainTitanUldaman_OnSpawn(pUnit, Event)
  40.     pUnit:RegisterEvent("Wait_For_Spawn_UldamanTitan", 1000, 1)
  41.     pUnit:SetFaction(35)
  42.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  43. end
  44.  
  45. function Wait_For_Spawn_UldamanTitan(pUnit)
  46.     pUnit:SetFaction(35)
  47.     pUnit:FullCastSpell(15533) -- stone state visual
  48.     pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE)
  49.     pUnit:RegisterEvent("EquipWeaponUldamanTitan", 4000, 1)
  50. end
  51.  
  52. function EquipWeaponUldamanTitan(pUnit)
  53.     pUnit:EquipWeapons(12796, 0, 0)
  54.     pUnit:SetUInt32Value(UNIT_FIELD_BYTES_2, 1)
  55.     Ulda.captain = pUnit:GetUnitBySqlId(9271259)
  56.     Ulda.dwarfa = pUnit:GetUnitBySqlId(9271263)
  57.     Ulda.dwarfb = pUnit:GetUnitBySqlId(9271261)
  58.     Ulda.dwarfc = pUnit:GetUnitBySqlId(9271260)
  59.     Ulda.ballista = pUnit:GetUnitBySqlId(9271324)
  60.     Ulda.main = pUnit:GetUnitBySqlId(9271616)
  61.     pUnit:RegisterEvent("Send_EnemiesToUlda_pUnit", 4000, 0)
  62.     pUnit:RegisterEvent("PLayRepetativeMusic", 60000, 0)
  63.     Ulda.captain:PlaySoundToSet(17673) -- Battle Music
  64. end
  65.  
  66. function PLayRepetativeMusic(pUnit)
  67.     Ulda.captain:PlaySoundToSet(17673) -- Battle Music
  68.     if Ulda.captain:GetSelection() ~= nil then
  69.         if Ulda.captain:GetSelection():GetEntry() ~= 239131 then
  70.             Ulda.captain:Despawn(1,1)
  71.         end
  72.     end
  73. end
  74.  
  75. function Send_EnemiesToUlda_pUnit(pUnit)
  76.     if math.random(1,10) == 5 then
  77.         local choice = math.random(1,4)
  78.         if choice == 1 then
  79.             if math.random(1,2) == 1 then
  80.                 Ulda.captain:SendChatMessage(12,0,"Hold your ground!")
  81.             else
  82.                 Ulda.captain:SendChatMessage(12,0,"Where are those ballista!?")
  83.             end
  84.         elseif choice == 2 then
  85.             Ulda.dwarfa:SendChatMessage(12,0,"Ugh-")
  86.         elseif choice == 3 then
  87.             Ulda.dwarfb:SendChatMessage(12,0,"Another one bites the dust.")
  88.         elseif choice == 4 then
  89.             Ulda.dwarfc:SendChatMessage(12,0,"They just don't stop!")
  90.         end
  91.     end
  92.     if (ready) then
  93.         pUnit:RemoveEvents()
  94.         pUnit:RegisterEvent("MainEvent_Handler_Go", 7500, 1)
  95.     else
  96.         pUnit:SpawnCreature(239131, -6080.8, -3160.8, 254.5, 3.644125, 21, 30000)
  97.     end
  98. end
  99.  
  100. RegisterUnitEvent(259271, 18, "MainTitanUldaman_OnSpawn")
  101.  
  102. function MainTitanUldaman_OnDead(pUnit, Event)
  103.     pUnit:RemoveEvents()
  104. end
  105.  
  106. RegisterUnitEvent(259271, 4, "MainTitanUldaman_OnDead")
  107.  
  108. -- The adds
  109.  
  110. function DreadBatburroweronspawn(pUnit, Event)
  111.     pUnit:RegisterEvent("BirrwerAttack_Ulda", 1000, 1)
  112.     local choice = math.random(1,3)
  113.     if choice == 1 then
  114.         pUnit:MoveTo(6102.8, -3234.1, 261.4, 0)
  115.     elseif choice == 2 then
  116.         pUnit:MoveTo(-6112.3, -3234.6, 260.8, 0)
  117.     elseif choice == 3 then
  118.         pUnit:MoveTo(-6120.6, -3234, 263.2, 0)
  119.     end
  120. end
  121.  
  122. function BirrwerAttack_Ulda(pUnit)
  123.     pUnit:SetMovementFlags(1)
  124.     local choice = math.random(1,3)
  125.     if choice == 1 then
  126.         pUnit:MoveTo(6102.8, -3234.1, 261.4, 0)
  127.     elseif choice == 2 then
  128.         pUnit:MoveTo(-6112.3, -3234.6, 260.8, 0)
  129.     elseif choice == 3 then
  130.         pUnit:MoveTo(-6120.6, -3234, 263.2, 0)
  131.     end
  132.     pUnit:ChangeTarget(Ulda.captain)
  133.     pUnit:RegisterEvent("KeepAttacking", 250, 0)
  134. end
  135.  
  136. function KeepAttacking(pUnit)
  137.     if pUnit then
  138.         if pUnit:IsAlive() then
  139.             pUnit:ChangeTarget(Ulda.captain)
  140.         else
  141.             pUnit:RemoveEvents()
  142.         end
  143.     end
  144. end
  145.  
  146. RegisterUnitEvent(239131, 18, "DreadBatburroweronspawn")
  147.  
  148. -- The snipers
  149.  
  150. function DwarfSniper_Uldaman(pUnit, Event)
  151.     if pUnit:GetPhase() == 1 then
  152.         pUnit:RegisterEvent("PrepareToShoot_Sniper", math.random(2000, 4000), 0)
  153.     end
  154. end
  155.  
  156. function PrepareToShoot_Sniper(pUnit)
  157.     for place,creature in pairs(pUnit:GetInRangeUnits()) do
  158.         if creature:GetEntry() == 239131 then
  159.             if (not creature:IsAlive()) then
  160.                 creature:RemoveEvents()
  161.                 creature:Despawn(1,0)
  162.             else
  163.                 if pUnit:GetDistanceYards(creature) < 30 then
  164.                     if math.random(1,20) == 5 then
  165.                         Ulda.ballista:FullCastSpellOnTarget(53117, creature)
  166.                         creature:CastSpell(11) -- suicide
  167.                     else
  168.                         pUnit:CastSpellOnTarget(30221, creature)
  169.                     end
  170.                     break -- stop checking
  171.                 end
  172.             end
  173.         end
  174.     end
  175. end
  176.  
  177. RegisterUnitEvent(158352, 18, "DwarfSniper_Uldaman")
  178.  
  179. -- The main guy
  180.  
  181. function TheLight_Guy_Uldamanclick(pUnit, event, player)
  182.     if pUnit:GetPhase() == 1 then
  183.         pUnit:GossipCreateMenu(7362, player, 0)
  184.         if player:HasQuest(6508) == true then
  185.             pUnit:GossipMenuAddItem(9, "I am here, Brom.", 11, 0)
  186.         end
  187.         pUnit:GossipMenuAddItem(0, "Nevermind Brom.", 3, 0)
  188.         pUnit:GossipSendMenu(player)
  189.     end
  190. end
  191.  
  192. function TheLight_Guy_Uldamangossip(pUnit, event, player, id, intid, code)
  193.     if(intid == 11) then
  194.         player:GossipComplete()
  195.         pUnit:SendChatMessage(12,0,"Good, now I am going to attempt to seal this tunnel.")
  196.         pUnit:SetNPCFlags(2)
  197.         ready = true
  198.     end
  199.     if(intid == 3) then
  200.         player:GossipComplete()
  201.     end
  202. end
  203.  
  204. RegisterUnitGossipEvent(225101, 1, "TheLight_Guy_Uldamanclick")
  205. RegisterUnitGossipEvent(225101, 2, "TheLight_Guy_Uldamangossip")
  206.  
  207. -- Main event handler
  208.  
  209. function MainEvent_Handler_Go(pUnit)
  210.     if i == 0 then
  211.         Ulda.main:SendChatMessage(12,0,"That's odd, they appear to have stopped coming out of the tunnel.")
  212.         pUnit:RegisterEvent("MainEvent_Handler_Go", 4000, 1)
  213.     elseif i == 1 then
  214.         Ulda.main:PlaySoundToSet(6077)
  215.         pUnit:RemoveAura(15533) -- stone state visual
  216.         pUnit:FullCastSpell(10347) -- Awaken Visual
  217.         pUnit:RegisterEvent("MainEvent_Handler_Go", 3000, 1)
  218.     elseif i == 2 then
  219.         pUnit:SetUInt32Value(UNIT_FIELD_FLAGS, 2) -- unattackable
  220.         pUnit:SetFaction(21)
  221.         pUnit:MoveKnockback(-6088, -3201, 255.5, 5, 10)
  222.         Ulda.main:Emote(45, 30000)
  223.         pUnit:RegisterEvent("MainEvent_Handler_Go", 1850, 1)
  224.     elseif i == 3 then
  225.         pUnit:Root()
  226.         Ulda.main:SendChatMessage(12,0,"What foul manner of creature is this?!")
  227.         pUnit:RegisterEvent("MainEvent_Handler_Go", 4000, 1)
  228.     elseif i == 4 then
  229.         pUnit:SendChatMessage(14,0,"You were foolish to think you could disturb the Titans without awakening me. You shall all be punished.")
  230.         pUnit:SetScale(1.1)
  231.         pUnit:RegisterEvent("MainEvent_Handler_Go", 2000, 1)
  232.     elseif i == 5 then
  233.         pUnit:SetScale(1.25)
  234.         pUnit:RegisterEvent("MainEvent_Handler_Go", 2000, 1)
  235.     elseif i == 6 then
  236.         pUnit:SetScale(1.5)
  237.         pUnit:RegisterEvent("MainEvent_Handler_Go", 2000, 1)
  238.     elseif i == 7 then
  239.         pUnit:SetScale(1.75)
  240.         Ulda.main:SendChatMessage(14,0,"May light protect me!")
  241.         Ulda.main:CastSpell(70571) -- visual
  242.         pUnit:RegisterEvent("MainEvent_Handler_Go", 500, 1)
  243.     elseif i == 8 then
  244.         pUnit:SetScale(1.85)
  245.         pUnit:Emote(38, 1500)
  246.         pUnit:RegisterEvent("MainEvent_Handler_Go", 4000, 1)
  247.     elseif i == 9 then
  248.         pUnit:SendChatMessage(14,0,"Your gods will not save you.")
  249.         pUnit:CastSpell(64785) -- Lightning visual
  250.         pUnit:FullCastSpell(52893) -- summon adds
  251.         pUnit:RegisterEvent("MainEvent_Handler_Go", 5500, 1)
  252.     elseif i == 10 then
  253.         Ulda.main:PlaySoundToSet(14556) -- Scream
  254.         Ulda.main:PlaySoundToSet(11836) -- Explosion
  255.         for place,plrs in pairs(Ulda.main:GetInRangePlayers()) do
  256.             if plrs:GetDistanceYards(Ulda.main) < 30 then
  257.                 if plrs:GetPhase() == 1 then
  258.                     plrs:MoveKnockback(-6049.7, -3333, 263, 5, 5)
  259.                     plrs:CastSpell(61456) -- visual
  260.                     if plrs:HasQuest(6508) then
  261.                         plrs:MarkQuestObjectiveAsComplete(6508, 0)
  262.                     end
  263.                     plrs:SetPhase(2)
  264.                 end
  265.             end
  266.         end
  267.         ready = false
  268.         Ulda.main:SetNPCFlags(1)
  269.         Ulda.main:RemoveAura(70571)
  270.         pUnit:SetScale(1)
  271.         pUnit:Unroot()
  272.         pUnit:SetPosition(-6092.3, -3183.9, 268.2, 4.985440)
  273.         pUnit:EquipWeapons(0,0,0)
  274.         i = 0
  275.         pUnit:RegisterEvent("MainTitanUldaman_OnSpawn", 5000, 1)
  276.     end
  277.     i = i + 1
  278. end
  279.  
  280. -- Transport vehicle part
  281.  
  282. function UldamanQuestAccept(event, player, questId, pQuestGiver)
  283.     if (questId == 6509) then -- Badlands, transport to uldaman side enterence quest
  284.         player:SetPhase(1)
  285.         player:SetModel(28476) -- box
  286.         player:SetScale(0.2)
  287.         player:SpawnAndEnterVehicle(288301, 1000)
  288.         local vehicle = player:GetCreatureNearestCoords(player:GetX(), player:GetY(), player:GetZ(), 288301)
  289.         UldamanInfo[tostring(vehicle)] = {
  290.             track = 1,
  291.             racecount = 1,
  292.             player = player,
  293.             vehicle = vehicle
  294.         }
  295.         RegisterTimedEvent("Uldaman_TrackGo", 1500, 1, vehicle)
  296.     end
  297. end
  298.  
  299.  
  300. RegisterServerHook(14, "UldamanQuestAccept")
  301.  
  302. function Uldaman_TrackGo(pUnit)
  303.     pUnit:CastSpell(60534)
  304.     pUnit:SetMovementFlags(2)
  305.     --pUnit:SendChatMessage(12,0, "POINT: "..UldamanInfo[tostring(pUnit)].racecount..".")
  306.     if UldamanInfo[tostring(pUnit)].racecount == #UldamanLocations[UldamanInfo[tostring(pUnit)].track] then
  307.         -- Were done
  308.         if UldamanInfo[tostring(pUnit)].vehicle ~= nil then
  309.             UldamanInfo[tostring(pUnit)].vehicle:EjectAllPassengers()
  310.         end
  311.         if UldamanInfo[tostring(pUnit)].player ~= nil then
  312.             UldamanInfo[tostring(pUnit)].player:DeMorph()
  313.             UldamanInfo[tostring(pUnit)].player:SetScale(1)
  314.         end
  315.         pUnit:Despawn(1000, 0)
  316.         return
  317.     end
  318.     pUnit:MoveTo(UldamanLocations[UldamanInfo[tostring(pUnit)].track][UldamanInfo[tostring(pUnit)].racecount][1],UldamanLocations[UldamanInfo[tostring(pUnit)].track][UldamanInfo[tostring(pUnit)].racecount][2],UldamanLocations[UldamanInfo[tostring(pUnit)].track][UldamanInfo[tostring(pUnit)].racecount][3],UldamanLocations[UldamanInfo[tostring(pUnit)].track][UldamanInfo[tostring(pUnit)].racecount][4])
  319.     -- Register the event again (recursion)
  320.     RegisterTimedEvent("Uldaman_TrackGo", UldamanLocations[UldamanInfo[tostring(pUnit)].track][UldamanInfo[tostring(pUnit)].racecount][5], 1, pUnit)
  321.     -- Add to the counter
  322.     UldamanInfo[tostring(pUnit)].racecount = UldamanInfo[tostring(pUnit)].racecount + 1
  323. end
  324.  
  325.  
  326.    
  327.  
Advertisement
Add Comment
Please, Sign In to add comment