local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
local Topic = {}
local vocStr = {Squire, Archer}
local vocNum = {4, 6}
local voc = 0
--[[function thinkCallback(cid)
if math.random(300) == 1 then
npcHandler:say("Join the Guard today!")
end
return true
end]]
function creatureSayCallback(cid, type, msg)
if getPlayerVocation(cid) == 0 then -- checks if player has no vocation and offers enrollment
npcHandler:say("Ah! Hiho! |PLAYERNAME|, I see you haven't chosen a career path, the royal guard has open positions, would you like to {enroll}?", cid)
npcHandler:addFocus(cid)
Topic[cid] = 0
while Topic[cid] == 0 do
if msgcontains(msg, "enroll") or msgcontains(msg, "yes") and Topic[cid] == 0 then
npcHandler:say ("Oh, so you want to enroll to the guard, yes?", cid)
if msgcontains (msg, "yes") then
Topic[cid] = 1
elseif msgcontains (msg, "no") then
npcHandler:say ("That's a shame!", cid)
else
npcHandler:say ("What was that?", cid)
end
elseif Topic[cid] == 1 then
npcHandler:say ("Very well. Here at the guard we have two branches, {melee} fighters and {distance} fighters; What would you like to specialize in?", cid)
if msgcontains (msg, "melee") then
voc = 1
assgnvoc(cid)
elseif msgcontains (msg, "distance") then
voc = 2
assgnvoc(cid)
else
npcHandler:say ("What was that?", cid)
Topic[cid] = 0
end
elseif Topic[cid] == 0 then
npcHandler:say ("So, how may I help you?", cid)
end
end
elseif getPlayerVocation(cid) ~= 4 or 6 then -- gives custom greet to those who do not belong to the guard
npcHandler:say("Oh, hi, |PLAYERNAME|. Welcome to the Guard HQ. How may I help you?", cid)
npcHandler:addFocus(cid)
elseif getPlayerVocation(cid) == 4 or 6 and Topic[cid] == 0 then -- welcomes back to members of the guard
npcHandler:say("Ah! Hello, welcome back |PLAYERNAME|.", cid)
npcHandler:addFocus(cid)
end
end
-- Set the greeting message.
npcHandler:setMessage(MESSAGE_GREET, 'Hey! Who is this?! Identify yourself!')
-- Set the greeting callback function
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
function assgnvoc(cid)
doPlayerSetVocation(cid, vocNum[voc])
npcHandler:say ("Alright, you are now a "..vocStr[voc].." for the guard.", cid)
npcHandler:say ("There's some more stuff I should teach you before you leave, do you want me to give you a short tutorial?", cid)
if msgcontains (msg, "yes") then
npcHandler:say ("Great! let's begin!", cid)
if voc == 1 then
tutorial(cid)
tutorialmelee(cid)
tutorialheal(cid)
else
tutorial(cid)
tutorialheal(cid)
end
npcHandler:say ("From now on you can ask for {missions} to me or Warden Finduin.", cid)
else
npcHandler:say ("Are you sure? This information is quite important...", cid)
if msgcontains (msg, "yes") then
npcHandler:say ("That's a shame, but as you wish. From now on you can ask for {missions} to me or Warden Finduin.", cid)
Topic[cid] = 0
else
npcHandler:say ("Great! let's begin!", cid)
tutorial(cid)
end
end
end
function tutorial(cid)
npcHandler:say("Very well. First of all, if you want to walk faster, you just need to {<dash>}, got it?", cid)
if msgcontains(msg, "yes") then
npcHandler:say("Good! moving on...", cid)
elseif msgcontains(msg, "no") then
npcHandler:say("No worries, just say {<dash>} to focus your energy and you'll walk faster. Ok?", cid)
end
end
function tutorialmelee(cid)
npcHandler:say("Now that you've learnt how to focus your energy to dash, let's see how you {<strike>}, got it?", cid)
if msgcontains(msg, "yes") then
npcHandler:say("Excellent! You're a fast learner!", cid)
elseif msgcontains(msg, "no") then
npcHandler:say("I see. Just like dashing, to make a good hit, you need to focus by saying {<strike>} and your target will receive a good blow! Alrite?", cid)
end
end
function tutorialheal(cid)
npcHandler:say("We're almost done so hang in there with me. Last but not least, I'm gonna show you how can you regain health. You can either {<apply bandage>}, but that will obviously require that you are carrying bandages with you; or you can pray to our Almighty 'El' to heal you, just repeat after me {I placito gratia habituali sanante}, Ok?", cid)
if msgcontains(msg, "yes") then
npcHandler:say("Nice! We're done now, it wasn't so bad, was it? You can keep coming to me to show you new techniqes, you just need to get {experience}", cid)
elseif msgcontains(msg, "no") then
npcHandler:say("It's OK, to be able to {<apply bandage>} you must be sure you have an available bandage in your backpack, else it won't work. For the prayer, you have to say {I placito gratia habituali sanante}, but you must have the required energy to do so, Alright? See? it didn't take me so long after all! Haha!")
end
end
-- npc answer to keyword "job"
local jobNode = keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I\'m the commander of the royal guard, my job is to overlook the safety of our citizens and {enroll} new recruits to man the guard.'})
-- npc answer to keyword "information"
local infoNode = keywordHandler:addKeyword({'information'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Here at the guard we employ {Melee} and {Distance} fighters only.'})
-- npc answer to keyword "mission"
local missionNode = keywordHandler:addKeyword ({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'There are no new missions at this moment, come back later.'})
npcHandler:addModule(FocusModule:new())