From 0d39b296912f5d4ec847baf1e2c6e744e7a80f3b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Thu, 15 Oct 2020 00:16:50 -0300 Subject: [PATCH] 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 f20e25019..4cf4a3a16 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 2bd6c8cb1..913dcaa91 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 73f528b2d..fda1616c3 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 d9230d6d0..107e1893a 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 17375b24c..f3a643e73 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 5cabacb69..6e7ed2996 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 797f42f6e..9fda2642d 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); }