diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9b05d8baa9..e01e13dd0e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2073,6 +2073,15 @@ u8 GetBattlerTurnOrderNum(u8 battlerId) return i; } +static void CheckSetUnburden(u8 battlerId) +{ + if (GetBattlerAbility(battlerId) == ABILITY_UNBURDEN) + { + gBattleResources->flags->flags[battlerId] |= RESOURCE_FLAG_UNBURDEN; + RecordAbilityBattle(battlerId, ABILITY_UNBURDEN); + } +} + #define INCREMENT_RESET_RETURN \ { \ gBattlescriptCurrInstr++; \ @@ -2677,15 +2686,9 @@ void SetMoveEffect(bool32 primary, u32 certain) else { gLastUsedItem = gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerTarget].item; - gBattleMons[gBattlerTarget].item = 0; - - + gBattleMons[gBattlerTarget].item = 0; - if (GetBattlerAbility(gBattlerTarget) == ABILITY_UNBURDEN) - { - gBattleResources->flags->flags[gBattlerTarget] |= RESOURCE_FLAG_UNBURDEN; - RecordAbilityBattle(gBattlerTarget, ABILITY_UNBURDEN); - } + CheckSetUnburden(gBattlerTarget); if (GetBattlerAbility(gBattlerAttacker) == ABILITY_UNBURDEN && gBattleResources->flags->flags[gBattlerAttacker] & RESOURCE_FLAG_UNBURDEN) gBattleResources->flags->flags[gBattlerAttacker] &= ~(RESOURCE_FLAG_UNBURDEN); @@ -2806,11 +2809,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gLastUsedItem = gBattleMons[gEffectBattler].item; gBattleMons[gEffectBattler].item = 0; gWishFutureKnock.knockedOffMons[side] |= gBitTable[gBattlerPartyIndexes[gEffectBattler]]; - if (GetBattlerAbility(gEffectBattler) == ABILITY_UNBURDEN) - { - gBattleResources->flags->flags[gEffectBattler] |= RESOURCE_FLAG_UNBURDEN; - RecordAbilityBattle(gEffectBattler, ABILITY_UNBURDEN); - } + CheckSetUnburden(gEffectBattler); BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_KnockedOff; @@ -2946,11 +2945,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gLastUsedItem = gBattleMons[gEffectBattler].item; gBattleMons[gEffectBattler].item = 0; - if (GetBattlerAbility(gEffectBattler) == ABILITY_UNBURDEN) - { - gBattleResources->flags->flags[gEffectBattler] |= RESOURCE_FLAG_UNBURDEN; - RecordAbilityBattle(gEffectBattler, ABILITY_UNBURDEN); - } + CheckSetUnburden(gEffectBattler); gActiveBattler = gEffectBattler; BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gEffectBattler].item); @@ -2966,11 +2961,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gLastUsedItem = gBattleMons[gEffectBattler].item; gBattleMons[gEffectBattler].item = 0; - if (GetBattlerAbility(gEffectBattler) == ABILITY_UNBURDEN) - { - gBattleResources->flags->flags[gEffectBattler] |= RESOURCE_FLAG_UNBURDEN; - RecordAbilityBattle(gEffectBattler, ABILITY_UNBURDEN); - } + CheckSetUnburden(gEffectBattler); gActiveBattler = gEffectBattler; BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gEffectBattler].item); @@ -6150,11 +6141,7 @@ static void Cmd_removeitem(void) gBattleMons[gActiveBattler].item = 0; - if (GetBattlerAbility(gActiveBattler) == ABILITY_UNBURDEN) - { - gBattleResources->flags->flags[gActiveBattler] |= RESOURCE_FLAG_UNBURDEN; - RecordAbilityBattle(gActiveBattler, ABILITY_UNBURDEN); - } + CheckSetUnburden(gActiveBattler); BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item); MarkBattlerForControllerExec(gActiveBattler); @@ -10530,11 +10517,7 @@ static void Cmd_tryswapitems(void) // trick } else { - if (GetBattlerAbility(gBattlerAttacker) == ABILITY_UNBURDEN) - { - gBattleResources->flags->flags[gBattlerAttacker] |= RESOURCE_FLAG_UNBURDEN; - RecordAbilityBattle(gBattlerAttacker, ABILITY_UNBURDEN); - } + CheckSetUnburden(gBattlerAttacker); gBattleCommunication[MULTISTRING_CHOOSER] = 1; // attacker's item -> <- nothing } diff --git a/src/battle_util.c b/src/battle_util.c index 8b5f83e728..e0d88bafc4 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5132,8 +5132,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) // todo break; case EFFECT_FLING: - // todo - // reminder to program Fling + Unburden interaction + // todo: program Fling + Unburden interaction break; case EFFECT_ERUPTION: basePower = gBattleMons[battlerAtk].hp * basePower / gBattleMons[battlerAtk].maxHP;