jonese1234 / PokeBotBad

The automated Pokémon speedrunning machine
http://www.twitch.tv/pokespeedrunbots
MIT License
26 stars 7 forks source link

Bot getting stuck on menuing #5

Open jonese1234 opened 7 years ago

jonese1234 commented 7 years ago

Idk how it happens

michaelowens commented 7 years ago

Is that this issue?

https://clips.twitch.tv/xikeon/BadWrenHassanChop

jonese1234 commented 7 years ago

Yeah thats one of the issues

bm01 commented 7 years ago

Filthypeasant apparently got it fixed. He explained it to me but I probably misunderstood something since it led to another similar menu glitch (which occurred two times, stuck after using repel on rock tunnel B1 and stuck trying to push a boulder on victory road F2 (strength not activated)).

It seems to have something to do with the "chain" argument passed to "Strategies.closeMenuFor(data)" in "ai/strategies.lua". Did you have a look there?

bm01 commented 7 years ago

So I found out that when this happens (menu glitch after using surf on the Victory Road), Strategies.closeMenuFor(data) isn't called at all. I don't know if it's supposed to be called but at least in that case, it isn't.

Basically we enter Strategies.skill(data), then completedSkillFor(data) returns true, then Menu.isOpened() returns false/nil. At that point the code returns true "manually" (we leave Strategies.skill(data)).

However status.menuOpened is still true there, to me it looks like a discrepancy, so instead of that manual return true I did return Menu.close(), and it worked. I haven't checked what goes on there but I suspect the B button was pressed and the call returned false/nil.

Instead of return Menu.close(), return closeMenuFor(data) could also work I suspect, it would check for status.menuOpened and since it resolves to true, would then do return Menu.close().

That being said, maybe it's Menu.isOpened() who doesn't work as intended and what I did is just a workaround. I can't really tell.

There are other menu glitches that seem unrelated to this one however (stuck on menu after using moon stone, teaching surf, using a potion...), I also managed to fix those but maybe in a dirty way, so it needs more testing. My guess was that Menu.hasBeenOpened() didn't handle some menu, I hadded some numbers to the table and managed to pass points where it would get stuck (tested by rerunning "glitched" seeds).