From a4e47f12012ef249d8fe25f5e2f391f3dd0a871f Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 21 Jul 2020 13:29:51 -0400 Subject: [PATCH 1/2] Clean some battle_message.c data --- data/battle_scripts_1.s | 18 +++--- data/battle_scripts_2.s | 36 ++++++------ src/battle_message.c | 127 ++++++++++++++++++++++++++-------------- 3 files changed, 111 insertions(+), 70 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3db9f28ffe..273b3d028f 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -798,7 +798,7 @@ BattleScript_KOFail:: BattleScript_EffectRazorWind:: jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn - setbyte sTWOTURN_STRINGID, 0x0 + setbyte sTWOTURN_STRINGID, 0 call BattleScriptFirstChargingTurn goto BattleScript_MoveEnd @@ -1084,7 +1084,7 @@ BattleScript_EffectAccuracyDownHit:: BattleScript_EffectSkyAttack:: jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn - setbyte sTWOTURN_STRINGID, 0x3 + setbyte sTWOTURN_STRINGID, 3 call BattleScriptFirstChargingTurn goto BattleScript_MoveEnd @@ -1831,7 +1831,7 @@ BattleScript_EffectMirrorCoat:: BattleScript_EffectSkullBash:: jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn - setbyte sTWOTURN_STRINGID, 0x2 + setbyte sTWOTURN_STRINGID, 2 call BattleScriptFirstChargingTurn setstatchanger STAT_DEF, 1, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_SkullBashEnd @@ -1927,7 +1927,7 @@ BattleScript_EffectSolarbeam:: BattleScript_SolarbeamDecideTurn:: jumpifstatus2 BS_ATTACKER, STATUS2_MULTIPLETURNS, BattleScript_TwoTurnMovesSecondTurn jumpifword CMP_COMMON_BITS, gHitMarker, HITMARKER_NO_ATTACKSTRING, BattleScript_TwoTurnMovesSecondTurn - setbyte sTWOTURN_STRINGID, 0x1 + setbyte sTWOTURN_STRINGID, 1 call BattleScriptFirstChargingTurn goto BattleScript_MoveEnd BattleScript_SolarbeamOnFirstTurn:: @@ -1996,19 +1996,19 @@ BattleScript_EffectSemiInvulnerable:: jumpifmove MOVE_FLY, BattleScript_FirstTurnFly jumpifmove MOVE_DIVE, BattleScript_FirstTurnDive jumpifmove MOVE_BOUNCE, BattleScript_FirstTurnBounce - setbyte sTWOTURN_STRINGID, 0x5 + setbyte sTWOTURN_STRINGID, 5 goto BattleScript_FirstTurnSemiInvulnerable BattleScript_FirstTurnBounce:: - setbyte sTWOTURN_STRINGID, 0x7 + setbyte sTWOTURN_STRINGID, 7 goto BattleScript_FirstTurnSemiInvulnerable BattleScript_FirstTurnDive:: - setbyte sTWOTURN_STRINGID, 0x6 + setbyte sTWOTURN_STRINGID, 6 goto BattleScript_FirstTurnSemiInvulnerable BattleScript_FirstTurnFly:: - setbyte sTWOTURN_STRINGID, 0x4 + setbyte sTWOTURN_STRINGID, 4 BattleScript_FirstTurnSemiInvulnerable:: call BattleScriptFirstChargingTurn setsemiinvulnerablebit @@ -3252,7 +3252,7 @@ BattleScript_SunlightFaded:: end2 BattleScript_OverworldWeatherStarts:: - printfromtable gWeatherContinuesStringIds + printfromtable gWeatherStartsStringIds waitmessage 0x40 playanimation2 BS_ATTACKER, sB_ANIM_ARG1, NULL end3 diff --git a/data/battle_scripts_2.s b/data/battle_scripts_2.s index b74f557a7c..316b4df25b 100644 --- a/data/battle_scripts_2.s +++ b/data/battle_scripts_2.s @@ -13,28 +13,28 @@ .align 2 gBattlescriptsForBallThrow:: @ 82DBD08 - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_SafariBallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow - .4byte BattleScript_BallThrow + .4byte BattleScript_BallThrow @ ITEM_NONE + .4byte BattleScript_BallThrow @ ITEM_MASTER_BALL + .4byte BattleScript_BallThrow @ ITEM_ULTRA_BALL + .4byte BattleScript_BallThrow @ ITEM_GREAT_BALL + .4byte BattleScript_BallThrow @ ITEM_POKE_BALL + .4byte BattleScript_SafariBallThrow @ ITEM_SAFARI_BALL + .4byte BattleScript_BallThrow @ ITEM_NET_BALL + .4byte BattleScript_BallThrow @ ITEM_DIVE_BALL + .4byte BattleScript_BallThrow @ ITEM_NEST_BALL + .4byte BattleScript_BallThrow @ ITEM_REPEAT_BALL + .4byte BattleScript_BallThrow @ ITEM_TIMER_BALL + .4byte BattleScript_BallThrow @ ITEM_LUXURY_BALL + .4byte BattleScript_BallThrow @ ITEM_PREMIER_BALL .align 2 gBattlescriptsForUsingItem:: @ 82DBD3C .4byte BattleScript_PlayerUsesItem - .4byte BattleScript_OpponentUsesHealItem - .4byte BattleScript_OpponentUsesHealItem - .4byte BattleScript_OpponentUsesStatusCureItem - .4byte BattleScript_OpponentUsesXItem - .4byte BattleScript_OpponentUsesGuardSpecs + .4byte BattleScript_OpponentUsesHealItem @ AI_ITEM_FULL_RESTORE + .4byte BattleScript_OpponentUsesHealItem @ AI_ITEM_HEAL_HP + .4byte BattleScript_OpponentUsesStatusCureItem @ AI_ITEM_CURE_CONDITION + .4byte BattleScript_OpponentUsesXItem @ AI_ITEM_X_STAT + .4byte BattleScript_OpponentUsesGuardSpecs @ AI_ITEM_GUARD_SPECS .align 2 gBattlescriptsForRunningByItem:: @ 82DBD54 diff --git a/src/battle_message.c b/src/battle_message.c index 2a0ba4ded3..cc43d1656e 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -19,12 +19,15 @@ #include "text.h" #include "trainer_hill.h" #include "window.h" +#include "constants/battle_dome.h" #include "constants/battle_string_ids.h" +#include "constants/berry.h" #include "constants/frontier_util.h" #include "constants/items.h" #include "constants/moves.h" #include "constants/trainers.h" #include "constants/trainer_hill.h" +#include "constants/weather.h" struct BattleWindowText { @@ -433,11 +436,16 @@ static const u8 sText_SpDef2[] = _("SP. DEF"); static const u8 sText_Accuracy[] = _("accuracy"); static const u8 sText_Evasiveness[] = _("evasiveness"); -const u8 * const gStatNamesTable[] = +const u8 * const gStatNamesTable[NUM_BATTLE_STATS] = { - sText_HP2, sText_Attack2, sText_Defense2, - sText_Speed, sText_SpAtk2, sText_SpDef2, - sText_Accuracy, sText_Evasiveness + [STAT_HP] = sText_HP2, + [STAT_ATK] = sText_Attack2, + [STAT_DEF] = sText_Defense2, + [STAT_SPEED] = sText_Speed, + [STAT_SPATK] = sText_SpAtk2, + [STAT_SPDEF] = sText_SpDef2, + [STAT_ACC] = sText_Accuracy, + [STAT_EVASION] = sText_Evasiveness }; static const u8 sText_PokeblockWasTooSpicy[] = _("was too spicy!"); @@ -446,11 +454,13 @@ static const u8 sText_PokeblockWasTooSweet[] = _("was too sweet!"); static const u8 sText_PokeblockWasTooBitter[] = _("was too bitter!"); static const u8 sText_PokeblockWasTooSour[] = _("was too sour!"); -const u8 * const gPokeblockWasTooXStringTable[] = +const u8 * const gPokeblockWasTooXStringTable[FLAVOR_COUNT] = { - sText_PokeblockWasTooSpicy, sText_PokeblockWasTooDry, - sText_PokeblockWasTooSweet, sText_PokeblockWasTooBitter, - sText_PokeblockWasTooSour + [FLAVOR_SPICY] = sText_PokeblockWasTooSpicy, + [FLAVOR_DRY] = sText_PokeblockWasTooDry, + [FLAVOR_SWEET] = sText_PokeblockWasTooSweet, + [FLAVOR_BITTER] = sText_PokeblockWasTooBitter, + [FLAVOR_SOUR] = sText_PokeblockWasTooSour }; static const u8 sText_PlayerUsedItem[] = _("{B_PLAYER_NAME} used\n{B_LAST_ITEM}!"); @@ -979,16 +989,28 @@ const u16 gStatDownStringIds[] = STRINGID_PKMNSSTATCHANGED3, STRINGID_PKMNSSTATCHANGED4, STRINGID_STATSWONTDECREASE, STRINGID_EMPTYSTRING3 }; +// Index read from sTWOTURN_STRINGID const u16 gFirstTurnOfTwoStringIds[] = { - STRINGID_PKMNWHIPPEDWHIRLWIND, STRINGID_PKMNTOOKSUNLIGHT, STRINGID_PKMNLOWEREDHEAD, STRINGID_PKMNISGLOWING, - STRINGID_PKMNFLEWHIGH, STRINGID_PKMNDUGHOLE, STRINGID_PKMNHIDUNDERWATER, STRINGID_PKMNSPRANGUP + STRINGID_PKMNWHIPPEDWHIRLWIND, // MOVE_RAZOR_WIND + STRINGID_PKMNTOOKSUNLIGHT, // MOVE_SOLAR_BEAM + STRINGID_PKMNLOWEREDHEAD, // MOVE_SKULL_BASH + STRINGID_PKMNISGLOWING, // MOVE_SKY_ATTACK + STRINGID_PKMNFLEWHIGH, // MOVE_FLY + STRINGID_PKMNDUGHOLE, // MOVE_DIG + STRINGID_PKMNHIDUNDERWATER, // MOVE_DIVE + STRINGID_PKMNSPRANGUP // MOVE_BOUNCE }; +// Index copied from move's index in gTrappingMoves const u16 gWrappedStringIds[] = { - STRINGID_PKMNSQUEEZEDBYBIND, STRINGID_PKMNWRAPPEDBY, STRINGID_PKMNTRAPPEDINVORTEX, - STRINGID_PKMNCLAMPED, STRINGID_PKMNTRAPPEDINVORTEX, STRINGID_PKMNTRAPPEDBYSANDTOMB + STRINGID_PKMNSQUEEZEDBYBIND, // MOVE_BIND + STRINGID_PKMNWRAPPEDBY, // MOVE_WRAP + STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_FIRE_SPIN + STRINGID_PKMNCLAMPED, // MOVE_CLAMP + STRINGID_PKMNTRAPPEDINVORTEX, // MOVE_WHIRLPOOL + STRINGID_PKMNTRAPPEDBYSANDTOMB // MOVE_SAND_TOMB }; const u16 gMistUsedStringIds[] = @@ -1078,13 +1100,25 @@ const u16 gBallEscapeStringIds[] = STRINGID_PKMNBROKEFREE, STRINGID_ITAPPEAREDCAUGHT, STRINGID_AARGHALMOSTHADIT, STRINGID_SHOOTSOCLOSE }; -const u16 gWeatherContinuesStringIds[] = +// Overworld weathers that don't have an associated battle weather default to "It is raining." +const u16 gWeatherStartsStringIds[] = { - STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_ITISRAINING, - STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_ITISRAINING, - STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_SANDSTORMISRAGING, - STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_ITISRAINING, - STRINGID_SUNLIGHTSTRONG, STRINGID_ITISRAINING, STRINGID_ITISRAINING, STRINGID_ITISRAINING + [WEATHER_NONE] = STRINGID_ITISRAINING, + [WEATHER_SUNNY_CLOUDS] = STRINGID_ITISRAINING, + [WEATHER_SUNNY] = STRINGID_ITISRAINING, + [WEATHER_RAIN] = STRINGID_ITISRAINING, + [WEATHER_SNOW] = STRINGID_ITISRAINING, + [WEATHER_RAIN_THUNDERSTORM] = STRINGID_ITISRAINING, + [WEATHER_FOG_HORIZONTAL] = STRINGID_ITISRAINING, + [WEATHER_VOLCANIC_ASH] = STRINGID_ITISRAINING, + [WEATHER_SANDSTORM] = STRINGID_SANDSTORMISRAGING, + [WEATHER_FOG_DIAGONAL] = STRINGID_ITISRAINING, + [WEATHER_UNDERWATER] = STRINGID_ITISRAINING, + [WEATHER_SHADE] = STRINGID_ITISRAINING, + [WEATHER_DROUGHT] = STRINGID_SUNLIGHTSTRONG, + [WEATHER_DOWNPOUR] = STRINGID_ITISRAINING, + [WEATHER_UNDERWATER_BUBBLES] = STRINGID_ITISRAINING, + [WEATHER_ABNORMAL] = STRINGID_ITISRAINING }; const u16 gInobedientStringIds[] = @@ -1146,7 +1180,13 @@ const u16 gCaughtMonStringIds[] = const u16 gTrappingMoves[] = { - MOVE_BIND, MOVE_WRAP, MOVE_FIRE_SPIN, MOVE_CLAMP, MOVE_WHIRLPOOL, MOVE_SAND_TOMB, 0xFFFF + MOVE_BIND, + MOVE_WRAP, + MOVE_FIRE_SPIN, + MOVE_CLAMP, + MOVE_WHIRLPOOL, + MOVE_SAND_TOMB, + 0xFFFF }; const u8 gText_PkmnIsEvolving[] = _("What?\n{STR_VAR_1} is evolving!"); @@ -1207,26 +1247,27 @@ const u8 gText_Draw[] = _("{HIGHLIGHT TRANSPARENT}Draw"); static const u8 sText_SpaceIs[] = _(" is"); static const u8 sText_ApostropheS[] = _("'s"); -static const u8 sATypeMove_Table[][17] = +// For displaying names of invalid moves +static const u8 sATypeMove_Table[][NUMBER_OF_MON_TYPES - 1] = { - _("a NORMAL move"), - _("a FIGHTING move"), - _("a FLYING move"), - _("a POISON move"), - _("a GROUND move"), - _("a ROCK move"), - _("a BUG move"), - _("a GHOST move"), - _("a STEEL move"), - _("a ??? move"), - _("a FIRE move"), - _("a WATER move"), - _("a GRASS move"), - _("an ELECTRIC move"), - _("a PSYCHIC move"), - _("an ICE move"), - _("a DRAGON move"), - _("a DARK move") + [TYPE_NORMAL] = _("a NORMAL move"), + [TYPE_FIGHTING] = _("a FIGHTING move"), + [TYPE_FLYING] = _("a FLYING move"), + [TYPE_POISON] = _("a POISON move"), + [TYPE_GROUND] = _("a GROUND move"), + [TYPE_ROCK] = _("a ROCK move"), + [TYPE_BUG] = _("a BUG move"), + [TYPE_GHOST] = _("a GHOST move"), + [TYPE_STEEL] = _("a STEEL move"), + [TYPE_MYSTERY] = _("a ??? move"), + [TYPE_FIRE] = _("a FIRE move"), + [TYPE_WATER] = _("a WATER move"), + [TYPE_GRASS] = _("a GRASS move"), + [TYPE_ELECTRIC] = _("an ELECTRIC move"), + [TYPE_PSYCHIC] = _("a PSYCHIC move"), + [TYPE_ICE] = _("an ICE move"), + [TYPE_DRAGON] = _("a DRAGON move"), + [TYPE_DARK] = _("a DARK move") }; const u8 gText_BattleTourney[] = _("BATTLE TOURNEY"); @@ -1235,12 +1276,12 @@ static const u8 sText_Round2[] = _("Round 2"); static const u8 sText_Semifinal[] = _("Semifinal"); static const u8 sText_Final[] = _("Final"); -const u8 *const gRoundsStringTable[] = +const u8 *const gRoundsStringTable[DOME_ROUNDS_COUNT] = { - sText_Round1, - sText_Round2, - sText_Semifinal, - sText_Final + [DOME_ROUND1] = sText_Round1, + [DOME_ROUND2] = sText_Round2, + [DOME_SEMIFINAL] = sText_Semifinal, + [DOME_FINAL] = sText_Final }; const u8 gText_TheGreatNewHope[] = _("The great new hope!\p"); From 5e8ffff62f6d4c7e4e2b62852eec14c086dc488e Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 4 Aug 2020 20:33:05 -0400 Subject: [PATCH 2/2] Add stat stage constants --- data/battle_ai_scripts.s | 108 +++++++++++++++++------------------ data/battle_scripts_1.s | 56 +++++++++--------- include/constants/pokemon.h | 4 ++ include/pokemon.h | 2 +- src/battle_ai_switch_items.c | 4 +- src/battle_main.c | 6 +- src/battle_message.c | 16 +++--- src/battle_script_commands.c | 44 +++++++------- src/battle_tv.c | 4 +- src/battle_util.c | 36 +++++++----- src/pokemon.c | 50 ++++++++-------- 11 files changed, 170 insertions(+), 160 deletions(-) diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index e33ba431da..1c7bff51c8 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -249,64 +249,64 @@ AI_CBM_BellyDrum: @ 82DC341 if_hp_less_than AI_USER, 51, Score_Minus10 AI_CBM_AttackUp: @ 82DC348 - if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10 + if_stat_level_equal AI_USER, STAT_ATK, MAX_STAT_STAGE, Score_Minus10 end AI_CBM_DefenseUp: @ 82DC351 - if_stat_level_equal AI_USER, STAT_DEF, 12, Score_Minus10 + if_stat_level_equal AI_USER, STAT_DEF, MAX_STAT_STAGE, Score_Minus10 end AI_CBM_SpeedUp: @ 82DC35A - if_stat_level_equal AI_USER, STAT_SPEED, 12, Score_Minus10 + if_stat_level_equal AI_USER, STAT_SPEED, MAX_STAT_STAGE, Score_Minus10 end AI_CBM_SpAtkUp: @ 82DC363 - if_stat_level_equal AI_USER, STAT_SPATK, 12, Score_Minus10 + if_stat_level_equal AI_USER, STAT_SPATK, MAX_STAT_STAGE, Score_Minus10 end AI_CBM_SpDefUp: @ 82DC36C - if_stat_level_equal AI_USER, STAT_SPDEF, 12, Score_Minus10 + if_stat_level_equal AI_USER, STAT_SPDEF, MAX_STAT_STAGE, Score_Minus10 end AI_CBM_AccUp: @ 82DC375 - if_stat_level_equal AI_USER, STAT_ACC, 12, Score_Minus10 + if_stat_level_equal AI_USER, STAT_ACC, MAX_STAT_STAGE, Score_Minus10 end AI_CBM_EvasionUp: @ 82DC37E - if_stat_level_equal AI_USER, STAT_EVASION, 12, Score_Minus10 + if_stat_level_equal AI_USER, STAT_EVASION, MAX_STAT_STAGE, Score_Minus10 end AI_CBM_AttackDown: @ 82DC387 - if_stat_level_equal AI_TARGET, STAT_ATK, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_ATK, MIN_STAT_STAGE, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_HYPER_CUTTER, Score_Minus10 goto CheckIfAbilityBlocksStatChange AI_CBM_DefenseDown: @ 82DC39C - if_stat_level_equal AI_TARGET, STAT_DEF, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_DEF, MIN_STAT_STAGE, Score_Minus10 goto CheckIfAbilityBlocksStatChange AI_CBM_SpeedDown: @ 82DC3A9 - if_stat_level_equal AI_TARGET, STAT_SPEED, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_SPEED, MIN_STAT_STAGE, Score_Minus10 if_ability AI_TARGET, ABILITY_SPEED_BOOST, Score_Minus10 goto CheckIfAbilityBlocksStatChange AI_CBM_SpAtkDown: @ 82DC3BF - if_stat_level_equal AI_TARGET, STAT_SPATK, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_SPATK, MIN_STAT_STAGE, Score_Minus10 goto CheckIfAbilityBlocksStatChange AI_CBM_SpDefDown: @ 82DC3CC - if_stat_level_equal AI_TARGET, STAT_SPDEF, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_SPDEF, MIN_STAT_STAGE, Score_Minus10 goto CheckIfAbilityBlocksStatChange AI_CBM_AccDown: @ 82DC3D9 - if_stat_level_equal AI_TARGET, STAT_ACC, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_ACC, MIN_STAT_STAGE, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_KEEN_EYE, Score_Minus10 goto CheckIfAbilityBlocksStatChange AI_CBM_EvasionDown: @ 82DC3EE - if_stat_level_equal AI_TARGET, STAT_EVASION, 0, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_EVASION, MIN_STAT_STAGE, Score_Minus10 CheckIfAbilityBlocksStatChange: @ 82DC3F6 get_ability AI_TARGET @@ -315,20 +315,20 @@ CheckIfAbilityBlocksStatChange: @ 82DC3F6 end AI_CBM_Haze: @ 82DC405 - if_stat_level_less_than AI_USER, STAT_ATK, 6, AI_CBM_Haze_End - if_stat_level_less_than AI_USER, STAT_DEF, 6, AI_CBM_Haze_End - if_stat_level_less_than AI_USER, STAT_SPEED, 6, AI_CBM_Haze_End - if_stat_level_less_than AI_USER, STAT_SPATK, 6, AI_CBM_Haze_End - if_stat_level_less_than AI_USER, STAT_SPDEF, 6, AI_CBM_Haze_End - if_stat_level_less_than AI_USER, STAT_ACC, 6, AI_CBM_Haze_End - if_stat_level_less_than AI_USER, STAT_EVASION, 6, AI_CBM_Haze_End - if_stat_level_more_than AI_TARGET, STAT_ATK, 6, AI_CBM_Haze_End - if_stat_level_more_than AI_TARGET, STAT_DEF, 6, AI_CBM_Haze_End - if_stat_level_more_than AI_TARGET, STAT_SPEED, 6, AI_CBM_Haze_End - if_stat_level_more_than AI_TARGET, STAT_SPATK, 6, AI_CBM_Haze_End - if_stat_level_more_than AI_TARGET, STAT_SPDEF, 6, AI_CBM_Haze_End - if_stat_level_more_than AI_TARGET, STAT_ACC, 6, AI_CBM_Haze_End - if_stat_level_more_than AI_TARGET, STAT_EVASION, 6, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_ATK, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_DEF, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_SPEED, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_SPATK, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_SPDEF, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_ACC, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_less_than AI_USER, STAT_EVASION, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_ATK, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_DEF, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_SPEED, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_SPATK, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_SPDEF, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_ACC, DEFAULT_STAT_STAGE, AI_CBM_Haze_End + if_stat_level_more_than AI_TARGET, STAT_EVASION, DEFAULT_STAT_STAGE, AI_CBM_Haze_End goto Score_Minus10 AI_CBM_Haze_End: @ 82DC47A @@ -436,8 +436,8 @@ AI_CBM_CantEscape: @ 82DC5B0 end AI_CBM_Curse: @ 82DC5BB - if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10 - if_stat_level_equal AI_USER, STAT_DEF, 12, Score_Minus8 + if_stat_level_equal AI_USER, STAT_ATK, MAX_STAT_STAGE, Score_Minus10 + if_stat_level_equal AI_USER, STAT_DEF, MAX_STAT_STAGE, Score_Minus8 end AI_CBM_Spikes: @ 82DC5CC @@ -484,8 +484,8 @@ AI_CBM_Safeguard: @ 82DC635 end AI_CBM_Memento: @ 82DC640 - if_stat_level_equal AI_TARGET, STAT_ATK, 0, Score_Minus10 - if_stat_level_equal AI_TARGET, STAT_SPATK, 0, Score_Minus8 + if_stat_level_equal AI_TARGET, STAT_ATK, MIN_STAT_STAGE, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_SPATK, MIN_STAT_STAGE, Score_Minus8 AI_CBM_BatonPass: @ 82DC650 count_usable_party_mons AI_USER @@ -574,18 +574,18 @@ AI_CBM_MudSport: @ 82DC71E end AI_CBM_Tickle: @ 82DC729 - if_stat_level_equal AI_TARGET, STAT_ATK, 0, Score_Minus10 - if_stat_level_equal AI_TARGET, STAT_DEF, 0, Score_Minus8 + if_stat_level_equal AI_TARGET, STAT_ATK, MIN_STAT_STAGE, Score_Minus10 + if_stat_level_equal AI_TARGET, STAT_DEF, MIN_STAT_STAGE, Score_Minus8 end AI_CBM_CosmicPower: @ 82DC73A - if_stat_level_equal AI_USER, STAT_DEF, 12, Score_Minus10 - if_stat_level_equal AI_USER, STAT_SPDEF, 12, Score_Minus8 + if_stat_level_equal AI_USER, STAT_DEF, MAX_STAT_STAGE, Score_Minus10 + if_stat_level_equal AI_USER, STAT_SPDEF, MAX_STAT_STAGE, Score_Minus8 end AI_CBM_BulkUp: @ 82DC74B - if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10 - if_stat_level_equal AI_USER, STAT_DEF, 12, Score_Minus8 + if_stat_level_equal AI_USER, STAT_ATK, MAX_STAT_STAGE, Score_Minus10 + if_stat_level_equal AI_USER, STAT_DEF, MAX_STAT_STAGE, Score_Minus8 end AI_CBM_WaterSport: @ 82DC75C @@ -593,13 +593,13 @@ AI_CBM_WaterSport: @ 82DC75C end AI_CBM_CalmMind: @ 82DC767 - if_stat_level_equal AI_USER, STAT_SPATK, 12, Score_Minus10 - if_stat_level_equal AI_USER, STAT_SPDEF, 12, Score_Minus8 + if_stat_level_equal AI_USER, STAT_SPATK, MAX_STAT_STAGE, Score_Minus10 + if_stat_level_equal AI_USER, STAT_SPDEF, MAX_STAT_STAGE, Score_Minus8 end AI_CBM_DragonDance: @ 82DC778 - if_stat_level_equal AI_USER, STAT_ATK, 12, Score_Minus10 - if_stat_level_equal AI_USER, STAT_SPEED, 12, Score_Minus8 + if_stat_level_equal AI_USER, STAT_ATK, MAX_STAT_STAGE, Score_Minus10 + if_stat_level_equal AI_USER, STAT_SPEED, MAX_STAT_STAGE, Score_Minus8 end Score_Minus1: @@ -1101,7 +1101,7 @@ AI_CV_EvasionUp7: AI_CV_EvasionUp8: if_hp_more_than AI_USER, 70, AI_CV_EvasionUp_End - if_stat_level_equal AI_USER, STAT_EVASION, 6, AI_CV_EvasionUp_End + if_stat_level_equal AI_USER, STAT_EVASION, DEFAULT_STAT_STAGE, AI_CV_EvasionUp_End if_hp_less_than AI_USER, 40, AI_CV_EvasionUp_ScoreDown2 if_hp_less_than AI_TARGET, 40, AI_CV_EvasionUp_ScoreDown2 if_random_less_than 70, AI_CV_EvasionUp_End @@ -1130,7 +1130,7 @@ AI_CV_AlwaysHit_End: end AI_CV_AttackDown: @ 82DCDF8 - if_stat_level_equal AI_TARGET, STAT_ATK, 6, AI_CV_AttackDown3 + if_stat_level_equal AI_TARGET, STAT_ATK, DEFAULT_STAT_STAGE, AI_CV_AttackDown3 score -1 if_hp_more_than AI_USER, 90, AI_CV_AttackDown2 score -1 @@ -1198,7 +1198,7 @@ AI_CV_SpeedDown_End: @ 82DCE96 end AI_CV_SpAtkDown: - if_stat_level_equal AI_TARGET, STAT_ATK, 6, AI_CV_SpAtkDown3 + if_stat_level_equal AI_TARGET, STAT_ATK, DEFAULT_STAT_STAGE, AI_CV_SpAtkDown3 score -1 if_hp_more_than AI_USER, 90, AI_CV_SpAtkDown2 score -1 @@ -1284,7 +1284,7 @@ AI_CV_AccuracyDown7: AI_CV_AccuracyDown8: if_hp_more_than AI_USER, 70, AI_CV_AccuracyDown_End - if_stat_level_equal AI_TARGET, STAT_ACC, 6, AI_CV_AccuracyDown_End + if_stat_level_equal AI_TARGET, STAT_ACC, DEFAULT_STAT_STAGE, AI_CV_AccuracyDown_End if_hp_less_than AI_USER, 40, AI_CV_AccuracyDown_ScoreDown2 if_hp_less_than AI_TARGET, 40, AI_CV_AccuracyDown_ScoreDown2 if_random_less_than 70, AI_CV_AccuracyDown_End @@ -1997,7 +1997,7 @@ AI_CV_Curse2: score +1 AI_CV_Curse3: - if_stat_level_more_than AI_USER, STAT_DEF, 6, AI_CV_Curse_End + if_stat_level_more_than AI_USER, STAT_DEF, DEFAULT_STAT_STAGE, AI_CV_Curse_End if_random_less_than 128, AI_CV_Curse_End score +1 goto AI_CV_Curse_End @@ -2518,7 +2518,7 @@ AI_CV_ChangeSelfAbility_AbilitiesToEncourage: AI_CV_Superpower: if_type_effectiveness AI_EFFECTIVENESS_x0_25, AI_CV_Superpower_ScoreDown1 if_type_effectiveness AI_EFFECTIVENESS_x0_5, AI_CV_Superpower_ScoreDown1 - if_stat_level_less_than AI_USER, STAT_ATK, 6, AI_CV_Superpower_ScoreDown1 + if_stat_level_less_than AI_USER, STAT_ATK, DEFAULT_STAT_STAGE, AI_CV_Superpower_ScoreDown1 if_target_faster AI_CV_Superpower2 if_hp_more_than AI_USER, 40, AI_CV_Superpower_ScoreDown1 goto AI_CV_Superpower_End @@ -2933,12 +2933,12 @@ sMovesTable_ProtectMoves: AI_PreferBatonPass_EncourageIfHighStats: get_turn_count if_equal 0, Score_Minus2 - if_stat_level_more_than AI_USER, STAT_ATK, 8, Score_Plus3 - if_stat_level_more_than AI_USER, STAT_ATK, 7, Score_Plus2 - if_stat_level_more_than AI_USER, STAT_ATK, 6, Score_Plus1 - if_stat_level_more_than AI_USER, STAT_SPATK, 8, Score_Plus3 - if_stat_level_more_than AI_USER, STAT_SPATK, 7, Score_Plus2 - if_stat_level_more_than AI_USER, STAT_SPATK, 6, Score_Plus1 + if_stat_level_more_than AI_USER, STAT_ATK, DEFAULT_STAT_STAGE + 2, Score_Plus3 + if_stat_level_more_than AI_USER, STAT_ATK, DEFAULT_STAT_STAGE + 1, Score_Plus2 + if_stat_level_more_than AI_USER, STAT_ATK, DEFAULT_STAT_STAGE, Score_Plus1 + if_stat_level_more_than AI_USER, STAT_SPATK, DEFAULT_STAT_STAGE + 2, Score_Plus3 + if_stat_level_more_than AI_USER, STAT_SPATK, DEFAULT_STAT_STAGE + 1, Score_Plus2 + if_stat_level_more_than AI_USER, STAT_SPATK, DEFAULT_STAT_STAGE, Score_Plus1 end AI_PreferBatonPassEnd: diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 273b3d028f..f0c0a7ea85 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1504,9 +1504,9 @@ BattleScript_EffectCurse:: attackcanceler attackstring ppreduce - jumpifstat BS_ATTACKER, CMP_GREATER_THAN, STAT_SPEED, 0x0, BattleScript_CurseTrySpeed - jumpifstat BS_ATTACKER, CMP_NOT_EQUAL, STAT_ATK, 0xC, BattleScript_CurseTrySpeed - jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_DEF, 0xC, BattleScript_ButItFailed + jumpifstat BS_ATTACKER, CMP_GREATER_THAN, STAT_SPEED, MIN_STAT_STAGE, BattleScript_CurseTrySpeed + jumpifstat BS_ATTACKER, CMP_NOT_EQUAL, STAT_ATK, MAX_STAT_STAGE, BattleScript_CurseTrySpeed + jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_DEF, MAX_STAT_STAGE, BattleScript_ButItFailed BattleScript_CurseTrySpeed:: copybyte gBattlerTarget, gBattlerAttacker setbyte sB_ANIM_TURN, 0x1 @@ -2670,8 +2670,8 @@ BattleScript_EffectTickle:: attackcanceler attackstring ppreduce - jumpifstat BS_TARGET, CMP_GREATER_THAN, STAT_ATK, 0x0, BattleScript_TickleDoMoveAnim - jumpifstat BS_TARGET, CMP_EQUAL, STAT_DEF, 0x0, BattleScript_CantLowerMultipleStats + jumpifstat BS_TARGET, CMP_GREATER_THAN, STAT_ATK, MIN_STAT_STAGE, BattleScript_TickleDoMoveAnim + jumpifstat BS_TARGET, CMP_EQUAL, STAT_DEF, MIN_STAT_STAGE, BattleScript_CantLowerMultipleStats BattleScript_TickleDoMoveAnim:: accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE attackanimation @@ -2705,8 +2705,8 @@ BattleScript_EffectCosmicPower:: attackcanceler attackstring ppreduce - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_DEF, 0xC, BattleScript_CosmicPowerDoMoveAnim - jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, 0xC, BattleScript_CantRaiseMultipleStats + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_DEF, MAX_STAT_STAGE, BattleScript_CosmicPowerDoMoveAnim + jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_CantRaiseMultipleStats BattleScript_CosmicPowerDoMoveAnim:: attackanimation waitanimation @@ -2734,8 +2734,8 @@ BattleScript_EffectBulkUp:: attackcanceler attackstring ppreduce - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_ATK, 0xC, BattleScript_BulkUpDoMoveAnim - jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_DEF, 0xC, BattleScript_CantRaiseMultipleStats + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_BulkUpDoMoveAnim + jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_DEF, MAX_STAT_STAGE, BattleScript_CantRaiseMultipleStats BattleScript_BulkUpDoMoveAnim:: attackanimation waitanimation @@ -2759,8 +2759,8 @@ BattleScript_EffectCalmMind:: attackcanceler attackstring ppreduce - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, 0xC, BattleScript_CalmMindDoMoveAnim - jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, 0xC, BattleScript_CantRaiseMultipleStats + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, MAX_STAT_STAGE, BattleScript_CalmMindDoMoveAnim + jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, MAX_STAT_STAGE, BattleScript_CantRaiseMultipleStats BattleScript_CalmMindDoMoveAnim:: attackanimation waitanimation @@ -2791,8 +2791,8 @@ BattleScript_EffectDragonDance:: attackcanceler attackstring ppreduce - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_ATK, 0xC, BattleScript_DragonDanceDoMoveAnim - jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPEED, 0xC, BattleScript_CantRaiseMultipleStats + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_DragonDanceDoMoveAnim + jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPEED, MAX_STAT_STAGE, BattleScript_CantRaiseMultipleStats BattleScript_DragonDanceDoMoveAnim:: attackanimation waitanimation @@ -3047,13 +3047,13 @@ BattleScript_FrontierTrainerBattleWon_LoseTexts: trainerslidein BS_ATTACKER waitstate printstring STRINGID_TRAINER1LOSETEXT - jumpifnotbattletype BATTLE_TYPE_TWO_OPPONENTS, BattleScript_82DAACB + jumpifnotbattletype BATTLE_TYPE_TWO_OPPONENTS, BattleScript_TryPickUpItems trainerslideout B_POSITION_OPPONENT_LEFT waitstate trainerslidein BS_FAINTED waitstate printstring STRINGID_TRAINER2LOSETEXT -BattleScript_82DAACB: +BattleScript_TryPickUpItems: jumpifnotbattletype BATTLE_TYPE_PYRAMID, BattleScript_FrontierTrainerBattleWon_End pickup BattleScript_FrontierTrainerBattleWon_End: @@ -3462,11 +3462,11 @@ BattleScript_PerishSongCountGoesDown:: end2 BattleScript_AllStatsUp:: - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_ATK, 0xC, BattleScript_AllStatsUpAtk - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_DEF, 0xC, BattleScript_AllStatsUpAtk - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPEED, 0xC, BattleScript_AllStatsUpAtk - jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, 0xC, BattleScript_AllStatsUpAtk - jumpifstat BS_ATTACKER, CMP_EQUAL, STAT_SPDEF, 0xC, BattleScript_AllStatsUpRet + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_AllStatsUpAtk + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_DEF, MAX_STAT_STAGE, BattleScript_AllStatsUpAtk + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPEED, MAX_STAT_STAGE, BattleScript_AllStatsUpAtk + jumpifstat BS_ATTACKER, CMP_LESS_THAN, STAT_SPATK, MAX_STAT_STAGE, BattleScript_AllStatsUpAtk + 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 @@ -3638,18 +3638,18 @@ BattleScript_AtkDefDown:: playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_ATK, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE | STAT_CHANGE_MULTIPLE_STATS playstatchangeanimation BS_ATTACKER, BIT_ATK, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE setstatchanger STAT_ATK, 1, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | STAT_BUFF_ALLOW_PTR, BattleScript_82DB144 - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DB144 + statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | STAT_BUFF_ALLOW_PTR, BattleScript_AtkDefDown_TryDef + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_AtkDefDown_TryDef printfromtable gStatDownStringIds waitmessage 0x40 -BattleScript_82DB144:: +BattleScript_AtkDefDown_TryDef:: playstatchangeanimation BS_ATTACKER, BIT_DEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE setstatchanger STAT_DEF, 1, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | STAT_BUFF_ALLOW_PTR, BattleScript_82DB167 - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_82DB167 + statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | STAT_BUFF_ALLOW_PTR, BattleScript_AtkDefDown_End + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_AtkDefDown_End printfromtable gStatDownStringIds waitmessage 0x40 -BattleScript_82DB167:: +BattleScript_AtkDefDown_End:: return BattleScript_KnockedOff:: @@ -4017,10 +4017,10 @@ BattleScript_WeatherFormChangesLoop:: return BattleScript_CastformChange:: - call BattleScript_82DB4AF + call BattleScript_DoCastformChange end3 -BattleScript_82DB4AF:: +BattleScript_DoCastformChange:: docastformchangeanimation waitstate printstring STRINGID_PKMNTRANSFORMED diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 0d8fc6a571..286726838b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -84,6 +84,10 @@ #define NUM_NATURE_STATS NUM_STATS - 1 // excludes HP #define NUM_BATTLE_STATS NUM_STATS + 2 // includes Accuracy and Evasion +#define MIN_STAT_STAGE 0 +#define DEFAULT_STAT_STAGE 6 +#define MAX_STAT_STAGE 12 + // Shiny odds #define SHINY_ODDS 8 // Actual probability is SHINY_ODDS/65536 diff --git a/include/pokemon.h b/include/pokemon.h index 69ef7a142b..d75ec94f30 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -254,7 +254,7 @@ extern const u16 *const gLevelUpLearnsets[]; extern const u8 gPPUpGetMask[]; extern const u8 gPPUpSetMask[]; extern const u8 gPPUpAddMask[]; -extern const u8 gStatStageRatios[][2]; +extern const u8 gStatStageRatios[MAX_STAT_STAGE + 1][2]; extern const u16 gLinkPlayerFacilityClasses[]; extern const struct SpriteTemplate gUnknown_08329D98[]; extern const s8 gNatureStatTable[][5]; diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 32f9620b7d..2a5a83e0d7 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -314,8 +314,8 @@ static bool8 AreStatsRaised(void) for (i = 0; i < NUM_BATTLE_STATS; i++) { - if (gBattleMons[gActiveBattler].statStages[i] > 6) - buffedStatsValue += gBattleMons[gActiveBattler].statStages[i] - 6; + if (gBattleMons[gActiveBattler].statStages[i] > DEFAULT_STAT_STAGE) + buffedStatsValue += gBattleMons[gActiveBattler].statStages[i] - DEFAULT_STAT_STAGE; } return (buffedStatsValue > 3); diff --git a/src/battle_main.c b/src/battle_main.c index 1d8aeab539..b8ebda9e47 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3135,7 +3135,7 @@ void SwitchInClearSetData(void) if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS) { for (i = 0; i < NUM_BATTLE_STATS; i++) - gBattleMons[gActiveBattler].statStages[i] = 6; + gBattleMons[gActiveBattler].statStages[i] = DEFAULT_STAT_STAGE; for (i = 0; i < gBattlersCount; i++) { if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].battlerPreventingEscape == gActiveBattler) @@ -3244,7 +3244,7 @@ void FaintClearSetData(void) u8 *ptr; for (i = 0; i < NUM_BATTLE_STATS; i++) - gBattleMons[gActiveBattler].statStages[i] = 6; + gBattleMons[gActiveBattler].statStages[i] = DEFAULT_STAT_STAGE; gBattleMons[gActiveBattler].status2 = 0; gStatuses3[gActiveBattler] = 0; @@ -3398,7 +3398,7 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)]; *hpOnSwitchout = gBattleMons[gActiveBattler].hp; for (i = 0; i < NUM_BATTLE_STATS; i++) - gBattleMons[gActiveBattler].statStages[i] = 6; + gBattleMons[gActiveBattler].statStages[i] = DEFAULT_STAT_STAGE; gBattleMons[gActiveBattler].status2 = 0; } diff --git a/src/battle_message.c b/src/battle_message.c index cc43d1656e..2fba578dc0 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -438,14 +438,14 @@ static const u8 sText_Evasiveness[] = _("evasiveness"); const u8 * const gStatNamesTable[NUM_BATTLE_STATS] = { - [STAT_HP] = sText_HP2, - [STAT_ATK] = sText_Attack2, + [STAT_HP] = sText_HP2, + [STAT_ATK] = sText_Attack2, [STAT_DEF] = sText_Defense2, - [STAT_SPEED] = sText_Speed, - [STAT_SPATK] = sText_SpAtk2, + [STAT_SPEED] = sText_Speed, + [STAT_SPATK] = sText_SpAtk2, [STAT_SPDEF] = sText_SpDef2, - [STAT_ACC] = sText_Accuracy, - [STAT_EVASION] = sText_Evasiveness + [STAT_ACC] = sText_Accuracy, + [STAT_EVASION] = sText_Evasiveness, }; static const u8 sText_PokeblockWasTooSpicy[] = _("was too spicy!"); @@ -456,9 +456,9 @@ static const u8 sText_PokeblockWasTooSour[] = _("was too sour!"); const u8 * const gPokeblockWasTooXStringTable[FLAVOR_COUNT] = { - [FLAVOR_SPICY] = sText_PokeblockWasTooSpicy, + [FLAVOR_SPICY] = sText_PokeblockWasTooSpicy, [FLAVOR_DRY] = sText_PokeblockWasTooDry, - [FLAVOR_SWEET] = sText_PokeblockWasTooSweet, + [FLAVOR_SWEET] = sText_PokeblockWasTooSweet, [FLAVOR_BITTER] = sText_PokeblockWasTooBitter, [FLAVOR_SOUR] = sText_PokeblockWasTooSour }; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4e0e087b60..c9c7857733 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1128,13 +1128,13 @@ static void Cmd_accuracycheck(void) else { u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_ACC]; - buff = acc + 6 - gBattleMons[gBattlerTarget].statStages[STAT_EVASION]; + buff = acc + DEFAULT_STAT_STAGE - gBattleMons[gBattlerTarget].statStages[STAT_EVASION]; } - if (buff < 0) - buff = 0; - if (buff > 0xC) - buff = 0xC; + if (buff < MIN_STAT_STAGE) + buff = MIN_STAT_STAGE; + if (buff > MAX_STAT_STAGE) + buff = MAX_STAT_STAGE; moveAcc = gBattleMoves[move].accuracy; // check Thunder on sunny weather @@ -3500,7 +3500,7 @@ static void Cmd_unknown_24(void) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId == TRAINER_STEVEN_PARTNER) { - for (i = 0; i < 3; i++) + for (i = 0; i < MULTI_PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP); @@ -4385,7 +4385,7 @@ static void Cmd_playstatchangeanimation(void) { if (gBattlescriptCurrInstr[3] & STAT_CHANGE_CANT_PREVENT) { - if (gBattleMons[gActiveBattler].statStages[currStat] > 0) + if (gBattleMons[gActiveBattler].statStages[currStat] > MIN_STAT_STAGE) { statAnimId = startingStatAnimId + currStat; changeableStatsCount++; @@ -4397,7 +4397,7 @@ static void Cmd_playstatchangeanimation(void) && !(gBattleMons[gActiveBattler].ability == ABILITY_KEEN_EYE && currStat == STAT_ACC) && !(gBattleMons[gActiveBattler].ability == ABILITY_HYPER_CUTTER && currStat == STAT_ATK)) { - if (gBattleMons[gActiveBattler].statStages[currStat] > 0) + if (gBattleMons[gActiveBattler].statStages[currStat] > MIN_STAT_STAGE) { statAnimId = startingStatAnimId + currStat; changeableStatsCount++; @@ -4425,7 +4425,7 @@ static void Cmd_playstatchangeanimation(void) while (statsToCheck != 0) { - if (statsToCheck & 1 && gBattleMons[gActiveBattler].statStages[currStat] < 0xC) + if (statsToCheck & 1 && gBattleMons[gActiveBattler].statStages[currStat] < MAX_STAT_STAGE) { statAnimId = startingStatAnimId + currStat; changeableStatsCount++; @@ -4495,7 +4495,7 @@ static void Cmd_moveend(void) && gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && TARGET_TURN_DAMAGED - && gBattleMoves[gCurrentMove].power && gBattleMons[gBattlerTarget].statStages[STAT_ATK] <= 0xB) + && gBattleMoves[gCurrentMove].power && gBattleMons[gBattlerTarget].statStages[STAT_ATK] < MAX_STAT_STAGE) { gBattleMons[gBattlerTarget].statStages[STAT_ATK]++; BattleScriptPushCursor(); @@ -7288,7 +7288,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) index++; gBattleTextBuff2[index] = B_BUFF_EOS; - if (gBattleMons[gActiveBattler].statStages[statId] == 0) + if (gBattleMons[gActiveBattler].statStages[statId] == MIN_STAT_STAGE) gBattleCommunication[MULTISTRING_CHOOSER] = 2; else gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); @@ -7315,17 +7315,17 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) index++; gBattleTextBuff2[index] = B_BUFF_EOS; - if (gBattleMons[gActiveBattler].statStages[statId] == 0xC) + if (gBattleMons[gActiveBattler].statStages[statId] == MAX_STAT_STAGE) gBattleCommunication[MULTISTRING_CHOOSER] = 2; else gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); } gBattleMons[gActiveBattler].statStages[statId] += statValue; - if (gBattleMons[gActiveBattler].statStages[statId] < 0) - gBattleMons[gActiveBattler].statStages[statId] = 0; - if (gBattleMons[gActiveBattler].statStages[statId] > 0xC) - gBattleMons[gActiveBattler].statStages[statId] = 0xC; + if (gBattleMons[gActiveBattler].statStages[statId] < MIN_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[statId] = MIN_STAT_STAGE; + if (gBattleMons[gActiveBattler].statStages[statId] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[statId] = MAX_STAT_STAGE; if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && flags & STAT_BUFF_ALLOW_PTR) gMoveResultFlags |= MOVE_RESULT_MISSED; @@ -7350,7 +7350,7 @@ static void Cmd_normalisebuffs(void) // haze for (i = 0; i < gBattlersCount; i++) { for (j = 0; j < NUM_BATTLE_STATS; j++) - gBattleMons[i].statStages[j] = 6; + gBattleMons[i].statStages[j] = DEFAULT_STAT_STAGE; } gBattlescriptCurrInstr++; @@ -8750,7 +8750,7 @@ static void Cmd_rolloutdamagecalculation(void) static void Cmd_jumpifconfusedandstatmaxed(void) { if (gBattleMons[gBattlerTarget].status2 & STATUS2_CONFUSION - && gBattleMons[gBattlerTarget].statStages[gBattlescriptCurrInstr[1]] == 0xC) + && gBattleMons[gBattlerTarget].statStages[gBattlescriptCurrInstr[1]] == MAX_STAT_STAGE) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; @@ -8957,10 +8957,10 @@ static void Cmd_maxattackhalvehp(void) // belly drum if (!(gBattleMons[gBattlerAttacker].maxHP / 2)) halfHp = 1; - if (gBattleMons[gBattlerAttacker].statStages[STAT_ATK] < 12 + if (gBattleMons[gBattlerAttacker].statStages[STAT_ATK] < MAX_STAT_STAGE && gBattleMons[gBattlerAttacker].hp > halfHp) { - gBattleMons[gBattlerAttacker].statStages[STAT_ATK] = 12; + gBattleMons[gBattlerAttacker].statStages[STAT_ATK] = MAX_STAT_STAGE; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -9234,8 +9234,8 @@ static void Cmd_sethail(void) static void Cmd_jumpifattackandspecialattackcannotfall(void) // memento { - if (gBattleMons[gBattlerTarget].statStages[STAT_ATK] == 0 - && gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == 0 + if (gBattleMons[gBattlerTarget].statStages[STAT_ATK] == MIN_STAT_STAGE + && gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == MIN_STAT_STAGE && gBattleCommunication[6] != 1) { gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); diff --git a/src/battle_tv.c b/src/battle_tv.c index 26df087864..c84ae827b0 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -1398,9 +1398,9 @@ static void TrySetBattleSeminarShow(void) return; else if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return; - else if (gBattleMons[gBattlerAttacker].statStages[STAT_ACC] <= 5) + else if (gBattleMons[gBattlerAttacker].statStages[STAT_ACC] < DEFAULT_STAT_STAGE) return; - else if (gBattleMons[gBattlerTarget].statStages[STAT_EVASION] > 6) + else if (gBattleMons[gBattlerTarget].statStages[STAT_EVASION] > DEFAULT_STAT_STAGE) return; else if (gCurrentMove == MOVE_HIDDEN_POWER || gCurrentMove == MOVE_WEATHER_BALL) return; diff --git a/src/battle_util.c b/src/battle_util.c index 9cc2252b68..38d6fb18a9 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1978,7 +1978,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA } break; case ABILITY_SPEED_BOOST: - if (gBattleMons[battler].statStages[STAT_SPEED] < 0xC && gDisableStructs[battler].isFirstTurn != 2) + if (gBattleMons[battler].statStages[STAT_SPEED] < MAX_STAT_STAGE && gDisableStructs[battler].isFirstTurn != 2) { gBattleMons[battler].statStages[STAT_SPEED]++; gBattleScripting.animArg1 = 0x11; @@ -2619,9 +2619,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) case HOLD_EFFECT_RESTORE_STATS: for (i = 0; i < NUM_BATTLE_STATS; i++) { - if (gBattleMons[battlerId].statStages[i] < 6) + if (gBattleMons[battlerId].statStages[i] < DEFAULT_STAT_STAGE) { - gBattleMons[battlerId].statStages[i] = 6; + gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE; effect = ITEM_STATS_CHANGE; } } @@ -2690,9 +2690,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) case HOLD_EFFECT_RESTORE_STATS: for (i = 0; i < NUM_BATTLE_STATS; i++) { - if (gBattleMons[battlerId].statStages[i] < 6) + if (gBattleMons[battlerId].statStages[i] < DEFAULT_STAT_STAGE) { - gBattleMons[battlerId].statStages[i] = 6; + gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE; effect = ITEM_STATS_CHANGE; } } @@ -2811,7 +2811,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; // copy/paste again, smh case HOLD_EFFECT_ATTACK_UP: - if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_ATK] < 0xC) + if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam + && !moveTurn && gBattleMons[battlerId].statStages[STAT_ATK] < MAX_STAT_STAGE) { PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK); PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE); @@ -2825,7 +2826,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_DEFENSE_UP: - if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_DEF] < 0xC) + if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn + && gBattleMons[battlerId].statStages[STAT_DEF] < MAX_STAT_STAGE) { PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_DEF); @@ -2838,7 +2840,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_SPEED_UP: - if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPEED] < 0xC) + if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn + && gBattleMons[battlerId].statStages[STAT_SPEED] < MAX_STAT_STAGE) { PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPEED); @@ -2851,7 +2854,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_SP_ATTACK_UP: - if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPATK] < 0xC) + if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn + && gBattleMons[battlerId].statStages[STAT_SPATK] < MAX_STAT_STAGE) { PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPATK); @@ -2864,7 +2868,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_SP_DEFENSE_UP: - if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPDEF] < 0xC) + if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn + && gBattleMons[battlerId].statStages[STAT_SPDEF] < MAX_STAT_STAGE) { PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPDEF); @@ -2877,7 +2882,8 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } break; case HOLD_EFFECT_CRITICAL_UP: - if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)) + if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn + && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY)) { gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY; BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2); @@ -2889,7 +2895,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) { for (i = 0; i < 5; i++) { - if (gBattleMons[battlerId].statStages[STAT_ATK + i] < 0xC) + if (gBattleMons[battlerId].statStages[STAT_ATK + i] < MAX_STAT_STAGE) break; } if (i != 5) @@ -2897,7 +2903,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) do { i = Random() % 5; - } while (gBattleMons[battlerId].statStages[STAT_ATK + i] == 0xC); + } while (gBattleMons[battlerId].statStages[STAT_ATK + i] == MAX_STAT_STAGE); PREPARE_STAT_BUFFER(gBattleTextBuff1, i + 1); @@ -3166,9 +3172,9 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) case HOLD_EFFECT_RESTORE_STATS: for (i = 0; i < NUM_BATTLE_STATS; i++) { - if (gBattleMons[battlerId].statStages[i] < 6) + if (gBattleMons[battlerId].statStages[i] < DEFAULT_STAT_STAGE) { - gBattleMons[battlerId].statStages[i] = 6; + gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE; effect = ITEM_STATS_CHANGE; } } diff --git a/src/pokemon.c b/src/pokemon.c index 80e93c5685..6561e653b0 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -1868,21 +1868,21 @@ const u8 gPPUpGetMask[] = {0x03, 0x0c, 0x30, 0xc0}; // Masks for getting PP Up c const u8 gPPUpSetMask[] = {0xfc, 0xf3, 0xcf, 0x3f}; // Masks for setting PP Up count const u8 gPPUpAddMask[] = {0x01, 0x04, 0x10, 0x40}; // Values added to PP Up count -const u8 gStatStageRatios[][2] = +const u8 gStatStageRatios[MAX_STAT_STAGE + 1][2] = { - {10, 40}, // -6 + {10, 40}, // -6, MIN_STAT_STAGE {10, 35}, // -5 {10, 30}, // -4 {10, 25}, // -3 {10, 20}, // -2 {10, 15}, // -1 - {10, 10}, // 0 + {10, 10}, // 0, DEFAULT_STAT_STAGE {15, 10}, // +1 {20, 10}, // +2 {25, 10}, // +3 {30, 10}, // +4 {35, 10}, // +5 - {40, 10}, // +6 + {40, 10}, // +6, MAX_STAT_STAGE }; static const u16 sDeoxysBaseStats[] = @@ -3199,7 +3199,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de { if (gCritMultiplier == 2) { - if (attacker->statStages[STAT_ATK] > 6) + if (attacker->statStages[STAT_ATK] > DEFAULT_STAT_STAGE) APPLY_STAT_MOD(damage, attacker, attack, STAT_ATK) else damage = attack; @@ -3212,7 +3212,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de if (gCritMultiplier == 2) { - if (defender->statStages[STAT_DEF] < 6) + if (defender->statStages[STAT_DEF] < DEFAULT_STAT_STAGE) APPLY_STAT_MOD(damageHelper, defender, defense, STAT_DEF) else damageHelper = defense; @@ -3249,7 +3249,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de { if (gCritMultiplier == 2) { - if (attacker->statStages[STAT_SPATK] > 6) + if (attacker->statStages[STAT_SPATK] > DEFAULT_STAT_STAGE) APPLY_STAT_MOD(damage, attacker, spAttack, STAT_SPATK) else damage = spAttack; @@ -3262,7 +3262,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de if (gCritMultiplier == 2) { - if (defender->statStages[STAT_SPDEF] < 6) + if (defender->statStages[STAT_SPDEF] < DEFAULT_STAT_STAGE) APPLY_STAT_MOD(damageHelper, defender, spDefense, STAT_SPDEF) else damageHelper = spDefense; @@ -4624,8 +4624,8 @@ void CopyPlayerPartyMonToBattleData(u8 battlerId, u8 partyIndex) hpSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(battlerId)]; *hpSwitchout = gBattleMons[battlerId].hp; - for (i = 0; i < 8; i++) - gBattleMons[battlerId].statStages[i] = 6; + for (i = 0; i < NUM_BATTLE_STATS; i++) + gBattleMons[battlerId].statStages[i] = DEFAULT_STAT_STAGE; gBattleMons[battlerId].status2 = 0; sub_803FA70(battlerId); @@ -4728,49 +4728,49 @@ bool8 PokemonUseItemEffects(struct Pokemon *mon, u16 item, u8 partyIndex, u8 mov retVal = FALSE; } if ((itemEffect[cmdIndex] & ITEM0_X_ATTACK) - && gBattleMons[gActiveBattler].statStages[STAT_ATK] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_ATK] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_ATK] += itemEffect[cmdIndex] & ITEM0_X_ATTACK; - if (gBattleMons[gActiveBattler].statStages[STAT_ATK] > 12) - gBattleMons[gActiveBattler].statStages[STAT_ATK] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_ATK] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_ATK] = MAX_STAT_STAGE; retVal = FALSE; } break; // in-battle stat boosting effects case 1: if ((itemEffect[cmdIndex] & ITEM1_X_DEFEND) - && gBattleMons[gActiveBattler].statStages[STAT_DEF] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_DEF] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_DEF] += (itemEffect[cmdIndex] & ITEM1_X_DEFEND) >> 4; - if (gBattleMons[gActiveBattler].statStages[STAT_DEF] > 12) - gBattleMons[gActiveBattler].statStages[STAT_DEF] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_DEF] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_DEF] = MAX_STAT_STAGE; retVal = FALSE; } if ((itemEffect[cmdIndex] & ITEM1_X_SPEED) - && gBattleMons[gActiveBattler].statStages[STAT_SPEED] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_SPEED] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_SPEED] += itemEffect[cmdIndex] & ITEM1_X_SPEED; - if (gBattleMons[gActiveBattler].statStages[STAT_SPEED] > 12) - gBattleMons[gActiveBattler].statStages[STAT_SPEED] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_SPEED] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_SPEED] = MAX_STAT_STAGE; retVal = FALSE; } break; // more stat boosting effects case 2: if ((itemEffect[cmdIndex] & ITEM2_X_ACCURACY) - && gBattleMons[gActiveBattler].statStages[STAT_ACC] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_ACC] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_ACC] += (itemEffect[cmdIndex] & ITEM2_X_ACCURACY) >> 4; - if (gBattleMons[gActiveBattler].statStages[STAT_ACC] > 12) - gBattleMons[gActiveBattler].statStages[STAT_ACC] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_ACC] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_ACC] = MAX_STAT_STAGE; retVal = FALSE; } if ((itemEffect[cmdIndex] & ITEM2_X_SPATK) - && gBattleMons[gActiveBattler].statStages[STAT_SPATK] < 12) + && gBattleMons[gActiveBattler].statStages[STAT_SPATK] < MAX_STAT_STAGE) { gBattleMons[gActiveBattler].statStages[STAT_SPATK] += itemEffect[cmdIndex] & ITEM2_X_SPATK; - if (gBattleMons[gActiveBattler].statStages[STAT_SPATK] > 12) - gBattleMons[gActiveBattler].statStages[STAT_SPATK] = 12; + if (gBattleMons[gActiveBattler].statStages[STAT_SPATK] > MAX_STAT_STAGE) + gBattleMons[gActiveBattler].statStages[STAT_SPATK] = MAX_STAT_STAGE; retVal = FALSE; } break;