From c9d3b26ff7de11b39ceeb0c713cb7b821f2b03d3 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 2 Apr 2021 02:12:46 -0400 Subject: [PATCH] Label miss string indexes --- data/battle_scripts_1.s | 12 +++++----- include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 7 ++++++ src/battle_message.c | 8 ++++--- src/battle_script_commands.c | 28 +++++++++++----------- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index ad9576a62..99b9be8dc 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2113,7 +2113,7 @@ BattleScript_EffectStockpile:: BattleScript_EffectSpitUp:: attackcanceler - jumpifbyte CMP_EQUAL, gBattleCommunication + 6, 0x1, BattleScript_82D9FA2 + jumpifbyte CMP_EQUAL, cMISS_TYPE, B_MSG_PROTECTED, BattleScript_SpitUpFailProtect attackstring ppreduce accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE @@ -2127,7 +2127,7 @@ BattleScript_SpitUpFail:: waitmessage 0x40 goto BattleScript_MoveEnd -BattleScript_82D9FA2:: +BattleScript_SpitUpFailProtect:: attackstring ppreduce pause 0x40 @@ -2223,7 +2223,7 @@ BattleScript_AlreadyBurned:: BattleScript_EffectMemento:: attackcanceler - jumpifbyte CMP_EQUAL, gBattleCommunication + 6, 0x1, BattleScript_82DA153 + jumpifbyte CMP_EQUAL, cMISS_TYPE, B_MSG_PROTECTED, BattleScript_MementoFailProtect attackstring ppreduce jumpifattackandspecialattackcannotfall BattleScript_ButItFailed @@ -2253,11 +2253,11 @@ BattleScript_EffectMementoPrintNoEffect: printstring STRINGID_BUTNOEFFECT waitmessage 0x40 goto BattleScript_EffectMementoTryFaint -BattleScript_82DA153: +BattleScript_MementoFailProtect: attackstring ppreduce - jumpifattackandspecialattackcannotfall BattleScript_82DA15A -BattleScript_82DA15A: + jumpifattackandspecialattackcannotfall BattleScript_MementoFailEnd +BattleScript_MementoFailEnd: setatkhptozero pause 0x40 effectivenesssound diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 9372377c4..cef0b184d 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -32,6 +32,7 @@ #define cEFFECT_CHOOSER gBattleCommunication + 3 #define cMULTISTRING_CHOOSER gBattleCommunication + 5 +#define cMISS_TYPE gBattleCommunication + 6 // Battle Script defines for getting the wanted battler #define BS_TARGET 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 1886043f1..f5b036b5d 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -383,4 +383,11 @@ #define STRINGID_TRAINER1WINTEXT 379 #define STRINGID_TRAINER2WINTEXT 380 +// Indexes into gMissStringIds +#define B_MSG_MISSED 0 +#define B_MSG_PROTECTED 1 +#define B_MSG_AVOIDED_ATK 2 +#define B_MSG_AVOIDED_DMG 3 +#define B_MSG_GROUND_MISS 4 + #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_message.c b/src/battle_message.c index 46444a8fa..5f088dded 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -893,9 +893,11 @@ const u8 * const gBattleStringsTable[BATTLESTRINGS_COUNT] = const u16 gMissStringIds[] = { - STRINGID_ATTACKMISSED, STRINGID_PKMNPROTECTEDITSELF, - STRINGID_PKMNAVOIDEDATTACK, STRINGID_AVOIDEDDAMAGE, - STRINGID_PKMNMAKESGROUNDMISS + [B_MSG_MISSED] = STRINGID_ATTACKMISSED, + [B_MSG_PROTECTED] = STRINGID_PKMNPROTECTEDITSELF, + [B_MSG_AVOIDED_ATK] = STRINGID_PKMNAVOIDEDATTACK, + [B_MSG_AVOIDED_DMG] = STRINGID_AVOIDEDDAMAGE, + [B_MSG_GROUND_MISS] = STRINGID_PKMNMAKESGROUNDMISS }; const u16 gNoEscapeStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 84f8efaa8..e0a3693eb 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -991,7 +991,7 @@ static void Cmd_attackcanceler(void) gMoveResultFlags |= MOVE_RESULT_MISSED; gLastLandedMoves[gBattlerTarget] = 0; gLastHitByType[gBattlerTarget] = 0; - gBattleCommunication[6] = 1; + gBattleCommunication[6] = B_MSG_PROTECTED; gBattlescriptCurrInstr++; } else @@ -1024,7 +1024,7 @@ static void Cmd_jumpifaffectedbyprotect(void) { gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(5, 0); - gBattleCommunication[6] = 1; + gBattleCommunication[6] = B_MSG_PROTECTED; } else { @@ -1039,7 +1039,7 @@ bool8 JumpIfMoveAffectedByProtect(u16 move) { gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); - gBattleCommunication[6] = 1; + gBattleCommunication[6] = B_MSG_PROTECTED; affected = TRUE; } return affected; @@ -1172,9 +1172,9 @@ static void Cmd_accuracycheck(void) gMoveResultFlags |= MOVE_RESULT_MISSED; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && (gBattleMoves[move].target == MOVE_TARGET_BOTH || gBattleMoves[move].target == MOVE_TARGET_FOES_AND_ALLY)) - gBattleCommunication[6] = 2; + gBattleCommunication[6] = B_MSG_AVOIDED_ATK; else - gBattleCommunication[6] = 0; + gBattleCommunication[6] = B_MSG_MISSED; CheckWonderGuardAndLevitate(); } @@ -1370,7 +1370,7 @@ static void Cmd_typecalc(void) gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); gLastLandedMoves[gBattlerTarget] = 0; gLastHitByType[gBattlerTarget] = 0; - gBattleCommunication[6] = moveType; + gBattleCommunication[6] = B_MSG_GROUND_MISS; RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } else @@ -1406,7 +1406,7 @@ static void Cmd_typecalc(void) gMoveResultFlags |= MOVE_RESULT_MISSED; gLastLandedMoves[gBattlerTarget] = 0; gLastHitByType[gBattlerTarget] = 0; - gBattleCommunication[6] = 3; + gBattleCommunication[6] = B_MSG_AVOIDED_DMG; RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) @@ -1429,7 +1429,7 @@ static void CheckWonderGuardAndLevitate(void) if (gBattleMons[gBattlerTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { gLastUsedAbility = ABILITY_LEVITATE; - gBattleCommunication[6] = moveType; + gBattleCommunication[6] = B_MSG_GROUND_MISS; RecordAbilityBattle(gBattlerTarget, ABILITY_LEVITATE); return; } @@ -1484,7 +1484,7 @@ static void CheckWonderGuardAndLevitate(void) if (((flags & 2) || !(flags & 1)) && gBattleMoves[gCurrentMove].power) { gLastUsedAbility = ABILITY_WONDER_GUARD; - gBattleCommunication[6] = 3; + gBattleCommunication[6] = B_MSG_AVOIDED_DMG; RecordAbilityBattle(gBattlerTarget, ABILITY_WONDER_GUARD); } } @@ -2019,7 +2019,7 @@ static void Cmd_resultmessage(void) if (gBattleControllerExecFlags) return; - if (gMoveResultFlags & MOVE_RESULT_MISSED && (!(gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) || gBattleCommunication[6] > 2)) + if (gMoveResultFlags & MOVE_RESULT_MISSED && (!(gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) || gBattleCommunication[6] > B_MSG_AVOIDED_ATK)) { stringId = gMissStringIds[gBattleCommunication[6]]; gBattleCommunication[MSG_DISPLAY] = 1; @@ -4459,7 +4459,7 @@ static void Cmd_typecalc2(void) gLastUsedAbility = gBattleMons[gBattlerTarget].ability; gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); gLastLandedMoves[gBattlerTarget] = 0; - gBattleCommunication[6] = moveType; + gBattleCommunication[6] = B_MSG_GROUND_MISS; RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } else @@ -4534,7 +4534,7 @@ static void Cmd_typecalc2(void) gLastUsedAbility = ABILITY_WONDER_GUARD; gMoveResultFlags |= MOVE_RESULT_MISSED; gLastLandedMoves[gBattlerTarget] = 0; - gBattleCommunication[6] = 3; + gBattleCommunication[6] = B_MSG_AVOIDED_DMG; RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) @@ -6802,7 +6802,7 @@ static void Cmd_stockpiletobasedamage(void) } else { - if (gBattleCommunication[6] != 1) + if (gBattleCommunication[6] != B_MSG_PROTECTED) { gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)], 0, @@ -8928,7 +8928,7 @@ static void Cmd_jumpifattackandspecialattackcannotfall(void) // memento { if (gBattleMons[gBattlerTarget].statStages[STAT_ATK] == MIN_STAT_STAGE && gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == MIN_STAT_STAGE - && gBattleCommunication[6] != 1) + && gBattleCommunication[6] != B_MSG_PROTECTED) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); }