rh-hideout/pokeemerald-expansion

Cannot cycle through balls if there are duplicates

Opened this issue · 2 comments

Description

If the player has multiple copies of a particular ball in their bag then GetPrevBall and GetNextBall don't work. For example if I have Poké Ball, Great Ball, Poké Ball, Ultra Ball then:

  • Pressing right will cycle between Poké Ball and Great Ball.
  • Pressing left will cycle between Poké Ball and Ultra Ball.
ball-1.mp4

Version

1.9.3 (Latest release)

Upcoming/master Version

No response

Discord contact info

No response

I think the intuitive solution is to store the index of the last used ball rather than the item ID of the last used ball. But of course that index could be invalidated by using the last copy of a ball, by the player reordering their balls, or obviously by CompactItemsInBagPocket which is in GetPrevBall and GetNextBall (and might occur in other code paths too).

Behavior is not entirely consistent:
Multiple Poke Balls:

  • PB (r) GB (r) UB (r) PB (r) GB (r) UB...

  • PB (l) PB (l) PB (l)...
    Multiple Great Balls:

  • PB (r) GB (r) UB (r) GB (r) UB (r) GB...

  • PB (r) GB (r) UB (l) GB (l) PB (l) GB (l) PB (l) GB...
    Multiple Ultra Balls:

  • PB (r) GB (r) UB (r) UB (r) UB (r) UB...

  • PB (l) UB (l) GB (l) PB (l) UB (l) GB (l) PB...