[Solved] Macro: buy red pots; fill them in cart; continue ai

Moderator: Moderators

Message
Author
Inserio
Noob
Noob
Posts: 2
Joined: 12 Nov 2012, 17:42
Noob?: Yes

[Solved] Macro: buy red pots; fill them in cart; continue ai

#1 Post by Inserio »

Check out the code on the bottom for what is currently working.

I've been trying to write a macro to fill up my cart with red pots when I run out. Right now, it's working up fine until the point where I should be going back to the lockMap. It keeps going to do an autostorage, autobuy, autosell loop (even though I don't have autosell turned on). So my character just spends a ton of zeny opening up storage a ton of times.

Here's what I've got. Please let me know where I am doing something wrong.
Also, my items_control for Red Potion is set to 75 0 0 1 1,
and the buyauto config is

Code: Select all

buyAuto Red Potion {
	npc [npc's location]
	standpoint
	distance 5
	price
	minAmount 
	maxAmount 150
}
so that my character can put the items in the cart without going over his carrying capacity.

Code: Select all

#########################
######## BUY POTS #######
#########################

automacro not_enough_reds {
  cart "Red Potion" = 0
  inventory "Red Potion" = 0
  call buy_reds
  overrideAI 0
  exclusive 1
  run-once 1
  timeout 120
}

macro buy_reds {
	$WeightPercent = @eval($.weight/$.maxweight)
	$CartRedPots = @cartamount(Red Potion)
	$RedPots = @invamount(Red Potion)
	if ($RedPots > 75) goto putincart
	if (@eval($WeightPercent) > "0.55") goto autostore
	if ($CartRedPots <= 900) goto autobuy
	if ($CartRedPots > 900) goto cartfull
	   log \Huh? Why'd this macro trigger?
	   release not_enough_reds
	   stop
	 :putincart
	   do cart add Red Potion 150
	   pause 1
	   release not_enough_reds
	   call buy_reds
	   stop
	 :autostore
	   do autostorage
	   pause 5
	   release not_enough_reds
	   call buy_reds
	   stop
	 :autobuy
	   do autobuy
	   pause 5
	   release not_enough_reds
	   call buy_reds
	   stop
	 :cartfull
	   log \The cart has $CartRedPots Red Potions! Don't buy any more!
	   pause 5
	   release not_enough_reds
	   stop
}
:edit: it also triggers upon tele unless I add the line "cartweight <= 35" to the automacro...which is peculiar
:edit2: I think I figured out the tele issue by reading http://wiki.openkore.com/index.php/Macro#FAQ just make sure you keep a butterfly wing on you at all times (or switch it in the code)
Also, I may have figured out the buy sequence issue by doing a workaround for the autobuy loop. I didn't try using ai manual before, but now I'm using that AND not using autobuy but instead using a command sequence to talk to the specific npc. Right now the macro works by itself this way from the start, I'll wait until it triggers the automacro to see if the whole sequence works. Finally, I also don't know what'll happen if/when it tries to do autostorage. Here's the updated code:

NOTE THAT IF ANYONE WANTED TO USE THIS, FIND THE NOTES # AND ADD THE APPROPRIATE INFORMATION TO YOUR NPC LOCATION AND MOVE LOCATION
You could also use this for other potions or w/e but switch the labels and options appropriately

Code: Select all

#########################
######## BUY POTS #######
#########################

automacro not_enough_reds {
  cart "Red Potion" <= 1
  inventory "Red Potion" <= 50
  call buy_reds
  overrideAI 0
  exclusive 1
  run-once 1
  timeout 120
}
automacro also_if_dead {
  console /You have died/i
  cart "Red Potion" <= 250
  inventory "Butterfly Wing" > 0
  overrideAI 0
  exclusive 1
  run-once 1
  delay 2
  call buy_reds
  timeout 60
}
macro buy_reds {
	$WeightPercent = @eval($.weight/$.maxweight*100)    #this finds the percent value of your weight from 0-100
	$CartRedPots = @cartamount(Red Potion)     #this returns the number of red pots in your cart
	$RedPots = @invamount(Red Potion)    #this returns the number of red pots in your inventory
	$BWings = @invamount(Butterfly Wing)    #this returns the number of butterfly wings in your inventory
	pause 1
	if ($RedPots > 75) goto putincart    #if you have more than 75 red pots on you, go to putincart
	if ($WeightPercent > 55 || $BWings < 1) goto autostore    #if your weight is above 55, go to autostore
	if ($CartRedPots <= 850 && ($.map != [map] && $.map != [map])) goto wingit  #REPLACE [map] with the map names where you want to not bwing from
	if ($CartRedPots <= 850) #if your cart has less than or equal to 850 red pots, go to justbuy
	if ($CartRedPots > 850 || cartweight >= 7800) goto cartfull   #if your cart has more than 850 red pots, go to cartfull and end macro
	   log Huh? Why'd this macro trigger?    #this is a check to make sure that the macro is working right. It's not necessary, but can be helpful if you call the macro on your own.
	   log Btw, I'm carrying $RedPots Red Potions, and $CartRedPots are in my cart. My weight is $WeightPercent%.
	   stop
	 :putincart
	   do cart add Red Potion 150
	   pause 1
	   call buy_reds
	   stop
	 :autostore
	   do autostorage
	   pause 5
	   call buy_reds
	   stop
	 :wingit
	   do ai manual
	   $bwing = @inventory(Butterfly Wing)
	   do is $bwing
	   pause 2
	   do ai on
	   call buy_reds
	   stop
	 :justbuy
	   do ai manual
	   do move 		#put map and coordinates of where you can see the npc here
	   pause 1
	   $ToolDealer = @npc ()
		#put coordinates in parenthesis; don't use the map name
	   do talk $ToolDealer
	   pause 1
	   do store
	   pause 1
	   $shopreds = @store(Red Potion)
	   do buy $shopreds 150 #This selects the item and amount. Now it is independent of whichever tool dealer you go to.
	   pause 1
	   do talk no
	   pause 1
	   call buy_reds
	   stop
	 :cartfull
	   log I'm carrying $RedPots Red Potions, and $CartRedPots are in my cart. My weight is $WeightPercent%. Stop buying.
	   pause 1
	   do ai on
	   release not_enough_reds
	   release also_if_dead
	   stop
}
:edit: Updated the second code for a few error fixes and such