stoneharry

Untitled

Jul 29th, 2011
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.94 KB | None | 0 0
  1. -- By Stoneharry
  2.  
  3. -- Variables
  4.  
  5. CHAL = {}
  6. CHAL.VAR = {}
  7.  
  8. local guy
  9.  
  10. local OBJECT_END = 0x0006
  11. local GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B
  12.  
  13. -- spawn 191101
  14. -- left
  15. -- SpawnA = 5276, 2037, 710
  16. -- right
  17. -- SpawnB = 5340, 1976, 710
  18. -- move to 5309, 2006, 708.44, 0
  19. -- Terenas
  20.  
  21. function CHAL.VAR.TERENAS_GOSSIP_CLICK(pUnit, event, player)
  22.     guy = pUnit
  23.     pUnit:GossipCreateMenu(1039, player, 0)
  24.     pUnit:GossipMenuAddItem(9, "Start the challenge.", 2, 0)
  25.     pUnit:GossipMenuAddItem(0, "Nevermind.", 1, 0)
  26.     pUnit:GossipSendMenu(player)
  27. end
  28.  
  29. function CHAL.VAR.TERENAS_GOSSIP_GOSSIP(pUnit, event, player, id, intid, code)
  30.     if intid == 2 then
  31.         if player:IsInGroup() then
  32.             pUnit:SendChatMessage(12,0,"You must face these challenges alone, "..player:GetName()..".")
  33.         else
  34.             local id = 2
  35.             CHAL[id] = CHAL[id] or {VAR={}}
  36.             local found = false
  37.             while (not found) do
  38.                 CHAL[id] = CHAL[id] or {VAR={}}
  39.                 if CHAL[id].VAR.player ~= nil then
  40.                     id = id*2
  41.                 else
  42.                     found = true
  43.                     CHAL[id].VAR.player = player
  44.                     CHAL[id].VAR.i = 0
  45.                     player:SetPhase(id)
  46.                     CHAL[id].VAR.girl = guy:SpawnCreature(13876, 5309.62, 2006.38, 711.7, 0, 35, 0, 0,0,0, id)
  47.                     player:PlaySoundToPlayer(17280) -- Ram'a'Jam
  48.                 end
  49.             end
  50.         end
  51.     end
  52.     player:GossipComplete()
  53. end
  54.  
  55. function CHAL.VAR.GirlSpawned(pUnit, event)
  56.     pUnit:RegisterEvent("CHAL.VAR.Player_Triggered_Event", 2500, 1)
  57. end
  58.  
  59. RegisterUnitEvent(13876, 18, "CHAL.VAR.GirlSpawned")
  60.  
  61. function CHAL.VAR.Player_Triggered_Event(pUnit)
  62.     local id = pUnit:GetPhase()
  63.     if CHAL[id].VAR.player == nil then
  64.         CHAL[id].VAR.player = nil
  65.     else
  66.         if CHAL[id].VAR.i == 0 then
  67.             pUnit:GetGameObjectNearestCoords(5309, 2006, 709, 202302):SetByte(GAMEOBJECT_BYTES_1,0,0) -- activate
  68.             pUnit:SendChatMessageToPlayer(42,0,"Don't let any manner of creature reach the center of the room!", CHAL[id].VAR.player)
  69.             CHAL[id].VAR.start = false
  70.             pUnit:RegisterEvent("CHAL.VAR.Player_Triggered_Event", 5000, 1)
  71.         elseif CHAL[id].VAR.i == 1 then
  72.             if (not CHAL[id].VAR.start) then
  73.                 pUnit:RegisterEvent("CHAL.VAR.SendHalfwayTimer", 60000, 1)
  74.                 pUnit:RegisterEvent("CHAL.VAR.StopWavesOfCreatures", 120000, 1)
  75.                 CHAL[id].VAR.start = true
  76.             end
  77.             if math.random(1,2) == 1 then
  78.                 pUnit:SpawnCreature(191101, 5276, 2037, 710, 0, 15, 30000, 0,0,0, id) -- a
  79.             else
  80.                 pUnit:SpawnCreature(191101, 5340, 1976, 710, 0, 15, 30000, 0,0,0, id) -- b
  81.             end
  82.             local creature = pUnit:GetCreatureNearestCoords(5309, 2006, 711, 191101)
  83.             if creature ~= nil then
  84.                 if creature:GetPhase() == id then
  85.                     if pUnit:GetDistanceYards(creature) < 6 then
  86.                         -- owned
  87.                         pUnit:SendChatMessageToPlayer(42,0,"You have failed!", CHAL[id].VAR.player)
  88.                         CHAL[id].VAR.player:SetPhase(1)
  89.                         CHAL[id].VAR.i = CHAL[id].VAR.i + 1
  90.                     end
  91.                 end
  92.             end
  93.             CHAL[id].VAR.i = CHAL[id].VAR.i - 1
  94.             if CHAL[id].VAR.player:GetMana() < 100 then
  95.                 pUnit:RegisterEvent("CHAL.VAR.Player_Triggered_Event", math.random(1, 10000), 1)
  96.             else
  97.                 pUnit:RegisterEvent("CHAL.VAR.Player_Triggered_Event", math.random(1, 7500), 1)
  98.             end
  99.         elseif CHAL[id].VAR.i == 2 then
  100.             pUnit:RemoveEvents()
  101.             pUnit:Despawn(2500, 0)
  102.             CHAL[id].VAR.player = nil
  103.         end
  104.         CHAL[id].VAR.i = CHAL[id].VAR.i + 1
  105.     end
  106. end
  107.  
  108. function CHAL.VAR.SendHalfwayTimer(pUnit)
  109.     local id = pUnit:GetPhase()
  110.     pUnit:SendChatMessageToPlayer(42,0,"60 seconds remaining!", CHAL[id].VAR.player)
  111. end
  112.  
  113. function CHAL.VAR.StopWavesOfCreatures(pUnit)
  114.     local id = pUnit:GetPhase()
  115.     pUnit:GetGameObjectNearestCoords(5309, 2006, 709, 202302):SetByte(GAMEOBJECT_BYTES_1,0,1) -- deactivate
  116.     pUnit:SendChatMessageToPlayer(42,0,"You have made it past the first challenge!", CHAL[id].VAR.player)
  117.     CHAL[id].VAR.player:SetPhase(1)
  118.     CHAL[id].VAR.player:Teleport(668, 5364, 2065, 708)
  119.     CHAL[id].VAR.player:CastSpell(64446)
  120.     CHAL[id].VAR.player = nil
  121.     pUnit:RemoveEvents()
  122.     pUnit:Despawn(10000, 0)
  123. end
  124.  
  125. RegisterUnitGossipEvent(310211, 1, "CHAL.VAR.TERENAS_GOSSIP_CLICK")
  126. RegisterUnitGossipEvent(310211, 2, "CHAL.VAR.TERENAS_GOSSIP_GOSSIP")
  127.  
  128. -- shadowfiends
  129.  
  130. function CHAL.VAR.OnSpawnFiend(pUnit, event)
  131.     --[[if pUnit:GetY() < 2000 then -- B
  132.     else
  133.     end -- A]]
  134.     pUnit:MoveTo(5309, 2006, 709.44, 0)
  135. end
  136.  
  137. RegisterUnitEvent(191101, 18, "CHAL.VAR.OnSpawnFiend")
  138.  
  139. -- Totem
  140.  
  141. local phase = 0
  142.  
  143. function TOTEM_ONSPAWN(pUnit, event)
  144.     pUnit:SetModel(30753) -- nature +1 fire +1 ice
  145.     pUnit:SetCombatCapable(1)
  146.     pUnit:Root()
  147. end
  148.  
  149. RegisterUnitEvent(307531, 18, "TOTEM_ONSPAWN")
  150.  
  151. function TOTEM_ONENTERCOMBAT(pUnit, event)
  152.     pUnit:PlaySoundToSet(17283) -- the chase
  153.     pUnit:SetModel(30753) -- nature +1 fire +1 ice
  154.     pUnit:SetCombatCapable(1)
  155.     phase = 1
  156.     pUnit:Root()
  157.     pUnit:GetGameObjectNearestCoords(5519.7, 2227, 733, 197342):SetByte(GAMEOBJECT_BYTES_1,0,1) -- deactivate
  158.     pUnit:RegisterEvent("SPAM_SPELL_TOTEM", 1500, 0)
  159.     pUnit:RegisterEvent("TOTEM_GETHP_70", 2500, 0)
  160. end
  161.  
  162. function SPAM_SPELL_TOTEM(pUnit)
  163.     local plr = pUnit:GetClosestPlayer()
  164.     if plr ~= nil then
  165.         if phase == 1 then
  166.             pUnit:CastSpellOnTarget(5176, plr) -- wrath
  167.         elseif phase == 2 then
  168.             pUnit:CastSpellOnTarget(35853, plr)
  169.         elseif phase == 3 then
  170.             if math.random(1,3) == 1 then
  171.                 pUnit:FullCastSpellOnTarget(22745, plr)
  172.             else
  173.                 pUnit:CastSpellOnTarget(205, plr)
  174.             end
  175.         end
  176.     end
  177. end
  178.  
  179. function TOTEM_GETHP_70(pUnit)
  180.     if pUnit:GetHealthPct() < 70 then
  181.         pUnit:RemoveEvents()
  182.         pUnit:CancelSpell()
  183.         phase = 2
  184.         pUnit:RegisterEvent("SPAM_SPELL_TOTEM", 2000, 0)
  185.         pUnit:SetModel(30754) -- fire
  186.         pUnit:RegisterEvent("TOTEM_GETHP_40", 2500, 0)
  187.     end
  188. end
  189.  
  190. function TOTEM_GETHP_40(pUnit)
  191.     if pUnit:GetHealthPct() < 40 then
  192.         pUnit:RemoveEvents()
  193.         pUnit:CancelSpell()
  194.         phase = 3
  195.         pUnit:SetModel(30755) -- ice
  196.         pUnit:RegisterEvent("SPAM_SPELL_TOTEM", 1750, 0)
  197.     end
  198. end
  199.  
  200. function TOTEM_ONLEAVE(pUnit)
  201.     pUnit:RemoveEvents()
  202.     pUnit:GetGameObjectNearestCoords(5519.7, 2227, 733, 197342):SetByte(GAMEOBJECT_BYTES_1,0,0)
  203.     pUnit:GetGameObjectNearestCoords(5582, 2231, 733, 197343):SetByte(GAMEOBJECT_BYTES_1,0,1)
  204.     pUnit:SetModel(30753) -- nature +1 fire +1 ice
  205. end
  206.  
  207. function TOTEM_ONDEATH(pUnit)
  208.     pUnit:RemoveEvents()
  209.     pUnit:GetGameObjectNearestCoords(5519.7, 2227, 733, 197342):SetByte(GAMEOBJECT_BYTES_1,0,0)
  210.     local door = pUnit:GetGameObjectNearestCoords(5582, 2231, 733, 197343)
  211.     door:SetByte(GAMEOBJECT_BYTES_1,0,0)
  212.     RegisterTimedEvent("CLOSE_DOOR_TOTEM", 30000, 1, door)
  213. end
  214.  
  215. function CLOSE_DOOR_TOTEM(door)
  216.     if door ~= nil then
  217.         door:SetByte(GAMEOBJECT_BYTES_1,0,1)
  218.     end
  219. end
  220.  
  221. RegisterUnitEvent(307531, 1, "TOTEM_ONENTERCOMBAT")
  222. RegisterUnitEvent(307531, 2, "TOTEM_ONLEAVE")
  223. RegisterUnitEvent(307531, 4, "TOTEM_ONDEATH")
  224.  
  225. -- Beams
  226.  
  227. function CHAL.VAR.Beams_OnSpawn(pUnit, event)
  228.     pUnit:RegisterEvent("CHAL.VAR.GetNearbyPlayers", 2000, 0)
  229.     pUnit:RegisterEvent("CHAL.VAR.BeamVisual", 1000, 1)
  230. end
  231.  
  232. function CHAL.VAR.BeamVisual(pUnit)
  233.     pUnit:CastSpell(32839) -- red beam
  234. end
  235.  
  236. function CHAL.VAR.GetNearbyPlayers(pUnit)
  237.     local p = pUnit:GetClosestPlayer()
  238.     if p ~= nil then
  239.         if pUnit:GetDistanceYards(p) < 7 then
  240.             p:Teleport(668, 5370.9, 2071.6, 708)
  241.             p:CastSpell(64446)
  242.         end
  243.     end
  244. end
  245.  
  246. RegisterUnitEvent(203160, 18, "CHAL.VAR.Beams_OnSpawn")
  247.  
  248. function CHAL.VAR.GoodBeamSpawn(pUnit, event)
  249.     pUnit:RegisterEvent("CHAL.VAR.GetNearbyPlayers", 2000, 0)
  250.     pUnit:RegisterEvent("CHAL.VAR.BeamVisual", 1000, 1)
  251. end
  252.  
  253. function CHAL.VAR.BeamVisual(pUnit)
  254.     pUnit:CastSpell(32840) -- blue beam
  255. end
  256.  
  257. function CHAL.VAR.GetNearbyPlayers(pUnit)
  258.     local a = pUnit:GetClosestPlayer()
  259.     if a ~= nil then
  260.         if pUnit:GetDistanceYards(a) < 7 then
  261.             if pUnit:GetEntry() == 203161 then -- 1
  262.                 local doorA = pUnit:GetGameObjectNearestCoords(5497.5, 1978.6, 736.5, 201385)
  263.                 doorA:SetByte(GAMEOBJECT_BYTES_1,0,0)
  264.                 pUnit:RemoveEvents()
  265.                 pUnit:RemoveAura(32840) -- blue beam
  266.                 pUnit:RegisterEvent("CHAL.VAR.GoodBeamSpawn", 15000, 1)
  267.                 RegisterTimedEvent("CLOSE_DOOR_TOTEM", 10000, 1, door)
  268.             end
  269.         end
  270.     end
  271. end
  272.  
  273. RegisterUnitEvent(203161, 18, "CHAL.VAR.GoodBeamSpawn")
Advertisement
Add Comment
Please, Sign In to add comment