Looking for basic, general information

Discuss, ask for help, share ideas, give suggestions, read tutorials, and tell us about bugs you have found with MicroMacro in here.

Do not post RoM-Bot stuff here. There is a subforum for that.
Forum rules
This is a sub-forum for things specific to MicroMacro.

This is not the place to ask questions about the RoM bot, which uses MicroMacro. There is a difference.
Post Reply
Message
Author
smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Looking for basic, general information

#1 Post by smokyru » Tue Apr 14, 2015 5:34 am

Hello friends,

I was using micromacro for RomBot quite a few years ago.
I now want to learn more about micromacro as a whole, and more precisely learn to use it to create my own bots for the games I play. The hardest part is knowing where to start, learning the code in itself probably isn't easy either, but even that doesnt seem possible if I don't know where I'm headed.

Can someone give me some tips? No need to enter into details for every step, but simply explaining what should be my first few goals. And it probably would help many a player who is looking to learn.

Of course, each games is different, but I can't imagine there being no common "guide-lines" at all.
I have searched through the forum and the wiki, but beside a list of commands, I couldn't find the help I required, hence the start of the topic.

Thanks for reading, I really hope some of you can share their experience !

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking for basic, general information

#2 Post by Administrator » Tue Apr 14, 2015 7:58 am

There really isn't much in the way of tutorials right now, but hopefully that will change in the future. Since you're starting from scratch, it is probably best that you start with learning how MicroMacro 2 works instead of the older (1.04) branch. While the codebase is much nicer to work with, it is still new enough that there's not a whole lot to base your own project off of.

I'm assuming you've already seen the basic script setup on the wiki.

Are you already familiar with Lua? If not, you might want to read up the documentation for Lua 5.3

Are you familiar with memory editing using tools such as CheatEngine? If not, that is borderline necessary. Not all scripts require memory reading/writing, but if you're focusing on games, you will probably want to use this more often than not.

Have you looked over the IRC and HTTP download examples here? https://solarstrike.net/phpBB3/viewforum.php?f=31
Even if you aren't doing anything with sockets, it might give you some rough ideas how the different parts all work together.

You might also look over the ArcheAge anti-idle script as a very simple example: https://solarstrike.net/phpBB3/viewtopi ... =38&t=5849


The hard part is organizing what you want to do into logic chunks that fit the flow of the target application. Unfortunately, this is also the hardest thing to describe, because not only is every game different, but there are many different types of things you would do in each game, and many different methods to go about those actions. If you can explain exactly what you are looking to accomplish, I can give some rough information on how to code it.

smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Re: Looking for basic, general information

#3 Post by smokyru » Tue Apr 14, 2015 9:20 am

We (a noble soul got interested in the project) are not very familiar with Lua. Even thou we wrote some scripts for RoM a few years ago, we will have to learn it more deeply as we go.

We are fairly familiar with CheatEngine, and are of course planning to use it.

The goal we're aiming for is for the character to be able to follow a rather simple waypoint and be able to deal with combat.

About the versions, I downloaded the version marked as stable, which is the 1.04. I didn't feel confident enough to start with a beta version. The beta version on solarstrike is 1.91, I guess the 2.0 is only available from GitHub. I did see the manuals for both 1.x and 2.x.
it is still new enough that there's not a whole lot to base your own project off of.
I'm not sure what you mean here: is 2.0 incomplete ? Or did you mean it'd be easier to start a project with 2.0 ?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking for basic, general information

#4 Post by Administrator » Tue Apr 14, 2015 9:54 am

1.91 will be 2.0 when I've finished adding all the functionality that was planned. It will be the same branch and same API, and so should be mostly compatible. 1.04 and 1.91(ie. 2) are vastly different and incompatible with each other. In my opinion, the 1.91 branch is much easier to develop for. While it is called a beta, it is actually more stable than the 1.04 version simply due to a massive code cleanup and better coding practices.

I do have an old test project from about a year ago that might be of use to you. It uses Ncurses for the UI and implements a state machine to handle various player actions (only standing idle and walking between waypoints supported, but fighting could be added). I'll attach that so you can look it over for ideas, but you should probably just ignore all the Ncurses stuff for the time being and focus on functionality. Some of the function names might have changed (like I said, it is pretty old) so don't be alarmed if you notice something isn't working as expected. This code also don't check to see if the player got caught up on anything while moving; I'll leave that as an exercise for you.

Fighting is a lot more complicated as you end up writing a bunch of AI to best decide which attack(s) to use, when to use them, when to heal or run away, and so on. I recommend just starting with a simple rotational attack cycle (use attack 1, then attack 2, then attack 3, then back to attack 1, ...) and checking HP to use potions in between attacks. As you watch the bot fight, you'll continuously think of improvements (it should use attacks as soon as they are off cooldown instead of in rotation, it should attempt to pull an enemy with a range attack to initiate the fight, if mana is low then avoid using attack 2, and so on, if your enemy runs out of range then chase him down). It is all those little decisions that improve the AI.
Attachments
rom.walker.zip
(4.82 KiB) Downloaded 190 times

User avatar
rock5
Posts: 12173
Joined: Tue Jan 05, 2010 3:30 am
Location: Australia

Re: Looking for basic, general information

#5 Post by rock5 » Tue Apr 14, 2015 11:44 am

Always the first things you need to check is that you can successfully send the necessary keypresses and mouse controls to the game and secondly you are able to read memory to find the values you need. If you can both of those then you're good to go.
  • Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
  • I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
  • How to: copy and paste in micromacro
    ________________________
    Quote:
    • “They say hard work never hurt anybody, but I figure, why take the chance.”
          • Ronald Reagan

smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Re: Looking for basic, general information

#6 Post by smokyru » Thu Apr 16, 2015 5:33 am

We can send keypresses. Mouse control is a bit more tedious, with the game centering the cursor automatically, all "setposition" or "move" commands end up in constant turning, but at least there's movement so chances aren't so bad.

I'm afraid we hit a wall with memory reading. As soon as I attach the debugger of CheatEngine the game closes. It looks a lot like some kind of protection. Do you think we're doomed?

Edit: found several threads talking about similar problems, will see what I can do.
Edit2: can now attach debugger, but damn, finding addresses is a struggle.

I'm trying to get the character's coordinates, starting with the vertical as adviced, but I'm getting ~200 addresses with each the exact same float value. Each of those addresses lead to 8-10 pointers. One of those is green (static?) but doesn't seem to work either, its value changes.

In Administrator's tutorial for double pointers, there is a part I don't understand:
manually add 0x20248844 to Cheat Engine's address list [...] Next, you'll find what points to it by following exactly the same method that tutorial 1 outlined.
Does it mean that something should write to the address of the first pointer we found?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking for basic, general information

#7 Post by Administrator » Thu Apr 16, 2015 10:17 am

If the pointer is valid across restarting the game, it should give the same value. That's how you would know that pointer chain is worth pursuing or not.
You might try CE's automatic pointer lookup. It is slow when dealing with huge numbers of pointers, but ~200 should be fine. How to use it should be pretty self explanatory.

Typically, the player's coordinates will be near other related data, such as the player's health, level, or whatever else. If you found the health, you can try limiting your search to the block surrounding that region. Say, maybe -512 -> +512 bytes from HP.

smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Re: Looking for basic, general information

#8 Post by smokyru » Thu Apr 16, 2015 1:25 pm

I don't really understand the Pointer Scanner, it picks memory addresses from other processes aswell. I've found some tutorials about it, but I still would like to understand what is going on by using the "usual" way.

For example, when searching for the maxHP, I narrow down the search to 6 addresses. When doing "see what writes to this address", and searching for the estimated value of the pointer, I get 2-10 pointers for each address, with at least one green each time. All green ones are rather close to each other:
74EC4708
74EC4738
74EC47C8
etc.
But their values (the address they point to) changes whenever I try to "see what writes" to any address. Sometimes randomly, sometimes they go back to pointing to the HP.

I expect that I'm supposed to find a chain of pointers, but I do not understand the part that I quoted from your tutorial. How can I follow "exactly the same method that tutorial 1 outlined" ? I don't think I can get any opcode when monitoring the address of a pointer.
I had the exact same problem with the coordinates, and the "green" pointers were the same but with different offsets, which actually seems to be the way it should be.

Maybe I should start a new thread about pointers and keep this one for more general steps?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking for basic, general information

#9 Post by Administrator » Thu Apr 16, 2015 2:48 pm

First find the address, then right-click it and select "Pointerscan for this address." Default settings are probably fine so just click OK, and it will do a scan. It will take a long time and then ask you to save results. Restart the game, find the new address, and reiterate the scan by going to Pointer scanner->Rescan memory. This basically just rechecks all the addresses and keeps only the valid ones. You might need to redo this a few times, or maybe even reboot your computer entirely before continuing a scan to narrow it down enough to be usable. I've had mixed results using this tool.

I expect that I'm supposed to find a chain of pointers, but I do not understand the part that I quoted from your tutorial. How can I follow "exactly the same method that tutorial 1 outlined" ?
You have address A (which contains the value you're looking for, such as HP). You determine that an address (B) seems to be pointing to A (it contains A as its value, is reading/writing to it, whatever). Add address B to your list, and now see what points to it using the exact same method you did on A. You'll find address C, so C points to B and B points to A.

smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Re: Looking for basic, general information

#10 Post by smokyru » Thu Apr 16, 2015 6:26 pm

Well, this is what I mean. If A is maxHP, it means I have to change my maxHP in-game while monitoring what writes to A - then the opcode appears in the monitoring window, allowing me to find B. But for B, I cannot use the same method, as simply changing my HP doesn't mean something is writing to B.

Concerning the pointer scan - as I have at least 6 addresses for HP (and many more for coords), if I use pointer scan on one of them, then reboot the game, I can't know which of the 6 new addresses matches the first I used. Does it not matter?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking for basic, general information

#11 Post by Administrator » Thu Apr 16, 2015 7:36 pm

Well, this is what I mean. If A is maxHP, it means I have to change my maxHP in-game while monitoring what writes to A - then the opcode appears in the monitoring window, allowing me to find B. But for B, I cannot use the same method, as simply changing my HP doesn't mean something is writing to B.
As long as the value of the max HP changes, it should be counted as being read or written to. It is not so much that the value of B (which is the address of A) is changing, but that B needs to be accessed to get to the address it is pointing to.

Still, I don't think scanning for Max HP is the best idea. Usually if you just find HP, you can assume that maxHP is at +4 bytes. The pointer would usually point to the character struct that contains all the player data, and so you can reuse that pointer chain. That means if the offset for HP is 50, assume max HP is at 54.
Concerning the pointer scan - as I have at least 6 addresses for HP (and many more for coords), if I use pointer scan on one of them, then reboot the game, I can't know which of the 6 new addresses matches the first I used. Does it not matter?
No. You don't actually do this on the pointer itself; you do it on the value. Any pointer chain that resolves to pointing to the same data (for example, your HP) will be held.

smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Re: Looking for basic, general information

#12 Post by smokyru » Thu Apr 16, 2015 8:28 pm

but that B needs to be accessed
Then this is probably where the difference is. To find B, I needed to check what writes to the address of A. I guess then that to find C, I need to check what access the address of B. I will check tomorrow if that gives better results, but I think I have already tried it with no luck a couple times. Which isn't sufficient ;)

However, if this time I'm understanding it correctly, and if this is supposed to be the proper way - may I humbly suggest to change it in the tutorial? The part about "exact same way" is kindof confusing to me. And I secretely hope I'm not the only dumb one !

I will also try with the current HP instead of the maxHP. I've seen many posts about equipping/removing gear to search for the maxHP, so I assumed it was the way to go.

Edit:
I'm still struggling with the pointer chain.
While I was trying a few things, I noticed this:
CE.jpg
The last pointer changed its value to the address of the first pointer. And I just keep on failing to find anything usable.
Last edited by smokyru on Sat Apr 18, 2015 7:53 pm, edited 2 times in total.

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking for basic, general information

#13 Post by Administrator » Fri Apr 17, 2015 5:28 pm

I've added onto that tutorial with a real-world example. That might help with some of your confusion.

You don't always need to check what writes to an address. Sometimes accesses is good enough. It is just recommended where available because there's far fewer things that will write to the address than will access it. There may also be code that accesses the address but does not make use of it in a meaningful way and so we should not rely on it for a pointer.

I think using 'what writes to this address' is best used on the first address (such as the player's HP), while the pointers down the chain should probably just use 'what accesses this address' as it may be a pain to actually get those pointers to update (be written to).

smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Re: Looking for basic, general information

#14 Post by smokyru » Sat Apr 18, 2015 12:03 pm

Alright, I have news. I think it was this way all along, but I didn't realize it.
First of all, I realized that some HP values are stored as 4byte, and others as float. Floats are probably the most accurate ones.

The news: The static pointer I had appeared to not be working, because when I changed zone, restarted the game, etc, the value changed and it was looking like broken.

What happened today: after starting CE with the address list saved, the pointer was still looking like broken. I then proceeded to search for the new addresses of the HP, and at the step when I "see what writes to this address", as soon as the opcodes shows up in the window, the old pointer "refreshes" and points to HP again. I can repeat it and it works everytime, after game restart, zone change, etc - but I need to find manually the address of HP and see what writes to that address everytime for the pointer to refresh.

It does not seem to be normal behaviour. Is it CE that fails to refresh the address list? Do you think this pointer is usable ?

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking for basic, general information

#15 Post by Administrator » Sat Apr 18, 2015 12:42 pm

You're right that is odd behavior. I can't make sense of it except that perhaps that pointer you found is actually internally being used as some sort of debugger.

Now this might not make sense to you right away, but it might be possible for one of those black addresses to be semi-static. That is, it is not declared in global scope, but will always be available during normal program execution. Take for example the following C code:

Code: Select all

int main(int argc, char **argv)
{
    int HP = 1000;
    bool running = true;

    while( running )
    {
        do_something();
    }
}
In that code, HP is declared inside the main function. That means it is local to main. For all intends and purposes, it is static, yet will not show as such from Cheat Engine. At least I think this may be the case, so don't quote me on this. I had noticed this sort of behavior yesterday while writing up that sample program for the tutorial.
So, it might just be possible that if you come across a black pointer in the chain and it is a dead end, it might actually still be useful. The only way to check for this that I know of would be just to leave them in your address list and restart the client to see if they retain their usefulness.


If I had an account for that game (and the client) I would lend a hand and see if I couldn't help find something useful. Do you know if there's going to be an open beta any time?

smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Re: Looking for basic, general information

#16 Post by smokyru » Sat Apr 18, 2015 3:13 pm

I've sent you the name of the game in a PM.

Concerning the pointer, I have confirmed that I get this behaviour with most of the pointers that come up as static, for both current HP and max HP, with both float values and 4 bytes.

Here's more info on the behaviour: I get 2 addresses for HP. Each of them gets me a green pointer (and some black ones). After a restart, both of the green pointers will "refresh" if the debugger monitors any action on the address of one of the HP addresses, no matter which one.

Concerning the "semi-static" pointers, I'm not sure this is what is going here. However, at some point, I did come accross some black ones that kept on pointing to the old address of HP after a restart - but of course the value at that address wasn't HP anymore. I didn't pay much attention to it. Even if I were able to recreate this situation, it doesn't look like I could get anything out of it.


But back to the green ones: if I can consistently make so that it points where needed with the use of the debugger, shouldn't I be able to make it work ?

smokyru
Posts: 31
Joined: Fri Dec 18, 2009 9:02 am

Re: Looking for basic, general information

#17 Post by smokyru » Tue May 12, 2015 10:37 am

It doesn't look like I'll be even able to actually find any working addresses. I've lost my mind over this in the past month, I think it's time for me to give up on this one. Thanks for all your help, at least I got some experience out of the tries !

User avatar
Administrator
Site Admin
Posts: 5306
Joined: Sat Jan 05, 2008 4:21 pm

Re: Looking for basic, general information

#18 Post by Administrator » Tue May 12, 2015 10:47 am

Did you try posting on the CheatEngine forum? I've been busy work work and have not had the time to look into this. Also, not speaking Russian gets in the way.

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests