Hello guys!I was meaning to post here for a long time my attempt to make a smart walk macro to use in Ragnarok Online and bot efficiently without the use of Fly Wings as the server i play doesn't allow use of the item.
It was a long patch to make this beauty and it was all done reading the various guides/documents/tips that are here in the forums and consulting old answers from users.
First i would like to make it clear that i don't code and never have before, my profession has nothing to do with it and i was (and still am) very new to coding in any sense. In that regard i am very thankful for all the work BEM Team has put into to make the software very user friendly!
Before posting the actual macro code for the smart walk i would like to reference here some necessary steps you need to follow and some things you need to check in your computer so the macro works as intended.
First and the most important, for this macro to even exist i used as a model and example Roan1234321's macro, so i would like to thank him for the code and i hope the people that read this can go to his post and thank him:viewtopic.php?f=437&t=30450In Roan's post you can find everything you need for runing a ragnarok macro with ease but i woudn't be happy just throwing to him all the responsabilty in explaining what you have to do for this to work, so here we go:
You will need to:Change the monster and item sprite in the data.grf so the macro can identify the monster you want to attack and the item you want it to pick, i will post the monster and item sprite i use but feel free to make your own and change accordingly in the macro code for the color you wish to use.For how to change monster and item sprites you again can see another guide Roan's posted here:
http://www.blueeye-macro.com/viewtopic. ... 35&t=30516And for creating you own monster and item sprite you can read this Roan's guide:
http://www.blueeye-macro.com/viewtopic. ... 35&t=30445Of course this part of the post woudn't be complete without mentioning Nyl- post about sprites, i used his guide to make mine and his method makes the monsters sprite animation smooth and easier for the pixel bot to identify and attack:
viewtopic.php?f=435&t=35307I recommend you edit your data.grf and make the map game a gray map so the bot can identify with ease what cell is a wall and what cell is walkable, for this i used this video as a guide:
https://www.youtube.com/watch?reload=9&v=xoI1NMN0WmM(Disclaimer: you will need GRF Editor for all this process in editing data.grf with sprites)After doing all this work check some things in your computer (this seems like a very useless part but for me it was the solution for the bot not attacking or not clicking on what i wanted him to click so i told myself that if i ever post this macro this would be one of the first things i would alert other users):
Your PC's Resolution: It makes a HUGE difference what resolution your PC is for a macro to run, if i use for example 1920x1080 and i calculate the coordinates for the macro in that resolution if your PC is on a different resolution then the same coordinates will not work the same as mine. Also this is the same for scale and layout in the windows (I use 100% but there is some people that prefer 125%).
Another thing that i found using BEM that can change your experience was that having more than one monitor changes your resolution and the values of the coordinates (yes, i know it is kinda obvious but i used in home 3 monitors and i never thought that it would make any difference for the macro if i was using more than 1 monitor, again not a expert in computers).
Here are my computer "specs" that i used to calculate the coordinates on Ragnarok and use in this macro: Resolution 1980x1080, Scale and layout: 100%, one monitor.There is this tool in BEM called Investigator that is amazing, you can use it to calculate coordinates, pixels pattern and RGB (and much more). For the resolution i highlight this part from investigator:

You can see the resolution BEM is working on, you have to be sure that it is the same resolution you have in Windows Resolution or the coordinates will not work as intended.
For the Ragnarok setup you will need to have this:
(Yes this is Roan's image too)
Okay now, i should have said this at the top of this post but:
You will need to download and install Blue Eye Macro to use this code (you can use other program to run this code but i can't help if doesn't work as i used BEM).You can download the .bem file and import to Blue Eye Macro or copy the following code in a new macro and execute.
Code:
begin
Color.Limit area of interest to window("Ragnarok", "yes")
Window.Set location("Ragnarok", "yes", "0", "0")
// Variables Declared
Variable.Set("a", "0")
Variable.Set("b", "0")
Variable.Set("c", "0")
Variable.Set("d", "0")
Variable.Set("e", "0")
Variable.Set("f", "0")
Variable.Set("h", "0")
Variable.Set("i", "0")
Variable.Copy("a1", "a")
Variable.Copy("b1", "b")
Variable.Copy("c1", "c")
Variable.Copy("d1", "d")
Variable.Copy("e1", "e")
Variable.Copy("f1", "f")
Variable.Copy("h1", "h")
Variable.Copy("i1", "i")
Variable.Set("l", "0")
Variable.Set("at", "0")
Variable.Set("1", "1")
Variable.Add to collection("and", "1")
Variable.Set("2", "2")
Variable.Add to collection("and", "2")
Variable.Set("3", "3")
Variable.Add to collection("and", "3")
Variable.Set("4", "4")
Variable.Add to collection("and", "4")
Variable.Set("5", "5")
Variable.Add to collection("and", "5")
Variable.Set("6", "6")
Variable.Add to collection("and", "6")
Variable.Set("7", "7")
Variable.Add to collection("and", "7")
Variable.Set("8", "8")
Variable.Add to collection("and", "8")
Variable.Set("j", " ")
Variable.Set random number("g", "1", "8")
Variable.Get from collection("and", "{g}", "j")
Variable.Set("mx", "651")
Variable.Set("my", "90")
Variable.Set("mx2", "518")
Variable.Set("my2", "504")
Variable.Set("mx3", "353")
Variable.Set("my3", "391")
Variable.Set("mx4", "827")
Variable.Set("my4", "252")
Variable.Set("mx5", "399")
Variable.Set("my5", "248")
Variable.Set("mx6", "861")
Variable.Set("my6", "385")
Variable.Set("mx7", "641")
Variable.Set("my7", "599")
Variable.Set("mx8", "839")
Variable.Set("my8", "519")
Function.Execute("AutoPots")
Function.Execute("{j}")
Variable.Set random number("g", "1", "8")
Variable.Get from collection("and", "{g}", "j")
Function.Execute("{j}")
Variable.Set random number("g", "1", "8")
Variable.Get from collection("and", "{g}", "j")
Variable.Set random number("g", "1", "8")
Variable.Get from collection("and", "{g}", "j")
Function.Execute("{j}")
Variable.Set random number("g", "1", "8")
Variable.Get from collection("and", "{g}", "j")
Function.Execute("{j}")
Variable.Set random number("g", "1", "8")
Variable.Get from collection("and", "{g}", "j")
Function.Execute("{j}")
Variable.Set random number("g", "1", "8")
Variable.Get from collection("and", "{g}", "j")
Function.Execute("{j}")
Variable.Set random number("g", "1", "8")
Variable.Get from collection("and", "{g}", "j")
Function.Execute("{j}")
Function.Execute("Attack")
Function.Execute("Loot4")
Function.Execute("AutoPots")
Function.Execute("Restart")
Function.Execute("Attack")
Macro.Restart("no")
end
function("Attack")
begin
if Color.Can be located on screen (RGB)("255", "255", "0", "0")
begin
Mouse.Release button("left")
Mouse.Click at color closest to coordinate (RGB)("255", "255", "0", "0", "645", "390", "left")
Variable.Add (Math)("at", "1")
Variable.Set("l", "0")
if Color.Pixel pattern can be located on screen("255,198,198,0,-1,255,198,198,0,2,255,198,198", "4")
begin loop()
Variable.Add (Math)("at", "1")
Macro.Pause("2000")
if Color.Pixel pattern can not be located on screen("255,198,198,0,-1,255,198,198,0,2,255,198,198", "4")
or
Variable.Is greater than (Math)("at", "30")
begin
Macro.Pause("400")
Macro.Break from loop("yes")
Variable.Set("at", "0")
end
end
end
end
function
function("Loot4")
begin
if Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin loop()
Mouse.Release button("left")
Mouse.Click at color closest to coordinate (RGB)("231", "33", "132", "0", "644", "392", "left")
Macro.Pause("100")
Variable.Add (Math)("l", "1")
if Variable.Is greater than (Math)("l", "10")
begin
Mouse.Click at coordinate("733", "353", "left")
Variable.Set("l", "0")
if Color.Can not be located on screen (RGB)("231", "33", "132", "0")
begin
Macro.Break from loop("yes")
end
end
end
end
function
function("1")
begin
if Color.Can not be located on screen (RGB)("255", "255", "0", "0")
and
Color.Can not be located on screen (RGB)("231", "33", "132", "0")
and
Variable.Is less than (Math)("a", "40")
begin loop()
Mouse.Release button("left")
Variable.Add (Math)("a", "1")
Variable.Set("a1", "{a}")
Mouse.Click("left")
Mouse.Hold button("left")
Mouse.Move to coordinate("{mx}", "{my}")
while Color.Can be located on screen (RGB)("255", "255", "0", "0")
or
Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin
Mouse.Release button("left")
Variable.Set("j", " 1")
Function.Execute("Attack")
Function.Execute("Loot4")
end
if Variable.Is greater than (Math)("a1", "39")
begin
Macro.Break from loop("yes")
end
if Mouse.Is above color (RGB)("189", "189", "198")
or
Color.At the current mouse position is (RGB)("189", "189", "198")
or
Color.Near the current mouse position is (RGB)("189", "189", "198", "3")
or
Color.At coordinate is (RGB)("189", "189", "198", "{mx}", "{my}")
begin
Macro.Break from loop("yes")
Variable.Set("a1", "40")
end
end
end
function
function("2")
begin
if Color.Can not be located on screen (RGB)("255", "255", "0", "0")
and
Color.Can not be located on screen (RGB)("231", "33", "132", "0")
and
Variable.Is less than (Math)("b", "40")
begin loop()
Mouse.Release button("left")
Variable.Add (Math)("b", "1")
Variable.Set("b1", "{b}")
Mouse.Click("left")
Mouse.Hold button("left")
Mouse.Move to coordinate("{mx2}", "{my2}")
while Color.Can be located on screen (RGB)("255", "255", "0", "0")
or
Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin
Mouse.Release button("left")
Variable.Set("j", "2 ")
Function.Execute("Attack")
Function.Execute("Loot4")
end
if Mouse.Is above color (RGB)("189", "189", "198")
or
Color.At the current mouse position is (RGB)("189", "189", "198")
or
Color.Near the current mouse position is (RGB)("189", "189", "198", "3")
or
Color.At coordinate is (RGB)("189", "189", "198", "{mx2}", "{my2}")
begin
Macro.Break from loop("yes")
Variable.Set("b1", "40")
end
if Variable.Is greater than (Math)("b1", "39")
begin
Macro.Break from loop("yes")
end
end
end
function
function("3")
begin
if Color.Can not be located on screen (RGB)("255", "255", "0", "0")
and
Color.Can not be located on screen (RGB)("231", "33", "132", "0")
and
Variable.Is less than (Math)("c", "40")
begin loop()
Mouse.Release button("left")
Variable.Add (Math)("c", "1")
Variable.Set("c1", "{c}")
Mouse.Click("left")
Mouse.Hold button("left")
Mouse.Move to coordinate("{mx3}", "{my3}")
while Color.Can be located on screen (RGB)("255", "255", "0", "0")
or
Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin
Mouse.Release button("left")
Variable.Set("j", " 3")
Function.Execute("Attack")
Function.Execute("Loot4")
end
if Mouse.Is above color (RGB)("189", "189", "198")
or
Color.At the current mouse position is (RGB)("189", "189", "198")
or
Color.Near the current mouse position is (RGB)("189", "189", "198", "3")
or
Color.At coordinate is (RGB)("189", "189", "198", "{mx3}", "{my3}")
begin
Macro.Break from loop("yes")
Variable.Set("c1", "40")
end
if Variable.Is greater than (Math)("c1", "39")
begin
Macro.Break from loop("yes")
end
end
end
function
function("4")
begin
if Color.Can not be located on screen (RGB)("255", "255", "0", "0")
and
Color.Can not be located on screen (RGB)("231", "33", "132", "0")
and
Variable.Is less than (Math)("d", "40")
begin loop()
Mouse.Release button("left")
Variable.Add (Math)("d", "1")
Variable.Set("d1", "{d}")
Mouse.Click("left")
Mouse.Hold button("left")
Mouse.Move to coordinate("{mx4}", "{my4}")
while Color.Can be located on screen (RGB)("255", "255", "0", "0")
or
Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin
Mouse.Release button("left")
Variable.Set("j", " 4")
Function.Execute("Attack")
Function.Execute("Loot4")
end
if Mouse.Is above color (RGB)("189", "189", "198")
or
Color.At the current mouse position is (RGB)("189", "189", "198")
or
Color.Near the current mouse position is (RGB)("189", "189", "198", "3")
or
Color.At coordinate is (RGB)("189", "189", "198", "{mx4}", "{my4}")
begin
Macro.Break from loop("yes")
Macro.Reset stopwatch("greywatch")
Variable.Set("d1", "40")
end
if Variable.Is greater than (Math)("d1", "39")
begin
Macro.Break from loop("yes")
end
end
end
function
function("5")
begin
if Color.Can not be located on screen (RGB)("255", "255", "0", "0")
and
Color.Can not be located on screen (RGB)("231", "33", "132", "0")
and
Variable.Is less than (Math)("e", "40")
begin loop()
Mouse.Release button("left")
Variable.Add (Math)("e", "1")
Variable.Set("e1", "{e}")
Mouse.Click("left")
Mouse.Hold button("left")
Mouse.Move to coordinate("{mx5}", "{my5}")
while Color.Can be located on screen (RGB)("255", "255", "0", "0")
or
Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin
Mouse.Release button("left")
Variable.Set("j", " 5")
Function.Execute("Attack")
Function.Execute("Loot4")
end
if Variable.Is greater than (Math)("e1", "39")
begin
Macro.Break from loop("yes")
end
if Mouse.Is above color (RGB)("189", "189", "198")
or
Color.At the current mouse position is (RGB)("189", "189", "198")
or
Color.Near the current mouse position is (RGB)("189", "189", "198", "3")
or
Color.At coordinate is (RGB)("189", "189", "198", "{mx5}", "{my5}")
begin
Macro.Break from loop("yes")
Variable.Set("e1", "40")
end
end
end
function
function("6")
begin
if Color.Can not be located on screen (RGB)("255", "255", "0", "0")
and
Color.Can not be located on screen (RGB)("231", "33", "132", "0")
and
Variable.Is less than (Math)("f", "40")
begin loop()
Mouse.Release button("left")
Variable.Add (Math)("f", "1")
Variable.Set("f1", "{f}")
Mouse.Click("left")
Mouse.Hold button("left")
Mouse.Move to coordinate("{mx6}", "{my6}")
while Color.Can be located on screen (RGB)("255", "255", "0", "0")
or
Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin
Mouse.Release button("left")
Variable.Set("j", "6 ")
Function.Execute("Attack")
Function.Execute("Loot4")
end
if Mouse.Is above color (RGB)("189", "189", "198")
or
Color.At the current mouse position is (RGB)("189", "189", "198")
or
Color.Near the current mouse position is (RGB)("189", "189", "198", "3")
or
Color.At coordinate is (RGB)("189", "189", "198", "{mx6}", "{my6}")
begin
Macro.Break from loop("yes")
Variable.Set("f1", "40")
end
if Variable.Is greater than (Math)("f1", "39")
begin
Macro.Break from loop("yes")
end
end
end
function
function("7")
begin
if Color.Can not be located on screen (RGB)("255", "255", "0", "0")
and
Color.Can not be located on screen (RGB)("231", "33", "132", "0")
and
Variable.Is less than (Math)("h", "40")
begin loop()
Mouse.Release button("left")
Variable.Add (Math)("h", "1")
Variable.Set("h1", "{h}")
Mouse.Click("left")
Mouse.Hold button("left")
Mouse.Move to coordinate("{mx7}", "{my7}")
while Color.Can be located on screen (RGB)("255", "255", "0", "0")
or
Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin
Mouse.Release button("left")
Variable.Set("j", " 7")
Function.Execute("Attack")
Function.Execute("Loot4")
end
if Mouse.Is above color (RGB)("189", "189", "198")
or
Color.At the current mouse position is (RGB)("189", "189", "198")
or
Color.Near the current mouse position is (RGB)("189", "189", "198", "3")
or
Color.At coordinate is (RGB)("189", "189", "198", "{mx7}", "{my7}")
begin
Macro.Break from loop("yes")
Variable.Set("h1", "40")
end
if Variable.Is greater than (Math)("h1", "39")
begin
Macro.Break from loop("yes")
end
end
end
function
function("8")
begin
if Color.Can not be located on screen (RGB)("255", "255", "0", "0")
and
Color.Can not be located on screen (RGB)("231", "33", "132", "0")
and
Variable.Is less than (Math)("i", "40")
begin loop()
Mouse.Release button("left")
Variable.Add (Math)("i", "1")
Variable.Set("i1", "{i}")
Mouse.Click("left")
Mouse.Hold button("left")
Mouse.Move to coordinate("{mx8}", "{my8}")
while Color.Can be located on screen (RGB)("255", "255", "0", "0")
or
Color.Can be located on screen (RGB)("231", "33", "132", "0")
begin
Mouse.Release button("left")
Variable.Set("j", "8 ")
Function.Execute("Attack")
Function.Execute("Loot4")
end
if Mouse.Is above color (RGB)("189", "189", "198")
or
Color.At the current mouse position is (RGB)("189", "189", "198")
or
Color.Near the current mouse position is (RGB)("189", "189", "198", "3")
or
Color.At coordinate is (RGB)("189", "189", "198", "{mx8}", "{my8}")
begin
Macro.Break from loop("yes")
Variable.Set("i1", "40")
end
if Variable.Is greater than (Math)("i1", "39")
begin
Macro.Break from loop("yes")
end
end
end
function
function("AutoPots")
begin
Macro.Execute new("RAGNAROK", "autopot", "no")
end
function
function("Restart")
begin
Variable.Set("a1", "{a}")
Variable.Set("b1", "{b}")
Variable.Set("c1", "{c}")
Variable.Set("d1", "{d}")
Variable.Set("e1", "{e}")
Variable.Set("f1", "{f}")
Variable.Set("h1", "{h}")
Variable.Set("i1", "{i}")
if Variable.Is greater than (Math)("a1", "39")
and
Variable.Is greater than (Math)("b1", "39")
and
Variable.Is greater than (Math)("c1", "39")
and
Variable.Is greater than (Math)("d1", "39")
and
Variable.Is greater than (Math)("e1", "39")
and
Variable.Is greater than (Math)("f1", "39")
and
Variable.Is greater than (Math)("h1", "39")
and
Variable.Is greater than (Math)("i1", "39")
begin
Macro.Restart("yes")
end
if Variable.Is less than (Math)("a", "40")
begin
Function.Execute("1")
end
if Variable.Is less than (Math)("b", "40")
begin
Function.Execute("2")
end
if Variable.Is less than (Math)("c", "40")
begin
Function.Execute("3")
end
if Variable.Is less than (Math)("d", "40")
begin
Function.Execute("4")
end
if Variable.Is less than (Math)("e", "40")
begin
Function.Execute("5")
end
if Variable.Is less than (Math)("f", "40")
begin
Function.Execute("6")
end
if Variable.Is less than (Math)("h", "40")
begin
Function.Execute("7")
end
if Variable.Is less than (Math)("i", "40")
begin
Function.Execute("8")
end
end
function
Now you guys must be asking: how this macro works and why you could call this a smart walk. The idea is that there is 8 directions that i put so that the mouse can click in a coordinate in a random sequence for 40 times or till it hits a gray wall. The character will not get stuck since the mouse "looks" for a walkable patch and then goes that way. You will attack and then continue to walk in the same direction, it will not change direction after attacking a monster and getting the loot, unless there isn't a walkable cell in that direction or it has walked 40 times already in that direction.
This macro is a work in progress i would say, there are some ideas that i thought to apply in the code like the macro using one walk function and then choose from a collection another walk function different from the already used one (but this i was not able to do, thats why i have the collection in there, i know i could have just used a "variable.set random number between" command instead of the "variable.get from collection" but i pretend to update this if i can figure a way to make it work the way i want).
For this macro to work you will have to change the RGB values from the attack, loot and 8 walk functons to the colors you use, i used a pink for itens, yellor for monsters and light gray for walls.
As a bonus i will put a simple autopot macro that i made, it recognizes when you health is low and uses F1 to use the potion, you will have to let your character tab open so it can identify the health color, and you will need to change the RGB values for the colors of the item in F1 so it can identify when you have:
Code:
begin
Color.Limit area of interest to window("Ragnarok", "yes")
Window.Bring to front("Ragnarok", "No")
Window.Set location("Ragnarok", "yes", "0", "0")
Function.Execute("AutoPots")
end
function("AutoPots")
begin
if Color.At coordinate is (RGB)("206", "206", "214", "159", "82")
and
Color.At coordinate is (RGB)("189", "66", "49", "240", "48")
and
Color.At coordinate is (RGB)("156", "181", "231", "155", "40")
begin loop()
Keyboard.Press key("{<f1>}")
if Color.At coordinate is (RGB)("156", "173", "222", "168", "83")
or
Color.At coordinate is (RGB)("165", "189", "231", "768", "489")
or
Color.At coordinate is not (RGB)("214", "222", "222", "168", "89")
begin
Macro.Break from loop("yes")
end
end
end
function
Note: Change "Ragnarok" in both macros to the name of the window your Ragnarok have.
You can put AutoPot code in the same macro or make it two macro separated (i use AutoPot separated because i found it worked better).
This ended up a much bigger post that i intended but i wanted to do a post that resembled all the good work this community has put through in so many guides, documents and ideas.
This is a form of contribution for BEM community and i look forward for you guys to help make this macro better or give me ideas on how can i improve it!
I falied to mention all the users that made some content here at the forum that i have read and used in learning my way into BEM, the post would become very long (yes longer than this), but if you want to learn the best way to start is the Documentation topic here in the forum, Gigas made a explanation on every criteria and intruction that there is on BEM and i found myself looking throught that a ton of times.
By the way, the macro makes your character kill steal so be careful on what map you run this, it can be very bothersome for some players to have someone kill stealing all the time.
Disclaimer: I made this macro on my spare time between work and family life so maybe there is some errors, i will be happy to help you to solve any problem you find along the way using this macro and i am open to new ways to make it better but i won't claim i can solve every problem!
good job for making this macro....
ill post my results here.
Welcome to the fam.