Gosu OTS

Forum naszego ots


#1 2008-08-26 12:54:49

Gosu

Hoster

13830120
Zarejestrowany: 2008-08-18
Posty: 694
Punktów :   

NPC Oracle

Bo to pomyslalem ze komus sie przyda xd Jedziemy:

Najpierw robimy sobie plik: oracle.lua o następującej zawartości i wkleić do data/npc

Kod:

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
            if voc == 1 then
                                                     doPlayerAddItem(cid,2190,1)
                                                     doPlayerSendTextMessage(cid,22,"You are now a Sorcerer. May your new wand give you might!")
                                                     end
                                                     if voc == 2 then
                                                     doPlayerAddItem(cid,2182,1)
                                                     doPlayerSendTextMessage(cid,22,"You are now a Druid. May your new rod give you intellect!")
                                                     end
                                                     if voc == 3 then
                                                     doPlayerAddItem(cid,2456,1)
                                                     doPlayerAddItem(cid,2544,50)
                                                     doPlayerSendTextMessage(cid,22,"You are now a Paladin. May your new Bow and Arrows protect you in dangerous cases!")
                                                     end
                                                     if voc == 4 then
                                                     doPlayerAddItem(cid,2428,1)
                                                     doPlayerAddItem(cid,2531,1)
                                                     doPlayerSendTextMessage(cid,22,"You are now a Knight. May your new shield and axe give you strength!")
                                                     end
                                                     doPlayerSetVocation(cid,voc)
            doPlayerSetTown(cid,townid)
                                               doTeleportThing(cid,destination)
                                               doSendMagicEffect(destination,12)

        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 = 2, destination = {x=32360, y=31782, z=7}, text = 'Carlin will be your home-town! 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 = '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 nimble 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 valorous 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 = 5, destination = {x=32369, y=32241, z=7}, text = 'Thais will be your home-town! 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 = 'A mighty 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 nimble 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 valorous 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 = 6, destination = {x=32957, y=32076, z=7}, text = 'Venore will be your home-town! 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 = 'A mighty 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 nimble 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 valorous knight! Are you sure? 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())

Musisz jeszcze zrobić plik: The Oracle.xml i wkleić do: data/npc/scripts

Kod:

<?xml version="1.0"?>
       <npc name="The Oracle" script="data/npc/scripts/oracle.lua" access="3" floorchange="0" autowalk="0">
                            <health now="1000" max="1000"/>    
                            <look typeex="1448"/>
       <parameters>
           
       </parameters>                         
       </npc>

i gotowe


http://tibiaimage.com/char/3/Gosu+Slayer.png

Offline

 

#2 2008-08-26 12:56:32

skrabix

Game Master

6292503
Zarejestrowany: 2008-08-20
Posty: 151
Punktów :   

Re: NPC Oracle

YYY a co to jest za koleś? XD


Jeśli grasz w metina i brakuje ci yang to wejdź tu i pobierz:
http://tnij.com/5FlZ
--------------------------------------------------------------------------------------
Pomogłem?? Daj reputka

Offline

 

#3 2008-08-26 13:46:47

Gosu

Hoster

13830120
Zarejestrowany: 2008-08-18
Posty: 694
Punktów :   

Re: NPC Oracle

Wyrocznia >.<


http://tibiaimage.com/char/3/Gosu+Slayer.png

Offline

 

#4 2008-08-26 14:03:22

skrabix

Game Master

6292503
Zarejestrowany: 2008-08-20
Posty: 151
Punktów :   

Re: NPC Oracle

Aha też prawda xD


Jeśli grasz w metina i brakuje ci yang to wejdź tu i pobierz:
http://tnij.com/5FlZ
--------------------------------------------------------------------------------------
Pomogłem?? Daj reputka

Offline

 

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi


Darmowe Forum | Ciekawe Fora | Darmowe Fora
www.andrewiprzyjaciele.pun.pl www.forumsko.pun.pl www.redmoondk.pun.pl www.joka.pun.pl www.magic-fight.pun.pl