From 380e1e470c2c25683b22e567cc65489faaf3c2ae Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Wed, 22 Sep 2021 23:29:00 -0300 Subject: [PATCH 1/7] Applied use of TRUE and FALSE for flags. --- src/battle_main.c | 60 +++++++++---------- src/battle_script_commands.c | 112 +++++++++++++++++------------------ src/battle_util.c | 112 +++++++++++++++++------------------ 3 files changed, 142 insertions(+), 142 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 72d05a0fd..1b4ad5f74 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3067,31 +3067,31 @@ void FaintClearSetData(void) memset(&gDisableStructs[gActiveBattler], 0, sizeof(struct DisableStruct)); - gProtectStructs[gActiveBattler].protected = 0; - gProtectStructs[gActiveBattler].spikyShielded = 0; - gProtectStructs[gActiveBattler].kingsShielded = 0; - gProtectStructs[gActiveBattler].banefulBunkered = 0; - gProtectStructs[gActiveBattler].endured = 0; - gProtectStructs[gActiveBattler].noValidMoves = 0; - gProtectStructs[gActiveBattler].helpingHand = 0; - gProtectStructs[gActiveBattler].bounceMove = 0; - gProtectStructs[gActiveBattler].stealMove = 0; - gProtectStructs[gActiveBattler].prlzImmobility = 0; - gProtectStructs[gActiveBattler].confusionSelfDmg = 0; - gProtectStructs[gActiveBattler].targetAffected = 0; - gProtectStructs[gActiveBattler].chargingTurn = 0; + gProtectStructs[gActiveBattler].protected = FALSE; + gProtectStructs[gActiveBattler].spikyShielded = FALSE; + gProtectStructs[gActiveBattler].kingsShielded = FALSE; + gProtectStructs[gActiveBattler].banefulBunkered = FALSE; + gProtectStructs[gActiveBattler].endured = FALSE; + gProtectStructs[gActiveBattler].noValidMoves = FALSE; + gProtectStructs[gActiveBattler].helpingHand = FALSE; + gProtectStructs[gActiveBattler].bounceMove = FALSE; + gProtectStructs[gActiveBattler].stealMove = FALSE; + gProtectStructs[gActiveBattler].prlzImmobility = FALSE; + gProtectStructs[gActiveBattler].confusionSelfDmg = FALSE; + gProtectStructs[gActiveBattler].targetAffected = FALSE; + gProtectStructs[gActiveBattler].chargingTurn = FALSE; gProtectStructs[gActiveBattler].fleeFlag = 0; - gProtectStructs[gActiveBattler].usedImprisonedMove = 0; - gProtectStructs[gActiveBattler].loveImmobility = 0; - gProtectStructs[gActiveBattler].usedDisabledMove = 0; - gProtectStructs[gActiveBattler].usedTauntedMove = 0; - gProtectStructs[gActiveBattler].flag2Unknown = 0; - gProtectStructs[gActiveBattler].flinchImmobility = 0; - gProtectStructs[gActiveBattler].notFirstStrike = 0; - gProtectStructs[gActiveBattler].usedHealBlockedMove = 0; - gProtectStructs[gActiveBattler].usesBouncedMove = 0; - gProtectStructs[gActiveBattler].usedGravityPreventedMove = 0; - gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = 0; + gProtectStructs[gActiveBattler].usedImprisonedMove = FALSE; + gProtectStructs[gActiveBattler].loveImmobility = FALSE; + gProtectStructs[gActiveBattler].usedDisabledMove = FALSE; + gProtectStructs[gActiveBattler].usedTauntedMove = FALSE; + gProtectStructs[gActiveBattler].flag2Unknown = FALSE; + gProtectStructs[gActiveBattler].flinchImmobility = FALSE; + gProtectStructs[gActiveBattler].notFirstStrike = FALSE; + gProtectStructs[gActiveBattler].usedHealBlockedMove = FALSE; + gProtectStructs[gActiveBattler].usesBouncedMove = FALSE; + gProtectStructs[gActiveBattler].usedGravityPreventedMove = FALSE; + gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = FALSE; gDisableStructs[gActiveBattler].isFirstTurn = 2; @@ -4541,10 +4541,10 @@ static void TurnValuesCleanUp(bool8 var0) { if (var0) { - gProtectStructs[gActiveBattler].protected = 0; - gProtectStructs[gActiveBattler].spikyShielded = 0; - gProtectStructs[gActiveBattler].kingsShielded = 0; - gProtectStructs[gActiveBattler].banefulBunkered = 0; + gProtectStructs[gActiveBattler].protected = FALSE; + gProtectStructs[gActiveBattler].spikyShielded = FALSE; + gProtectStructs[gActiveBattler].kingsShielded = FALSE; + gProtectStructs[gActiveBattler].banefulBunkered = FALSE; } else { @@ -5032,7 +5032,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk) gBattleStruct->dynamicMoveType = 0; gBattleStruct->ateBoost[battlerAtk] = 0; - gSpecialStatuses[battlerAtk].gemBoost = 0; + gSpecialStatuses[battlerAtk].gemBoost = FALSE; if (gBattleMoves[move].effect == EFFECT_WEATHER_BALL) { @@ -5126,7 +5126,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk) && moveType == ItemId_GetSecondaryId(gBattleMons[battlerAtk].item)) { gSpecialStatuses[battlerAtk].gemParam = GetBattlerHoldEffectParam(battlerAtk); - gSpecialStatuses[battlerAtk].gemBoost = 1; + gSpecialStatuses[battlerAtk].gemBoost = TRUE; } } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5840e8805..9a107fac0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1402,8 +1402,8 @@ static void Cmd_attackcanceler(void) && !gProtectStructs[gBattlerAttacker].usesBouncedMove) { PressurePPLose(gBattlerAttacker, gBattlerTarget, MOVE_MAGIC_COAT); - gProtectStructs[gBattlerTarget].bounceMove = 0; - gProtectStructs[gBattlerTarget].usesBouncedMove = 1; + gProtectStructs[gBattlerTarget].bounceMove = FALSE; + gProtectStructs[gBattlerTarget].usesBouncedMove = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; @@ -1414,7 +1414,7 @@ static void Cmd_attackcanceler(void) && !gProtectStructs[gBattlerAttacker].usesBouncedMove) { RecordAbilityBattle(gBattlerTarget, ABILITY_MAGIC_BOUNCE); - gProtectStructs[gBattlerTarget].usesBouncedMove = 1; + gProtectStructs[gBattlerTarget].usesBouncedMove = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = 1; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; @@ -1426,7 +1426,7 @@ static void Cmd_attackcanceler(void) if ((gProtectStructs[gBattlerByTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) { PressurePPLose(gBattlerAttacker, gBattlerByTurnOrder[i], MOVE_SNATCH); - gProtectStructs[gBattlerByTurnOrder[i]].stealMove = 0; + gProtectStructs[gBattlerByTurnOrder[i]].stealMove = FALSE; gBattleScripting.battler = gBattlerByTurnOrder[i]; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SnatchedMove; @@ -1436,7 +1436,7 @@ static void Cmd_attackcanceler(void) if (gSpecialStatuses[gBattlerTarget].lightningRodRedirected) { - gSpecialStatuses[gBattlerTarget].lightningRodRedirected = 0; + gSpecialStatuses[gBattlerTarget].lightningRodRedirected = FALSE; gLastUsedAbility = ABILITY_LIGHTNING_ROD; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_TookAttack; @@ -1444,7 +1444,7 @@ static void Cmd_attackcanceler(void) } else if (gSpecialStatuses[gBattlerTarget].stormDrainRedirected) { - gSpecialStatuses[gBattlerTarget].stormDrainRedirected = 0; + gSpecialStatuses[gBattlerTarget].stormDrainRedirected = FALSE; gLastUsedAbility = ABILITY_STORM_DRAIN; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_TookAttack; @@ -1456,7 +1456,7 @@ static void Cmd_attackcanceler(void) && gBattleMoves[gCurrentMove].effect != EFFECT_SUCKER_PUNCH) { if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT) - gProtectStructs[gBattlerAttacker].touchedProtectLike = 1; + gProtectStructs[gBattlerAttacker].touchedProtectLike = TRUE; CancelMultiTurnMoves(gBattlerAttacker); gMoveResultFlags |= MOVE_RESULT_MISSED; gLastLandedMoves[gBattlerTarget] = 0; @@ -1745,7 +1745,7 @@ static void Cmd_ppreduce(void) if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos]) { - gProtectStructs[gBattlerAttacker].notFirstStrike = 1; + gProtectStructs[gBattlerAttacker].notFirstStrike = TRUE; // For item Metronome, echoed voice if (gCurrentMove == gLastResultingMoves[gBattlerAttacker] && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) @@ -1888,17 +1888,17 @@ static void Cmd_adjustdamage(void) if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param) { RecordItemEffectBattle(gBattlerTarget, holdEffect); - gSpecialStatuses[gBattlerTarget].focusBanded = 1; + gSpecialStatuses[gBattlerTarget].focusBanded = TRUE; } else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) { RecordItemEffectBattle(gBattlerTarget, holdEffect); - gSpecialStatuses[gBattlerTarget].focusSashed = 1; + gSpecialStatuses[gBattlerTarget].focusSashed = TRUE; } else if (GetBattlerAbility(gBattlerTarget) == ABILITY_STURDY && BATTLER_MAX_HP(gBattlerTarget)) { RecordAbilityBattle(gBattlerTarget, ABILITY_STURDY); - gSpecialStatuses[gBattlerTarget].sturdied = 1; + gSpecialStatuses[gBattlerTarget].sturdied = TRUE; } if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE @@ -1961,7 +1961,7 @@ static void Cmd_multihitresultmessage(void) if (gMoveResultFlags & MOVE_RESULT_STURDIED) { gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON); - gSpecialStatuses[gBattlerTarget].sturdied = 0; // Delete this line to make Sturdy last for the duration of the whole move turn. + gSpecialStatuses[gBattlerTarget].sturdied = FALSE; // Delete this line to make Sturdy last for the duration of the whole move turn. BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SturdiedMsg; return; @@ -1971,8 +1971,8 @@ static void Cmd_multihitresultmessage(void) gLastUsedItem = gBattleMons[gBattlerTarget].item; gPotentialItemEffectBattler = gBattlerTarget; gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_HUNG_ON); - gSpecialStatuses[gBattlerTarget].focusBanded = 0; // Delete this line to make Focus Band last for the duration of the whole move turn. - gSpecialStatuses[gBattlerTarget].focusSashed = 0; // Delete this line to make Focus Sash last for the duration of the whole move turn. + gSpecialStatuses[gBattlerTarget].focusBanded = FALSE; // Delete this line to make Focus Band last for the duration of the whole move turn. + gSpecialStatuses[gBattlerTarget].focusSashed = FALSE; // Delete this line to make Focus Sash last for the duration of the whole move turn. BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_HangedOnMsg; return; @@ -1984,7 +1984,7 @@ static void Cmd_multihitresultmessage(void) if (gSpecialStatuses[gBattlerTarget].berryReduced && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - gSpecialStatuses[gBattlerTarget].berryReduced = 0; + gSpecialStatuses[gBattlerTarget].berryReduced = FALSE; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString; } @@ -2336,7 +2336,7 @@ static void Cmd_resultmessage(void) else if (gMoveResultFlags & MOVE_RESULT_STURDIED) { gMoveResultFlags &= ~(MOVE_RESULT_STURDIED | MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON); - gSpecialStatuses[gBattlerTarget].sturdied = 0; + gSpecialStatuses[gBattlerTarget].sturdied = FALSE; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SturdiedMsg; return; @@ -2378,7 +2378,7 @@ static void Cmd_resultmessage(void) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { gLastUsedItem = gBattleMons[gBattlerTarget].item; - gSpecialStatuses[gBattlerTarget].berryReduced = 0; + gSpecialStatuses[gBattlerTarget].berryReduced = FALSE; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_PrintBerryReduceString; } @@ -2888,7 +2888,7 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_CHARGING: gBattleMons[gEffectBattler].status2 |= STATUS2_MULTIPLETURNS; gLockedMoves[gEffectBattler] = gCurrentMove; - gProtectStructs[gEffectBattler].chargingTurn = 1; + gProtectStructs[gEffectBattler].chargingTurn = TRUE; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_WRAP: @@ -3212,14 +3212,14 @@ void SetMoveEffect(bool32 primary, u32 certain) || gProtectStructs[gBattlerTarget].kingsShielded || gProtectStructs[gBattlerTarget].banefulBunkered) { - gProtectStructs[gBattlerTarget].protected = 0; + gProtectStructs[gBattlerTarget].protected = FALSE; gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_WIDE_GUARD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_QUICK_GUARD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_CRAFTY_SHIELD); gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_MAT_BLOCK); - gProtectStructs[gBattlerTarget].spikyShielded = 0; - gProtectStructs[gBattlerTarget].kingsShielded = 0; - gProtectStructs[gBattlerTarget].banefulBunkered = 0; + gProtectStructs[gBattlerTarget].spikyShielded = FALSE; + gProtectStructs[gBattlerTarget].kingsShielded = FALSE; + gProtectStructs[gBattlerTarget].banefulBunkered = FALSE; if (gCurrentMove == MOVE_FEINT) { BattleScriptPush(gBattlescriptCurrInstr + 1); @@ -4753,7 +4753,7 @@ static void Cmd_moveend(void) { if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD) { - gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; + gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -4764,7 +4764,7 @@ static void Cmd_moveend(void) } else if (gProtectStructs[gBattlerTarget].kingsShielded) { - gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; + gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; i = gBattlerAttacker; gBattlerAttacker = gBattlerTarget; gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable @@ -4775,7 +4775,7 @@ static void Cmd_moveend(void) } else if (gProtectStructs[gBattlerTarget].banefulBunkered) { - gProtectStructs[gBattlerAttacker].touchedProtectLike = 0; + gProtectStructs[gBattlerAttacker].touchedProtectLike = FALSE; gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER; PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_BANEFUL_BUNKER); BattleScriptPushCursor(); @@ -4924,7 +4924,7 @@ static void Cmd_moveend(void) BtlController_EmitSpriteInvisibility(0, FALSE); MarkBattlerForControllerExec(gActiveBattler); gStatuses3[gBattlerAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); - gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = 1; + gSpecialStatuses[gBattlerAttacker].restoredBattlerSprite = TRUE; gBattleScripting.moveendState++; return; } @@ -5030,7 +5030,7 @@ static void Cmd_moveend(void) // Set a flag if move hits either target (for throat spray that can't check damage) if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) - gProtectStructs[gBattlerAttacker].targetAffected = 1; + gProtectStructs[gBattlerAttacker].targetAffected = TRUE; if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE @@ -5227,7 +5227,7 @@ static void Cmd_moveend(void) { gBattleScripting.savedBattler = gBattlerTarget | 0x4; gBattleScripting.savedBattler |= (gBattlerAttacker << 4); - gSpecialStatuses[gBattlerAttacker].dancerUsedMove = 1; + gSpecialStatuses[gBattlerAttacker].dancerUsedMove = TRUE; } for (battler = 0; battler < MAX_BATTLERS_COUNT; battler++) { @@ -5275,13 +5275,13 @@ static void Cmd_moveend(void) *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].instructedChosenTarget & 0x3; if (gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget) *(gBattleStruct->moveTarget + gBattlerAttacker) = gSpecialStatuses[gBattlerAttacker].dancerOriginalTarget & 0x3; - gProtectStructs[gBattlerAttacker].usesBouncedMove = 0; - gProtectStructs[gBattlerAttacker].targetAffected = 0; + gProtectStructs[gBattlerAttacker].usesBouncedMove = FALSE; + gProtectStructs[gBattlerAttacker].targetAffected = FALSE; gBattleStruct->ateBoost[gBattlerAttacker] = 0; gStatuses3[gBattlerAttacker] &= ~(STATUS3_ME_FIRST); - gSpecialStatuses[gBattlerAttacker].gemBoost = 0; + gSpecialStatuses[gBattlerAttacker].gemBoost = FALSE; gSpecialStatuses[gBattlerAttacker].damagedMons = 0; - gSpecialStatuses[gBattlerTarget].berryReduced = 0; + gSpecialStatuses[gBattlerTarget].berryReduced = FALSE; gBattleScripting.moveEffect = 0; gBattleScripting.moveendState++; break; @@ -7538,9 +7538,9 @@ static void Cmd_various(void) gBattleCommunication[0] = FALSE; break; case VARIOUS_RESET_INTIMIDATE_TRACE_BITS: - gSpecialStatuses[gActiveBattler].intimidatedMon = 0; - gSpecialStatuses[gActiveBattler].traced = 0; - gSpecialStatuses[gActiveBattler].switchInAbilityDone = 0; + gSpecialStatuses[gActiveBattler].intimidatedMon = FALSE; + gSpecialStatuses[gActiveBattler].traced = FALSE; + gSpecialStatuses[gActiveBattler].switchInAbilityDone = FALSE; break; case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP: if (gBattlerPartyIndexes[0] == gBattleStruct->expGetterMonId || gBattlerPartyIndexes[2] == gBattleStruct->expGetterMonId) @@ -8615,27 +8615,27 @@ static void Cmd_setprotectlike(void) { if (gBattleMoves[gCurrentMove].effect == EFFECT_ENDURE) { - gProtectStructs[gBattlerAttacker].endured = 1; + gProtectStructs[gBattlerAttacker].endured = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_BRACED_ITSELF; } else if (gCurrentMove == MOVE_DETECT || gCurrentMove == MOVE_PROTECT) { - gProtectStructs[gBattlerAttacker].protected = 1; + gProtectStructs[gBattlerAttacker].protected = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; } else if (gCurrentMove == MOVE_SPIKY_SHIELD) { - gProtectStructs[gBattlerAttacker].spikyShielded = 1; + gProtectStructs[gBattlerAttacker].spikyShielded = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; } else if (gCurrentMove == MOVE_KINGS_SHIELD) { - gProtectStructs[gBattlerAttacker].kingsShielded = 1; + gProtectStructs[gBattlerAttacker].kingsShielded = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; } else if (gCurrentMove == MOVE_BANEFUL_BUNKER) { - gProtectStructs[gBattlerAttacker].banefulBunkered = 1; + gProtectStructs[gBattlerAttacker].banefulBunkered = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_PROTECTED_ITSELF; } @@ -8800,7 +8800,7 @@ static void Cmd_trymirrormove(void) } else { - gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; + gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; gBattlescriptCurrInstr++; } } @@ -9168,7 +9168,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr BattleScriptPush(BS_ptr); gBattleScripting.battler = gActiveBattler; gBattlescriptCurrInstr = BattleScript_MistProtected; - gSpecialStatuses[gActiveBattler].statLowered = 1; + gSpecialStatuses[gActiveBattler].statLowered = TRUE; } } return STAT_CHANGE_DIDNT_WORK; @@ -9198,7 +9198,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss; gLastUsedAbility = GetBattlerAbility(gActiveBattler); RecordAbilityBattle(gActiveBattler, gLastUsedAbility); - gSpecialStatuses[gActiveBattler].statLowered = 1; + gSpecialStatuses[gActiveBattler].statLowered = TRUE; } } return STAT_CHANGE_DIDNT_WORK; @@ -9218,7 +9218,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr gBattlerAbility = index - 1; gBattlescriptCurrInstr = BattleScript_FlowerVeilProtectsRet; gLastUsedAbility = ABILITY_FLOWER_VEIL; - gSpecialStatuses[gActiveBattler].statLowered = 1; + gSpecialStatuses[gActiveBattler].statLowered = TRUE; } } return STAT_CHANGE_DIDNT_WORK; @@ -9293,7 +9293,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr else { // Check eject pack. disableEjectPack set for edge cases (e.g. attacking weak armor'd eject pack holder with u-turn) - if (gProtectStructs[gActiveBattler].disableEjectPack == 0) + if (!gProtectStructs[gActiveBattler].disableEjectPack) gSpecialStatuses[gActiveBattler].statFell = TRUE; gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); // B_MSG_ATTACKER_STAT_FELL or B_MSG_DEFENDER_STAT_FELL } @@ -9787,12 +9787,12 @@ static void Cmd_tryKO(void) if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < GetBattlerHoldEffectParam(gBattlerTarget)) { - gSpecialStatuses[gBattlerTarget].focusBanded = 1; + gSpecialStatuses[gBattlerTarget].focusBanded = TRUE; RecordItemEffectBattle(gBattlerTarget, holdEffect); } else if (holdEffect == HOLD_EFFECT_FOCUS_SASH && BATTLER_MAX_HP(gBattlerTarget)) { - gSpecialStatuses[gBattlerTarget].focusSashed = 1; + gSpecialStatuses[gBattlerTarget].focusSashed = TRUE; RecordItemEffectBattle(gBattlerTarget, holdEffect); } @@ -10206,7 +10206,7 @@ static void Cmd_counterdamagecalculator(void) } else { - gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; + gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } } @@ -10231,7 +10231,7 @@ static void Cmd_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the phy } else { - gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; + gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } } @@ -10720,7 +10720,7 @@ static void Cmd_trysetspikes(void) if (gSideTimers[targetSide].spikesAmount == 3) { - gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; + gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } else @@ -11407,7 +11407,7 @@ static void Cmd_trysethelpinghand(void) && !gProtectStructs[gBattlerAttacker].helpingHand && !gProtectStructs[gBattlerTarget].helpingHand) { - gProtectStructs[gBattlerTarget].helpingHand = 1; + gProtectStructs[gBattlerTarget].helpingHand = TRUE; gBattlescriptCurrInstr += 5; } else @@ -11827,28 +11827,28 @@ static void Cmd_assistattackselect(void) static void Cmd_trysetmagiccoat(void) { gBattlerTarget = gBattlerAttacker; - gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; + gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } else { - gProtectStructs[gBattlerAttacker].bounceMove = 1; + gProtectStructs[gBattlerAttacker].bounceMove = TRUE; gBattlescriptCurrInstr += 5; } } static void Cmd_trysetsnatch(void) // snatch { - gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; + gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } else { - gProtectStructs[gBattlerAttacker].stealMove = 1; + gProtectStructs[gBattlerAttacker].stealMove = TRUE; gBattlescriptCurrInstr += 5; } } @@ -12835,7 +12835,7 @@ static void Cmd_metalburstdamagecalculator(void) } else { - gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = 1; + gSpecialStatuses[gBattlerAttacker].ppNotAffectedByPressure = TRUE; gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); } } diff --git a/src/battle_util.c b/src/battle_util.c index f0adfebb9..b012f7d49 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -255,7 +255,7 @@ void HandleAction_UseMove(void) // choose move if (gProtectStructs[gBattlerAttacker].noValidMoves) { - gProtectStructs[gBattlerAttacker].noValidMoves = 0; + gProtectStructs[gBattlerAttacker].noValidMoves = FALSE; gCurrentMove = gChosenMove = MOVE_STRUGGLE; gHitMarker |= HITMARKER_NO_PPDEDUCT; *(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0); @@ -386,9 +386,9 @@ void HandleAction_UseMove(void) gActiveBattler = gBattlerByTurnOrder[var]; RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); if (gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD) - gSpecialStatuses[gActiveBattler].lightningRodRedirected = 1; + gSpecialStatuses[gActiveBattler].lightningRodRedirected = TRUE; else if (gBattleMons[gActiveBattler].ability == ABILITY_STORM_DRAIN) - gSpecialStatuses[gActiveBattler].stormDrainRedirected = 1; + gSpecialStatuses[gActiveBattler].stormDrainRedirected = TRUE; gBattlerTarget = gActiveBattler; } } @@ -1594,7 +1594,7 @@ u8 TrySetCantSelectMoveBattleScript(void) if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMoveInPalace; - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1609,7 +1609,7 @@ u8 TrySetCantSelectMoveBattleScript(void) if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMoveInPalace; - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1624,7 +1624,7 @@ u8 TrySetCantSelectMoveBattleScript(void) if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTauntInPalace; - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1639,7 +1639,7 @@ u8 TrySetCantSelectMoveBattleScript(void) if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveThroatChopInPalace; - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1654,7 +1654,7 @@ u8 TrySetCantSelectMoveBattleScript(void) if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisonedMoveInPalace; - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1669,7 +1669,7 @@ u8 TrySetCantSelectMoveBattleScript(void) if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveGravityInPalace; - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1684,7 +1684,7 @@ u8 TrySetCantSelectMoveBattleScript(void) if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveHealBlockInPalace; - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1699,7 +1699,7 @@ u8 TrySetCantSelectMoveBattleScript(void) if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace; - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1715,7 +1715,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gLastUsedItem = gBattleMons[gActiveBattler].item; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1729,7 +1729,7 @@ u8 TrySetCantSelectMoveBattleScript(void) gLastUsedItem = gBattleMons[gActiveBattler].item; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1742,7 +1742,7 @@ u8 TrySetCantSelectMoveBattleScript(void) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = TRUE; } else { @@ -1801,12 +1801,12 @@ bool8 AreAllMovesUnusable(void) if (unusable == 0xF) // All moves are unusable. { - gProtectStructs[gActiveBattler].noValidMoves = 1; + gProtectStructs[gActiveBattler].noValidMoves = TRUE; gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft; } else { - gProtectStructs[gActiveBattler].noValidMoves = 0; + gProtectStructs[gActiveBattler].noValidMoves = FALSE; } return (unusable == 0xF); @@ -3194,7 +3194,7 @@ u8 AtkCanceller_UnableToUseMove(void) case CANCELLER_FLINCH: // flinch if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FLINCHED) { - gProtectStructs[gBattlerAttacker].flinchImmobility = 1; + gProtectStructs[gBattlerAttacker].flinchImmobility = TRUE; CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; @@ -3205,7 +3205,7 @@ u8 AtkCanceller_UnableToUseMove(void) case CANCELLER_DISABLED: // disabled move if (gDisableStructs[gBattlerAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattlerAttacker].disabledMove != 0) { - gProtectStructs[gBattlerAttacker].usedDisabledMove = 1; + gProtectStructs[gBattlerAttacker].usedDisabledMove = TRUE; gBattleScripting.battler = gBattlerAttacker; CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled; @@ -3217,7 +3217,7 @@ u8 AtkCanceller_UnableToUseMove(void) case CANCELLER_HEAL_BLOCKED: if (gStatuses3[gBattlerAttacker] & STATUS3_HEAL_BLOCK && IsHealBlockPreventingMove(gBattlerAttacker, gCurrentMove)) { - gProtectStructs[gBattlerAttacker].usedHealBlockedMove = 1; + gProtectStructs[gBattlerAttacker].usedHealBlockedMove = TRUE; gBattleScripting.battler = gBattlerAttacker; CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedHealBlockPrevents; @@ -3229,7 +3229,7 @@ u8 AtkCanceller_UnableToUseMove(void) case CANCELLER_GRAVITY: if (gFieldStatuses & STATUS_FIELD_GRAVITY && IsGravityPreventingMove(gCurrentMove)) { - gProtectStructs[gBattlerAttacker].usedGravityPreventedMove = 1; + gProtectStructs[gBattlerAttacker].usedGravityPreventedMove = TRUE; gBattleScripting.battler = gBattlerAttacker; CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedGravityPrevents; @@ -3241,7 +3241,7 @@ u8 AtkCanceller_UnableToUseMove(void) case CANCELLER_TAUNTED: // taunt if (gDisableStructs[gBattlerAttacker].tauntTimer && gBattleMoves[gCurrentMove].power == 0) { - gProtectStructs[gBattlerAttacker].usedTauntedMove = 1; + gProtectStructs[gBattlerAttacker].usedTauntedMove = TRUE; CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; @@ -3252,7 +3252,7 @@ u8 AtkCanceller_UnableToUseMove(void) case CANCELLER_IMPRISONED: // imprisoned if (GetImprisonedMovesCount(gBattlerAttacker, gCurrentMove)) { - gProtectStructs[gBattlerAttacker].usedImprisonedMove = 1; + gProtectStructs[gBattlerAttacker].usedImprisonedMove = TRUE; CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; @@ -3271,7 +3271,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleCommunication[MULTISTRING_CHOOSER] = TRUE; gBattlerTarget = gBattlerAttacker; gBattleMoveDamage = CalculateMoveDamage(MOVE_NONE, gBattlerAttacker, gBattlerAttacker, TYPE_MYSTERY, 40, FALSE, FALSE, TRUE); - gProtectStructs[gBattlerAttacker].confusionSelfDmg = 1; + gProtectStructs[gBattlerAttacker].confusionSelfDmg = TRUE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; } else @@ -3293,7 +3293,7 @@ u8 AtkCanceller_UnableToUseMove(void) case CANCELLER_PARALYSED: // paralysis if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) { - gProtectStructs[gBattlerAttacker].prlzImmobility = 1; + gProtectStructs[gBattlerAttacker].prlzImmobility = TRUE; // This is removed in Emerald for some reason //CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; @@ -3314,7 +3314,7 @@ u8 AtkCanceller_UnableToUseMove(void) { BattleScriptPush(BattleScript_MoveUsedIsInLoveCantAttack); gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; - gProtectStructs[gBattlerAttacker].loveImmobility = 1; + gProtectStructs[gBattlerAttacker].loveImmobility = TRUE; CancelMultiTurnMoves(gBattlerAttacker); } gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove; @@ -3393,7 +3393,7 @@ u8 AtkCanceller_UnableToUseMove(void) GET_MOVE_TYPE(gCurrentMove, moveType); if (moveType == TYPE_FIRE) { - gProtectStructs[gBattlerAttacker].powderSelfDmg = 1; + gProtectStructs[gBattlerAttacker].powderSelfDmg = TRUE; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; gBattlescriptCurrInstr = BattleScript_MoveUsedPowder; effect = 1; @@ -3404,7 +3404,7 @@ u8 AtkCanceller_UnableToUseMove(void) case CANCELLER_THROAT_CHOP: if (gDisableStructs[gBattlerAttacker].throatChopTimer && gBattleMoves[gCurrentMove].flags & FLAG_SOUND) { - gProtectStructs[gBattlerAttacker].usedThroatChopPreventedMove = 1; + gProtectStructs[gBattlerAttacker].usedThroatChopPreventedMove = TRUE; CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsThroatChopPrevented; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; @@ -3926,7 +3926,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_MOLDBREAKER; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -3935,7 +3935,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TERAVOLT; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -3944,7 +3944,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_TURBOBLAZE; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -3954,7 +3954,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move { gDisableStructs[battler].slowStartTimer = 5; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SLOWSTART; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -3963,7 +3963,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_UNNERVE; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -3973,7 +3973,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ASONE; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_ActivateAsOne); effect++; } @@ -3985,7 +3985,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move u32 i; gEffectBattler = BATTLE_PARTNER(battler); gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_CURIOUS_MEDICINE; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -4015,7 +4015,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (effect) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_ANTICIPATION; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); } } @@ -4023,7 +4023,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_FRISK: if (!gSpecialStatuses[battler].switchInAbilityDone) { - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_FriskActivates); // Try activate effect++; } @@ -4033,7 +4033,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move { ForewarnChooseMove(battler); gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FOREWARN; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -4063,7 +4063,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move else statId = STAT_SPATK; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; if (CompareStat(battler, statId, MAX_STAT_STAGE, CMP_LESS_THAN)) { @@ -4080,7 +4080,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_PRESSURE; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -4089,7 +4089,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_DARKAURA; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -4098,7 +4098,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_FAIRYAURA; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -4107,7 +4107,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_AURABREAK; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -4116,7 +4116,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_COMATOSE; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -4125,7 +4125,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!gSpecialStatuses[battler].switchInAbilityDone && TryRemoveScreens(battler)) { gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_SWITCHIN_SCREENCLEANER; - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_SwitchInAbilityMsg); effect++; } @@ -4190,7 +4190,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!(gSpecialStatuses[battler].intimidatedMon)) { gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_INTIMIDATED; - gSpecialStatuses[battler].intimidatedMon = 1; + gSpecialStatuses[battler].intimidatedMon = TRUE; } break; case ABILITY_FORECAST: @@ -4206,14 +4206,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!(gSpecialStatuses[battler].traced)) { gBattleResources->flags->flags[battler] |= RESOURCE_FLAG_TRACED; - gSpecialStatuses[battler].traced = 1; + gSpecialStatuses[battler].traced = TRUE; } break; case ABILITY_CLOUD_NINE: case ABILITY_AIR_LOCK: if (!gSpecialStatuses[battler].switchInAbilityDone) { - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; BattleScriptPushCursorAndCallback(BattleScript_AnnounceAirLockCloudNine); effect++; } @@ -4231,7 +4231,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_INTREPID_SWORD: if (!gSpecialStatuses[battler].switchInAbilityDone) { - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; SET_STATCHANGER(STAT_ATK, 1, FALSE); BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn); effect++; @@ -4240,7 +4240,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_DAUNTLESS_SHIELD: if (!gSpecialStatuses[battler].switchInAbilityDone) { - gSpecialStatuses[battler].switchInAbilityDone = 1; + gSpecialStatuses[battler].switchInAbilityDone = TRUE; SET_STATCHANGER(STAT_DEF, 1, FALSE); BattleScriptPushCursorAndCallback(BattleScript_BattlerAbilityStatRaiseOnSwitchIn); effect++; @@ -4659,7 +4659,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move || CompareStat(battler, STAT_DEF, MIN_STAT_STAGE, CMP_GREATER_THAN))) // Don't activate if defense cannot be lowered { if (gBattleMoves[gCurrentMove].effect == EFFECT_HIT_ESCAPE && CanBattlerSwitch(gBattlerAttacker)) - gProtectStructs[battler].disableEjectPack = 1; // Set flag for target + gProtectStructs[battler].disableEjectPack = TRUE; // Set flag for target BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_WeakArmorActivates; @@ -5015,7 +5015,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move && gBattlerAttacker != battler) { // Set bit and save Dancer mon's original target - gSpecialStatuses[battler].dancerUsedMove = 1; + gSpecialStatuses[battler].dancerUsedMove = TRUE; gSpecialStatuses[battler].dancerOriginalTarget = *(gBattleStruct->moveTarget + battler) | 0x4; gBattleStruct->atkCancellerTracker = 0; gBattlerAttacker = gBattlerAbility = battler; @@ -6016,7 +6016,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) if (effect) { - gSpecialStatuses[battlerId].switchInItemDone = 1; + gSpecialStatuses[battlerId].switchInItemDone = TRUE; gActiveBattler = gBattlerAttacker = gPotentialItemEffectBattler = gBattleScripting.battler = battlerId; switch (effect) { @@ -6852,7 +6852,7 @@ u8 GetMoveTarget(u16 move, u8 setTarget) { targetBattler ^= BIT_FLANK; RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability); - gSpecialStatuses[targetBattler].lightningRodRedirected = 1; + gSpecialStatuses[targetBattler].lightningRodRedirected = TRUE; } else if (gBattleMoves[move].type == TYPE_WATER && IsAbilityOnOpposingSide(gBattlerAttacker, ABILITY_STORM_DRAIN) @@ -6860,7 +6860,7 @@ u8 GetMoveTarget(u16 move, u8 setTarget) { targetBattler ^= BIT_FLANK; RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability); - gSpecialStatuses[targetBattler].stormDrainRedirected = 1; + gSpecialStatuses[targetBattler].stormDrainRedirected = TRUE; } } break; @@ -7387,7 +7387,7 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) basePower *= 2; break; case EFFECT_ASSURANCE: - if (gProtectStructs[battlerDef].physicalDmg != 0 || gProtectStructs[battlerDef].specialDmg != 0 || gProtectStructs[battlerDef].confusionSelfDmg != 0) + if (gProtectStructs[battlerDef].physicalDmg != 0 || gProtectStructs[battlerDef].specialDmg != 0 || gProtectStructs[battlerDef].confusionSelfDmg) basePower *= 2; break; case EFFECT_TRUMP_CARD: @@ -8236,7 +8236,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move else MulModifier(&finalModifier, UQ_4_12(0.5)); if (updateFlags) - gSpecialStatuses[battlerDef].berryReduced = 1; + gSpecialStatuses[battlerDef].berryReduced = TRUE; } break; } From 075c0299a13fa1b012614eadefebd9f991f83e74 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Wed, 22 Sep 2021 23:29:26 -0300 Subject: [PATCH 2/7] Better names for Micle and Custap flags --- include/battle.h | 4 ++-- src/battle_main.c | 12 ++++++------ src/battle_script_commands.c | 4 ++-- src/battle_util.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/battle.h b/include/battle.h index 36646c9fe..200b1112d 100644 --- a/include/battle.h +++ b/include/battle.h @@ -142,8 +142,8 @@ struct ProtectStruct u32 usedGravityPreventedMove:1; u32 powderSelfDmg:1; u32 usedThroatChopPreventedMove:1; - u32 micle:1; - u32 custap:1; // also quick claw + u32 usedMicleBerry:1; + u32 usedCustapBerry:1; // also quick claw u32 touchedProtectLike:1; u32 disableEjectPack:1; u32 physicalDmg; diff --git a/src/battle_main.c b/src/battle_main.c index 1b4ad5f74..cc9fff1d3 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4360,7 +4360,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) || (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE) && holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item))) - gProtectStructs[battler1].custap = TRUE; + gProtectStructs[battler1].usedCustapBerry = TRUE; speedBattler2 = GetBattlerTotalSpeedStat(battler2); holdEffectBattler2 = GetBattlerHoldEffect(battler2, TRUE); @@ -4368,7 +4368,7 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) || (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE) && holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item))) - gProtectStructs[battler2].custap = TRUE; + gProtectStructs[battler2].usedCustapBerry = TRUE; if (!ignoreChosenMoves) { @@ -4384,9 +4384,9 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) // LAGGING TAIL - always last // STALL - always last - if (gProtectStructs[battler1].custap && !gProtectStructs[battler2].custap) + if (gProtectStructs[battler1].usedCustapBerry && !gProtectStructs[battler2].usedCustapBerry) strikesFirst = 0; - else if (gProtectStructs[battler2].custap && !gProtectStructs[battler1].custap) + else if (gProtectStructs[battler2].usedCustapBerry && !gProtectStructs[battler1].usedCustapBerry) strikesFirst = 1; else if (holdEffectBattler1 == HOLD_EFFECT_LAGGING_TAIL && holdEffectBattler2 != HOLD_EFFECT_LAGGING_TAIL) strikesFirst = 1; @@ -4639,12 +4639,12 @@ static void CheckQuickClaw_CustapBerryActivation(void) gBattleStruct->quickClawBattlerId++; if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE && gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here - && gProtectStructs[gActiveBattler].custap + && gProtectStructs[gActiveBattler].usedCustapBerry && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) && !(gDisableStructs[gBattlerAttacker].truantCounter) && !(gProtectStructs[gActiveBattler].noValidMoves)) { - gProtectStructs[gActiveBattler].custap = FALSE; + gProtectStructs[gActiveBattler].usedCustapBerry = FALSE; gLastUsedItem = gBattleMons[gActiveBattler].item; if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9a107fac0..b03da17c3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1638,9 +1638,9 @@ u32 GetTotalAccuracy(u32 battlerAtk, u32 battlerDef, u32 move) else if (atkHoldEffect == HOLD_EFFECT_ZOOM_LENS && GetBattlerTurnOrderNum(battlerAtk) > GetBattlerTurnOrderNum(battlerDef)); calc = (calc * (100 + atkParam)) / 100; - if (gProtectStructs[battlerAtk].micle) + if (gProtectStructs[battlerAtk].usedMicleBerry) { - gProtectStructs[battlerAtk].micle = FALSE; + gProtectStructs[battlerAtk].usedMicleBerry = FALSE; if (atkAbility == ABILITY_RIPEN) calc = (calc * 140) / 100; // ripen gives 40% acc boost else diff --git a/src/battle_util.c b/src/battle_util.c index b012f7d49..c9ecfd3d8 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5616,7 +5616,7 @@ static u8 TrySetMicleBerry(u32 battlerId, u32 itemId, bool32 end2) { if (HasEnoughHpToEatBerry(battlerId, 4, itemId)) { - gProtectStructs[battlerId].micle = TRUE; // battler's next attack has increased accuracy + gProtectStructs[battlerId].usedMicleBerry = TRUE; // battler's next attack has increased accuracy if (end2) { From 996301d5d33072407fe9143811d27eb31e07e201 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 12 Oct 2021 18:04:34 -0400 Subject: [PATCH 3/7] add mirror armor --- asm/macros/battle_script.inc | 4 ++ data/battle_scripts_1.s | 36 +++++++++++++++ include/battle_scripts.h | 2 + include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 51 +++++++++++++++++----- src/battle_util.c | 7 +-- 6 files changed, 86 insertions(+), 15 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 4d8fe0365..f00e580f0 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1824,6 +1824,10 @@ .macro trytoclearprimalweather various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER .endm + + .macro getrandommirrorarmortarget + various BS_TARGET, VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET + .endm @ helpful macros .macro setstatchanger stat:req, stages:req, down:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e1fb47930..5979f4c67 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2645,6 +2645,33 @@ BattleScript_StatDownPrintString:: BattleScript_StatDownEnd:: goto BattleScript_MoveEnd +BattleScript_MirrorArmorReflect:: + pause B_WAIT_TIME_SHORT + call BattleScript_AbilityPopUp + jumpifsubstituteblocks BattleScript_AbilityNoSpecificStatLoss +BattleScript_MirrorArmorReflectStatLoss: + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_MirrorArmorReflectWontFall + jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_MirrorArmorReflectAnim + goto BattleScript_MirrorArmorReflectWontFall +BattleScript_MirrorArmorReflectAnim: + setgraphicalstatchangevalues + playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 +BattleScript_MirrorArmorReflectPrintString: + printfromtable gStatDownStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_MirrorArmorReflectEnd: + return + +BattleScript_MirrorArmorReflectWontFall: + copybyte gBattlerTarget, gBattlerAttacker @ STRINGID_STATSWONTDECREASE uses target + goto BattleScript_MirrorArmorReflectPrintString + +BattleScript_MirrorArmorReflectStickyWeb: + call BattleScript_AbilityPopUp + getrandommirrorarmortarget + jumpifbyteequal gBattlerTarget, gBattlerAttacker, BattleScript_AbilityNoSpecificStatLossPrint + goto BattleScript_MirrorArmorReflectStatLoss + BattleScript_StatDown:: playanimation BS_EFFECT_BATTLER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 printfromtable gStatDownStringIds @@ -6099,6 +6126,7 @@ BattleScript_StickyWebOnSwitchIn:: copybyte gBattlerTarget, sBATTLER printstring STRINGID_STICKYWEBSWITCHIN waitmessage B_WAIT_TIME_LONG + jumpifability BS_TARGET, ABILITY_MIRROR_ARMOR, BattleScript_MirrorArmorReflectStickyWeb statbuffchange STAT_BUFF_ALLOW_PTR, BattleScript_StickyWebOnSwitchInEnd jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_StickyWebOnSwitchInStatAnim jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY, BattleScript_StickyWebOnSwitchInEnd @@ -7639,6 +7667,7 @@ BattleScript_GrassyTerrainHealEnd: BattleScript_AbilityNoSpecificStatLoss:: pause B_WAIT_TIME_SHORT call BattleScript_AbilityPopUp +BattleScript_AbilityNoSpecificStatLossPrint: printstring STRINGID_PKMNSXPREVENTSYLOSS waitmessage B_WAIT_TIME_LONG setbyte cMULTISTRING_CHOOSER, B_MSG_STAT_FELL_EMPTY @@ -7885,6 +7914,13 @@ BattleScript_CuteCharmActivates:: call BattleScript_TryDestinyKnotTarget return +BattleScript_GooeyActivates:: + waitstate + call BattleScript_AbilityPopUp + swapattackerwithtarget @ for defiant, mirror armor + seteffectsecondary + return + BattleScript_AbilityStatusEffect:: waitstate call BattleScript_AbilityPopUp diff --git a/include/battle_scripts.h b/include/battle_scripts.h index cd4600543..4e5568c75 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -398,5 +398,7 @@ extern const u8 BattleScript_MysteriousAirCurrentBlowsOn[]; extern const u8 BattleScript_AttackWeakenedByStrongWinds[]; extern const u8 BattleScript_BlockedByPrimalWeatherEnd3[]; extern const u8 BattleScript_BlockedByPrimalWeatherRet[]; +extern const u8 BattleScript_MirrorArmorReflect[]; +extern const u8 BattleScript_GooeyActivates[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index d61eabbf8..bbf5714e9 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -185,6 +185,7 @@ #define VARIOUS_REMOVE_TERRAIN 113 #define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 #define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 +#define VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET 116 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df..9c0b4ec37 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2582,6 +2582,8 @@ void SetMoveEffect(bool32 primary, u32 certain) { s32 i, byTwo, affectsUser = 0; bool32 statusChanged = FALSE; + bool32 mirrorArmorReflected = (GetBattlerAbility(gBattlerTarget) == ABILITY_MIRROR_ARMOR); + u32 flags; switch (gBattleScripting.moveEffect) // Set move effects which happen later on { @@ -3012,11 +3014,18 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_SP_DEF_MINUS_1: case MOVE_EFFECT_ACC_MINUS_1: case MOVE_EFFECT_EVS_MINUS_1: - if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE, - gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_1 + 1, - affectsUser, 0)) + flags = affectsUser | certain; + if (mirrorArmorReflected && !affectsUser) { - gBattlescriptCurrInstr++; + flags |= STAT_BUFF_ALLOW_PTR; + } + + if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE, + gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_1 + 1, + flags, gBattlescriptCurrInstr + 1)) + { + if (!mirrorArmorReflected) + gBattlescriptCurrInstr++; } else { @@ -8822,6 +8831,25 @@ static void Cmd_various(void) } break; } + case VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET: + i = BATTLE_OPPOSITE(gActiveBattler); + gBattlerAttacker = gBattlerTarget; + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) + { + if (IsBattlerAlive(i) + && !(gBattleMons[i].status2 & STATUS2_SUBSTITUTE)) + gBattlerAttacker = i; + else if (IsBattlerAlive(BATTLE_PARTNER(i)) + && !(gBattleMons[BATTLE_PARTNER(i)].status2 & STATUS2_SUBSTITUTE)) + gBattlerAttacker = BATTLE_PARTNER(i); + } + else + { + if (IsBattlerAlive(i) && !(gBattleMons[i].status2 & STATUS2_SUBSTITUTE)) + gBattlerAttacker = i; + } + SET_STATCHANGER(STAT_SPEED, 1, TRUE); + break; } gBattlescriptCurrInstr += 3; @@ -9355,8 +9383,9 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr bool32 certain = FALSE; bool32 notProtectAffected = FALSE; u32 index; + bool32 affectsUser = flags & MOVE_EFFECT_AFFECTS_USER; - if (flags & MOVE_EFFECT_AFFECTS_USER) + if (affectsUser) gActiveBattler = gBattlerAttacker; else gActiveBattler = gBattlerTarget; @@ -9457,8 +9486,9 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr } return STAT_CHANGE_DIDNT_WORK; } - else if (GetBattlerAbility(gActiveBattler) == ABILITY_KEEN_EYE - && !certain && statId == STAT_ACC) + else if (!certain + && ((GetBattlerAbility(gActiveBattler) == ABILITY_KEEN_EYE && statId == STAT_ACC) + || (GetBattlerAbility(gActiveBattler) == ABILITY_HYPER_CUTTER && statId == STAT_ATK))) { if (flags == STAT_BUFF_ALLOW_PTR) { @@ -9471,17 +9501,14 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr } return STAT_CHANGE_DIDNT_WORK; } - else if (GetBattlerAbility(gActiveBattler) == ABILITY_HYPER_CUTTER - && !certain && statId == STAT_ATK) + else if (GetBattlerAbility(gActiveBattler) == ABILITY_MIRROR_ARMOR && !affectsUser && gBattlerAttacker != gBattlerTarget && gActiveBattler == gBattlerTarget) { if (flags == STAT_BUFF_ALLOW_PTR) { BattleScriptPush(BS_ptr); gBattleScripting.battler = gActiveBattler; gBattlerAbility = gActiveBattler; - gBattlescriptCurrInstr = BattleScript_AbilityNoSpecificStatLoss; - gLastUsedAbility = GetBattlerAbility(gActiveBattler); - RecordAbilityBattle(gActiveBattler, gLastUsedAbility); + gBattlescriptCurrInstr = BattleScript_MirrorArmorReflect; } return STAT_CHANGE_DIDNT_WORK; } diff --git a/src/battle_util.c b/src/battle_util.c index 68e787698..37cc17644 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4835,15 +4835,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move case ABILITY_TANGLING_HAIR: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBattlerAttacker].hp != 0 - && CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) + && (CompareStat(gBattlerAttacker, STAT_SPEED, MIN_STAT_STAGE, CMP_GREATER_THAN) || GetBattlerAbility(gBattlerAttacker) == ABILITY_MIRROR_ARMOR) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED && IsMoveMakingContact(move, gBattlerAttacker)) { - gBattleScripting.moveEffect = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_SPD_MINUS_1; + SET_STATCHANGER(STAT_SPEED, 1, TRUE); + gBattleScripting.moveEffect = MOVE_EFFECT_SPD_MINUS_1; PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility); BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_AbilityStatusEffect; + gBattlescriptCurrInstr = BattleScript_GooeyActivates; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; effect++; } From f9272a89fa3fade69f26a37462cc2fe93e9abc15 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 12 Oct 2021 21:09:27 -0400 Subject: [PATCH 4/7] add mirror armor check to two-stage stat decrease effects --- src/battle_script_commands.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9c0b4ec37..253f87c1c 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3016,9 +3016,7 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_EVS_MINUS_1: flags = affectsUser | certain; if (mirrorArmorReflected && !affectsUser) - { flags |= STAT_BUFF_ALLOW_PTR; - } if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(1) | STAT_BUFF_NEGATIVE, gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_1 + 1, @@ -3063,11 +3061,15 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_SP_DEF_MINUS_2: case MOVE_EFFECT_ACC_MINUS_2: case MOVE_EFFECT_EVS_MINUS_2: + flags = affectsUser | certain; + if (mirrorArmorReflected && !affectsUser) + flags |= STAT_BUFF_ALLOW_PTR; if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE, gBattleScripting.moveEffect - MOVE_EFFECT_ATK_MINUS_2 + 1, - affectsUser, 0)) + flags, gBattlescriptCurrInstr + 1)) { - gBattlescriptCurrInstr++; + if (!mirrorArmorReflected) + gBattlescriptCurrInstr++; } else { From 592a1dab63d3b8eb97679cbdc9161ade8f762d90 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 2 Nov 2021 12:02:58 -0400 Subject: [PATCH 5/7] fix mirror armor setstatchanger, handle reflected stat blockage --- data/battle_scripts_1.s | 2 +- src/battle_script_commands.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b72140a11..eb80a41d5 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2894,7 +2894,7 @@ BattleScript_MirrorArmorReflect:: call BattleScript_AbilityPopUp jumpifsubstituteblocks BattleScript_AbilityNoSpecificStatLoss BattleScript_MirrorArmorReflectStatLoss: - statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_MirrorArmorReflectWontFall + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_NOT_PROTECT_AFFECTED | STAT_BUFF_ALLOW_PTR, BattleScript_MirrorArmorReflectEnd jumpifbyte CMP_LESS_THAN, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_DECREASE, BattleScript_MirrorArmorReflectAnim goto BattleScript_MirrorArmorReflectWontFall BattleScript_MirrorArmorReflectAnim: diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 28cab4af3..2ee80557f 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9689,10 +9689,12 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr { if (flags == STAT_BUFF_ALLOW_PTR) { + SET_STATCHANGER(statId, GET_STAT_BUFF_VALUE(statValue) | STAT_BUFF_NEGATIVE, TRUE); BattleScriptPush(BS_ptr); gBattleScripting.battler = gActiveBattler; gBattlerAbility = gActiveBattler; gBattlescriptCurrInstr = BattleScript_MirrorArmorReflect; + RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); } return STAT_CHANGE_DIDNT_WORK; } From 7e6e23005be4bbfbffda03be99c5db0c64ae892d Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 3 Nov 2021 13:59:26 -0400 Subject: [PATCH 6/7] fix clear body --- src/battle_script_commands.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2ee80557f..500b7cab0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -2586,7 +2586,7 @@ void SetMoveEffect(bool32 primary, u32 certain) s32 i, byTwo, affectsUser = 0; bool32 statusChanged = FALSE; bool32 mirrorArmorReflected = (GetBattlerAbility(gBattlerTarget) == ABILITY_MIRROR_ARMOR); - u32 flags; + u32 flags = 0; switch (gBattleScripting.moveEffect) // Set move effects which happen later on { @@ -3017,7 +3017,7 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_SP_DEF_MINUS_1: case MOVE_EFFECT_ACC_MINUS_1: case MOVE_EFFECT_EVS_MINUS_1: - flags = affectsUser | certain; + flags = affectsUser; if (mirrorArmorReflected && !affectsUser) flags |= STAT_BUFF_ALLOW_PTR; @@ -3064,7 +3064,7 @@ void SetMoveEffect(bool32 primary, u32 certain) case MOVE_EFFECT_SP_DEF_MINUS_2: case MOVE_EFFECT_ACC_MINUS_2: case MOVE_EFFECT_EVS_MINUS_2: - flags = affectsUser | certain; + flags = affectsUser; if (mirrorArmorReflected && !affectsUser) flags |= STAT_BUFF_ALLOW_PTR; if (ChangeStatBuffs(SET_STAT_BUFF_VALUE(2) | STAT_BUFF_NEGATIVE, @@ -9567,7 +9567,7 @@ static u32 ChangeStatBuffs(s8 statValue, u32 statId, u32 flags, const u8 *BS_ptr bool32 certain = FALSE; bool32 notProtectAffected = FALSE; u32 index; - bool32 affectsUser = flags & MOVE_EFFECT_AFFECTS_USER; + bool32 affectsUser = (flags & MOVE_EFFECT_AFFECTS_USER); if (affectsUser) gActiveBattler = gBattlerAttacker; From 48c29a9cd823ea7d9b000c493ef52e925c467aba Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 3 Nov 2021 15:05:52 -0400 Subject: [PATCH 7/7] proper mirror armor sticky web targeting --- asm/macros/battle_script.inc | 4 ++-- data/battle_scripts_1.s | 5 +++-- include/battle.h | 1 + include/constants/battle_script_commands.h | 2 +- src/battle_main.c | 8 ++++++++ src/battle_script_commands.c | 24 +++++++--------------- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 6b2c248db..328780f53 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1839,8 +1839,8 @@ various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER .endm - .macro getrandommirrorarmortarget - various BS_TARGET, VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET + .macro setattackertostickywebuser + various BS_TARGET, VARIOUS_SET_ATTACKER_STICKY_WEB_USER .endm .macro getrototillertargets ptr:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index eb80a41d5..36ae4d967 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2910,10 +2910,11 @@ BattleScript_MirrorArmorReflectWontFall: copybyte gBattlerTarget, gBattlerAttacker @ STRINGID_STATSWONTDECREASE uses target goto BattleScript_MirrorArmorReflectPrintString +@ gBattlerTarget is battler with Mirror Armor BattleScript_MirrorArmorReflectStickyWeb: call BattleScript_AbilityPopUp - getrandommirrorarmortarget - jumpifbyteequal gBattlerTarget, gBattlerAttacker, BattleScript_AbilityNoSpecificStatLossPrint + setattackertostickywebuser + jumpifbyteequal gBattlerAttacker, gBattlerTarget, BattleScript_StickyWebOnSwitchInEnd @ Sticky web user not on field -> no stat loss goto BattleScript_MirrorArmorReflectStatLoss BattleScript_StatDown:: diff --git a/include/battle.h b/include/battle.h index 5e5aa2479..770d826a5 100644 --- a/include/battle.h +++ b/include/battle.h @@ -612,6 +612,7 @@ struct BattleStruct struct StolenItem itemStolen[PARTY_SIZE]; // Player's team that had items stolen (two bytes per party member) u8 blunderPolicy:1; // should blunder policy activate u8 ballSpriteIds[2]; // item gfx, window gfx + u8 stickyWebUser; }; #define GET_MOVE_TYPE(move, typeArg) \ diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 5034c4f56..3b4495208 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -197,7 +197,7 @@ #define VARIOUS_UPDATE_ABILITY_POPUP 124 #define VARIOUS_JUMP_IF_WEATHER_AFFECTED 125 #define VARIOUS_JUMP_IF_LEAF_GUARD_PROTECTED 126 -#define VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET 127 +#define VARIOUS_SET_ATTACKER_STICKY_WEB_USER 127 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_main.c b/src/battle_main.c index ad02854bd..f1adb1bfb 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2933,6 +2933,8 @@ static void BattleStartClearSetData(void) gBattleStruct->mega.triggerSpriteId = 0xFF; + gBattleStruct->stickyWebUser = 0xFF; + for (i = 0; i < PARTY_SIZE; i++) { gBattleStruct->usedHeldItems[i][0] = 0; @@ -3030,6 +3032,9 @@ void SwitchInClearSetData(void) gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0; gBattleStruct->lastMoveFailed &= ~(gBitTable[gActiveBattler]); gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]); + + if (gActiveBattler == gBattleStruct->stickyWebUser) + gBattleStruct->stickyWebUser = 0xFF; // Switched into sticky web user slot so reset it for (i = 0; i < gBattlersCount; i++) { @@ -3127,6 +3132,9 @@ void FaintClearSetData(void) gBattleStruct->lastTakenMoveFrom[gActiveBattler][3] = 0; gBattleStruct->palaceFlags &= ~(gBitTable[gActiveBattler]); + + if (gActiveBattler == gBattleStruct->stickyWebUser) + gBattleStruct->stickyWebUser = 0xFF; // User of sticky web fainted, so reset the stored battler ID for (i = 0; i < gBattlersCount; i++) { diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 500b7cab0..3d5786b35 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -9015,24 +9015,13 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; } return; - case VARIOUS_GET_RANDOM_MIRROR_ARMOR_TARGET: - i = BATTLE_OPPOSITE(gActiveBattler); - gBattlerAttacker = gBattlerTarget; - if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - { - if (IsBattlerAlive(i) - && !(gBattleMons[i].status2 & STATUS2_SUBSTITUTE)) - gBattlerAttacker = i; - else if (IsBattlerAlive(BATTLE_PARTNER(i)) - && !(gBattleMons[BATTLE_PARTNER(i)].status2 & STATUS2_SUBSTITUTE)) - gBattlerAttacker = BATTLE_PARTNER(i); - } - else - { - if (IsBattlerAlive(i) && !(gBattleMons[i].status2 & STATUS2_SUBSTITUTE)) - gBattlerAttacker = i; - } + case VARIOUS_SET_ATTACKER_STICKY_WEB_USER: + // For Mirror Armor: "If the Pokémon with this Ability is affected by Sticky Web, the effect is reflected back to the Pokémon which set it up. + // If Pokémon which set up Sticky Web is not on the field, no Pokémon have their Speed lowered." + gBattlerAttacker = gBattlerTarget; // Initialize 'fail' condition SET_STATCHANGER(STAT_SPEED, 1, TRUE); + if (gBattleStruct->stickyWebUser != 0xFF) + gBattlerAttacker = gBattleStruct->stickyWebUser; break; } @@ -11590,6 +11579,7 @@ static void Cmd_setstickyweb(void) { gSideStatuses[targetSide] |= SIDE_STATUS_STICKY_WEB; gSideTimers[targetSide].stickyWebAmount = 1; + gBattleStruct->stickyWebUser = gBattlerAttacker; // For Mirror Armor gBattlescriptCurrInstr += 5; } }