OpenKore / openkore

A free/open source client and automation tool for Ragnarok Online
http://openkore.com
Other
1.28k stars 1.04k forks source link

Help with tweaking my macro please. #936

Closed ytbro00 closed 7 years ago

ytbro00 commented 7 years ago

Not entirely a big issue. Still trying to learn how to use macros. Thanks to anyone that can help.

So I'm trying to have my bots autodeal my merchant as soon as they're done auto selling & auto buying. My actual macro itself partially works. I'd just like to tweak on the trigger and auto adding. So here's a modified sample of what I'm trying to tweak around on.

  1. I did not put weight trigger because I have my bots set to go back for auto buying and selling once they run out of potions and fly wings. Which is why I'm trying to get the macro to trigger as soon as I get to town. It actually only works if I add weight on it, if I remove it, I have to reload all configs to trigger this macro.

  2. Trying to use zenyChecks to leave at least 50k - 100k on my farming bots so that they have enough money to auto-buy what they need?

  3. I've been able to successfully add numerous amounts of items by adding the same line. Can anyone clarify if it's possible to just keep adding the same item like composite bow, wooden mail, knife until there are none left to trade without having to add multiple lines of the do deal add @inventory?

automacro moveToMaster { #How can I trigger the macro to run as soon as my bot goes back to town (dies / uses butterfly wing)
   location #where my merchant is sitting
   call {
      do autosell
      do autobuy
      do conf lockMap
      do conf lockMap_x
      do conf lockMap_y
      do move
   }
   run-once 1
}

automacro dealToMaster {
   location #where my merchant is sitting
   call {
      do deal @player
      pause 3
      macro checkZeny { #not sure if this is working correctly
      switch ($.zeny) {
      case (> 200000) {
      do deal add z 100000 #any way to deal all zeny and just leave at least 100k on my farmer?
      pause 1
      do deal add @inventory(Hood [1]) #How can I add hood until I have none left without repeating the code?
      pause 1
      do deal
     pause 1
     do deal
   }
   run-once 1
}

automacro moveToFild { #where my bots are farming
   console /Deal Complete/i
   call {
      do conf lockMap
      do conf lockMap_x none
      do conf lockMap_y none
     do move
      do reload mac
   }
}

autodeal macro

Any help is appreciated. Thanks.

Nipodemos commented 7 years ago

hello! i think i can help you. here is the code optimized

automacro moveToMaster {
    eval ($field->isCity) #the automacro will only trigger if is inside city 
        #(which happens when you die or use butterfly wing, or do autostorage, autosell)
    call {
        do autosell
        do autobuy
        do conf lockMap
        do conf lockMap_x
        do conf lockMap_y
        do move payon 100 100 #just an example
    }
    run-once 1
}

automacro dealToMaster {
    location payon 100 100 #example
    call {
        do deal @player
        pause 3
        $zenyToGive = @eval($.zeny - 100000)
        if ( $zenyToGive > 0 ) do deal add z $zenyToGive
                #this way it will add any zeny that you have and keep 100k 
        pause 1
        while (@invamout(Hood [1] != 0) as loop1
        do deal add @inventory(Hood [1]) #just put a while in every equip, just like that
        end loop1
        pause 1
        do deal
        pause 1
        do deal
    }
    run-once 1
}

automacro moveToFild {  #where my bots are farming
    console /Deal Complete/i
    call {
        do conf lockMap
        do conf lockMap_x none
        do conf lockMap_y none
        do move
        do reload mac
    }
}

is there anything else?

oleokoong commented 7 years ago

Can I ask if the item more than 10 in a time, how to deal again?

Nipodemos commented 7 years ago

I don't know how...you have to check every single item that you pass normally, check if has 0 of the item You have to do this in the last macro, that ends the deal And if some of the items it's more than 0 Call the dealToMaster again

oleokoong commented 7 years ago

Maybe trig when deal is full , then do deal and call again

Nipodemos commented 7 years ago

it's an ideia, but how the bot knows when to stop this loop?

ytbro00 commented 7 years ago

Hi, thanks nipodemos. I tried running the code, although I was getting [macro] dealToMaster.call error: error in 5: error in 5: error in 5: You probably missed 1 or more closing round- bracket ')' in the statement.

This was the error for zeny line. This got it to work though.

 if ($.zeny >= 400000) {
 do deal add z @eval($.zeny - 100000)
 }

Now I have the same message for equipment adding, tried placing a bracket for the equipment lines but if I do that it ignores everything below it. Removing the while condition and trading equipment successfully completes the macro though so just trying to figure out how to fix dealing equipment.

This is what I currently have excluding the do deal and above lines.

pause 3
         if ($.zeny >= 400000) {
                do deal add z @eval($.zeny - 100000)
        }
        pause 1

        while (@invamout(Hood [1] != 0) as loop1
        do deal add @inventory(Hood [1]) #just put a while in every equip, just like that

        end loop1
        pause 1
        do deal
        pause 1
        do deal
    }
    run-once 1
}

Tried this also but it got me errors and shut off openkore

 pause 1
      $hoods = @Inventory(Hood [1])
      while ($hoods != -1 || $hoods != "") as loop
         do deal add [$hoods]
         pause 1
      end loop
      pause 1

capture

Nipodemos commented 7 years ago

$hoods = @Inventory(Hood [1]) while ($hoods != -1 || $hoods != "") as loop do deal add [$hoods] pause 1 end loop

why do deal add [$hoods] have these things surrounding $hoods?

i believe that you can't put the e"||" inside while maybe... but the good thing is $hood will not have an empty value. Try like this:

 $hoods = @Inventory(Hood [1])
      while ($hoods != -1 ) as loop
         do deal add $hoods
         pause 1
      end loop

if you try this, and still get an error, try use the @inventory all in lowercase.

ytbro00 commented 7 years ago

Alright, thanks Nipodemos.

That did the trick and it did add the equipments I wanted it to add. The end loop doesn't seem to work though and it keeps trying to add the items again. For this test I used mufflers.

capture

Nipodemos commented 7 years ago

i said in the end, use @inventory in lowercase. you are using with the first letter in upper case, that returns several numbers and it's harder to deal with. use @inventory all in lowercase

ytbro00 commented 7 years ago

I did that earlier. But using @inventory in lower case only added 19 and does not add anything after that, while looping the same message.

"Error in function 'deal_add' (Add Item to Deal) Inventory Item 19 does not exist."

The one with @Inventory worked as above, added everything but loops.

EDIT:

Got it to work using this. Going to test it a bit.

$list = @Inventory(#itemname)
      while ($list != -1 && $list != "") as loop
      do deal add $item
      }
Nipodemos commented 7 years ago

Oh Sorry , In that case, put the variable inside the while loop. So in every loop it will update its value Or learn to extract just one of the values per time of @Inventory with uppercase letter ( I don't know how, but I know it's possible

The first solution is a lot easier

ytbro00 commented 7 years ago

Got it to work @Nipodemos edited my post up there took a few tweaks seems good now. Thanks for the assistance.

Although a little bit worried with the series of macros. Since I have a couple of bots running and the merchant will go to sell the items once it gathers everything.

This one I'm not really sure how, but how would I got about farmer slave bot checking if the master bot is in its spot? If the master isn't there just continue on and go to the farming location.

Also, going to test it out a bit but since I have a couple of slave bots running around, they might try to deal the master at the same time and get stuck.

Nipodemos commented 7 years ago

You have to use eval for this one... Unfortunately I don't know which eval you have to use... Macro plugin it's veeeeeeeeeery incomplete ...

I know it may seem difficult to you, but have you tried eventMacro plugin ? It's a rework of the plug-in you currently uses, and it is much more complete , much more ... In eventMacro, you can use the condition PlayerNear , that checks if the player you specify is near , it would solve this issue

alisonrag commented 7 years ago

For more support use: htttp://www.openkore.com