oserra Posted April 27, 2018 at 03:05 AM Share Posted April 27, 2018 at 03:05 AM 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 More sharing options...
PACI Posted April 27, 2018 at 11:27 AM Share Posted April 27, 2018 at 11:27 AM Falta atualizares a variável haveItem quando removido 1 item do jogador, caso contrário o seu valor será constante (atribuido no inicio). Link to comment Share on other sites More sharing options...
oserra Posted April 27, 2018 at 12:14 PM Author Share Posted April 27, 2018 at 12:14 PM 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? Link to comment Share on other sites More sharing options...
WLN Posted April 27, 2018 at 12:23 PM Share Posted April 27, 2018 at 12:23 PM na função pc.remove_item(vnum, 1) acho interessante colocar ela antes de atribuir como concluida a quest, não sabemos quando alguem pode bugar algo xD Link to comment Share on other sites More sharing options...
PACI Posted April 27, 2018 at 02:54 PM Share Posted April 27, 2018 at 02:54 PM 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 More sharing options...
oserra Posted April 27, 2018 at 04:52 PM Author Share Posted April 27, 2018 at 04:52 PM (edited) 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 April 27, 2018 at 05:57 PM by oserra Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now