• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Djinn npc Umar, small issues

Massen

Masserv RPG
Joined
Jul 23, 2007
Messages
324
Reaction score
1
Location
Sweden
Hello, Im working on real Tibias Djinn quest at the moment, this npc Umar from the marids (blue djinn quest) Is suppose to only reply to you if you have talked to Melchior about the word of greeting (done) it adds the storagevalue 29364(snacka) then you are able to talk to Umar (this npc) that will let you pass the quest doors inside the djinn tower. Umar should only reply to Djanni'hah unless you have joined them, then he will reply to Hi as usual.

This works somewhat but he wont reply to Join and sometimes when you greet him with Djanni'hah he will emediaetly ungreet you, sometimes he doesn't.

Lua:
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


function greetCallback(cid)
local nome2 = getCreatureName(cid)
    if (getPlayerStorageValue(cid, 29361) == 1) then
        npcHandler:setMessage(MESSAGE_GREET, "Still alive, ".. nome2 .."?")
        return true
    else
	return false
    end
end

	--		doPlayerAddExp(cid,addexp)
	--		doSendAnimatedText(getCreaturePosition(cid), ' ' .. addexp .. ' ', TEXTCOLOR_WHITE)


 function creatureSayCallback(cid, type, msg)
 
 --- CONFIG ---
 
 	local nome = getCreatureName(cid)
 	local marid = getPlayerStorageValue(cid, 29361)
	local nopledge = getPlayerStorageValue(cid, 29360)
	local snacka = getPlayerStorageValue(cid, 29364)
	local chain = getPlayerStorageValue(cid, 29362)
	local mission1={"Whoa? You know the word! Amazing, " .. nome .. " ...","I should go and tell Fa'hradin. ...","Well. Why are you here anyway, " .. nome .. "?"}
	local mission2={"Oh. Ok. Welcome then. You may pass. ...","And don't forget to kill some Efreets, now and then."}
	local mission3={"Whoa! A human! This is no place for you, ".. nome ..". ...,","Go and play somewhere else."}
	local DELAY = 9
	local EVENT
--- CONFIG END ---

 	if msgcontains(msg, 'djanni\'hah') or msgcontains(msg, 'DJANNI\'HAH') then
		if (chain==0) and (marid==0) and (snacka==1) and (nopledge==0) and (getDistanceToCreature(cid) < 4) then
			npcHandler:addFocus(cid)
		    addEvent(function(cid) if isPlayer(cid) then talkstate=1 end end, 12100, cid)
			talk_var=doNPCTalkALot(mission1,6000)
 		elseif msgcontains(msg, 'djanni\'hah') or msgcontains(msg, 'DJANNI\'HAH') then
			if (chain==0) and (marid==0) and (snacka==0) and (nopledge==0) and (getDistanceToCreature(cid) < 4) then
				talk_var=doNPCTalkALot(mission3,6000) -- Inte pratat med melchior, inte valt efreet inte startat chain eller valt marid.
		elseif msgcontains(msg, 'djanni\'hah') or msgcontains(msg, 'DJANNI\'HAH') then -- Valt efreet!
			if (nopledge>=1) then
				selfSay('Shove off, little one! Humans are not welcome here, '.. nome ..'!')
				talkstate=0

		elseif msgcontains(msg, 'join') and talkstate==1 then  -- quest start
			selfSay('Are you sure? You pledge loyalty to king Gabel, who is... you know. And you are willing to never ever set foot on Efreets\' territory, unless you want to kill them? Yes?')
			talkstate=2
		elseif (msgcontains(msg, 'yes')) and talkstate==2 then -- first continue
			talk_var=doNPCTalkALot(mission2,6000)
				setPlayerStorageValue(cid,29361,1) -- Dörr
				setPlayerStorageValue(cid,29362,1) -- Chain
			talkstate=0
			end
			end
		end
	end
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Anyone know why this happends?

btw

Lua:
talk_var=doNPCTalkALot(mission2,6000)
will print the these messages
Lua:
	local mission2={"Oh. Ok. Welcome then. You may pass. ...","And don't forget to kill some Efreets, now and then."}

Hope anyone can help me

Cheers


//Massen
 
Those storages are confusing. Why don't you base them on Cip's npcs?
Lua:
# GIMUD - Graphical Interface Multi User Dungeon
# umar.npc: Datenbank für den Maridpförtner Umar

Name = "Umar"
Sex = male
Race = 80
Outfit = (80,0-0-0-0)
Home = [33102,32531,6]
Radius = 1
GoStrength = 5

Behaviour = {

ADDRESS,"hello$",QuestValue(278)=2,!      -> "%N! How's it going these days?"
ADDRESS,"hi$",QuestValue(278)=2,!         -> *
ADDRESS,"greetings$",QuestValue(278)=2,!  -> *
ADDRESS,"djanni'hah$",QuestValue(278)=2,! -> *
ADDRESS,"hello$",QuestValue(278)>0,!      -> "Whoa! A human! This is no place for you, %N. ...",
                                             "Go and play somewhere else.", Idle
ADDRESS,"hi$",QuestValue(278)>0,!         -> *
ADDRESS,"greetings$",QuestValue(278)>0,!  -> *
ADDRESS,"hello$",!                        -> *
ADDRESS,"hi$",!                           -> *
ADDRESS,"greetings$",!                    -> *
ADDRESS,"djanni'hah$",QuestValue(278)>0,! -> "Whoa? You know the word! Amazing, %N! ...",
                                             "I should go and tell Fa'hradin. ...",
                                             "Well. Why are you here anyway, %N?"
ADDRESS,"djanni'hah$",!                   -> "Hahahaha! ...",
                                             "%N, that almost sounded like the word of greeting. Humans - cute they are!", Idle
ADDRESS,!                                 -> Idle

BUSY,"hello$",QuestValue(278)=2,!         -> "Hey %N! Please wait a second!", Queue
BUSY,"hi$",QuestValue(278)=2,!            -> *
BUSY,"greetings$",QuestValue(278)=2,!     -> *
BUSY,"djanni'hah$",QuestValue(278)=2,!    -> *
BUSY,"hello$",QuestValue(278)>0,!         -> "Another human! This is no place for you, %N. ...",
                                             "Go and play somewhere else."
BUSY,"hi$",QuestValue(278)>0,!            -> *
BUSY,"greetings$",QuestValue(278)>0,!     -> *
BUSY,"hello$",!                           -> *
BUSY,"hi$",!                              -> *
BUSY,"greetings$",!                       -> *
BUSY,"djanni'hah$",QuestValue(278)>0,!    -> "Yikes! Another human? Where did you come from? Well, ehm - if you could please wait a second, %N?", Queue
BUSY,"djanni'hah$",!                      -> "That almost sounded like the word of greeting, %N. Humans - cute they are!"
BUSY,!                                    -> NOP

VANISH,!                                  -> "Back to work."

"bye"         -> "<salutes>Aaaa -tention!.", Idle
"farewell"    -> *
"name"        -> "I am Umar. Pleased to meet you!"
"job"         -> "I am the gatekeeper of Ashta'daramai. That's what Gabel told me to do. You know - keeping the courtyard clean, getting rid of salesmen, keeping Efreet scum out... that kind of thing. But in my spare time I work as a part-time philosopher."
"philosopher" -> "Yes. Comes with the job. You see - here I am, sitting on the same chair all day and staring at the same blank wall. So what happens is that my mind starts wandering. And, you know, I start thinking. You know - about all kinds of things."
"things"      -> "Yes. About the world and the gods and all that. And about girls. Yes, about girls, mostly."
"girls"       -> "You did not know there are female djinns, did you? That's because they are quite rare. They are the greatest treasures of our race, and we guard them jealously."

"gate"        -> "On the orders of king Gabel, who technically is no real king, only Marid may enter Ashta'daramai."
"pass"        -> "If you want to enter our fortress you have to become one of us and fight the Efreet. ...",
                 "So, are you willing to do so?", Topic=1 
"door"        -> *
"enter"       -> *
"join"        -> *
"follow"      -> *

"gate",QuestValue(278)=2,!        -> "You allready have the permission to enter Ashta'daramai."
"pass",QuestValue(278)=2,!        -> *
"door",QuestValue(278)=2,!        -> *
"enter",QuestValue(278)=2,!       -> *
"join",QuestValue(278)=2,!        -> *
"follow",QuestValue(278)=2,!      -> *


Topic=1,"yes",QuestValue(278)=3,! -> "I don't believe you! You better go now.", Idle
Topic=1,"yes",! -> "Are you sure? You pledge loyalty to king Gabel, who is... you know. And you are willing to never ever set foot on Efreets' territory, unless you want to kill them? Yes?", Topic=2
Topic=2,"yes",! -> "Oh. Ok. Welcome then. You may pass. ...",
                   "And don't forget to kill some Efreets, now and then.", SetQuestValue(278,2)
Topic=1,!       -> "This isn't your war anyway, human."
Topic=2,!       -> *

"gabel"			  -> "He is our king and leader. Well, he isn't a king, you know. I mean, from a technical point of view he is, but he does not wear a crown or anything, and he says he isn't one, so even though he is one he isn't. Right?"
"king"        -> "Okay, let's do this again. Gabel says he isn't a king, but he acts like one, which makes him one anyway - right? ...",
                 "But you know, he does not really act like one, either. I mean, he does give us orders and all that, and we obey sure enough, but it's not that we have to, I mean, technically speaking. ...",
                 "I mean - I don't know what would happen if anybody would not follow his orders for a change. After all he is no longer a king, right? ...",
                 "But then I don't want to be the first one to find out what happens if you disobey, so I always do as I'm told. ...",
                 "Which means I do not really know whether or not he is king. <sighs> Things were so much easier when Gabel still said he was king. Matters were so much clearer then." 
"djinn"       -> "Well, I am a djinn, but only as far as my physical aspect is concerned. As far as my way of thinking is concerned I think I might actually be somebody else. You now - not even a djinn. In fact, I think I might be a dwarf." 
"dwarf"       -> "Yes. Consider this: Dwarves live in the mountains. So do I. And just like dwarves I really like gold. But most of all, dwarves like beer. ...",
                 "Isn't that amazing? I think that is more than a coincidence. You know - perhaps I am a reincarnated dwarf or something. You never know." 
"human"       -> "See. That's another problem. In the past, it was us against you - djinn against humans. But one day this guy came along, and all of a sudden things were so much more complicated. ...",
                 "All of a sudden there was good djinn and evil djinn, and good humans and evil humans. Everything got so damn complicated. ...",
                 "All of a sudden we did not know who to trust and who to fight. Should we join the evil djnn and battle all humans? ...",
                 "Or was it smarter to ally with the good humans and to battle the bad djinn? ...",
                 "Perhaps we should join nobody and fight the bad humans? So many choices."
"efreet"      -> "I have thought long and hard about this and I have come to the conclusion that all Efreet are scum."
"ashta'daramai" -> "This place is the Marids' safe haven. No enemy has ever managed to take this fortress by assault, and we will see to it that it stays this way."
"mal'ouquah"  -> "That is the Efreets fortress. I have never seen it, but I'm sure it can't compare to this place."
"marid"		    -> "That's us. I suppose we are the good guys in this war. Although good is relative, of course. So let's say, we are relatively good. Depends on the point of view, really."
"war"         -> "We had thought the war was over for good when Malor was finally imprisoned. That little creep is as obstinate as... as... well, as a really obstinate djinn."
"malor"			  -> "Malor is evil. I mean - really evil. Things used to be much better when he was still locked away in that lamp."
"tibia"       -> "Tibia is a beautiful world. Not that I see much of it, staring at this wall night and day."
"world"       -> *
"gods"        -> "I have not made my mind up what to think about the gods yet. I am still struggling with Daraman's teachings."
"daraman"	    -> "Daraman has changed our lives. I mean, we were not stupid or anything before he came, but still it was different. Fa'hradin says that while Zathroth made us intelligent, Daraman made us think." 
"zathroth"    -> "Zathroth is not very popular among the djinn because it is said that he abandoned us even though he was our creator. Legend has it that we failed to meet his expectations. ...",
                 "Fa'hradin once said that all djinn are oedipally traumatised because of this, but I have no idea what he is talking about."

"darashia"    -> "They say Darashia is a beautiful human city somewhere to the north. I would really love to see it, but I can't abandon my post."
"edron"       -> "I understand the humans have founded some beautiful cities. I would like to see them, but as long as I have to stay here that won't happen. Which means I will not go anywhere as long as the war goes on."
"thais"       -> *
"venore"      -> *
"kazordoon"   -> *
"carlin"      -> *
"ab'dendriel" -> *
"ankrahmun"   -> "I was there, long ago. We had a garrison based in Ankrahmun during the early phases of the war. That was before the whole plains of the Kha'labal were set on fire."

"scarab"      -> "I don't care whether or not they are special animals. None of that creeping vermin will enter Ashta'daramai as long as I am here!"
"pharaoh"     -> "They say the new pharaoh is mad!"
"palace"      -> "I remember the palace. It was a beautiful place. Ah... those were happy days."
"temple"	    -> "In these heretic times the priests at Ankrahmun's temple are devoted to the teachings of that pompous pharaoh."
"ascension"   -> "Apparently that is what the followers of the pharaoh are striving for. It has to do with that pharaoh's teachings."
"rah"         -> "That's just some heretic drivel. Don't ask me about it."
"uthun"			  -> *
"akh"				  -> *

"kha'zeel"		-> "When I look up from my wall, what do I see? Huge, forbidding mountains! No wonder I feel claustrophobic."
"kha'labal"	  -> "Ah yes - the desert. I still remember how beautiful that land was back in the days before the war. ...",
                 "A land full of song and bliss it was - a veritable paradise. Fa'hradin once said its destruction was a supreme example of the transitoriness of all things mortal. ...",
                 "I am not sure I agree because I don't know what 'transitoriness' means." 
                 
"djema"       -> "You know her? She's a human like you. I like her lots because she often comes down here for a chat. Nobody else around here does that." 
"bo'ques"     -> "That fat old cook. I like his food, but I find him a bit boring. Food and cooking is all he ever talks about."
"alesar"      -> "Ah. That guy. He was one of us, a Marid, but he left long ago. I have no idea why. Rumours and hearsay is all I ever get."
"fa'hradin"   -> "Fa'hradin is a powerful wizard and the smartest djinn I know. I love talking to him because there is so much he can teach me, but he rarely has time for me."
"lamp"        -> "Djinns sleep in lamps. I don't know what is so special about that." 
"melchior"    -> "That name rings a bell. A trader from Ankrahmun... or was it Darashia? I remember him and his mule. He used to come up here quite often to do business with Haroun. ...",
                 "Lately I haven't seen him around, though. I think last time he came here was about 20 years ago."
}
Lua:
# GIMUD - Graphical Interface Multi User Dungeon
# ubaid.npc: Datenbank für den Efreetpförtner Ubaid

Name = "Ubaid"
Sex = male
Race = 51
Outfit = (51,0-0-0-0)
Home = [33046,32622,6]
Radius = 1
GoStrength = 5

Behaviour = {

ADDRESS,"hello$",QuestValue(278)=3,!      -> "Still alive, %N?"
ADDRESS,"hi$",QuestValue(278)=3,!         -> *
ADDRESS,"greetings$",QuestValue(278)=3,!  -> *
ADDRESS,"djanni'hah$",QuestValue(278)=3,! -> *
ADDRESS,"hello$",QuestValue(278)>0,!      -> "Shove off, little one! Humans are not welcome here, %N!", Idle
ADDRESS,"hi$",QuestValue(278)>0,!         -> *
ADDRESS,"greetings$",QuestValue(278)>0,!  -> *
ADDRESS,"hello$",!                        -> *
ADDRESS,"hi$",!                           -> *
ADDRESS,"greetings$",!                    -> *
ADDRESS,"djanni'hah$",QuestValue(278)>0,! -> "What? You know the word, %N? All right then - I won't kill you. At least, not now."
ADDRESS,"djanni'hah$",!                   -> "Hmmm? Is this human %N trying to say something? I don't think so.", Idle
ADDRESS,!                                 -> Idle

BUSY,"hello$",QuestValue(278)=3,!         -> "%N again. You have to wait.", Queue
BUSY,"hi$",QuestValue(278)=3,!            -> *
BUSY,"greetings$",QuestValue(278)=3,!     -> *
BUSY,"djanni'hah$",QuestValue(278)=3,!    -> *
BUSY,"hello$",QuestValue(278)>0,!         -> "Shove off, little one! You are not welcome here, %N!"
BUSY,"hi$",QuestValue(278)>0,!            -> *
BUSY,"greetings$",QuestValue(278)>0,!     -> *
BUSY,"hello$",!                           -> *
BUSY,"hi$",!                              -> *
BUSY,"greetings$",!                       -> *
BUSY,"djanni'hah$",QuestValue(278)>0,!    -> "Oh no! More of you humans! I'm busy, %N, so you better hold your tongue until I have time for you.", Queue
BUSY,"djanni'hah$",!                      -> "Hmmm? Is this human trying to say something? I don't think so."
BUSY,!                                    -> NOP

VANISH,!                                  -> "Why did you waste my time?"

"bye"           -> "Hail King Malor! See you on the battlefield, human worm.", Idle
"farewell"      -> *
"name"          -> "My name is Ubaid. Why do you want to know that, human? Hmm... suspicious."
"ubaid"			    -> "That is my name. I don't like it when a human pronounces it." 
"job"           -> "Well, what do you think? I keep watch around here to make sure people like you don't enter."

"gate"        -> "Only the mighty Efreet, the true djinn of Tibia, may enter Mal'ouquah! ...",
                 "All Marids and little worms like yourself should leave now or something bad may happen. Am I right?", Topic=1
"pass"        -> *
"door"        -> *
"enter"       -> *
"join"        -> *
"follow"      -> *

"gate",QuestValue(278)=3,!     -> "You already pledged loyalty to king Malor!"
"pass",QuestValue(278)=3,!     -> *
"door",QuestValue(278)=3,!     -> *
"enter",QuestValue(278)=3,!    -> *
"join",QuestValue(278)=3,!     -> *
"follow",QuestValue(278)=3,!   -> *



Topic=1,"no",QuestValue(278)=2,! -> "Who do you think you are? A Marid? Shove off, moron.", Idle
Topic=1,"no",! -> "Of cour... Huh!? No!? I can't believe it! ...",
                  "You... you got some nerves... Hmm. ...",
                  "Maybe we have some use for someone like you. Would you be interested in working for us. Helping to fight the Marid?", Topic=2

Topic=2,"yes",! -> "So you pledge loyalty to king Malor and you are willing to never ever set foot on Marids' territory, unless you want to kill them? Yes?", Topic=3
Topic=3,"yes",! -> "Well then - welcome to Mal'ouquah. ...",
                   "Go now to general Baa'leal and don't forget to greet him correctly! ...",
                   "And don't touch anything!", SetQuestValue(278,3), Idle
Topic=1,!       -> "Of course. Then don't waste my time and shove off.", Idle
Topic=2,!       -> *
Topic=3,!       -> *

"king"          -> "Well, Malor is not officially king of all djinn yet, but now our beloved leader is back that is a mere formality."
"malor"         -> *
"djinn"         -> "We are a race of rulers and dominators! Or at least we, the Efreet, are!"
"efreet"		    -> "The Efreet are the true djinn! Those namby-pamby milksops who call themselves the Marid and still follow Gabel, no longer deserve the honour to call themselves djinn."
"marid"		      -> "Marid? When? Where? How many? RED ALERT! ...", 
                   "Hey! There is nobody here! Don't do that again, human!"
"gabel"		      -> "I used to serve under Gabel, but he is no longer my king. If that wacky wimp should ever come here to Mal'ouquah I will personally... you know... turn him away. Yes!"
"mal'ouquah"    -> "This place is our home, and as long as I'm here no meddler will trespass!"
"ashta'daramai" -> "The Marids' hideout, isn't it? I have never been there, but I am sure one day I will. That will be the day Ashta'daramai falls into our hands!"
"human"         -> "You are an inferior race of feeble, scheming jerks. No offence."
"zathroth"      -> "Zathroth is our father! Of course, the son always has a right to hate his father, right?"
"tibia"         -> "This world is ours by right, and we will take it!"
"daraman"	      -> "How dare you utter that name in my presence, human. Don't strain my patience, worm! You may know the secret word, but... who knows... it is always possible that your head is torn off in some terrible accident."
"darashia"      -> "A human settlement to the west? I have not been there yet, but when I do I'm sure I will be remembered."
"scarab"        -> "They make good pets if you know how to keep them. Did you know they just adore human flesh?"
"edron"         -> "Isn't that the name of some petty human settlement?"
"thais"         -> *
"venore"        -> *
"kazordoon"     -> *
"carlin"        -> *
"ab'dendriel"   -> *
"ankrahmun"     -> "I know that damn city well. A long time ago we laid siege to it. ...",
                   "We would have taken it, but those traitorous humans allowed a Marid garrison to entrench itself there, and we never managed to throw them out. Cowards and traitors the lot of them."
"pharaoh"       -> "They say Ankrahmun is now ruled by a crazy pharaoh who wants to tell his whole people into drooling undead. That's humans. Sickos and weirdos the lot of them."
"palace"        -> "One day we will sack that place and burn it to the ground."
"temple"	      -> *
"ascension"     -> "I think I've heard that term before. Has to do with that weirdo pharaoh, right?"
"rah"           -> "Are you drunk?"
"uthun"			    -> *
"akh"				    -> *

"kha'zeel"      -> "This mountain range is our home. Too bad we have to share it with the Marid. That will change, though. And pretty soon, believe me."
"kha'labal"	    -> "I like the desert. Just ruins and sand. And no human scum to be seen. The Kha'labal is a foretaste of what the djinn will do to the whole of Tibia!"
"war"           -> "I don't know why I am stuck here! I should be at the front, killing Marid and humans. Well, perhaps I will kill you..."
"baa'leal"      -> "General Baa'leal is our commander-in-chief of all his minions. He is as tough as an ancient scarab's buttocks and as sly a sand weasel."
"alesar"        -> "I am not used to the sight of blueskins here in Mal'ouquah, and it does not make me too happy to see one. I am keeping an eye on this guy, and if I should ever find that he is playing games with us I will personally break his neck!"
"fa'hradin"     -> "The old wizard is dangerous, but he will get what he deserves sooner or later."
"lamp"          -> "I am not taking a nap! I am on duty!"
}
 
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
function npcHandler:say(msg) selfSay(msg) end
NpcSystem.parseParameters(npcHandler)

local main = 278
-- 1 => Knows the word of greeting
-- 2 => Joined Marid Faction
-- 3 => Joined Efreet Faction

local Topic, event, eventW, tmpFocus = 0, 0, 0, nil

local function walkAgain()
	if npcHandler.focuses == 0 then
		tmpFocus = nil
		selfFocus(0)
	end
end

local function loop(msg, cid)
	if npcHandler.focuses == 0 then
		stopEvent(eventW)
		if not tmpFocus then
			selfFocus(cid)
			tmpFocus = cid
		end
		eventW = addEvent(walkAgain, 6000)
	end
	doCreatureSay(getNpcCid(), msg[1], 1)
	table.remove(msg, 1)
	if msg[1] and isPlayer(cid) then
		event = addEvent(loop, 5000, msg, cid)
	end
end

function selfSay(msg, cid)
	if npcHandler.focuses == 0 then
		stopEvent(eventW)
		if not tmpFocus then
			selfFocus(cid)
			tmpFocus = cid
		end
		eventW = addEvent(walkAgain, 6000)
	end
	stopEvent(event)
	if type(msg) == 'table' then
		event = addEvent(loop, 1000, msg, cid)
	else
		event = addEvent(doCreatureSay, 1000, getNpcCid(), msg, 1)
	end
end

function msgcontains(message, keyword, ends)
	message, keyword = message:lower(), keyword:lower()
	if message:find(keyword) and not message:find('(%w+)' .. keyword) and (not ends or not message:find(keyword .. '(%w+)')) then
		return true
	end
end

function disappearCallback(cid)
	stopEvent(event)
	npcHandler:releaseFocus(cid)
	if isPlayer(cid) then
		selfSay('Back to work.', cid)
	end
	return false
end
npcHandler:setCallback(CALLBACK_CREATURE_DISAPPEAR, disappearCallback)
npcHandler:setCallback(CALLBACK_FAREWELL, disappearCallback)

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)
	if cid == npcHandler.focuses then
		stopEvent(event)
		npcHandler:releaseFocus(cid)
	end
end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink()
	if tmpFocus then
		if npcHandler.focuses == 0 and isPlayer(tmpFocus) then
			selfFocus(tmpFocus)
		else
			tmpFocus = nil
		end
	end
	npcHandler:onThink()
end 

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		if (msgcontains(msg, 'hello', true) or msgcontains(msg, 'hi', true) or msgcontains(msg, 'greetings', true) or msgcontains(msg, 'djanni\'hah', true)) then
			local v, p = getPlayerStorageValue(cid, main), getCreatureName(cid)
			if v == 2 then
				if npcHandler.focuses == 0 then
					npcHandler:addFocus(cid)
					selfSay(p .. "! How's it going these days?", cid)
					Topic = 0
				else
					selfSay("Hey " .. p .. "! Please wait a second!", cid)
				end
			elseif msgcontains(msg, 'djanni\'hah') then
				if v > 0 then
					if npcHandler.focuses == 0 then
						npcHandler:addFocus(cid)
						selfSay({"Whoa? You know the word! Amazing, " .. p .. "! ...", "I should go and tell Fa'hradin. ...", "Well. Why are you here anyway, " .. p .. "?"}, cid)
						Topic = 0
					else
						selfSay("Yikes! Another human? Where did you come from? Well, ehm - if you could please wait a second, " .. p .. "?", cid)
					end
				else
					if npcHandler.focuses == 0 then
						selfSay({"Hahahaha! ...", p .. ", that almost sounded like the word of greeting. Humans - cute they are!"}, cid)
					else
						selfSay("That almost sounded like the word of greeting, " .. p .. ". Humans - cute they are!", cid)
					end
				end
			else
				selfSay({npcHandler.focuses == 0 and "Whoa! A human! This is no place for you, " .. p .. ". ..." or "Another human! This is no place for you, " .. p .. ". ...", "Go and play somewhere else."}, cid)
			end
		else
			return false
		end
	elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
		npcHandler:releaseFocus(cid)
		selfSay("<salutes>Aaaa -tention!", cid)
		Topic = 0
	elseif msgcontains(msg, 'name') then
		selfSay("I am Umar. Pleased to meet you!", cid)
		Topic = 0
	elseif msgcontains(msg, 'job') then
		selfSay("I am the gatekeeper of Ashta'daramai. That's what Gabel told me to do. You know - keeping the courtyard clean, getting rid of salesmen, keeping Efreet scum out... that kind of thing. But in my spare time I work as a part-time philosopher.", cid)
		Topic = 0
	elseif msgcontains(msg, 'philosopher') then
		selfSay("Yes. Comes with the job. You see - here I am, sitting on the same chair all day and staring at the same blank wall. So what happens is that my mind starts wandering. And, you know, I start thinking. You know - about all kinds of things.", cid)
		Topic = 0
	elseif msgcontains(msg, 'philosopher') then
		selfSay("Yes. Comes with the job. You see - here I am, sitting on the same chair all day and staring at the same blank wall. So what happens is that my mind starts wandering. And, you know, I start thinking. You know - about all kinds of things.", cid)
		Topic = 0
	elseif msgcontains(msg, 'things') then
		selfSay("Yes. About the world and the gods and all that. And about girls. Yes, about girls, mostly.", cid)
		Topic = 0
	elseif msgcontains(msg, 'girls') then
		selfSay("You did not know there are female djinns, did you? That's because they are quite rare. They are the greatest treasures of our race, and we guard them jealously.", cid)
		Topic = 0
	elseif msgcontains(msg, 'gate') then
		selfSay("On the orders of king Gabel, who technically is no real king, only Marid may enter Ashta'daramai.", cid)
		Topic = 0
	elseif msgcontains(msg, 'pass') or msgcontains(msg, 'door') or msgcontains(msg, 'enter') or msgcontains(msg, 'join') or msgcontains(msg, 'follow') then
		if getPlayerStorageValue(cid, main) == 2 then
			selfSay("You allready have the permission to enter Ashta'daramai.", cid)
			Topic = 0
		else
			selfSay({"If you want to enter our fortress you have to become one of us and fight the Efreet. ...", "So, are you willing to do so?"}, cid)
			Topic = 1
		end
	elseif Topic == 1 then
		if msgcontains(msg, 'yes') then
			if getPlayerStorageValue(cid, main) == 3 then
				selfSay("I don't believe you! You better go now.", cid)
				npcHandler:releaseFocus(cid)
			else
				selfSay("Are you sure? You pledge loyalty to king Gabel, who is... you know. And you are willing to never ever set foot on Efreets' territory, unless you want to kill them? Yes?", cid)
				Topic = 2
			end
		else
			selfSay("This isn't your war anyway, human.", cid)
			Topic = 0
		end
	elseif Topic == 2 then
		if msgcontains(msg, 'yes') then
			selfSay({"Oh. Ok. Welcome then. You may pass. ...","And don't forget to kill some Efreets, now and then."}, cid)
			setPlayerStorageValue(cid, main, 2)
		else
			selfSay("This isn't your war anyway, human.", cid)
		end
		Topic = 0
	elseif msgcontains(msg, 'gabel') then
		selfSay("He is our king and leader. Well, he isn't a king, you know. I mean, from a technical point of view he is, but he does not wear a crown or anything, and he says he isn't one, so even though he is one he isn't. Right?", cid)
		Topic = 0
	elseif msgcontains(msg, 'king') then
		selfSay({"Okay, let's do this again. Gabel says he isn't a king, but he acts like one, which makes him one anyway - right? ...","But you know, he does not really act like one, either. I mean, he does give us orders and all that, and we obey sure enough, but it's not that we have to, I mean, technically speaking. ...","I mean - I don't know what would happen if anybody would not follow his orders for a change. After all he is no longer a king, right? ...","But then I don't want to be the first one to find out what happens if you disobey, so I always do as I'm told. ...","Which means I do not really know whether or not he is king. <sighs> Things were so much easier when Gabel still said he was king. Matters were so much clearer then."}, cid)
		Topic = 0
	elseif msgcontains(msg, 'djinn') then
		selfSay("Well, I am a djinn, but only as far as my physical aspect is concerned. As far as my way of thinking is concerned I think I might actually be somebody else. You now - not even a djinn. In fact, I think I might be a dwarf." )
		Topic = 0
	elseif msgcontains(msg, 'dwarf') then
		selfSay({"Yes. Consider this: Dwarves live in the mountains. So do I. And just like dwarves I really like gold. But most of all, dwarves like beer. ...","Isn't that amazing? I think that is more than a coincidence. You know - perhaps I am a reincarnated dwarf or something. You never know."}, cid)
		Topic = 0
	elseif msgcontains(msg, 'human') then
		selfSay({"See. That's another problem. In the past, it was us against you - djinn against humans. But one day this guy came along, and all of a sudden things were so much more complicated. ...","All of a sudden there was good djinn and evil djinn, and good humans and evil humans. Everything got so damn complicated. ...","All of a sudden we did not know who to trust and who to fight. Should we join the evil djnn and battle all humans? ...","Or was it smarter to ally with the good humans and to battle the bad djinn? ...","Perhaps we should join nobody and fight the bad humans? So many choices."}, cid)
		Topic = 0
	elseif msgcontains(msg, 'efreet') then
		selfSay("I have thought long and hard about this and I have come to the conclusion that all Efreet are scum.", cid)
		Topic = 0
	elseif msgcontains(msg, 'ashta\'daramai') then
		selfSay("This place is the Marids' safe haven. No enemy has ever managed to take this fortress by assault, and we will see to it that it stays this way.", cid)
		Topic = 0
	elseif msgcontains(msg, 'mal\'ouquah') then
		selfSay("That is the Efreets fortress. I have never seen it, but I'm sure it can't compare to this place.", cid)
		Topic = 0
	elseif msgcontains(msg, 'marid') then
		selfSay("That's us. I suppose we are the good guys in this war. Although good is relative, of course. So let's say, we are relatively good. Depends on the point of view, really.", cid)
		Topic = 0
	elseif msgcontains(msg, 'war') then
		selfSay("We had thought the war was over for good when Malor was finally imprisoned. That little creep is as obstinate as... as... well, as a really obstinate djinn.", cid)
		Topic = 0
	elseif msgcontains(msg, 'malor') then
		selfSay("Malor is evil. I mean - really evil. Things used to be much better when he was still locked away in that lamp.", cid)
		Topic = 0
	elseif msgcontains(msg, 'tibia') or msgcontains(msg, 'world') then
		selfSay("Tibia is a beautiful world. Not that I see much of it, staring at this wall night and day.", cid)
		Topic = 0
	elseif msgcontains(msg, 'gods') then
		selfSay("I have not made my mind up what to think about the gods yet. I am still struggling with Daraman's teachings.", cid)
		Topic = 0
	elseif msgcontains(msg, 'darama') then
		selfSay("Daraman has changed our lives. I mean, we were not stupid or anything before he came, but still it was different. Fa'hradin says that while Zathroth made us intelligent, Daraman made us think." )
		Topic = 0
	elseif msgcontains(msg, 'zathroth') then
		selfSay({"Zathroth is not very popular among the djinn because it is said that he abandoned us even though he was our creator. Legend has it that we failed to meet his expectations. ...","Fa'hradin once said that all djinn are oedipally traumatised because of this, but I have no idea what he is talking about."}, cid)
		Topic = 0
	elseif msgcontains(msg, 'darashia') then
		selfSay("They say Darashia is a beautiful human city somewhere to the north. I would really love to see it, but I can't abandon my post.", cid)
		Topic = 0
	elseif msgcontains(msg, 'edron') or msgcontains(msg, 'thais') or msgcontains(msg, 'venore') or msgcontains(msg, 'kazordoon') or msgcontains(msg, 'carlin') or msgcontains(msg, 'ab\'dendriel') then
		selfSay("I understand the humans have founded some beautiful cities. I would like to see them, but as long as I have to stay here that won't happen. Which means I will not go anywhere as long as the war goes on.", cid)
		Topic = 0
	elseif msgcontains(msg, 'ankrahmun') then
		selfSay("I was there, long ago. We had a garrison based in Ankrahmun during the early phases of the war. That was before the whole plains of the Kha'labal were set on fire.", cid)
		Topic = 0
	elseif msgcontains(msg, 'scarab') then
		selfSay("I don't care whether or not they are special animals. None of that creeping vermin will enter Ashta'daramai as long as I am here!", cid)
		Topic = 0
	elseif msgcontains(msg, 'pharaoh') then
		selfSay("They say the new pharaoh is mad!", cid)
		Topic = 0
	elseif msgcontains(msg, 'palace') then
		selfSay("I remember the palace. It was a beautiful place. Ah... those were happy days.", cid)
		Topic = 0
	elseif msgcontains(msg, 'temple') then
		selfSay("In these heretic times the priests at Ankrahmun's temple are devoted to the teachings of that pompous pharaoh.", cid)
		Topic = 0
	elseif msgcontains(msg, 'ascension') then
		selfSay("Apparently that is what the followers of the pharaoh are striving for. It has to do with that pharaoh's teachings.", cid)
		Topic = 0
	elseif msgcontains(msg, 'rah') or msgcontains(msg, 'uthun') or msgcontains(msg, 'akh') then
		selfSay("That's just some heretic drivel. Don't ask me about it.", cid)
		Topic = 0
	elseif msgcontains(msg, 'kha\'zeel') then
		selfSay("When I look up from my wall, what do I see? Huge, forbidding mountains! No wonder I feel claustrophobic.", cid)
		Topic = 0
	elseif msgcontains(msg, 'kha\'labal') then
		selfSay({"Ah yes - the desert. I still remember how beautiful that land was back in the days before the war. ...","A land full of song and bliss it was - a veritable paradise. Fa'hradin once said its destruction was a supreme example of the transitoriness of all things mortal. ...","I am not sure I agree because I don't know what 'transitoriness' means."}, cid)
		Topic = 0
	elseif msgcontains(msg, 'djema') then
		selfSay("You know her? She's a human like you. I like her lots because she often comes down here for a chat. Nobody else around here does that." )
		Topic = 0
	elseif msgcontains(msg, 'bo\'ques') then
		selfSay("That fat old cook. I like his food, but I find him a bit boring. Food and cooking is all he ever talks about.", cid)
		Topic = 0
	elseif msgcontains(msg, 'alesar') then
		selfSay("Ah. That guy. He was one of us, a Marid, but he left long ago. I have no idea why. Rumours and hearsay is all I ever get.", cid)
		Topic = 0
	elseif msgcontains(msg, 'fa\'hradin') then
		selfSay("Fa'hradin is a powerful wizard and the smartest djinn I know. I love talking to him because there is so much he can teach me, but he rarely has time for me.", cid)
		Topic = 0
	elseif msgcontains(msg, 'lamp') then
		selfSay("Djinns sleep in lamps. I don't know what is so special about that." )
		Topic = 0
	elseif msgcontains(msg, 'melchior') then
		selfSay({"That name rings a bell. A trader from Ankrahmun... or was it Darashia? I remember him and his mule. He used to come up here quite often to do business with Haroun. ...","Lately I haven't seen him around, though. I think last time he came here was about 20 years ago."}, cid)
		Topic = 0
	end
	return true
end

npcHandler:setMessage(MESSAGE_IDLETIMEOUT, "Back to work.")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
Here's an example of a perfectly emulated NPC behaviour from versions before 8.20, enjoy.
 
Last edited:
Back
Top