From 0d39b296912f5d4ec847baf1e2c6e744e7a80f3b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 15 Oct 2020 00:16:50 -0300 Subject: [PATCH 1/3] Option to use Gen 3 Physical/Special split. --- include/battle.h | 5 +++-- include/battle_util.h | 1 + include/constants/battle_config.h | 1 + src/battle_ai_script_commands.c | 11 ++++++----- src/battle_main.c | 2 +- src/battle_util.c | 12 +++++++++++- src/pokemon_summary_screen.c | 2 +- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/include/battle.h b/include/battle.h index f20e250196..4cf4a3a169 100644 --- a/include/battle.h +++ b/include/battle.h @@ -549,8 +549,9 @@ struct BattleStruct typeArg = gBattleMoves[move].type; \ } -#define IS_MOVE_PHYSICAL(move)(gBattleMoves[move].split == SPLIT_PHYSICAL) -#define IS_MOVE_SPECIAL(move)(gBattleMoves[move].split == SPLIT_SPECIAL) +#define IS_MOVE_PHYSICAL(move)(GetBattleMoveSplit(move) == SPLIT_PHYSICAL) +#define IS_MOVE_SPECIAL(move)(GetBattleMoveSplit(move) == SPLIT_SPECIAL) +#define IS_MOVE_STATUS(move)(gBattleMoves[move].split == SPLIT_STATUS) #define BATTLER_MAX_HP(battlerId)(gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP) #define TARGET_TURN_DAMAGED ((gSpecialStatuses[gBattlerTarget].physicalDmg != 0 || gSpecialStatuses[gBattlerTarget].specialDmg != 0)) diff --git a/include/battle_util.h b/include/battle_util.h index 2bd6c8cb13..913dcaa911 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -127,5 +127,6 @@ bool32 CanBattlerGetOrLoseItem(u8 battlerId, u16 itemId); struct Pokemon *GetIllusionMonPtr(u32 battlerId); void ClearIllusionMon(u32 battlerId); bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId); +u8 GetBattleMoveSplit(u32 moveId); #endif // GUARD_BATTLE_UTIL_H diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 73f528b2d9..fda1616c39 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -72,6 +72,7 @@ #define B_PSYWAVE_DMG GEN_6 // Psywave's damage formula. See Cmd_psywavedamageeffect. // Move settings +#define B_PHYSICAL_SPECIAL_SPLIT GEN_3 // In Gen3, the move's type determines if it will do physical or special damage. #define B_FELL_STINGER_STAT_RAISE GEN_6 // In Gen7+, it raises Atk by 3 stages instead of 2 if it causes the target to faint. #define B_SOUND_SUBSTITUTE GEN_6 // In Gen6+, sound moves bypass Substitute. #define B_TOXIC_NEVER_MISS GEN_6 // In Gen6+, if Toxic is used by a Poison type, it will never miss. diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index d9230d6d06..107e1893af 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -3,6 +3,7 @@ #include "battle.h" #include "battle_anim.h" #include "battle_ai_script_commands.h" +#include "battle_config.h" #include "battle_factory.h" #include "battle_setup.h" #include "data.h" @@ -2607,7 +2608,7 @@ static bool32 HasMoveWithSplit(u32 battler, u32 split) for (i = 0; i < MAX_MON_MOVES; i++) { - if (moves[i] != MOVE_NONE && moves[i] != 0xFFFF && gBattleMoves[moves[i]].split == split) + if (moves[i] != MOVE_NONE && moves[i] != 0xFFFF && GetBattleMoveSplit(moves[i]) == split) return TRUE; } @@ -2643,7 +2644,7 @@ static bool32 MovesWithSplitUnusable(u32 attacker, u32 target, u32 split) { if (moves[i] != MOVE_NONE && moves[i] != 0xFFFF - && gBattleMoves[moves[i]].split == split + && GetBattleMoveSplit(moves[i]) == split && !(unusable & gBitTable[i])) { SetTypeBeforeUsingMove(moves[i], attacker); @@ -2801,19 +2802,19 @@ static void Cmd_get_curr_dmg_hp_percent(void) static void Cmd_get_move_split_from_result(void) { - AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->funcResult].split; + AI_THINKING_STRUCT->funcResult = GetBattleMoveSplit(AI_THINKING_STRUCT->funcResult); gAIScriptPtr += 1; } static void Cmd_get_considered_move_split(void) { - AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].split; + AI_THINKING_STRUCT->funcResult = GetBattleMoveSplit(AI_THINKING_STRUCT->moveConsidered); gAIScriptPtr += 1; } static void Cmd_get_considered_move_target(void) { - AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].target; + AI_THINKING_STRUCT->funcResult = GetBattleMoveSplit(AI_THINKING_STRUCT->moveConsidered); gAIScriptPtr += 1; } diff --git a/src/battle_main.c b/src/battle_main.c index 17375b24c7..f3a643e737 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4288,7 +4288,7 @@ s8 GetMovePriority(u32 battlerId, u16 move) priority++; } else if (GetBattlerAbility(battlerId) == ABILITY_PRANKSTER - && gBattleMoves[move].split == SPLIT_STATUS) + && GetBattleMoveSplit(move) == SPLIT_STATUS) { priority++; } diff --git a/src/battle_util.c b/src/battle_util.c index 5cabacb69f..6e7ed2996b 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4247,7 +4247,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && TARGET_TURN_DAMAGED && IsBattlerAlive(battler) - && gBattleMoves[gCurrentMove].split == SPLIT_PHYSICAL + && GetBattleMoveSplit(gCurrentMove) == SPLIT_PHYSICAL && (gBattleMons[battler].statStages[STAT_SPEED] != 12 || gBattleMons[battler].statStages[STAT_DEF] != 0)) { BattleScriptPushCursor(); @@ -7665,3 +7665,13 @@ bool32 SetIllusionMon(struct Pokemon *mon, u32 battlerId) return FALSE; } + +u8 GetBattleMoveSplit(u32 moveId) +{ + if (IS_MOVE_STATUS(moveId) || B_PHYSICAL_SPECIAL_SPLIT >= GEN_4) + return gBattleMoves[moveId].split; + else if (gBattleMoves[moveId].type < TYPE_MYSTERY) + return SPLIT_PHYSICAL; + else + return SPLIT_SPECIAL; +} diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 797f42f6e2..9fda2642d7 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -3708,7 +3708,7 @@ static void PrintMoveDetails(u16 move) { if (sMonSummaryScreen->currPageIndex == PSS_PAGE_BATTLE_MOVES) { - ShowSplitIcon(gBattleMoves[move].split); + ShowSplitIcon(GetBattleMoveSplit(move)); PrintMovePowerAndAccuracy(move); PrintTextOnWindow(windowId, gMoveDescriptionPointers[move - 1], 6, 1, 0, 0); } From a6e88b82ee67c58216ecfea39b2de083e224ecd5 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 15 Oct 2020 20:15:44 -0300 Subject: [PATCH 2/3] Review changes and option to hide split icon. --- include/constants/battle_config.h | 39 +++++++++++++++++-------------- src/battle_ai_script_commands.c | 1 - src/battle_main.c | 3 +-- src/battle_util.c | 2 +- src/pokemon_summary_screen.c | 4 +++- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index fda1616c39..93e8dfb777 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -72,7 +72,7 @@ #define B_PSYWAVE_DMG GEN_6 // Psywave's damage formula. See Cmd_psywavedamageeffect. // Move settings -#define B_PHYSICAL_SPECIAL_SPLIT GEN_3 // In Gen3, the move's type determines if it will do physical or special damage. +#define B_PHYSICAL_SPECIAL_SPLIT GEN_6 // In Gen3, the move's type determines if it will do physical or special damage. The split icon in the summary will reflect this. #define B_FELL_STINGER_STAT_RAISE GEN_6 // In Gen7+, it raises Atk by 3 stages instead of 2 if it causes the target to faint. #define B_SOUND_SUBSTITUTE GEN_6 // In Gen6+, sound moves bypass Substitute. #define B_TOXIC_NEVER_MISS GEN_6 // In Gen6+, if Toxic is used by a Poison type, it will never miss. @@ -98,29 +98,32 @@ #define B_HP_BERRIES GEN_6 // In Gen4+, berries which restore hp activate immediately after hp drops to half. In gen3, the effect occurs at the end of the turn. #define B_BERRIES_INSTANT GEN_6 // 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. -// Other -#define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water. 0 disables the feature. +// Interface settings #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. + +// Other +#define B_FLAG_INVERSE_BATTLE 0 // If this flag is set, the battle's type effectiveness are inversed. For example, fire is super effective against water. 0 disables the feature. #define B_SLEEP_TURNS GEN_6 // In Gen5+, sleep lasts for 1-3 turns instead of 2-5 turns. #define B_PARALYZE_ELECTRIC GEN_6 // In Gen6+, Electric type Pokémon can't be paralyzed. #define B_POWDER_GRASS GEN_6 // In Gen6+, Grass type Pokémon are immune to powder and spore moves. // Animation Settings -#define NEW_SWORD_PARTICLE TRUE // update swords dance particle -#define NEW_LEECH_SEED_PARTICLE TRUE //update leech seed's animation particle -#define NEW_HORN_ATTACK_PARTICLE TRUE //update horn attack's horn -#define NEW_LEAF_PARTICLE TRUE // update leaf particle -#define NEW_EMBER_PARTICLES TRUE //updates ember fire particle -#define NEW_MEAN_LOOK_PARTICLE TRUE //update mean look eye -#define NEW_TEETH_PARTICLE TRUE //update bite/crunch teeth particle -#define NEW_HANDS_FEET_PARTICLE TRUE //update chop/kick/punch particles -#define NEW_SPIKES_PARTICLE TRUE //update spikes particle -#define NEW_FLY_BUBBLE_PARTICLE TRUE //update fly 'bubble' particle -#define NEW_CURSE_NAIL_PARTICLE TRUE //updates curse nail -#define NEW_BATON_PASS_BALL_PARTICLE TRUE //update baton pass pokeball sprite -#define NEW_MORNING_SUN_STAR_PARTICLE TRUE //updates morning sun star particles -#define NEW_IMPACT_PALETTE TRUE //updates the basic 'hit' particle -#define NEW_SURF_PARTICLE_PALETTE TRUE //updates the surf wave palette +#define NEW_SWORD_PARTICLE TRUE // If set to TRUE, it updates Swords Dance's particle. +#define NEW_LEECH_SEED_PARTICLE TRUE // If set to TRUE, it updates Leech Seed's animation particle. +#define NEW_HORN_ATTACK_PARTICLE TRUE // If set to TRUE, it updates Horn Attack's horn particle. +#define NEW_LEAF_PARTICLE TRUE // If set to TRUE, it updates leaf particle. +#define NEW_EMBER_PARTICLES TRUE // If set to TRUE, it updates Ember's fire particle. +#define NEW_MEAN_LOOK_PARTICLE TRUE // If set to TRUE, it updates Mean Look's eye particle. +#define NEW_TEETH_PARTICLE TRUE // If set to TRUE, it updates Bite/Crunch teeth particle. +#define NEW_HANDS_FEET_PARTICLE TRUE // If set to TRUE, it updates chop/kick/punch particles. +#define NEW_SPIKES_PARTICLE TRUE // If set to TRUE, it updates Spikes particle. +#define NEW_FLY_BUBBLE_PARTICLE TRUE // If set to TRUE, it updates Fly's 'bubble' particle. +#define NEW_CURSE_NAIL_PARTICLE TRUE // If set to TRUE, it updates Curse's nail. +#define NEW_BATON_PASS_BALL_PARTICLE TRUE // If set to TRUE, it updates Baton Pass' Poké Ball sprite. +#define NEW_MORNING_SUN_STAR_PARTICLE TRUE // If set to TRUE, it updates Morning Sun's star particles. +#define NEW_IMPACT_PALETTE TRUE // If set to TRUE, it updates the basic 'hit' palette. +#define NEW_SURF_PARTICLE_PALETTE TRUE // If set to TRUE, it updates Surf's wave palette. #endif // GUARD_CONSTANTS_BATTLE_CONFIG_H diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 107e1893af..0515143471 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -3,7 +3,6 @@ #include "battle.h" #include "battle_anim.h" #include "battle_ai_script_commands.h" -#include "battle_config.h" #include "battle_factory.h" #include "battle_setup.h" #include "data.h" diff --git a/src/battle_main.c b/src/battle_main.c index f3a643e737..4d74db3322 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4287,8 +4287,7 @@ s8 GetMovePriority(u32 battlerId, u16 move) { priority++; } - else if (GetBattlerAbility(battlerId) == ABILITY_PRANKSTER - && GetBattleMoveSplit(move) == SPLIT_STATUS) + else if (GetBattlerAbility(battlerId) == ABILITY_PRANKSTER && IS_MOVE_STATUS(move)) { priority++; } diff --git a/src/battle_util.c b/src/battle_util.c index 6e7ed2996b..74ccfda60a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -4247,7 +4247,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && TARGET_TURN_DAMAGED && IsBattlerAlive(battler) - && GetBattleMoveSplit(gCurrentMove) == SPLIT_PHYSICAL + && IS_MOVE_PHYSICAL(gCurrentMove) && (gBattleMons[battler].statStages[STAT_SPEED] != 12 || gBattleMons[battler].statStages[STAT_DEF] != 0)) { BattleScriptPushCursor(); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 9fda2642d7..93b20fef80 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -46,6 +46,7 @@ #include "constants/region_map_sections.h" #include "constants/rgb.h" #include "constants/songs.h" +#include "constants/battle_config.h" // Screen titles (upper left) #define PSS_LABEL_WINDOW_POKEMON_INFO_TITLE 0 @@ -3708,7 +3709,8 @@ static void PrintMoveDetails(u16 move) { if (sMonSummaryScreen->currPageIndex == PSS_PAGE_BATTLE_MOVES) { - ShowSplitIcon(GetBattleMoveSplit(move)); + if (B_SHOW_SPLIT_ICON == TRUE) + ShowSplitIcon(GetBattleMoveSplit(move)); PrintMovePowerAndAccuracy(move); PrintTextOnWindow(windowId, gMoveDescriptionPointers[move - 1], 6, 1, 0, 0); } From 27a31224aaba3cad257eb22b7014bec60dbd31b8 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Fri, 23 Oct 2020 21:50:25 -0300 Subject: [PATCH 3/3] Fixed mix up. --- src/battle_ai_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 0515143471..39246c732e 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -2813,7 +2813,7 @@ static void Cmd_get_considered_move_split(void) static void Cmd_get_considered_move_target(void) { - AI_THINKING_STRUCT->funcResult = GetBattleMoveSplit(AI_THINKING_STRUCT->moveConsidered); + AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].target; gAIScriptPtr += 1; }