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

EV Caps and EV Items #5269

Merged
merged 5 commits into from
Sep 1, 2024
Merged

EV Caps and EV Items #5269

merged 5 commits into from
Sep 1, 2024

Conversation

Flash1Lucky
Copy link

@Flash1Lucky Flash1Lucky commented Aug 26, 2024

Description

Introduces EV caps, inspired by level caps, with configurable options for various cap implementations. Additionally, modifies EV items to interact with these caps based on a configurable setting.

Feature List for EV Caps Implementation

EV Cap Configurations:
EV_CAP_NONE: No EV cap applied; EV growth is unrestricted.
EV_CAP_FLAG_LIST: Caps EVs at predefined milestones, halting further EV gain from battles once the cap is reached.
EV_CAP_VARIABLE: Dynamic EV cap determined by a modifiable variable, allowing for flexible adjustments during gameplay.
EV_CAP_NO_GAIN: Completely disables EV gain from battles and other sources.

EV-Boosting Items Interaction:
B_EV_ITEMS_CAP: When set to TRUE, EV-boosting items are modified to respect the current EV cap:
Below Cap: If using an item would exceed the cap, the EV increase is reduced to match the cap.
At Cap: Items cannot be used if the Pokémon is already at the cap, preventing any EV gain.

Additional Features:
Script Integration: Supports dynamic changes to EV caps via scripts.
Milestone Management: Allows for structured progression of EV caps with predefined milestones.
Enhanced EV Management: Ensures EV growth is properly halted at the cap, both from battles and item usage, maintaining balanced gameplay.

Images

The demonstration below has the EV cap set to 16 and I'm using archie's Stat Editor to show the EV values.
Properly gaining EVs from battle but not being able to go over the EV from it:
evs from battle

Properly gaining EVs from EV items, having the increase reduced to the EV cap, and not being able to use EV items when at the EV cap:
evs from items

People who collaborated with me in this PR

Heavily inspired by Level Cap system and reviewed by @AlexOn1ine

Feature(s) this PR does NOT handle:

This doesn't include any way to look at a Pokemon's current EVs. There's also no indicator for the current EV cap in game.

Discord contact info

Discord: flash1lucky

Introduces EV caps, inspired by level caps, with configurable options for various cap implementations. Additionally, modifies EV items to interact with these caps based on a configurable setting.
@Pawkkie Pawkkie added new-feature Adds a feature category: battle-mechanic Pertains to battle mechanics labels Aug 27, 2024
src/party_menu.c Outdated Show resolved Hide resolved
@AlexOn1ine AlexOn1ine self-assigned this Aug 27, 2024
src/party_menu.c Outdated Show resolved Hide resolved
Changed the EV caps to be less redundant and work better overall.
Set the items back to ItemUseOutOfBattle_Medicine, got rid of ItemUseOutOfBattle_EVItem and ItemUseCB_EVItem, and reverted CB2_ReturnToPartyMenuUsingItem to CB2_ReturnToPartyMenuUsingRareCandy
Copy link
Collaborator

@AlexOn1ine AlexOn1ine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is something broken since once I reach the cap it loops over starting from 0. I used vitamins to increase the evs.

src/pokemon.c Outdated
@@ -5195,6 +5199,7 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies)
int i, multiplier;
u8 stat;
u8 bonus;
u32 currentEVCap = GetCurrentEVCap(); // Get the current EV cap
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is redundant since it restates the function name.

src/pokemon.c Outdated
@@ -5224,7 +5229,7 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies)

for (i = 0; i < NUM_STATS; i++)
{
if (totalEVs >= MAX_TOTAL_EVS)
if (totalEVs >= currentEVCap) // Use currentEVCap instead of MAX_TOTAL_EVS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment seems redundant here as well.

src/pokemon.c Outdated
@@ -5275,8 +5280,8 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies)
if (holdEffect == HOLD_EFFECT_MACHO_BRACE)
evIncrease *= 2;

if (totalEVs + (s16)evIncrease > MAX_TOTAL_EVS)
evIncrease = ((s16)evIncrease + MAX_TOTAL_EVS) - (totalEVs + evIncrease);
if (totalEVs + (s16)evIncrease > currentEVCap) // Use currentEVCap instead of MAX_TOTAL_EVS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also comment not needed here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed all the unnecessary comments.

Fixed being able to use EV items to go over 252 limit on single stats.
Copy link
Collaborator

@AlexOn1ine AlexOn1ine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more minor thing and then it can be merged.

src/ev_caps.c Outdated Show resolved Hide resolved
Co-authored-by: Alex <93446519+AlexOn1ine@users.noreply.github.com>
@AlexOn1ine AlexOn1ine merged commit de242c8 into rh-hideout:upcoming Sep 1, 2024
1 check passed
@Flash1Lucky Flash1Lucky deleted the ev_caps branch September 4, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: battle-mechanic Pertains to battle mechanics new-feature Adds a feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants