Implemented the effects of the Power Items

For more info: https://bulbapedia.bulbagarden.net/wiki/Power_item
This commit is contained in:
LOuroboros 2020-10-15 05:21:28 -03:00
parent e4635525e7
commit 2578a440a1

View File

@ -5560,6 +5560,24 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies)
u16 heldItem;
u8 holdEffect;
int i, multiplier;
u8 stat;
u8 bonus;
heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, 0);
if (heldItem == ITEM_ENIGMA_BERRY)
{
if (gMain.inBattle)
holdEffect = gEnigmaBerries[0].holdEffect;
else
holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect;
}
else
{
holdEffect = ItemId_GetHoldEffect(heldItem);
}
stat = ItemId_GetSecondaryId(heldItem);
bonus = ItemId_GetHoldEffectParam(heldItem);
for (i = 0; i < NUM_STATS; i++)
{
@ -5580,38 +5598,43 @@ void MonGainEVs(struct Pokemon *mon, u16 defeatedSpecies)
switch (i)
{
case STAT_HP:
if (holdEffect == HOLD_EFFECT_POWER_ITEM && stat == STAT_HP)
evIncrease = (gBaseStats[defeatedSpecies].evYield_HP + bonus) * multiplier;
else
evIncrease = gBaseStats[defeatedSpecies].evYield_HP * multiplier;
break;
case STAT_ATK:
if (holdEffect == HOLD_EFFECT_POWER_ITEM && stat == STAT_ATK)
evIncrease = (gBaseStats[defeatedSpecies].evYield_Attack + bonus) * multiplier;
else
evIncrease = gBaseStats[defeatedSpecies].evYield_Attack * multiplier;
break;
case STAT_DEF:
if (holdEffect == HOLD_EFFECT_POWER_ITEM && stat == STAT_DEF)
evIncrease = (gBaseStats[defeatedSpecies].evYield_Defense + bonus) * multiplier;
else
evIncrease = gBaseStats[defeatedSpecies].evYield_Defense * multiplier;
break;
case STAT_SPEED:
if (holdEffect == HOLD_EFFECT_POWER_ITEM && stat == STAT_SPEED)
evIncrease = (gBaseStats[defeatedSpecies].evYield_Speed + bonus) * multiplier;
else
evIncrease = gBaseStats[defeatedSpecies].evYield_Speed * multiplier;
break;
case STAT_SPATK:
if (holdEffect == HOLD_EFFECT_POWER_ITEM && stat == STAT_SPATK)
evIncrease = (gBaseStats[defeatedSpecies].evYield_SpAttack + bonus) * multiplier;
else
evIncrease = gBaseStats[defeatedSpecies].evYield_SpAttack * multiplier;
break;
case STAT_SPDEF:
if (holdEffect == HOLD_EFFECT_POWER_ITEM && stat == STAT_SPDEF)
evIncrease = (gBaseStats[defeatedSpecies].evYield_SpDefense + bonus) * multiplier;
else
evIncrease = gBaseStats[defeatedSpecies].evYield_SpDefense * multiplier;
break;
}
heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, 0);
if (heldItem == ITEM_ENIGMA_BERRY)
{
if (gMain.inBattle)
holdEffect = gEnigmaBerries[0].holdEffect;
else
holdEffect = gSaveBlock1Ptr->enigmaBerry.holdEffect;
}
else
{
holdEffect = ItemId_GetHoldEffect(heldItem);
}
if (holdEffect == HOLD_EFFECT_MACHO_BRACE)
evIncrease *= 2;