Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- By Stoneharry
- -- Variables
- CHAL = {}
- CHAL.VAR = {}
- local guy
- local OBJECT_END = 0x0006
- local GAMEOBJECT_BYTES_1 = OBJECT_END + 0x000B
- -- spawn 191101
- -- left
- -- SpawnA = 5276, 2037, 710
- -- right
- -- SpawnB = 5340, 1976, 710
- -- move to 5309, 2006, 708.44, 0
- -- Terenas
- function CHAL.VAR.TERENAS_GOSSIP_CLICK(pUnit, event, player)
- guy = pUnit
- pUnit:GossipCreateMenu(1039, player, 0)
- pUnit:GossipMenuAddItem(9, "Start the challenge.", 2, 0)
- pUnit:GossipMenuAddItem(0, "Nevermind.", 1, 0)
- pUnit:GossipSendMenu(player)
- end
- function CHAL.VAR.TERENAS_GOSSIP_GOSSIP(pUnit, event, player, id, intid, code)
- if intid == 2 then
- if player:IsInGroup() then
- pUnit:SendChatMessage(12,0,"You must face these challenges alone, "..player:GetName()..".")
- else
- local id = 2
- CHAL[id] = CHAL[id] or {VAR={}}
- local found = false
- while (not found) do
- CHAL[id] = CHAL[id] or {VAR={}}
- if CHAL[id].VAR.player ~= nil then
- id = id*2
- else
- found = true
- CHAL[id].VAR.player = player
- CHAL[id].VAR.i = 0
- player:SetPhase(id)
- CHAL[id].VAR.girl = guy:SpawnCreature(13876, 5309.62, 2006.38, 711.7, 0, 35, 0, 0,0,0, id)
- player:PlaySoundToPlayer(17280) -- Ram'a'Jam
- end
- end
- end
- end
- player:GossipComplete()
- end
- function CHAL.VAR.GirlSpawned(pUnit, event)
- pUnit:RegisterEvent("CHAL.VAR.Player_Triggered_Event", 2500, 1)
- end
- RegisterUnitEvent(13876, 18, "CHAL.VAR.GirlSpawned")
- function CHAL.VAR.Player_Triggered_Event(pUnit)
- local id = pUnit:GetPhase()
- if CHAL[id].VAR.player == nil then
- CHAL[id].VAR.player = nil
- else
- if CHAL[id].VAR.i == 0 then
- pUnit:GetGameObjectNearestCoords(5309, 2006, 709, 202302):SetByte(GAMEOBJECT_BYTES_1,0,0) -- activate
- pUnit:SendChatMessageToPlayer(42,0,"Don't let any manner of creature reach the center of the room!", CHAL[id].VAR.player)
- CHAL[id].VAR.start = false
- pUnit:RegisterEvent("CHAL.VAR.Player_Triggered_Event", 5000, 1)
- elseif CHAL[id].VAR.i == 1 then
- if (not CHAL[id].VAR.start) then
- pUnit:RegisterEvent("CHAL.VAR.SendHalfwayTimer", 60000, 1)
- pUnit:RegisterEvent("CHAL.VAR.StopWavesOfCreatures", 120000, 1)
- CHAL[id].VAR.start = true
- end
- if math.random(1,2) == 1 then
- pUnit:SpawnCreature(191101, 5276, 2037, 710, 0, 15, 30000, 0,0,0, id) -- a
- else
- pUnit:SpawnCreature(191101, 5340, 1976, 710, 0, 15, 30000, 0,0,0, id) -- b
- end
- local creature = pUnit:GetCreatureNearestCoords(5309, 2006, 711, 191101)
- if creature ~= nil then
- if creature:GetPhase() == id then
- if pUnit:GetDistanceYards(creature) < 6 then
- -- owned
- pUnit:SendChatMessageToPlayer(42,0,"You have failed!", CHAL[id].VAR.player)
- CHAL[id].VAR.player:SetPhase(1)
- CHAL[id].VAR.i = CHAL[id].VAR.i + 1
- end
- end
- end
- CHAL[id].VAR.i = CHAL[id].VAR.i - 1
- if CHAL[id].VAR.player:GetMana() < 100 then
- pUnit:RegisterEvent("CHAL.VAR.Player_Triggered_Event", math.random(1, 10000), 1)
- else
- pUnit:RegisterEvent("CHAL.VAR.Player_Triggered_Event", math.random(1, 7500), 1)
- end
- elseif CHAL[id].VAR.i == 2 then
- pUnit:RemoveEvents()
- pUnit:Despawn(2500, 0)
- CHAL[id].VAR.player = nil
- end
- CHAL[id].VAR.i = CHAL[id].VAR.i + 1
- end
- end
- function CHAL.VAR.SendHalfwayTimer(pUnit)
- local id = pUnit:GetPhase()
- pUnit:SendChatMessageToPlayer(42,0,"60 seconds remaining!", CHAL[id].VAR.player)
- end
- function CHAL.VAR.StopWavesOfCreatures(pUnit)
- local id = pUnit:GetPhase()
- pUnit:GetGameObjectNearestCoords(5309, 2006, 709, 202302):SetByte(GAMEOBJECT_BYTES_1,0,1) -- deactivate
- pUnit:SendChatMessageToPlayer(42,0,"You have made it past the first challenge!", CHAL[id].VAR.player)
- CHAL[id].VAR.player:SetPhase(1)
- CHAL[id].VAR.player:Teleport(668, 5364, 2065, 708)
- CHAL[id].VAR.player:CastSpell(64446)
- CHAL[id].VAR.player = nil
- pUnit:RemoveEvents()
- pUnit:Despawn(10000, 0)
- end
- RegisterUnitGossipEvent(310211, 1, "CHAL.VAR.TERENAS_GOSSIP_CLICK")
- RegisterUnitGossipEvent(310211, 2, "CHAL.VAR.TERENAS_GOSSIP_GOSSIP")
- -- shadowfiends
- function CHAL.VAR.OnSpawnFiend(pUnit, event)
- --[[if pUnit:GetY() < 2000 then -- B
- else
- end -- A]]
- pUnit:MoveTo(5309, 2006, 709.44, 0)
- end
- RegisterUnitEvent(191101, 18, "CHAL.VAR.OnSpawnFiend")
- -- Totem
- local phase = 0
- function TOTEM_ONSPAWN(pUnit, event)
- pUnit:SetModel(30753) -- nature +1 fire +1 ice
- pUnit:SetCombatCapable(1)
- pUnit:Root()
- end
- RegisterUnitEvent(307531, 18, "TOTEM_ONSPAWN")
- function TOTEM_ONENTERCOMBAT(pUnit, event)
- pUnit:PlaySoundToSet(17283) -- the chase
- pUnit:SetModel(30753) -- nature +1 fire +1 ice
- pUnit:SetCombatCapable(1)
- phase = 1
- pUnit:Root()
- pUnit:GetGameObjectNearestCoords(5519.7, 2227, 733, 197342):SetByte(GAMEOBJECT_BYTES_1,0,1) -- deactivate
- pUnit:RegisterEvent("SPAM_SPELL_TOTEM", 1500, 0)
- pUnit:RegisterEvent("TOTEM_GETHP_70", 2500, 0)
- end
- function SPAM_SPELL_TOTEM(pUnit)
- local plr = pUnit:GetClosestPlayer()
- if plr ~= nil then
- if phase == 1 then
- pUnit:CastSpellOnTarget(5176, plr) -- wrath
- elseif phase == 2 then
- pUnit:CastSpellOnTarget(35853, plr)
- elseif phase == 3 then
- if math.random(1,3) == 1 then
- pUnit:FullCastSpellOnTarget(22745, plr)
- else
- pUnit:CastSpellOnTarget(205, plr)
- end
- end
- end
- end
- function TOTEM_GETHP_70(pUnit)
- if pUnit:GetHealthPct() < 70 then
- pUnit:RemoveEvents()
- pUnit:CancelSpell()
- phase = 2
- pUnit:RegisterEvent("SPAM_SPELL_TOTEM", 2000, 0)
- pUnit:SetModel(30754) -- fire
- pUnit:RegisterEvent("TOTEM_GETHP_40", 2500, 0)
- end
- end
- function TOTEM_GETHP_40(pUnit)
- if pUnit:GetHealthPct() < 40 then
- pUnit:RemoveEvents()
- pUnit:CancelSpell()
- phase = 3
- pUnit:SetModel(30755) -- ice
- pUnit:RegisterEvent("SPAM_SPELL_TOTEM", 1750, 0)
- end
- end
- function TOTEM_ONLEAVE(pUnit)
- pUnit:RemoveEvents()
- pUnit:GetGameObjectNearestCoords(5519.7, 2227, 733, 197342):SetByte(GAMEOBJECT_BYTES_1,0,0)
- pUnit:GetGameObjectNearestCoords(5582, 2231, 733, 197343):SetByte(GAMEOBJECT_BYTES_1,0,1)
- pUnit:SetModel(30753) -- nature +1 fire +1 ice
- end
- function TOTEM_ONDEATH(pUnit)
- pUnit:RemoveEvents()
- pUnit:GetGameObjectNearestCoords(5519.7, 2227, 733, 197342):SetByte(GAMEOBJECT_BYTES_1,0,0)
- local door = pUnit:GetGameObjectNearestCoords(5582, 2231, 733, 197343)
- door:SetByte(GAMEOBJECT_BYTES_1,0,0)
- RegisterTimedEvent("CLOSE_DOOR_TOTEM", 30000, 1, door)
- end
- function CLOSE_DOOR_TOTEM(door)
- if door ~= nil then
- door:SetByte(GAMEOBJECT_BYTES_1,0,1)
- end
- end
- RegisterUnitEvent(307531, 1, "TOTEM_ONENTERCOMBAT")
- RegisterUnitEvent(307531, 2, "TOTEM_ONLEAVE")
- RegisterUnitEvent(307531, 4, "TOTEM_ONDEATH")
- -- Beams
- function CHAL.VAR.Beams_OnSpawn(pUnit, event)
- pUnit:RegisterEvent("CHAL.VAR.GetNearbyPlayers", 2000, 0)
- pUnit:RegisterEvent("CHAL.VAR.BeamVisual", 1000, 1)
- end
- function CHAL.VAR.BeamVisual(pUnit)
- pUnit:CastSpell(32839) -- red beam
- end
- function CHAL.VAR.GetNearbyPlayers(pUnit)
- local p = pUnit:GetClosestPlayer()
- if p ~= nil then
- if pUnit:GetDistanceYards(p) < 7 then
- p:Teleport(668, 5370.9, 2071.6, 708)
- p:CastSpell(64446)
- end
- end
- end
- RegisterUnitEvent(203160, 18, "CHAL.VAR.Beams_OnSpawn")
- function CHAL.VAR.GoodBeamSpawn(pUnit, event)
- pUnit:RegisterEvent("CHAL.VAR.GetNearbyPlayers", 2000, 0)
- pUnit:RegisterEvent("CHAL.VAR.BeamVisual", 1000, 1)
- end
- function CHAL.VAR.BeamVisual(pUnit)
- pUnit:CastSpell(32840) -- blue beam
- end
- function CHAL.VAR.GetNearbyPlayers(pUnit)
- local a = pUnit:GetClosestPlayer()
- if a ~= nil then
- if pUnit:GetDistanceYards(a) < 7 then
- if pUnit:GetEntry() == 203161 then -- 1
- local doorA = pUnit:GetGameObjectNearestCoords(5497.5, 1978.6, 736.5, 201385)
- doorA:SetByte(GAMEOBJECT_BYTES_1,0,0)
- pUnit:RemoveEvents()
- pUnit:RemoveAura(32840) -- blue beam
- pUnit:RegisterEvent("CHAL.VAR.GoodBeamSpawn", 15000, 1)
- RegisterTimedEvent("CLOSE_DOOR_TOTEM", 10000, 1, door)
- end
- end
- end
- end
- RegisterUnitEvent(203161, 18, "CHAL.VAR.GoodBeamSpawn")
Advertisement
Add Comment
Please, Sign In to add comment