Skip to content

Instantly share code, notes, and snippets.

@allanon
Created May 18, 2015 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allanon/7bf226a2bdfdf1c47424 to your computer and use it in GitHub Desktop.
Save allanon/7bf226a2bdfdf1c47424 to your computer and use it in GitHub Desktop.
macro weight {
$weight = @eval ( $::config{autoWeight} = $::config{autoWeight} ? 0 : 1 )
if ($weight == 1) goto weight
log No longer automatically going back to town when overweight
goto done
:weight
log Going back to town when overweight
goto done
:done
}
macro choose_aspd_pot {
[
$job = @eval( $::jobs_lut{ $::char->{jobID} } || 'unknown' )
$aspdpot = Concentration Potion
if (@eval( "$job" !~ /Swordsman|Knight|Lord Knight|Rune Knight|Crusader|Paladin|Royal Guard|Merchant|Blacksmith|Whitesmith|Mechanic|Alchemist|Creator|Genetic|Wizard|High Wizard|Warlock|Rogue|Stalker|Shadow Chaser/) == 1) goto notberserk
if ($.lvl >= 40) $aspdpot = Awakening Potion
if ($.lvl >= 85) $aspdpot = Berserk Potion
:notberserk
if (@eval( $.lvl >= 40 && "$job" =~ /Mage|Sage|Professor|Sorcerer|Archer|Hunter|Sniper|Ranger|Thief|Assassin|Assassin Cross|Glt. Cross|Monk|Champion|Sura/) == 1) $aspdpot = Awakening Potion
# The ability to buy Berserks is rare. Assume we'll need to use storage, and if there aren't enough in storage, fall back to Awakes.
if ($aspdpot = Berserk Potion && @storamount(Berserk Potion) < 3) $aspdpot = Awakening Potion
]
}
automacro auto_weight_1 {
checkTimeout 3
exclusive 1
timeout 2700
eval $config{autoWeight} && $field->isCity && $AI == AI::AUTO && $net->getState == Network::IN_GAME
call auto_weight_1m
}
macro auto_weight_1m {
[
set macro_delay 0.1
do conf spread_followerWaitDist 999
do conf spread_followerMoveDist 999
$follow = @eval ( $::config{follow} )
do follow stop
do conf route_step 15
]
call repair
call store
if (@config(autoWeight_useCart) == 1) call storecart_all
[
do conf relogAfterStorage 0
call choose_aspd_pot
# For bwings in Einbroch, since they're not sold there.
$refill = Butterfly Wing,10,White Potion,@config(autoWeight_whitePotions),Holy Water,60,$aspdpot,@config(autoWeight_aspdPotions),@config(homunculus_food),30,Iron Cannon Ball,@config(autoWeight_cannonBalls),Acid Bottle,@config(autoWeight_acidBombs),Bottle Grenade,@config(autoWeight_acidBombs),Fly Wing,@config(autoWeight_flyWings)
$refillcart = @config(homunculus_food),150,Iron Cannon Ball,@config(autoWeight_cannonBallsCart),White Potion,@config(autoWeight_whitePotionsCart),Holy Cannon Ball,500
]
call refill_from_storage ''
call goto_seller
call sell_uneq
do sell done
[
do conf buywing.npc $sellermap $sellerx $sellery
do conf buywing.disabled 0
if (@config(autoWeight_whitePotions) <= 0) goto nowhite1
do conf buywhite.npc $sellermap $sellerx $sellery
do conf buywhite.disabled 0
do conf buywhite.maxAmount @config(autoWeight_whitePotions)
:nowhite1
if (@eval( config_block( 'buyfly', 'disabled') < 2 ? 1 : 0 ) == 0) goto nofly1
do conf buyfly.disabled 0
do conf buyfly.npc $sellermap $sellerx $sellery
do conf buyfly.maxAmount @config(autoWeight_flyWings)
:nofly1
]
do autobuy
[
do conf buywing.disabled 1
if ($fly == 0) goto nofly2
do conf buyfly.disabled 1
:nofly2
do conf buywhite.disabled 1
#do conf route_step 5
if ($follow != 1) goto nofollow
do conf follow $follow
:nofollow
]
# Moving from the Tool Seller in aldebaran to xmas_dun results in an infinite loop.
# Break the loop by going back to kafra first.
$alde = @eval( $::field->baseName eq 'aldeba_in' ? 1 : 0 )
if ($alde = 0) goto done
call goto_kafra
:done
call storage_get_broken
[
do conf spread_followerWaitDist 10
do conf spread_followerMoveDist 30
if (@eval( int 100 * $::char->{weight} / $::char->{weight_max} ) > 49) then overweight
do sp_notify [autoweight] Still overweight after storing items. Logging off!
do relog 8640000
end overweight
]
}
automacro auto_weight_2 {
checkTimeout 10
timeout 30
eval $net->getState == Network::IN_GAME && $AI == AI::AUTO && $config{autoWeight} && $config{lockMap} eq $field->baseName && $char->{weight} / $char->{weight_max} >= 0.49
call {
# Try to put stuff in the cart if we can.
[
if (@config(autoWeight_useCart) != 1) goto nocart
$havecart = @eval( $::cart{exists} ? 1 : 0 )
$cartweightavail = @eval( $::cart{weight_max} - $::cart{weight} )
if ($havecart == 1 && $cartweightavail > 1000) call overweight
if (@eval(int 100 * $::char->{weight} / $::char->{weight_max}) < 49) stop
:nocart
]
log Respawn: auto_weight_2
call respawn
cleartimeout auto_weight_1
}
}
automacro auto_weight_3 {
checkTimeout 10
timeout 12
delay 10
# eval $net->getState == Network::IN_GAME && $AI == AI::AUTO && $config{autoWeight} && $config{lockMap} eq $field->baseName && $config{autoWeight_whitePotions} >= 3 && $char->{zeny} > 30000
eval $net->getState == Network::IN_GAME && $AI == AI::AUTO && $config{autoWeight} && $config{autoWeight_whitePotions} >= 3 && $char->{zeny} > 30000
inventory "White Potion" < 3
call {
if (@invamount(White Potion) > 2) stop
if (@cartamount(White Potion) <= 0) goto nocart
[
$c = @cartamount(White Potion)
$i = @invamount(White Potion)
$a = @config(autoWeight_whitePotions)
do cart get @cart(White Potion) @eval($a - $i)
]
stop
:nocart
log Respawn: auto_weight_3
call respawn
cleartimeout auto_weight_1
}
}
# Make sure we have at least 10 cannon balls, if we have any at all.
automacro auto_weight_4 {
checkTimeout 10
timeout 12
eval $::net->getState == Network::IN_GAME && $::AI == AI::AUTO
inventory "Iron Cannon Ball" = 1..10
call {
[
$c = @cartamount(Iron Cannon Ball)
if ($c >= 10) goto haveballs
# Take the whole party offline, just in case we have a priest.
do sp_p relog 8640000
pause 1
do sp_p relog 8640000
pause 1
do relog 8640000
pause 1
goto done
:haveballs
$i = @invamount(Iron Cannon Ball)
do cart get @cart(Iron Cannon Ball) @eval(100 - $i)
$i = @invamount(Holy Cannon Ball)
do cart get @cart(Holy Cannon Ball) @eval(100 - $i)
pause 1
do eq @inventory(Iron Cannon Ball)
:done
]
}
}
# Make sure we have homunculus food if any is needed.
automacro auto_weight_5 {
checkTimeout 10
timeout 12
eval $net->getState == Network::IN_GAME && $AI == AI::AUTO && $config{homunculus_food} && checkItem('inv', qq{"$config{homunculus_food}" < 10}) && checkItem('cart', qq{"$config{homunculus_food}" > 0})
call {
[
$food = @config(homunculus_food)
$i = @invamount($food)
do cart get @cart($food) @eval(30 - $i)
]
}
}
automacro auto_set_homunculus_food {
hook packet_pre/homunculus_food
save foodID
eval $config{homunculus_food} ne Misc::itemNameSimple($varStack{'.hooksave0'})
timeout 10
call {
do conf -f homunculus_food @eval( Misc::itemNameSimple('$.hooksave0') )
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment