UsernameFodder / pmdsky-debug

Debug info for reverse engineering PMD: Explorers of Sky
GNU General Public License v3.0
38 stars 20 forks source link

Fix `ExecuteMonsterAction` return value #252

Closed tech-ticks closed 5 months ago

tech-ticks commented 5 months ago

ExecuteMonsterAction is supposed to have a return value, which became apparent after trying to hook calls to this function via a wrapper with a void return type and watching every Pokémon attack three times in a row. The actual return value seems to be a bool because either 0 or 1 are moved into r0 before the function returns.

Frostbyte0x70 commented 5 months ago

I took a quick look, it looks like the return value is not used when this function is called for the player or the enemies, but it is checked after executing the action of an ally. If the result is true, the AI is run again for the current ally, and it performs another action. This can happen up to three times. Quite interesting.

UsernameFodder commented 5 months ago

Thanks!