Skip to content

Commit

Permalink
Hard Level Caps issues (#4420)
Browse files Browse the repository at this point in the history
* Fix 1 exp gain on hard level caps

* Level Cap issues

* fix compile

* brackets
  • Loading branch information
AlexOn1ine authored Apr 30, 2024
1 parent 6ad443c commit 48d71b0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -4416,7 +4416,15 @@ static void Cmd_getexp(void)
gBattleMoveDamage += GetSoftLevelCapExpValue(gPlayerParty[*expMonId].level, gBattleStruct->expShareExpValue);;
}

ApplyExperienceMultipliers(&gBattleMoveDamage, *expMonId, gBattlerFainted);
if (EXP_CAP_HARD && gBattleMoveDamage != 0)
{
u32 growthRate = gSpeciesInfo[GetMonData(&gPlayerParty[*expMonId], MON_DATA_SPECIES)].growthRate;
if (gExperienceTables[growthRate][GetCurrentLevelCap()] < gExperienceTables[growthRate][GetMonData(&gPlayerParty[*expMonId], MON_DATA_LEVEL)] + gBattleMoveDamage)
gBattleMoveDamage = gExperienceTables[growthRate][GetCurrentLevelCap()];
}

if (!EXP_CAP_HARD || gBattleMoveDamage != 0) // Edge case for hard level caps. Prevents mons from getting 1 exp
ApplyExperienceMultipliers(&gBattleMoveDamage, *expMonId, gBattlerFainted);

if (IsTradedMon(&gPlayerParty[*expMonId]))
{
Expand Down Expand Up @@ -15987,6 +15995,7 @@ void ApplyExperienceMultipliers(s32 *expAmount, u8 expGetterMonId, u8 faintedBat

value *= sExperienceScalingFactors[(faintedLevel * 2) + 10];
value /= sExperienceScalingFactors[faintedLevel + expGetterLevel + 10];

*expAmount = value + 1;
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -3530,8 +3530,17 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov
{
u16 species = GetMonData(mon, MON_DATA_SPECIES, NULL);
dataUnsigned = sExpCandyExperienceTable[param - 1] + GetMonData(mon, MON_DATA_EXP, NULL);
if (dataUnsigned > gExperienceTables[gSpeciesInfo[species].growthRate][MAX_LEVEL])

if (B_RARE_CANDY_CAP && EXP_CAP_HARD)
{
u32 currentLevelCap = GetCurrentLevelCap();
if (dataUnsigned > gExperienceTables[gSpeciesInfo[species].growthRate][currentLevelCap])
dataUnsigned = gExperienceTables[gSpeciesInfo[species].growthRate][currentLevelCap];
}
else if (dataUnsigned > gExperienceTables[gSpeciesInfo[species].growthRate][MAX_LEVEL])
{
dataUnsigned = gExperienceTables[gSpeciesInfo[species].growthRate][MAX_LEVEL];
}
}

if (dataUnsigned != 0) // Failsafe
Expand Down
Binary file added tools/trainerproc/trainerproc
Binary file not shown.

0 comments on commit 48d71b0

Please sign in to comment.