tarantonio
Old School Player
- Joined
- Jun 21, 2009
- Messages
- 865
- Solutions
- 1
- Reaction score
- 274
Well, almost all Oracle npcs are wrong, now that we have the Tibia RL 7.7 leaked files I want to replicate the RL behaviour.
I use OTHire but it can apply to other engines.
There is the Lua code for OTHire, but I need some help:
And this is the RL code:
I only need to replicate the point where The Oracle asks:
If the player is premium it goes this way:
If the player is not premium goes this way:
I don't know how to replicate this with Lua nodes, please help.
I use OTHire but it can apply to other engines.
There is the Lua code for OTHire, but I need some help:
Lua:
local LEVEL = 8
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions
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
-- OTServ event handling functions end
function oracle(cid, message, keywords, parameters, node)
if(cid ~= npcHandler.focus) then
return false
end
local cityNode = node:getParent():getParent()
local vocNode = node:getParent()
local destination = cityNode:getParameters().destination
local townid = cityNode:getParameters().townid
local voc = vocNode:getParameters().voc
if(destination ~= nil and voc ~= nil and townid ~= nil) then
if(getPlayerLevel(cid) < parameters.level) then
npcHandler:say('CHILD! COME BACK WHEN YOU HAVE GROWN UP!')
else
npcHandler:say('SO BE IT!')
doPlayerSetVocation(cid,voc)
doPlayerSetTown(cid,townid)
doTeleportThing(cid,destination)
doSendMagicEffect(destination, CONST_ME_MAGIC_BLUE)
end
else
error('Destination:', destination, 'Vocation:', vocation, 'Townid:', townid)
end
npcHandler:resetNpc()
return true
end
function greetCallback(cid)
if(getPlayerLevel(cid) < LEVEL) then
npcHandler:say('CHILD! COME BACK WHEN YOU HAVE GROWN UP!')
return false
else
return true
end
end
-- Set the greeting callback function
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
-- Set the greeting message.
npcHandler:setMessage(MESSAGE_GREET, '|PLAYERNAME|, ARE YOU PREPARED TO FACE YOUR DESTINY?')
-- Pre-create the yes/no nodes.
local yesNode = KeywordNode:new({'yes'}, oracle, {level = LEVEL})
local noNode = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'KNIGHT, PALADIN, SORCERER, OR DRUID?'})
-- Create the actual keyword structure...
local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'IN WHICH TOWN DO YOU WANT TO LIVE: CARLIN, THAIS, OR VENORE?'})
local node2 = node1:addChildKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 5, destination = {x=32360, y=31782, z=7}, text = 'IN CARLIN! AND WHAT PROFESSION HAVE YOU CHOSEN: KNIGHT, PALADIN, SORCERER, OR DRUID?'})
local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, voc = 3, onlyFocus = true, text = 'A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, voc = 4, onlyFocus = true, text = 'A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node2 = node1:addChildKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 3, destination = {x=32369, y=32241, z=7}, text = 'IN THAIS! AND WHAT PROFESSION HAVE YOU CHOSEN: KNIGHT, PALADIN, SORCERER, OR DRUID?'})
local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, voc = 3, onlyFocus = true, text = 'A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, voc = 4, onlyFocus = true, text = 'A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node2 = node1:addChildKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 4, destination = {x=32957, y=32076, z=7}, text = 'IN VENORE! AND WHAT PROFESSION HAVE YOU CHOSEN: KNIGHT, PALADIN, SORCERER, OR DRUID?'})
local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, voc = 3, onlyFocus = true, text = 'A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, voc = 4, onlyFocus = true, text = 'A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!'})
-- Make it react to hi/bye etc.
npcHandler:addModule(FocusModule:new())
And this is the RL code:
Code:
# GIMUD - Graphical Interface Multi User Dungeon
# oracle.npc: Datenbank fuer das Orakel auf Rookgaard
Name = "The Oracle"
Sex = female
Race = 1
Outfit = (0,2031)
Home = [32104,32190,6]
Radius = 0
GoStrength = 1
Behaviour = {
ADDRESS,"hello$",Level>=8,! -> "%N, ARE YOU PREPARED TO FACE YOUR DESTINY?"
ADDRESS,"hi$",Level>=8,! -> *
ADDRESS,"greet",Level>=8,! -> *
ADDRESS,"hello$",! -> "CHILD! COME BACK WHEN YOU HAVE GROWN UP!", Idle
ADDRESS,"hi$",! -> *
ADDRESS,"greet",! -> *
ADDRESS,! -> Idle
BUSY,"hello$",Level>=8,! -> "WAIT UNTIL IT IS YOUR TURN!", Queue
BUSY,"hi$",Level>=8,! -> *
BUSY,"greet",Level>=8,! -> *
BUSY,"hello$",! -> "CHILD! COME BACK WHEN YOU HAVE GROWN UP!"
BUSY,"hi$",! -> *
BUSY,"greet",! -> *
BUSY,! -> NOP
VANISH,! -> "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!"
"yes",premium -> "IN WHICH TOWN DO YOU WANT TO LIVE: CARLIN, EDRON, THAIS, OR VENORE?", Topic=1
"yes" -> "IN WHICH TOWN DO YOU WANT TO LIVE: CARLIN, THAIS, OR VENORE?", Topic=1
"bye",! -> "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!", Idle
-> *
Topic=1,"thais" -> Data=1, "IN THAIS! AND WHAT PROFESSION HAVE YOU CHOSEN: KNIGHT, PALADIN, SORCERER, OR DRUID?", Topic=2
Topic=1,"carlin" -> Data=2, "IN CARLIN! AND WHAT PROFESSION HAVE YOU CHOSEN: KNIGHT, PALADIN, SORCERER, OR DRUID?", Topic=2
Topic=1,"venore" -> Data=3, "IN VENORE! AND WHAT PROFESSION HAVE YOU CHOSEN: KNIGHT, PALADIN, SORCERER, OR DRUID?", Topic=2
Topic=1,"edron",premium -> Data=4, "IN EDRON! AND WHAT PROFESSION HAVE YOU CHOSEN: KNIGHT, PALADIN, SORCERER, OR DRUID?", Topic=2
Topic=1,"edron" -> "YOU NEED A PREMIUM ACCOUNT IN ORDER TO GO THERE!", Topic=1
Topic=1,premium -> "CARLIN, EDRON, THAIS, OR VENORE?", Topic=1
Topic=1 -> "CARLIN, THAIS, OR VENORE?", Topic=1
Topic=2,"knight" -> Type=1, "A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", Topic=3
Topic=2,"paladin" -> Type=2, "A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", Topic=3
Topic=2,"sorcerer" -> Type=3, "A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", Topic=3
Topic=2,"druid" -> Type=4, "A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", Topic=3
Topic=2 -> "KNIGHT, PALADIN, SORCERER, OR DRUID?", Topic=2
Topic=3,Data=1,"yes" -> "SO BE IT!", Profession(Type), StartPosition(32369,32241,7), Idle, EffectOpp(11), Teleport(32369,32241,7), EffectOpp(11)
Topic=3,Data=2,"yes" -> "SO BE IT!", Profession(Type), StartPosition(32360,31782,7), Idle, EffectOpp(11), Teleport(32360,31782,7), EffectOpp(11)
Topic=3,Data=3,"yes" -> "SO BE IT!", Profession(Type), StartPosition(32957,32076,7), Idle, EffectOpp(11), Teleport(32957,32076,7), EffectOpp(11)
Topic=3,Data=4,"yes" -> "SO BE IT!", Profession(Type), StartPosition(33217,31814,8), Idle, EffectOpp(11), Teleport(33217,31814,8), EffectOpp(11)
}
I only need to replicate the point where The Oracle asks:
Code:
-- Set the greeting message.
npcHandler:setMessage(MESSAGE_GREET, '|PLAYERNAME|, ARE YOU PREPARED TO FACE YOUR DESTINY?')
If the player is premium it goes this way:
Code:
"yes",premium -> "IN WHICH TOWN DO YOU WANT TO LIVE: CARLIN, EDRON, THAIS, OR VENORE?", Topic=1
If the player is not premium goes this way:
Code:
"yes" -> "IN WHICH TOWN DO YOU WANT TO LIVE: CARLIN, THAIS, OR VENORE?", Topic=1
I don't know how to replicate this with Lua nodes, please help.