summaryrefslogtreecommitdiff
path: root/src/battle_util.c
diff options
context:
space:
mode:
authorhondew <pokehondew@gmail.com>2020-08-30 14:14:38 -0400
committerhondew <pokehondew@gmail.com>2020-08-30 14:14:38 -0400
commite46b35455d1e2af8c8c2d291ce1cc28e682d9095 (patch)
tree76855f3dedad94ba34a8f8b40811a1005107b5ae /src/battle_util.c
parent328aecc96e690c437e52663a1445417e8aa78df6 (diff)
parenta9719c92bfa4c6b6dcf57e9516f184721152ad80 (diff)
Merge branch 'master' into pokeball-doc
Diffstat (limited to 'src/battle_util.c')
-rw-r--r--src/battle_util.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/battle_util.c b/src/battle_util.c
index 9cc2252b6..699fd05bc 100644
--- a/src/battle_util.c
+++ b/src/battle_util.c
@@ -259,7 +259,7 @@ void ResetSentPokesToOpponentValue(void)
gSentPokesToOpponent[(i & BIT_FLANK) >> 1] = bits;
}
-void sub_803F9EC(u8 battler)
+void OpponentSwitchInResetSentPokesToOpponentValue(u8 battler)
{
s32 i = 0;
u32 bits = 0;
@@ -279,11 +279,11 @@ void sub_803F9EC(u8 battler)
}
}
-void sub_803FA70(u8 battler)
+void UpdateSentPokesToOpponentValue(u8 battler)
{
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
{
- sub_803F9EC(battler);
+ OpponentSwitchInResetSentPokesToOpponentValue(battler);
}
else
{
@@ -1250,7 +1250,7 @@ bool8 HandleFaintedMonActions(void)
gBattleStruct->faintedActionsState = 3;
break;
case 2:
- sub_803F9EC(gBattlerFainted);
+ OpponentSwitchInResetSentPokesToOpponentValue(gBattlerFainted);
if (++gBattleStruct->faintedActionsBattlerId == gBattlersCount)
gBattleStruct->faintedActionsState = 3;
else
@@ -1978,7 +1978,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
}
break;
case ABILITY_SPEED_BOOST:
- if (gBattleMons[battler].statStages[STAT_SPEED] < 0xC && gDisableStructs[battler].isFirstTurn != 2)
+ if (gBattleMons[battler].statStages[STAT_SPEED] < MAX_STAT_STAGE && gDisableStructs[battler].isFirstTurn != 2)
{
gBattleMons[battler].statStages[STAT_SPEED]++;
gBattleScripting.animArg1 = 0x11;
@@ -2619,9 +2619,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < NUM_BATTLE_STATS; i++)
{
- if (gBattleMons[battlerId].statStages[i] < 6)
+ if (gBattleMons[battlerId].statStages[i] < DEFAULT_STAT_STAGE)
{
- gBattleMons[battlerId].statStages[i] = 6;
+ gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE;
effect = ITEM_STATS_CHANGE;
}
}
@@ -2690,9 +2690,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < NUM_BATTLE_STATS; i++)
{
- if (gBattleMons[battlerId].statStages[i] < 6)
+ if (gBattleMons[battlerId].statStages[i] < DEFAULT_STAT_STAGE)
{
- gBattleMons[battlerId].statStages[i] = 6;
+ gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE;
effect = ITEM_STATS_CHANGE;
}
}
@@ -2811,7 +2811,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break;
// copy/paste again, smh
case HOLD_EFFECT_ATTACK_UP:
- if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_ATK] < 0xC)
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam
+ && !moveTurn && gBattleMons[battlerId].statStages[STAT_ATK] < MAX_STAT_STAGE)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK);
PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE);
@@ -2825,7 +2826,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
break;
case HOLD_EFFECT_DEFENSE_UP:
- if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_DEF] < 0xC)
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn
+ && gBattleMons[battlerId].statStages[STAT_DEF] < MAX_STAT_STAGE)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_DEF);
@@ -2838,7 +2840,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
break;
case HOLD_EFFECT_SPEED_UP:
- if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPEED] < 0xC)
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn
+ && gBattleMons[battlerId].statStages[STAT_SPEED] < MAX_STAT_STAGE)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPEED);
@@ -2851,7 +2854,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
break;
case HOLD_EFFECT_SP_ATTACK_UP:
- if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPATK] < 0xC)
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn
+ && gBattleMons[battlerId].statStages[STAT_SPATK] < MAX_STAT_STAGE)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPATK);
@@ -2864,7 +2868,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
break;
case HOLD_EFFECT_SP_DEFENSE_UP:
- if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPDEF] < 0xC)
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn
+ && gBattleMons[battlerId].statStages[STAT_SPDEF] < MAX_STAT_STAGE)
{
PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPDEF);
@@ -2877,7 +2882,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
}
break;
case HOLD_EFFECT_CRITICAL_UP:
- if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY))
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn
+ && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY))
{
gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2);
@@ -2889,7 +2895,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
{
for (i = 0; i < 5; i++)
{
- if (gBattleMons[battlerId].statStages[STAT_ATK + i] < 0xC)
+ if (gBattleMons[battlerId].statStages[STAT_ATK + i] < MAX_STAT_STAGE)
break;
}
if (i != 5)
@@ -2897,7 +2903,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
do
{
i = Random() % 5;
- } while (gBattleMons[battlerId].statStages[STAT_ATK + i] == 0xC);
+ } while (gBattleMons[battlerId].statStages[STAT_ATK + i] == MAX_STAT_STAGE);
PREPARE_STAT_BUFFER(gBattleTextBuff1, i + 1);
@@ -3166,9 +3172,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
case HOLD_EFFECT_RESTORE_STATS:
for (i = 0; i < NUM_BATTLE_STATS; i++)
{
- if (gBattleMons[battlerId].statStages[i] < 6)
+ if (gBattleMons[battlerId].statStages[i] < DEFAULT_STAT_STAGE)
{
- gBattleMons[battlerId].statStages[i] = 6;
+ gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE;
effect = ITEM_STATS_CHANGE;
}
}