Skip to content

Commit

Permalink
Power Items block other EV gains
Browse files Browse the repository at this point in the history
While holding a Power Item, a Pokémon will only gain EVs from the item itself. E.g. kill Zubat with Power Weight, get 8 HP EVs, 0 Speed EVs.
  • Loading branch information
BuffelSaft committed Sep 2, 2021
1 parent 2cfc74c commit 2128ae2
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -6801,6 +6801,8 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies)
powerItemStat = ItemId_GetSecondaryId(heldItem);
}

powerItemBonus = ItemId_GetHoldEffectParam(heldItem);

for (i = 0; i < NUM_STATS; i++)
{
if (totalEVs >= MAX_TOTAL_EVS)
Expand All @@ -6811,35 +6813,37 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies)
else
multiplier = 1;

if ((holdEffect == HOLD_EFFECT_POWER_ITEM) && (powerItemStat == (STAT_HP + i)))
// Power items prevent EV gain from Pokemon
if (holdEffect == HOLD_EFFECT_POWER_ITEM)
{
powerItemBonus = ItemId_GetHoldEffectParam(heldItem);
if (powerItemStat == (STAT_HP + i))
evIncrease = powerItemBonus * multiplier;
else
evIncrease = 0;
}
else
{
powerItemBonus = 0;
}

switch (i)
{
case STAT_HP:
evIncrease = (gBaseStats[defeatedSpecies].evYield_HP + powerItemBonus) * multiplier;
break;
case STAT_ATK:
evIncrease = (gBaseStats[defeatedSpecies].evYield_Attack + powerItemBonus) * multiplier;
break;
case STAT_DEF:
evIncrease = (gBaseStats[defeatedSpecies].evYield_Defense + powerItemBonus) * multiplier;
break;
case STAT_SPEED:
evIncrease = (gBaseStats[defeatedSpecies].evYield_Speed + powerItemBonus) * multiplier;
break;
case STAT_SPATK:
evIncrease = (gBaseStats[defeatedSpecies].evYield_SpAttack + powerItemBonus) * multiplier;
break;
case STAT_SPDEF:
evIncrease = (gBaseStats[defeatedSpecies].evYield_SpDefense + powerItemBonus) * multiplier;
break;
switch (i)
{
case STAT_HP:
evIncrease = gBaseStats[defeatedSpecies].evYield_HP * multiplier;
break;
case STAT_ATK:
evIncrease = gBaseStats[defeatedSpecies].evYield_Attack * multiplier;
break;
case STAT_DEF:
evIncrease = gBaseStats[defeatedSpecies].evYield_Defense * multiplier;
break;
case STAT_SPEED:
evIncrease = gBaseStats[defeatedSpecies].evYield_Speed * multiplier;
break;
case STAT_SPATK:
evIncrease = gBaseStats[defeatedSpecies].evYield_SpAttack * multiplier;
break;
case STAT_SPDEF:
evIncrease = gBaseStats[defeatedSpecies].evYield_SpDefense * multiplier;
break;
}
}

if (holdEffect == HOLD_EFFECT_MACHO_BRACE)
Expand Down

0 comments on commit 2128ae2

Please sign in to comment.