From d2bcc2ad5b550ba1d403749d756f6440b3acb169 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 1 Sep 2021 00:14:02 -0300 Subject: [PATCH 01/14] Added configs for modern post-battle stat calcs --- include/constants/battle_config.h | 2 ++ src/battle_script_commands.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index bf31c77b3..2b83b766f 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -93,6 +93,8 @@ #define B_RECOIL_IF_MISS_DMG GEN_7 // In Gen5+, Jump Kick and High Jump Kick will always do half of the user's max HP when missing. #define B_PSYWAVE_DMG GEN_7 // Psywave's damage formula. See Cmd_psywavedamageeffect. #define B_BADGE_BOOST GEN_7 // In Gen4+, Gym Badges no longer boost a Pokémon's stats. +#define B_MAX_LEVEL_EV_GAINS GEN_7 // In Gen5+, Lv100 Pokémon can obtain Effort Values normally. +#define B_RECALCULATE_STATS GEN_7 // In Gen5+, the stats of the Pokémon who participate in battle are recalculated at the end of each battle. // Move data settings #define B_UPDATED_MOVE_DATA GEN_8 // Updates move data in gBattleMoves, including Power, Accuracy, PP, stat changes, targets, chances of secondary effects, etc. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 21bc7945b..eaceb8545 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3783,6 +3783,9 @@ static void Cmd_getexp(void) *(&gBattleStruct->sentInPokes) >>= 1; gBattleScripting.getexpState = 5; gBattleMoveDamage = 0; // used for exp + #if B_MAX_LEVEL_EV_GAINS >= GEN_5 + MonGainEVs(&gPlayerParty[gBattleStruct->expGetterMonId], gBattleMons[gBattlerFainted].species); + #endif } else { @@ -3958,6 +3961,12 @@ static void Cmd_getexp(void) case 6: // increment instruction if (gBattleControllerExecFlags == 0) { + #if B_RECALCULATE_STATS >= GEN_5 + // Recalculate the stats of every party member before the end + for (i = 0; i < PARTY_SIZE; i++) + CalculateMonStats(&gPlayerParty[i]); + #endif + // not sure why gf clears the item and ability here gBattleMons[gBattlerFainted].item = 0; gBattleMons[gBattlerFainted].ability = 0; From 9990bda7a4e4610390ab92ff0eff90f2a0c7a174 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 1 Sep 2021 02:54:44 -0300 Subject: [PATCH 02/14] Fixed `if` statement for stat recalculation Thanks to Syreldar. --- src/battle_script_commands.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index eaceb8545..a3edf689a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3964,7 +3964,14 @@ static void Cmd_getexp(void) #if B_RECALCULATE_STATS >= GEN_5 // Recalculate the stats of every party member before the end for (i = 0; i < PARTY_SIZE; i++) - CalculateMonStats(&gPlayerParty[i]); + { + if (GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0 + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE + && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) + { + CalculateMonStats(&gPlayerParty[i]); + } + } #endif // not sure why gf clears the item and ability here From 46fb92c4da8de0f7166a48c77a8a74fb3ee0351a Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 1 Sep 2021 17:40:12 -0300 Subject: [PATCH 03/14] Optimized checks --- src/battle_script_commands.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a3edf689a..1a2d90ac2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3965,9 +3965,8 @@ static void Cmd_getexp(void) // Recalculate the stats of every party member before the end for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0 - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE - && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) { CalculateMonStats(&gPlayerParty[i]); } From 3113e4fa125b1e3d63f6453dec9c36c932f2b1a7 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 6 Sep 2021 07:40:21 -0300 Subject: [PATCH 04/14] Moved stat recalculation to `HandleEndTurn_FinishBattle` --- src/battle_main.c | 11 +++++++++++ src/battle_script_commands.c | 12 ------------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 282b85035..728d33d4e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4880,6 +4880,17 @@ static void HandleEndTurn_FinishBattle(void) UndoMegaEvolution(i); UndoFormChange(i, B_SIDE_PLAYER, FALSE); } + #if B_RECALCULATE_STATS >= GEN_5 + // Recalculate the stats of every party member before the end + for (i = 0; i < PARTY_SIZE; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) + { + CalculateMonStats(&gPlayerParty[i]); + } + } + #endif gBattleMainFunc = FreeResetData_ReturnToOvOrDoEvolutions; gCB2_AfterEvolution = BattleMainCB2; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1a2d90ac2..2d64f7795 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3961,18 +3961,6 @@ static void Cmd_getexp(void) case 6: // increment instruction if (gBattleControllerExecFlags == 0) { - #if B_RECALCULATE_STATS >= GEN_5 - // Recalculate the stats of every party member before the end - for (i = 0; i < PARTY_SIZE; i++) - { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) - { - CalculateMonStats(&gPlayerParty[i]); - } - } - #endif - // not sure why gf clears the item and ability here gBattleMons[gBattlerFainted].item = 0; gBattleMons[gBattlerFainted].ability = 0; From 903c4cbf68d1c73cca1ab076177e54c7a3bc73ea Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 9 Oct 2021 23:52:37 -0300 Subject: [PATCH 05/14] Config for Blizzard + Hail --- include/constants/battle_config.h | 1 + src/battle_script_commands.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index bcf4491f9..2c005f50a 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -123,6 +123,7 @@ #define B_CRASH_IF_TARGET_IMMUNE GEN_7 // In Gen4+, The user of Jump Kick or High Jump Kick will "keep going and crash" if it attacks a target that is immune to the move. #define B_TAILWIND_TIMER GEN_7 // In Gen5+, Tailwind lasts 4 turns instead of 3. #define B_MEMENTO_FAIL GEN_7 // In Gen4+, Memento fails if there is no target or if the target is protected or behind substitute. But not if Atk/Sp. Atk are at -6. +#define B_BLIZZARD_HAIL GEN_7 // In Gen4+, Blizzard bypasses accuracy checks if it's hailing. // Ability settings #define B_ABILITY_WEATHER GEN_7 // In Gen6+, ability-induced weather lasts 5 turns. Before, it lasted until the battle ended or until it was changed by a move or a different weather-affecting ability. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9d6dbb89b..fa167bf66 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1597,7 +1597,7 @@ static bool32 AccuracyCalcHelper(u16 move) if ((WEATHER_HAS_EFFECT && (((gBattleWeather & WEATHER_RAIN_ANY) && (gBattleMoves[move].effect == EFFECT_THUNDER || gBattleMoves[move].effect == EFFECT_HURRICANE)) - || (((gBattleWeather & WEATHER_HAIL_ANY) && move == MOVE_BLIZZARD)))) + || ((B_BLIZZARD_HAIL >= GEN_4 && (gBattleWeather & WEATHER_HAIL_ANY) && move == MOVE_BLIZZARD)))) || (gBattleMoves[move].effect == EFFECT_VITAL_THROW) || (gBattleMoves[move].accuracy == 0) || ((B_MINIMIZE_DMG_ACC >= GEN_6) && (gStatuses3[gBattlerTarget] & STATUS3_MINIMIZED) && (gBattleMoves[move].flags & FLAG_DMG_MINIMIZE))) From 4572e62669a2a461b98dd660b2dd80a8ddca78da Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 9 Oct 2021 23:56:07 -0300 Subject: [PATCH 06/14] Gen 5 Scald effect --- src/data/battle_moves.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 1aa8c4dfd..3f4b8eefc 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -7944,7 +7944,11 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_SCALD] = { - .effect = EFFECT_SCALD, + #if B_UPDATED_MOVE_DATA >= GEN_6 + .effect = EFFECT_SCALD, + #else + .effect = EFFECT_BURN_HIT, + #endif .power = 80, .type = TYPE_WATER, .accuracy = 100, From dd82e051bd16ba8dfd5fabf6381c31ef66923180 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 22 Oct 2021 06:48:24 -0300 Subject: [PATCH 07/14] Fixed Rapid Spin raising Speed even when the move fails --- data/battle_scripts_1.s | 1 + 1 file changed, 1 insertion(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3d7dde94d..47a564077 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4258,6 +4258,7 @@ BattleScript_EffectRapidSpin:: accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring ppreduce + jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd critcalc damagecalc adjustdamage From 24876ac5e32a3944eb5d5577ccfc4d02a734ba2a Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 22 Oct 2021 07:21:31 -0300 Subject: [PATCH 08/14] Small tweak for BattleScript_EffectRapidSpin --- data/battle_scripts_1.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 47a564077..215727100 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4288,8 +4288,8 @@ BattleScript_EffectRapidSpinEnd:: end .else setmoveeffect MOVE_EFFECT_RAPIDSPIN | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN -.endif goto BattleScript_EffectHit +.endif BattleScript_EffectSonicboom:: attackcanceler From 4c90cbe625f926ac7551ba5c3236b48dd9f2c55c Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 22 Oct 2021 19:58:27 -0300 Subject: [PATCH 09/14] Repositioned the gMoveResultFlags check --- data/battle_scripts_1.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 215727100..0748e0a5b 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4258,7 +4258,6 @@ BattleScript_EffectRapidSpin:: accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE attackstring ppreduce - jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd critcalc damagecalc adjustdamage @@ -4273,6 +4272,7 @@ BattleScript_EffectRapidSpin:: waitmessage B_WAIT_TIME_LONG resultmessage waitmessage B_WAIT_TIME_LONG + jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd setmoveeffect MOVE_EFFECT_RAPIDSPIN | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN seteffectwithchance setstatchanger STAT_SPEED, 1, FALSE From 71ff66470053dcd1baebae57798734e8cf845c8a Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 23 Oct 2021 20:11:02 -0300 Subject: [PATCH 10/14] Ordered config into new categories --- include/constants/battle_config.h | 36 ++++++++++++++++++------------- src/battle_interface.c | 2 +- src/battle_script_commands.c | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 4cf4c0eb5..28dd06dcf 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -104,6 +104,20 @@ #define B_MAX_LEVEL_EV_GAINS GEN_7 // In Gen5+, Lv100 Pokémon can obtain Effort Values normally. #define B_RECALCULATE_STATS GEN_7 // In Gen5+, the stats of the Pokémon who participate in battle are recalculated at the end of each battle. +// Type settings +#define B_GHOSTS_ESCAPE GEN_7 // In Gen6+, Ghost-type Pokémon can escape even when blocked by abilities such as Shadow Tag. +#define B_PARALYZE_ELECTRIC GEN_7 // In Gen6+, Electric-type Pokémon can't be paralyzed. +#define B_POWDER_GRASS GEN_7 // In Gen6+, Grass-type Pokémon are immune to powder and spore moves. +#define B_STEEL_RESISTANCES GEN_7 // In Gen6+, Steel-type Pokémon are no longer resistant to Dark-type and Ghost-type moves. +#define B_PRANKSTER_DARK_TYPES GEN_7 // In Gen7+, Prankster-elevated status moves do not affect Dark type Pokémon. + +// Turn count settings +#define B_BINDING_TURNS GEN_7 // In Gen5+, binding moves last for 4-5 turns instead of 2-5 turns. (With Grip Claw, 7 and 5 turns respectively.) +#define B_UPROAR_TURNS GEN_7 // In Gen5+, Uproar lasts for 3 turns instead of 2-5 turns. +#define B_DISABLE_TURNS GEN_7 // Disable's turns. See Cmd_disablelastusedattack. +#define B_TAILWIND_TURNS GEN_7 // In Gen5+, Tailwind lasts 4 turns instead of 3. +#define B_SLEEP_TURNS GEN_7 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. + // Move data settings #define B_UPDATED_MOVE_DATA GEN_8 // Updates move data in gBattleMoves, including Power, Accuracy, PP, stat changes, targets, chances of secondary effects, etc. #define B_PHYSICAL_SPECIAL_SPLIT GEN_7 // In Gen3, the move's type determines if it will do physical or special damage. The split icon in the summary will reflect this. @@ -111,35 +125,31 @@ #define B_KINGS_SHIELD_LOWER_ATK GEN_7 // In Gen7+, it lowers Atk by 1 stage instead of 2 of oponents that hit it. #define B_SPEED_BUFFING_RAPID_SPIN GEN_8 // In Gen8, Rapid Spin raises the user's Speed by 1 stage. +// Move accuracy settings +#define B_TOXIC_NEVER_MISS GEN_7 // In Gen6+, if Toxic is used by a Poison-type Pokémon, it will never miss. +#define B_MINIMIZE_DMG_ACC GEN_7 // In Gen6+, moves that causes double damage to minimized Pokémon will also skip accuracy checks. +#define B_BLIZZARD_HAIL GEN_7 // In Gen4+, Blizzard bypasses accuracy checks if it's hailing. + // Other move settings #define B_SOUND_SUBSTITUTE GEN_7 // In Gen6+, sound moves bypass Substitute. -#define B_TOXIC_NEVER_MISS GEN_7 // In Gen6+, if Toxic is used by a Poison-type Pokémon, it will never miss. #define B_PAYBACK_SWITCH_BOOST GEN_7 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled. -#define B_BINDING_TURNS GEN_7 // In Gen5+, binding moves last for 4-5 turns instead of 2-5 turns. (With Grip Claw, 7 and 5 turns respectively.) -#define B_UPROAR_TURNS GEN_7 // In Gen5+, Uproar lasts for 3 turns instead of 2-5 turns. -#define B_DISABLE_TURNS GEN_7 // Disable's turns. See Cmd_disablelastusedattack. #define B_INCINERATE_GEMS GEN_7 // In Gen6+, Incinerate can destroy Gems. -#define B_MINIMIZE_DMG_ACC GEN_7 // In Gen6+, moves that causes double damage to minimized Pokémon will also skip accuracy checks. #define B_PP_REDUCED_BY_SPITE GEN_7 // In Gen4+, Spite reduces the foe's last move's PP by 4, instead of 2 to 5. #define B_CAN_SPITE_FAIL GEN_7 // In Gen4+, Spite can no longer fail if the foe's last move only has 1 remaining PP. #define B_CRASH_IF_TARGET_IMMUNE GEN_7 // In Gen4+, The user of Jump Kick or High Jump Kick will "keep going and crash" if it attacks a target that is immune to the move. -#define B_TAILWIND_TIMER GEN_7 // In Gen5+, Tailwind lasts 4 turns instead of 3. #define B_MEMENTO_FAIL GEN_7 // In Gen4+, Memento fails if there is no target or if the target is protected or behind substitute. But not if Atk/Sp. Atk are at -6. #define B_HIDDEN_POWER_DMG GEN_7 // In Gen6+, Hidden Power's base power was set to always be 60. Before, it was determined by the mon's IVs. #define B_GLARE_GHOST GEN_7 // In Gen4+, Glare can hit Ghost-type Pokémon normally. -#define B_BLIZZARD_HAIL GEN_7 // In Gen4+, Blizzard bypasses accuracy checks if it's hailing. // Ability settings #define B_ABILITY_WEATHER GEN_7 // In Gen6+, ability-induced weather lasts 5 turns. Before, it lasted until the battle ended or until it was changed by a move or a different weather-affecting ability. #define B_GALE_WINGS GEN_7 // In Gen7+ requires full HP to trigger. #define B_STANCE_CHANGE_FAIL GEN_7 // In Gen7+, Stance Change fails if the Pokémon is unable to use a move because of confusion, paralysis, etc. In Gen6, it doesn't. -#define B_GHOSTS_ESCAPE GEN_7 // In Gen6+, Ghost-type Pokémon can escape even when blocked by abilities such as Shadow Tag. #define B_SHADOW_TAG_ESCAPE GEN_7 // In Gen4+, if both sides have a Pokémon with Shadow Tag, all battlers can escape. Before, neither side could escape this situation. #define B_MOODY_ACC_EVASION GEN_8 // In Gen8, Moody CANNOT raise Accuracy and Evasion anymore. #define B_FLASH_FIRE_FROZEN GEN_7 // In Gen5+, Flash Fire can trigger even when frozen, when it couldn't before. #define B_SYNCHRONIZE_NATURE GEN_8 // In Gen8, if the Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same ability, as opposed to 50% previously. #define B_UPDATED_INTIMIDATE GEN_8 // In Gen8, Intimidate doesn't work on opponents with the Inner Focus, Scrappy, Own Tempo or Oblivious abilities. -#define B_PRANKSTER_DARK_TYPES GEN_7 // In Gen7+, Prankster-elevated status moves do not affect Dark type Pokémon. // Item settings #define B_HP_BERRIES GEN_7 // In Gen4+, berries which restore hp activate immediately after HP drops to half. In Gen3, the effect occurs at the end of the turn. @@ -163,6 +173,8 @@ #define B_FAST_INTRO TRUE // If set to TRUE, battle intro texts print at the same time as animation of a Pokémon, as opposing to waiting for the animation to end. #define B_SHOW_TARGETS TRUE // If set to TRUE, all available targets, for moves hitting 2 or 3 Pokémon, will be shown before selecting a move. #define B_SHOW_SPLIT_ICON TRUE // If set to TRUE, it will show an icon in the summary showing the move's category split. +#define B_HIDE_HEALTHBOX_IN_ANIMS TRUE // If set to TRUE, hides healthboxes during move animations. +#define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. // Critical Capture #define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled. @@ -177,10 +189,6 @@ // Other #define B_DOUBLE_WILD_CHANCE 0 // % chance of encountering two Pokémon in a Wild Encounter. -#define B_SLEEP_TURNS GEN_7 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. -#define B_PARALYZE_ELECTRIC GEN_7 // In Gen6+, Electric-type Pokémon can't be paralyzed. -#define B_POWDER_GRASS GEN_7 // In Gen6+, Grass-type Pokémon are immune to powder and spore moves. -#define B_STEEL_RESISTANCES GEN_7 // In Gen6+, Steel-type Pokémon are no longer resistant to Dark-type and Ghost-type moves. #define B_THUNDERSTORM_TERRAIN TRUE // If TRUE, overworld Thunderstorm generates Rain and Electric Terrain as in Gen 8. #define B_SEMI_INVULNERABLE_CATCH GEN_7 // In Gen4+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) @@ -201,8 +209,6 @@ #define B_NEW_IMPACT_PALETTE FALSE // If set to TRUE, it updates the basic 'hit' palette. #define B_NEW_SURF_PARTICLE_PALETTE FALSE // If set to TRUE, it updates Surf's wave palette. -#define B_HIDE_HEALTHBOXES_DURING_ANIMS TRUE // If set to TRUE, hides healthboxes during move animations. -#define B_TERRAIN_BG_CHANGE TRUE // If set to TRUE, terrain moves permanently change the default battle background until the effect fades. #define B_ENABLE_DEBUG TRUE // If set to TRUE, enables a debug menu to use in battles by pressing the Select button. #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H diff --git a/src/battle_interface.c b/src/battle_interface.c index 36353c1d8..1e9d9008c 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -1040,7 +1040,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHPBoxes) if (indicatorSpriteId != 0xFF) gSprites[indicatorSpriteId].oam.priority = priority; - #if B_HIDE_HEALTHBOXES_DURING_ANIMS + #if B_HIDE_HEALTHBOX_IN_ANIMS if (hideHPBoxes && IsBattlerAlive(i)) TryToggleHealboxVisibility(priority, healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId, indicatorSpriteId); #endif diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ac27d8c45..58c46d171 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -10922,7 +10922,7 @@ static void Cmd_settailwind(void) { gSideStatuses[side] |= SIDE_STATUS_TAILWIND; gSideTimers[side].tailwindBattlerId = gBattlerAttacker; - gSideTimers[side].tailwindTimer = (B_TAILWIND_TIMER >= GEN_5) ? 4 : 3; + gSideTimers[side].tailwindTimer = (B_TAILWIND_TURNS >= GEN_5) ? 4 : 3; gBattlescriptCurrInstr += 5; } else From 8699db942b55674e48aeacdbd90fb2bb56d5acdd Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 24 Oct 2021 20:03:21 -0300 Subject: [PATCH 11/14] More ordering --- include/constants/battle_config.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 28dd06dcf..80bf55920 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -88,22 +88,27 @@ // Calculation settings #define B_CRIT_CHANCE GEN_7 // Chances of a critical hit landing. See CalcCritChanceStage. #define B_CRIT_MULTIPLIER GEN_7 // In Gen6+, critical hits multiply damage by 1.5 instead of 2. +#define B_PARALYSIS_SPEED GEN_7 // In Gen7+, Speed is decreased by 50% instead of 75%. +#define B_TERRAIN_TYPE_BOOST GEN_8 // In Gen8, damage is boosted by 30% instead of 50%. +#define B_CONFUSION_SELF_DMG_CHANCE GEN_7 // In Gen7+, confusion has a 33.3% of self-damage, instead of 50%. +#define B_MULTI_HIT_CHANCE GEN_7 // In Gen5+, multi-hit moves have different %. See Cmd_setmultihitcounter for values. + +// Exp and stat settings #define B_EXP_CATCH GEN_7 // In Gen6+, Pokémon get experience from catching. #define B_TRAINER_EXP_MULTIPLIER GEN_7 // In Gen7+, trainer battles no longer give a 1.5 multiplier to EXP gain. #define B_SPLIT_EXP GEN_7 // In Gen6+, all participating mon get full experience. #define B_SCALED_EXP GEN_7 // In Gen5 and Gen7+, experience is weighted by level difference. -#define B_BURN_DAMAGE GEN_7 // In Gen7+, burn damage is 1/16th of max HP instead of 1/8th. -#define B_PARALYSIS_SPEED GEN_7 // In Gen7+, Speed is decreased by 50% instead of 75%. -#define B_TERRAIN_TYPE_BOOST GEN_8 // In Gen8, damage is boosted by 30% instead of 50%. -#define B_BINDING_DAMAGE GEN_7 // In Gen6+, binding damage is 1/8 of max HP instead of 1/16. (With Binding Band, 1/6 and 1/8 respectively.) -#define B_CONFUSION_SELF_DMG_CHANCE GEN_7 // In Gen7+, confusion has a 33.3% of self-damage, instead of 50%. -#define B_MULTI_HIT_CHANCE GEN_7 // In Gen5+, multi-hit moves have different %. See Cmd_setmultihitcounter for values. -#define B_RECOIL_IF_MISS_DMG GEN_7 // In Gen5+, Jump Kick and High Jump Kick will always do half of the user's max HP when missing. -#define B_PSYWAVE_DMG GEN_7 // Psywave's damage formula. See Cmd_psywavedamageeffect. #define B_BADGE_BOOST GEN_7 // In Gen4+, Gym Badges no longer boost a Pokémon's stats. #define B_MAX_LEVEL_EV_GAINS GEN_7 // In Gen5+, Lv100 Pokémon can obtain Effort Values normally. #define B_RECALCULATE_STATS GEN_7 // In Gen5+, the stats of the Pokémon who participate in battle are recalculated at the end of each battle. +// Damage settings +#define B_BURN_DAMAGE GEN_7 // In Gen7+, burn damage is 1/16th of max HP instead of 1/8th. +#define B_BINDING_DAMAGE GEN_7 // In Gen6+, binding damage is 1/8 of max HP instead of 1/16. (With Binding Band, 1/6 and 1/8 respectively.) +#define B_PSYWAVE_DMG GEN_7 // Psywave's damage formula. See Cmd_psywavedamageeffect. +#define B_PAYBACK_SWITCH_BOOST GEN_7 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled. +#define B_HIDDEN_POWER_DMG GEN_7 // In Gen6+, Hidden Power's base power was set to always be 60. Before, it was determined by the mon's IVs. + // Type settings #define B_GHOSTS_ESCAPE GEN_7 // In Gen6+, Ghost-type Pokémon can escape even when blocked by abilities such as Shadow Tag. #define B_PARALYZE_ELECTRIC GEN_7 // In Gen6+, Electric-type Pokémon can't be paralyzed. @@ -124,6 +129,7 @@ #define B_FELL_STINGER_STAT_RAISE GEN_7 // In Gen7+, it raises Atk by 3 stages instead of 2 if it causes the target to faint. #define B_KINGS_SHIELD_LOWER_ATK GEN_7 // In Gen7+, it lowers Atk by 1 stage instead of 2 of oponents that hit it. #define B_SPEED_BUFFING_RAPID_SPIN GEN_8 // In Gen8, Rapid Spin raises the user's Speed by 1 stage. +#define B_RECOIL_IF_MISS_DMG GEN_7 // In Gen5+, Jump Kick and High Jump Kick will always do half of the user's max HP when missing. // Move accuracy settings #define B_TOXIC_NEVER_MISS GEN_7 // In Gen6+, if Toxic is used by a Poison-type Pokémon, it will never miss. @@ -132,13 +138,11 @@ // Other move settings #define B_SOUND_SUBSTITUTE GEN_7 // In Gen6+, sound moves bypass Substitute. -#define B_PAYBACK_SWITCH_BOOST GEN_7 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled. #define B_INCINERATE_GEMS GEN_7 // In Gen6+, Incinerate can destroy Gems. #define B_PP_REDUCED_BY_SPITE GEN_7 // In Gen4+, Spite reduces the foe's last move's PP by 4, instead of 2 to 5. #define B_CAN_SPITE_FAIL GEN_7 // In Gen4+, Spite can no longer fail if the foe's last move only has 1 remaining PP. #define B_CRASH_IF_TARGET_IMMUNE GEN_7 // In Gen4+, The user of Jump Kick or High Jump Kick will "keep going and crash" if it attacks a target that is immune to the move. #define B_MEMENTO_FAIL GEN_7 // In Gen4+, Memento fails if there is no target or if the target is protected or behind substitute. But not if Atk/Sp. Atk are at -6. -#define B_HIDDEN_POWER_DMG GEN_7 // In Gen6+, Hidden Power's base power was set to always be 60. Before, it was determined by the mon's IVs. #define B_GLARE_GHOST GEN_7 // In Gen4+, Glare can hit Ghost-type Pokémon normally. // Ability settings @@ -156,6 +160,7 @@ #define B_BERRIES_INSTANT GEN_7 // In Gen4+, most berries activate on battle start/switch-in if applicable. In Gen3, they only activate either at the move end or turn end. #define B_X_ITEMS_BUFF GEN_7 // In Gen7+, the X Items raise a stat by 2 stages instead of 1. #define B_MENTAL_HERB GEN_5 // In Gen5+, the Mental Herb cures Infatuation, Taunt, Encore, Torment, Heal Block, and Disable +#define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items. // Flag settings // To use the following features in scripting, replace the 0s with the flag ID you're assigning it to. @@ -180,9 +185,6 @@ #define B_CRITICAL_CAPTURE TRUE // If set to TRUE, Critical Capture will be enabled. #define B_CATCHING_CHARM_BOOST 20 // % boost in Critical Capture odds if player has the Catching Charm. -// Item Theft Settings -#define B_TRAINERS_KNOCK_OFF_ITEMS TRUE // If TRUE, trainers can steal/swap your items (non-berries are restored after battle). In vanilla games trainers cannot steal items. - // Last Used Ball #define B_LAST_USED_BALL TRUE // If TRUE, the "last used ball" feature from Gen 7 will be implemented #define B_LAST_USED_BALL_BUTTON R_BUTTON // If last used ball is implemented, this button (or button combo) will trigger throwing the last used ball. From 70aeaf288feb48ec2e6ef731f86ba7c8157b3cf9 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 24 Oct 2021 20:07:22 -0300 Subject: [PATCH 12/14] Rough Skin damage config --- include/constants/battle_config.h | 1 + src/battle_util.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 80bf55920..0406d20a9 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -108,6 +108,7 @@ #define B_PSYWAVE_DMG GEN_7 // Psywave's damage formula. See Cmd_psywavedamageeffect. #define B_PAYBACK_SWITCH_BOOST GEN_7 // In Gen5+, if the opponent switches out, Payback's damage will no longer be doubled. #define B_HIDDEN_POWER_DMG GEN_7 // In Gen6+, Hidden Power's base power was set to always be 60. Before, it was determined by the mon's IVs. +#define B_ROUGH_SKIN_DMG GEN_7 // In Gen4+, Rough Skin contact damage is 1/8th of max HP instead of 1/16th. This will also affect Iron Barbs. // Type settings #define B_GHOSTS_ESCAPE GEN_7 // In Gen6+, Ghost-type Pokémon can escape even when blocked by abilities such as Shadow Tag. diff --git a/src/battle_util.c b/src/battle_util.c index 33dd0f5de..9515a1f32 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4884,7 +4884,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move && TARGET_TURN_DAMAGED && IsMoveMakingContact(move, gBattlerAttacker)) { - gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; + #if B_ROUGH_SKIN_DMG >= GEN_4 + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8; + #else + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; + #endif if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility); From 44625561e5b06a5d9111a6c1e215cfdb48437b74 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 24 Oct 2021 20:21:54 -0300 Subject: [PATCH 13/14] Taunt turn config --- include/constants/battle_config.h | 1 + src/battle_script_commands.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 0406d20a9..02f873659 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -123,6 +123,7 @@ #define B_DISABLE_TURNS GEN_7 // Disable's turns. See Cmd_disablelastusedattack. #define B_TAILWIND_TURNS GEN_7 // In Gen5+, Tailwind lasts 4 turns instead of 3. #define B_SLEEP_TURNS GEN_7 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. +#define B_TAUNT_TURNS GEN_7 // In Gen5+, Taunt lasts 3 turns if the user acts before the target, or 4 turns if the target acted before the user. In Gen3, taunt lasts 2 turns and in Gen 4, 3-5 turns. // Move data settings #define B_UPDATED_MOVE_DATA GEN_8 // Updates move data in gBattleMoves, including Power, Accuracy, PP, stat changes, targets, chances of secondary effects, etc. diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 58c46d171..9a3f0bf01 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11778,9 +11778,15 @@ static void Cmd_settaunt(void) } else if (gDisableStructs[gBattlerTarget].tauntTimer == 0) { - u8 turns = 4; - if (GetBattlerTurnOrderNum(gBattlerTarget) > GetBattlerTurnOrderNum(gBattlerAttacker)) - turns--; // If the target hasn't yet moved this turn, Taunt lasts for only three turns (source: Bulbapedia) + #if B_TAUNT_TURNS >= GEN_5 + u8 turns = 4; + if (GetBattlerTurnOrderNum(gBattlerTarget) > GetBattlerTurnOrderNum(gBattlerAttacker)) + turns--; // If the target hasn't yet moved this turn, Taunt lasts for only three turns (source: Bulbapedia) + #elif B_TAUNT_TURNS == GEN_4 + u8 turns = (Random() & 2) + 3; + #else + u8 turns = 2; + #endif gDisableStructs[gBattlerTarget].tauntTimer = gDisableStructs[gBattlerTarget].tauntTimer2 = turns; gBattlescriptCurrInstr += 5; From 442376e75b5b45d4049795563ff2c926dcafc372 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 25 Oct 2021 16:36:17 -0300 Subject: [PATCH 14/14] Replaced jumpifbyte with jumpifhalfword in a few BattleScripts --- data/battle_scripts_1.s | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 0748e0a5b..d1e03b305 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3168,7 +3168,7 @@ BattleScript_EffectRecoilIfMiss:: accuracycheck BattleScript_MoveMissedDoDamage, ACC_CURR_MOVE .if B_CRASH_IF_TARGET_IMMUNE >= GEN_4 typecalc - jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveMissedDoDamage + jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveMissedDoDamage .endif goto BattleScript_HitFromAtkString BattleScript_MoveMissedDoDamage:: @@ -3179,7 +3179,7 @@ BattleScript_MoveMissedDoDamage:: resultmessage waitmessage B_WAIT_TIME_LONG .if B_CRASH_IF_TARGET_IMMUNE < GEN_4 - jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd + jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd .endif printstring STRINGID_PKMNCRASHED waitmessage B_WAIT_TIME_LONG @@ -3925,7 +3925,7 @@ BattleScript_TripleKickPrintStrings:: resultmessage waitmessage B_WAIT_TIME_LONG jumpifbyte CMP_EQUAL, sMULTIHIT_STRING + 4, 0, BattleScript_TripleKickEnd - jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_TripleKickEnd + jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_TripleKickEnd copyarray gBattleTextBuff1, sMULTIHIT_STRING, 6 printstring STRINGID_HITXTIMES waitmessage B_WAIT_TIME_LONG @@ -4272,7 +4272,7 @@ BattleScript_EffectRapidSpin:: waitmessage B_WAIT_TIME_LONG resultmessage waitmessage B_WAIT_TIME_LONG - jumpifbyte CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd + jumpifhalfword CMP_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd setmoveeffect MOVE_EFFECT_RAPIDSPIN | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN seteffectwithchance setstatchanger STAT_SPEED, 1, FALSE