Can't Knock Off mega stones

This commit is contained in:
DizzyEggg 2020-02-22 17:30:07 +01:00
parent 6c71f9b57b
commit 517974ebcb
2 changed files with 9 additions and 4 deletions

View file

@ -2828,7 +2828,11 @@ void SetMoveEffect(bool32 primary, u32 certain)
} }
break; break;
case MOVE_EFFECT_KNOCK_OFF: case MOVE_EFFECT_KNOCK_OFF:
if (GetBattlerAbility(gEffectBattler) == ABILITY_STICKY_HOLD) if (!CanBattlerGetOrLoseItem(gEffectBattler, gBattleMons[gEffectBattler].item))
{
gBattlescriptCurrInstr++;
}
else if (GetBattlerAbility(gEffectBattler) == ABILITY_STICKY_HOLD)
{ {
if (gBattleMons[gEffectBattler].item == 0) if (gBattleMons[gEffectBattler].item == 0)
{ {
@ -2840,9 +2844,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; gBattlescriptCurrInstr = BattleScript_StickyHoldActivates;
RecordAbilityBattle(gEffectBattler, ABILITY_STICKY_HOLD); RecordAbilityBattle(gEffectBattler, ABILITY_STICKY_HOLD);
} }
break;
} }
if (gBattleMons[gEffectBattler].item) else if (gBattleMons[gEffectBattler].item)
{ {
side = GetBattlerSide(gEffectBattler); side = GetBattlerSide(gEffectBattler);

View file

@ -6383,7 +6383,9 @@ bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId)
return FALSE; return FALSE;
else if (species == SPECIES_GROUDON && itemId == ITEM_RED_ORB) else if (species == SPECIES_GROUDON && itemId == ITEM_RED_ORB)
return FALSE; return FALSE;
else if (ItemId_GetHoldEffect(itemId) == HOLD_EFFECT_MEGA_STONE && GetMegaEvolutionSpecies(species, itemId) != SPECIES_NONE) // Mega stone cannot be lost if pokemon can mega evolve with it or is already mega evolved.
else if (ItemId_GetHoldEffect(itemId) == HOLD_EFFECT_MEGA_STONE
&& ((GetMegaEvolutionSpecies(species, itemId) != SPECIES_NONE) || gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]))
return FALSE; return FALSE;
else if (species == SPECIES_GIRATINA && itemId == ITEM_GRISEOUS_ORB) else if (species == SPECIES_GIRATINA && itemId == ITEM_GRISEOUS_ORB)
return FALSE; return FALSE;