From 43821d606fef3b367297f5d8158688165307a7a8 Mon Sep 17 00:00:00 2001 From: Alex <93446519+AlexOn1ine@users.noreply.github.com> Date: Wed, 21 Jun 2023 17:11:06 +0200 Subject: [PATCH 1/3] Fix Baton Pass for when Ace mon is the last alive (#3067) * Updated preproc config for Diamond Storm * Fix baton pass bug with IsAceMon remove not needed check --------- Co-authored-by: LOuroboros --- src/battle_ai_switch_items.c | 5 ++--- src/data/battle_moves.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index d7fd062ba2..9ef3477877 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -989,9 +989,8 @@ u8 GetMostSuitableMonToSwitchInto(void) if (bestMonId != PARTY_SIZE) return bestMonId; - // If ace mon is the last available Pokemon and U-Turn/Volt Switch was used - switch to the mon. - if (aceMonId != PARTY_SIZE - && (gBattleMoves[gLastUsedMove].effect == EFFECT_HIT_ESCAPE || gBattleMoves[gLastUsedMove].effect == EFFECT_PARTING_SHOT)) + // If ace mon is the last available Pokemon and switch move was used - switch to the mon. + if (aceMonId != PARTY_SIZE) return aceMonId; return PARTY_SIZE; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index ef6ad52a1c..ebd64ae10b 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9895,7 +9895,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT_Z] = [MOVE_DIAMOND_STORM] = { - #if B_UPDATED_MOVE_DATA >= GEN_4 + #if B_UPDATED_MOVE_DATA >= GEN_7 .effect = EFFECT_DEFENSE_UP2_HIT, #else .effect = EFFECT_DEFENSE_UP_HIT, From 62ae3b1df14b56e04de15dda318a180266e38848 Mon Sep 17 00:00:00 2001 From: Pawkkie <61265402+Pawkkie@users.noreply.github.com> Date: Wed, 21 Jun 2023 12:59:30 -0400 Subject: [PATCH 2/3] Fix bug due to variable overflow when AI chooses new Pokemon to send out (#3068) --- include/battle_util.h | 2 ++ src/battle_ai_switch_items.c | 12 ++++++------ src/battle_util.c | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 96ffc2fa16..b5ba5249ea 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -212,6 +212,8 @@ bool8 IsMoveAffectedByParentalBond(u16 move, u8 battlerId); void CopyMonLevelAndBaseStatsToBattleMon(u32 battler, struct Pokemon *mon); void CopyMonAbilityAndTypesToBattleMon(u32 battler, struct Pokemon *mon); void RecalcBattlerStats(u32 battler, struct Pokemon *mon); +void MulModifier(u16 *modifier, u16 val); + // Ability checks bool32 IsRolePlayBannedAbilityAtk(u16 ability); bool32 IsRolePlayBannedAbility(u16 ability); diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 9ef3477877..48ca258a89 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -822,7 +822,7 @@ static u32 GetBestMonTypeMatchup(struct Pokemon *party, int firstId, int lastId, while (bits != 0x3F) // All mons were checked. { - u32 bestResist = UQ_4_12(1.0); + u16 bestResist = UQ_4_12(1.0); int bestMonId = PARTY_SIZE; // Find the mon whose type is the most suitable defensively. for (i = firstId; i < lastId; i++) @@ -830,21 +830,21 @@ static u32 GetBestMonTypeMatchup(struct Pokemon *party, int firstId, int lastId, if (!(gBitTable[i] & invalidMons) && !(gBitTable[i] & bits)) { u16 species = GetMonData(&party[i], MON_DATA_SPECIES); - u32 typeEffectiveness = UQ_4_12(1.0); + u16 typeEffectiveness = UQ_4_12(1.0); u8 atkType1 = gBattleMons[opposingBattler].type1; u8 atkType2 = gBattleMons[opposingBattler].type2; u8 defType1 = gSpeciesInfo[species].types[0]; u8 defType2 = gSpeciesInfo[species].types[1]; - typeEffectiveness *= GetTypeModifier(atkType1, defType1); + MulModifier(&typeEffectiveness, (GetTypeModifier(atkType1, defType1))); if (atkType2 != atkType1) - typeEffectiveness *= GetTypeModifier(atkType2, defType1); + MulModifier(&typeEffectiveness, (GetTypeModifier(atkType2, defType1))); if (defType2 != defType1) { - typeEffectiveness *= GetTypeModifier(atkType1, defType2); + MulModifier(&typeEffectiveness, (GetTypeModifier(atkType1, defType2))); if (atkType2 != atkType1) - typeEffectiveness *= GetTypeModifier(atkType2, defType2); + MulModifier(&typeEffectiveness, (GetTypeModifier(atkType2, defType2))); } if (typeEffectiveness < bestResist) { diff --git a/src/battle_util.c b/src/battle_util.c index 93d0233630..e608b0e51f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8341,7 +8341,7 @@ u32 GetMoveTargetCount(u16 move, u8 battlerAtk, u8 battlerDef) } } -static void MulModifier(u16 *modifier, u16 val) +void MulModifier(u16 *modifier, u16 val) { *modifier = UQ_4_12_TO_INT((*modifier * val) + UQ_4_12_ROUND); } From c911d4bf57ecc4aad6cc9f366ff750df58ce4951 Mon Sep 17 00:00:00 2001 From: voloved <36523934+voloved@users.noreply.github.com> Date: Wed, 21 Jun 2023 13:19:08 -0400 Subject: [PATCH 3/3] Made window's starting location track with ball; made window show if it's showing on startup (#3042) --- src/battle_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_interface.c b/src/battle_interface.c index 518bad2c94..35f4413a89 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -3258,7 +3258,7 @@ static const struct SpriteSheet sSpriteSheet_LastUsedBallWindow = #define LAST_USED_BALL_Y ((IsDoubleBattle()) ? 78 : 68) #define LAST_BALL_WIN_X_F (LAST_USED_BALL_X_F - 1) -#define LAST_BALL_WIN_X_0 (LAST_USED_BALL_X_0 - 0) +#define LAST_BALL_WIN_X_0 (LAST_USED_BALL_X_0 - 1) #define LAST_USED_WIN_Y (LAST_USED_BALL_Y - 8) #define sHide data[0] @@ -3314,7 +3314,7 @@ void TryAddLastUsedBallItemSprites(void) gBattleStruct->ballSpriteIds[1] = CreateSprite(&sSpriteTemplate_LastUsedBallWindow, LAST_BALL_WIN_X_0, LAST_USED_WIN_Y, 5); - gSprites[gBattleStruct->ballSpriteIds[0]].sHide = FALSE; // restore + gSprites[gBattleStruct->ballSpriteIds[1]].sHide = FALSE; // restore } #endif }