Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unlimited protein usage #307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix unlimited protein usage #307

wants to merge 1 commit into from

Conversation

Grobak
Copy link

@Grobak Grobak commented May 8, 2023

A "recent" update added 2 new vitamin types, Calcium and Carbos. This updates the listener in the "item bag" part of the "item" menu so each vitamin can be affected by this script. The pokemon list sorted for protein seems to work in console, but not in here so i used the in game code to get it to work.

I also seperated the bypassProtein function from the "main" script for readability and changed variable name to better reflect the in-game change in vitamin mecanics.

Also, this will most likely not work for the 4rth, 5th [...] vitamin added if more are added. To fix it, just add X new assignment in line 36 (but it would be great to use a better way to get this to work, this selector is shit).

Line 43 and 44 are only used if the user doesn't click on the vitamin img element but on the text or the outer box.

A "recent" update added 2 new vitamin types, Calcium and Carbos.
This updates the listener in the "item bag" part of the "item" menu so each vitamin can be affected by this script.
The pokemon list sorted for protein seems to work in console, but not in here so i used the in game code to get it to work.

I also seperated the bypassProtein function from the "main" script for readability and changed variable name to better reflect the in-game change in vitamin mecanics.

Also, this will most likely not work for the 4rth, 5th [...] vitamin added if more are added. To fix it, just add X new assignment in line 36 (but it would be great to use a better way to get this to work, this selector is shit).

Line 43 and 44 are only used if the user doesn't click on the vitamin img element but on the text or the outer box.
@umbralOptimatum
Copy link
Contributor

A few suggestions:

  • For Carbos, there should be an extra check to prevent egg steps from reaching or going below 0.
  • This fixes the individual vitamin menus, but the all-vitamins menu still has the 40 limit.
  • The new querySelector call can incorrectly select quest items if any are present. A more precise selector would allow programmatically selecting all vitamins, even if more get added later.

And there's definitely some way to avoid that awkward interval. And probably better to just override PartyPokemon.useVitamin() than keep adding event listeners over the game's existing ones... y'know what, I have the time today, I'll make my own PR

@Grobak
Copy link
Author

Grobak commented May 8, 2023

yeah, i didn't take that much time to find a better selector, feel free to improve it of you like.
I didn't got deep inside the game code, so i have no idea how to check if the egg steps is at a X or Y value. i guess it's linked to the pokemon object, but i haven't looked into it yet

About the interval, i think it is needed because the pokemon filtered list isn't loaded at the same time the click is made, but a bit after. There is only 3 listeners, one for each vitamin type.

where is the all vitamin menu ? i haven't seen it yet, or maybe i forgot.

Edit :
Just noticed the "All vitamin" button right under the vitamins. I honnestly don't think i'l look into it. I think the same listener can be used but there must be a switch or something to add. It would most likely be easier to export the vitamin override part into a separate function and call it in a new listener + the one existing now

@umbralOptimatum
Copy link
Contributor

Yes, the interval is used because the menu isn't part of the DOM at the time, but there are other options like tying the code to execute alongside other game functions or adding the listeners once during loading before the menu is hidden. Doesn't really matter though as the listeners definitely aren't the right approach—just noticed they also interfere with the button to remove vitamins.

I rewrote the script to just modify useVitamin() in #308. Much less tangly, works for all the menus, and should support any future vitamins that get added.

@Ephenia Ephenia added the Insufficient votes This means the PR lacks votes and requires more attention for a decision to be made label May 9, 2023
@Ephenia Ephenia added the Merge Conflicting This means that this PR has a merge conflict and it will need to be revised label May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Insufficient votes This means the PR lacks votes and requires more attention for a decision to be made Merge Conflicting This means that this PR has a merge conflict and it will need to be revised
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants