Part 1: http://www.liquiddota.com/blogs/503835-dota-2-bot-api-the-glutinitial-step
Part 2: http://www.liquiddota.com/blogs/508438-dota-2-bot-api-2-training-for-a-trainer
Part 3: http://www.liquiddota.com/blogs/508958-creating-a-dota-2-bot-api-part-3-float-on
Next up in the variables needed for a Bot API is determining to which team each entity belongs to.
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
Then start a bot game with you playing as Chen. Put your skill point in "Holy Persuasion".
2. You start of by finding the HP of an enemy creep. I choose a melee creep, but this works on all three types.
( 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 an unknown integer between the memory address of the HP and that memory address + 3000 (in hex). Technically you have to search from the base of an entity, which is the memory address of the HP - BC , but since the offset we are looking for is beyond the HP we can fill in the memory address of the HP straight away.
5. After clicking on new scan, let the game play for a while (make sure you lock the HP value of the creep so it won't die).
6. Do a new scan with "unchanged value". Repeat this for a while.
7. Now cast Holy persuasion on that creep
8. Scan for "changed value"
9. scan again for values less than 100
10. Add the results to your address list
11. Now look for another melee creep of your team so that you can use the offsets from step 10 and see which values are the same. Those values can be used to determine which team a creep belongs to.
12. After finding the correct HP ( see part 2, some addresses have the same value but are only used for displaying the HP not actually using it in the game logic), take note of the memory address.
13. Now you calculate the offsets based on the memory addresses you got from step 10 . For example,
450CA114 - 450C9B2C = 5E8 (make sure that you put your calculator on "Hex")
You then take the offset and add it to the HP address you found in step 12. In the image below, it gives a value of 3, which is different than the value of 2 for our (holy persuasion) converted creep.
14. Eventually you come across an offset that gives the same value (in my case it was 8D4). It should be just 1 offset that is the same, but if you have multiple you can narrow them down by following the steps below for each address.
15. For each offset you can verify if it is correct. You will need to do this anyway in order to find out which value belongs to Radiant and Dire
16. Get the HP memory address of an enemy creep. Then add the offset you got from step 14 to it. This should give you the team value of that creep ( in my case 4 = Dire, 8 = Radiant , but this can change in an update).
17. To check if it is a team value, use "Holy persuasion" on that creep.
18. If it is correct, then the value should change to the team value of your team ( in my case 4 = Dire, 8 = Radiant , but this can change in an update).
19. If not, then use the other offsets you found at step 14.
---------------------------------------------------------------------------------------------
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
- Translate the position of the entities and the camera into x,y coordinates on the screen