X
Xikini
Guest
An answer was provided by Ninja here.
Feel free to read through the discussion.
TL : DR I need to know how to create timed storyline within an npc, along with advancement in conversation.
Also knowing what the local's are defining.
I have been editing some npc's for my friends server, and for the most part it's pretty easy.
In every single one of his npc's there is no dialogue.
example:
Player: Hello
Npc: What's up?
Player: quest!
Npc: I might have something for you.
Player: something?
Npc: Something. Everything! Goblins everywhere!
idle timer, 2 seconds.
Npc: Are you up for that kind of Challenge?
Player: Yes!
Npc: Great! I'll be here when you get back!
else
shame. I needed help.
Come back if you want to help me.
I can easily assume that talkState = {} would be useful in advancing npc conversation, however I am unfamiliar with it's use. I also do not see how to create an idle timer, or a lull in conversation before the npc speaks again.
I crafted this *masterpeice* from the scripts he has.
The npc will *ask* (being a loose term at the moment) for help, and give you an item as a reward, along with experience.
If you wish to repeat the mission, he will give you gold and experience, every time thereafter.
One more thing I'd like to reason out.. How do you create general question and answers?
like this?
..
Assuming once again to put it near end of script, so it doesn't interfere with quest checks.
So all in all I guess I just want an example of everything, and some information so I can actually make a decent storyline and interactive npc's.
PS: how do you disable smilies! Lol
Feel free to read through the discussion.
TL : DR I need to know how to create timed storyline within an npc, along with advancement in conversation.
Also knowing what the local's are defining.
I have been editing some npc's for my friends server, and for the most part it's pretty easy.
In every single one of his npc's there is no dialogue.
example:
Player: Hello
Npc: What's up?
Player: quest!
Npc: I might have something for you.
Player: something?
Npc: Something. Everything! Goblins everywhere!
idle timer, 2 seconds.
Npc: Are you up for that kind of Challenge?
Player: Yes!
Npc: Great! I'll be here when you get back!
else
shame. I needed help.
Come back if you want to help me.
I can easily assume that talkState = {} would be useful in advancing npc conversation, however I am unfamiliar with it's use. I also do not see how to create an idle timer, or a lull in conversation before the npc speaks again.
I crafted this *masterpeice* from the scripts he has.
The npc will *ask* (being a loose term at the moment) for help, and give you an item as a reward, along with experience.
If you wish to repeat the mission, he will give you gold and experience, every time thereafter.
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onThink() npcHandler:onThink() end
local playerID = 0
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid)
end
-- Npc Name That this Quest is Used with --
-- Monk Tonir --
-- Other Npc's --
function onCreatureSay(cid, type, msg)
npcHandler:setMessage(MESSAGE_FAREWELL, "Wish I could get rid of those goblins as easy as I {kill} people.") -- generic end of conversation
if (getPlayerStorageValue(cid,45007) < 1) then
npcHandler:setMessage(MESSAGE_GREET, "Hey there.") -- Generic Greeting
elseif (getPlayerStorageValue(cid,45007) == 1) then
npcHandler:setMessage(MESSAGE_GREET, "Please kill off some of those goblins or I'll never get rid of them all!") -- Started quest for First Reward
elseif (getPlayerStorageValue(cid,45007) == 2) then
npcHandler:setMessage(MESSAGE_GREET, "I still need a few more {troublemakers} taken care of!") -- Ended Starting Quest, Now Repeatable quest
elseif (getPlayerStorageValue(cid,45007) == 3) then
npcHandler:setMessage(MESSAGE_GREET, "The more goblins you kill the richer I'll make you!") -- Ended Starting Quest, Now Repeatable quest
end
npcHandler:onCreatureSay(cid, type, msg)
end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return FALSE
end
playerID = cid
if (getPlayerStorageValue(cid,45007) < 1) then
if msgcontains(msg, 'kill goblins') then
if (getPlayerStorageValue(cid,45007) < 1) then
npcHandler:say("Great! Please kill 50 {goblins} and I'll give you an awesome reward!",cid)
setPlayerStorageValue(cid,45007,1) -- start killing monsters
else
npcHandler:say("What was that?",cid)
end
end
elseif (getPlayerStorageValue(cid,45007) == 1) then -- if player has started killing monster
if msgcontains(msg, "goblins") then
if (getPlayerStorageValue(cid,45008) == 50) then -- If player has killed 50 monsters
npcHandler:say("Thank you.. here's an awesome reward! If you want some extra money and experience ask me about those {troublemakers}.",cid)
doPlayerAddItem(cid, 8305, 1) -- whatever item it is
local exp = getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier) -- checks if they have bonus exp on
doPlayerAddExperience(cid, 2000 * exp) -- Gives player exp depending on level and current exp rate
setPlayerStorageValue(cid,45007,2) -- start repeatable
setPlayerStorageValue(cid,45008,0) -- restart monster count
else
npcHandler:say("If you can kill 50 goblins I'll reward you greatly!",cid)
end
end
end
if (getPlayerStorageValue(cid,45007) == 2) then
if msgcontains(msg, 'troublemakers') then
if (getPlayerStorageValue(cid,45007) == 2) then
npcHandler:say("Please kill more {goblins} and I'll give you 300 gold and some experience points!",cid)
setPlayerStorageValue(cid,45007,3) -- start killing monsters
else
npcHandler:say("What was that?",cid)
end
end
elseif (getPlayerStorageValue(cid,45007) == 3) then -- if player has started killing goblins
if msgcontains(msg, "goblins") then
if (getPlayerStorageValue(cid,45008) == 50) then -- If player has killed 30 goblins
npcHandler:say("As promised here's your reward. If you want to help me again just ask about those troublemakers.",cid)
doPlayerAddItem(cid, 2152, 3) -- platinum coins
local exp = getExperienceStage(getPlayerLevel(cid), getVocationInfo(getPlayerVocation(cid)).experienceMultiplier) -- checks if they have bonus exp on
doPlayerAddExperience(cid, 2000 * exp) -- Gives player exp depending on level and current exp rate
setPlayerStorageValue(cid,45007,2) -- restart repeatable
setPlayerStorageValue(cid,45008,0) -- restart monster count
else
npcHandler:say("If you can kill 50 goblins I'll reward you with my rapidly depleting wealth!",cid)
end
end
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
One more thing I'd like to reason out.. How do you create general question and answers?
like this?
Code:
if msgcontains(msg, 'job') then
npcHandler:say("I am a farmer!",cid)
end
if msgcontains(msg, 'monk tonir') then
npcHandler:say("He is a monk!",cid)
end
Assuming once again to put it near end of script, so it doesn't interfere with quest checks.
So all in all I guess I just want an example of everything, and some information so I can actually make a decent storyline and interactive npc's.
PS: how do you disable smilies! Lol
Last edited by a moderator: