Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

Falaaaaa, galerinha! Bem, hoje compartilho com vocês o código da Goblin Merchant Quest que é a quest dos coryms lá de venore ?Na verdade, estou compartilhando as duas primeiras missões. A depender do feedback, se o pessoal se interessar pelo tipo de conteúdocompartilho as outras missões. Acredito que a quest pode ser aproveitada em servidores com foco no RPG ou apenas para levar algo diferente ao servidor. Lembrando que o código é para TFS 0.4.

 

Para saber mais sobre a quest: https://www.tibiawiki.com.br/wiki/Goblin_Merchant_Quest

 

As falas do NPC Rafzan estão 99% iguais ao global. Aquele 1% vagabundo? é de algumas adaptações que fiz. Adaptei os itens que foram utilizados na quest, já que não possuía os itens utilizados na quest do global por ter feito em uma versão anterior a atual. No entanto, está facilmente editável para vocês também colocarem os ids que desejarem.

 

Configuração:

 

  • Em data/lib crie o arquivo Goblin Merchant Quest.lua e cole isto dentro:

 

Spoiler

-- Globin Merchant Quest by Dwarfer

RAFZAN = {

    mission01 = { -- Missão: Publicidade para Rafzan
        cracked_stone = 1285, -- id da cracked stone (pedra sem a placa)
        signed_stone = 10023, -- id da pedra com a placa
        signs_to_place = 3, -- quantidade de sinais necessários para colocar
        signs_id = 2229, -- id da placa (sinal)
        time_to_again = {1, "day"}, -- tempo para fazer a task novamente -> ex.: {60, "sec"}, {10, "min"}, {20, "hour"}
        
        rewards = { -- recompensas
            experience = 1000,
            money = 1000
        },
        
        storages = { -- só modifique se necessário
            advertising_counter = 74410,
            time_check = 74411
        }
    },
    
    mission02 = { -- Missão: Perfume para Corym
        perfume_gatherer = 2007, -- id do perfume gatherer
        slug_corpse = 6532, -- id do corpo do slug
        black_swamp_gas = 8062, -- id do field de gás
        fart_monster = "Rotworm", -- nome do monstro no qual o gatherer será utilizado
        moudly_cheese = 2235, -- id do queijo
        time_to_again = {1, "day"}, -- tempo para fazer a task novamente -> ex.: {60, "sec"}, {10, "min"}, {20, "hour"}
        
        rewards = { -- recompensas
            experience = 1000,
            money = 1000
        },
        
        storages = {  -- só modifique se necessário
            perfume_gatherer = 74412,
            time_check = 74413
        }
    }
}

function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return error("Bad declaration in mathtime function.")
end

 

 

 

  • No items.xml (Escolha os ids que preferir e edite de forma semelhante, mostrarei os que escolhi):

 

---> Para a missão 1:

  

* cracked stone (id 1285)

<item fromid="1285" toid="1292" article="a" name="stone" />

* skull stone (id 10023)

<item id="10023" article="a" name="skull stone">
  <attribute key="description" value="It is used to mark the way." />
  <attribute key="decayTo" value="1285" />
  <attribute key="duration" value="60" />
  <attribute key="weight" value="950" />
</item>

* skulls (id 2229)

<item id="2229" article="a" name="skull" plural="skulls">
  <attribute key="weight" value="2180" />
</item>

O resultado ficou assim:

3xzvFn2.gif

 

--->Para a missão 2:

 

* perfume gatherer (id 2007)

<item id="2007" article="a" name="perfume gatherer">
  <attribute key="weight" value="250" />
  <attribute key="description" value="It is empty. The first odour you'r looking for is special snail slime." />
</item>

 

  • Em data/actions/scripts, crie o arquivo rafzan_mission01.lua e cole isto dentro:

 

Spoiler

function onUse(cid, item, fromPosition, itemEx, toPosition) 
    local x = RAFZAN.mission01
    local advert_counter = getPlayerStorageValue(cid, x.storages.advertising_counter)
    if advert_counter ~= -1 and advert_counter < x.signs_to_place then
        if itemEx.itemid == x.cracked_stone then
            doTransformItem(itemEx.uid, x.signed_stone)
            doDecayItem(itemEx.uid)
            setPlayerStorageValue(cid, x.storages.advertising_counter, advert_counter + 1)
            doSendMagicEffect(toPosition, CONST_ME_POFF)
            doRemoveItem(item.uid, 1)
            return true
        end
    end
    return false
end

 

 

  • Em data/actions/scripts, crie o arquivo rafzan_mission02.lua e cole isto dentro:

 

Spoiler

function onUse(cid, item, fromPosition, itemEx, toPosition) 
    local perfume = getPlayerStorageValue(cid, RAFZAN.mission02.storages.perfume_gatherer)
    local order = {
        [1] = {id = RAFZAN.mission02.slug_corpse, msg = "You gather the first part of the rat perfume!", description = "It is partly filled. The second odour you need is black samp gas."},
        [2] = {id = RAFZAN.mission02.black_swamp_gas, msg = "You gather the second part of the rat perfume!", description = "It is partly filled. The third odour you need is a rotworm fart."},
        [4] = {id = RAFZAN.mission02.moudly_cheese, msg = "You gather the last part of the rat perfume!", description = "It is full filled."}
    }
    if perfume ~= -1 then
        local gatherer_sequence = getItemAttribute(item.uid, "sequence")
        if not isCreature(itemEx.uid) then
            local task_step = order[gatherer_sequence]
            if task_step then
                if itemEx.itemid == task_step.id then
                    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, task_step.msg)
                    doItemSetAttribute(item.uid, "sequence", gatherer_sequence + 1)
                    doItemSetAttribute(item.uid, "description", task_step.description)
                    doSendMagicEffect(toPosition, CONST_ME_POFF)
                    if itemEx.itemid == order[4].id then
                        doRemoveItem(itemEx.uid, 1)
                    end
                end
            end
        else
            if gatherer_sequence == 3 then
                if getCreatureName(itemEx.uid):lower() == RAFZAN.mission02.fart_monster:lower() then
                    if math.random(1, 100) <= 80 then
                        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You gather the third part of the rat perfume.")
                        doItemSetAttribute(item.uid, "description", "It is partly filled. The final odour you need is that of moudly cheese.")
                        doItemSetAttribute(item.uid, "sequence", gatherer_sequence + 1)
                        doSendMagicEffect(toPosition, CONST_ME_POFF)
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Damn, it didn't fart!")
                    end
                end
            end
        end
        return true
    end
    return false
end

 

 

  • No actions.xml, adicione as linhas:
<action itemid="2229" script="rafzan_mission01.lua" /> <!-- id da placa -->
<action itemid="2007" script="rafzan_mission02.lua" /> <!-- id do perfume gatherer -->

 

  • E por último, mas não menos importante, em data/npc crie o arquivo Rafzan.xml:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Rafzan" script="rafzan.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
    <look type="61"/>
    <parameters>
        <parameter key="module_shop" value="1" />
        <parameter key="shop_buyable" value="backpack,1988,10;bag,1987,4;fishing rod,2580,150;rope,2120,50;shovel,2554,10;scythe,2550,12;torch,2050,2;worm,3976,1;" />
        <parameter key="shop_sellable" value="fishing rod,2580,30;rope,2120,8;shovel,2554,2;" />
    </parameters>
</npc>

Lembrando que coloquei somente os itens que existiam na versão que utilizei.

 

  • Em data/npc/scripts, crie o arquivo rafzan.lua e cole isto dentro:

 

Spoiler

-- Goblin Merchant Quest by Dwarfer

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local npcTopic = {}
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
 

local function doNpcTellStory(cid, story_tab)
    for i = 1, #story_tab do
        npcHandler:say(story_tab[i], cid)
    end
end
 
function creatureSayCallback(cid, type, msg)
    local talkUser, msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid, string.lower(msg)
    if (not npcHandler:isFocused(cid)) then
        if isInArray({"hi", "hello"}, msg) then
            npcHandler:addFocus(cid)
            npcHandler:say("Hello, hello. Me peaceful, poor and honest goblin. Are you lookin' for {trade} or want to {help} me?", cid)
            npcTopic[talkUser] = 1
        else
            return false
        end
    elseif msgcontains(msg, "advertising") and npcTopic[talkUser] == 1 then
            local x = RAFZAN.mission01
            if getPlayerStorageValue(cid, x.storages.time_check) <= os.time() then
                local advert_counter = getPlayerStorageValue(cid, x.storages.advertising_counter)
                if advert_counter == -1 then 
                    npcHandler:say("Me need to get well known all over the swamp. Cheapest prices, best service in whole swamp. Me need you to place some advertisement signs in the swamp. Are you helping poor me?", cid)
                    npcTopic[talkUser] = 2
                else
                    if advert_counter < x.signs_to_place then  
                        local left = (x.signs_to_place - advert_counter)
                        npcHandler:say("You no ready! Gogogo! You left to place ".. left .. " more sign"..(left > 1 and "s" or "")..".", cid)
                    else
                        local r = x.rewards
                        npcHandler:say("You did not too bad, me guess. Though me children will starve, I give you biggest reward, don't tell others. Only you get good reward. You are me best.", cid)
                        if r.experience > 0 then
                            doPlayerAddExperience(cid, r.experience)
                            doSendAnimatedText(getPlayerPosition(cid), r.experience, COLOR_WHITE)
                        end
                        if r.money > 0 then
                            doPlayerAddMoney(cid, r.money)                            
                        end
                        setPlayerStorageValue(cid, x.storages.advertising_counter, -1)
                        setPlayerStorageValue(cid, x.storages.time_check, mathtime(x.time_to_again) + os.time())
                    end
                end
            else
                npcHandler:say("Not the time for that again. Me don't want to overuse me tricks. I can give you this mission only at ".. os.date("%d %B %Y %X", getPlayerStorageValue(cid, x.storages.time_check))..".", cid)
            end
    elseif msgcontains(msg, "perfume") and npcTopic[talkUser] == 1 then
            local x = RAFZAN.mission02
            if getPlayerStorageValue(cid, x.storages.time_check) <= os.time() then
                if getPlayerStorageValue(cid, x.storages.perfume_gatherer) == -1 then
                    doNpcTellStory(cid, {"Me mostly deal with ratmen for old stuff they collected. Nothing to make any profit, nonono. But me need stuff to keep alive. Ratmen are fond of perfume I invented. ...",
                                        "I need you to create more of it. Are you helping poor me?"})
                    npcTopic[talkUser] = 3
                else
                    if getPlayerItemCount(cid, x.perfume_gatherer) == 1 then
                        local filled_gatherer = getPlayerItemById(cid, true, x.perfume_gatherer)
                        if filled_gatherer.uid > 0 then
                            local check_gatherer = getItemAttribute(filled_gatherer.uid, "sequence")
                            if check_gatherer == 5 then
                                local r = x.rewards
                                npcHandler:say("You did not too bad, me guess. Though me children will starve, I give you biggest reward, don't tell others. Only you get good reward. You are me best.", cid)
                                if r.experience > 0 then
                                    doPlayerAddExperience(cid, r.experience)
                                    doSendAnimatedText(getPlayerPosition(cid), r.experience, COLOR_WHITE) 
                                end
                                if r.money > 0 then
                                    doPlayerAddMoney(cid, r.money)                            
                                end
                                doRemoveItem(filled_gatherer.uid, 1)
                                setPlayerStorageValue(cid, x.storages.time_check, os.time() + mathtime(x.time_to_again))
                                setPlayerStorageValue(cid, x.storages.perfume_gatherer, -1)
                            else
                                npcHandler:say("You no ready! Gogogo!", cid)
                            end
                        else
                            npcHandler:say("You no ready! Gogogo!", cid)
                        end
                    else
                        npcHandler:say("I do not need more than one perfume gatherer. Only the full filled is enough for me.", cid)
                    end
                end
            else
                npcHandler:say("Not the time for that again. Me don't want to overuse me tricks. I can give you this mission only at ".. os.date("%d %B %Y %X", getPlayerStorageValue(cid, x.storages.time_check))..".", cid)
            end
    elseif msgcontains(msg, "yes") and npcTopic[talkUser] == 2 then
        local sign = {id = RAFZAN.mission01.signs_id, count = RAFZAN.mission01.signs_to_place}
        local needed_cap = getItemWeightById(sign.id, sign.count, false)
        if getPlayerFreeCap(cid) >= needed_cap then
            npcHandler:say("Oh, so thankful me be! So take these three signs and place them on cracked stones you find all over the swamp. There they stay at least for a while before getting stolen or blown away.", cid)
            
            if isItemStackable(sign.id) then
                doPlayerAddItem(cid, sign.id, sign.count)
            else
                for k = 1, sign.count do
                    doPlayerAddItem(cid, sign.id, 1)
                end
            end
            setPlayerStorageValue(cid, RAFZAN.mission01.storages.advertising_counter, 0)
            npcTopic[talkUser] = 0
            npcHandler:releaseFocus(cid)
        else
            npcHandler:say("Soooorry. You cannot carry the stuff me has to give you. Get rid of it!", cid)
            npcTopic[talkUser] = 1
        end
    elseif msgcontains(msg, "yes") and npcTopic[talkUser] == 3 then
        local needed_cap = getItemWeightById(RAFZAN.mission02.perfume_gatherer, 1)
        if getPlayerFreeCap(cid) >= needed_cap then
            doNpcTellStory(cid,  
                {"Oh, so thankful me be! Use this container in the correct order on the following: ...",
                "FIRST, FRESH snail slime from a slain snail. Any snail you find will do. You will have to wait a little before its corpse will allow you to gather the slime. ...",
                "Second, add a sample black swamp gas that can be found in some remote areas of the swamp. ...",
                "Third, the fart of a rotworm. Rotworms eat the strangest things and their farts have a special ... odour. Use the container on a living rotworm. With some luck you catch a fart. ...",
                "Last, you need to use the container on moudly cheese, this is what ratmen love most! You might find some in possession of globins. If you are done, return the container to me."})
            local gatherer = doPlayerAddItem(cid, RAFZAN.mission02.perfume_gatherer, 1)
            doItemSetAttribute(gatherer, "sequence", 1)
            setPlayerStorageValue(cid, RAFZAN.mission02.storages.perfume_gatherer, 1)
            npcTopic[talkUser] = 0
        else
            npcHandler:say("Soooorry. You cannot carry the stuff me has to give you. Get rid of it!", cid)
            npcTopic[talkUser] = 1
        end
    elseif msgcontains(msg, "no") and isInArray({2, 3}, npcTopic[talkUser]) then
        npcHandler:say("Oh no, oh no. Soon me be ruined and dead.", cid)
        npcTopic[talkUser] = 1
    elseif msgcontains(msg, "bye") then
        npcHandler:say("Bye bye. Come back with much money to trade soon.", cid)
        npcTopic[talkUser] = 0
        npcHandler:releaseFocus(cid)
    elseif msgcontains(msg, "task") then
        npcHandler:say("Are you here to {get} a task or to {report} you finished task?", cid)
    elseif msgcontains(msg, "get") then
        doNpcTellStory(cid, {"So much to be done! Me desperately need {advertising}. Me have to create new ratmen {perfume}. Me in need of {guards} to keep me safe when trading. ...",
                            "Me looking for someone to keep ratmen {busy}, me need hero to {destroy} some ratmen stuff, and me need someone to {kill} evil marsh stalkers?"})
        npcTopic[talkUser] = 1
    elseif msgcontains(msg, "report") then
        npcHandler:say("What are you reporting about? Me {advertising} campaign, the {perfume}, recruitment of {guards}, keeping the ratmen {busy}, that you {destroyed} certain provisions or {killing} the marsh stalkers?", cid)
        npcTopic[talkUser] = 1
    elseif msgcontains(msg, "name") then
        npcHandler:say("Me humble name is Rafzan. Good old goblin name meaning honest, generous and nice person, I swear!", cid)
    elseif msgcontains(msg, "goblin") then
        npcHandler:say("Most goblins so afraid of everything, that they fight everything. Me different. Me just want trade.", cid)
    elseif msgcontains(msg, "human") then
        npcHandler:say("You humans are so big, strong, clever and beautiful. Me really feel little and green beside you. Must be sooo fun to be human. You surely always make profit!", cid)
    elseif msgcontains(msg, "profit") then
        npcHandler:say("To be honest to me human friend, me only heard about it, never seen one. I imagine it\'s something cute and cuddly.", cid)
    elseif msgcontains(msg, "swamp") then
        npcHandler:say("Swamp is horrible. Slowly eating away at health of poor little goblin. No profit here at all. Me will die poor and desperate, probably eaten by giant mosquitoes.", cid)
    elseif msgcontains(msg, "dwarf") then
        npcHandler:say("Beardmen are nasty. Always want to kill little goblin. No trade at all. Not good, not good.", cid) -- don't believe him xD
    elseif msgcontains(msg, "help") then
        doNpcTellStory(cid, {"So much to do, so little help. Me poor goblin desperately needs help. Me have a few {tasks} me need to be done. ...",
                            "I can offer you all money I made if you only help me a little with stuff which is easy to strong smart human but impossible for poor, little me."})
    elseif msgcontains(msg, "thais") then
        doNpcTellStory(cid, {"Me heard Thais is big city with king! Must be strong and clever, to become chief of all humans. Me cannot imagine how many people you have to beat up to become king of all humans. ...", 
                            "Surely he makes lot of profit in his pretty city."})
    elseif msgcontains(msg, "elves") then
        doNpcTellStory(cid, {"They are mean and cruel. Humble goblin rarely trades with them. They would rather kill poor me if not too greedy for stuff only me can get them. ...",
                            "Still, they rob me of it for a few spare coins and there is noooo profit for poor goblin."})
    elseif msgcontains(msg, "job") then
        doNpcTellStory(cid, {"Me job {merchant} is. Me {trade} with all kinds of things. Me not good trader though, so you get everything incredibly cheap! ...",
                            "You might think me mad, but please don't rip off poor goblin too much. Me has four or five wives and dozens of kids to feed!"})
    elseif msgcontains(msg, "venore") then
        doNpcTellStory(cid, {"Humans so clever. Much, much smarter than poor, stupid goblin. They have big rich town. Goblin lives here poor and hungry. Me so impressed by you strong and smart humans. ...",
                            "So much to learn from you. Poor goblin only sees pretty city from afar. Poor goblin too afraid to go there."})
    elseif msgcontains(msg, "gold") then
        doNpcTellStory(cid, {"Me have seen a gold coin once or twice. So bright and shiny it hurt me poor eyes. You surely are incredibly rich human who has even three or four coins at once! ...",
                            "Perhaps you want to exchange them for some things me offer? Just don't rob me too much, me little stupid goblin, have no idea what stuff is worth... you look honest, you surely pay fair price like I ask and tell if it's too cheap."})
    elseif msgcontains(msg, "ratmen") then
        doNpcTellStory(cid, {"Furry guys are strange fellows. Always collecting things and stuff. Not easy to make them share, oh there is noooo profit for little, poor me to be made. ...",
                            "They build underground dens that can stretch quite far. Rumour has it the corym have strange tunnels that connect their different networks all over the world."})
    elseif msgcontains(msg, "merchant") then
        npcHandler:say("Ah, yes, yes, merchant me be. Me is looking for {help} to start me {business}.", cid)
    elseif msgcontains(msg, "business") then
        npcHandler:say("Me humble little trader. Making a coin now and then, just enough not to starve to death. If you hear strange noise it's not dragon but empty stomach of poor goblin trader.", cid)
    end    
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye bye. Come back with much money to trade soon.")
npcHandler:setMessage(MESSAGE_FAREWELL, "Bye bye. Come back with much money to trade soon.")
npcHandler:setMessage(MESSAGE_SENDTRADE, "Ah, you too clever for me to make any meagre profit. Just please, please don't rob poor stupid goblin too much, you master of shrewd trading.")

 

 

Qualquer dúvida na configuração que tenha ficado, é só se basear na própria quest do global.

 

É isso, beijinhos ?.

Contato:

 

  • 8 months later...
Postado

Bom dia,

 

Apenas alterei o ID da placa e das pedras para as que são da versão original do Tibia.

Porem quando dei use da placa na stone, deu este erro no console:

 

image.thumb.png.8ec01eff8af4192801aa8afe62ff39e4.png

 

Obrigado!

Postado
  • Autor
Em 23/09/2019 em 09:18, Trayron1 disse:

Bom dia,

 

Apenas alterei o ID da placa e das pedras para as que são da versão original do Tibia.

Porem quando dei use da placa na stone, deu este erro no console:

 

image.thumb.png.8ec01eff8af4192801aa8afe62ff39e4.png

 

Obrigado!

 

Colocou a lib corretamente? Se sim, vê se não tem algum bug de formatação que geralmente tá surgindo ao copiar o conteúdo do fórum e colar.

Contato:

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo