Netdex/twinject

AI is not working

huixiong806 opened this issue · 3 comments

twinject 1.2.104 release version
th08
windows 7
AI only press up and use deathbomb,not moving left,right or down.
It happened on my computer and my friend's.
(On my friend's computer,AI works well at lunatic mode,but on my computer the problem still exist.)
image
By the way,I have made an algorithm for TH10,it has reached lunatic no miss.
I'd like to apply it to th15.

Hello,

th_vo_algo will do a calibration when it is enabled by moving the player while measuring position to find the player velocity (instead of reading them from memory, to save me reverse engineering work). I see in the screenshot that the "calib vel" parameters (which are the velocities gained from calibration) are both 0, which means the algorithm thinks the player's movement speed is zero, which would lead to the behavior you have seen.

Make sure you only enable the bot after you are in the stage, because the calibration requires the player to be movable through input in order to measure velocity. Also, make sure your game is configured to use DirectInput through config.exe, and that you don't have a controller plugged into your computer (it breaks the DirectInput hook). If it still doesn't work, please paste the contents of the debug log so I can take a look.

Lunatic no miss is pretty impressive, I'm glad there are a lot of people working on algorithm ideas :)

If you'd like to apply it to th15 you can create an adapter for your algorithm to implement a th_algorithm, and use the player member to access available stage information. Then, you can change the algorithm used by the player controller from twinhook.cpp. Since the algorithm implementation is abstracted away from the specific game, a th_algorithm will work with any game supported by twinject. Note that th10 is the only game that is fully supported, th15 is missing some velocity information for lasers, and I have not finished reverse engineering hooks for enemy position.

Please let me know if you have any more questions.

OK it's working now,thank you very much!
The reason is that the focus changes while the start button is clicked.

Hmm interesting, I thought I made the window as a child so that it shouldn't lose focus. Might be a discrepancy between win7 and win10. You can use the keyboard shortcut 'G' to toggle the bot as well without losing focus. Glad you got it working.