Created
June 8, 2019 18:58
-
-
Save Nipodemos/c6f29bd63e243dcef2e5767ef3be7a14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| macro pegarDoStorageEVender { | |
| set exclusive 1 | |
| $continuarLoop = 1 | |
| while ($continuarLoop) { | |
| do ai manual | |
| @listaDeItems = criarListaDeItens("sell") #cria a array listaDeItems | |
| if (&config(itemsCheckWeight) != 1) do conf -f itemsCheckWeight 1 | |
| call irNaKafraEAbrirStorage | |
| if (!$.storageopen) stop | |
| pause 2 | |
| $temItem = 0 | |
| if ($listaDeItems[0] = erro) stop | |
| $index = 0 | |
| set macro_delay 0.3 | |
| while ($index < @listaDeItems && $.weightpercent < 85) { | |
| $temItem = 1 | |
| $qtdDoItemAtual = &storamount($listaDeItems[$index]) | |
| do storage get &storage($listaDeItems[$index]) if ( $qtdDoItemAtual > 0) | |
| $index++ | |
| } | |
| do storage close | |
| pause 1 | |
| set macro_delay 1 | |
| do ai on | |
| do autosell | |
| if (! $temItem) { | |
| [ | |
| log =================================== | |
| log = Acredito que vendi todos os itens | |
| log = que estavam no storage mas estavam marcados | |
| log = pra ser vendido no npc | |
| log =================================== | |
| ] | |
| $continuarLoop = 0 | |
| } | |
| } | |
| log FIM | |
| } | |
| # essa macro serve para tentar abrir o storage | |
| # na kafra que está salva na config storageAuto_npc | |
| # em caso de erro, vai tentar abrir mais duas vezes | |
| # na terceira vez mostra um erro e para oq tava fazendo | |
| macro irNaKafraEAbrirStorage { | |
| $tentativa = 0 | |
| while ($continuarLoop || $tentativa >= 3) { | |
| $localKafra = &config(storageAuto_npc) | |
| do move $localKafra &rand(4,7) | |
| if (&config(master) =~ /Valhalla/ ) { | |
| do talknpc &arg("$localKafra", 2) &arg("$localKafra", 3) r1 r0 | |
| } else { | |
| do talknpc &arg("$localKafra", 2) &arg("$localKafra", 3) r1 | |
| } | |
| if (!$.storageopen) { | |
| $tentativa++ | |
| if ($tentativa >= 3) { | |
| [ | |
| error =================================== | |
| error = acabei de executar os comandos para | |
| error = abrir o storage, porém o mesmo não está aberto | |
| error = vou parar tudo que estou fazendo | |
| error =================================== | |
| ] | |
| stop | |
| } else { | |
| [ | |
| warning =================================== | |
| warning = tentativa $tentativa de 3 de abrir o storage | |
| warning = tentando denovo | |
| warning =================================== | |
| ] | |
| } | |
| } else { | |
| #objetivo cumprido: abrir storage | |
| #podemos parar o loop | |
| $continuarLoop = 0 | |
| } | |
| } | |
| } | |
| sub criarListaDeItens { | |
| my ($option) = @_; | |
| my @lista; | |
| #warning "option is $option\n"; | |
| foreach $key ( keys %items_control ) { | |
| if ($items_control{$key}{$option}) { | |
| #warning "da pra vender $key\n"; | |
| push @lista, $key; | |
| } | |
| } | |
| if (@lista) { | |
| return \@lista; | |
| } else { | |
| warning "não foi encontrado items para vender no items_control.txt"; | |
| return "erro"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment