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 voices = {
{ text = "Weak chest? Why not dish out some magic!" },
{ text = "Wield a staff - the magician's weapon!" },
{ text = "Flay your foes with fireballs!" },
{ text = "Weak punch? Deal out some heavy damage with magic!" },
{ text = "Staffs, wands, rods - the true weapons of power!" },
{ text = "Shoot your enemy with energy spheres!" }
}
npcHandler:addModule(VoiceModule:new(voices))
local function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if msgcontains(msg, "hi") or msgcontains(msg, "hello") and not npcHandler:isFocused(cid) then
npcHandler:addFocus(cid)
if player:getStorageValue(Storage.IslandOfDestiny.ChildOfDestiny.QuestLine) < 2 then
npcHandler:say("Hello there! Interested in magic? Wish to become an acolyte of the arcane, a neophyte of nature? Then the staff is your weapon of choice! Care to try it out? Of course you do. Say {yes}.", cid)
elseif player:getStorageValue(Storage.IslandOfDestiny.ChildOfDestiny.QuestLine) >= 2 then
npcHandler:say("Hello again! Do you want me to explain how distance fighting for mages works {again}, or did you lose your {staff}?", cid)
npcHandler.topic[cid] = 50
end
elseif(not npcHandler:isFocused(cid)) then return false end
if msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
npcHandler:say("<bows> Goodbye. May we meet again!")
npcHandler:releaseFocus(cid)
elseif msgcontains(msg, "yes") or msgcontains(msg, "ready") then
if npcHandler.topic[cid] == 20 then
npcHandler:say({
"Alright, let's get startted! <snaps fingers> Here's your staff! Just drag it from your inventory to your weapon slot to use it. ...",
"<chuckles> Have a blast and just visit Shanoya next door to try out mundane distance weapon, too, afterwards."
}, cid)
player:setStorageValue(Storage.IslandOfDestiny.ChildOfDestiny.QuestLine, 2)
player:addItem(19391, 1)
npcHandler:resetNpc(cid)
npcHandler:releaseFocus(cid)
elseif npcHandler.topic[cid] == 0 then
npcHandler:say({
"<chuckles> Good. We magic wielders prefer to fight from a distance, as our defense and armor is lot weaker that that of the knights. But we deal out more damage with a hit than they do. ...",
"Stay a little distance from a monster. Too far away staff won't hit the monster, come too close and the monster will hit YOU. ...",
"First, drag your staff to the weapon slot in your inventory to use it. Then, to attack, RIGHT-CLICK on a monster on the screen or battle list and choose 'ATTACK'. ...",
"Remember that a staff also need {mana} to work, so make sure you always have some food, or you won't regenerate mana. There's food in the chest outside, and some blueberry bushes. Oh yeas, one other thing! mana will only regenerated inside tents. ...",
"{Ready} for the staff?"
}, cid)
npcHandler.topic[cid] = 20
end
elseif msgcontains(msg, "no") then
if npcHandler.topic[cid] == 50 then
npcHandler.say("<chuckles> Oh well, if you're sure... come back if you change your mind. Have fun!", cid)
npcHandler:resetNpc(cid)
npcHandler:releaseFocus(cid)
end
elseif msgcontains(msg, "again") and npcHandler.topic[cid] == 50 then
npcHandler:say({
"Gladly. We magic wielders prefer to fight from a distance, as our defense and armor is a lot weaker than that of the knights. But we deal out more damage with a hit than they do. ...",
"Stay at a little distance from a monster. Too far away: the staff won't hit the monster; come too close and the monster will hit YOU. ...",
"Drag your staff to the weapon slot in your inventory to use it, right-click on a monster and choose 'attack'. ...",
"Check your mana and always have some food with you. When you're done, visit Shanoya next door for more... mundane distance fighting. <chuckles> Enjoy!"
},cid)
npcHandler:resetNpc(cid)
npcHandler:releaseFocus(cid)
end
end
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = "I am a sorcerer apprentice to the master {sorcerer Estrella}."})
keywordHandler:addKeyword({'estrella'}, StdModule.say, {npcHandler = npcHandler, text = "She is the local vocation trainer for {sorcerers} and my esteemed master."})
keywordHandler:addKeyword({'sorcerer', 'estrella'}, StdModule.say, {npcHandler = npcHandler, text = "She is the local vocation trainer for {sorcerers} and my esteemed master."})
keywordHandler:addAliasKeyword({'sorcerer'})
keywordHandler:addKeyword({'ula'}, StdModule.say, {npcHandler = npcHandler, text = "<chuckles> Cute girl. Has some mean fireballs at the ready, too."})
keywordHandler:addKeyword({'shanoya'}, StdModule.say, {npcHandler = npcHandler, text = "<chuckles> Don't cross her in a dark wood! Or was it dark mood? Anyway. Tough lady. Teaches distance fighting for non-magic people, next door."})
npcHandler:setMessage(MESSAGE_WALKAWAY, '<chuckles> Always in a hurry, eh?')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)