Merge pull request #216 from ultima-soul/unburden

Implement Unburden
This commit is contained in:
DizzyEggg 2019-12-25 12:01:25 +01:00 committed by GitHub
commit 5e5767bb5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 3 deletions

View File

@ -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++; \
@ -2679,6 +2688,11 @@ void SetMoveEffect(bool32 primary, u32 certain)
gLastUsedItem = gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerTarget].item;
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);
MarkBattlerForControllerExec(gBattlerAttacker);
@ -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);
@ -6120,6 +6141,8 @@ static void Cmd_removeitem(void)
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
}
}
}
}

View File

@ -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;