Ir para conteúdo

Featured Replies

Postado
  • Autor

Desculpa, não entendi direito sua duvida. Você quis dizer que ele não vai entrar em "Segundo Código" com a keyword 'yes'? Se for o caso, ele deverá entrar se você na primeira parte mudar o npc.Handler.topic[cid] para 2 e ele falar 'yes' novamente.

desculpe...

eu consegui arrumar... segue ele feito ...

local keywordHandler = KeywordHandler:new()

local keywordHandler = KeywordHandler:new()

local npcHandler = NpcHandler:new(keywordHandler)

NpcSystem.parseParameters(npcHandler)

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 creatureSayCallback(cid, type, msg)

if not npcHandler:isFocused(cid) then

return false

end

local player = Player(cid)

if msgcontains(msg, "flou") then

if npcHandler.topic[cid] == 0 then

npcHandler.topic[cid] = 1

npcHandler:say("Lhnjei gouthn naumpi! I know why you are here. I can explain everything.", cid)

else

npcHandler:say('I don\'t know what you are talking about.', cid)

end

elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "explain") then

npcHandler.topic[cid] = 2

npcHandler:say("By entering this place, you have earned the right to learn what this is all about. This is a long story. Are you sure you want to hear this?", cid)

elseif npcHandler.topic[cid] == 2 and msgcontains(msg, "yes") then

npcHandler.topic[cid] = 3

npcHandler:say({

'I was once captain of a ship, the Skyflare. We were traders for King Tibianus and on our way home when we got into a storm. We fought hard to escape the cold grip of the sea. ...',

'I myself did what I could to navigate the Skyflare out of this mess. They depended on me. Me, the navigator. And I succeeded. ...',

'However, when the sea calmed down and the rain was finally gone, we recognised that our ship wouldn\'t move. It wasn\'t my fault. ...',

'There was a strong gale and we could already see this island on the horizon. There were seagulls all around the Skyflare to lead us to dry land. But the ship did not move a single inch. It was NOT my fault. ...',

'We dived under the bow and saw that it was stuck right on the tip of a sharp rock. The world below us was treacherous, we could see large underwater mountains and a labyrinthine system of caves and holes. ...',

'Some of my men panicked and hijacked the dinghies to reach the island, others tried to swim. I remained on the ship. It was not my FAULT. It was not. ...',

'Do you have enough, can I stop?'

}, cid)

elseif npcHandler.topic[cid] == 3 and msgcontains(msg, "no") then

npcHandler.topic[cid] = 4

npcHandler:say({

'When none of my men returned, I forced myself to make a decision. Either dying on this dead ship or plunging into the liquid black beneath. ...',

'In my desperation my thoughts fell onto a strange armor - a gift from a trader we dealt with just before the storm. Strange ornaments and fish-like elements decorated this armor. We thought it would fit just perfectly into the captain\'s cabin. ...',

'He said something like a \'blessed breath\' and \'to subdue the drift\'. We thought he wanted to sell us worthless decoration and make it look interesting. If I had only listened to what he said. ...',

'I figured that this thing would have something to do with diving or at least protect me from the icy water. I put it on, grabbed a shimmer glower from our storage to light my path and jumped in. ...',

'Do you want me to go on?'

}, cid)

elseif npcHandler.topic[cid] == 4 and msgcontains(msg, "yes") then

npcHandler.topic[cid] = 5

npcHandler:say({

'Hmpf. The armor was working. After some time I was surrounded by darkness and could only see as far as my shimmer glower would me allow to. But I didn\'t feel the cold - I could even breathe through that helmet. ...',

'I dived into the deep black. Across rugged mountains, vast fields of kelp, swarms of strange fish. ...',

'And then I laid my eyes on a creature I have never seen before. I now know that they call themselves Njey. You would call them the \'Creatures of the Deep\' or \'Deeplings\'. ...',

'I am now convinced that when they first saw me descending in that suit with the light of the shimmer glower encompassing me, they took me for their God King Qjell. And that\'s when it all started to make sense. Don\'t you agree?'

}, cid)

elseif npcHandler.topic[cid] == 4 and msgcontains(msg, "yes") then

npcHandler.topic[cid] = 5

npcHandler:say({

'Of course you do. And they did, too. They obeyed me. They adored me. They followed me. ...',

'I learnt everything about their culture, their life, their goals and their problems. I found out about vile insect-like creatures inhabiting the surface of the island. And their waiting for the return of Qjell. ...',

'I practically rewrote their history. I WAS THE SECOND COMING. I WAS QJELL. I, THE NAVIGATOR. ...',

' And I navigated them out of their miserable lives. Away from their petty interests. I led them to a greater purpose - to form chaos out of order, to bring back the storm to the seas and to make THINGS MOVE. Do you want to hear the rest as well?'

}, cid)

elseif npcHandler.topic[cid] == 5 and msgcontains(msg, "yes") then

npcHandler.topic[cid] = 6

npcHandler:say({

'I control EVERYTHING from this room, navigating the fate of this land for more than a century now. Can you see all these funnels? My voice travels through them and throughout everything down here! ...'

}, cid)

elseif npcHandler.topic[cid] == 6 and msgcontains(msg, "helmet") then

npcHandler.topic[cid] = 7

npcHandler:say({

'NAAAAARGH. If you promise to leave me alone and NOT TO TELL MY SECRET to anyone - you can have one. ...',

'NO! Not the one I\'m wearing. I am BOUND to this device. This suit has granted me a longer life. However, once you have spent a certain time with this - there is no turning back if you know what I mean. ... ',

'The armor will merge with your very body. Holding you captive, holding your life in its hands like a ransom. ... ',

' Using Deepling craft and various components from down here, I created several spare helmets - just in case this one gets damaged. If you return that small golden anchor to me, you can have one. Will you? '

}, cid)

elseif npcHandler.topic[cid] == 7 and msgcontains(msg, "yes") then

npcHandler.topic[cid] = 0

player:addOutfit(463, 2)

player:addOutfit(464, 2)

player:setStorageValue(15432, 1)

player:removeItem(15432, 1)

npcHandler:say({

'Then take this one. And remember: DO NOT TELL ANYONE ABOUT ME OR ANYTHING YOU HAVE HEARD HERE TODAY. '

}, cid)

end

return true

end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:setMessage(MESSAGE_GREET, "Hello there!")

npcHandler:setMessage(MESSAGE_FAREWELL, "See you, |PLAYERNAME|.")

npcHandler:setMessage(MESSAGE_WALKAWAY, "See you, |PLAYERNAME|.")

npcHandler:addModule(FocusModule:new())

 

se quiser ver se tem algum erro...

mas rodou, fez tudo certinho :D

Se Ajudei Rep+ pra mim ^^

tumblr_lyd1xtGgx81qf9l6uo1_500.gif

  • Respostas 14
  • Visualizações 998
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end

  • Desculpa, não entendi direito sua duvida. Você quis dizer que ele não vai entrar em "Segundo Código" com a keyword 'yes'? Se for o caso, ele deverá entrar se você na primeira parte mudar o npc.Handler

  • Tem um detalhe só, se o player ficar repetindo "yes", o item vai ser removido mais de uma vez. Nada demais, mas que é bom consertar.

Postado
  • Autor

ah sim, mas não importa, como eu lhe falei, vou colocar um action pra o player só ir uma vez nesse npc...

ele vai ganhar um item x, vai usar em outro, e esse outro vai ter um storage, que se ele ja tiver o addon ele não vai poder entrar...

simples.

to com um bug num outro aqui :S

local keywordHandler = KeywordHandler:new()


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

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 creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end

local player = Player(cid)

if msgcontains(msg, "help") then
if npcHandler.topic[cid] == 0 then
npcHandler.topic[cid] = 1
npcHandler:say("If you want anything, you should talk to Old Rock Boy over there. I do collect stuff, though. So just ask if you\'re interested in helping me.", cid)
else
npcHandler:say('I don\'t know what you are talking about.', cid)
end
elseif npcHandler.topic[cid] == 1 and msgcontains(msg, "collect") then
npcHandler.topic[cid] = 2
npcHandler:say({
'I collect everything that reflects light in strange ways. However, I am bored by my collection. And there wasn\'t anything new to add for years. ...',
'I like pearls for example - but I have already enough. I also like shells - but I can\'t even count how many I already own. ...',
'If you find anything of REAL VALUE - bring it to me. I will reward you well. You don\'t already have something for me by chance?'
}, cid)
player:setStorageValue(15434, 1)
elseif npcHandler.topic[cid] == 2 and msgcontains(msg, "yes") then
if player:getStorageValue(15434) == 1 and player:getItemCount(15435) > 0 then
npcHandler.topic[cid] = 0
npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
player:setStorageValue(15434, 2)
player:removeItem(15435, 1)
else
npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)

end
elseif msgcontains(msg, "collect") then
npcHandler.topic[cid] = 3
npcHandler:say("Have you got anything for me today?", cid)
elseif npcHandler.topic[cid] == 3 and msgcontains(msg, "yes") then
if player:getStorageValue(15434) == 2 and player:getItemCount(15436) > 0 then
npcHandler.topic[cid] = 0
npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
player:setStorageValue(15434, 3)
player:removeItem(15436, 1)
else
npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)

end
elseif msgcontains(msg, "collect") then
npcHandler.topic[cid] = 4
npcHandler:say("Have you got anything for me today?", cid)


elseif npcHandler.topic[cid] == 4 and msgcontains(msg, "yes") then
if player:getStorageValue(15434) == 3 and player:getItemCount(15434) > 0 then
npcHandler.topic[cid] = 0
npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
player:setStorageValue(15434, 4)
player:removeItem(15434, 1)
else
npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)

end


elseif msgcontains(msg, "collect") then
if player:getStorageValue(15434) == 4 then
npcHandler.topic[cid] = 0
player:addAchievement('Spolium Profundis')
player:addOutfitAddon(463, 1)
player:addOutfitAddon(464, 1)
player:setStorageValue(15434, 5)
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
npcHandler:say({
'Have you got anything... what? You want what? A reward? HAHAHAHAAAA!! ...',
'No I\'m just teasing you. I\'m really happy about my collection now. ... ',
'Well, I found some kind of weapon a long time ago. I believe it may be especially helpful underwater as it is from the deep folk. In any case it is of more use for you than it would be for me.'
}, cid)
else
npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)
end
end
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, "Need help? Or are you only here for some news. Either way, make it short.")
npcHandler:setMessage(MESSAGE_FAREWELL, "See you, |PLAYERNAME|.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you, |PLAYERNAME|.")
npcHandler:addModule(FocusModule:new())

 

 

nas duas primeiras vezes que eu falo collect/yes ele pega os items, nas na terceira ele diz que eu não tenho nada valioso pra ele, o que será que pode ser?

esse npc funciona assim...

fala "hi / help" === ele vai dar um storage

"collect / yes" === ele vai pegar um item e agradecer, e dar o segundo storage.

dai falando "collect / yes" === ele vai pegar outro item e dar o terceiro storage

dai falando "collect / yes" === ele vai pegar outro item e dar o quarto storage

 

falando "collect" novamente ele vai ver se o player tem o quarto storage, e vai dar o addon....

e também não sei como colocar a verificação se ele ja te o storage do addon pra ele não pegar os items novamente

Editado por Schiffert (veja o histórico de edições)

Se Ajudei Rep+ pra mim ^^

tumblr_lyd1xtGgx81qf9l6uo1_500.gif

Postado

(O código está no "Spoiler", se quiser entender o que eu fiz, leia abaixo)

 

Então, dessa vez existiam muitos erros de lógica então eu fiz um novo.

 

Eu percebi que quando você fala "collect" pela primeira vez, tem um texto, da segunda em diante outra. E que você usa um storage para saber onde da quest está o player, então eu fiz o seguinte:

 

if msgcontains(msg, "collect") then
        npcHandler.topic[cid] = 2

        if player:getStorageValue(15434) < 1 then
            npcHandler:say({
            'I collect everything that reflects light in strange ways. However, I am bored by my collection. And there wasn\'t anything new to add for years. ...',
            'I like pearls for example - but I have already enough. I also like shells - but I can\'t even count how many I already own. ...',
            'If you find anything of REAL VALUE - bring it to me. I will reward you well. You don\'t already have something for me by chance?'
            }, cid)
        else
            npcHandler:say("Have you got anything for me today?", cid)
        end
end

 

Se a storage que você está usando ainda não tiver sido inicializada, ele fala a mensagem inicial, se não, a segunda. Para entrar em "collect" eu botei para não precisar falar "help" para poupar tempo do player.

 

Agora sobre o tratamento da mensagem "yes", eu fiz o seguinte:

 

Ele só vai entrar no bloco de código para o "yes" se já tiver passado pelo "collect", ou seja, o npcHandler.topic[cid] == 2.

E dentro do bloco de código para o "yes" eu verifiquei com if e elseif em qual parte da quest o player está para dar o storage correto ao player. Dessa forma:

 

    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
        if player:getStorageValue(15434) < 1 then
            if player:getItemCount(15435) > 0 then
                npcHandler.topic[cid] = 0
                npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
                player:setStorageValue(15434, 2)
                player:removeItem(15435, 1)
            else
                npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)
            end
        elseif player:getStorageValue(15434) == 2 then
            if player:getItemCount(15436) > 0 then
                npcHandler.topic[cid] = 0
                npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
                player:setStorageValue(15434, 3)
                player:removeItem(15436, 1)
            else
                npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)
            end
        elseif player:getStorageValue(15434) == 3 then
            if player:getItemCount(15434) > 0 then
                npcHandler.topic[cid] = 0
                npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
                player:setStorageValue(15434, 4)
                player:removeItem(15434, 1)
            else
                npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)
            end
        elseif player:getStorageValue(15434) == 4 then
            npcHandler.topic[cid] = 0
            player:addAchievement('Spolium Profundis')
            player:addOutfitAddon(463, 1)
            player:addOutfitAddon(464, 1)
            player:setStorageValue(15434, 5)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            npcHandler:say({
            'Have you got anything... what? You want what? A reward? HAHAHAHAAAA!! ...',
            'No I\'m just teasing you. I\'m really happy about my collection now. ... ',
            'Well, I found some kind of weapon a long time ago. I believe it may be especially helpful underwater as it is from the deep folk. In any case it is of more use for you than it would be for me.'
            }, cid)
        elseif player:getStorageValue(15434) == 5 then
            npcHandler:say("You already got your reward.", cid)
        end
    end

 

Botei um detalhe também no final, para quando o player já pegou o reward dele, o npc avisar se ele falar outro "collect / yes"

 

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

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 creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end

    local player = Player(cid)

    if msgcontains(msg, "help") then
        if npcHandler.topic[cid] == 0 then
            npcHandler.topic[cid] = 1
            npcHandler:say("If you want anything, you should talk to Old Rock Boy over there. I do collect stuff, though. So just ask if you\'re interested in helping me.", cid)
        else
            npcHandler:say('I don\'t know what you are talking about.', cid)
        end
    elseif msgcontains(msg, "collect") then
        npcHandler.topic[cid] = 2

        if player:getStorageValue(15434) < 1 then
            npcHandler:say({
            'I collect everything that reflects light in strange ways. However, I am bored by my collection. And there wasn\'t anything new to add for years. ...',
            'I like pearls for example - but I have already enough. I also like shells - but I can\'t even count how many I already own. ...',
            'If you find anything of REAL VALUE - bring it to me. I will reward you well. You don\'t already have something for me by chance?'
            }, cid)
        else
            npcHandler:say("Have you got anything for me today?", cid)
        end
    elseif msgcontains(msg, "yes") and npcHandler.topic[cid] == 2 then
        if player:getStorageValue(15434) < 1 then
            if player:getItemCount(15435) > 0 then
                npcHandler.topic[cid] = 0
                npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
                player:setStorageValue(15434, 2)
                player:removeItem(15435, 1)
            else
                npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)
            end
        elseif player:getStorageValue(15434) == 2 then
            if player:getItemCount(15436) > 0 then
                npcHandler.topic[cid] = 0
                npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
                player:setStorageValue(15434, 3)
                player:removeItem(15436, 1)
            else
                npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)
            end
        elseif player:getStorageValue(15434) == 3 then
            if player:getItemCount(15434) > 0 then
                npcHandler.topic[cid] = 0
                npcHandler:say("Great! Let me see. Amazing! I will take this, thank you!", cid)
                player:setStorageValue(15434, 4)
                player:removeItem(15434, 1)
            else
                npcHandler:say("You don\'t have anything with a REAL VALUE for me!", cid)
            end
        elseif player:getStorageValue(15434) == 4 then
            npcHandler.topic[cid] = 0
            player:addAchievement('Spolium Profundis')
            player:addOutfitAddon(463, 1)
            player:addOutfitAddon(464, 1)
            player:setStorageValue(15434, 5)
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            npcHandler:say({
            'Have you got anything... what? You want what? A reward? HAHAHAHAAAA!! ...',
            'No I\'m just teasing you. I\'m really happy about my collection now. ... ',
            'Well, I found some kind of weapon a long time ago. I believe it may be especially helpful underwater as it is from the deep folk. In any case it is of more use for you than it would be for me.'
            }, cid)
        elseif player:getStorageValue(15434) == 5 then
            npcHandler:say("You already got your reward.", cid)
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, "Need help? Or are you only here for some news. Either way, make it short.")
npcHandler:setMessage(MESSAGE_FAREWELL, "See you, |PLAYERNAME|.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "See you, |PLAYERNAME|.")
npcHandler:addModule(FocusModule:new())

Editado por elwyn (veja o histórico de edições)

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