LetaBot Profile Joined June 2014 Netherlands 21 Posts #1 Creating a Dota 2 Bot API Part 3: float on



Part 2:





Next up in the variables needed for a Bot API is the position of units/camera.



If you know anything about the internal workings of RTS games you know that most things in the game are stored as units. In StarCraft Brood War the buildings are stored with the unit class for example. So are most of the spells you can cast.



Dota 2 works in the same way, but it uses the name entities to describe the objects in the game. The position of an entity is in the same class as a unit, so it is just a matter of finding the offset for it, just like xorentor did for his Dota2harvester (

Here is how to find the new offset:



If you want to try it yourself, keep in mind that you should start steam in offline mode and turn of your internet



1. After you made sure that steam is in offline mode and you have no internet, you start Dota 2 with the launch option: -console



2. You start of by finding the HP of an entity. I choose my own hero since I can move him around freely, but technically any entity that moves could be used ( so don't use runes :p )



Look at part 2 of my blog to see how to get the HP value.









3. Now press ctrl+T to start a new scan (or click on file->Add scan tab).

4. Search for a float with an unknown initial value







5. Move to the left ( this decreases the x position )

6. Do a next scan with "Decreased value" selected.







7. Move to the right

8. Do a next scan with "Increased value" selected.







9. After doing this for a while you will narrow the addresses down.

10. open the console with \ , then make sure your cursor is on your hero and type in:

sv_cheats 1

ent_text



11. Look for the addresses that have the same x value as is given in the debug output.

12. Select the ones whose memory address is close the the memory address of your HP.



13. To be sure which one is correct, calculate the difference in memory address between your HP and x possibilities. For example 33C69120 - 33C68C5C = 4C4 .



14. Find the HP memory address of one of the creeps. Add the value from 13 to it, and set the type to a float.

15. Check the resulting value with the ent_text for that creep.

16. Choose the offset difference that gives you the correct result







Getting the camera position



17. Open the console and type in "cl_showpos 1"

18. Search for a float with an unknown initial value

19. Repeat step 5-9 but with your camera instead of your hero

20. Select several of the memory addresses and them to the addresslist below

21. Shift select them then press the space-bar to activate all of them

22. Move your camera around and see if you are forces back to your original location

23. Narrow this down to one address









24. Find out what accesses this memory address

25. Move the camera around and look at the counter of the opcodes that access the address.

26. Select the one you see in the image below and record the offset (22C in this case) and the memory address (0B980C80 in this case)







27. Search for the address you got at 26 in a new scan. This should give you two green memory addresses.

28. Pick any one of them. Now combined with your offset you can not only read the camera x position but also write (change) it.











---------------------------------------------------------------------------------------------





So the only things left now to make a very simple but already functional bot API is:

- Add a method to access and iterate over all the entities (and figure out their type/team)

- Translate the position of the entities and the camera into x,y coordinates on the screen





Sending commands to Dota 2 via calling in-game functions (DLL injection) is a bit to much of a hassle for me now. So I will stick with sending commands via simulated input for now.



Part 2: http://www.liquiddota.com/blogs/508438-dota-2-bot-api-2-training-for-a-trainer Next up in the variables needed for a Bot API is the position of units/camera.If you know anything about the internal workings of RTS games you know that most things in the game are stored as units. In StarCraft Brood War the buildings are stored with the unit class for example. So are most of the spells you can cast.Dota 2 works in the same way, but it uses the name entities to describe the objects in the game. The position of an entity is in the same class as a unit, so it is just a matter of finding the offset for it, just like xorentor did for his Dota2harvester ( https://github.com/xorentor/dota2harvester/blob/master/src/client_win32cli/d2h.c#L551 ).Here is how to find the new offset:1. After you made sure that steam is in offline mode and you have no internet, you start Dota 2 with the launch option: -console2. You start of by finding the HP of an entity. I choose my own hero since I can move him around freely, but technically any entity that moves could be used ( so don't use runes :p )Look at part 2 of my blog to see how to get the HP value.3. Now press ctrl+T to start a new scan (or click on file->Add scan tab).4. Search for a float with an unknown initial value5. Move to the left ( this decreases the x position )6. Do a next scan with "Decreased value" selected.7. Move to the right8. Do a next scan with "Increased value" selected.9. After doing this for a while you will narrow the addresses down.10. open the console with \ , then make sure your cursor is on your hero and type in:sv_cheats 1ent_text11. Look for the addresses that have the same x value as is given in the debug output.12. Select the ones whose memory address is close the the memory address of your HP.13. To be sure which one is correct, calculate the difference in memory address between your HP and x possibilities. For example 33C69120 - 33C68C5C = 4C4 .14. Find the HP memory address of one of the creeps. Add the value from 13 to it, and set the type to a float.15. Check the resulting value with the ent_text for that creep.16. Choose the offset difference that gives you the correct result17. Open the console and type in "cl_showpos 1"18. Search for a float with an unknown initial value19. Repeat step 5-9 but with your camera instead of your hero20. Select several of the memory addresses and them to the addresslist below21. Shift select them then press the space-bar to activate all of them22. Move your camera around and see if you are forces back to your original location23. Narrow this down to one address24. Find out what accesses this memory address25. Move the camera around and look at the counter of the opcodes that access the address.26. Select the one you see in the image below and record the offset (22C in this case) and the memory address (0B980C80 in this case)27. Search for the address you got at 26 in a new scan. This should give you two green memory addresses.28. Pick any one of them. Now combined with your offset you can not only read the camera x position but also write (change) it.---------------------------------------------------------------------------------------------So the only things left now to make a very simple but already functional bot API is:- Add a method to access and iterate over all the entities (and figure out their type/team)- Translate the position of the entities and the camera into x,y coordinates on the screenSending commands to Dota 2 via calling in-game functions (DLL injection) is a bit to much of a hassle for me now. So I will stick with sending commands via simulated input for now. If you cannot win with 100 apm, win with 100 cpm.