UPDATE:
automacro ops {
status not EFST_STOP
map prontera
call {
do move 146 90
pause 1
log open storage
do talknpc 146 89 c r1 c r0 n
pause 2
do storage log
pause 1
if (@storamount (Yggdrasil Seed) > 0 && @eval (int((8000 - $::cart{'weight'}) / 30)) > 0) call cartygg
pause 1
if (@storamount (Rough Oridecon) > 0 && @eval (int((8000 - $::cart{'weight'}) / 20)) > 0) call cartori
pause 1
if (@storamount (Maneater Blossom) > 0 && @eval (int(8000 - $::cart{'weight'})) > 0) call cartblossom
pause 1
if (@storamount (Stem) > 0 && @eval (int(8000 - $::cart{'weight'})) > 0) call cartstem
pause 1
do storage close
pause 2
do move x0 y0
pause 2
do openshop
pause 2
}
timeout 60
}
automacro cls {
status EFST_STOP
map prontera
call {
pause 1200
do closeshop
pause 3
}
timeout 1205
}
macro cartygg {
log refill Yggdrasil Seed.
do storage gettocart @storage (Yggdrasil Seed) @eval (int((8000 - $::cart{'weight'}) / 30))
}
macro cartblossom {
log refill Maneater Blossom.
do storage gettocart @storage (Maneater Blossom) @eval (int(8000 - $::cart{'weight'}))
}
macro cartstem {
log refill Stem.
do storage gettocart @storage (Stem) @eval (int(8000 - $::cart{'weight'}))
}
macro cartori {
log refill Rough Oridecon.
do storage gettocart @storage (Rough Oridecon) @eval (int((8000 - $::cart{'weight'}) / 20))
}
These macros generally just do vending and refill the items every hour bases.
I had tried many other approaches, but there are always issues, and this one is more reliable.
share an autmacro for vending and refill
Moderator: Moderators
-
- Developers
- Posts: 19
- Joined: 06 Mar 2010, 19:33
- Noob?: No
Re: share an autmacro for vending and refill
Here's the system I use. Hopefully it'll work in an OpenKore which isn't hacked as much as mine is.
This set of macros uses the contents of your shop.txt file to automatically reload the shop periodically. It's pretty convenient, since you don't have to mess with the macros when you want to vend something new. Just reload shop.txt and call macro reload_shop manually... or wait for the shop to automatically reload, since it reloads shop.txt automatically.
It has two config.txt options:
autoReloadShop 1 - turns on the set of macros
shop_pos X Y - location of the shop
This set of macros uses the contents of your shop.txt file to automatically reload the shop periodically. It's pretty convenient, since you don't have to mess with the macros when you want to vend something new. Just reload shop.txt and call macro reload_shop manually... or wait for the shop to automatically reload, since it reloads shop.txt automatically.
It has two config.txt options:
autoReloadShop 1 - turns on the set of macros
shop_pos X Y - location of the shop
Code: Select all
# To use, set the following additional options in your config.txt.
#
# # autoReloadShop turns on the macros.
# autoReloadShop 1
# # shop_pos sets the shop location.
# shop_pos 159 98
macro openshop {
do conf autoReloadShop 1
# The auto_reload_shop macro will now start the shop.
}
macro closeshop {
if (@eval($::shopstarted ? 1 : 0) == 0) goto noshop
do closeshop
:noshop
do conf autoReloadShop 0
}
# If:
# we're fully in-game,
# autoReloadShop is turned on,
# we have at least 2000z,
# our shop isn't started or two items are over half sold,
# and there's at least one item we can restock,
# then reload the shop!
automacro auto_reload_shop {
timeout 120
exclusive 1
eval $net->getState == Network::IN_GAME && $char->{zeny} > 2000 && $config{autoReloadShop} && (!$shopstarted || scalar(grep { $::_ && $::_->{sold} > $::_->{quantity} } @articles) > 1) && Macro::Parser::storage_choose_shop_items() ne
call {
# Delay a random amount of time from 90 seconds to 30 minutes.
$pause = @eval( 90 + int rand 1710 )
$junk = @eval( eval('use Time::Piece') || 1 )
log Reloading shop at @eval( localtime(time+$pause)->strftime('%H:%M:%S') ).
pause $pause
call reload_shop
}
}
macro reload_shop {
if ($shop == 0) goto noshop
do closeshop
:noshop
call storage_open
do reload shop.txt
$items = @eval( storage_choose_shop_items() )
$item = [$items]
while ($item != END) as item_loop
$amount = [$items]
if (@storage($item) == -1) goto noitem
do storage gettocart @storage($item) $amount
:noitem
$item = [$items]
end item_loop
do move @config(shop_pos)
pause 45
do reload shop.txt
do ss 41
}
# I actually use a much more complicated macro for this that works in almost every town.
macro storage_open {
if (@eval( $::storage{opened} ? 1 : 0 ) == 1) stop
do move 146 90
do talknpc 146 89 c r1 c r0 n
pause 4
}
sub storage_choose_shop_items {
my ( $to_inventory, $multiplier ) = @_;
$multiplier ||= 1;
# Get a list of all items we want.
my $items = {};
foreach ( @{ $shop{items} } ) {
my $item = $items->{ $_->{name} } ||= { name => $_->{name}, vend_amount => 0, vend_count => 0 };
$item->{vend_amount} += $_->{amount} * $multiplier;
$item->{vend_count}++;
}
# Subtract how much we already have.
if ( $to_inventory ) {
foreach ( @{ $char->inventory->getItems } ) {
next if !$_ || !%$_;
my $item = $items->{ $_->{name} };
next if !$item;
$item->{cart_amount} += $_->{amount};
}
} else {
foreach ( @{ $cart{inventory} } ) {
next if !$_ || !%$_;
my $item = $items->{ $_->{name} };
next if !$item;
$item->{cart_amount} += $_->{amount};
}
}
# List items to get from storage.
my @get;
foreach my $item ( sort { $a->{name} cmp $b->{name} } values %$items ) {
my $amount = $item->{vend_amount} - $item->{cart_amount};
next if $amount <= 0;
if ( $item->{vend_count} > 1 ) {
push @get, $item->{name}, 1 foreach 1 .. $amount;
} else {
push @get, $item->{name}, $amount;
}
}
return join ',', @get, 'END';
}