diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 48ac38841..e01e13dd0 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,7 +2686,12 @@ void SetMoveEffect(bool32 primary, u32 certain) else { gLastUsedItem = gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerTarget].item; - gBattleMons[gBattlerTarget].item = 0; + gBattleMons[gBattlerTarget].item = 0; + + CheckSetUnburden(gBattlerTarget); + + if (GetBattlerAbility(gBattlerAttacker) == ABILITY_UNBURDEN && gBattleResources->flags->flags[gBattlerAttacker] & RESOURCE_FLAG_UNBURDEN) + gBattleResources->flags->flags[gBattlerAttacker] &= ~(RESOURCE_FLAG_UNBURDEN); gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem); @@ -2795,6 +2809,7 @@ void SetMoveEffect(bool32 primary, u32 certain) gLastUsedItem = gBattleMons[gEffectBattler].item; gBattleMons[gEffectBattler].item = 0; gWishFutureKnock.knockedOffMons[side] |= gBitTable[gBattlerPartyIndexes[gEffectBattler]]; + CheckSetUnburden(gEffectBattler); BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_KnockedOff; @@ -2929,6 +2944,9 @@ void SetMoveEffect(bool32 primary, u32 certain) { gLastUsedItem = gBattleMons[gEffectBattler].item; gBattleMons[gEffectBattler].item = 0; + + CheckSetUnburden(gEffectBattler); + gActiveBattler = gEffectBattler; BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gEffectBattler].item); MarkBattlerForControllerExec(gActiveBattler); @@ -2942,6 +2960,9 @@ void SetMoveEffect(bool32 primary, u32 certain) { gLastUsedItem = gBattleMons[gEffectBattler].item; gBattleMons[gEffectBattler].item = 0; + + CheckSetUnburden(gEffectBattler); + gActiveBattler = gEffectBattler; BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gEffectBattler].item); MarkBattlerForControllerExec(gActiveBattler); @@ -6119,6 +6140,8 @@ static void Cmd_removeitem(void) gBattleStruct->usedHeldItems[gActiveBattler] = gBattleMons[gActiveBattler].item; gBattleMons[gActiveBattler].item = 0; + + CheckSetUnburden(gActiveBattler); BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item); MarkBattlerForControllerExec(gActiveBattler); @@ -10486,9 +10509,18 @@ static void Cmd_tryswapitems(void) // trick if (oldItemAtk != 0 && *newItemAtk != 0) gBattleCommunication[MULTISTRING_CHOOSER] = 2; // attacker's item -> <- target's item else if (oldItemAtk == 0 && *newItemAtk != 0) - gBattleCommunication[MULTISTRING_CHOOSER] = 0; // nothing -> <- target's item + { + if (GetBattlerAbility(gBattlerAttacker) == ABILITY_UNBURDEN && gBattleResources->flags->flags[gBattlerAttacker] & RESOURCE_FLAG_UNBURDEN) + gBattleResources->flags->flags[gBattlerAttacker] &= ~(RESOURCE_FLAG_UNBURDEN); + + gBattleCommunication[MULTISTRING_CHOOSER] = 0; // nothing -> <- target's item + } else + { + CheckSetUnburden(gBattlerAttacker); + gBattleCommunication[MULTISTRING_CHOOSER] = 1; // attacker's item -> <- nothing + } } } } diff --git a/src/battle_util.c b/src/battle_util.c index ebdc2063b..e0d88bafc 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5132,7 +5132,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) // todo break; case EFFECT_FLING: - // todo + // todo: program Fling + Unburden interaction break; case EFFECT_ERUPTION: basePower = gBattleMons[battlerAtk].hp * basePower / gBattleMons[battlerAtk].maxHP;