From f4d8a91ba44d7bcf0f9df8db7ca5f7aeb688497f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Sat, 3 Apr 2021 12:38:07 -0400 Subject: [PATCH] Misc battle script cleanup --- asm/macros/battle_script.inc | 2 +- data/battle_scripts_1.s | 216 +++++++++++---------- data/battle_scripts_2.s | 17 +- include/battle_controllers.h | 4 +- include/constants/battle_script_commands.h | 48 ++--- include/constants/battle_string_ids.h | 23 ++- src/battle_controller_link_opponent.c | 6 +- src/battle_controller_link_partner.c | 6 +- src/battle_controller_opponent.c | 6 +- src/battle_controller_player.c | 6 +- src/battle_controller_player_partner.c | 6 +- src/battle_controller_recorded_opponent.c | 6 +- src/battle_controller_recorded_player.c | 6 +- src/battle_controller_safari.c | 6 +- src/battle_controller_wally.c | 6 +- src/battle_controllers.c | 10 +- src/battle_message.c | 24 +-- src/battle_script_commands.c | 62 +++--- src/battle_util.c | 2 +- 19 files changed, 238 insertions(+), 224 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index f3664a1c4..0f51061e8 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1311,7 +1311,7 @@ various \battler, 15 .endm - .macro arenajudmengtstring id:req + .macro arenajudgmentstring id:req various \id, VARIOUS_ARENA_JUDGMENT_STRING .endm diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index daaf5eafd..045db19c5 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1,3 +1,4 @@ +#include "constants/global.h" #include "constants/battle.h" #include "constants/pokemon.h" #include "constants/battle_script_commands.h" @@ -627,9 +628,9 @@ BattleScript_EffectMultiHit:: accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring ppreduce - setmultihitcounter 0x0 + setmultihitcounter 0 initmultihitstring - setbyte sMULTIHIT_EFFECT, 0x0 + setbyte sMULTIHIT_EFFECT, 0 BattleScript_MultiHitLoop:: jumpifhasnohp BS_ATTACKER, BattleScript_MultiHitEnd jumpifhasnohp BS_TARGET, BattleScript_MultiHitPrintStrings @@ -654,7 +655,7 @@ BattleScript_DoMultiHit:: waitmessage B_WAIT_TIME_LONG printstring STRINGID_EMPTYSTRING3 waitmessage 1 - addbyte sMULTIHIT_STRING + 4, 0x1 + addbyte sMULTIHIT_STRING + 4, 1 moveendto MOVEEND_NEXT_TARGET jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_FOE_ENDURED, BattleScript_MultiHitPrintStrings decrementmultihit BattleScript_MultiHitLoop @@ -665,7 +666,7 @@ BattleScript_MultiHitPrintStrings:: resultmessage waitmessage B_WAIT_TIME_LONG jumpifmovehadnoeffect BattleScript_MultiHitEnd - copyarray gBattleTextBuff1, sMULTIHIT_STRING, 0x6 + copyarray gBattleTextBuff1, sMULTIHIT_STRING, 6 printstring STRINGID_HITXTIMES waitmessage B_WAIT_TIME_LONG BattleScript_MultiHitEnd:: @@ -806,7 +807,7 @@ BattleScript_EffectRazorWind:: BattleScript_TwoTurnMovesSecondTurn:: attackcanceler setmoveeffect MOVE_EFFECT_CHARGING - setbyte sB_ANIM_TURN, 0x1 + setbyte sB_ANIM_TURN, 1 clearstatusfromeffect BS_ATTACKER orword gHitMarker, HITMARKER_NO_PPDEDUCT jumpifnotmove MOVE_SKY_ATTACK, BattleScript_HitFromAccCheck @@ -862,9 +863,9 @@ BattleScript_EffectDoubleHit:: accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring ppreduce - setmultihitcounter 0x2 + setmultihitcounter 2 initmultihitstring - setbyte sMULTIHIT_EFFECT, 0x0 + setbyte sMULTIHIT_EFFECT, 0 goto BattleScript_MultiHitLoop BattleScript_EffectRecoilIfMiss:: @@ -1099,7 +1100,7 @@ BattleScript_EffectTwineedle:: setbyte sMULTIHIT_EFFECT, MOVE_EFFECT_POISON attackstring ppreduce - setmultihitcounter 0x2 + setmultihitcounter 2 initmultihitstring goto BattleScript_MultiHitLoop @@ -1171,8 +1172,8 @@ BattleScript_EffectMetronome:: pause B_WAIT_TIME_SHORT attackanimation waitanimation - setbyte sB_ANIM_TURN, 0x0 - setbyte sB_ANIM_TARGETS_HIT, 0x0 + setbyte sB_ANIM_TURN, 0 + setbyte sB_ANIM_TARGETS_HIT, 0 metronome BattleScript_EffectLeechSeed:: @@ -1348,8 +1349,8 @@ BattleScript_SleepTalkIsAsleep:: BattleScript_SleepTalkUsingMove:: attackanimation waitanimation - setbyte sB_ANIM_TURN, 0x0 - setbyte sB_ANIM_TARGETS_HIT, 0x0 + setbyte sB_ANIM_TURN, 0 + setbyte sB_ANIM_TARGETS_HIT, 0 jumptocalledmove TRUE BattleScript_EffectDestinyBond:: @@ -1406,9 +1407,9 @@ BattleScript_EffectTripleKick:: attackcanceler attackstring ppreduce - sethword sTRIPLE_KICK_POWER, 0x0 + sethword sTRIPLE_KICK_POWER, 0 initmultihitstring - setmultihit 0x3 + setmultihit 3 BattleScript_TripleKickLoop:: jumpifhasnohp BS_ATTACKER, BattleScript_TripleKickEnd jumpifhasnohp BS_TARGET, BattleScript_TripleKickNoMoreHits @@ -1418,7 +1419,7 @@ BattleScript_DoTripleKickAttack:: accuracycheck BattleScript_TripleKickNoMoreHits, ACC_CURR_MOVE movevaluescleanup addbyte sTRIPLE_KICK_POWER, 10 - addbyte sMULTIHIT_STRING + 4, 0x1 + addbyte sMULTIHIT_STRING + 4, 1 copyhword gDynamicBasePower, sTRIPLE_KICK_POWER critcalc damagecalc @@ -1442,14 +1443,14 @@ BattleScript_DoTripleKickAttack:: goto BattleScript_TripleKickPrintStrings BattleScript_TripleKickNoMoreHits:: pause B_WAIT_TIME_SHORT - jumpifbyte CMP_EQUAL, sMULTIHIT_STRING + 4, 0x0, BattleScript_TripleKickPrintStrings + jumpifbyte CMP_EQUAL, sMULTIHIT_STRING + 4, 0, BattleScript_TripleKickPrintStrings bicbyte gMoveResultFlags, MOVE_RESULT_MISSED BattleScript_TripleKickPrintStrings:: resultmessage waitmessage B_WAIT_TIME_LONG - jumpifbyte CMP_EQUAL, sMULTIHIT_STRING + 4, 0x0, BattleScript_TripleKickEnd + jumpifbyte CMP_EQUAL, sMULTIHIT_STRING + 4, 0, BattleScript_TripleKickEnd jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_TripleKickEnd - copyarray gBattleTextBuff1, sMULTIHIT_STRING, 0x6 + copyarray gBattleTextBuff1, sMULTIHIT_STRING, 6 printstring STRINGID_HITXTIMES waitmessage B_WAIT_TIME_LONG BattleScript_TripleKickEnd:: @@ -1510,7 +1511,7 @@ BattleScript_EffectCurse:: jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_DEF, MAX_STAT_STAGE, BattleScript_ButItFailed BattleScript_CurseTrySpeed:: copybyte gBattlerTarget, gBattlerAttacker - setbyte sB_ANIM_TURN, 0x1 + setbyte sB_ANIM_TURN, 1 attackanimation waitanimation setstatchanger STAT_SPEED, 1, TRUE @@ -1540,7 +1541,7 @@ BattleScript_DoGhostCurse:: accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON cursetarget BattleScript_ButItFailed orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE - setbyte sB_ANIM_TURN, 0x0 + setbyte sB_ANIM_TURN, 0 attackanimation waitanimation healthbarupdate BS_ATTACKER @@ -1594,11 +1595,11 @@ BattleScript_EffectPerishSong:: waitanimation printstring STRINGID_FAINTINTHREE waitmessage B_WAIT_TIME_LONG - setbyte sBATTLER, 0x0 + setbyte sBATTLER, 0 BattleScript_PerishSongLoop:: jumpifability BS_SCRIPTING, ABILITY_SOUNDPROOF, BattleScript_PerishSongNotAffected BattleScript_PerishSongLoopIncrement:: - addbyte sBATTLER, 0x1 + addbyte sBATTLER, 1 jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_PerishSongLoop goto BattleScript_MoveEnd @@ -1720,10 +1721,10 @@ BattleScript_EffectBatonPass:: jumpifcantswitch SWITCH_IGNORE_ESCAPE_PREVENTION | BS_ATTACKER, BattleScript_ButItFailed attackanimation waitanimation - openpartyscreen 0x1, BattleScript_ButItFailed + openpartyscreen BS_ATTACKER, BattleScript_ButItFailed switchoutabilities BS_ATTACKER waitstate - switchhandleorder BS_ATTACKER, 0x2 + switchhandleorder BS_ATTACKER, 2 returntoball BS_ATTACKER getswitchedmondata BS_ATTACKER switchindataupdate BS_ATTACKER @@ -1949,8 +1950,8 @@ BattleScript_EffectTeleport:: ppreduce jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_ButItFailed getifcantrunfrombattle BS_ATTACKER - jumpifbyte CMP_EQUAL, gBattleCommunication, 0x1, BattleScript_ButItFailed - jumpifbyte CMP_EQUAL, gBattleCommunication, 0x2, BattleScript_PrintAbilityMadeIneffective + jumpifbyte CMP_EQUAL, gBattleCommunication, 1, BattleScript_ButItFailed + jumpifbyte CMP_EQUAL, gBattleCommunication, 2, BattleScript_PrintAbilityMadeIneffective attackanimation waitanimation printstring STRINGID_PKMNFLEDFROMBATTLE @@ -1964,13 +1965,13 @@ BattleScript_EffectBeatUp:: attackstring pause B_WAIT_TIME_SHORT ppreduce - setbyte gBattleCommunication, 0x0 + setbyte gBattleCommunication, 0 BattleScript_BeatUpLoop:: movevaluescleanup trydobeatup BattleScript_BeatUpEnd, BattleScript_ButItFailed printstring STRINGID_PKMNATTACK critcalc - jumpifbyte CMP_NOT_EQUAL, gCritMultiplier, 0x2, BattleScript_BeatUpAttack + jumpifbyte CMP_NOT_EQUAL, gCritMultiplier, 2, BattleScript_BeatUpAttack manipulatedamage DMG_DOUBLED BattleScript_BeatUpAttack:: adjustnormaldamage @@ -2018,7 +2019,7 @@ BattleScript_FirstTurnSemiInvulnerable:: BattleScript_SecondTurnSemiInvulnerable:: attackcanceler setmoveeffect MOVE_EFFECT_CHARGING - setbyte sB_ANIM_TURN, 0x1 + setbyte sB_ANIM_TURN, 1 clearstatusfromeffect BS_ATTACKER orword gHitMarker, HITMARKER_NO_PPDEDUCT jumpifnotmove MOVE_BOUNCE, BattleScript_SemiInvulnerableTryHit @@ -2379,7 +2380,7 @@ BattleScript_EffectWish:: attackcanceler attackstring ppreduce - trywish 0x0, BattleScript_ButItFailed + trywish 0, BattleScript_ButItFailed attackanimation waitanimation goto BattleScript_MoveEnd @@ -2390,8 +2391,8 @@ BattleScript_EffectAssist:: assistattackselect BattleScript_ButItFailedPpReduce attackanimation waitanimation - setbyte sB_ANIM_TURN, 0x0 - setbyte sB_ANIM_TARGETS_HIT, 0x0 + setbyte sB_ANIM_TURN, 0 + setbyte sB_ANIM_TARGETS_HIT, 0 jumptocalledmove TRUE BattleScript_EffectIngrain:: @@ -2445,12 +2446,12 @@ BattleScript_EffectBrickBreak:: damagecalc typecalc adjustnormaldamage - jumpifbyte CMP_EQUAL, sB_ANIM_TURN, 0x0, BattleScript_BrickBreakAnim + jumpifbyte CMP_EQUAL, sB_ANIM_TURN, 0, BattleScript_BrickBreakAnim bicbyte gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE BattleScript_BrickBreakAnim:: attackanimation waitanimation - jumpifbyte CMP_LESS_THAN, sB_ANIM_TURN, 0x2, BattleScript_BrickBreakDoHit + jumpifbyte CMP_LESS_THAN, sB_ANIM_TURN, 2, BattleScript_BrickBreakDoHit printstring STRINGID_THEWALLSHATTERED waitmessage B_WAIT_TIME_LONG BattleScript_BrickBreakDoHit:: @@ -2592,7 +2593,7 @@ BattleScript_EffectTeeterDance:: attackcanceler attackstring ppreduce - setbyte gBattlerTarget, 0x0 + setbyte gBattlerTarget, 0 BattleScript_TeeterDanceLoop:: movevaluescleanup setmoveeffect MOVE_EFFECT_CONFUSION @@ -2611,7 +2612,7 @@ BattleScript_TeeterDanceLoop:: BattleScript_TeeterDanceDoMoveEndIncrement:: moveendto MOVEEND_NEXT_TARGET BattleScript_TeeterDanceLoopIncrement:: - addbyte gBattlerTarget, 0x1 + addbyte gBattlerTarget, 1 jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TeeterDanceLoop end @@ -2714,7 +2715,7 @@ BattleScript_CosmicPowerDoMoveAnim:: attackanimation waitanimation setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, 0x0 + playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, 0 setstatchanger STAT_DEF, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_CosmicPowerTrySpDef jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_CosmicPowerTrySpDef @@ -2743,7 +2744,7 @@ BattleScript_BulkUpDoMoveAnim:: attackanimation waitanimation setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_DEF, 0x0 + playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_DEF, 0 setstatchanger STAT_ATK, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_BulkUpTryDef jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_BulkUpTryDef @@ -2768,7 +2769,7 @@ BattleScript_CalmMindDoMoveAnim:: attackanimation waitanimation setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_ATTACKER, BIT_SPATK | BIT_SPDEF, 0x0 + playstatchangeanimation BS_ATTACKER, BIT_SPATK | BIT_SPDEF, 0 setstatchanger STAT_SPATK, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_CalmMindTrySpDef jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_CalmMindTrySpDef @@ -2800,7 +2801,7 @@ BattleScript_DragonDanceDoMoveAnim:: attackanimation waitanimation setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_SPEED, 0x0 + playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_SPEED, 0 setstatchanger STAT_ATK, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_DragonDanceTrySpeed jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_DragonDanceTrySpeed @@ -2843,40 +2844,40 @@ BattleScript_FaintTarget:: return BattleScript_GiveExp:: - setbyte sGIVEEXP_STATE, 0x0 + setbyte sGIVEEXP_STATE, 0 getexp BS_TARGET end2 BattleScript_HandleFaintedMon:: - atk24 BattleScript_82DA8F6 + atk24 BattleScript_HandleFaintedMonMultiple jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_FaintedMonEnd jumpifbattletype BATTLE_TYPE_TRAINER, BattleScript_FaintedMonTryChooseAnother jumpifword CMP_NO_COMMON_BITS, gHitMarker, HITMARKER_x400000, BattleScript_FaintedMonTryChooseAnother printstring STRINGID_USENEXTPKMN - setbyte gBattleCommunication, 0x0 + setbyte gBattleCommunication, 0 yesnobox - jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 0x0, BattleScript_FaintedMonTryChooseAnother + jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 0, BattleScript_FaintedMonTryChooseAnother jumpifplayerran BattleScript_FaintedMonEnd printstring STRINGID_CANTESCAPE2 BattleScript_FaintedMonTryChooseAnother:: - openpartyscreen 0x3, BattleScript_FaintedMonEnd - switchhandleorder BS_FAINTED, 0x2 + openpartyscreen BS_FAINTED, BattleScript_FaintedMonEnd + switchhandleorder BS_FAINTED, 2 jumpifnotbattletype BATTLE_TYPE_TRAINER, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_LINK, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_RECORDED_LINK, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_FRONTIER, BattleScript_FaintedMonChooseAnother jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_FaintedMonChooseAnother jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_x400000, BattleScript_FaintedMonChooseAnother - jumpifbyte CMP_EQUAL, sBATTLE_STYLE, 0x1, BattleScript_FaintedMonChooseAnother + jumpifbyte CMP_EQUAL, sBATTLE_STYLE, OPTIONS_BATTLE_STYLE_SET, BattleScript_FaintedMonChooseAnother jumpifcantswitch BS_PLAYER1, BattleScript_FaintedMonChooseAnother printstring STRINGID_ENEMYABOUTTOSWITCHPKMN - setbyte gBattleCommunication, 0x0 + setbyte gBattleCommunication, 0 yesnobox - jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 0x1, BattleScript_FaintedMonChooseAnother + jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 1, BattleScript_FaintedMonChooseAnother setatktoplayer0 - openpartyscreen 0x81, BattleScript_FaintedMonChooseAnother - switchhandleorder BS_ATTACKER, 0x2 - jumpifbyte CMP_EQUAL, gBattleCommunication, 0x6, BattleScript_FaintedMonChooseAnother + openpartyscreen BS_ATTACKER | PARTY_SCREEN_OPTIONAL, BattleScript_FaintedMonChooseAnother + switchhandleorder BS_ATTACKER, 2 + jumpifbyte CMP_EQUAL, gBattleCommunication, PARTY_SIZE, BattleScript_FaintedMonChooseAnother atknameinbuff1 resetintimidatetracebits BS_ATTACKER hpthresholds2 BS_ATTACKER @@ -2891,7 +2892,7 @@ BattleScript_FaintedMonTryChooseAnother:: hpthresholds BS_ATTACKER printstring STRINGID_SWITCHINMON hidepartystatussummary BS_ATTACKER - switchinanim BS_ATTACKER, 0x0 + switchinanim BS_ATTACKER, 0 waitstate switchineffects BS_ATTACKER resetsentmonsvalue @@ -2911,14 +2912,14 @@ BattleScript_FaintedMonChooseAnother:: BattleScript_FaintedMonEnd:: end2 -BattleScript_82DA8F6:: - openpartyscreen 0x5, BattleScript_82DA8FC -BattleScript_82DA8FC:: - switchhandleorder BS_FAINTED, 0x0 - openpartyscreen 0x6, BattleScript_82DA92C - switchhandleorder BS_FAINTED, 0x0 -BattleScript_82DA908:: - switchhandleorder BS_FAINTED, 0x3 +BattleScript_HandleFaintedMonMultiple:: + openpartyscreen BS_UNK_5, BattleScript_HandleFaintedMonMultipleStart +BattleScript_HandleFaintedMonMultipleStart:: + switchhandleorder BS_FAINTED, 0 + openpartyscreen BS_UNK_6, BattleScript_HandleFaintedMonMultipleEnd + switchhandleorder BS_FAINTED, 0 +BattleScript_HandleFaintedMonLoop:: + switchhandleorder BS_FAINTED, 3 drawpartystatussummary BS_FAINTED getswitchedmondata BS_FAINTED switchindataupdate BS_FAINTED @@ -2928,8 +2929,8 @@ BattleScript_82DA908:: switchinanim BS_FAINTED, FALSE waitstate switchineffects 5 - jumpifbytenotequal gBattlerFainted, gBattlersCount, BattleScript_82DA908 -BattleScript_82DA92C:: + jumpifbytenotequal gBattlerFainted, gBattlersCount, BattleScript_HandleFaintedMonLoop +BattleScript_HandleFaintedMonMultipleEnd:: end2 BattleScript_LocalTrainerBattleWon:: @@ -3105,10 +3106,10 @@ BattleScript_ActionSwitch:: printstring STRINGID_RETURNMON setbyte sDMG_MULTIPLIER, 2 jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_PursuitSwitchDmgSetMultihit - setmultihit 0x1 + setmultihit 1 goto BattleScript_PursuitSwitchDmgLoop BattleScript_PursuitSwitchDmgSetMultihit:: - setmultihit 0x2 + setmultihit 2 BattleScript_PursuitSwitchDmgLoop:: jumpifnopursuitswitchdmg BattleScript_DoSwitchOut swapattackerwithtarget @@ -3122,7 +3123,7 @@ BattleScript_DoSwitchOut:: returnatktoball waitstate drawpartystatussummary BS_ATTACKER - switchhandleorder BS_ATTACKER, 0x1 + switchhandleorder BS_ATTACKER, 1 getswitchedmondata BS_ATTACKER switchindataupdate BS_ATTACKER hpthresholds BS_ATTACKER @@ -3158,7 +3159,7 @@ BattleScript_PursuitDmgOnSwitchOut:: moveendfromto MOVEEND_ON_DAMAGE_ABILITIES, MOVEEND_CHOICE_MOVE getbattlerfainted BS_TARGET jumpifbyte CMP_EQUAL, gBattleCommunication, FALSE, BattleScript_PursuitDmgOnSwitchOutRet - setbyte sGIVEEXP_STATE, 0x0 + setbyte sGIVEEXP_STATE, 0 getexp BS_TARGET BattleScript_PursuitDmgOnSwitchOutRet: return @@ -3170,7 +3171,7 @@ BattleScript_Pausex20:: BattleScript_LevelUp:: fanfare MUS_LEVEL_UP printstring STRINGID_PKMNGREWTOLV - setbyte sLVLBOX_STATE, 0x0 + setbyte sLVLBOX_STATE, 0 drawlvlupbox handlelearnnewmove BattleScript_LearnedNewMove, BattleScript_LearnMoveReturn, TRUE goto BattleScript_AskToLearnMove @@ -3182,11 +3183,11 @@ BattleScript_AskToLearnMove:: printstring STRINGID_TRYTOLEARNMOVE2 printstring STRINGID_TRYTOLEARNMOVE3 waitstate - setbyte sLEARNMOVE_STATE, 0x0 + setbyte sLEARNMOVE_STATE, 0 yesnoboxlearnmove BattleScript_ForgotAndLearnedNewMove printstring STRINGID_STOPLEARNINGMOVE waitstate - setbyte sLEARNMOVE_STATE, 0x0 + setbyte sLEARNMOVE_STATE, 0 yesnoboxstoplearningmove BattleScript_AskToLearnMove printstring STRINGID_DIDNOTLEARNMOVE goto BattleScript_TryLearnMoveLoop @@ -3216,11 +3217,11 @@ BattleScript_DamagingWeatherContinues:: printfromtable gSandStormHailContinuesStringIds waitmessage B_WAIT_TIME_LONG playanimation2 BS_ATTACKER, sB_ANIM_ARG1, NULL - setbyte gBattleCommunication, 0x0 + setbyte gBattleCommunication, 0 BattleScript_DamagingWeatherLoop:: - copyarraywithindex gBattlerAttacker, gBattlerByTurnOrder, gBattleCommunication, 0x1 + copyarraywithindex gBattlerAttacker, gBattlerByTurnOrder, gBattleCommunication, 1 weatherdamage - jumpifword CMP_EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement + jumpifword CMP_EQUAL, gBattleMoveDamage, 0, BattleScript_DamagingWeatherLoopIncrement printfromtable gSandStormHailDmgStringIds waitmessage B_WAIT_TIME_LONG orword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE @@ -3232,7 +3233,7 @@ BattleScript_DamagingWeatherLoop:: atk24 BattleScript_DamagingWeatherLoopIncrement BattleScript_DamagingWeatherLoopIncrement:: jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_DamagingWeatherContinuesEnd - addbyte gBattleCommunication, 0x1 + addbyte gBattleCommunication, 1 jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamagingWeatherLoop BattleScript_DamagingWeatherContinuesEnd:: bicword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE @@ -3315,7 +3316,7 @@ BattleScript_BideAttack:: bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE copyword gBattleMoveDamage, sBIDE_DMG adjustsetdamage - setbyte sB_ANIM_TURN, 0x1 + setbyte sB_ANIM_TURN, 1 attackanimation waitanimation effectivenesssound @@ -3410,7 +3411,7 @@ BattleScript_SpikesOnAttacker:: return BattleScript_SpikesOnAttackerFainted:: - setbyte sGIVEEXP_STATE, 0x0 + setbyte sGIVEEXP_STATE, 0 getexp BS_ATTACKER moveendall goto BattleScript_HandleFaintedMon @@ -3425,7 +3426,7 @@ BattleScript_SpikesOnTarget:: return BattleScript_SpikesOnTargetFainted:: - setbyte sGIVEEXP_STATE, 0x0 + setbyte sGIVEEXP_STATE, 0 getexp BS_TARGET moveendall goto BattleScript_HandleFaintedMon @@ -3440,7 +3441,7 @@ BattleScript_SpikesOnFaintedBattler:: return BattleScript_SpikesOnFaintedBattlerFainted:: - setbyte sGIVEEXP_STATE, 0x0 + setbyte sGIVEEXP_STATE, 0 getexp BS_FAINTED moveendall goto BattleScript_HandleFaintedMon @@ -3472,7 +3473,7 @@ BattleScript_AllStatsUp:: jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_AllStatsUpRet BattleScript_AllStatsUpAtk:: setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_DEF | BIT_SPEED | BIT_SPATK | BIT_SPDEF, 0x0 + playstatchangeanimation BS_ATTACKER, BIT_ATK | BIT_DEF | BIT_SPEED | BIT_SPATK | BIT_SPDEF, 0 setstatchanger STAT_ATK, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_AllStatsUpDef printfromtable gStatUpStringIds @@ -3602,7 +3603,7 @@ BattleScript_SelectingNotAllowedMoveTauntInPalace:: goto BattleScript_SelectingUnusableMoveInPalace BattleScript_WishComesTrue:: - trywish 0x1, BattleScript_WishButFullHp + trywish 1, BattleScript_WishButFullHp playanimation BS_TARGET, B_ANIM_WISH_HEAL, NULL printstring STRINGID_PKMNWISHCAMETRUE waitmessage B_WAIT_TIME_LONG @@ -4012,10 +4013,10 @@ BattleScript_ShedSkinActivates:: end3 BattleScript_WeatherFormChanges:: - setbyte sBATTLER, 0x0 + setbyte sBATTLER, 0 BattleScript_WeatherFormChangesLoop:: trycastformdatachange - addbyte sBATTLER, 0x1 + addbyte sBATTLER, 1 jumpifbytenotequal sBATTLER, gBattlersCount, BattleScript_WeatherFormChangesLoop return @@ -4037,7 +4038,7 @@ BattleScript_IntimidateActivatesEnd3:: BattleScript_PauseIntimidateActivates: pause B_WAIT_TIME_SHORT BattleScript_IntimidateActivates:: - setbyte gBattlerTarget, 0x0 + setbyte gBattlerTarget, 0 setstatchanger STAT_ATK, 1, TRUE BattleScript_IntimidateActivatesLoop: trygetintimidatetarget BattleScript_IntimidateActivatesReturn @@ -4052,7 +4053,7 @@ BattleScript_IntimidateActivatesLoop: printstring STRINGID_PKMNCUTSATTACKWITH waitmessage B_WAIT_TIME_LONG BattleScript_IntimidateActivatesLoopIncrement: - addbyte gBattlerTarget, 0x1 + addbyte gBattlerTarget, 1 goto BattleScript_IntimidateActivatesLoop BattleScript_IntimidateActivatesReturn: return @@ -4466,18 +4467,19 @@ BattleScript_ArenaTurnBeginning:: pause 8 playse SE_ARENA_TIMEUP1 various14 BS_ATTACKER - arenajudmengtstring 8 - arenawaitmessage 8 + arenajudgmentstring B_MSG_REF_COMMENCE_BATTLE + arenawaitmessage B_MSG_REF_COMMENCE_BATTLE pause B_WAIT_TIME_LONG various15 BS_ATTACKER volumeup end2 - -BattleScript_82DB8E0:: @ Unused battlescript + +@ Unused +BattleScript_ArenaNothingDecided:: playse SE_DING_DONG various14 BS_ATTACKER - arenajudmengtstring BS_TARGET - arenawaitmessage BS_TARGET + arenajudgmentstring B_MSG_REF_NOTHING_IS_DECIDED + arenawaitmessage B_MSG_REF_NOTHING_IS_DECIDED pause B_WAIT_TIME_LONG various15 BS_ATTACKER end2 @@ -4493,26 +4495,26 @@ BattleScript_ArenaDoJudgment:: playse SE_ARENA_TIMEUP1 pause B_WAIT_TIME_LONG various14 BS_ATTACKER - arenajudmengtstring 1 - arenawaitmessage 1 + arenajudgmentstring B_MSG_REF_THATS_IT + arenawaitmessage B_MSG_REF_THATS_IT pause B_WAIT_TIME_LONG - setbyte gBattleCommunication, 0x0 + setbyte gBattleCommunication, 0 arenajudgmentwindow pause B_WAIT_TIME_LONG arenajudgmentwindow - arenajudmengtstring 2 - arenawaitmessage 2 + arenajudgmentstring B_MSG_REF_JUDGE_MIND + arenawaitmessage B_MSG_REF_JUDGE_MIND arenajudgmentwindow - arenajudmengtstring 3 - arenawaitmessage 3 + arenajudgmentstring B_MSG_REF_JUDGE_SKILL + arenawaitmessage B_MSG_REF_JUDGE_SKILL arenajudgmentwindow - arenajudmengtstring 4 - arenawaitmessage 4 + arenajudgmentstring B_MSG_REF_JUDGE_BODY + arenawaitmessage B_MSG_REF_JUDGE_BODY arenajudgmentwindow - jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 0x3, BattleScript_ArenaJudgmentPlayerLoses - jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 0x4, BattleScript_ArenaJudgmentDraw - arenajudmengtstring 5 - arenawaitmessage 5 + jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 3, BattleScript_ArenaJudgmentPlayerLoses + jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 4, BattleScript_ArenaJudgmentDraw + arenajudgmentstring B_MSG_REF_PLAYER_WON + arenawaitmessage B_MSG_REF_PLAYER_WON arenajudgmentwindow various15 BS_ATTACKER printstring STRINGID_DEFEATEDOPPONENTBYREFEREE @@ -4525,8 +4527,8 @@ BattleScript_ArenaDoJudgment:: end2 BattleScript_ArenaJudgmentPlayerLoses: - arenajudmengtstring 6 - arenawaitmessage 6 + arenajudgmentstring B_MSG_REF_OPPONENT_WON + arenawaitmessage B_MSG_REF_OPPONENT_WON arenajudgmentwindow various15 BS_ATTACKER printstring STRINGID_LOSTTOOPPONENTBYREFEREE @@ -4539,8 +4541,8 @@ BattleScript_ArenaJudgmentPlayerLoses: end2 BattleScript_ArenaJudgmentDraw: - arenajudmengtstring 7 - arenawaitmessage 7 + arenajudgmentstring B_MSG_REF_DRAW + arenawaitmessage B_MSG_REF_DRAW arenajudgmentwindow various15 BS_ATTACKER printstring STRINGID_TIEDOPPONENTBYREFEREE diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index 4b8ca0d87..378819a94 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -95,7 +95,7 @@ BattleScript_ShakeBallThrow:: printfromtable gBallEscapeStringIds waitmessage B_WAIT_TIME_LONG jumpifword CMP_NO_COMMON_BITS, gBattleTypeFlags, BATTLE_TYPE_SAFARI, BattleScript_ShakeBallThrowEnd - jumpifbyte CMP_NOT_EQUAL, gNumSafariBalls, 0x0, BattleScript_ShakeBallThrowEnd + jumpifbyte CMP_NOT_EQUAL, gNumSafariBalls, 0, BattleScript_ShakeBallThrowEnd printstring STRINGID_OUTOFSAFARIBALLS waitmessage B_WAIT_TIME_LONG setbyte gBattleOutcome, B_OUTCOME_NO_SAFARI_BALLS @@ -111,8 +111,7 @@ BattleScript_TrainerBallBlock:: finishaction BattleScript_PlayerUsesItem:: - setbyte sMOVEEND_STATE, 0xF - moveend 0x1, 0x0 + moveendcase MOVEEND_MIRROR_MOVE end BattleScript_OpponentUsesHealItem:: @@ -128,8 +127,7 @@ BattleScript_OpponentUsesHealItem:: printstring STRINGID_PKMNSITEMRESTOREDHEALTH waitmessage B_WAIT_TIME_LONG updatestatusicon BS_ATTACKER - setbyte sMOVEEND_STATE, 0xF - moveend 0x1, 0x0 + moveendcase MOVEEND_MIRROR_MOVE finishaction BattleScript_OpponentUsesStatusCureItem:: @@ -142,8 +140,7 @@ BattleScript_OpponentUsesStatusCureItem:: printfromtable gTrainerItemCuredStatusStringIds waitmessage B_WAIT_TIME_LONG updatestatusicon BS_ATTACKER - setbyte sMOVEEND_STATE, 0xF - moveend 0x1, 0x0 + moveendcase MOVEEND_MIRROR_MOVE finishaction BattleScript_OpponentUsesXItem:: @@ -155,8 +152,7 @@ BattleScript_OpponentUsesXItem:: useitemonopponent printfromtable gStatUpStringIds waitmessage B_WAIT_TIME_LONG - setbyte sMOVEEND_STATE, 0xF - moveend 0x1, 0x0 + moveendcase MOVEEND_MIRROR_MOVE finishaction BattleScript_OpponentUsesGuardSpecs:: @@ -168,8 +164,7 @@ BattleScript_OpponentUsesGuardSpecs:: useitemonopponent printfromtable gMistUsedStringIds waitmessage B_WAIT_TIME_LONG - setbyte sMOVEEND_STATE, 0xF - moveend 0x1, 0x0 + moveendcase MOVEEND_MIRROR_MOVE finishaction BattleScript_RunByUsingItem:: diff --git a/include/battle_controllers.h b/include/battle_controllers.h index da76ab0c6..34e916b0f 100644 --- a/include/battle_controllers.h +++ b/include/battle_controllers.h @@ -156,7 +156,7 @@ enum CONTROLLER_CLEARUNKFLAG, CONTROLLER_TOGGLEUNKFLAG, CONTROLLER_HITANIMATION, - CONTROLLER_42, + CONTROLLER_CANTSWITCH, CONTROLLER_PLAYSE, CONTROLLER_PLAYFANFAREORBGM, CONTROLLER_FAINTINGCRY, @@ -227,7 +227,7 @@ void BtlController_EmitSetUnkVar(u8 bufferId, u8 b); // unused void BtlController_EmitClearUnkFlag(u8 bufferId); // unused void BtlController_EmitToggleUnkFlag(u8 bufferId); // unused void BtlController_EmitHitAnimation(u8 bufferId); -void BtlController_EmitCmd42(u8 bufferId); +void BtlController_EmitCantSwitch(u8 bufferId); void BtlController_EmitPlaySE(u8 bufferId, u16 songId); void BtlController_EmitPlayFanfareOrBGM(u8 bufferId, u16 songId, bool8 playBGM); void BtlController_EmitFaintingCry(u8 bufferId); diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index cef0b184d..9794589af 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -39,8 +39,10 @@ #define BS_ATTACKER 1 #define BS_EFFECT_BATTLER 2 #define BS_FAINTED 3 -#define BS_BATTLER_0 7 #define BS_ATTACKER_WITH_PARTNER 4 // for Cmd_updatestatusicon +#define BS_UNK_5 5 +#define BS_UNK_6 6 +#define BS_BATTLER_0 7 #define BS_ATTACKER_SIDE 8 // for Cmd_jumpifability #define BS_NOT_ATTACKER_SIDE 9 // for Cmd_jumpifability #define BS_SCRIPTING 10 @@ -55,12 +57,12 @@ #define ACC_CURR_MOVE 0 // compare operands -#define CMP_EQUAL 0x0 -#define CMP_NOT_EQUAL 0x1 -#define CMP_GREATER_THAN 0x2 -#define CMP_LESS_THAN 0x3 -#define CMP_COMMON_BITS 0x4 -#define CMP_NO_COMMON_BITS 0x5 +#define CMP_EQUAL 0 +#define CMP_NOT_EQUAL 1 +#define CMP_GREATER_THAN 2 +#define CMP_LESS_THAN 3 +#define CMP_COMMON_BITS 4 +#define CMP_NO_COMMON_BITS 5 // Cmd_various #define VARIOUS_CANCEL_MULTI_TURN_MOVES 0 @@ -93,27 +95,29 @@ #define DMG_DOUBLED 2 // Cmd_jumpifcantswitch -#define SWITCH_IGNORE_ESCAPE_PREVENTION 0x80 +#define SWITCH_IGNORE_ESCAPE_PREVENTION (1 << 7) // Cmd_statbuffchange -#define STAT_BUFF_ALLOW_PTR 0x1 // If set, allow use of jumpptr. Set in every use of statbuffchange -#define STAT_BUFF_NOT_PROTECT_AFFECTED 0x20 +#define STAT_BUFF_ALLOW_PTR (1 << 0) // If set, allow use of jumpptr. Set in every use of statbuffchange +#define STAT_BUFF_NOT_PROTECT_AFFECTED (1 << 5) // stat change flags for Cmd_playstatchangeanimation -#define STAT_CHANGE_NEGATIVE 0x1 -#define STAT_CHANGE_BY_TWO 0x2 -#define STAT_CHANGE_MULTIPLE_STATS 0x4 -#define STAT_CHANGE_CANT_PREVENT 0x8 +#define STAT_CHANGE_NEGATIVE (1 << 0) +#define STAT_CHANGE_BY_TWO (1 << 1) +#define STAT_CHANGE_MULTIPLE_STATS (1 << 2) +#define STAT_CHANGE_CANT_PREVENT (1 << 3) // stat flags for Cmd_playstatchangeanimation -#define BIT_HP 0x1 -#define BIT_ATK 0x2 -#define BIT_DEF 0x4 -#define BIT_SPEED 0x8 -#define BIT_SPATK 0x10 -#define BIT_SPDEF 0x20 -#define BIT_ACC 0x40 -#define BIT_EVASION 0x80 +#define BIT_HP (1 << 0) +#define BIT_ATK (1 << 1) +#define BIT_DEF (1 << 2) +#define BIT_SPEED (1 << 3) +#define BIT_SPATK (1 << 4) +#define BIT_SPDEF (1 << 5) +#define BIT_ACC (1 << 6) +#define BIT_EVASION (1 << 7) + +#define PARTY_SCREEN_OPTIONAL (1 << 7) // Flag for first argument to openpartyscreen // cases for Cmd_moveend #define MOVEEND_RAGE 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index f1c589fee..f22541272 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -421,12 +421,6 @@ #define B_MSG_LEECH_SEED_DRAIN 3 #define B_MSG_LEECH_SEED_OOZE 4 -// gBattlePalaceFlavorTextTable -#define B_MSG_GLINT_IN_EYE 0 -#define B_MSG_GETTING_IN_POS 1 -#define B_MSG_GROWL_DEEPLY 2 -#define B_MSG_EAGER_FOR_MORE 3 - // gFirstTurnOfTwoStringIds #define B_MSG_TURN1_RAZOR_WIND 0 #define B_MSG_TURN1_SOLAR_BEAM 1 @@ -586,4 +580,21 @@ #define B_MSG_DEFROSTED 0 #define B_MSG_DEFROSTED_BY_MOVE 1 +// gBattlePalaceFlavorTextTable +#define B_MSG_GLINT_IN_EYE 0 +#define B_MSG_GETTING_IN_POS 1 +#define B_MSG_GROWL_DEEPLY 2 +#define B_MSG_EAGER_FOR_MORE 3 + +// gRefereeStringsTable +#define B_MSG_REF_NOTHING_IS_DECIDED 0 +#define B_MSG_REF_THATS_IT 1 +#define B_MSG_REF_JUDGE_MIND 2 +#define B_MSG_REF_JUDGE_SKILL 3 +#define B_MSG_REF_JUDGE_BODY 4 +#define B_MSG_REF_PLAYER_WON 5 +#define B_MSG_REF_OPPONENT_WON 6 +#define B_MSG_REF_DRAW 7 +#define B_MSG_REF_COMMENCE_BATTLE 8 + #endif // GUARD_CONSTANTS_BATTLE_STRING_IDS_H diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index dd44bc91b..179ae18e8 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -74,7 +74,7 @@ static void LinkOpponentHandleSetUnkVar(void); static void LinkOpponentHandleClearUnkFlag(void); static void LinkOpponentHandleToggleUnkFlag(void); static void LinkOpponentHandleHitAnimation(void); -static void LinkOpponentHandleCmd42(void); +static void LinkOpponentHandleCantSwitch(void); static void LinkOpponentHandlePlaySE(void); static void LinkOpponentHandlePlayFanfareOrBGM(void); static void LinkOpponentHandleFaintingCry(void); @@ -146,7 +146,7 @@ static void (*const sLinkOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_CLEARUNKFLAG] = LinkOpponentHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = LinkOpponentHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = LinkOpponentHandleHitAnimation, - [CONTROLLER_42] = LinkOpponentHandleCmd42, + [CONTROLLER_CANTSWITCH] = LinkOpponentHandleCantSwitch, [CONTROLLER_PLAYSE] = LinkOpponentHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = LinkOpponentHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = LinkOpponentHandleFaintingCry, @@ -1647,7 +1647,7 @@ static void LinkOpponentHandleHitAnimation(void) } } -static void LinkOpponentHandleCmd42(void) +static void LinkOpponentHandleCantSwitch(void) { LinkOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 3d6cd7c3b..2bb1cd914 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -72,7 +72,7 @@ static void LinkPartnerHandleSetUnkVar(void); static void LinkPartnerHandleClearUnkFlag(void); static void LinkPartnerHandleToggleUnkFlag(void); static void LinkPartnerHandleHitAnimation(void); -static void LinkPartnerHandleCmd42(void); +static void LinkPartnerHandleCantSwitch(void); static void LinkPartnerHandlePlaySE(void); static void LinkPartnerHandlePlayFanfareOrBGM(void); static void LinkPartnerHandleFaintingCry(void); @@ -143,7 +143,7 @@ static void (*const sLinkPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_CLEARUNKFLAG] = LinkPartnerHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = LinkPartnerHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = LinkPartnerHandleHitAnimation, - [CONTROLLER_42] = LinkPartnerHandleCmd42, + [CONTROLLER_CANTSWITCH] = LinkPartnerHandleCantSwitch, [CONTROLLER_PLAYSE] = LinkPartnerHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = LinkPartnerHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = LinkPartnerHandleFaintingCry, @@ -1477,7 +1477,7 @@ static void LinkPartnerHandleHitAnimation(void) } } -static void LinkPartnerHandleCmd42(void) +static void LinkPartnerHandleCantSwitch(void) { LinkPartnerBufferExecCompleted(); } diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 69f729ee0..2c181c14f 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -79,7 +79,7 @@ static void OpponentHandleSetUnkVar(void); static void OpponentHandleClearUnkFlag(void); static void OpponentHandleToggleUnkFlag(void); static void OpponentHandleHitAnimation(void); -static void OpponentHandleCmd42(void); +static void OpponentHandleCantSwitch(void); static void OpponentHandlePlaySE(void); static void OpponentHandlePlayFanfareOrBGM(void); static void OpponentHandleFaintingCry(void); @@ -151,7 +151,7 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_CLEARUNKFLAG] = OpponentHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = OpponentHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = OpponentHandleHitAnimation, - [CONTROLLER_42] = OpponentHandleCmd42, + [CONTROLLER_CANTSWITCH] = OpponentHandleCantSwitch, [CONTROLLER_PLAYSE] = OpponentHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = OpponentHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = OpponentHandleFaintingCry, @@ -1813,7 +1813,7 @@ static void OpponentHandleHitAnimation(void) } } -static void OpponentHandleCmd42(void) +static void OpponentHandleCantSwitch(void) { OpponentBufferExecCompleted(); } diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 7b5e55adb..e7801d0e4 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -80,7 +80,7 @@ static void PlayerHandleSetUnkVar(void); static void PlayerHandleClearUnkFlag(void); static void PlayerHandleToggleUnkFlag(void); static void PlayerHandleHitAnimation(void); -static void PlayerHandleCmd42(void); +static void PlayerHandleCantSwitch(void); static void PlayerHandlePlaySE(void); static void PlayerHandlePlayFanfareOrBGM(void); static void PlayerHandleFaintingCry(void); @@ -167,7 +167,7 @@ static void (*const sPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_CLEARUNKFLAG] = PlayerHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = PlayerHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = PlayerHandleHitAnimation, - [CONTROLLER_42] = PlayerHandleCmd42, + [CONTROLLER_CANTSWITCH] = PlayerHandleCantSwitch, [CONTROLLER_PLAYSE] = PlayerHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = PlayerHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = PlayerHandleFaintingCry, @@ -2890,7 +2890,7 @@ static void PlayerHandleHitAnimation(void) } } -static void PlayerHandleCmd42(void) +static void PlayerHandleCantSwitch(void) { PlayerBufferExecCompleted(); } diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 251542a48..cc433a9b2 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -70,7 +70,7 @@ static void PlayerPartnerHandleSetUnkVar(void); static void PlayerPartnerHandleClearUnkFlag(void); static void PlayerPartnerHandleToggleUnkFlag(void); static void PlayerPartnerHandleHitAnimation(void); -static void PlayerPartnerHandleCmd42(void); +static void PlayerPartnerHandleCantSwitch(void); static void PlayerPartnerHandlePlaySE(void); static void PlayerPartnerHandlePlayFanfareOrBGM(void); static void PlayerPartnerHandleFaintingCry(void); @@ -146,7 +146,7 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_CLEARUNKFLAG] = PlayerPartnerHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = PlayerPartnerHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = PlayerPartnerHandleHitAnimation, - [CONTROLLER_42] = PlayerPartnerHandleCmd42, + [CONTROLLER_CANTSWITCH] = PlayerPartnerHandleCantSwitch, [CONTROLLER_PLAYSE] = PlayerPartnerHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = PlayerPartnerHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = PlayerPartnerHandleFaintingCry, @@ -1727,7 +1727,7 @@ static void PlayerPartnerHandleHitAnimation(void) } } -static void PlayerPartnerHandleCmd42(void) +static void PlayerPartnerHandleCantSwitch(void) { PlayerPartnerBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 26d93ad28..663d71ec7 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -74,7 +74,7 @@ static void RecordedOpponentHandleSetUnkVar(void); static void RecordedOpponentHandleClearUnkFlag(void); static void RecordedOpponentHandleToggleUnkFlag(void); static void RecordedOpponentHandleHitAnimation(void); -static void RecordedOpponentHandleCmd42(void); +static void RecordedOpponentHandleCantSwitch(void); static void RecordedOpponentHandlePlaySE(void); static void RecordedOpponentHandlePlayFanfareOrBGM(void); static void RecordedOpponentHandleFaintingCry(void); @@ -146,7 +146,7 @@ static void (*const sRecordedOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void [CONTROLLER_CLEARUNKFLAG] = RecordedOpponentHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = RecordedOpponentHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = RecordedOpponentHandleHitAnimation, - [CONTROLLER_42] = RecordedOpponentHandleCmd42, + [CONTROLLER_CANTSWITCH] = RecordedOpponentHandleCantSwitch, [CONTROLLER_PLAYSE] = RecordedOpponentHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = RecordedOpponentHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = RecordedOpponentHandleFaintingCry, @@ -1587,7 +1587,7 @@ static void RecordedOpponentHandleHitAnimation(void) } } -static void RecordedOpponentHandleCmd42(void) +static void RecordedOpponentHandleCantSwitch(void) { RecordedOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 63a04ac40..aa4154a3f 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -70,7 +70,7 @@ static void RecordedPlayerHandleSetUnkVar(void); static void RecordedPlayerHandleClearUnkFlag(void); static void RecordedPlayerHandleToggleUnkFlag(void); static void RecordedPlayerHandleHitAnimation(void); -static void RecordedPlayerHandleCmd42(void); +static void RecordedPlayerHandleCantSwitch(void); static void RecordedPlayerHandlePlaySE(void); static void RecordedPlayerHandlePlayFanfareOrBGM(void); static void RecordedPlayerHandleFaintingCry(void); @@ -141,7 +141,7 @@ static void (*const sRecordedPlayerBufferCommands[CONTROLLER_CMDS_COUNT])(void) [CONTROLLER_CLEARUNKFLAG] = RecordedPlayerHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = RecordedPlayerHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = RecordedPlayerHandleHitAnimation, - [CONTROLLER_42] = RecordedPlayerHandleCmd42, + [CONTROLLER_CANTSWITCH] = RecordedPlayerHandleCantSwitch, [CONTROLLER_PLAYSE] = RecordedPlayerHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = RecordedPlayerHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = RecordedPlayerHandleFaintingCry, @@ -1610,7 +1610,7 @@ static void RecordedPlayerHandleHitAnimation(void) } } -static void RecordedPlayerHandleCmd42(void) +static void RecordedPlayerHandleCantSwitch(void) { RecordedPlayerBufferExecCompleted(); } diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 22c01586d..0fdf32fb6 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -67,7 +67,7 @@ static void SafariHandleSetUnkVar(void); static void SafariHandleClearUnkFlag(void); static void SafariHandleToggleUnkFlag(void); static void SafariHandleHitAnimation(void); -static void SafariHandleCmd42(void); +static void SafariHandleCantSwitch(void); static void SafariHandlePlaySE(void); static void SafariHandlePlayFanfareOrBGM(void); static void SafariHandleFaintingCry(void); @@ -131,7 +131,7 @@ static void (*const sSafariBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_CLEARUNKFLAG] = SafariHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = SafariHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = SafariHandleHitAnimation, - [CONTROLLER_42] = SafariHandleCmd42, + [CONTROLLER_CANTSWITCH] = SafariHandleCantSwitch, [CONTROLLER_PLAYSE] = SafariHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = SafariHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = SafariHandleFaintingCry, @@ -580,7 +580,7 @@ static void SafariHandleHitAnimation(void) SafariBufferExecCompleted(); } -static void SafariHandleCmd42(void) +static void SafariHandleCantSwitch(void) { SafariBufferExecCompleted(); } diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 8b3863c85..8b490a5bf 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -75,7 +75,7 @@ static void WallyHandleSetUnkVar(void); static void WallyHandleClearUnkFlag(void); static void WallyHandleToggleUnkFlag(void); static void WallyHandleHitAnimation(void); -static void WallyHandleCmd42(void); +static void WallyHandleCantSwitch(void); static void WallyHandlePlaySE(void); static void WallyHandlePlayFanfareOrBGM(void); static void WallyHandleFaintingCry(void); @@ -144,7 +144,7 @@ static void (*const sWallyBufferCommands[CONTROLLER_CMDS_COUNT])(void) = [CONTROLLER_CLEARUNKFLAG] = WallyHandleClearUnkFlag, [CONTROLLER_TOGGLEUNKFLAG] = WallyHandleToggleUnkFlag, [CONTROLLER_HITANIMATION] = WallyHandleHitAnimation, - [CONTROLLER_42] = WallyHandleCmd42, + [CONTROLLER_CANTSWITCH] = WallyHandleCantSwitch, [CONTROLLER_PLAYSE] = WallyHandlePlaySE, [CONTROLLER_PLAYFANFAREORBGM] = WallyHandlePlayFanfareOrBGM, [CONTROLLER_FAINTINGCRY] = WallyHandleFaintingCry, @@ -1385,7 +1385,7 @@ static void WallyHandleHitAnimation(void) } } -static void WallyHandleCmd42(void) +static void WallyHandleCantSwitch(void) { WallyBufferExecCompleted(); } diff --git a/src/battle_controllers.c b/src/battle_controllers.c index a9f3ab610..0f3234579 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -1385,12 +1385,12 @@ void BtlController_EmitHitAnimation(u8 bufferId) PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } -void BtlController_EmitCmd42(u8 bufferId) +void BtlController_EmitCantSwitch(u8 bufferId) { - sBattleBuffersTransferData[0] = CONTROLLER_42; - sBattleBuffersTransferData[1] = CONTROLLER_42; - sBattleBuffersTransferData[2] = CONTROLLER_42; - sBattleBuffersTransferData[3] = CONTROLLER_42; + sBattleBuffersTransferData[0] = CONTROLLER_CANTSWITCH; + sBattleBuffersTransferData[1] = CONTROLLER_CANTSWITCH; + sBattleBuffersTransferData[2] = CONTROLLER_CANTSWITCH; + sBattleBuffersTransferData[3] = CONTROLLER_CANTSWITCH; PrepareBufferDataTransfer(bufferId, sBattleBuffersTransferData, 4); } diff --git a/src/battle_message.c b/src/battle_message.c index 4f219c063..7472e2e89 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -1401,9 +1401,9 @@ static const u8 sText_RefThatsIt[] = _("REFEREE: That's it! We will now go to\nj static const u8 sText_RefJudgeMind[] = _("REFEREE: Judging category 1, Mind!\nThe POKéMON showing the most guts!\p"); static const u8 sText_RefJudgeSkill[] = _("REFEREE: Judging category 2, Skill!\nThe POKéMON using moves the best!\p"); static const u8 sText_RefJudgeBody[] = _("REFEREE: Judging category 3, Body!\nThe POKéMON with the most vitality!\p"); -static const u8 sText_RefJudgement1[] = _("REFEREE: Judgment: {B_BUFF1} to {B_BUFF2}!\nThe winner is {B_PLAYER_NAME}'s {B_PLAYER_MON1_NAME}!\p"); -static const u8 sText_RefJudgement2[] = _("REFEREE: Judgment: {B_BUFF1} to {B_BUFF2}!\nThe winner is {B_TRAINER1_NAME}'s {B_OPPONENT_MON1_NAME}!\p"); -static const u8 sText_RefJudgement3[] = _("REFEREE: Judgment: 3 to 3!\nWe have a draw!\p"); +static const u8 sText_RefPlayerWon[] = _("REFEREE: Judgment: {B_BUFF1} to {B_BUFF2}!\nThe winner is {B_PLAYER_NAME}'s {B_PLAYER_MON1_NAME}!\p"); +static const u8 sText_RefOpponentWon[] = _("REFEREE: Judgment: {B_BUFF1} to {B_BUFF2}!\nThe winner is {B_TRAINER1_NAME}'s {B_OPPONENT_MON1_NAME}!\p"); +static const u8 sText_RefDraw[] = _("REFEREE: Judgment: 3 to 3!\nWe have a draw!\p"); static const u8 sText_DefeatedOpponentByReferee[] = _("{B_PLAYER_MON1_NAME} defeated the opponent\n{B_OPPONENT_MON1_NAME} in a REFEREE's decision!"); static const u8 sText_LostToOpponentByReferee[] = _("{B_PLAYER_MON1_NAME} lost to the opponent\n{B_OPPONENT_MON1_NAME} in a REFEREE's decision!"); static const u8 sText_TiedOpponentByReferee[] = _("{B_PLAYER_MON1_NAME} tied the opponent\n{B_OPPONENT_MON1_NAME} in a REFEREE's decision!"); @@ -1411,15 +1411,15 @@ static const u8 sText_RefCommenceBattle[] = _("REFEREE: {B_PLAYER_MON1_NAME} VS const u8 * const gRefereeStringsTable[] = { - sText_RefIfNothingIsDecided, - sText_RefThatsIt, - sText_RefJudgeMind, - sText_RefJudgeSkill, - sText_RefJudgeBody, - sText_RefJudgement1, - sText_RefJudgement2, - sText_RefJudgement3, - sText_RefCommenceBattle, + [B_MSG_REF_NOTHING_IS_DECIDED] = sText_RefIfNothingIsDecided, + [B_MSG_REF_THATS_IT] = sText_RefThatsIt, + [B_MSG_REF_JUDGE_MIND] = sText_RefJudgeMind, + [B_MSG_REF_JUDGE_SKILL] = sText_RefJudgeSkill, + [B_MSG_REF_JUDGE_BODY] = sText_RefJudgeBody, + [B_MSG_REF_PLAYER_WON] = sText_RefPlayerWon, + [B_MSG_REF_OPPONENT_WON] = sText_RefOpponentWon, + [B_MSG_REF_DRAW] = sText_RefDraw, + [B_MSG_REF_COMMENCE_BATTLE] = sText_RefCommenceBattle, }; static const u8 sText_QuestionForfeitMatch[] = _("Would you like to forfeit the match\nand quit now?"); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 6cd7debda..3962c4369 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4801,7 +4801,9 @@ static void Cmd_jumpifcantswitch(void) } } -static void sub_804CF10(u8 slotId) +// Opens the party screen to choose a new Pokémon to send out +// slotId is the Pokémon to replace +static void ChooseMonToSendOut(u8 slotId) { *(gBattleStruct->field_58 + gActiveBattler) = gBattlerPartyIndexes[gActiveBattler]; *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = PARTY_SIZE; @@ -4822,7 +4824,7 @@ static void Cmd_openpartyscreen(void) flags = 0; jumpPtr = T1_READ_PTR(gBattlescriptCurrInstr + 2); - if (gBattlescriptCurrInstr[1] == 5) + if (gBattlescriptCurrInstr[1] == BS_UNK_5) { if ((gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_MULTI)) != BATTLE_TYPE_DOUBLE) { @@ -4830,7 +4832,7 @@ static void Cmd_openpartyscreen(void) { if (gHitMarker & HITMARKER_FAINTED(gActiveBattler)) { - if (HasNoMonsToSwitch(gActiveBattler, 6, 6)) + if (HasNoMonsToSwitch(gActiveBattler, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); @@ -4839,7 +4841,7 @@ static void Cmd_openpartyscreen(void) } else if (!gSpecialStatuses[gActiveBattler].flag40) { - sub_804CF10(PARTY_SIZE); + ChooseMonToSendOut(PARTY_SIZE); gSpecialStatuses[gActiveBattler].flag40 = 1; } } @@ -4859,16 +4861,16 @@ static void Cmd_openpartyscreen(void) if (gBitTable[0] & hitmarkerFaintBits) { gActiveBattler = 0; - if (HasNoMonsToSwitch(0, 6, 6)) + if (HasNoMonsToSwitch(0, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); - BtlController_EmitCmd42(0); + BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } else if (!gSpecialStatuses[gActiveBattler].flag40) { - sub_804CF10(gBattleStruct->monToSwitchIntoId[2]); + ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[2]); gSpecialStatuses[gActiveBattler].flag40 = 1; } else @@ -4881,16 +4883,16 @@ static void Cmd_openpartyscreen(void) if (gBitTable[2] & hitmarkerFaintBits && !(gBitTable[0] & hitmarkerFaintBits)) { gActiveBattler = 2; - if (HasNoMonsToSwitch(2, 6, 6)) + if (HasNoMonsToSwitch(2, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); - BtlController_EmitCmd42(0); + BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } else if (!gSpecialStatuses[gActiveBattler].flag40) { - sub_804CF10(gBattleStruct->monToSwitchIntoId[0]); + ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[0]); gSpecialStatuses[gActiveBattler].flag40 = 1; } else if (!(flags & 1)) @@ -4902,16 +4904,16 @@ static void Cmd_openpartyscreen(void) if (gBitTable[1] & hitmarkerFaintBits) { gActiveBattler = 1; - if (HasNoMonsToSwitch(1, 6, 6)) + if (HasNoMonsToSwitch(1, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); - BtlController_EmitCmd42(0); + BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } else if (!gSpecialStatuses[gActiveBattler].flag40) { - sub_804CF10(gBattleStruct->monToSwitchIntoId[3]); + ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[3]); gSpecialStatuses[gActiveBattler].flag40 = 1; } else @@ -4924,16 +4926,16 @@ static void Cmd_openpartyscreen(void) if (gBitTable[3] & hitmarkerFaintBits && !(gBitTable[1] & hitmarkerFaintBits)) { gActiveBattler = 3; - if (HasNoMonsToSwitch(3, 6, 6)) + if (HasNoMonsToSwitch(3, PARTY_SIZE, PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); - BtlController_EmitCmd42(0); + BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } else if (!gSpecialStatuses[gActiveBattler].flag40) { - sub_804CF10(gBattleStruct->monToSwitchIntoId[1]); + ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[1]); gSpecialStatuses[gActiveBattler].flag40 = 1; } else if (!(flags & 2)) @@ -4977,7 +4979,7 @@ static void Cmd_openpartyscreen(void) } gBattlescriptCurrInstr += 6; } - else if (gBattlescriptCurrInstr[1] == 6) + else if (gBattlescriptCurrInstr[1] == BS_UNK_6) { if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { @@ -4987,32 +4989,32 @@ static void Cmd_openpartyscreen(void) if (gBitTable[2] & hitmarkerFaintBits && gBitTable[0] & hitmarkerFaintBits) { gActiveBattler = 2; - if (HasNoMonsToSwitch(2, gBattleBufferB[0][1], 6)) + if (HasNoMonsToSwitch(2, gBattleBufferB[0][1], PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); - BtlController_EmitCmd42(0); + BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } else if (!gSpecialStatuses[gActiveBattler].flag40) { - sub_804CF10(gBattleStruct->monToSwitchIntoId[0]); + ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[0]); gSpecialStatuses[gActiveBattler].flag40 = 1; } } if (gBitTable[3] & hitmarkerFaintBits && hitmarkerFaintBits & gBitTable[1]) { gActiveBattler = 3; - if (HasNoMonsToSwitch(3, gBattleBufferB[1][1], 6)) + if (HasNoMonsToSwitch(3, gBattleBufferB[1][1], PARTY_SIZE)) { gAbsentBattlerFlags |= gBitTable[gActiveBattler]; gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); - BtlController_EmitCmd42(0); + BtlController_EmitCantSwitch(0); MarkBattlerForControllerExec(gActiveBattler); } else if (!gSpecialStatuses[gActiveBattler].flag40) { - sub_804CF10(gBattleStruct->monToSwitchIntoId[1]); + ChooseMonToSendOut(gBattleStruct->monToSwitchIntoId[1]); gSpecialStatuses[gActiveBattler].flag40 = 1; } } @@ -5040,17 +5042,17 @@ static void Cmd_openpartyscreen(void) } else { - if (gBattlescriptCurrInstr[1] & 0x80) + if (gBattlescriptCurrInstr[1] & PARTY_SCREEN_OPTIONAL) hitmarkerFaintBits = PARTY_ACTION_CHOOSE_MON; // Used here as the caseId for the EmitChoose function. else hitmarkerFaintBits = PARTY_ACTION_SEND_OUT; - battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(0x80)); + battlerId = GetBattlerForBattleScript(gBattlescriptCurrInstr[1] & ~(PARTY_SCREEN_OPTIONAL)); if (gSpecialStatuses[battlerId].flag40) { gBattlescriptCurrInstr += 6; } - else if (HasNoMonsToSwitch(battlerId, 6, 6)) + else if (HasNoMonsToSwitch(battlerId, PARTY_SIZE, PARTY_SIZE)) { gActiveBattler = battlerId; gAbsentBattlerFlags |= gBitTable[gActiveBattler]; @@ -6372,10 +6374,10 @@ static void Cmd_various(void) break; case VARIOUS_ARENA_JUDGMENT_STRING: BattleStringExpandPlaceholdersToDisplayedString(gRefereeStringsTable[gBattlescriptCurrInstr[1]]); - BattlePutTextOnWindow(gDisplayedStringBattle, 0x16); + BattlePutTextOnWindow(gDisplayedStringBattle, 22); break; case VARIOUS_ARENA_WAIT_STRING: - if (IsTextPrinterActive(0x16)) + if (IsTextPrinterActive(22)) return; break; case VARIOUS_WAIT_CRY: @@ -7313,7 +7315,7 @@ static void Cmd_tryconversiontypechange(void) // randomly changes user's type to do { - while ((moveChecked = Random() & 3) >= validMoves); + while ((moveChecked = Random() & (MAX_MON_MOVES - 1)) >= validMoves); moveType = gBattleMoves[gBattleMons[gBattlerAttacker].moves[moveChecked]].type; @@ -8138,7 +8140,7 @@ static void Cmd_trychoosesleeptalkmove(void) do { - movePosition = Random() & 3; + movePosition = Random() & (MAX_MON_MOVES - 1); } while ((gBitTable[movePosition] & unusableMovesBits)); gCalledMove = gBattleMons[gBattlerAttacker].moves[movePosition]; diff --git a/src/battle_util.c b/src/battle_util.c index 6fb307d63..e2dfeef27 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1874,7 +1874,7 @@ bool8 HandleFaintedMonActions(void) gBattleStruct->faintedActionsState++; for (i = 0; i < gBattlersCount; i++) { - if (gAbsentBattlerFlags & gBitTable[i] && !HasNoMonsToSwitch(i, 6, 6)) + if (gAbsentBattlerFlags & gBitTable[i] && !HasNoMonsToSwitch(i, PARTY_SIZE, PARTY_SIZE)) gAbsentBattlerFlags &= ~(gBitTable[i]); } // fall through