From 8494306d1d9fc13b40b3070c7476472418323726 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Wed, 7 Apr 2021 15:57:13 -0500 Subject: [PATCH 1/7] Rename flags --- include/constants/pokemon.h | 4 ++-- src/battle_script_commands.c | 2 +- src/battle_util.c | 2 +- src/data/battle_moves.h | 14 +++++++------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 5579102f5b..846a03e3f1 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -312,8 +312,8 @@ #define FLAG_POWDER (1 << 19) #define FLAG_TARGET_ABILITY_IGNORED (1 << 20) #define FLAG_DANCE (1 << 21) -#define FLAG_DMG_IN_AIR (1 << 22) // X2 dmg on air, always hits target on air -#define FLAG_HIT_IN_AIR (1 << 23) // dmg is normal, always hits target on air +#define FLAG_DMG_2X_IN_AIR (1 << 22) // X2 dmg on air, always hits target on air +#define FLAG_DMG_IN_AIR (1 << 23) // dmg is normal, always hits target on air // Split defines. #define SPLIT_PHYSICAL 0x0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a2151c157c..afd8bcace0 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1471,7 +1471,7 @@ static bool32 AccuracyCalcHelper(u16 move) } if ((gStatuses3[gBattlerTarget] & STATUS3_PHANTOM_FORCE) - || (!(gBattleMoves[move].flags & FLAG_HIT_IN_AIR) && gStatuses3[gBattlerTarget] & STATUS3_ON_AIR) + || (!(gBattleMoves[move].flags & FLAG_DMG_IN_AIR) && gStatuses3[gBattlerTarget] & STATUS3_ON_AIR) || (!(gBattleMoves[move].flags & FLAG_DMG_UNDERGROUND) && gStatuses3[gBattlerTarget] & STATUS3_UNDERGROUND) || (!(gBattleMoves[move].flags & FLAG_DMG_UNDERWATER) && gStatuses3[gBattlerTarget] & STATUS3_UNDERWATER)) { diff --git a/src/battle_util.c b/src/battle_util.c index 31c99084a7..c40e3595ef 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7754,7 +7754,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move MulModifier(&finalModifier, UQ_4_12(2.0)); if (gBattleMoves[move].flags & FLAG_DMG_UNDERWATER && gStatuses3[battlerDef] & STATUS3_UNDERWATER) MulModifier(&finalModifier, UQ_4_12(2.0)); - if (gBattleMoves[move].flags & FLAG_DMG_IN_AIR && gStatuses3[battlerDef] & STATUS3_ON_AIR) + if (gBattleMoves[move].flags & FLAG_DMG_2X_IN_AIR && gStatuses3[battlerDef] & STATUS3_ON_AIR) MulModifier(&finalModifier, UQ_4_12(2.0)); dmg = ApplyModifier(finalModifier, dmg); diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 661af2eab5..2b2e471055 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -242,7 +242,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_2X_IN_AIR, .split = SPLIT_SPECIAL, }, @@ -1383,7 +1383,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_HIT_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_IN_AIR, .split = SPLIT_SPECIAL, }, @@ -3750,7 +3750,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 20, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_2X_IN_AIR, .split = SPLIT_SPECIAL, }, @@ -5138,7 +5138,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_IRON_FIST_BOOST | FLAG_HIT_IN_AIR, + .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_IRON_FIST_BOOST | FLAG_DMG_IN_AIR, .split = SPLIT_PHYSICAL, }, @@ -7488,7 +7488,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIT_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR, .split = SPLIT_PHYSICAL, }, @@ -8436,7 +8436,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 30, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_HIT_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST | FLAG_DMG_IN_AIR, .split = SPLIT_SPECIAL, }, @@ -9491,7 +9491,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 0, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIT_IN_AIR, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR, .split = SPLIT_PHYSICAL, }, From 0e96b4758414f5ca03e0e27c3c50833a65053218 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Fri, 4 Jun 2021 18:50:11 -0500 Subject: [PATCH 2/7] Review comments --- include/constants/pokemon.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 846a03e3f1..a6f51d6103 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -312,8 +312,8 @@ #define FLAG_POWDER (1 << 19) #define FLAG_TARGET_ABILITY_IGNORED (1 << 20) #define FLAG_DANCE (1 << 21) -#define FLAG_DMG_2X_IN_AIR (1 << 22) // X2 dmg on air, always hits target on air -#define FLAG_DMG_IN_AIR (1 << 23) // dmg is normal, always hits target on air +#define FLAG_DMG_2X_IN_AIR (1 << 22) // If target is in the air, can hit and deal double damage. +#define FLAG_DMG_IN_AIR (1 << 23) // If target is in the air, can hit. // Split defines. #define SPLIT_PHYSICAL 0x0 From ec2c140ecbc35863410044b169738c6f3c970915 Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Fri, 4 Jun 2021 19:34:37 -0500 Subject: [PATCH 3/7] Disambiguate Thousand Arrows flag from other flags --- include/constants/pokemon.h | 2 +- src/battle_util.c | 4 ++-- src/data/battle_moves.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index a8d988ad8e..5e030698c3 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -314,7 +314,7 @@ #define FLAG_DANCE (1 << 21) #define FLAG_DMG_2X_IN_AIR (1 << 22) // If target is in the air, can hit and deal double damage. #define FLAG_DMG_IN_AIR (1 << 23) // If target is in the air, can hit. -#define FLAG_DAMAGE_AIRBORNE (1 << 24) // Makes a Ground type move do 1x damage to flying and levitating targets +#define FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING (1 << 24) // Makes a Ground type move do 1x damage to flying and levitating targets // Split defines. diff --git a/src/battle_util.c b/src/battle_util.c index a89063f788..86e0579955 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8092,7 +8092,7 @@ static u16 CalcTypeEffectivenessMultiplierInternal(u16 move, u8 moveType, u8 bat && gBattleMons[battlerDef].type3 != gBattleMons[battlerDef].type1) MulByTypeEffectiveness(&modifier, move, moveType, battlerDef, gBattleMons[battlerDef].type3, battlerAtk, recordAbilities); - if (moveType == TYPE_GROUND && !IsBattlerGrounded(battlerDef) && !(gBattleMoves[move].flags & FLAG_DAMAGE_AIRBORNE)) + if (moveType == TYPE_GROUND && !IsBattlerGrounded(battlerDef) && !(gBattleMoves[move].flags & FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING)) { modifier = UQ_4_12(0.0); if (recordAbilities && GetBattlerAbility(battlerDef) == ABILITY_LEVITATE) @@ -8106,7 +8106,7 @@ static u16 CalcTypeEffectivenessMultiplierInternal(u16 move, u8 moveType, u8 bat } // Thousand Arrows ignores type modifiers for flying mons - if (!IsBattlerGrounded(battlerDef) && (gBattleMoves[move].flags & FLAG_DAMAGE_AIRBORNE) + if (!IsBattlerGrounded(battlerDef) && (gBattleMoves[move].flags & FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING) && (gBattleMons[battlerDef].type1 == TYPE_FLYING || gBattleMons[battlerDef].type2 == TYPE_FLYING || gBattleMons[battlerDef].type3 == TYPE_FLYING)) { modifier = UQ_4_12(1.0); diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index caa343dfe4..db02083b0f 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9588,7 +9588,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 100, .target = MOVE_TARGET_BOTH, .priority = 0, - .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR | FLAG_DAMAGE_AIRBORNE, + .flags = FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_DMG_IN_AIR | FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING, .split = SPLIT_PHYSICAL, }, From 4bb33367dfb488d7d8105142954fc45fefe3ac2a Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Fri, 4 Jun 2021 19:35:16 -0500 Subject: [PATCH 4/7] Newline --- include/constants/pokemon.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 5e030698c3..322bee7061 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -316,7 +316,6 @@ #define FLAG_DMG_IN_AIR (1 << 23) // If target is in the air, can hit. #define FLAG_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING (1 << 24) // Makes a Ground type move do 1x damage to flying and levitating targets - // Split defines. #define SPLIT_PHYSICAL 0x0 #define SPLIT_SPECIAL 0x1 From 88108098495a80f1cd394bace16ea3134de0174f Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Fri, 4 Jun 2021 19:39:03 -0500 Subject: [PATCH 5/7] Missed one rename! --- src/battle_ai_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 2e1dc71232..caabc7519d 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -1343,7 +1343,7 @@ bool32 IsSemiInvulnerable(u8 battlerDef, u16 move) { if (gStatuses3[battlerDef] & STATUS3_PHANTOM_FORCE) return TRUE; - else if (!TestMoveFlags(move, FLAG_HIT_IN_AIR) && gStatuses3[battlerDef] & STATUS3_ON_AIR) + else if (!TestMoveFlags(move, FLAG_DMG_IN_AIR) && gStatuses3[battlerDef] & STATUS3_ON_AIR) return TRUE; else if (!TestMoveFlags(move, FLAG_DMG_UNDERWATER) && gStatuses3[battlerDef] & STATUS3_UNDERWATER) return TRUE; From aefd5e26d14762073789e94159da0dfd0ccb8f72 Mon Sep 17 00:00:00 2001 From: ExpoSeed <43502820+ExpoSeed@users.noreply.github.com> Date: Fri, 4 Jun 2021 21:26:15 -0500 Subject: [PATCH 6/7] Update src/battle_util.c Co-authored-by: ultima-soul <33333039+ultima-soul@users.noreply.github.com> --- src/battle_util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 86e0579955..16ceb35a36 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7977,7 +7977,7 @@ static u32 CalcFinalDmg(u32 dmg, u16 move, u8 battlerAtk, u8 battlerDef, u8 move MulModifier(&finalModifier, UQ_4_12(2.0)); if (gBattleMoves[move].flags & FLAG_DMG_UNDERWATER && gStatuses3[battlerDef] & STATUS3_UNDERWATER) MulModifier(&finalModifier, UQ_4_12(2.0)); - if (gBattleMoves[move].flags & FLAG_DMG_2X_IN_AIR && gStatuses3[battlerDef] & STATUS3_ON_AIR) + if (gBattleMoves[move].flags & FLAG_DMG_2X_IN_AIR && gStatuses3[battlerDef] & STATUS3_ON_AIR) MulModifier(&finalModifier, UQ_4_12(2.0)); dmg = ApplyModifier(finalModifier, dmg); @@ -8661,4 +8661,3 @@ bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability) } return FALSE; } - From 12a155bd9a89d8af8332d39a1b7fa67804ceb5ca Mon Sep 17 00:00:00 2001 From: ExpoSeed <> Date: Fri, 4 Jun 2021 21:28:28 -0500 Subject: [PATCH 7/7] FLAG_DMG_2X_IN_AIR can now hit targets --- src/battle_script_commands.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 463c27e683..edefead6b5 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1542,6 +1542,7 @@ static bool32 AccuracyCalcHelper(u16 move) if ((gStatuses3[gBattlerTarget] & STATUS3_PHANTOM_FORCE) || (!(gBattleMoves[move].flags & FLAG_DMG_IN_AIR) && gStatuses3[gBattlerTarget] & STATUS3_ON_AIR) + || (!(gBattleMoves[move].flags & FLAG_DMG_2X_IN_AIR) && gStatuses3[gBattlerTarget] & STATUS3_ON_AIR) || (!(gBattleMoves[move].flags & FLAG_DMG_UNDERGROUND) && gStatuses3[gBattlerTarget] & STATUS3_UNDERGROUND) || (!(gBattleMoves[move].flags & FLAG_DMG_UNDERWATER) && gStatuses3[gBattlerTarget] & STATUS3_UNDERWATER)) {