-- Merc Guild Script
require("topic_list")
require("quest_manager")
require("interface_builder")
local pl = event.activator
local me = event.me
local msg = string.lower(event.message)
local q_iname1 = "Lost Brother"
local q_mgr_1 = QuestManager(pl,"Lost Brother")
local ib = InterfaceBuilder()
ib:SetHeader(me, me.name)
local function topicDefault()
if q_mgr_1:GetStatus() < game.QSTAT_DONE then
if q_mgr_1:GetStatus() == game.QSTAT_NO then
ib:SetTitle("Distressed Peasant")
ib:AddMsg("Hi.\nI am really distressed.\n")
ib:AddLink("What happened?", "startq1")
else
ib:SetTitle("Found brother?")
ib:AddMsg("You have done the task?\n\nShow me the helm and you can join our guild.")
ib:AddLink("Give the peasant the corpse", "checkq1")
end
else
end
ib:AddMsg("Good to see you back. How are you?\n\nNice that you have joined our ^troops^.")
end
pl:Interface(1, ib:Build())
end
-- quest body (added to player quest obj for quest list)
local function quest_icons1()
ib:AddIcon("Lost Brother", "Peasant", "")
end
local function quest_body1()
ib:AddMsg("\nMy brother was out hunting the local bears and he hadn't come back in three days.")
ib:AddMsg("\nI went out to investigate and discovered a cave which had his spear on the outside. ")
ib:AddMsg("I would appreciate it if you would go and search for him.\n")
ib:AddMsg("\nWill you go find him?")
ib:SetDesc("Hurry and find my brother.", 0, 0, 0, 0)
end
-- start: accept or decline the quest
local function topStartQ1()
if q_mgr_1:GetStatus() ~= game.QSTAT_NO then
topicDefault()
else
ib:SetTitle(q_mgr_1.name)
quest_body1()
quest_icons1()
ib:SetAccept(nil, "acceptq1")
ib:SetDecline(nil, "hi")
pl:Interface(1, ib:Build())
end
end
-- accepted: start the quest
local function topAcceptQ1()
if q_mgr_1:GetStatus() ~= game.QSTAT_NO then
topicDefault()
return
end
quest_body1()
quest_icons1()
if q_mgr_1:RegisterQuest(game.QUEST_ITEM, ib) then
q_mgr_1:AddQuestItem(1, "Brother's Corpse", "corpse_human.101", q_iname1)
pl:Sound(0, 0, 2, 0)
pl:Write("You take the quest '".. q_mgr_1.name .."'.", game.COLOR_NAVY)
end
pl:Interface(-1, ib:Build())
end
-- try to finish: check the quest
local function topCheckQ1()
if q_mgr_1:GetStatus() == game.QSTAT_NO then
topicDefault()
return
end
ib:SetTitle("Found my brother?")
ib:SetMsg("The quest status is: ".. q_mgr_1:GetStatus() .."\n\n")
if q_mgr_1:GetStatus() ~= game.QSTAT_SOLVED then
ib:AddMsg("Where is my brother?\n\nCome back if you find him.\n")
ib:AddQuestChecklist(q_mgr_1)
ib:SetButton("Back", "hi")
else
ib:AddMsg("My.....\n")
ib:AddMsg("\nMy brother's.... Dead?/\n")
ib:AddMsg("'Tis a great shame, he was a good man.... \n")
ib:SetDesc("Here, take this.", 0, 0, 0, 0)
quest_icons1()
ib:AddQuestChecklist(q_mgr_1)
ib:SetAccept(nil, "finishq1")
ib:SetDecline(nil, "hi")
end
pl:Interface(1, ib:Build())
end
-- done: finish quest and give reward
local function topFinishQ1()
if q_mgr_1:GetStatus() ~= game.QSTAT_SOLVED then
topicDefault()
return
else
q_mgr_1:RemoveQuestItems()
q_mgr_1:Finish()
pl:Sound(0, 0, 2, 0)
local q_i1 = pl:CreateObjectInside("legs_leather", 1,1)
q_i1.name = q_iname1
pl:Write("You got ".. q_iname1.."Soft leather pants!!", game.COLOR_WHITE)
ib:SetTitle("Hello")
ib:SetMsg("Thank you for finding my brother.\n")
ib:SetButton("Ok", "hi")
pl:Interface(1, ib:Build())
end
end
local function topTroops()
ib:SetMsg("\nAfter Moroch's took the Demon Plane,\n")
ib:AddMsg("\ndemons moved into the animal's homes.\n")
ib:AddMsg("\nThose animals were forced to attack humans to survive, and the demons stole their food.\n")
ib:AddMsg("\nI don't believe that the demons killed my brother. I think that they just stole his body from the animals.")
ib:AddMsg("I don't blame those bears for trying to eat him, the way the demons are treating them.")
ib:AddMsg("\n\nAnyway, I've talked too much. ")
ib:AddMsg("You should go now.\n")
ib:SetButton("Bye", "hi")
pl:Interface(1, ib:Build())
end
tl = TopicList()
tl:AddGreeting(nil, topicDefault)
tl:SetDefault(topicDefault)
if q_mgr_1:GetStatus() < game.QSTAT_DONE then
tl:AddTopics("startq1", topStartQ1)
tl:AddTopics("acceptq1", topAcceptQ1)
tl:AddTopics("checkq1", topCheckQ1)
tl:AddTopics("finishq1", topFinishQ1)
end
tl:CheckMessage(event)
That's just a quick edit of the guild hall mercenary script.... it's not done, but i just tried to get a script working.
EDIT: Please use [ code ] and [ /code ] for such posts thanks