Ir para conteúdo

Exemplos de NPC


SamueLGuedes

Posts Recomendados

Mostrarei aqui, exemplos de NPCs Comuns no TIBIA.

AwkUqYB.png

 

NPC Distance

(Vendedor de Artigos para Paladins)

 

Spoiler

 

data\npc\Distance.xml

<npc name="Frenzy" script="data/npc/scripts/distance.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">    <health now="150" max="150"/>    <look type="134" head="57" body="59" legs="40" feet="76" corpse="2212"/>    <parameters>        <parameter key="module_shop" value="1" />        <parameter key="shop_sellable" value="crossbow,2455,150;bow,2456,130" />        <parameter key="shop_buyable" value="crossbow,2455,360;bow,2456,200;spear,2389,20;power bolt,2547,200;burst arrow,2546,56;poison arrow,2545,18;bolt,2543,3;arrow,2544,2" />    </parameters></npc>

 

data\npc\scripts\distance.lua

local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler) -- OTServ event handling functions startfunction onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) endfunction onThink()                         npcHandler:onThink() end-- OTServ event handling functions end npcHandler:addModule(FocusModule:new())

 

 

 

separador+blog.jpg

 

NPC Boat (Funções no próprio XML)

(Para viagens entre citys)

 

 

Spoiler

 

data\npc\Boat.xml 

 

<npc name="Captain Steven" script="data/npc/scripts/travel.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">    <health now="150" max="150"/>    <look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/>    <parameters>        <parameter key="module_travel" value="1" />        <parameter key="travel_destinations" value="derelin,1294,429,6,119;farda,865,251,6,123;taqinata,868,690,6,134" />         <parameter key="module_keywords" value="1" />        <parameter key="keywords" value="job;name;offer;help;mission;quest" />        <parameter key="keyword_reply1" value="I am the captain of this ship." />        <parameter key="keyword_reply2" value="My name is Steven. Why do you ask?" />        <parameter key="keyword_reply3" value="I offer only the possability to travel to far away cities on this continent." />        <parameter key="keyword_reply4" value="Do I look like a helpful guy to you?" />        <parameter key="keyword_reply5" value="What are you talking about?" />        <parameter key="keyword_reply6" value="Hum. I'll tell you what! If you come back in a month or so I might be able to help you with that my friend." />    </parameters></npc>

 

data\npc\scripts\travel.lua:

 

local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)   -- OTServ event handling functions startfunction onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) endfunction onThink()                         npcHandler:onThink() end-- OTServ event handling functions end   -- Makes sure the npc reacts when you say hi, bye etc.npcHandler:addModule(FocusModule:new())

 

 

 

separador+blog.jpg

 

NPC Boat (Funções no próprio LUA)

 

 

Spoiler

 

data\npc\Boat.xml 

<npc name="Captain Steven" script="data/npc/scripts/travel.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">    <health now="150" max="150"/>    <look type="133" head="20" body="120" legs="75" feet="13" corpse="2212"/>    <parameters>     </parameters></npc>

 

data\npc\scripts\travel.lua

 

local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)   -- OTServ event handling functions startfunction onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) endfunction onThink()                         npcHandler:onThink() end-- OTServ event handling functions end  -- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!local travelNode = keywordHandler:addKeyword({'derelin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Derelin for 119 gold coins?'})    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 119, destination = {x=1367, y=403, z=7} })    travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'I wouldn\'t go there either.'}) local travelNode = keywordHandler:addKeyword({'drunia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you wish to travel to Drunia for 123 gold coins?'})    travelNode:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 0, cost = 123, destination = {x=967, y=247, z=7} })    travelNode:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Too expensive, eh?'}) keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can take you to Derelin or Drunia for just a small fee.'}) -- Makes sure the npc reacts when you say hi, bye etc.npcHandler:addModule(FocusModule:new())

 

 

 

separador+blog.jpg

 

NPC King

(Para promotion)

 

 

Spoiler

 

data\npc\King.xml:

<npc name="The King" script="data/npc/scripts/promotion.lua" autowalk="0" floorchange="0" access="5" level="1" maglevel="1">    <health now="150" max="150"/>    <look type="137" head="140" body="64" legs="121" feet="76" corpse="2212"/>    <parameters>        <parameter key="message_farewell" value="Farewell |PLAYERNAME|!" />    </parameters></npc>

 

data\npc\script\promotion.lua:

 

local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)   -- OTServ event handling functions startfunction onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) endfunction onThink()                         npcHandler:onThink() end-- OTServ event handling functions end local node1 = keywordHandler:addKeyword({'promot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can promote you for 20000 gold coins. Do you want me to promote you?'})    node1:addChildKeyword({'yes'}, StdModule.promotePlayer, {npcHandler = npcHandler, promotions = {[1] = 5, [2] = 6, [3] = 7, [4] = 8}, cost = 20000, level = 20, text = 'Congratulations! You are now promoted.'})    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Allright then. Come back when you are ready.', reset = true}) npcHandler:addModule(FocusModule:new())

 

 

 

separador+blog.jpg

 

NPC Oracle

(Para sua primeira Vocation)

 

 

Spoiler

 

data\npc\Oracle.xml:

<npc name="The Oracle" script="data/npc/scripts/oracle.lua" autowalk="0" floorchange="0" access="5" level="1" maglevel="1">    <health now="150" max="150"/>    <look typeex="1448" corpse="2212"/>    <parameters>     </parameters></npc>

 

data\npc\scripts\oracle.lua:

local LEVEL = 8 local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)   -- OTServ event handling functions startfunction onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) endfunction 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 trueend  function greetCallback(cid)    if(getPlayerLevel(cid) < LEVEL) then        npcHandler:say('CHILD! COME BACK WHEN YOU HAVE GROWN UP!')        return false    else        return true    endend -- Set the greeting callback functionnpcHandler: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? Derelin or Drunia?'})    local node2 = node1:addChildKeyword({'derelin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 3, destination = {x=1330, y=368, z=7}, text = 'The desert city of Derelin, 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({'drunia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, townid = 1, destination = {x=939, y=263, z=7}, text = 'The town of Drunia, 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())

 

 

 

separador+blog.jpg

 

NPC Runes

(Vendedor de Runas)

 

 

Spoiler

 

data\npc\Runes.xml

<npc name="Mike" script="data/npc/scripts/runes.lua" autowalk="1" floorchange="0" access="5" level="1" maglevel="1">    <health now="150" max="150"/>    <look type="130" head="39" body="122" legs="125" feet="57" corpse="2212"/>    <parameters>        <parameter key="message_greet" value="Hello |PLAYERNAME|. Do you want to buy any spell runes?" />        <parameter key="message_needmoremoney" value="You do not have enough money." />        <parameter key="message_decline" value="Is |TOTALCOST| gold coins too much for you? Get out of here!" />    </parameters></npc>

 

data\npc\scripts\runes.lua

 

local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)   -- OTServ event handling functions startfunction onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) endfunction onCreatureDisappear(cid)             npcHandler:onCreatureDisappear(cid) endfunction onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg) endfunction onThink()                         npcHandler:onThink() end-- OTServ event handling functions end local shopModule = ShopModule:new()npcHandler:addModule(shopModule) shopModule:addBuyableItem({'light wand', 'lightwand'},         2163, 500,         'magic light wand')shopModule:addBuyableItem({'mana fluid', 'manafluid'},         2006, 100,     7,     'mana fluid')shopModule:addBuyableItem({'life fluid', 'lifefluid'},         2006, 80,     10,    'life fluid')shopModule:addBuyableItem({'heavy magic missile', 'hmm'},     2311, 125,     10,    'heavy magic missile rune')shopModule:addBuyableItem({'great fireball', 'gfb'},             2304, 180,     4,     'great fireball rune')shopModule:addBuyableItem({'explo', 'xpl'},                     2313, 250,     6,     'explosion rune')shopModule:addBuyableItem({'ultimate healing', 'uh'},         2273, 175,     2,     'ultimate healing rune')shopModule:addBuyableItem({'sudden death', 'sd'},             2268, 325,     2,     'sudden death rune')shopModule:addBuyableItem({'blank', 'rune'},                     2260, 10,         'blank rune')  npcHandler:addModule(FocusModule:new())

 

 

 

Creditos: MokerHamer

 

 

Editado por SamueLGuedes
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...