diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 0ee6e1b698..95ad77ff53 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2828,7 +2828,11 @@ void SetMoveEffect(bool32 primary, u32 certain) } break; 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) { @@ -2840,9 +2844,8 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; RecordAbilityBattle(gEffectBattler, ABILITY_STICKY_HOLD); } - break; } - if (gBattleMons[gEffectBattler].item) + else if (gBattleMons[gEffectBattler].item) { side = GetBattlerSide(gEffectBattler); diff --git a/src/battle_util.c b/src/battle_util.c index 007a863a2e..1b8ad6fcf1 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -6383,7 +6383,9 @@ bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId) return FALSE; else if (species == SPECIES_GROUDON && itemId == ITEM_RED_ORB) 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; else if (species == SPECIES_GIRATINA && itemId == ITEM_GRISEOUS_ORB) return FALSE;