Code:
--[[
This sample escort quest is scripted by Wolferine and Kerp.
Do not claim this to be yours.
Do not re-release without my permission.
Do not remove these credits.
]]
local NPC_ID = Npc ID here
local QUEST_ID = Quest ID here
local NPC_ID2 = Npc ID Spawn 2
local NPC_ID3 = Npc ID Spawn 3
local NPC_ID4 = NPC ID Spawn 4
function OnQuestAccept(event, pPlayer, pQuestGiver, questId)
if(pQuestGiver == NPC_ID) and (questId == QUEST_ID) then
pUnit:SendChatMessage(12, 0, "We better be going else they will notice I left!")
pUnit:RegisterEvent("Escort_Move", 1000, 1)
end
end
function Escort_Move(pUnit, Event)
pUnit:GetX()
pUnit:GetY()
pUnit:GetZ()
pUnit:MoveTo(0, x+10, y, z)
pUnit:RegisterEvent("Escort_Move2", 5000, 1)
end
function Escort_Move2(pUnit, Event)
pUnit:GetX()
pUnit:GetY()
pUnit:GetZ()
pUnit:MoveTo(0, x+10, y, z)
pUnit:RegisterEvent("Escort_Move3", 10000, 1)
end
function Escort_Move3(pUnit, Event)
pUnit:SendChatMessage(12, 0, "I really need to catch breath...")
pUnit:RegisterEvent("Escort_Spawn", 5000, 1)
end
function Escort_Spawn(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Watch out!")
pUnit:GetX()
pUnit:GetY()
pUnit:GetZ()
pUnit:SpawnCreature(NPC_ID2, x+5, z+5, y, 0)
pUnit:SpawnCreature(NPC_ID3, x+10, z+5, y, 0)
pUnit:SpawnCreature(NPC_ID4, x+7, z+7, y, 0)
pUnit:RegisterEvent("Escort_Move4", 40000, 1)
end
function Escort_Move4(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Phew, that was close.")
pUnit:GetX()
pUnit:GetY()
pUnit:GetZ()
pUnit:MoveTo(1, x+10, z, y, 0)
pUnit:RegisterEvent("Escort_Complete", 10000, 1)
end
function Escort_Complete(pUnit, Event)
pUnit:SendChatMessage(12, 0, "Thanks for helping me man!")
player:QuestComplete(QUEST_ID)
pUnit:Despawn()
end
RegisterServerHook(14, "OnQuestAccept")
This scripts will trigger with an additional server hook( added in LuaHypArc) if you accept the quest the npc will begin to move.