Code:
--People who have helped: Rochet2 of *****,
--------------------------------------------------------------------------------------------------------------------------------
-------Script 1-----------------------------------------------------------------------------------------------------------------
local Running_Whitemane01 = false --Is the script running? "false" means nope.
Whitemane_Say_Table01 = {}
Whitemane_Say_Table01[1] ="Follow me. *Note to player: Don't talk to her or accept the quest until she stops.*"
Whitemane_Say_Table01[2] ="Here we are, speak with me to begin your next test."
function OnQuestComplete_Whitemane90001(event, pPlayer, QuestId, pQuestGiver)
if(QuestId == 90001 and not Running) then --If the quest completed has the ID 90001 and the script isn't running then continue running the script.
local Whitemane = pPlayer:GetCreatureNearestCoords(199.408005, 121.653, 134.910004, 90010)
if(Whitemane) then --If the selected npc is Whitemane the script continues.
Running = true --Because the Whitemane was the NPC selected this is set to "true to say that the script is running.
Whitemane:SendChatMessage(12, 7, Whitemane_Say_Table01[1])
Whitemane:RegisterEvent("Move01_Whitemane", 1000, 1) --In 1 second "1000ms" the function "Move01_Whitemane" will run.
end
end
end
function Move01_Whitemane(Whitemane, event)
Whitemane:MoveTo(199.556656, 108.91169, 128.522507, 4.753242)
Whitemane:RegisterEvent("Move02_Whitemane", 4000, 1)
end
function Move02_Whitemane(Whitemane, event)
Whitemane:MoveTo(201.447388, 52.051525, 128.766281, 4.742254)
Whitemane:RegisterEvent("Move03_Whitemane", 24000, 1)
end
function Move03_Whitemane(Whitemane, event)
Whitemane:MoveTo(209.785873, 51.152771, 128.840088, 6.267476)
Whitemane:RegisterEvent("Move04_Whitemane", 4000, 1)
end
function Move04_Whitemane(Whitemane, event)
Whitemane:MoveTo(236.614975, 51.835903, 115.707848, 0.027489)
Whitemane:RegisterEvent("Move05_Whitemane", 13000, 1)
end
function Move05_Whitemane(Whitemane, event)
Whitemane:MoveTo(233.375031, 41.485565, 115.707848, 4.374668)
Whitemane:RegisterEvent("Move06_Whitemane", 6000, 1)
end
function Move06_Whitemane(Whitemane, event)
Whitemane:MoveTo(201.992569, 12.324375, 115.707878, 1.586526)
Whitemane:RegisterEvent("Talk01_Whitemane", 20000, 1)
end
function Talk01_Whitemane(Whitemane, event)
Whitemane:SendChatMessage(12, 7, Whitemane_Say_Table01[2])
end
--------------------------------------------------------------------------------------------------------------------------------
--------Script 2----------------------------------------------------------------------------------------------------------------
local T = {} --Creates a new table. The weird brackets {} tell the script to create a new table.
function OnQuestAccept_Whitemane90002(event, pPlayer, QuestId, pQuestGiver)
local ID = pUnit:GetInstanceID() --Gets the specific ID of the instance Whitemane is in. The ID of the instance is then used for the table.
if(QuestId == 90002 and not T[ID]) then -- If the quest completed has the ID 90002 and the script isn't running in the current instance then continue running the script.
T[ID] = 0 --ID is the ID of the specific instance that the script is running in.
pQuestGiver:RegisterEvent("Quest01_Whitemane90002", 10000, 1) -- We use the questgiver to register events since we need him later
end
end
function Quest01_Whitemane90002(pUnit, event)
pUnit:SpawnCreature(37227, 200.697739, 59.384331, 115.708244, 1.576423, 694, 120000, 0, 0, 0, 1, 0) --Spawns the portal
pUnit:SendChatMessage(42, 0, "The undead are comming, prepare yourself!") -- Questgiver says
pUnit:RegisterEvent("Spawn_Timer_Whitemane", 4000, 1) -- Spawns an NPC after 4 seconds
end
function Spawn_Timer_Whitemane(pUnit, event)
pUnit:RegisterEvent("Spawn01_Whitemane90002", 40000, 4) -- Spawn an NPC after 40 seconds 4 times.
end
function Spawn01_Whitemane90002(pUnit, event) -- The function that spawns the NPCs
local MindlessGhoul = pUnit:SpawnCreature(90012, 200.697739, 59.384331, 115.708244, 4.644086, 14, 120000, 0, 0, 0, 1, 0) --Sets the last spawned creature to the MindlessGhoul variable.
MindlessGhoul:MoveTo(201.975159, 21.787292, 114.983719, 4.718697) --Tells the mindless ghoul to move to the point
end
function Spawn_On_Death(pUnit, event, pPlayer)
local ID = pUnit:GetInstanceID()
T[ID] = T[ID]+1
if(T[ID] >= 5) then
-- complete quest etc
table.remove(T, ID) -- Quest can now be re-triggered
end
end
--------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
function END_Whitemane90001(Whitemane, event) --DO NOT RUN THIS UNTIL THE PLAYER HAS FINISHED THE ENTIRE QUEST CHAIN AND LEFT THE INSTNACE
Whitemane:Despawn(0, 0)
Running = false
end
RegisterServerHook(22, "OnQuestAccept_Whitemane90002")
RegisterServerHook(22, "OnQuestComplete_Whitemane90001")
RegisterUnitEvent(90012, 4, "Spawn_On_Death")
RegisterUnitEvent(90010, 18, function() return; end) -- This allows the use of :RegisterEvent() for Whitemane