What's new

TheOracle [8.1][NPC]

Status
Not open for further replies.
Joined
Apr 15, 2008
Messages
21
Reaction score
0
Robimy data/npc/scripts oracle.lua
Code:
local LEVEL = 8

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



-- OTServ event handling functions start
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('You must first reach level ' .. parameters.level .. '!')
else
doPlayerSetVocation(cid,voc)
doPlayerSetTown(cid,townid)
--doPlayerSetMasterPos(cid,destination)
doTeleportThing(cid,destination)
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, 'Hello |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 = 'Then what vocation do you want to become?'})

-- Create the actual keyword structure...
local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'What city do you wish to live in? Carlin, Thais or Venore.'})
local node2 = node1:addChildKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 5, destination = {x=703, y=600, z=7}, text = 'The carlin, eh? So what vocation do you wish to become? Sorcerer, druid, paladin or knight?'})
local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'So, you wish to be a powerful magician? Are you sure about that? This decision is irreversible!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'Are you sure that a druid is what you wish to become? 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 ranged marksman. 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 mighty warrior. Is that your final decision? 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=712, y=1059, z=7}, text = 'The thais, eh? So what vocation do you wish to become? Sorcerer, druid, paladin or knight?'})
local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'So, you wish to be a powerful magician? Are you sure about that? This decision is irreversible!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'Are you sure that a druid is what you wish to become? 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 ranged marksman. 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 mighty warrior. Is that your final decision? 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=1300, y=894, z=7}, text = 'The venore, eh? So what vocation do you wish to become? Sorcerer, druid, paladin or knight?'})
local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, voc = 1, onlyFocus = true, text = 'So, you wish to be a powerful magician? Are you sure about that? This decision is irreversible!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
local node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, voc = 2, onlyFocus = true, text = 'Are you sure that a druid is what you wish to become? 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 ranged marksman. 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 mighty warrior. Is that your final decision? This decision is irreversible!'})
node3:addChildKeywordNode(yesNode)
node3:addChildKeywordNode(noNode)
keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Then come back when you are ready.'})

-- Make it react to hi/bye etc.
npcHandler:addModule(FocusModule:new())


-- Makes sure the npc reacts when you say hi, bye etc.
npcHandler:addModule(FocusModule:new())
i the oracle w data/npc/
Code:
<npc name="The Oracle" script="data/npc/scripts/oracle.lua" autowalk="0" floorchange="0" access="5" level="1" maglevel="0">
<health now="150" max="150"/>
<look typeex="1448" corpse="2212"/>
<parameters>

</parameters>
</npc>
Skrypt by me (gg 10106053)
 

Masiar

Advanced User
Joined
Apr 12, 2008
Messages
274
Reaction score
21
bardzo fajne 10/10 my?le ?e przyda si? to na wielu otsach (na moim r?wnierz)
Pozdrawiam.
Masiar
 

Patus

Active User
Joined
Apr 5, 2008
Messages
127
Reaction score
22
Dzieki bardzoo szukalem tego juz od dawana 10/10. Do tej poty nie mog?em tego nigdzie znale?? nawet jak wpisywa?em w "google" czy na tej stronie w obpcji "szukaj".
 
Last edited:

Minokon

Active User
Joined
Apr 8, 2008
Messages
76
Reaction score
1
dzieki tego potrzebowalem
PS. wie ktos zeby accmanager byl na rooku nie chcial o wybor profesji??
 

Bolmex

Advanced User
Joined
Apr 7, 2008
Messages
322
Reaction score
53
@up
Nieda rady chyba tego zrobi? ?eby AccManager nie chiac? wyboru profesji. Da si? chyba tylko przez AccMakera ale nie wiem jak przypuszczam ?e trzeba by?o by poszpera? w plikach serverowych albo w plikach od stronki.
@Topic
Ja powiem tak jak moi poprzednicy te? tego potrzebowa?em ale musze najpierw pomy?le? jak to zrobi?.
 

Masiar

Advanced User
Joined
Apr 12, 2008
Messages
274
Reaction score
21
@up
polecam silnik TFS. tam jest taka opcja ;d
 

mateusz605

User
Joined
Apr 5, 2008
Messages
17
Reaction score
0
Dzi?ki za npc. Bardzo mi si? przyda?, bo zrobi?em niedawno rook na swoim ots i teraz umieszcze tam npc i bedzi? si? ju? mo?na przenosi? na main.
 

Hoxaver

Banned
Joined
Apr 4, 2008
Messages
300
Reaction score
60
Skrpypt przyda si? wielu osobom. Z tego co widz? bardzo poprawny.
 
Joined
Apr 26, 2008
Messages
10
Reaction score
0
gratulacj?, naprawd? bardzo przydatny skrypcik. Ju? dodaje do otsika ;) 10/10

#Edit

Przechwali?em :-/ nie dzia?a mi w RME :-( pisze The Oracle klikam a nic si? nie pojawia. Help Me PLX!
 
Last edited:

lolek123e

User
Joined
Apr 6, 2008
Messages
13
Reaction score
0
Npc Mi dziala ale jak wlaczam otsa to pisze ze cos w global musze zrobic Prosze o pomoc npc dziala ale go nie ma ;/
 

DeGhost

Active User
Joined
Apr 14, 2008
Messages
82
Reaction score
7
Mam ma?y problem z tym npc ...
Chyba niechce mi silnik go w czyta? ...
Oto ss :
hxxp://img212.imageshack.us/img212/4931/beztytuuid8.jpg
 

lolek123e

User
Joined
Apr 6, 2008
Messages
13
Reaction score
0
Mi tak samo jak u ciebie Bo mamy Devlanda trzeba cos zrobic ale sam nie wiem co ;/
 

Niedzwiedz

New User
Joined
May 1, 2008
Messages
5
Reaction score
0
gratulacj?, naprawd? bardzo przydatny skrypcik. Ju? dodaje do otsika ;) 10/10

#Edit

Przechwali?em :-/ nie dzia?a mi w RME :-( pisze The Oracle klikam a nic si? nie pojawia. Help Me PLX!
Bo RME nie jest najlepszym map edytorem ... sam wole tego zwyklego
Poza tym skrypcik dobry.dalem go mojemu koledze bo ja rooka nie mam ;);););););););)
 

Patrykolo

New User
Joined
Apr 22, 2008
Messages
1
Reaction score
0
Ja nie umiem tego robi?, jak kto? mo?e mi pom?c to niech pisze na gg 8827236.
 

damian1964

New User
Joined
Apr 8, 2008
Messages
5
Reaction score
0
A jak zmienic w nim zeby pisal inne miasta i do niego przenosil ???

pls o fast odp :)
 

osxxx1

User
Joined
Apr 7, 2008
Messages
14
Reaction score
0
Na wielu real otsach ten skrypt juz jest na reputa nie zasluzyles ale dla pustych ots moze sie pszydac scenografia fatalna ale dzianki temu masz punkt opis zero wychodzi na 5/10
 
Status
Not open for further replies.
Top