Jump to content

Biólogo - Entregar múltiplos items


oserra
 Share

Recommended Posts

Olá, estava a pensar em como escrever uma quest que permitisse entregar logo vários items de seguida ao biólogo em vez de estar a clicar imensas vezes e poupar algum tempo.

O objetivo é ele verificar e decidir se aceita ou nao os items e se aceitar o limite, passar à próxima fase tudo de seguida.

Deixo um esboço da quest que escrevi mas aviso já que é capaz de estar alguma coisa estúpida aí, só queria saber se estou no bom caminho.

Spoiler

quest npc begin
    state start begin
        when 20083.chat."xx" with pc.count_item(vnum) > 0 begin
        local haveItem = pc.count_item(vnum) > 0
        say_title("Biólogo:")
        if pc.count_item(vnum) == 1 then
            say("Tens um item.")
            wait()
        else
            say(string.format("Tens %d items.", pc.count_item(vnum)))
            wait()
        end --if
            while haveItem == true do
            local pass_perc
                if pc.count_item(elixir) > 0 then
                    pass_perc = 70
                else
                    pass_perc = 50
                end --if
                local a = number(1, 100)
                    if a <= pass_perc then
                        local count = pc.getqf("count")
                        pc.setqf("count", count+1)
                        if count == 10 then
                            say("Passaste.")
                            set_state(key_item)
                            break
                        else
                            say(string.format("Faltam-te %d items para entregar.", 10-count))
                        end --if
                    else
                        say("Falhou.")
                    end --if
                pc.remove_item(vnum, 1)
                if pc.count_item(elixir) > 0 then
                    pc.remove_item(elixir, 1)
                end --if
            end --while
        end --when
    end --state
end --quest

 

Link to comment
Share on other sites

2 horas atrás, oserra disse:

Só mais uma coisa, o loop irá criar janelas umas sobre as outras devido à condição estar sempre a correr ou o end na variavel trata disso?

O loop irá correr todas as funções dentro dessa condição e só serão executadas de novo quando a execução anterior terminar.
Pelo que: não, não irão haver janelas sobrepostas.

Link to comment
Share on other sites

3 horas atrás, PACI disse:

O loop irá correr todas as funções dentro dessa condição e só serão executadas de novo quando a execução anterior terminar.
Pelo que: não, não irão haver janelas sobrepostas.

Era o que estava à espera, obrigado.

Versão alternativa(a remover o item logo no início do ciclo para não haver bugs intencionais):

Spoiler

quest npc begin
    state start begin
        when 20083.chat."xx" with pc.count_item(vnum) > 0 begin
        say_title("Biólogo:")
        if pc.count_item(vnum) == 1 then
            say("Tens um item.")
            wait()
        else
            say(string.format("Tens %d items.", pc.count_item(vnum)))
            wait()
        end --if
            local haveItem = true
            while haveItem == true do
            pc.remove_item(vnum, 1)
            local pass_perc
                if pc.count_item(elixir) > 0 then
                    pass_perc = 70
                    pc.remove_item(elixir, 1)
                else
                    pass_perc = 50
                end --if
                local a = number(1, 100)
                    if a <= pass_perc then
                        local count = pc.getqf("count")
                        pc.setqf("count", count+1)
                        if count == 10 then
                            say("Passaste.")
                            set_state(key_item)
                            break
                        else
                            say(string.format("Faltam-te %d items para entregar.", 10-count))
                        end --if
                    else
                        say("Falhou.")
                    end --if
                if pc.count_item(vnum) == 0 then
                    haveItem = false
                end --if
            end --while
        end --when
    end --state
end --quest

 

Edited by oserra
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...