From c428d1bdbbff34858304a13d2c70ddeabc3cd38b Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 23 May 2021 17:59:14 -0700 Subject: [PATCH 01/85] Coded Hyperspace Fury --- data/battle_scripts_1.s | 11 +++++++++++ include/battle_scripts.h | 1 + src/battle_script_commands.c | 7 ++++++- src/data/battle_moves.h | 10 +++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 77eddc8ab..3c59041b6 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6058,6 +6058,17 @@ BattleScript_AtkDefDownTryDef: BattleScript_AtkDefDownRet: return +BattleScript_DefDown:: + setbyte sSTAT_ANIM_PLAYED, FALSE + playstatchangeanimation BS_ATTACKER, BIT_DEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE + setstatchanger STAT_DEF, 1, TRUE + statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | STAT_BUFF_ALLOW_PTR, BattleScript_DefDownRet + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_DefDownRet + printfromtable gStatDownStringIds + waitmessage 0x40 +BattleScript_DefDownRet: + return + BattleScript_DefSpDefDown:: setbyte sSTAT_ANIM_PLAYED, FALSE playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE | STAT_CHANGE_MULTIPLE_STATS diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 0b94a6ae7..196383dc3 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -90,6 +90,7 @@ extern const u8 BattleScript_SelectingNotAllowedMoveTauntInPalace[]; extern const u8 BattleScript_WishComesTrue[]; extern const u8 BattleScript_IngrainTurnHeal[]; extern const u8 BattleScript_AtkDefDown[]; +extern const u8 BattleScript_DefDown[]; // Hyperspace Fury extern const u8 BattleScript_DefSpDefDown[]; extern const u8 BattleScript_KnockedOff[]; extern const u8 BattleScript_MoveUsedIsImprisoned[]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index fc0eedcbc..b990f7d7d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3148,7 +3148,12 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } - } + } + if (gCurrentMove == MOVE_HYPERSPACE_FURY) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_DefDown; + } break; case MOVE_EFFECT_SPECTRAL_THIEF: gBattleStruct->stolenStats[0] = 0; // Stats to steal. diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 61050e44f..fa1d54c39 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9581,15 +9581,15 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_HYPERSPACE_FURY] = { - .effect = EFFECT_PLACEHOLDER, - .power = 0, + .effect = EFFECT_FEINT, + .power = 100, .type = TYPE_DARK, .accuracy = 0, - .pp = 0, - .secondaryEffectChance = 0, + .pp = 5, + .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = 0, + .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, }, From 0d47269798452d1fa05fde08e25323f0c605b003 Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 23 May 2021 18:11:53 -0700 Subject: [PATCH 02/85] Spaces instead of tabs --- src/battle_script_commands.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b990f7d7d..ede3d16a3 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3149,11 +3149,11 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } } - if (gCurrentMove == MOVE_HYPERSPACE_FURY) - { - BattleScriptPush(gBattlescriptCurrInstr + 1); - gBattlescriptCurrInstr = BattleScript_DefDown; - } + if (gCurrentMove == MOVE_HYPERSPACE_FURY) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_DefDown; + } break; case MOVE_EFFECT_SPECTRAL_THIEF: gBattleStruct->stolenStats[0] = 0; // Stats to steal. From 07a9674d22dc60fb2f5f059573ec48a950803d0c Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 23 May 2021 18:30:22 -0700 Subject: [PATCH 03/85] Fixed --- data/battle_scripts_1.s | 11 ----------- include/battle_scripts.h | 1 - src/battle_script_commands.c | 5 ----- src/data/battle_moves.h | 3 ++- 4 files changed, 2 insertions(+), 18 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3c59041b6..77eddc8ab 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6058,17 +6058,6 @@ BattleScript_AtkDefDownTryDef: BattleScript_AtkDefDownRet: return -BattleScript_DefDown:: - setbyte sSTAT_ANIM_PLAYED, FALSE - playstatchangeanimation BS_ATTACKER, BIT_DEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE - setstatchanger STAT_DEF, 1, TRUE - statbuffchange MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN | STAT_BUFF_ALLOW_PTR, BattleScript_DefDownRet - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, 0x2, BattleScript_DefDownRet - printfromtable gStatDownStringIds - waitmessage 0x40 -BattleScript_DefDownRet: - return - BattleScript_DefSpDefDown:: setbyte sSTAT_ANIM_PLAYED, FALSE playstatchangeanimation BS_ATTACKER, BIT_DEF | BIT_SPDEF, STAT_CHANGE_CANT_PREVENT | STAT_CHANGE_NEGATIVE | STAT_CHANGE_MULTIPLE_STATS diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 196383dc3..0b94a6ae7 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -90,7 +90,6 @@ extern const u8 BattleScript_SelectingNotAllowedMoveTauntInPalace[]; extern const u8 BattleScript_WishComesTrue[]; extern const u8 BattleScript_IngrainTurnHeal[]; extern const u8 BattleScript_AtkDefDown[]; -extern const u8 BattleScript_DefDown[]; // Hyperspace Fury extern const u8 BattleScript_DefSpDefDown[]; extern const u8 BattleScript_KnockedOff[]; extern const u8 BattleScript_MoveUsedIsImprisoned[]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ede3d16a3..e9fce3ac6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3149,11 +3149,6 @@ void SetMoveEffect(bool32 primary, u32 certain) gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } } - if (gCurrentMove == MOVE_HYPERSPACE_FURY) - { - BattleScriptPush(gBattlescriptCurrInstr + 1); - gBattlescriptCurrInstr = BattleScript_DefDown; - } break; case MOVE_EFFECT_SPECTRAL_THIEF: gBattleStruct->stolenStats[0] = 0; // Stats to steal. diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index fa1d54c39..5a9de6b9e 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9581,7 +9581,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_HYPERSPACE_FURY] = { - .effect = EFFECT_FEINT, + .effect = EFFECT_ATTACKER_DEFENSE_DOWN_HIT, .power = 100, .type = TYPE_DARK, .accuracy = 0, @@ -9591,6 +9591,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .priority = 0, .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, + .argument = MOVE_EFFECT_FEINT, }, [MOVE_SHORE_UP] = From 031504cd1217c3a0358b3e3466a09ecf02da7118 Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 23 May 2021 18:31:49 -0700 Subject: [PATCH 04/85] Spaces instead of tabs --- src/battle_script_commands.c | 2 +- src/data/battle_moves.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index e9fce3ac6..fc0eedcbc 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3148,7 +3148,7 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } - } + } break; case MOVE_EFFECT_SPECTRAL_THIEF: gBattleStruct->stolenStats[0] = 0; // Stats to steal. diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 5a9de6b9e..689218c3a 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9591,7 +9591,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .priority = 0, .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, .split = SPLIT_PHYSICAL, - .argument = MOVE_EFFECT_FEINT, + .argument = MOVE_EFFECT_FEINT, }, [MOVE_SHORE_UP] = From bfc66a21cc6a03ea34e3f1dd4d8647a7943b54fd Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sun, 6 Jun 2021 19:14:11 -0700 Subject: [PATCH 05/85] `gBattlescriptCurrInstr[3]` is not reading `species` parameter --- asm/macros/battle_script.inc | 6 ++++++ data/battle_scripts_1.s | 13 +++++++++++++ include/constants/battle_config.h | 2 ++ include/constants/battle_move_effects.h | 3 ++- include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 4 +++- include/constants/pokemon.h | 1 + src/battle_message.c | 4 ++++ src/battle_script_commands.c | 8 ++++++++ src/data/battle_moves.h | 4 ++-- 10 files changed, 42 insertions(+), 4 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9fa3fe0c3..9d624195b 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1769,6 +1769,12 @@ various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH .endm + .macro jumpifspecies battler:req, species:req, ptr:req + various \battler, VARIOUS_JUMP_IF_SPECIES + .byte \species + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b5dc673a0..6fb81c9ac 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -11,6 +11,7 @@ #include "constants/game_stat.h" #include "constants/trainers.h" #include "constants/battle_config.h" +#include "constants/species.h" .include "asm/macros.inc" .include "asm/macros/battle_script.inc" .include "constants/constants.inc" @@ -369,6 +370,18 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectSleepHit .4byte BattleScript_EffectAttackerDefenseDownHit .4byte BattleScript_EffectBodyPress + .4byte BattleScript_EffectHyperspaceFury + +BattleScript_EffectHyperspaceFury: + jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectAttackerDefenseDownHit + jumpifspecies BS_ATTACKER, SPECIES_HOOPA, BattleScript_ButHoopaCantUseIt + printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd +BattleScript_ButHoopaCantUseIt: + printstring STRINGID_BUTHOOPACANTUSEIT + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd BattleScript_EffectAttackerDefenseDownHit: setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index fe376da8d..9e610b43c 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -35,6 +35,8 @@ #define SPECIES_ZYGARDE 0 // 50% #define SPECIES_ZYGARDE_10 10011 // 10 % #define SPECIES_ZYGARDE_COMPLETE 10012 // 100 % + #define SPECIES_HOOPA 0 + #define SPECIES_HOOPA_UNBOUND 10013 #endif // Items with peculiar battle effects. diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 6174ca496..0fa6dea89 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -353,7 +353,8 @@ #define EFFECT_SLEEP_HIT 347 // Relic Song #define EFFECT_ATTACKER_DEFENSE_DOWN_HIT 348 #define EFFECT_BODY_PRESS 349 +#define EFFECT_HYPERSPACE_FURY 350 -#define NUM_BATTLE_MOVE_EFFECTS 350 +#define NUM_BATTLE_MOVE_EFFECTS 351 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index faaf8f17e..87139bbe0 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -173,6 +173,7 @@ #define VARIOUS_DESTROY_ABILITY_POPUP 102 #define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 +#define VARIOUS_JUMP_IF_SPECIES 105 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 266aef147..9e3941324 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -570,8 +570,10 @@ #define STRINGID_MICLEBERRYACTIVATES 566 #define STRINGID_PKMNSHOOKOFFTHETAUNT 567 #define STRINGID_PKMNGOTOVERITSINFATUATION 568 +#define STRINGID_BUTPOKEMONCANTUSETHEMOVE 569 +#define STRINGID_BUTHOOPACANTUSEIT 570 -#define BATTLESTRINGS_COUNT 569 +#define BATTLESTRINGS_COUNT 571 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 322bee706..39157a53b 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -315,6 +315,7 @@ #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_DMG_UNGROUNDED_IGNORE_TYPE_IF_FLYING (1 << 24) // Makes a Ground type move do 1x damage to flying and levitating targets +#define FLAG_HIT_IN_SUBSTITUTE (1 << 25) // Hyperspace Fury // Split defines. #define SPLIT_PHYSICAL 0x0 diff --git a/src/battle_message.c b/src/battle_message.c index d4d5756f9..9f4de13d9 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -696,6 +696,8 @@ static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faste static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!"); static const u8 sText_PkmnShookOffTheTaunt[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} shook off\nthe taunt!"); static const u8 sText_PkmnGotOverItsInfatuation[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} got over\nits infatuation!"); +static const u8 sText_ButPokemonCantUseTheMove[] = _("But {B_ATK_NAME_WITH_PREFIX} can't\nuse the move!"); +static const u8 sText_ButHoopaCantUseIt[] = _("But Hoopa can't use it\nthe way it is now!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { @@ -1256,6 +1258,8 @@ const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = [STRINGID_AURABREAKENTERS - 12] = sText_AuraBreakActivates, [STRINGID_COMATOSEENTERS - 12] = sText_ComatoseActivates, [STRINGID_SCREENCLEANERENTERS - 12] = sText_ScreenCleanerActivates, + [STRINGID_BUTPOKEMONCANTUSETHEMOVE - 12] = sText_ButPokemonCantUseTheMove, + [STRINGID_BUTHOOPACANTUSEIT - 12] = sText_ButHoopaCantUseIt, }; const u16 gTerrainStringIds[] = diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 4c95ecb63..2a4b2e347 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8426,6 +8426,12 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe) } return; + case VARIOUS_JUMP_IF_SPECIES: + if (gBattleMons[gBattlerAttacker].species == gBattlescriptCurrInstr[3]) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4); + else + gBattlescriptCurrInstr += 8; + return; } gBattlescriptCurrInstr += 3; @@ -11862,6 +11868,8 @@ bool32 DoesSubstituteBlockMove(u8 battlerAtk, u8 battlerDef, u32 move) return FALSE; else if (GetBattlerAbility(battlerAtk) == ABILITY_INFILTRATOR) return FALSE; + else if (gBattleMoves[move].flags & FLAG_HIT_IN_SUBSTITUTE) + return FALSE; else return TRUE; } diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 7746b1196..ecc0f907b 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9678,7 +9678,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_HYPERSPACE_FURY] = { - .effect = EFFECT_ATTACKER_DEFENSE_DOWN_HIT, + .effect = EFFECT_HYPERSPACE_FURY, .power = 100, .type = TYPE_DARK, .accuracy = 0, @@ -9686,7 +9686,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .secondaryEffectChance = 100, .target = MOVE_TARGET_SELECTED, .priority = 0, - .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, + .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIT_IN_SUBSTITUTE, .split = SPLIT_PHYSICAL, .argument = MOVE_EFFECT_FEINT, }, From beb126b534a0df8af3ffb9d105b10793401665ac Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sat, 12 Jun 2021 13:58:54 -0700 Subject: [PATCH 06/85] Implemented Zippy Zap's effect --- data/battle_scripts_1.s | 5 +++++ include/constants/battle_move_effects.h | 3 ++- src/data/battle_moves.h | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 11616e300..39a5ddca7 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -369,6 +369,11 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectSleepHit .4byte BattleScript_EffectAttackerDefenseDownHit .4byte BattleScript_EffectBodyPress + .4byte BattleScript_EffectEvasionUpHit + +BattleScript_EffectEvasionUpHit: + setmoveeffect MOVE_EFFECT_EVS_PLUS_1 | MOVE_EFFECT_AFFECTS_USER + goto BattleScript_EffectHit BattleScript_EffectAttackerDefenseDownHit: setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 6174ca496..3e831cfd3 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -353,7 +353,8 @@ #define EFFECT_SLEEP_HIT 347 // Relic Song #define EFFECT_ATTACKER_DEFENSE_DOWN_HIT 348 #define EFFECT_BODY_PRESS 349 +#define EFFECT_EVASION_UP_HIT 350 -#define NUM_BATTLE_MOVE_EFFECTS 350 +#define NUM_BATTLE_MOVE_EFFECTS 351 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index db02083b0..41aad29f6 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10456,7 +10456,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = { #if B_UPDATED_MOVE_DATA >= GEN_8 .power = 80, - .effect = EFFECT_PLACEHOLDER, // TODO: EFFECT_EVASION_UP_HIT + .effect = EFFECT_EVASION_UP_HIT, // TODO: EFFECT_EVASION_UP_HIT .pp = 10, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, #else From 610b18bfdbfbf6564978385e37a84989d7e9c928 Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sat, 12 Jun 2021 14:27:50 -0700 Subject: [PATCH 07/85] Implemented Double Iron Bash's effect --- data/battle_scripts_1.s | 11 +++++++++++ include/constants/battle_move_effects.h | 3 ++- src/data/battle_moves.h | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 39a5ddca7..d41231dcd 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -370,6 +370,17 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectAttackerDefenseDownHit .4byte BattleScript_EffectBodyPress .4byte BattleScript_EffectEvasionUpHit + .4byte BattleScript_EffectDoubleIronBash + +BattleScript_EffectDoubleIronBash: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + setmultihitcounter 2 + initmultihitstring + sethword sMULTIHIT_EFFECT, MOVE_EFFECT_FLINCH + goto BattleScript_MultiHitLoop BattleScript_EffectEvasionUpHit: setmoveeffect MOVE_EFFECT_EVS_PLUS_1 | MOVE_EFFECT_AFFECTS_USER diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 3e831cfd3..d056edf6a 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -354,7 +354,8 @@ #define EFFECT_ATTACKER_DEFENSE_DOWN_HIT 348 #define EFFECT_BODY_PRESS 349 #define EFFECT_EVASION_UP_HIT 350 +#define EFFECT_DOUBLE_IRON_BASH 351 -#define NUM_BATTLE_MOVE_EFFECTS 351 +#define NUM_BATTLE_MOVE_EFFECTS 352 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 41aad29f6..4a917dc9b 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10456,7 +10456,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = { #if B_UPDATED_MOVE_DATA >= GEN_8 .power = 80, - .effect = EFFECT_EVASION_UP_HIT, // TODO: EFFECT_EVASION_UP_HIT + .effect = EFFECT_EVASION_UP_HIT, .pp = 10, .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_SHEER_FORCE_BOOST, #else @@ -10716,7 +10716,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = #else .flags = FLAG_MAKES_CONTACT | FLAG_PROTECT_AFFECTED | FLAG_MIRROR_MOVE_AFFECTED | FLAG_DMG_MINIMIZE | FLAG_IRON_FIST_BOOST | FLAG_SHEER_FORCE_BOOST, #endif - .effect = EFFECT_PLACEHOLDER, //TODO (EFFECT_FLINCH_HIT + EFFECT_DOUBLE_HIT) + .effect = EFFECT_DOUBLE_IRON_BASH, .power = 60, .type = TYPE_STEEL, .accuracy = 100, From 721dbe917849039df29644729aa879256b24fe16 Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sat, 12 Jun 2021 18:01:35 -0700 Subject: [PATCH 08/85] Implemented all PLG effects --- data/battle_scripts_1.s | 31 +++++++++++++++++++++++++ include/constants/battle_move_effects.h | 7 +++++- src/data/battle_moves.h | 10 ++++---- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d41231dcd..1343b0523 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -371,6 +371,37 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectBodyPress .4byte BattleScript_EffectEvasionUpHit .4byte BattleScript_EffectDoubleIronBash + .4byte BattleScript_EffectGlitzyGlow + .4byte BattleScript_EffectBaddyBad + .4byte BattleScript_EffectSappySeed + .4byte BattleScript_EffectFreezyFrost + .4byte BattleScript_EffectSparklySwirl + +BattleScript_EffectSparklySwirl: + healpartystatus + waitstate + updatestatusicon BS_ATTACKER_WITH_PARTNER + waitstate + goto BattleScript_EffectHit + +BattleScript_EffectFreezyFrost: + normalisebuffs + goto BattleScript_EffectHit + +BattleScript_EffectSappySeed: + jumpifstatus3 BS_TARGET, STATUS3_LEECHSEED, BattleScript_EffectHit + setseeded + goto BattleScript_EffectHit + +BattleScript_EffectBaddyBad: + jumpifsideaffecting BS_ATTACKER, SIDE_STATUS_REFLECT, BattleScript_EffectHit + setreflect + goto BattleScript_EffectHit + +BattleScript_EffectGlitzyGlow: + jumpifsideaffecting BS_ATTACKER, SIDE_STATUS_LIGHTSCREEN, BattleScript_EffectHit + setlightscreen + goto BattleScript_EffectHit BattleScript_EffectDoubleIronBash: attackcanceler diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index d056edf6a..884a83d60 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -355,7 +355,12 @@ #define EFFECT_BODY_PRESS 349 #define EFFECT_EVASION_UP_HIT 350 #define EFFECT_DOUBLE_IRON_BASH 351 +#define EFFECT_GLITZY_GLOW 352 +#define EFFECT_BADDY_BAD 353 +#define EFFECT_SAPPY_SEED 354 +#define EFFECT_FREEZY_FROST 355 +#define EFFECT_SPARKLY_SWIRL 356 -#define NUM_BATTLE_MOVE_EFFECTS 352 +#define NUM_BATTLE_MOVE_EFFECTS 357 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 4a917dc9b..df33efb21 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10599,7 +10599,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 100, .flags = FLAG_PROTECT_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, #endif - .effect = EFFECT_PLACEHOLDER, //TODO (Light Screen + Hit) + .effect = EFFECT_GLITZY_GLOW, .type = TYPE_PSYCHIC, .pp = 15, .secondaryEffectChance = 0, @@ -10619,7 +10619,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 100, .flags = FLAG_PROTECT_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, #endif - .effect = EFFECT_PLACEHOLDER, //TODO (Reflect + Hit) + .effect = EFFECT_BADDY_BAD, .type = TYPE_DARK, .pp = 15, .secondaryEffectChance = 0, @@ -10641,7 +10641,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .pp = 15, .flags = FLAG_PROTECT_AFFECTED | FLAG_MAGIC_COAT_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, #endif - .effect = EFFECT_PLACEHOLDER, //TODO (Leech Seed + Hit) + .effect = EFFECT_SAPPY_SEED, .type = TYPE_GRASS, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, @@ -10662,7 +10662,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .pp = 15, .flags = FLAG_PROTECT_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, #endif - .effect = EFFECT_PLACEHOLDER, //TODO (Haze + Hit) + .effect = EFFECT_FREEZY_FROST, .type = TYPE_ICE, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, @@ -10683,7 +10683,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .pp = 15, .flags = FLAG_PROTECT_AFFECTED | FLAG_KINGS_ROCK_AFFECTED, #endif - .effect = EFFECT_PLACEHOLDER, //TODO (Heal Bell + Hit) + .effect = EFFECT_SPARKLY_SWIRL, .type = TYPE_FAIRY, .secondaryEffectChance = 0, .target = MOVE_TARGET_SELECTED, From 32c8de5eca8b2ee46917d5bc6fb4988fb0a2224c Mon Sep 17 00:00:00 2001 From: MissingNoL Date: Sat, 12 Jun 2021 21:23:56 -0700 Subject: [PATCH 09/85] Finished! --- data/battle_scripts_1.s | 114 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 109 insertions(+), 5 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 1343b0523..13b8d720f 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -378,30 +378,134 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectSparklySwirl BattleScript_EffectSparklySwirl: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + tryfaintmon BS_TARGET, FALSE, NULL healpartystatus waitstate updatestatusicon BS_ATTACKER_WITH_PARTNER waitstate - goto BattleScript_EffectHit + goto BattleScript_MoveEnd BattleScript_EffectFreezyFrost: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + tryfaintmon BS_TARGET, FALSE, NULL normalisebuffs - goto BattleScript_EffectHit + printstring STRINGID_STATCHANGESGONE + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd BattleScript_EffectSappySeed: jumpifstatus3 BS_TARGET, STATUS3_LEECHSEED, BattleScript_EffectHit + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + tryfaintmon BS_TARGET, FALSE, NULL + jumpifhasnohp BS_TARGET, BattleScript_MoveEnd setseeded - goto BattleScript_EffectHit + printfromtable gLeechSeedStringIds + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd BattleScript_EffectBaddyBad: jumpifsideaffecting BS_ATTACKER, SIDE_STATUS_REFLECT, BattleScript_EffectHit + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + tryfaintmon BS_TARGET, FALSE, NULL setreflect - goto BattleScript_EffectHit + printfromtable gReflectLightScreenSafeguardStringIds + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd BattleScript_EffectGlitzyGlow: jumpifsideaffecting BS_ATTACKER, SIDE_STATUS_LIGHTSCREEN, BattleScript_EffectHit + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + tryfaintmon BS_TARGET, FALSE, NULL setlightscreen - goto BattleScript_EffectHit + printfromtable gReflectLightScreenSafeguardStringIds + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd BattleScript_EffectDoubleIronBash: attackcanceler From 4ca6d76160b01738d9fcd326643a89828a045b61 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 25 Jul 2021 14:55:52 -0600 Subject: [PATCH 10/85] add bug bite --- asm/macros/battle_script.inc | 5 ++++ data/battle_scripts_1.s | 5 ++++ include/battle.h | 1 + include/battle_util.h | 1 + include/constants/battle_script_commands.h | 2 ++ src/battle_script_commands.c | 31 ++++++++++++++++++++-- src/battle_util.c | 5 ++++ 7 files changed, 48 insertions(+), 2 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9fa3fe0c3..953180d91 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1768,6 +1768,11 @@ .macro tryactivategrimneigh, battler:req various \battler, VARIOUS_TRY_ACTIVATE_GRIM_NEIGH .endm + + .macro consumeberry battler:req, restoreItem=FALSE + various \battler, VARIOUS_CONSUME_BERRY + .byte \restoreItem + .endm @ helpful macros .macro setstatchanger stat:req, stages:req, down:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 522ffb701..d48076e48 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -508,6 +508,11 @@ BattleScript_MoveEffectIncinerate:: BattleScript_MoveEffectBugBite:: printstring STRINGID_BUGBITE waitmessage B_WAIT_TIME_LONG + orword gHitMarker, HITMARKER_NO_ANIMATIONS + setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries + consumeberry BS_ATTACKER, TRUE @ consume the berry, then restore the item from changedItems + bicword gHitMarker, HITMARKER_NO_ANIMATIONS + setbyte sBERRY_OVERRIDE, FALSE return BattleScript_EffectCoreEnforcer: diff --git a/include/battle.h b/include/battle.h index b51a3d71b..e82253747 100644 --- a/include/battle.h +++ b/include/battle.h @@ -659,6 +659,7 @@ struct BattleScripting u8 illusionNickHack; // To properly display nick in STRINGID_ENEMYABOUTTOSWITCHPKMN. bool8 fixedPopup; // force ability popup to stick until manually called back u16 abilityPopupOverwrite; + u8 overrideBerryRequirements; }; // rom_80A5C6C diff --git a/include/battle_util.h b/include/battle_util.h index e10305e56..bea6af848 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -31,6 +31,7 @@ #define ITEMEFFECT_KINGSROCK_SHELLBELL 0x4 #define ITEMEFFECT_TARGET 0x5 #define ITEMEFFECT_ORBS 0x6 +#define ITEMEFFECT_BATTLER_MOVE_END 0x7 // move end effects for just the battler, not whole field #define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK))) diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index faaf8f17e..881bb82e0 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -37,6 +37,7 @@ #define sILLUSION_NICK_HACK gBattleScripting + 0x32 #define sFIXED_ABILITY_POPUP gBattleScripting + 0x33 #define sABILITY_OVERWRITE gBattleScripting + 0x34 +#define sBERRY_OVERRIDE gBattleScripting + 0x36 #define cMULTISTRING_CHOOSER gBattleCommunication + 5 #define cMISS_TYPE gBattleCommunication + 6 @@ -173,6 +174,7 @@ #define VARIOUS_DESTROY_ABILITY_POPUP 102 #define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 +#define VARIOUS_CONSUME_BERRY 105 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index de7105a27..067d0b62e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3284,16 +3284,22 @@ void SetMoveEffect(bool32 primary, u32 certain) } break; case MOVE_EFFECT_BUG_BITE: - if ((gBattleMons[gEffectBattler].item >= FIRST_BERRY_INDEX && gBattleMons[gEffectBattler].item <= LAST_BERRY_INDEX) + if (ItemId_GetPocket(gBattleMons[gEffectBattler].item) == POCKET_BERRIES && GetBattlerAbility(gEffectBattler) != ABILITY_STICKY_HOLD) { + // target loses their berry gLastUsedItem = gBattleMons[gEffectBattler].item; gBattleMons[gEffectBattler].item = 0; CheckSetUnburden(gEffectBattler); - gActiveBattler = gEffectBattler; + BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gEffectBattler].item); MarkBattlerForControllerExec(gActiveBattler); + + // attacker temporarily gains their item + gBattleStruct->changedItems[gBattlerAttacker] = gBattleMons[gBattlerAttacker].item; + gBattleMons[gBattlerAttacker].item = gLastUsedItem; + BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectBugBite; } @@ -8422,6 +8428,27 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe) } return; + case VARIOUS_CONSUME_BERRY: + if (ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item) == HOLD_EFFECT_NONE) + { + gBattlescriptCurrInstr += 4; + return; + } + + gBattleScripting.battler = gEffectBattler = gBattlerTarget = gActiveBattler; // cover all berry effect battlerId cases. e.g. ChangeStatBuffs uses target ID + // do move end berry effects for just a single battler, instead of looping through all battlers + if (ItemBattleEffects(ITEMEFFECT_BATTLER_MOVE_END, gActiveBattler, FALSE)) + return; + + if (gBattlescriptCurrInstr[3]) + { + gBattleMons[gActiveBattler].item = gBattleStruct->changedItems[gActiveBattler]; + gBattleStruct->changedItems[gActiveBattler] = ITEM_NONE; + gBattleResources->flags->flags[gActiveBattler] &= ~(RESOURCE_FLAG_UNBURDEN); + } + + gBattlescriptCurrInstr += 4; + return; } gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index 7deebd25e..6c9e14187 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5385,6 +5385,8 @@ bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) if (gBattleMons[battlerId].hp == 0) return FALSE; + if (gBattleScripting.overrideBerryRequirements) + return TRUE; // Unnerve prevents consumption of opponents' berries. if (isBerry && IsUnnerveAbilityOnOpposingSide(battlerId)) return FALSE; @@ -6095,11 +6097,14 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) } } break; + case ITEMEFFECT_BATTLER_MOVE_END: + goto DO_ITEMEFFECT_MOVE_END; // this hurts a bit to do, but is an easy solution case ITEMEFFECT_MOVE_END: for (battlerId = 0; battlerId < gBattlersCount; battlerId++) { gLastUsedItem = gBattleMons[battlerId].item; battlerHoldEffect = GetBattlerHoldEffect(battlerId, TRUE); + DO_ITEMEFFECT_MOVE_END: switch (battlerHoldEffect) { case HOLD_EFFECT_MICLE_BERRY: From ab529b4e8934afa152ef54ad0189e8a6df7c06d6 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 27 Jul 2021 10:31:48 -0600 Subject: [PATCH 11/85] add stuff cheeks --- data/battle_scripts_1.s | 28 +++++++++++++++++++++++++ include/battle_scripts.h | 1 + include/constants/battle_move_effects.h | 1 + include/constants/battle_string_ids.h | 3 ++- src/battle_ai_main.c | 12 ++++------- src/battle_message.c | 2 ++ src/battle_util.c | 17 +++++++++++++++ src/data/battle_moves.h | 2 +- 8 files changed, 56 insertions(+), 10 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index d48076e48..37ae9b730 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -368,6 +368,30 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .4byte BattleScript_EffectSleepHit .4byte BattleScript_EffectAttackerDefenseDownHit .4byte BattleScript_EffectBodyPress + .4byte BattleScript_EffectStuffCheeks + +BattleScript_EffectStuffCheeks:: + attackcanceler + attackstring + ppreduce + jumpifnotberry BS_ATTACKER, BattleScript_ButItFailed + attackanimation + waitanimation +BattleScript_StuffCheeksEatBerry: + setbyte sBERRY_OVERRIDE, TRUE + orword gHitMarker, HITMARKER_NO_ANIMATIONS + consumeberry BS_ATTACKER + bicword gHitMarker, HITMARKER_NO_ANIMATIONS + setbyte sBERRY_OVERRIDE, FALSE + setstatchanger STAT_DEF, 2, FALSE + statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_StuffCheeksEnd + setgraphicalstatchangevalues + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_StuffCheeksEnd @ cant raise def + playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printfromtable gStatUpStringIds + waitmessage B_WAIT_TIME_LONG +BattleScript_StuffCheeksEnd: + goto BattleScript_MoveEnd BattleScript_EffectAttackerDefenseDownHit: setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN @@ -5985,6 +6009,10 @@ BattleScript_SelectingNotAllowedMoveGravity:: printselectionstring STRINGID_GRAVITYPREVENTSUSAGE endselectionscript +BattleScript_SelectingNotAllowedStuffCheeks:: + printselectionstring STRINGID_STUFFCHEEKSCANTSELECT + endselectionscript + BattleScript_SelectingNotAllowedBelch:: printselectionstring STRINGID_BELCHCANTSELECT endselectionscript diff --git a/include/battle_scripts.h b/include/battle_scripts.h index f0712fc43..0b81fc675 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -295,6 +295,7 @@ extern const u8 BattleScript_ProteanActivates[]; extern const u8 BattleScript_DazzlingProtected[]; extern const u8 BattleScript_MoveUsedPsychicTerrainPrevents[]; extern const u8 BattleScript_MoveUsedPowder[]; +extern const u8 BattleScript_SelectingNotAllowedStuffCheeks[]; extern const u8 BattleScript_SelectingNotAllowedBelch[]; extern const u8 BattleScript_SelectingNotAllowedBelchInPalace[]; extern const u8 BattleScript_PsychicSurgeActivates[]; diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index cbab68b66..2e54e9ef3 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -352,6 +352,7 @@ #define EFFECT_SLEEP_HIT 346 #define EFFECT_ATTACKER_DEFENSE_DOWN_HIT 347 #define EFFECT_BODY_PRESS 348 +#define EFFECT_STUFF_CHEEKS 349 #define NUM_BATTLE_MOVE_EFFECTS 350 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index cda885694..e2b97d443 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -570,8 +570,9 @@ #define STRINGID_MICLEBERRYACTIVATES 566 #define STRINGID_PKMNSHOOKOFFTHETAUNT 567 #define STRINGID_PKMNGOTOVERITSINFATUATION 568 +#define STRINGID_STUFFCHEEKSCANTSELECT 569 -#define BATTLESTRINGS_COUNT 569 +#define BATTLESTRINGS_COUNT 570 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 81d97fcab..da978b427 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -792,21 +792,17 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) if (!BattlerStatCanRise(battlerAtk, AI_DATA->atkAbility, STAT_ATK) || !HasMoveWithSplit(battlerAtk, SPLIT_PHYSICAL)) score -= 10; break; - case EFFECT_DEFENSE_UP_2: - if (move == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[battlerAtk].item) != POCKET_BERRIES) - score -= 10; + case EFFECT_STUFF_CHEEKS: + if (ItemId_GetPocket(gBattleMons[battlerAtk].item) != POCKET_BERRIES) + return 0; // cannot even select //fallthrough case EFFECT_DEFENSE_UP: + case EFFECT_DEFENSE_UP_2: case EFFECT_DEFENSE_UP_3: case EFFECT_DEFENSE_CURL: if (!BattlerStatCanRise(battlerAtk, AI_DATA->atkAbility, STAT_DEF)) score -= 10; break; - case EFFECT_SPEED_UP: - case EFFECT_SPEED_UP_2: - if (!BattlerStatCanRise(battlerAtk, AI_DATA->atkAbility, STAT_SPEED)) - score -= 10; - break; case EFFECT_SPECIAL_ATTACK_UP: case EFFECT_SPECIAL_ATTACK_UP_2: case EFFECT_SPECIAL_ATTACK_UP_3: diff --git a/src/battle_message.c b/src/battle_message.c index c4f043e15..439f88e29 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -696,9 +696,11 @@ static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faste static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!"); static const u8 sText_PkmnShookOffTheTaunt[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} shook off\nthe taunt!"); static const u8 sText_PkmnGotOverItsInfatuation[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} got over\nits infatuation!"); +static const u8 sText_StuffCheeksCantSelect[] = _("Stuff Cheeks cannot be\nselected without a Berry!\p"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_STUFFCHEEKSCANTSELECT - 12] = sText_StuffCheeksCantSelect, [STRINGID_PKMNGOTOVERITSINFATUATION - 12] = sText_PkmnGotOverItsInfatuation, [STRINGID_PKMNSHOOKOFFTHETAUNT - 12] = sText_PkmnShookOffTheTaunt, [STRINGID_MICLEBERRYACTIVATES - 12] = sText_MicleBerryActivates, diff --git a/src/battle_util.c b/src/battle_util.c index 6c9e14187..99217ce6f 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1708,6 +1708,21 @@ u8 TrySetCantSelectMoveBattleScript(void) limitations++; } } + + if (move == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[gActiveBattler].item) != POCKET_BERRIES) + { + gCurrentMove = move; + if (gBattleTypeFlags & BATTLE_TYPE_PALACE) + { + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedBelchInPalace; + gProtectStructs[gActiveBattler].palaceUnableToUseMove = 1; + } + else + { + gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedStuffCheeks; + limitations++; + } + } gPotentialItemEffectBattler = gActiveBattler; if (HOLD_EFFECT_CHOICE(holdEffect) && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move) @@ -1791,6 +1806,8 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check) unusableMoves |= gBitTable[i]; else if (gDisableStructs[battlerId].throatChopTimer && gBattleMoves[gBattleMons[battlerId].moves[i]].flags & FLAG_SOUND) unusableMoves |= gBitTable[i]; + else if (gBattleMons[battlerId].moves[i] == MOVE_STUFF_CHEEKS && ItemId_GetPocket(gBattleMons[gActiveBattler].item) != POCKET_BERRIES) + unusableMoves |= gBitTable[i]; } return unusableMoves; } diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 9fc79581f..416c5b850 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10771,7 +10771,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_STUFF_CHEEKS] = { - .effect = EFFECT_DEFENSE_UP_2, + .effect = EFFECT_STUFF_CHEEKS, .power = 0, .type = TYPE_NORMAL, .accuracy = 0, From d2bcc2ad5b550ba1d403749d756f6440b3acb169 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 1 Sep 2021 00:14:02 -0300 Subject: [PATCH 12/85] 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 13/85] 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 14/85] 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 15/85] 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 9c94eb6140a0752d5bef391c3679c68af14d5404 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 16 Sep 2021 10:24:32 -0400 Subject: [PATCH 16/85] but it failed check for rototiller --- asm/macros/battle_script.inc | 10 +++++ data/battle_scripts_1.s | 40 +++++++++++-------- include/battle.h | 1 + include/constants/battle_script_commands.h | 2 + src/battle_script_commands.c | 45 ++++++++++++++++++++++ 5 files changed, 83 insertions(+), 15 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 662bfbf2f..a2d940737 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1776,6 +1776,16 @@ .macro pickpocketsteal various 0, VARIOUS_PICKPOCKET .endm + + .macro getrototillertargets ptr:req + various BS_ATTACKER, VARIOUS_GET_ROTOTILLER_TARGETS + .4byte \ptr + .endm + + .macro jumpifnotrototilleraffected battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED + .4byte \ptr + .endm @ helpful macros .macro setstatchanger stat:req, stages:req, down:req diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 2d6db5a28..177c657ce 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -814,27 +814,28 @@ BattleScript_FlowerShieldMoveTargetEnd: moveendto MOVEEND_NEXT_TARGET jumpifnexttargetvalid BattleScript_FlowerShieldLoop end + +BattleScript_RototillerRet:: + + return BattleScript_EffectRototiller: attackcanceler attackstring ppreduce - selectfirstvalidtarget -BattleScript_RototillerLoop: - movevaluescleanup - jumpifnotgrounded BS_TARGET, BattleScript_RototillerNoEffect - jumpiftype BS_TARGET, TYPE_GRASS, BattleScript_RototillerLoop2 -BattleScript_RototillerNoEffect: - pause B_WAIT_TIME_SHORT - printstring STRINGID_NOEFFECTONTARGET - waitmessage B_WAIT_TIME_LONG - goto BattleScript_RototillerMoveTargetEnd -BattleScript_RototillerLoop2: - jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_RototillerDoMoveAnim - jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPATK, MAX_STAT_STAGE, BattleScript_RototillerCantRaiseMultipleStats -BattleScript_RototillerDoMoveAnim:: + getrototillertargets BattleScript_ButItFailed + @ at least one battler is affected attackanimation waitanimation + savetarget + setbyte gBattlerTarget, 0 +BattleScript_RototillerLoop: + movevaluescleanup + jumpifstat BS_TARGET, CMP_LESS_THAN, STAT_ATK, MAX_STAT_STAGE, BattleScript_RototillerCheckAffected + jumpifstat BS_TARGET, CMP_EQUAL, STAT_SPATK, MAX_STAT_STAGE, BattleScript_RototillerCantRaiseMultipleStats +BattleScript_RototillerCheckAffected: + jumpifnotrototilleraffected BS_TARGET, BattleScript_RototillerNoEffect +BattleScript_RototillerAffected: setbyte sSTAT_ANIM_PLAYED, FALSE playstatchangeanimation BS_TARGET, BIT_ATK | BIT_SPATK, 0 setstatchanger STAT_ATK, 1, FALSE @@ -850,13 +851,22 @@ BattleScript_RototillerTrySpAtk:: waitmessage B_WAIT_TIME_LONG BattleScript_RototillerMoveTargetEnd: moveendto MOVEEND_NEXT_TARGET - jumpifnexttargetvalid BattleScript_RototillerLoop + addbyte gBattlerTarget, 1 + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_RototillerLoop end + BattleScript_RototillerCantRaiseMultipleStats: + copybyte gBattlerAttacker, gBattlerTarget printstring STRINGID_STATSWONTINCREASE2 waitmessage B_WAIT_TIME_LONG goto BattleScript_RototillerMoveTargetEnd +BattleScript_RototillerNoEffect: + pause B_WAIT_TIME_SHORT + printstring STRINGID_NOEFFECTONTARGET + waitmessage B_WAIT_TIME_LONG + goto BattleScript_RototillerMoveTargetEnd + BattleScript_EffectBestow: attackcanceler accuracycheck BattleScript_PrintMoveMissed, NO_ACC_CALC_CHECK_LOCK_ON diff --git a/include/battle.h b/include/battle.h index 3fbefe55b..576884d81 100644 --- a/include/battle.h +++ b/include/battle.h @@ -169,6 +169,7 @@ struct SpecialStatus u8 instructedChosenTarget:3; u8 berryReduced:1; u8 gemBoost:1; + u8 rototillerAffected:1; // to be affected by rototiller u8 gemParam; u8 damagedMons:4; // Mons that have been damaged directly by using a move, includes substitute. u8 dancerUsedMove:1; diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 7e7bb6ca9..6c5e3872a 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -174,6 +174,8 @@ #define VARIOUS_TOTEM_BOOST 103 #define VARIOUS_TRY_ACTIVATE_GRIM_NEIGH 104 #define VARIOUS_MOVEEND_ITEM_EFFECTS 105 +#define VARIOUS_GET_ROTOTILLER_TARGETS 106 +#define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 107 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 05702aec6..a719db550 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7246,6 +7246,21 @@ static u32 GetHighestStatId(u32 battlerId) return highestId; } +static bool32 IsRototillerAffected(u32 battlerId) +{ + if (!IsBattlerAlive(battlerId)) + return FALSE; + if (!IsBattlerGrounded(battlerId)) + return FALSE; // Only grounded battlers affected + if (!IS_BATTLER_OF_TYPE(battlerId, TYPE_GRASS)) + return FALSE; // Only grass types affected + if (gStatuses3[battlerId] & STATUS3_SEMI_INVULNERABLE) + return FALSE; // Rototiller doesn't affected semi-invulnerable battlers + //if (!CompareStat(battlerId, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN) && !CompareStat(battlerId, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN)) + //return FALSE; // Battler unaffected if atk and spatk are maxed + return TRUE; +} + static void Cmd_various(void) { struct Pokemon *mon; @@ -8498,6 +8513,36 @@ static void Cmd_various(void) if (ItemBattleEffects(1, gActiveBattler, FALSE)) return; break; + case VARIOUS_GET_ROTOTILLER_TARGETS: + // Gets the battlers to be affected by rototiller. If there are none, print 'But it failed!' + { + u32 count = 0; + for (i = 0; i < gBattlersCount; i++) + { + if (IsRototillerAffected(i)) + { + gSpecialStatuses[i].rototillerAffected = 1; + count++; + } + } + + if (count == 0) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); // Rototiller fails + else + gBattlescriptCurrInstr += 7; + } + return; + case VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED: + if (gSpecialStatuses[gActiveBattler].rototillerAffected) + { + gSpecialStatuses[gActiveBattler].rototillerAffected = 0; + gBattlescriptCurrInstr += 7; + } + else + { + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); // Unaffected by rototiller - print STRINGID_NOEFFECTONTARGET + } + return; } gBattlescriptCurrInstr += 3; From aac7ae359518c3610fb02f91b05b244172208944 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 16 Sep 2021 10:45:33 -0400 Subject: [PATCH 17/85] add MOVE_TARGET_ALL_BATTLERS --- include/constants/battle.h | 2 + src/battle_controller_player.c | 84 ++++++++++++++++++++++++++++------ src/data/battle_moves.h | 4 +- 3 files changed, 74 insertions(+), 16 deletions(-) diff --git a/include/constants/battle.h b/include/constants/battle.h index 73d5c3deb..53e933944 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -379,4 +379,6 @@ #define MOVE_TARGET_OPPONENTS_FIELD 0x40 #define MOVE_TARGET_ALLY 0x80 +#define MOVE_TARGET_ALL_BATTLERS (MOVE_TARGET_BOTH | MOVE_TARGET_OPPONENTS_FIELD) + #endif // GUARD_CONSTANTS_BATTLE_H diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 841e30327..70a8f51e9 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -485,6 +485,19 @@ static void HandleInputChooseTarget(void) } } +static void HideAllTargets(void) +{ + s32 i; + for (i = 0; i < MAX_BATTLERS_COUNT; i++) + { + if (IsBattlerAlive(i) && gBattleSpritesDataPtr->healthBoxesData[i].healthboxIsBouncing) + { + gSprites[gBattlerSpriteIds[i]].callback = SpriteCb_HideAsMoveTarget; + EndBounceEffect(i, BOUNCE_HEALTHBOX); + } + } +} + static void HideShownTargets(void) { s32 i; @@ -498,6 +511,34 @@ static void HideShownTargets(void) } } +static void HandleInputShowEntireFieldTargets(void) +{ + if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) + gPlayerDpadHoldFrames++; + else + gPlayerDpadHoldFrames = 0; + + if (JOY_NEW(A_BUTTON)) + { + PlaySE(SE_SELECT); + HideAllTargets(); + if (gBattleStruct->mega.playerSelect) + BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8)); + else + BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); + HideMegaTriggerSprite(); + PlayerBufferExecCompleted(); + } + else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59) + { + PlaySE(SE_SELECT); + HideAllTargets(); + gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseMove; + DoBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX, 7, 1); + DoBounceEffect(gActiveBattler, BOUNCE_MON, 7, 1); + } +} + static void HandleInputShowTargets(void) { if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) @@ -589,27 +630,39 @@ static void HandleInputChooseMove(void) } // Show all available targets for multi-target moves - if (B_SHOW_TARGETS && moveTarget & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY)) + if (B_SHOW_TARGETS) { - TryShowAsTarget(gMultiUsePlayerCursor); - TryShowAsTarget(BATTLE_PARTNER(gMultiUsePlayerCursor)); - if (moveTarget & MOVE_TARGET_FOES_AND_ALLY) - TryShowAsTarget(BATTLE_PARTNER(gActiveBattler)); - canSelectTarget = 2; + if ((moveTarget & MOVE_TARGET_ALL_BATTLERS) == MOVE_TARGET_ALL_BATTLERS) + { + u32 i = 0; + for (i = 0; i < gBattlersCount; i++) + TryShowAsTarget(i); + + canSelectTarget = 3; + } + else if (moveTarget & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY)) + { + TryShowAsTarget(gMultiUsePlayerCursor); + TryShowAsTarget(BATTLE_PARTNER(gMultiUsePlayerCursor)); + if (moveTarget & MOVE_TARGET_FOES_AND_ALLY) + TryShowAsTarget(BATTLE_PARTNER(gActiveBattler)); + canSelectTarget = 2; + } } } - - if (canSelectTarget == 0) + + switch (canSelectTarget) { + case 0: + default: if (gBattleStruct->mega.playerSelect) BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | RET_MEGA_EVOLUTION | (gMultiUsePlayerCursor << 8)); else BtlController_EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); HideMegaTriggerSprite(); PlayerBufferExecCompleted(); - } - else if (canSelectTarget == 1) - { + break; + case 1: gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseTarget; if (moveTarget & (MOVE_TARGET_USER | MOVE_TARGET_USER_OR_SELECTED)) @@ -620,10 +673,13 @@ static void HandleInputChooseMove(void) gMultiUsePlayerCursor = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_ShowAsMoveTarget; - } - else - { + break; + case 2: gBattlerControllerFuncs[gActiveBattler] = HandleInputShowTargets; + break; + case 3: // Entire field + gBattlerControllerFuncs[gActiveBattler] = HandleInputShowEntireFieldTargets; + break; } } else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 657341b5e..a63aca114 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -8838,7 +8838,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_FOES_AND_ALLY | MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -9083,7 +9083,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER | MOVE_TARGET_FOES_AND_ALLY, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, From 11f4f0f08e42a2d6b9c0ba56b9938e755601ea7e Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 6 Oct 2021 14:41:48 -0400 Subject: [PATCH 18/85] update move data to those that target all battlers --- src/data/battle_moves.h | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index a63aca114..98b30951e 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -1789,7 +1789,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 30, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = FLAG_PROTECT_AFFECTED, .split = SPLIT_STATUS, @@ -3100,7 +3100,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 5, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = FLAG_SOUND, .split = SPLIT_STATUS, @@ -3204,7 +3204,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -3804,7 +3804,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 5, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -3818,7 +3818,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 5, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -4125,7 +4125,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = FLAG_PROTECT_AFFECTED, .split = SPLIT_STATUS, @@ -4768,7 +4768,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 100, .pp = 15, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -5504,7 +5504,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 100, .pp = 15, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -5661,7 +5661,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 5, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -6875,7 +6875,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 5, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = -7, .flags = FLAG_MIRROR_MOVE_AFFECTED, .split = SPLIT_STATUS, @@ -7478,7 +7478,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .flags = FLAG_MIRROR_MOVE_AFFECTED, .split = SPLIT_STATUS, }, @@ -7570,7 +7570,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .flags = FLAG_MIRROR_MOVE_AFFECTED, .split = SPLIT_STATUS, }, @@ -8932,7 +8932,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 25, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 1, .flags = 0, .split = SPLIT_STATUS, @@ -9097,7 +9097,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -9111,7 +9111,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -9195,7 +9195,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = FLAG_MIRROR_MOVE_AFFECTED, .split = SPLIT_STATUS, @@ -9445,7 +9445,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -9965,7 +9965,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -10848,7 +10848,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 0, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = 0, .split = SPLIT_STATUS, @@ -10904,7 +10904,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .accuracy = 100, .pp = 10, .secondaryEffectChance = 0, - .target = MOVE_TARGET_USER, + .target = MOVE_TARGET_ALL_BATTLERS, .priority = 0, .flags = FLAG_MIRROR_MOVE_AFFECTED, .split = SPLIT_STATUS, From 91a68cd5dbcadf8123d9f7da7cbf5ed6cf505475 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Wed, 25 Aug 2021 03:35:21 -0300 Subject: [PATCH 19/85] Implemented Primal Reversion --- asm/macros/battle_script.inc | 10 ++ data/battle_anim_scripts.s | 93 +++++++++++++++-- data/battle_scripts_1.s | 30 ++++++ .../battle_anims/sprites/alpha_symbol.png | Bin 0 -> 263 bytes .../battle_anims/sprites/omega_symbol.png | Bin 0 -> 349 bytes .../battle_anims/sprites/primal_particles.png | Bin 0 -> 510 bytes graphics/battle_interface/alpha_indicator.png | Bin 0 -> 266 bytes graphics/battle_interface/omega_indicator.png | Bin 0 -> 271 bytes include/battle.h | 4 + include/battle_interface.h | 10 +- include/battle_scripts.h | 1 + include/constants/battle_anim.h | 4 + include/constants/battle_script_commands.h | 2 + include/constants/battle_string_ids.h | 3 +- include/constants/pokemon.h | 54 ++++++---- include/graphics.h | 6 ++ src/battle_anim.c | 6 ++ src/battle_anim_effects_3.c | 55 ++++++++++ src/battle_anim_new.c | 10 ++ src/battle_interface.c | 95 ++++++++++++++++-- src/battle_main.c | 12 +++ src/battle_message.c | 2 + src/battle_script_commands.c | 70 ++++++++++++- src/battle_util.c | 28 +++++- src/graphics.c | 9 ++ 25 files changed, 455 insertions(+), 49 deletions(-) create mode 100644 graphics/battle_anims/sprites/alpha_symbol.png create mode 100644 graphics/battle_anims/sprites/omega_symbol.png create mode 100644 graphics/battle_anims/sprites/primal_particles.png create mode 100644 graphics/battle_interface/alpha_indicator.png create mode 100644 graphics/battle_interface/omega_indicator.png diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 4d8fe0365..3f0b52340 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1543,6 +1543,11 @@ .byte \case .endm + .macro handleprimalreversion battler:req, case:req + various \battler, VARIOUS_HANDLE_PRIMAL_REVERSION + .byte \case + .endm + .macro handleformchange battler:req, case:req various \battler, VARIOUS_HANDLE_FORM_CHANGE .byte \case @@ -1825,6 +1830,11 @@ various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER .endm + .macro jumpifcantreverttoprimal ptr:req + various BS_ATTACKER, VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 4063885e0..808049d21 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -4,6 +4,7 @@ #include "constants/songs.h" #include "constants/moves.h" #include "constants/pokemon.h" +#include "constants/items.h" .include "asm/macros.inc" .include "asm/macros/battle_anim_script.inc" .include "constants/constants.inc" @@ -824,6 +825,7 @@ gBattleAnims_General:: .4byte General_TotemFlare @ B_ANIM_TOTEM_FLARE .4byte General_GulpMissile @ B_ANIM_GULP_MISSILE .4byte General_StrongWinds @ B_ANIM_STRONG_WINDS + .4byte General_PrimalReversion @ B_ANIM_PRIMAL_REVERSION .align 2 gBattleAnims_Special:: @@ -24399,6 +24401,17 @@ General_TotemFlare:: clearmonbg ANIM_ATTACKER end +RainbowEndureEffect: + launchtemplate gBlueEndureEnergySpriteTemplate 0x2 0x4 0x0 0xffe8 0x1a 0x2 + delay 0x3 + launchtemplate gEndureEnergySpriteTemplate 0x2 0x4 0x0 0xe 0x1c 0x1 @Red Buff + delay 0x3 + launchtemplate gGreenEndureEnergySpriteTemplate 0x2 0x4 0x0 0xfffb 0xa 0x2 + delay 0x3 + launchtemplate gYellowEndureEnergySpriteTemplate 0x2 0x4 0x0 0x1c 0x1a 0x3 + delay 0x3 + return + General_GulpMissile: @ Tackle anim (placeholder) loadspritegfx ANIM_TAG_IMPACT monbg ANIM_ATTACKER @@ -24424,15 +24437,77 @@ General_StrongWinds:: stopsound end -RainbowEndureEffect: - launchtemplate gBlueEndureEnergySpriteTemplate 0x2 0x4 0x0 0xffe8 0x1a 0x2 - delay 0x3 - launchtemplate gEndureEnergySpriteTemplate 0x2 0x4 0x0 0xe 0x1c 0x1 @Red Buff - delay 0x3 - launchtemplate gGreenEndureEnergySpriteTemplate 0x2 0x4 0x0 0xfffb 0xa 0x2 - delay 0x3 - launchtemplate gYellowEndureEnergySpriteTemplate 0x2 0x4 0x0 0x1c 0x1a 0x3 - delay 0x3 +General_PrimalReversion:: + launchtask AnimTask_PrimalReversion 0x5 0x0 + jumpargeq 0x0, ITEM_RED_ORB, General_PrimalReversion_Omega + jumpargeq 0x1, ITEM_BLUE_ORB, General_PrimalReversion_Alpha +General_PrimalReversion_Alpha: + loadspritegfx ANIM_TAG_ALPHA_STONE + loadspritegfx ANIM_TAG_PRIMAL_PARTICLES + loadspritegfx ANIM_TAG_ALPHA_SYMBOL + monbg ANIM_ATTACKER + setalpha 12, 8 + loopsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER, 13, 3 + createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 6, 0, 11, RGB(31, 31, 11) + call PrimalReversionParticles + call PrimalReversionParticles + call PrimalReversionParticles + waitforvisualfinish + playsewithpan SE_M_SOLAR_BEAM, SOUND_PAN_ATTACKER + createsprite gAlphaStoneSpriteTemplate, ANIM_ATTACKER, 41, 0, 0, 0, 0 + delay 20 + createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 0, 16, RGB_WHITEALPHA + waitforvisualfinish + createvisualtask AnimTask_TransformMon, 2, 0, 1 + createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 16, 0, RGB_WHITEALPHA + createvisualtask AnimTask_HorizontalShake, 5, 1, 5, 14 + waitforvisualfinish + createsprite gAlphaSymbolSpriteTemplate ANIM_ATTACKER, 2 + waitforvisualfinish + clearmonbg ANIM_ATK_PARTNER + blendoff + end +General_PrimalReversion_Omega: + loadspritegfx ANIM_TAG_OMEGA_STONE + loadspritegfx ANIM_TAG_PRIMAL_PARTICLES + loadspritegfx ANIM_TAG_OMEGA_SYMBOL + monbg ANIM_ATTACKER + setalpha 12, 8 + loopsewithpan SE_M_MEGA_KICK, SOUND_PAN_ATTACKER, 13, 3 + createvisualtask AnimTask_BlendColorCycle, 2, 2, 0, 6, 0, 11, RGB(31, 31, 11) + call PrimalReversionParticles + call PrimalReversionParticles + call PrimalReversionParticles + waitforvisualfinish + playsewithpan SE_M_SOLAR_BEAM, SOUND_PAN_ATTACKER + createsprite gOmegaStoneSpriteTemplate, ANIM_ATTACKER, 41, 0, 0, 0, 0 + delay 20 + createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 0, 16, RGB_WHITEALPHA + waitforvisualfinish + createvisualtask AnimTask_TransformMon, 2, 0, 1 + createvisualtask AnimTask_BlendBattleAnimPalExclude, 5, 5, 2, 16, 0, RGB_WHITEALPHA + createvisualtask AnimTask_HorizontalShake, 5, 1, 5, 14 + waitforvisualfinish + createsprite gOmegaSymbolSpriteTemplate ANIM_ATTACKER, 2 + waitforvisualfinish + clearmonbg ANIM_ATK_PARTNER + blendoff + end +PrimalReversionParticles: + createsprite gPrimalParticlesSpriteTemplate, ANIM_ATTACKER, 2, 40, -10, 13 + delay 3 + createsprite gPrimalParticlesSpriteTemplate, ANIM_ATTACKER, 2, -35, -10, 13 + delay 3 + createsprite gPrimalParticlesSpriteTemplate, ANIM_ATTACKER, 2, 15, -40, 13 + delay 3 + createsprite gPrimalParticlesSpriteTemplate, ANIM_ATTACKER, 2, -10, -32, 13 + delay 3 + createsprite gPrimalParticlesSpriteTemplate, ANIM_ATTACKER, 2, 25, -20, 13 + delay 3 + createsprite gPrimalParticlesSpriteTemplate, ANIM_ATTACKER, 2, -40, -20, 13 + delay 3 + createsprite gPrimalParticlesSpriteTemplate, ANIM_ATTACKER, 2, 5, -40, 13 + delay 3 return SnatchMoveTrySwapFromSubstitute: diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 67f7762ac..4ec6423ed 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5599,6 +5599,9 @@ BattleScript_DoSwitchOut:: hidepartystatussummary BS_ATTACKER switchinanim BS_ATTACKER, FALSE waitstate + jumpifcantreverttoprimal BattleScript_DoSwitchOut2 + call BattleScript_PrimalReversionRet +BattleScript_DoSwitchOut2: switchineffects BS_ATTACKER moveendcase MOVEEND_STATUS_IMMUNITY_ABILITIES moveendcase MOVEEND_MIRROR_MOVE @@ -6625,6 +6628,33 @@ BattleScript_WishMegaEvolution:: switchinabilities BS_ATTACKER end2 +BattleScript_PrimalReversion:: + printstring STRINGID_EMPTYSTRING3 + waitmessage 1 + setbyte gIsCriticalHit, 0 + handleprimalreversion BS_ATTACKER, 0 + handleprimalreversion BS_ATTACKER, 1 + playanimation BS_ATTACKER, B_ANIM_PRIMAL_REVERSION, NULL + waitanimation + handleprimalreversion BS_ATTACKER, 2 + printstring STRINGID_PKMNREVERTEDTOPRIMAL + waitmessage B_WAIT_TIME_LONG + switchinabilities BS_ATTACKER + end2 + +BattleScript_PrimalReversionRet:: + printstring STRINGID_EMPTYSTRING3 + waitmessage 1 + setbyte gIsCriticalHit, 0 + handleprimalreversion BS_ATTACKER, 0 + handleprimalreversion BS_ATTACKER, 1 + playanimation BS_ATTACKER, B_ANIM_PRIMAL_REVERSION, NULL + waitanimation + handleprimalreversion BS_ATTACKER, 2 + printstring STRINGID_PKMNREVERTEDTOPRIMAL + waitmessage B_WAIT_TIME_LONG + return + BattleScript_AttackerFormChange:: pause 5 copybyte gBattlerAbility, gBattlerAttacker diff --git a/graphics/battle_anims/sprites/alpha_symbol.png b/graphics/battle_anims/sprites/alpha_symbol.png new file mode 100644 index 0000000000000000000000000000000000000000..34ff13de351a1ecb8ec9ac7ab941022c081b048f GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvg8-ip*NOux4*dAh@Z*QVfgcPF zKY+sc0dIi-6Hvt@PZ!4!jfr!EPV*i$;5eR}0;weg6yIB90M#%idAqy(U&{XJD3H_W z>EaktF=uVSUC9FmEGf)64ZKPJ?`nmE6?A^fM&P zv1oJ1E|*Eh%NKb|@Eo|uBa`oiD?Oh7bk7N#DzUX9=4T?v^`5SNF6*2UngH8O BZ8`t| literal 0 HcmV?d00001 diff --git a/graphics/battle_anims/sprites/primal_particles.png b/graphics/battle_anims/sprites/primal_particles.png new file mode 100644 index 0000000000000000000000000000000000000000..6fdf09d96e0d606f5253e5ed18da3c272120e6ce GIT binary patch literal 510 zcmeAS@N?(olHy`uVBq!ia0vp^0zhoQ!VDx|6+TY^QY`6?zK#qG8~eHcB(ehe3dtTp zz6=aiY77hwEes65fIi1;V5)EKCOG0EHAg;|it=M#{_S>O>_%)r2R1cVu< zYV%101=&kHeO=k_v+;>Y%TBb>0$R^-!qdeuMB;MkSzAA6Ljjftm4S70^!7P!X%c?J zx+ueSZqwV#8y5LIH!JaLcR5@*^ZAE0>`j^9Cfg`8ALfgA)2R6Tu2V|CBd6-7XF6I< zXE=;s`@AUD;Xm-|NOoDo&iNZcoH&Dx!^FC;kotR)G0UiF^6U!J>Hw}q4M{;9{;^}p4Yc+{(W|*rs(G7+07lj71mug zd;WDF7kn9csjh*UuAxbYp@o%^xs{P6 VL_^=Zwnsn>44$rjF6*2UngE>NybAyT literal 0 HcmV?d00001 diff --git a/graphics/battle_interface/alpha_indicator.png b/graphics/battle_interface/alpha_indicator.png new file mode 100644 index 0000000000000000000000000000000000000000..0e302576b6aced8d385e93eee3a2919ea2e4d1c3 GIT binary patch literal 266 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF|4}nTJN(%hkfilKGHiK7#raX{hNq6*h zWMJ6X&;2Kn705RT@CkAK&%mHie?!1~&W;BkI(9q&3gZVW>MkqO6D zAV<&B#WAE}PIAHmF@cb#3q8l0_!8PSb#D}yk*JZ;aV$X0q-{l-QCO2kT0j#A14Dl= V^X1G4%?}`pJYD@<);T3K0RZ%8M?wGq literal 0 HcmV?d00001 diff --git a/graphics/battle_interface/omega_indicator.png b/graphics/battle_interface/omega_indicator.png new file mode 100644 index 0000000000000000000000000000000000000000..c56d51c151e6c578e4a8935a7cf6bd4efaceb009 GIT binary patch literal 271 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF@n0>&h7cbET5**_fx za*RD)978JRBquBo69{U%(4*zVme4k_TfyaohrlU=5D_6Z<2fR&AqRNGl9Smx%#xE0 ZSQ$DpnC~sh`gIy)nWw9t%Q~loCIEHMMaKXD literal 0 HcmV?d00001 diff --git a/include/battle.h b/include/battle.h index 3aa78f50c..765313311 100644 --- a/include/battle.h +++ b/include/battle.h @@ -461,10 +461,14 @@ struct MegaEvolutionData bool8 alreadyEvolved[4]; // Array id is used for mon position. u16 evolvedSpecies[MAX_BATTLERS_COUNT]; u16 playerEvolvedSpecies; + u8 primalRevertedPartyIds[2]; // As flags using gBitTable; + u16 primalRevertedSpecies[MAX_BATTLERS_COUNT]; + u16 playerPrimalRevertedSpecies; u8 battlerId; bool8 playerSelect; u8 triggerSpriteId; bool8 isWishMegaEvo; + bool8 isPrimalReversion; }; struct Illusion diff --git a/include/battle_interface.h b/include/battle_interface.h index 0bcadaaac..bd0a4f2dd 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -39,16 +39,20 @@ enum #define TAG_STATUS_SUMMARY_BAR_TILE 0xD70C #define TAG_STATUS_SUMMARY_BALLS_TILE 0xD714 -#define TAG_MEGA_TRIGGER_TILE 0xD777 +#define TAG_MEGA_TRIGGER_TILE 0xD777 #define TAG_MEGA_INDICATOR_TILE 0xD778 +#define TAG_ALPHA_INDICATOR_TILE 0xD779 +#define TAG_OMEGA_INDICATOR_TILE 0xD77A #define TAG_HEALTHBOX_PAL 0xD6FF #define TAG_HEALTHBAR_PAL 0xD704 #define TAG_STATUS_SUMMARY_BAR_PAL 0xD710 #define TAG_STATUS_SUMMARY_BALLS_PAL 0xD712 -#define TAG_MEGA_TRIGGER_PAL 0xD777 -#define TAG_MEGA_INDICATOR_PAL 0xD778 +#define TAG_MEGA_TRIGGER_PAL 0xD777 +#define TAG_MEGA_INDICATOR_PAL 0xD778 +#define TAG_ALPHA_INDICATOR_PAL 0xD779 +#define TAG_OMEGA_INDICATOR_PAL 0xD77A enum { diff --git a/include/battle_scripts.h b/include/battle_scripts.h index cd4600543..1604d70d5 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -398,5 +398,6 @@ extern const u8 BattleScript_MysteriousAirCurrentBlowsOn[]; extern const u8 BattleScript_AttackWeakenedByStrongWinds[]; extern const u8 BattleScript_BlockedByPrimalWeatherEnd3[]; extern const u8 BattleScript_BlockedByPrimalWeatherRet[]; +extern const u8 BattleScript_PrimalReversion[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_anim.h b/include/constants/battle_anim.h index 72f4fcd66..7fd515bdf 100644 --- a/include/constants/battle_anim.h +++ b/include/constants/battle_anim.h @@ -391,6 +391,9 @@ #define ANIM_TAG_DREEPY (ANIM_SPRITES_START + 379) #define ANIM_TAG_ICE_ROCK_SINGLE (ANIM_SPRITES_START + 380) #define ANIM_TAG_STONE_PILLAR_MULTI (ANIM_SPRITES_START + 381) +#define ANIM_TAG_ALPHA_SYMBOL (ANIM_SPRITES_START + 382) +#define ANIM_TAG_OMEGA_SYMBOL (ANIM_SPRITES_START + 383) +#define ANIM_TAG_PRIMAL_PARTICLES (ANIM_SPRITES_START + 384) // battlers #define ANIM_ATTACKER 0 @@ -525,6 +528,7 @@ #define B_ANIM_TOTEM_FLARE 28 // Totem boosts aura flare #define B_ANIM_GULP_MISSILE 29 #define B_ANIM_STRONG_WINDS 30 +#define B_ANIM_PRIMAL_REVERSION 31 // special animations table (gBattleAnims_Special) #define B_ANIM_LVL_UP 0 diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index d61eabbf8..c78c550fa 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -185,6 +185,8 @@ #define VARIOUS_REMOVE_TERRAIN 113 #define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 #define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 +#define VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL 116 +#define VARIOUS_HANDLE_PRIMAL_REVERSION 117 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index b74c9cd14..7b4e6e536 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -592,8 +592,9 @@ #define STRINGID_STRONGWINDSDISSIPATED 588 #define STRINGID_MYSTERIOUSAIRCURRENTBLOWSON 589 #define STRINGID_ATTACKWEAKENEDBSTRONGWINDS 590 +#define STRINGID_PKMNREVERTEDTOPRIMAL 591 -#define BATTLESTRINGS_COUNT 591 +#define BATTLESTRINGS_COUNT 592 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 742824335..bb176e464 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -336,25 +336,43 @@ #define F_SUMMARY_SCREEN_FLIP_SPRITE 0x80 // Evolution types -#define EVO_MEGA_EVOLUTION 0xffff // Not an actual evolution, used to temporarily mega evolve in battle. -#define EVO_MOVE_MEGA_EVOLUTION 0xfffe // Mega Evolution that checks for a move instead of held item. -#define EVO_FRIENDSHIP 1 // Pokémon levels up with friendship ≥ 220 -#define EVO_FRIENDSHIP_DAY 2 // Pokémon levels up during the day with friendship ≥ 220 -#define EVO_FRIENDSHIP_NIGHT 3 // Pokémon levels up at night with friendship ≥ 220 -#define EVO_LEVEL 4 // Pokémon reaches the specified level -#define EVO_TRADE 5 // Pokémon is traded -#define EVO_TRADE_ITEM 6 // Pokémon is traded while it's holding the specified item -#define EVO_ITEM 7 // specified item is used on Pokémon -#define EVO_LEVEL_ATK_GT_DEF 8 // Pokémon reaches the specified level with attack > defense -#define EVO_LEVEL_ATK_EQ_DEF 9 // Pokémon reaches the specified level with attack = defense -#define EVO_LEVEL_ATK_LT_DEF 10 // Pokémon reaches the specified level with attack < defense -#define EVO_LEVEL_SILCOON 11 // Pokémon reaches the specified level with a Silcoon personality value -#define EVO_LEVEL_CASCOON 12 // Pokémon reaches the specified level with a Cascoon personality value -#define EVO_LEVEL_NINJASK 13 // Pokémon reaches the specified level (special value for Ninjask) -#define EVO_LEVEL_SHEDINJA 14 // Pokémon reaches the specified level (special value for Shedinja) -#define EVO_BEAUTY 15 // Pokémon levels up with beauty ≥ specified value +#define EVO_MEGA_EVOLUTION 0xffff // Not an actual evolution, used to temporarily mega evolve in battle. +#define EVO_MOVE_MEGA_EVOLUTION 0xfffe // Mega Evolution that checks for a move instead of held item. +#define EVO_PRIMAL_REVERSION 0xfffd // Not an actual evolution, used to undergo primal reversion in battle. +#define EVO_FRIENDSHIP 1 // Pokémon levels up with friendship ≥ 220 +#define EVO_FRIENDSHIP_DAY 2 // Pokémon levels up during the day with friendship ≥ 220 +#define EVO_FRIENDSHIP_NIGHT 3 // Pokémon levels up at night with friendship ≥ 220 +#define EVO_LEVEL 4 // Pokémon reaches the specified level +#define EVO_TRADE 5 // Pokémon is traded +#define EVO_TRADE_ITEM 6 // Pokémon is traded while it's holding the specified item +#define EVO_ITEM 7 // specified item is used on Pokémon +#define EVO_LEVEL_ATK_GT_DEF 8 // Pokémon reaches the specified level with attack > defense +#define EVO_LEVEL_ATK_EQ_DEF 9 // Pokémon reaches the specified level with attack = defense +#define EVO_LEVEL_ATK_LT_DEF 10 // Pokémon reaches the specified level with attack < defense +#define EVO_LEVEL_SILCOON 11 // Pokémon reaches the specified level with a Silcoon personality value +#define EVO_LEVEL_CASCOON 12 // Pokémon reaches the specified level with a Cascoon personality value +#define EVO_LEVEL_NINJASK 13 // Pokémon reaches the specified level (special value for Ninjask) +#define EVO_LEVEL_SHEDINJA 14 // Pokémon reaches the specified level (special value for Shedinja) +#define EVO_BEAUTY 15 // Pokémon levels up with beauty ≥ specified value +#define EVO_LEVEL_FEMALE 16 // Pokémon reaches the specified level, is female +#define EVO_LEVEL_MALE 17 // Pokémon reaches the specified level, is male +#define EVO_LEVEL_NIGHT 18 // Pokémon reaches the specified level, is night +#define EVO_LEVEL_DAY 19 // Pokémon reaches the specified level, is day +#define EVO_LEVEL_DUSK 20 // Pokémon reaches the specified level, is dusk (5-6 P.M) +#define EVO_ITEM_HOLD_DAY 21 // Pokémon levels up, holds specified item at day +#define EVO_ITEM_HOLD_NIGHT 22 // Pokémon levels up, holds specified item at night +#define EVO_MOVE 23 // Pokémon levels up, knows specified move +#define EVO_MOVE_TYPE 24 // Pokémon levels up, knows move with specified type +#define EVO_MAPSEC 25 // Pokémon levels up on specified mapsec +#define EVO_ITEM_MALE 26 // specified item is used on a male Pokémon +#define EVO_ITEM_FEMALE 27 // specified item is used on a female Pokémon +#define EVO_LEVEL_RAIN 28 // Pokémon reaches the specified level while it's raining +#define EVO_SPECIFIC_MON_IN_PARTY 29 // Pokémon levels up with a specified Pokémon in party +#define EVO_LEVEL_DARK_TYPE_MON_IN_PARTY 30 // Pokémon reaches the specified level with a Dark Type Pokémon in party +#define EVO_TRADE_SPECIFIC_MON 31 // Pokémon is traded for a specified Pokémon +#define EVO_SPECIFIC_MAP 32 // Pokémon levels up on specified map -#define EVOS_PER_MON 5 +#define EVOS_PER_MON 10 // Evolution 'modes,' for GetEvolutionTargetSpecies #define EVO_MODE_NORMAL 0 diff --git a/include/graphics.h b/include/graphics.h index 6139e90cf..5c2150f4a 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4749,6 +4749,8 @@ extern const u32 gBattleAnimSpriteGfx_MegaStone[]; extern const u32 gBattleAnimSpritePal_MegaStone[]; extern const u32 gBattleAnimSpriteGfx_MegaParticles[]; extern const u32 gBattleAnimSpritePal_MegaParticles[]; +extern const u32 gBattleAnimSpriteGfx_PrimalParticles[]; +extern const u32 gBattleAnimSpritePal_PrimalParticles[]; extern const u32 gBattleAnimSpriteGfx_MegaSymbol[]; extern const u32 gBattleAnimSpritePal_MegaSymbol[]; extern const u32 gBattleAnimSpriteGfx_FlashCannonBall[]; @@ -4765,6 +4767,8 @@ extern const u32 gBattleAnimSpriteGfx_AcupressureFinger[]; extern const u32 gBattleAnimSpritePal_AcupressureFinger[]; extern const u32 gBattleAnimSpriteGfx_AlphaStone[]; extern const u32 gBattleAnimSpritePal_AlphaStone[]; +extern const u32 gBattleAnimSpriteGfx_AlphaSymbol[]; +extern const u32 gBattleAnimSpritePal_AlphaSymbol[]; extern const u32 gBattleAnimSpriteGfx_Anchor[]; extern const u32 gBattleAnimSpriteGfx_Apple[]; extern const u32 gBattleAnimSpritePal_Apple[]; @@ -4867,6 +4871,8 @@ extern const u32 gBattleAnimSpriteGfx_Obstruct[]; extern const u32 gBattleAnimSpritePal_Obstruct[]; extern const u32 gBattleAnimSpriteGfx_OmegaStone[]; extern const u32 gBattleAnimSpritePal_OmegaStone[]; +extern const u32 gBattleAnimSpriteGfx_OmegaSymbol[]; +extern const u32 gBattleAnimSpritePal_OmegaSymbol[]; extern const u32 gBattleAnimSpriteGfx_PinkDiamond[]; extern const u32 gBattleAnimSpritePal_PinkDiamond[]; extern const u32 gBattleAnimSpriteGfx_PoisonColumn[]; diff --git a/src/battle_anim.c b/src/battle_anim.c index d1a69bcde..551979e70 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -1564,6 +1564,9 @@ const struct CompressedSpriteSheet gBattleAnimPicTable[] = {gBattleAnimSpriteGfx_DreepyMissile, 0x200, ANIM_TAG_DREEPY}, {gBattleAnimSpriteGfx_IceRock, 0x1800, ANIM_TAG_ICE_ROCK_SINGLE}, {gBattleAnimSpriteGfx_StonePillar, 0x1800, ANIM_TAG_STONE_PILLAR_MULTI}, + {gBattleAnimSpriteGfx_AlphaSymbol, 0x0200, ANIM_TAG_ALPHA_SYMBOL}, + {gBattleAnimSpriteGfx_OmegaSymbol, 0x0200, ANIM_TAG_OMEGA_SYMBOL}, + {gBattleAnimSpriteGfx_PrimalParticles, 0x0180, ANIM_TAG_PRIMAL_PARTICLES}, }; const struct CompressedSpritePalette gBattleAnimPaletteTable[] = @@ -2011,6 +2014,9 @@ const struct CompressedSpritePalette gBattleAnimPaletteTable[] = {gBattleAnimSpritePal_DreepyMissile, ANIM_TAG_DREEPY}, {gBattleAnimSpritePal_IceRock, ANIM_TAG_ICE_ROCK_SINGLE}, {gBattleAnimSpritePal_StonePillar, ANIM_TAG_STONE_PILLAR_MULTI}, + {gBattleAnimSpritePal_AlphaSymbol, ANIM_TAG_ALPHA_SYMBOL}, + {gBattleAnimSpritePal_OmegaSymbol, ANIM_TAG_OMEGA_SYMBOL}, + {gBattleAnimSpritePal_PrimalParticles, ANIM_TAG_PRIMAL_PARTICLES}, }; const struct BattleAnimBackground gBattleAnimBackgroundTable[] = diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index 78b02168e..11e350535 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -1219,6 +1219,61 @@ const struct SpriteTemplate gMegaSymbolSpriteTemplate = .callback = AnimGhostStatusSprite, }; +const struct SpriteTemplate gAlphaStoneSpriteTemplate = +{ + .tileTag = ANIM_TAG_ALPHA_STONE, + .paletteTag = ANIM_TAG_ALPHA_STONE, + .oam = &gOamData_AffineDouble_ObjBlend_64x64, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gAffineAnims_LusterPurgeCircle, + .callback = AnimSpriteOnMonPos, +}; + +const struct SpriteTemplate gOmegaStoneSpriteTemplate = +{ + .tileTag = ANIM_TAG_OMEGA_STONE, + .paletteTag = ANIM_TAG_OMEGA_STONE, + .oam = &gOamData_AffineDouble_ObjBlend_64x64, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gAffineAnims_LusterPurgeCircle, + .callback = AnimSpriteOnMonPos, +}; + +const struct SpriteTemplate gPrimalParticlesSpriteTemplate = +{ + .tileTag = ANIM_TAG_PRIMAL_PARTICLES, + .paletteTag = ANIM_TAG_PRIMAL_PARTICLES, + .oam = &gOamData_AffineNormal_ObjBlend_16x16, + .anims = gPowerAbsorptionOrbAnimTable, + .images = NULL, + .affineAnims = gPowerAbsorptionOrbAffineAnimTable, + .callback = AnimPowerAbsorptionOrb, +}; + +const struct SpriteTemplate gAlphaSymbolSpriteTemplate = +{ + .tileTag = ANIM_TAG_ALPHA_SYMBOL, + .paletteTag = ANIM_TAG_ALPHA_SYMBOL, + .oam = &gOamData_AffineOff_ObjBlend_32x32, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = AnimGhostStatusSprite, +}; + +const struct SpriteTemplate gOmegaSymbolSpriteTemplate = +{ + .tileTag = ANIM_TAG_OMEGA_SYMBOL, + .paletteTag = ANIM_TAG_OMEGA_SYMBOL, + .oam = &gOamData_AffineOff_ObjBlend_32x32, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = AnimGhostStatusSprite, +}; + void AnimBlackSmoke(struct Sprite *sprite) { sprite->x += gBattleAnimArgs[0]; diff --git a/src/battle_anim_new.c b/src/battle_anim_new.c index 0c452c236..367f6ddeb 100644 --- a/src/battle_anim_new.c +++ b/src/battle_anim_new.c @@ -15,6 +15,7 @@ #include "battle_controllers.h" #include "constants/moves.h" #include "constants/hold_effects.h" +#include "constants/items.h" //// function declarations static void SpriteCB_SpriteToCentreOfSide(struct Sprite* sprite); @@ -5020,3 +5021,12 @@ void AnimTask_TechnoBlast(u8 taskId) gBattleAnimArgs[0] = 0; DestroyAnimVisualTask(taskId); } + +void AnimTask_PrimalReversion(u8 taskId) +{ + if (ItemId_GetId(gBattleMons[gBattleAnimAttacker].item) == ITEM_RED_ORB) + gBattleAnimArgs[0] = ItemId_GetId(gBattleMons[gBattleAnimAttacker].item); + else + gBattleAnimArgs[0] = 0; + DestroyAnimVisualTask(taskId); +} diff --git a/src/battle_interface.c b/src/battle_interface.c index 26d6fb27f..e909ea22a 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -665,6 +665,28 @@ static const struct SpritePalette sSpritePalette_MegaIndicator = sMegaIndicatorPal, TAG_MEGA_INDICATOR_PAL }; +static const u8 sAlphaIndicatorGfx[] = INCBIN_U8("graphics/battle_interface/alpha_indicator.4bpp"); +static const u16 sAlphaIndicatorPal[] = INCBIN_U16("graphics/battle_interface/alpha_indicator.gbapal"); +static const u8 sOmegaIndicatorGfx[] = INCBIN_U8("graphics/battle_interface/omega_indicator.4bpp"); +static const u16 sOmegaIndicatorPal[] = INCBIN_U16("graphics/battle_interface/omega_indicator.gbapal"); + +static const struct SpriteSheet sSpriteSheet_AlphaIndicator = +{ + sAlphaIndicatorGfx, sizeof(sAlphaIndicatorGfx), TAG_ALPHA_INDICATOR_TILE +}; +static const struct SpritePalette sSpritePalette_AlphaIndicator = +{ + sAlphaIndicatorPal, TAG_ALPHA_INDICATOR_PAL +}; +static const struct SpriteSheet sSpriteSheet_OmegaIndicator = +{ + sOmegaIndicatorGfx, sizeof(sOmegaIndicatorGfx), TAG_OMEGA_INDICATOR_TILE +}; +static const struct SpritePalette sSpritePalette_OmegaIndicator = +{ + sOmegaIndicatorPal, TAG_OMEGA_INDICATOR_PAL +}; + static const struct OamData sOamData_MegaIndicator = { .y = 0, @@ -693,6 +715,28 @@ static const struct SpriteTemplate sSpriteTemplate_MegaIndicator = .callback = SpriteCb_MegaIndicator, }; +static const struct SpriteTemplate sSpriteTemplate_AlphaIndicator = +{ + .tileTag = TAG_ALPHA_INDICATOR_TILE, + .paletteTag = TAG_ALPHA_INDICATOR_PAL, + .oam = &sOamData_MegaIndicator, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCb_MegaIndicator, +}; + +static const struct SpriteTemplate sSpriteTemplate_OmegaIndicator = +{ + .tileTag = TAG_OMEGA_INDICATOR_TILE, + .paletteTag = TAG_OMEGA_INDICATOR_PAL, + .oam = &sOamData_MegaIndicator, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCb_MegaIndicator, +}; + // code @@ -805,8 +849,9 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId) healthBarSpritePtr->hBar_Data6 = data6; healthBarSpritePtr->invisible = TRUE; - // Create mega indicator sprite if is a mega evolved mon. - if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + // Create mega indicator sprite if is a mega evolved or a primal reverted mon. + if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]] + || gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) { megaIndicatorSpriteId = CreateMegaIndicatorSprite(battlerId, 0); gSprites[megaIndicatorSpriteId].invisible = TRUE; @@ -910,7 +955,8 @@ void SetHealthboxSpriteVisible(u8 healthboxSpriteId) gSprites[healthboxSpriteId].invisible = FALSE; gSprites[gSprites[healthboxSpriteId].hMain_HealthBarSpriteId].invisible = FALSE; gSprites[gSprites[healthboxSpriteId].oam.affineParam].invisible = FALSE; - if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]] + || gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) { u8 spriteId = GetMegaIndicatorSpriteId(healthboxSpriteId); if (spriteId != 0xFF) @@ -1033,8 +1079,9 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl) u8 *objVram; u8 battler = gSprites[healthboxSpriteId].hMain_Battler; - // Don't print Lv char if mon is mega evolved. - if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]) + // Don't print Lv char if mon is mega evolved or primal reverted. + if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]] + || gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battler)] & gBitTable[gBattlerPartyIndexes[battler]]) { objVram = ConvertIntToDecimalStringN(text, lvl, STR_CONV_MODE_LEFT_ALIGN, 3); xPos = 5 * (3 - (objVram - (text + 2))) - 1; @@ -1506,12 +1553,28 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) u32 spriteId, position; s16 x, y; - LoadSpritePalette(&sSpritePalette_MegaIndicator); - LoadSpriteSheet(&sSpriteSheet_MegaIndicator); + if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + { + LoadSpritePalette(&sSpritePalette_MegaIndicator); + LoadSpriteSheet(&sSpriteSheet_MegaIndicator); + } + else if (gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + { + if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_GROUDON) + { + LoadSpritePalette(&sSpritePalette_OmegaIndicator); + LoadSpriteSheet(&sSpriteSheet_OmegaIndicator); + } + else if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_KYOGRE) + { + LoadSpritePalette(&sSpritePalette_AlphaIndicator); + LoadSpriteSheet(&sSpriteSheet_AlphaIndicator); + } + } position = GetBattlerPosition(battlerId); GetBattlerHealthboxCoords(battlerId, &x, &y); - + x += sIndicatorPositions[position][0]; y += sIndicatorPositions[position][1]; @@ -1519,10 +1582,20 @@ u32 CreateMegaIndicatorSprite(u32 battlerId, u32 which) x -= 4; else if (gBattleMons[battlerId].level < 10) x += 5; - - spriteId = CreateSpriteAtEnd(&sSpriteTemplate_MegaIndicator, x, y, 0); - gSprites[gSprites[gHealthboxSpriteIds[battlerId]].oam.affineParam].hOther_IndicatorSpriteId = spriteId; + if (gBattleStruct->mega.evolvedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + { + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_MegaIndicator, x, y, 0); + } + else if (gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(battlerId)] & gBitTable[gBattlerPartyIndexes[battlerId]]) + { + if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_GROUDON) + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_OmegaIndicator, x, y, 0); + else if (GET_BASE_SPECIES_ID(gBattleMons[battlerId].species) == SPECIES_KYOGRE) + spriteId = CreateSpriteAtEnd(&sSpriteTemplate_AlphaIndicator, x, y, 0); + } + + gSprites[gSprites[gHealthboxSpriteIds[battlerId]].oam.affineParam].hOther_IndicatorSpriteId = spriteId; gSprites[spriteId].tBattler = battlerId; return spriteId; } diff --git a/src/battle_main.c b/src/battle_main.c index 62662d1e4..da080316e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3512,6 +3512,18 @@ static void TryDoEventsBeforeFirstTurn(void) } memset(gTotemBoosts, 0, sizeof(gTotemBoosts)); // erase all totem boosts just to be safe + // Primal Reversion + for (i = 0; i < gBattlersCount; i++) + { + if (CanMegaEvolve(i) + && GetBattlerHoldEffect(i, TRUE) == HOLD_EFFECT_PRIMAL_ORB) + { + gBattlerAttacker = i; + BattleScriptExecute(BattleScript_PrimalReversion); + return; + } + } + // Check all switch in abilities happening from the fastest mon to slowest. while (gBattleStruct->switchInAbilitiesCounter < gBattlersCount) { diff --git a/src/battle_message.c b/src/battle_message.c index f8df8f4b8..8ae103a66 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -718,9 +718,11 @@ static const u8 sText_MysteriousAirCurrent[] = _("A mysterious air current is\np static const u8 sText_StrongWindsDissipated[] = _("The mysterious strong winds\nhave dissipated!{PAUSE 64}"); static const u8 sText_MysteriousAirCurrentBlowsOn[] = _("The mysterious air current\nblows on regardless!"); static const u8 sText_AttackWeakenedByStrongWinds[] = _("The mysterious strong winds\nweakened the attack!"); +static const u8 sText_PkmnRevertedToPrimal[] = _("{B_ATK_NAME_WITH_PREFIX}'s Primal Reversion!\nIt reverted to its primal form!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_PKMNREVERTEDTOPRIMAL - 12] = sText_PkmnRevertedToPrimal, [STRINGID_ATTACKWEAKENEDBSTRONGWINDS - 12] = sText_AttackWeakenedByStrongWinds, [STRINGID_MYSTERIOUSAIRCURRENTBLOWSON - 12] = sText_MysteriousAirCurrentBlowsOn, [STRINGID_STRONGWINDSDISSIPATED - 12] = sText_StrongWindsDissipated, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 3b627a020..1fbf2369a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -56,6 +56,7 @@ #include "constants/party_menu.h" extern struct MusicPlayerInfo gMPlayInfo_BGM; +extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; extern const u8* const gBattleScriptsForMoveEffects[]; @@ -4545,7 +4546,12 @@ static void Cmd_playanimation(void) || gBattlescriptCurrInstr[2] == B_ANIM_MEGA_EVOLUTION || gBattlescriptCurrInstr[2] == B_ANIM_ILLUSION_OFF || gBattlescriptCurrInstr[2] == B_ANIM_FORM_CHANGE - || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE) + || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE + || gBattlescriptCurrInstr[2] == B_ANIM_RAIN_CONTINUES + || gBattlescriptCurrInstr[2] == B_ANIM_SUN_CONTINUES + || gBattlescriptCurrInstr[2] == B_ANIM_SANDSTORM_CONTINUES + || gBattlescriptCurrInstr[2] == B_ANIM_HAIL_CONTINUES + || gBattlescriptCurrInstr[2] == B_ANIM_PRIMAL_REVERSION) { BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); @@ -4591,7 +4597,11 @@ static void Cmd_playanimation2(void) // animation Id is stored in the first poin || *animationIdPtr == B_ANIM_MEGA_EVOLUTION || *animationIdPtr == B_ANIM_ILLUSION_OFF || *animationIdPtr == B_ANIM_FORM_CHANGE - || *animationIdPtr == B_ANIM_SUBSTITUTE_FADE) + || *animationIdPtr == B_ANIM_SUBSTITUTE_FADE + || *animationIdPtr == B_ANIM_RAIN_CONTINUES + || *animationIdPtr == B_ANIM_SUN_CONTINUES + || *animationIdPtr == B_ANIM_SANDSTORM_CONTINUES + || *animationIdPtr == B_ANIM_PRIMAL_REVERSION) { BtlController_EmitBattleAnimation(0, *animationIdPtr, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); @@ -8179,6 +8189,47 @@ static void Cmd_various(void) } gBattlescriptCurrInstr += 4; return; + case VARIOUS_HANDLE_PRIMAL_REVERSION: + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) + mon = &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]; + else + mon = &gPlayerParty[gBattlerPartyIndexes[gActiveBattler]]; + + // Change species. + if (gBattlescriptCurrInstr[3] == 0) + { + u16 primalSpecies; + gBattleStruct->mega.primalRevertedSpecies[gActiveBattler] = gBattleMons[gActiveBattler].species; + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT + || (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT && !(gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_INGAME_PARTNER)))) + { + gBattleStruct->mega.playerPrimalRevertedSpecies = gBattleStruct->mega.primalRevertedSpecies[gActiveBattler]; + } + // Checks Primal Reversion + primalSpecies = GetMegaEvolutionSpecies(gBattleStruct->mega.primalRevertedSpecies[gActiveBattler], gBattleMons[gActiveBattler].item); + + gBattleMons[gActiveBattler].species = primalSpecies; + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gActiveBattler].species); + + BtlController_EmitSetMonData(0, REQUEST_SPECIES_BATTLE, gBitTable[gBattlerPartyIndexes[gActiveBattler]], 2, &gBattleMons[gActiveBattler].species); + MarkBattlerForControllerExec(gActiveBattler); + } + // Change stats. + else if (gBattlescriptCurrInstr[3] == 1) + { + RecalcBattlerStats(gActiveBattler, mon); + gBattleStruct->mega.primalRevertedPartyIds[GetBattlerSide(gActiveBattler)] |= gBitTable[gBattlerPartyIndexes[gActiveBattler]]; + } + // Update healthbox and elevation. + else + { + UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], mon, HEALTHBOX_ALL); + CreateMegaIndicatorSprite(gActiveBattler, 0); + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) + SetBattlerShadowSpriteCallback(gActiveBattler, gBattleMons[gActiveBattler].species); + } + gBattlescriptCurrInstr += 4; + return; case VARIOUS_HANDLE_FORM_CHANGE: if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) mon = &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]; @@ -8822,6 +8873,21 @@ static void Cmd_various(void) } break; } + case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL: + { + bool8 canDoPrimalReversion = FALSE; + + for (i = 0; i < EVOS_PER_MON; i++) + { + if (gEvolutionTable[gBattleMons[gActiveBattler].species][i].method == EVO_PRIMAL_REVERSION + && gEvolutionTable[gBattleMons[gActiveBattler].species][i].param == gBattleMons[gActiveBattler].item) + canDoPrimalReversion = TRUE; + } + if (!canDoPrimalReversion) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + } } gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index 01ee1a691..991692006 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -8154,7 +8154,8 @@ static bool32 CanEvolve(u32 species) { if (gEvolutionTable[species][i].method && gEvolutionTable[species][i].method != EVO_MEGA_EVOLUTION - && gEvolutionTable[species][i].method != EVO_MOVE_MEGA_EVOLUTION) + && gEvolutionTable[species][i].method != EVO_MOVE_MEGA_EVOLUTION + && gEvolutionTable[species][i].method != EVO_PRIMAL_REVERSION) return TRUE; } return FALSE; @@ -8708,9 +8709,10 @@ u16 GetMegaEvolutionSpecies(u16 preEvoSpecies, u16 heldItemId) for (i = 0; i < EVOS_PER_MON; i++) { - if (gEvolutionTable[preEvoSpecies][i].method == EVO_MEGA_EVOLUTION - && gEvolutionTable[preEvoSpecies][i].param == heldItemId) - return gEvolutionTable[preEvoSpecies][i].targetSpecies; + if ((gEvolutionTable[preEvoSpecies][i].method == EVO_MEGA_EVOLUTION + || gEvolutionTable[preEvoSpecies][i].method == EVO_PRIMAL_REVERSION) + && gEvolutionTable[preEvoSpecies][i].param == heldItemId) + return gEvolutionTable[preEvoSpecies][i].targetSpecies; } return SPECIES_NONE; } @@ -8775,12 +8777,20 @@ bool32 CanMegaEvolve(u8 battlerId) else holdEffect = ItemId_GetHoldEffect(itemId); - // Can Mega Evolve via Item. + // Can Mega Evolve via Mega Stone. if (holdEffect == HOLD_EFFECT_MEGA_STONE) { gBattleStruct->mega.isWishMegaEvo = FALSE; return TRUE; } + + // Can undergo Primal Reversion. + if (holdEffect == HOLD_EFFECT_PRIMAL_ORB) + { + gBattleStruct->mega.isWishMegaEvo = FALSE; + gBattleStruct->mega.isPrimalReversion = TRUE; + return TRUE; + } } // Check if there is an entry in the evolution table for Wish Mega Evolution. @@ -8796,12 +8806,20 @@ bool32 CanMegaEvolve(u8 battlerId) void UndoMegaEvolution(u32 monId) { + u16 baseSpecies = GET_BASE_SPECIES_ID(GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES)); + if (gBattleStruct->mega.evolvedPartyIds[B_SIDE_PLAYER] & gBitTable[monId]) { gBattleStruct->mega.evolvedPartyIds[B_SIDE_PLAYER] &= ~(gBitTable[monId]); SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleStruct->mega.playerEvolvedSpecies); CalculateMonStats(&gPlayerParty[monId]); } + else if (gBattleStruct->mega.primalRevertedPartyIds[B_SIDE_PLAYER] & gBitTable[monId]) + { + gBattleStruct->mega.primalRevertedPartyIds[B_SIDE_PLAYER] &= ~(gBitTable[monId]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &baseSpecies); + CalculateMonStats(&gPlayerParty[monId]); + } // While not exactly a mega evolution, Zygarde follows the same rules. else if (GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, NULL) == SPECIES_ZYGARDE_COMPLETE) { diff --git a/src/graphics.c b/src/graphics.c index 247231d55..4cbc4b334 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -41,6 +41,15 @@ const u32 gBattleAnimSpritePal_MegaParticles[] = INCBIN_U32("graphics/battle_ani const u32 gBattleAnimSpriteGfx_MegaSymbol[] = INCBIN_U32("graphics/battle_anims/sprites/mega_symbol.4bpp.lz"); const u32 gBattleAnimSpritePal_MegaSymbol[] = INCBIN_U32("graphics/battle_anims/sprites/mega_symbol.gbapal.lz"); +const u32 gBattleAnimSpriteGfx_AlphaSymbol[] = INCBIN_U32("graphics/battle_anims/sprites/alpha_symbol.4bpp.lz"); +const u32 gBattleAnimSpritePal_AlphaSymbol[] = INCBIN_U32("graphics/battle_anims/sprites/alpha_symbol.gbapal.lz"); + +const u32 gBattleAnimSpriteGfx_OmegaSymbol[] = INCBIN_U32("graphics/battle_anims/sprites/omega_symbol.4bpp.lz"); +const u32 gBattleAnimSpritePal_OmegaSymbol[] = INCBIN_U32("graphics/battle_anims/sprites/omega_symbol.gbapal.lz"); + +const u32 gBattleAnimSpriteGfx_PrimalParticles[] = INCBIN_U32("graphics/battle_anims/sprites/primal_particles.4bpp.lz"); +const u32 gBattleAnimSpritePal_PrimalParticles[] = INCBIN_U32("graphics/battle_anims/sprites/primal_particles.gbapal.lz"); + const u32 gBattleAnimSpriteGfx_FlashCannonBall[] = INCBIN_U32("graphics/battle_anims/sprites/flash_cannon_ball.4bpp.lz"); const u32 gBattleAnimSpritePal_FlashCannonBall[] = INCBIN_U32("graphics/battle_anims/sprites/flash_cannon_ball.gbapal.lz"); From 2120545649004d618397d9f39b884b391dffcfad Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 9 Oct 2021 01:07:27 -0300 Subject: [PATCH 20/85] Oopsie --- src/battle_script_commands.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1fbf2369a..dcd9c8999 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4547,10 +4547,6 @@ static void Cmd_playanimation(void) || gBattlescriptCurrInstr[2] == B_ANIM_ILLUSION_OFF || gBattlescriptCurrInstr[2] == B_ANIM_FORM_CHANGE || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE - || gBattlescriptCurrInstr[2] == B_ANIM_RAIN_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_SUN_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_SANDSTORM_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_HAIL_CONTINUES || gBattlescriptCurrInstr[2] == B_ANIM_PRIMAL_REVERSION) { BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); @@ -4598,9 +4594,6 @@ static void Cmd_playanimation2(void) // animation Id is stored in the first poin || *animationIdPtr == B_ANIM_ILLUSION_OFF || *animationIdPtr == B_ANIM_FORM_CHANGE || *animationIdPtr == B_ANIM_SUBSTITUTE_FADE - || *animationIdPtr == B_ANIM_RAIN_CONTINUES - || *animationIdPtr == B_ANIM_SUN_CONTINUES - || *animationIdPtr == B_ANIM_SANDSTORM_CONTINUES || *animationIdPtr == B_ANIM_PRIMAL_REVERSION) { BtlController_EmitBattleAnimation(0, *animationIdPtr, *argumentPtr); 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 21/85] 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 22/85] 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 3add4d6a17f261a1223d7b2ce765f583bf8d753b Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 10 Oct 2021 00:46:59 -0300 Subject: [PATCH 23/85] Added some status3 options to debug menu --- src/battle_debug.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/battle_debug.c b/src/battle_debug.c index b9cfcdc03..657dc6061 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -207,6 +207,8 @@ static const u8 sText_GastroAcid[] = _("Gastro Acid"); static const u8 sText_SmackDown[] = _("Smacked Down"); static const u8 sText_MiracleEye[] = _("Miracle Eye"); static const u8 sText_AquaRing[] = _("Aqua Ring"); +static const u8 sText_LaserFocus[] = _("Laser Focused"); +static const u8 sText_Electrified[] = _("Electrified"); static const u8 sText_AuroraVeil[] = _("Aurora Veil"); static const u8 sText_LuckyChant[] = _("Lucky Chant"); static const u8 sText_Tailwind[] = _("Tailwind"); @@ -295,6 +297,9 @@ static const struct BitfieldInfo sStatus3Bitfield[] = // Magnet Rise 1, 26, // Heal Block 1, 27, {/*Aqua Ring*/ 1, 28}, + {/*Laser Focus*/ 1, 29}, + {/*Electrified*/ 1, 30}, + // Power Trick 1, 31, }; static const struct BitfieldInfo sAIBitfield[] = @@ -408,6 +413,8 @@ static const struct ListMenuItem sStatus3ListItems[] = {sText_SmackDown, 8}, {sText_MiracleEye, 9}, {sText_AquaRing, 10}, + {sText_LaserFocus, 11}, + {sText_Electrified, 12}, }; static const struct ListMenuItem sSideStatusListItems[] = From cf6e3873b48bbf3d9c1ed3cd611ca6cf47e04ec2 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sun, 10 Oct 2021 01:13:23 -0300 Subject: [PATCH 24/85] Moved Electrified to Status4. --- include/battle.h | 1 + include/constants/battle.h | 5 +++-- src/battle_debug.c | 27 ++++++++++++++++++++++++--- src/battle_main.c | 3 ++- src/battle_script_commands.c | 2 +- src/battle_util.c | 2 +- 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/include/battle.h b/include/battle.h index 826a0929e..6bca8d394 100644 --- a/include/battle.h +++ b/include/battle.h @@ -857,6 +857,7 @@ extern u8 gUnusedFirstBattleVar2; extern u32 gSideStatuses[2]; extern struct SideTimer gSideTimers[2]; extern u32 gStatuses3[MAX_BATTLERS_COUNT]; +extern u32 gStatuses4[MAX_BATTLERS_COUNT]; extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT]; extern u16 gPauseCounterBattle; extern u16 gPaydayMoney; diff --git a/include/constants/battle.h b/include/constants/battle.h index a59ea2f1a..abaddde96 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -169,10 +169,11 @@ #define STATUS3_HEAL_BLOCK (1 << 27) #define STATUS3_AQUA_RING (1 << 28) #define STATUS3_LASER_FOCUS (1 << 29) -#define STATUS3_ELECTRIFIED (1 << 30) -#define STATUS3_POWER_TRICK (1 << 31) +#define STATUS3_POWER_TRICK (1 << 30) #define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER | STATUS3_PHANTOM_FORCE) +#define STATUS4_ELECTRIFIED (1 << 0) + #define HITMARKER_x10 (1 << 4) #define HITMARKER_x20 (1 << 5) #define HITMARKER_DESTINYBOND (1 << 6) diff --git a/src/battle_debug.c b/src/battle_debug.c index 657dc6061..25ca9e92d 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -97,6 +97,7 @@ enum LIST_ITEM_STATUS1, LIST_ITEM_STATUS2, LIST_ITEM_STATUS3, + LIST_ITEM_STATUS4, LIST_ITEM_SIDE_STATUS, LIST_ITEM_AI, LIST_ITEM_AI_MOVES_PTS, @@ -164,6 +165,7 @@ static const u8 sText_StatStages[] = _("Stat Stages"); static const u8 sText_Status1[] = _("Status1"); static const u8 sText_Status2[] = _("Status2"); static const u8 sText_Status3[] = _("Status3"); +static const u8 sText_Status4[] = _("Status4"); static const u8 sText_HeldItem[] = _("Held Item"); static const u8 sText_SideStatus[] = _("Side Status"); static const u8 sText_MaxHp[] = _("HP Max"); @@ -298,8 +300,12 @@ static const struct BitfieldInfo sStatus3Bitfield[] = // Heal Block 1, 27, {/*Aqua Ring*/ 1, 28}, {/*Laser Focus*/ 1, 29}, - {/*Electrified*/ 1, 30}, - // Power Trick 1, 31, + // Power Trick 1, 30, +}; + +static const struct BitfieldInfo sStatus4Bitfield[] = +{ + {/*Electrified*/ 1, 0,} }; static const struct BitfieldInfo sAIBitfield[] = @@ -329,6 +335,7 @@ static const struct ListMenuItem sMainListItems[] = {sText_Status1, LIST_ITEM_STATUS1}, {sText_Status2, LIST_ITEM_STATUS2}, {sText_Status3, LIST_ITEM_STATUS3}, + {sText_Status4, LIST_ITEM_STATUS4}, {sText_SideStatus, LIST_ITEM_SIDE_STATUS}, {sText_AI, LIST_ITEM_AI}, {sText_AIMovePts, LIST_ITEM_AI_MOVES_PTS}, @@ -414,7 +421,11 @@ static const struct ListMenuItem sStatus3ListItems[] = {sText_MiracleEye, 9}, {sText_AquaRing, 10}, {sText_LaserFocus, 11}, - {sText_Electrified, 12}, +}; + +static const struct ListMenuItem sStatus4ListItems[] = +{ + {sText_Electrified, 0}, }; static const struct ListMenuItem sSideStatusListItems[] = @@ -1183,6 +1194,11 @@ static void CreateSecondaryListMenu(struct BattleDebugMenu *data) itemsCount = ARRAY_COUNT(sStatus3ListItems); data->bitfield = sStatus3Bitfield; break; + case LIST_ITEM_STATUS4: + listTemplate.items = sStatus4ListItems; + itemsCount = ARRAY_COUNT(sStatus4ListItems); + data->bitfield = sStatus4Bitfield; + break; case LIST_ITEM_AI: listTemplate.items = sAIListItems; itemsCount = ARRAY_COUNT(sAIListItems); @@ -1741,6 +1757,11 @@ static void SetUpModifyArrows(struct BattleDebugMenu *data) data->modifyArrows.currValue = GetBitfieldValue(gStatuses3[data->battlerId], data->bitfield[data->currentSecondaryListItemId].currBit, data->bitfield[data->currentSecondaryListItemId].bitsCount); data->modifyArrows.typeOfVal = VAL_BITFIELD_32; goto CASE_ITEM_STATUS; + case LIST_ITEM_STATUS4: + data->modifyArrows.modifiedValPtr = &gStatuses4[data->battlerId]; + data->modifyArrows.currValue = GetBitfieldValue(gStatuses4[data->battlerId], data->bitfield[data->currentSecondaryListItemId].currBit, data->bitfield[data->currentSecondaryListItemId].bitsCount); + data->modifyArrows.typeOfVal = VAL_BITFIELD_32; + goto CASE_ITEM_STATUS; case LIST_ITEM_AI: data->modifyArrows.modifiedValPtr = &gBattleResources->ai->aiFlags; data->modifyArrows.currValue = GetBitfieldValue(gBattleResources->ai->aiFlags, data->bitfield[data->currentSecondaryListItemId].currBit, data->bitfield[data->currentSecondaryListItemId].bitsCount); diff --git a/src/battle_main.c b/src/battle_main.c index 055ec9bbe..2c1597718 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -190,6 +190,7 @@ EWRAM_DATA u8 gUnusedFirstBattleVar2 = 0; // Never read EWRAM_DATA u32 gSideStatuses[2] = {0}; EWRAM_DATA struct SideTimer gSideTimers[2] = {0}; EWRAM_DATA u32 gStatuses3[MAX_BATTLERS_COUNT] = {0}; +EWRAM_DATA u32 gStatuses4[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u16 gPauseCounterBattle = 0; EWRAM_DATA u16 gPaydayMoney = 0; @@ -5118,7 +5119,7 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk) attackerAbility = GetBattlerAbility(battlerAtk); GET_MOVE_TYPE(move, moveType); if ((gFieldStatuses & STATUS_FIELD_ION_DELUGE && moveType == TYPE_NORMAL) - || gStatuses3[battlerAtk] & STATUS3_ELECTRIFIED) + || gStatuses4[battlerAtk] & STATUS4_ELECTRIFIED) { gBattleStruct->dynamicMoveType = 0x80 | TYPE_ELECTRIC; } diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9d6dbb89b..8eeea603e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8089,7 +8089,7 @@ static void Cmd_various(void) } else { - gStatuses3[gBattlerTarget] |= STATUS3_ELECTRIFIED; + gStatuses4[gBattlerTarget] |= STATUS4_ELECTRIFIED; gBattlescriptCurrInstr += 7; } return; diff --git a/src/battle_util.c b/src/battle_util.c index 8195e2f32..36effb2db 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2838,7 +2838,7 @@ u8 DoBattlerEndTurnEffects(void) gBattleStruct->turnEffectsTracker++; break; case ENDTURN_ELECTRIFY: - gStatuses3[gActiveBattler] &= ~(STATUS3_ELECTRIFIED); + gStatuses4[gActiveBattler] &= ~(STATUS4_ELECTRIFIED); gBattleStruct->turnEffectsTracker++; case ENDTURN_POWDER: gBattleMons[gActiveBattler].status2 &= ~(STATUS2_POWDER); From fcada4fcad924a905560a726beb49733c3278382 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sun, 10 Oct 2021 19:54:17 -0400 Subject: [PATCH 25/85] handle rototiller + prankster --- data/battle_scripts_1.s | 4 ---- include/battle_util.h | 2 +- src/battle_script_commands.c | 19 ++++++++++--------- src/battle_util.c | 25 +++++++++++++++---------- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3d9c66bd6..9ed0d1fcc 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -942,10 +942,6 @@ BattleScript_FlowerShieldMoveTargetEnd: jumpifnexttargetvalid BattleScript_FlowerShieldLoop end -BattleScript_RototillerRet:: - - return - BattleScript_EffectRototiller: attackcanceler attackstring diff --git a/include/battle_util.h b/include/battle_util.h index 612a2e6d9..43f66db6b 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -152,7 +152,7 @@ bool32 CompareStat(u8 battlerId, u8 statId, u8 cmpTo, u8 cmpKind); bool32 TryRoomService(u8 battlerId); void BufferStatChange(u8 battlerId, u8 statId, u8 stringId); void DoBurmyFormChange(u32 monId); -bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef); +bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget); // ability checks bool32 IsRolePlayBannedAbilityAtk(u16 ability); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 339e5bd99..e70b990eb 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1416,7 +1416,7 @@ static void Cmd_attackcanceler(void) gProtectStructs[gBattlerTarget].bounceMove = 0; gProtectStructs[gBattlerTarget].usesBouncedMove = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 0; - if (BlocksPrankster(gCurrentMove, gBattlerTarget, gBattlerAttacker)) + if (BlocksPrankster(gCurrentMove, gBattlerTarget, gBattlerAttacker, TRUE)) { // Opponent used a prankster'd magic coat -> reflected status move should fail against a dark-type attacker gBattlerTarget = gBattlerAttacker; @@ -7345,8 +7345,8 @@ static bool32 IsRototillerAffected(u32 battlerId) return FALSE; // Only grass types affected if (gStatuses3[battlerId] & STATUS3_SEMI_INVULNERABLE) return FALSE; // Rototiller doesn't affected semi-invulnerable battlers - //if (!CompareStat(battlerId, STAT_ATK, MAX_STAT_STAGE, CMP_LESS_THAN) && !CompareStat(battlerId, STAT_SPATK, MAX_STAT_STAGE, CMP_LESS_THAN)) - //return FALSE; // Battler unaffected if atk and spatk are maxed + if (BlocksPrankster(MOVE_ROTOTILLER, gBattlerAttacker, battlerId, FALSE)) + return FALSE; return TRUE; } @@ -8757,21 +8757,22 @@ static void Cmd_various(void) } gFieldStatuses &= ~STATUS_FIELD_TERRAIN_ANY; // remove the terrain break; - case VARIOUS_JUMP_IF_PRANKSTER_BLOCKED: - if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gActiveBattler)) + case VARIOUS_JUMP_IF_PRANKSTER_BLOCKED: + if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gActiveBattler, TRUE)) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; return; - case VARIOUS_GET_ROTOTILLER_TARGETS: + case VARIOUS_GET_ROTOTILLER_TARGETS: // Gets the battlers to be affected by rototiller. If there are none, print 'But it failed!' { u32 count = 0; for (i = 0; i < gBattlersCount; i++) { + gSpecialStatuses[i].rototillerAffected = FALSE; if (IsRototillerAffected(i)) { - gSpecialStatuses[i].rototillerAffected = 1; + gSpecialStatuses[i].rototillerAffected = TRUE; count++; } } @@ -8785,7 +8786,7 @@ static void Cmd_various(void) case VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED: if (gSpecialStatuses[gActiveBattler].rototillerAffected) { - gSpecialStatuses[gActiveBattler].rototillerAffected = 0; + gSpecialStatuses[gActiveBattler].rototillerAffected = FALSE; gBattlescriptCurrInstr += 7; } else @@ -10954,7 +10955,7 @@ static void Cmd_trysetperishsong(void) { if (gStatuses3[i] & STATUS3_PERISH_SONG || GetBattlerAbility(i) == ABILITY_SOUNDPROOF - || BlocksPrankster(gCurrentMove, gBattlerAttacker, i)) + || BlocksPrankster(gCurrentMove, gBattlerAttacker, i, TRUE)) { notAffectedCount++; } diff --git a/src/battle_util.c b/src/battle_util.c index a709aaf9e..40a100796 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3421,7 +3421,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case CANCELLER_PRANKSTER: - if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gBattlerTarget) + if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gBattlerTarget, TRUE) && !(IS_MOVE_STATUS(gCurrentMove) && GetBattlerAbility(gBattlerTarget) == ABILITY_MAGIC_BOUNCE)) { if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(gBattleMoves[gCurrentMove].target & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) @@ -9344,16 +9344,21 @@ void DoBurmyFormChange(u32 monId) } } -bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef) +bool32 BlocksPrankster(u16 move, u8 battlerPrankster, u8 battlerDef, bool32 checkTarget) { #if B_PRANKSTER_DARK_TYPES >= GEN_7 - if (gProtectStructs[battlerPrankster].pranksterElevated - && GetBattlerSide(battlerPrankster) != GetBattlerSide(battlerDef) - && !(gBattleMoves[gCurrentMove].target & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_DEPENDS)) // Don't block hazards, assist-type moves - && IS_BATTLER_OF_TYPE(battlerDef, TYPE_DARK) // Only Dark-types can block Prankster'd - && !(gStatuses3[battlerDef] & STATUS3_SEMI_INVULNERABLE)) - return TRUE; - else - #endif + if (!gProtectStructs[battlerPrankster].pranksterElevated) return FALSE; + if (GetBattlerSide(battlerPrankster) == GetBattlerSide(battlerDef)) + return FALSE; + if (checkTarget && (gBattleMoves[move].target & (MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_DEPENDS))) + return FALSE; + if (!IS_BATTLER_OF_TYPE(battlerDef, TYPE_DARK)) + return FALSE; + if (gStatuses3[battlerDef] & STATUS3_SEMI_INVULNERABLE) + return FALSE; + + return TRUE; + #endif + return FALSE; } From 6c550cd7490183b25caa294109da057de7824a8f Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 11 Oct 2021 03:16:59 -0300 Subject: [PATCH 26/85] Implemented Retaliate's effect --- include/battle.h | 1 + src/battle_main.c | 3 +++ src/battle_script_commands.c | 1 + src/battle_util.c | 6 +++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/battle.h b/include/battle.h index 826a0929e..aaecb9ea1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -908,5 +908,6 @@ extern u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; extern u16 gLastThrownBall; +extern bool8 gCanRetaliate; #endif // GUARD_BATTLE_H diff --git a/src/battle_main.c b/src/battle_main.c index 055ec9bbe..7d4ae76dd 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -231,6 +231,7 @@ EWRAM_DATA struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA bool8 gHasFetchedBall = FALSE; EWRAM_DATA u8 gLastUsedBall = 0; EWRAM_DATA u16 gLastThrownBall = 0; +EWRAM_DATA bool8 gCanRetaliate = FALSE; // IWRAM common vars void (*gPreBattleCallback1)(void); @@ -2876,6 +2877,8 @@ static void BattleStartClearSetData(void) gHasFetchedBall = FALSE; gLastUsedBall = 0; + gCanRetaliate = FALSE; + gBattlerAttacker = 0; gBattlerTarget = 0; gBattleWeather = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df..b3ac59863 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3499,6 +3499,7 @@ static void Cmd_tryfaintmon(void) if (gBattleResults.playerFaintCounter < 0xFF) gBattleResults.playerFaintCounter++; AdjustFriendshipOnBattleFaint(gActiveBattler); + gCanRetaliate = TRUE; } else { diff --git a/src/battle_util.c b/src/battle_util.c index 0bca1c0e7..d588d5b08 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7933,7 +7933,11 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); break; case EFFECT_RETALIATE: - // todo + if (gCanRetaliate) + { + MulModifier(&modifier, UQ_4_12(2.0)); + gCanRetaliate = FALSE; + } break; case EFFECT_SOLARBEAM: if (WEATHER_HAS_EFFECT && gBattleWeather & (WEATHER_HAIL_ANY | WEATHER_SANDSTORM_ANY | WEATHER_RAIN_ANY)) From 791a899eed1a4e34eed30ff80b531a96248f5008 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Mon, 11 Oct 2021 21:29:08 -0400 Subject: [PATCH 27/85] fix sand spit + primal weather --- src/battle_util.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 68e787698..7b0c85078 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5028,20 +5028,21 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && TARGET_TURN_DAMAGED - && !(WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SANDSTORM_ANY) - && TryChangeBattleWeather(battler, ENUM_WEATHER_SANDSTORM, TRUE) - && !(WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_PRIMAL_ANY)) + && !(WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SANDSTORM_ANY)) { - gBattleScripting.battler = gActiveBattler = battler; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_SandSpitActivates; - effect++; - } - else if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_PRIMAL_ANY) - { - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_BlockedByPrimalWeatherRet; - effect++; + if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_PRIMAL_ANY) + { + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_BlockedByPrimalWeatherRet; + effect++; + } + else if (TryChangeBattleWeather(battler, ENUM_WEATHER_SANDSTORM, TRUE)) + { + gBattleScripting.battler = gActiveBattler = battler; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_SandSpitActivates; + effect++; + } } break; case ABILITY_PERISH_BODY: From 11626d5043e94f9e82c458eb60ff49f19476e6bd Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 12 Oct 2021 07:53:28 -0400 Subject: [PATCH 28/85] fix memento fail condition --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df..5d483aa3e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11520,7 +11520,7 @@ static void Cmd_jumpifattackandspecialattackcannotfall(void) // memento && gBattleMons[gBattlerTarget].statStages[STAT_SPATK] == MIN_STAT_STAGE && gBattleCommunication[MISS_TYPE] != B_MSG_PROTECTED) #else - if (gBattleCommunication[MISS_TYPE] != B_MSG_PROTECTED + if (gBattleCommunication[MISS_TYPE] == B_MSG_PROTECTED || gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE || IsBattlerProtected(gBattlerTarget, gCurrentMove) || DoesSubstituteBlockMove(gBattlerAttacker, gBattlerTarget, gCurrentMove)) From 3248bd796aae7c25eed0314f4d84dccc4c6eed2b Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 12 Oct 2021 21:49:18 -0400 Subject: [PATCH 29/85] add quick draw --- data/battle_scripts_1.s | 8 ++++++ include/battle.h | 1 + include/battle_scripts.h | 1 + src/battle_main.c | 58 +++++++++++++++++++++++++++++----------- src/battle_message.c | 2 +- 5 files changed, 54 insertions(+), 16 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e1fb47930..eac3fc58c 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -8461,6 +8461,14 @@ BattleScript_QuickClawActivation:: waitmessage B_WAIT_TIME_LONG end2 +BattleScript_QuickDrawActivation:: + printstring STRINGID_EMPTYSTRING3 + waitmessage 1 + call BattleScript_AbilityPopUp + printstring STRINGID_CANACTFASTERTHANKSTO + waitmessage B_WAIT_TIME_LONG + end2 + BattleScript_CustapBerryActivation:: printstring STRINGID_EMPTYSTRING3 waitmessage 1 diff --git a/include/battle.h b/include/battle.h index 826a0929e..6c4cf290c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -151,6 +151,7 @@ struct ProtectStruct u32 disableEjectPack:1; u32 statFell:1; u32 pranksterElevated:1; + u32 quickDraw:1; u32 physicalDmg; u32 specialDmg; u8 physicalBattlerId; diff --git a/include/battle_scripts.h b/include/battle_scripts.h index cd4600543..b5ac64972 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -365,6 +365,7 @@ extern const u8 BattleScript_PerishBodyActivates[]; extern const u8 BattleScript_ActivateAsOne[]; extern const u8 BattleScript_RaiseStatOnFaintingTarget[]; extern const u8 BattleScript_QuickClawActivation[]; +extern const u8 BattleScript_QuickDrawActivation[]; extern const u8 BattleScript_CustapBerryActivation[]; extern const u8 BattleScript_MicleBerryActivateEnd2[]; extern const u8 BattleScript_MicleBerryActivateRet[]; diff --git a/src/battle_main.c b/src/battle_main.c index 055ec9bbe..ee3f57e35 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4379,20 +4379,32 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) u32 holdEffectBattler1 = 0, holdEffectBattler2 = 0; s8 priority1 = 0, priority2 = 0; + // Battler 1 speedBattler1 = GetBattlerTotalSpeedStat(battler1); holdEffectBattler1 = GetBattlerHoldEffect(battler1, TRUE); - if ((holdEffectBattler1 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler1)) / 100) + // Quick Draw + if (!ignoreChosenMoves && GetBattlerAbility(battler1) == ABILITY_QUICK_DRAW && !IS_MOVE_STATUS(gChosenMoveByBattler[battler1]) && Random() % 100 < 30) + gProtectStructs[battler1].quickDraw = TRUE; + // Quick Claw and Custap Berry + if (!gProtectStructs[battler1].quickDraw + && ((holdEffectBattler1 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler1)) / 100) || (!IsAbilityOnOpposingSide(battler1, ABILITY_UNNERVE) && holdEffectBattler1 == HOLD_EFFECT_CUSTAP_BERRY - && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item))) + && HasEnoughHpToEatBerry(battler1, 4, gBattleMons[battler1].item)))) gProtectStructs[battler1].custap = TRUE; + // Battler 2 speedBattler2 = GetBattlerTotalSpeedStat(battler2); holdEffectBattler2 = GetBattlerHoldEffect(battler2, TRUE); - if ((holdEffectBattler2 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler2)) / 100) + // Quick Draw + if (!ignoreChosenMoves && GetBattlerAbility(battler2) == ABILITY_QUICK_DRAW && !IS_MOVE_STATUS(gChosenMoveByBattler[battler2]) && Random() % 100 < 30) + gProtectStructs[battler2].quickDraw = TRUE; + // Quick Claw and Custap Berry + if (!gProtectStructs[battler2].quickDraw + && ((holdEffectBattler2 == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * GetBattlerHoldEffectParam(battler2)) / 100) || (!IsAbilityOnOpposingSide(battler2, ABILITY_UNNERVE) && holdEffectBattler2 == HOLD_EFFECT_CUSTAP_BERRY - && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item))) + && HasEnoughHpToEatBerry(battler2, 4, gBattleMons[battler2].item)))) gProtectStructs[battler2].custap = TRUE; if (!ignoreChosenMoves) @@ -4408,8 +4420,12 @@ u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) // QUICK CLAW / CUSTAP - always first // LAGGING TAIL - always last // STALL - always last - - if (gProtectStructs[battler1].custap && !gProtectStructs[battler2].custap) + + if (gProtectStructs[battler1].quickDraw && !gProtectStructs[battler2].quickDraw) + strikesFirst = 0; + else if (!gProtectStructs[battler1].quickDraw && gProtectStructs[battler2].quickDraw) + strikesFirst = 1; + else if (gProtectStructs[battler1].custap && !gProtectStructs[battler2].custap) strikesFirst = 0; else if (gProtectStructs[battler2].custap && !gProtectStructs[battler1].custap) strikesFirst = 1; @@ -4670,22 +4686,34 @@ static void CheckQuickClaw_CustapBerryActivation(void) gBattleStruct->quickClawBattlerId++; if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_MOVE && gChosenMoveByBattler[gActiveBattler] != MOVE_FOCUS_PUNCH // quick claw message doesn't need to activate here - && gProtectStructs[gActiveBattler].custap + && (gProtectStructs[gActiveBattler].custap || gProtectStructs[gActiveBattler].quickDraw) && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) && !(gDisableStructs[gBattlerAttacker].truantCounter) && !(gProtectStructs[gActiveBattler].noValidMoves)) { - gProtectStructs[gActiveBattler].custap = FALSE; - gLastUsedItem = gBattleMons[gActiveBattler].item; - if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) + if (gProtectStructs[gActiveBattler].custap) { - // don't record berry since its gone now - BattleScriptExecute(BattleScript_CustapBerryActivation); + gProtectStructs[gActiveBattler].custap = FALSE; + gLastUsedItem = gBattleMons[gActiveBattler].item; + PREPARE_ITEM_BUFFER(gBattleTextBuff1, gLastUsedItem); + if (GetBattlerHoldEffect(gActiveBattler, FALSE) == HOLD_EFFECT_CUSTAP_BERRY) + { + // don't record berry since its gone now + BattleScriptExecute(BattleScript_CustapBerryActivation); + } + else + { + RecordItemEffectBattle(gActiveBattler, GetBattlerHoldEffect(gActiveBattler, FALSE)); + BattleScriptExecute(BattleScript_QuickClawActivation); + } } - else + else if (gProtectStructs[gActiveBattler].quickDraw) { - RecordItemEffectBattle(gActiveBattler, GetBattlerHoldEffect(gActiveBattler, FALSE)); - BattleScriptExecute(BattleScript_QuickClawActivation); + gProtectStructs[gActiveBattler].quickDraw = FALSE; + gLastUsedAbility = gBattleMons[gActiveBattler].ability; + PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gLastUsedAbility); + RecordAbilityBattle(gActiveBattler, gLastUsedAbility); + BattleScriptExecute(BattleScript_QuickDrawActivation); } return; } diff --git a/src/battle_message.c b/src/battle_message.c index 69463ce69..4bc6330b2 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -692,7 +692,7 @@ static const u8 sText_PkmnsWillPerishIn3Turns[] = _("Both Pokémon will perish\n static const u8 sText_AbilityRaisedStatDrastically[] = _("{B_DEF_ABILITY} raised {B_DEF_NAME_WITH_PREFIX}'s\n{B_BUFF1} drastically!"); static const u8 sText_AsOneEnters[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} has two Abilities!"); static const u8 sText_CuriousMedicineEnters[] = _("{B_EFF_NAME_WITH_PREFIX}'s\nstat changes were reset!"); -static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faster,\nthanks to {B_LAST_ITEM}!"); +static const u8 sText_CanActFaster[] = _("{B_ATK_NAME_WITH_PREFIX} can act faster,\nthanks to {B_BUFF1}!"); static const u8 sText_MicleBerryActivates[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} boosted the accuracy of its\nnext move using {B_LAST_ITEM}!"); static const u8 sText_PkmnShookOffTheTaunt[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} shook off\nthe taunt!"); static const u8 sText_PkmnGotOverItsInfatuation[] = _("{B_SCR_ACTIVE_NAME_WITH_PREFIX} got over\nits infatuation!"); From b447d582cd6f929acc7aaeba3eb313dfe7df3891 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 13 Oct 2021 09:04:03 -0400 Subject: [PATCH 30/85] fix terrain timer decrementing and bg changing with anims disabled --- src/battle_script_commands.c | 31 ++++++++++++++++--------------- src/battle_util.c | 6 +++--- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df..6852dee1e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -4527,12 +4527,13 @@ static void Cmd_endselectionscript(void) static void Cmd_playanimation(void) { const u16* argumentPtr; + u8 animId = gBattlescriptCurrInstr[2]; gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); argumentPtr = T2_READ_PTR(gBattlescriptCurrInstr + 3); #if B_TERRAIN_BG_CHANGE == FALSE - if (gBattlescriptCurrInstr[2] == B_ANIM_RESTORE_BG) + if (animId == B_ANIM_RESTORE_BG) { // workaround for .if not working gBattlescriptCurrInstr += 7; @@ -4540,28 +4541,28 @@ static void Cmd_playanimation(void) } #endif - if (gBattlescriptCurrInstr[2] == B_ANIM_STATS_CHANGE - || gBattlescriptCurrInstr[2] == B_ANIM_SNATCH_MOVE - || gBattlescriptCurrInstr[2] == B_ANIM_MEGA_EVOLUTION - || gBattlescriptCurrInstr[2] == B_ANIM_ILLUSION_OFF - || gBattlescriptCurrInstr[2] == B_ANIM_FORM_CHANGE - || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE) + if (animId == B_ANIM_STATS_CHANGE + || animId == B_ANIM_SNATCH_MOVE + || animId == B_ANIM_MEGA_EVOLUTION + || animId == B_ANIM_ILLUSION_OFF + || animId == B_ANIM_FORM_CHANGE + || animId == B_ANIM_SUBSTITUTE_FADE) { - BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(0, animId, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } - else if (gHitMarker & HITMARKER_NO_ANIMATIONS) + else if (gHitMarker & HITMARKER_NO_ANIMATIONS && animId != B_ANIM_RESTORE_BG) { BattleScriptPush(gBattlescriptCurrInstr + 7); gBattlescriptCurrInstr = BattleScript_Pausex20; } - else if (gBattlescriptCurrInstr[2] == B_ANIM_RAIN_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_SUN_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_SANDSTORM_CONTINUES - || gBattlescriptCurrInstr[2] == B_ANIM_HAIL_CONTINUES) + else if (animId == B_ANIM_RAIN_CONTINUES + || animId == B_ANIM_SUN_CONTINUES + || animId == B_ANIM_SANDSTORM_CONTINUES + || animId == B_ANIM_HAIL_CONTINUES) { - BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(0, animId, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } @@ -4571,7 +4572,7 @@ static void Cmd_playanimation(void) } else { - BtlController_EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); + BtlController_EmitBattleAnimation(0, animId, *argumentPtr); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 7; } diff --git a/src/battle_util.c b/src/battle_util.c index 68e787698..68e52f49d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2234,7 +2234,7 @@ u8 DoFieldEndTurnEffects(void) break; case ENDTURN_ELECTRIC_TERRAIN: if (gFieldStatuses & STATUS_FIELD_ELECTRIC_TERRAIN - && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0)) + && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.electricTerrainTimer == 0)) { gFieldStatuses &= ~(STATUS_FIELD_ELECTRIC_TERRAIN | STATUS_FIELD_TERRAIN_PERMANENT); BattleScriptExecute(BattleScript_ElectricTerrainEnds); @@ -2244,7 +2244,7 @@ u8 DoFieldEndTurnEffects(void) break; case ENDTURN_MISTY_TERRAIN: if (gFieldStatuses & STATUS_FIELD_MISTY_TERRAIN - && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0)) + && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.mistyTerrainTimer == 0)) { gFieldStatuses &= ~(STATUS_FIELD_MISTY_TERRAIN); BattleScriptExecute(BattleScript_MistyTerrainEnds); @@ -2266,7 +2266,7 @@ u8 DoFieldEndTurnEffects(void) break; case ENDTURN_PSYCHIC_TERRAIN: if (gFieldStatuses & STATUS_FIELD_PSYCHIC_TERRAIN - && ((!gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0)) + && (!(gFieldStatuses & STATUS_FIELD_TERRAIN_PERMANENT) && --gFieldTimers.psychicTerrainTimer == 0)) { gFieldStatuses &= ~(STATUS_FIELD_PSYCHIC_TERRAIN); BattleScriptExecute(BattleScript_PsychicTerrainEnds); From 5108d173fc2970dc3fed4514d173eb6e5a693c2b Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 13 Oct 2021 10:11:02 -0400 Subject: [PATCH 31/85] fix protect struct fields being set during ai calcs --- src/battle_ai_main.c | 6 +++++- src/battle_main.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index 2ab6e287e..188b30cee 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -209,7 +209,11 @@ u8 BattleAI_ChooseMoveOrAction(void) ret = ChooseMoveOrAction_Singles(); else ret = ChooseMoveOrAction_Doubles(); - + + // Clear protect structures, some flags may be set during AI calcs + // e.g. pranksterElevated from GetMovePriority + memset(&gProtectStructs[gActiveBattler], 0, sizeof(struct ProtectStruct)); + gCurrentMove = savedCurrentMove; return ret; } diff --git a/src/battle_main.c b/src/battle_main.c index 055ec9bbe..a304defee 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3097,6 +3097,7 @@ void FaintClearSetData(void) gProtectStructs[gActiveBattler].usedThroatChopPreventedMove = 0; gProtectStructs[gActiveBattler].statRaised = 0; gProtectStructs[gActiveBattler].statFell = 0; + gProtectStructs[gActiveBattler].pranksterElevated = 0; gDisableStructs[gActiveBattler].isFirstTurn = 2; From 7f2efb66190eb7351d8fae56b5e436d5d419dcb2 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Wed, 13 Oct 2021 18:39:24 -0400 Subject: [PATCH 32/85] format fixes, fix healing berries from printing message at full hp --- data/battle_scripts_1.s | 8 ++++---- src/battle_util.c | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e842ddc39..cda99c54d 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -380,7 +380,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHit @ EFFECT_SNIPE_SHOT .4byte BattleScript_EffectTripleHit @ EFFECT_TRIPLE_HIT .4byte BattleScript_EffectRecoilHP25 @ EFFECT_RECOIL_HP_25 - .4byte BattleScript_EffectStuffCheeks @ EFFECT_STUFF_CHEEKS + .4byte BattleScript_EffectStuffCheeks @ EFFECT_STUFF_CHEEKS BattleScript_EffectStuffCheeks:: attackcanceler @@ -398,7 +398,7 @@ BattleScript_StuffCheeksEatBerry: setstatchanger STAT_DEF, 2, FALSE statbuffchange MOVE_EFFECT_AFFECTS_USER | STAT_BUFF_ALLOW_PTR, BattleScript_StuffCheeksEnd setgraphicalstatchangevalues - jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_StuffCheeksEnd @ cant raise def + jumpifbyte CMP_EQUAL, cMULTISTRING_CHOOSER, B_MSG_STAT_WONT_INCREASE, BattleScript_StuffCheeksEnd @ cant raise def playanimation BS_ATTACKER, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 printfromtable gStatUpStringIds waitmessage B_WAIT_TIME_LONG @@ -661,8 +661,8 @@ BattleScript_MoveEffectBugBite:: printstring STRINGID_BUGBITE waitmessage B_WAIT_TIME_LONG orword gHitMarker, HITMARKER_NO_ANIMATIONS - setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries - consumeberry BS_ATTACKER, TRUE @ consume the berry, then restore the item from changedItems + setbyte sBERRY_OVERRIDE, TRUE @ override the requirements for eating berries + consumeberry BS_ATTACKER, TRUE @ consume the berry, then restore the item from changedItems bicword gHitMarker, HITMARKER_NO_ANIMATIONS setbyte sBERRY_OVERRIDE, FALSE return diff --git a/src/battle_util.c b/src/battle_util.c index 6ecc755f6..88350b7c4 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5862,7 +5862,8 @@ u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 exec static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) { - if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) + if (HasEnoughHpToEatBerry(battlerId, 2, itemId) + && !(gBattleScripting.overrideBerryRequirements && gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)) { if (percentHeal) gBattleMoveDamage = (gBattleMons[battlerId].maxHP * GetBattlerHoldEffectParam(battlerId) / 100) * -1; From bb8d0e3d6b87d02d93e4bcbad10518e34f936b20 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Thu, 14 Oct 2021 16:18:11 +1300 Subject: [PATCH 33/85] Fix Battle Bond Battle Bond Greninja transforms only after a KO, and doesn't revert when switched out. --- asm/macros/battle_script.inc | 4 ++++ data/battle_scripts_1.s | 1 + include/constants/battle_script_commands.h | 1 + src/battle_script_commands.c | 13 +++++++++++++ src/battle_util.c | 18 +++--------------- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 4d8fe0365..7ed108bde 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1825,6 +1825,10 @@ various BS_ATTACKER, VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER .endm + .macro tryactivatebattlebond battler:req + various \battler, VARIOUS_TRY_ACTIVATE_BATTLE_BOND + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e1fb47930..9ec90e3df 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -5288,6 +5288,7 @@ BattleScript_FaintTarget:: tryactivatemoxie BS_ATTACKER @ and chilling neigh, as one ice rider tryactivatebeastboost BS_ATTACKER tryactivategrimneigh BS_ATTACKER @ and as one shadow rider + tryactivatebattlebond BS_ATTACKER trytrainerslidefirstdownmsg BS_TARGET return diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index d61eabbf8..29236c7b0 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -185,6 +185,7 @@ #define VARIOUS_REMOVE_TERRAIN 113 #define VARIOUS_JUMP_IF_PRANKSTER_BLOCKED 114 #define VARIOUS_TRY_TO_CLEAR_PRIMAL_WEATHER 115 +#define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 116 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2c017b2df..472487e09 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8822,6 +8822,19 @@ static void Cmd_various(void) } break; } + case VARIOUS_TRY_ACTIVATE_BATTLE_BOND: + if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND + && HasAttackerFaintedTarget() + && CalculateEnemyPartyCount() > 1) + { + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species); + gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; + gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_BattleBondActivatesOnMoveEndAttacker; + return; + } + break; } gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index 68e787698..e4b8f9cf3 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -5147,18 +5147,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move effect++; } break; - case ABILITY_BATTLE_BOND: - if (gBattleMons[gBattlerAttacker].species == SPECIES_GRENINJA_BATTLE_BOND - && gBattleResults.opponentFaintCounter != 0 - && CalculateEnemyPartyCount() > 1) - { - PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species); - gBattleStruct->changedSpecies[gBattlerPartyIndexes[gBattlerAttacker]] = gBattleMons[gBattlerAttacker].species; - gBattleMons[gBattlerAttacker].species = SPECIES_GRENINJA_ASH; - BattleScriptPushCursor(); - gBattlescriptCurrInstr = BattleScript_BattleBondActivatesOnMoveEndAttacker; - } - break; } break; case ABILITYEFFECT_MOVE_END_OTHER: // Abilities that activate on *another* battler's moveend: Dancer, Soul-Heart, Receiver, Symbiosis @@ -8846,6 +8834,7 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut) static const u16 species[][2] = // changed form id, default form id { {SPECIES_MIMIKYU_BUSTED, SPECIES_MIMIKYU}, + {SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND}, {SPECIES_AEGISLASH_BLADE, SPECIES_AEGISLASH}, {SPECIES_DARMANITAN_ZEN_MODE, SPECIES_DARMANITAN}, {SPECIES_MINIOR, SPECIES_MINIOR_CORE_RED}, @@ -8858,11 +8847,10 @@ void UndoFormChange(u32 monId, u32 side, bool32 isSwitchingOut) {SPECIES_WISHIWASHI_SCHOOL, SPECIES_WISHIWASHI}, {SPECIES_CRAMORANT_GORGING, SPECIES_CRAMORANT}, {SPECIES_CRAMORANT_GULPING, SPECIES_CRAMORANT}, - {SPECIES_GRENINJA_ASH, SPECIES_GRENINJA_BATTLE_BOND}, }; - if (isSwitchingOut) // Don't revert Mimikyu Busted when switching out - i = 1; + if (isSwitchingOut) // Don't revert Mimikyu Busted or Ash-Greninja when switching out + i = 2; else i = 0; From 85dd7ff63c40778538ece6d465f42a28a232b252 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Thu, 14 Oct 2021 16:40:18 +1300 Subject: [PATCH 34/85] Fix Storm Drain/Dive bug If Storm Drain is triggered by dive it should clear the attacker's semi-invulnerable status. --- 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 616fe21f1..c70bddcd4 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -7525,6 +7525,7 @@ BattleScript_MoveStatDrain:: waitanimation printstring STRINGID_TARGETABILITYSTATRAISE waitmessage B_WAIT_TIME_LONG + clearsemiinvulnerablebit tryfaintmon BS_ATTACKER, FALSE, NULL goto BattleScript_MoveEnd From 85ce72a4d07cbf1f4339d03e2e774938046e98fc Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Thu, 14 Oct 2021 10:47:39 -0400 Subject: [PATCH 35/85] add shell smash anim --- data/battle_anim_scripts.s | 25 +++++++++++++++++++++++++ include/battle_anim.h | 2 ++ src/battle_anim_new.c | 34 ++++++++++++++++++++++++++++++++++ src/battle_anim_rock.c | 9 ++++----- 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/data/battle_anim_scripts.s b/data/battle_anim_scripts.s index 4063885e0..794cc2c0c 100644 --- a/data/battle_anim_scripts.s +++ b/data/battle_anim_scripts.s @@ -5374,6 +5374,31 @@ ScaldHitSplats: return Move_SHELL_SMASH: + loadspritegfx ANIM_TAG_SHELL_RIGHT + loadspritegfx ANIM_TAG_SHELL_LEFT + loadspritegfx ANIM_TAG_IMPACT + loadspritegfx ANIM_TAG_ROCKS + loadspritegfx ANIM_TAG_HANDS_AND_FEET + playsewithpan SE_M_SCRATCH, SOUND_PAN_ATTACKER + createsprite gShellSmashRightShellSpriteTemplate, ANIM_ATTACKER, 2, 0xffd7, 0x0, 0x2, 0x333, 0x0, 0xa + createsprite gShellSmashLeftShellSpriteTemplate, ANIM_ATTACKER, 2, 0x20, 0x0, 0x6, 0xfccd, 0x0, 0xa + delay 10 + createsprite gBasicHitSplatSpriteTemplate, ANIM_ATTACKER, 2, 0x0, 0x0, 0x1, 0x1 + createsprite gFistFootSpriteTemplate, ANIM_ATTACKER, 3, 0x0, 0x0, 0x8, 0x1, 0x0 + playsewithpan SE_M_ICY_WIND, SOUND_PAN_TARGET + createvisualtask AnimTask_ShakeMon, 2, 1, 3, 0, 5, 1 + waitforvisualfinish + playsewithpan SE_M_BUBBLE, SOUND_PAN_TARGET + createsprite gShellSmashPurpleRocksSpriteTemplate, ANIM_ATTACKER, 2, 0x0, 0x0, 0x14, 0x18, 0xe, 0x2 + createsprite gShellSmashPurpleRocksSpriteTemplate, ANIM_ATTACKER, 2, 0x5, 0x0, 0xffec, 0x18, 0xe, 0x1 + createsprite gShellSmashPurpleRocksSpriteTemplate, ANIM_ATTACKER, 2, 0x0, 0x5, 0x14, 0xffe8, 0xe, 0x2 + createsprite gShellSmashPurpleRocksSpriteTemplate, ANIM_ATTACKER, 2, 0xfffb, 0x0, 0xffec, 0xffe8, 0xe, 0x2 + createsprite gShellSmashPurpleRocksSpriteTemplate, ANIM_ATTACKER, 2, 0x0, 0xfffb, 0x1e, 0x12, 0x8, 0x2 + createsprite gShellSmashPurpleRocksSpriteTemplate, ANIM_ATTACKER, 2, 0x0, 0x0, 0x1e, 0xffee, 0x8, 0x2 + createsprite gShellSmashPurpleRocksSpriteTemplate, ANIM_ATTACKER, 2, 0x0, 0x0, 0xffe2, 0x12, 0x8, 0x2 + createsprite gShellSmashPurpleRocksSpriteTemplate, ANIM_ATTACKER, 2, 0x0, 0x0, 0xffe2, 0xffee, 0x8, 0x2 + createvisualtask AnimTask_ShakeMon, 2, 1, 0, 3, 7, 1 + waitforvisualfinish end Move_HEAL_PULSE: diff --git a/include/battle_anim.h b/include/battle_anim.h index 9bc51facb..ff388c714 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -442,6 +442,7 @@ extern const union AffineAnimCmd *const gAffineAnims_SpinningHandOrFoot[]; extern const union AnimCmd *const gAnims_RevengeBigScratch[]; // battle_anim_rock.c +extern const union AnimCmd *const gAnims_FlyingRock[]; extern const union AffineAnimCmd *const gAffineAnims_Whirlpool[]; extern const union AffineAnimCmd *const gAffineAnims_BasicRock[]; void AnimParticleInVortex(struct Sprite *sprite); @@ -449,6 +450,7 @@ void AnimFallingRock(struct Sprite *sprite); void AnimRaiseSprite(struct Sprite *sprite); void AnimFallingRock_Step(struct Sprite *sprite); void AnimFlyingSandCrescent(struct Sprite *sprite); +void AnimRockFragment(struct Sprite *); // battle_anim_dark.c void AnimClawSlash(struct Sprite *sprite); diff --git a/src/battle_anim_new.c b/src/battle_anim_new.c index 0c452c236..55a617bab 100644 --- a/src/battle_anim_new.c +++ b/src/battle_anim_new.c @@ -93,6 +93,40 @@ const struct SpriteTemplate gPowerTrickSpriteTemplate = //// GEN 5 +//shell smash +const struct SpriteTemplate gShellSmashLeftShellSpriteTemplate = +{ + .tileTag = ANIM_TAG_SHELL_RIGHT, + .paletteTag = ANIM_TAG_SHELL_RIGHT, + .oam = &gOamData_AffineNormal_ObjBlend_64x64, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gAffineAnims_Bite, + .callback = AnimBite +}; + +const struct SpriteTemplate gShellSmashRightShellSpriteTemplate = +{ + .tileTag = ANIM_TAG_SHELL_LEFT, + .paletteTag = ANIM_TAG_SHELL_LEFT, + .oam = &gOamData_AffineNormal_ObjBlend_64x64, + .anims = gDummySpriteAnimTable, + .images = NULL, + .affineAnims = gAffineAnims_Bite, + .callback = AnimBite +}; + +const struct SpriteTemplate gShellSmashPurpleRocksSpriteTemplate = +{ + .tileTag = ANIM_TAG_ROCKS, + .paletteTag = ANIM_TAG_SHELL_RIGHT, + .oam = &gOamData_AffineOff_ObjNormal_32x32, + .anims = gAnims_FlyingRock, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = AnimRockFragment +}; + //wide guard const struct SpriteTemplate gWideGuardBlueConversionTemplate = { diff --git a/src/battle_anim_rock.c b/src/battle_anim_rock.c index da2d9b645..afbacc633 100644 --- a/src/battle_anim_rock.c +++ b/src/battle_anim_rock.c @@ -9,7 +9,6 @@ #include "constants/rgb.h" #include "constants/songs.h" -static void AnimRockFragment(struct Sprite *); static void AnimTask_Rollout_Step(u8 taskId); static void AnimRolloutParticle(struct Sprite *); static void AnimRockTomb(struct Sprite *); @@ -43,7 +42,7 @@ static const union AnimCmd sAnim_FlyingRock_2[] = ANIMCMD_END, }; -static const union AnimCmd *const sAnims_FlyingRock[] = +const union AnimCmd *const gAnims_FlyingRock[] = { sAnim_FlyingRock_0, sAnim_FlyingRock_1, @@ -55,7 +54,7 @@ const struct SpriteTemplate gFallingRockSpriteTemplate = .tileTag = ANIM_TAG_ROCKS, .paletteTag = ANIM_TAG_ROCKS, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_FlyingRock, + .anims = gAnims_FlyingRock, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimFallingRock, @@ -66,7 +65,7 @@ const struct SpriteTemplate gRockFragmentSpriteTemplate = .tileTag = ANIM_TAG_ROCKS, .paletteTag = ANIM_TAG_ROCKS, .oam = &gOamData_AffineOff_ObjNormal_32x32, - .anims = sAnims_FlyingRock, + .anims = gAnims_FlyingRock, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimRockFragment, @@ -430,7 +429,7 @@ void AnimFallingRock_Step(struct Sprite *sprite) } // Animates the rock particles that are shown on the impact for Rock Blast / Rock Smash -static void AnimRockFragment(struct Sprite *sprite) +void AnimRockFragment(struct Sprite *sprite) { StartSpriteAnim(sprite, gBattleAnimArgs[5]); AnimateSprite(sprite); From 1f97198267a4af39788246db08f583df0fc85682 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 15 Oct 2021 05:02:14 -0300 Subject: [PATCH 36/85] Oops, I forgot to take the opponent's side into account --- include/battle.h | 3 ++- src/battle_main.c | 6 ++++-- src/battle_script_commands.c | 3 ++- src/battle_util.c | 7 +++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/battle.h b/include/battle.h index aaecb9ea1..7958c40f5 100644 --- a/include/battle.h +++ b/include/battle.h @@ -908,6 +908,7 @@ extern u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; extern u16 gLastThrownBall; -extern bool8 gCanRetaliate; +extern bool8 gCanPlayerRetaliate; +extern bool8 gCanOpponentRetaliate; #endif // GUARD_BATTLE_H diff --git a/src/battle_main.c b/src/battle_main.c index 7d4ae76dd..ffb33da10 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -231,7 +231,8 @@ EWRAM_DATA struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA bool8 gHasFetchedBall = FALSE; EWRAM_DATA u8 gLastUsedBall = 0; EWRAM_DATA u16 gLastThrownBall = 0; -EWRAM_DATA bool8 gCanRetaliate = FALSE; +EWRAM_DATA bool8 gCanPlayerRetaliate = FALSE; +EWRAM_DATA bool8 gCanOpponentRetaliate = FALSE; // IWRAM common vars void (*gPreBattleCallback1)(void); @@ -2877,7 +2878,8 @@ static void BattleStartClearSetData(void) gHasFetchedBall = FALSE; gLastUsedBall = 0; - gCanRetaliate = FALSE; + gCanPlayerRetaliate = FALSE; + gCanOpponentRetaliate = FALSE; gBattlerAttacker = 0; gBattlerTarget = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b3ac59863..132a434cb 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3499,13 +3499,14 @@ static void Cmd_tryfaintmon(void) if (gBattleResults.playerFaintCounter < 0xFF) gBattleResults.playerFaintCounter++; AdjustFriendshipOnBattleFaint(gActiveBattler); - gCanRetaliate = TRUE; + gCanPlayerRetaliate = TRUE; } else { if (gBattleResults.opponentFaintCounter < 0xFF) gBattleResults.opponentFaintCounter++; gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL); + gCanOpponentRetaliate = TRUE; } if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattlerAttacker].hp != 0) { diff --git a/src/battle_util.c b/src/battle_util.c index d588d5b08..689a846d6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7933,10 +7933,13 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); break; case EFFECT_RETALIATE: - if (gCanRetaliate) + if (gCanPlayerRetaliate || gCanOpponentRetaliate) { MulModifier(&modifier, UQ_4_12(2.0)); - gCanRetaliate = FALSE; + if (gCanPlayerRetaliate) + gCanPlayerRetaliate = FALSE; + else if (gCanOpponentRetaliate) + gCanOpponentRetaliate = FALSE; } break; case EFFECT_SOLARBEAM: From 3a25bce185635b9887de6eb91a9803b8e9dbb1aa Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 15 Oct 2021 06:00:24 -0300 Subject: [PATCH 37/85] Turned Retaliate's effect into a side status --- include/battle.h | 2 -- include/constants/battle.h | 1 + src/battle_main.c | 5 ----- src/battle_script_commands.c | 4 ++-- src/battle_util.c | 8 +++----- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/battle.h b/include/battle.h index 7958c40f5..826a0929e 100644 --- a/include/battle.h +++ b/include/battle.h @@ -908,7 +908,5 @@ extern u8 gBattleControllerData[MAX_BATTLERS_COUNT]; extern bool8 gHasFetchedBall; extern u8 gLastUsedBall; extern u16 gLastThrownBall; -extern bool8 gCanPlayerRetaliate; -extern bool8 gCanOpponentRetaliate; #endif // GUARD_BATTLE_H diff --git a/include/constants/battle.h b/include/constants/battle.h index a59ea2f1a..39994a049 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -220,6 +220,7 @@ #define SIDE_STATUS_WIDE_GUARD (1 << 19) #define SIDE_STATUS_CRAFTY_SHIELD (1 << 20) #define SIDE_STATUS_MAT_BLOCK (1 << 21) +#define SIDE_STATUS_RETALIATE (1 << 22) #define SIDE_STATUS_HAZARDS_ANY (SIDE_STATUS_SPIKES | SIDE_STATUS_STICKY_WEB | SIDE_STATUS_TOXIC_SPIKES | SIDE_STATUS_STEALTH_ROCK) #define SIDE_STATUS_SCREEN_ANY (SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL) diff --git a/src/battle_main.c b/src/battle_main.c index ffb33da10..055ec9bbe 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -231,8 +231,6 @@ EWRAM_DATA struct TotemBoost gTotemBoosts[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA bool8 gHasFetchedBall = FALSE; EWRAM_DATA u8 gLastUsedBall = 0; EWRAM_DATA u16 gLastThrownBall = 0; -EWRAM_DATA bool8 gCanPlayerRetaliate = FALSE; -EWRAM_DATA bool8 gCanOpponentRetaliate = FALSE; // IWRAM common vars void (*gPreBattleCallback1)(void); @@ -2878,9 +2876,6 @@ static void BattleStartClearSetData(void) gHasFetchedBall = FALSE; gLastUsedBall = 0; - gCanPlayerRetaliate = FALSE; - gCanOpponentRetaliate = FALSE; - gBattlerAttacker = 0; gBattlerTarget = 0; gBattleWeather = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 132a434cb..b301047aa 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3499,14 +3499,14 @@ static void Cmd_tryfaintmon(void) if (gBattleResults.playerFaintCounter < 0xFF) gBattleResults.playerFaintCounter++; AdjustFriendshipOnBattleFaint(gActiveBattler); - gCanPlayerRetaliate = TRUE; + gSideStatuses[0] |= SIDE_STATUS_RETALIATE; } else { if (gBattleResults.opponentFaintCounter < 0xFF) gBattleResults.opponentFaintCounter++; gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL); - gCanOpponentRetaliate = TRUE; + gSideStatuses[1] |= SIDE_STATUS_RETALIATE; } if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattlerAttacker].hp != 0) { diff --git a/src/battle_util.c b/src/battle_util.c index 689a846d6..e3bec3508 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7681,6 +7681,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe u16 basePower = CalcMoveBasePower(move, battlerAtk, battlerDef); u16 holdEffectModifier; u16 modifier = UQ_4_12(1.0); + u32 atkSide = GET_BATTLER_SIDE(battlerAtk); // attacker's abilities switch (GetBattlerAbility(battlerAtk)) @@ -7933,13 +7934,10 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); break; case EFFECT_RETALIATE: - if (gCanPlayerRetaliate || gCanOpponentRetaliate) + if (gSideStatuses[atkSide] & SIDE_STATUS_RETALIATE) { MulModifier(&modifier, UQ_4_12(2.0)); - if (gCanPlayerRetaliate) - gCanPlayerRetaliate = FALSE; - else if (gCanOpponentRetaliate) - gCanOpponentRetaliate = FALSE; + gSideStatuses[atkSide] &= ~SIDE_STATUS_RETALIATE; } break; case EFFECT_SOLARBEAM: From 2bf8022673a7754135097215bc16bebcf6aa0d3b Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 15 Oct 2021 07:09:27 -0300 Subject: [PATCH 38/85] Changed how SIDE_STATUS_RETALIATE is cleared --- src/battle_main.c | 1 + src/battle_util.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index 055ec9bbe..f3f86d58f 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3583,6 +3583,7 @@ static void HandleEndTurn_ContinueBattle(void) gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); if ((gBattleMons[i].status1 & STATUS1_SLEEP) && (gBattleMons[i].status2 & STATUS2_MULTIPLETURNS)) CancelMultiTurnMoves(i); + gSideStatuses[GET_BATTLER_SIDE(i)] &= ~SIDE_STATUS_RETALIATE; } gBattleStruct->turnEffectsTracker = 0; gBattleStruct->turnEffectsBattlerId = 0; diff --git a/src/battle_util.c b/src/battle_util.c index e3bec3508..3bf34afd5 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7935,10 +7935,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe break; case EFFECT_RETALIATE: if (gSideStatuses[atkSide] & SIDE_STATUS_RETALIATE) - { MulModifier(&modifier, UQ_4_12(2.0)); - gSideStatuses[atkSide] &= ~SIDE_STATUS_RETALIATE; - } break; case EFFECT_SOLARBEAM: if (WEATHER_HAS_EFFECT && gBattleWeather & (WEATHER_HAIL_ANY | WEATHER_SANDSTORM_ANY | WEATHER_RAIN_ANY)) From 883a2498364d1a8d40989ea5642b2ea24f81f38c Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 15 Oct 2021 09:20:32 -0400 Subject: [PATCH 39/85] config for catching semi-invulnerable mons --- include/constants/battle_config.h | 1 + src/item_use.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index bce49719e..eb9d9639e 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -178,6 +178,7 @@ #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_5 // In Gen5+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) // Animation Settings #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/item_use.c b/src/item_use.c index 63854a1ac..93604efef 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -947,11 +947,18 @@ u32 CanThrowBall(void) { return 2; // No room for mon } + #if B_SEMI_INVULNERABLE_CATCH >= GEN_5 + else if (gStatuses3[B_POSITION_OPPONENT_LEFT] & STATUS3_SEMI_INVULNERABLE) + { + return 3; // in semi-invulnerable state + } + #endif return 0; // usable } -static const u8 sText_CantThrowPokeBall_TwoMons[] = _("Cannot throw a ball!\nThere are two pokemon out there!\p"); +static const u8 sText_CantThrowPokeBall_TwoMons[] = _("Cannot throw a ball!\nThere are two Pokémon out there!\p"); +static const u8 sText_CantThrowPokeBall_SemiInvulnerable[] = _("Cannot throw a ball!\nThere's no Pokémon in sight!\p"); void ItemUseInBattle_PokeBall(u8 taskId) { switch (CanThrowBall()) @@ -976,6 +983,14 @@ void ItemUseInBattle_PokeBall(u8 taskId) else DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, Task_CloseBattlePyramidBagMessage); break; + #if B_SEMI_INVULNERABLE_CATCH >= GEN_5 + case 3: // Semi-Invulnerable + if (!InBattlePyramid()) + DisplayItemMessage(taskId, 1, sText_CantThrowPokeBall_SemiInvulnerable, CloseItemMessage); + else + DisplayItemMessageInBattlePyramid(taskId, sText_CantThrowPokeBall_SemiInvulnerable, Task_CloseBattlePyramidBagMessage); + break; + #endif } } From ef19c8c415b0f583bc686f131a58fba169c58fe6 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 15 Oct 2021 09:22:50 -0400 Subject: [PATCH 40/85] fix gen define --- include/constants/battle_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index eb9d9639e..62c8705e5 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -178,7 +178,7 @@ #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_5 // In Gen5+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) +#define B_SEMI_INVULNERABLE_CATCH GEN_4 // In Gen5+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) // Animation Settings #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. From c077091dbf917a17f469168c86a84c012a88d2ef Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 15 Oct 2021 14:57:26 -0400 Subject: [PATCH 41/85] small fixes, check GetCatchingBattler's semi-invulnerability --- include/constants/battle_config.h | 2 +- src/item_use.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 62c8705e5..fc9bc9f4e 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -178,7 +178,7 @@ #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_4 // In Gen5+, you cannot throw a ball against a Pokemon that is in a semi-invulnerable state (dig/fly/etc) +#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) // Animation Settings #define B_NEW_SWORD_PARTICLE FALSE // If set to TRUE, it updates Swords Dance's particle. diff --git a/src/item_use.c b/src/item_use.c index 93604efef..9a1fd2478 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -947,8 +947,8 @@ u32 CanThrowBall(void) { return 2; // No room for mon } - #if B_SEMI_INVULNERABLE_CATCH >= GEN_5 - else if (gStatuses3[B_POSITION_OPPONENT_LEFT] & STATUS3_SEMI_INVULNERABLE) + #if B_SEMI_INVULNERABLE_CATCH >= GEN_4 + else if (gStatuses3[GetCatchingBattler()] & STATUS3_SEMI_INVULNERABLE) { return 3; // in semi-invulnerable state } @@ -983,7 +983,7 @@ void ItemUseInBattle_PokeBall(u8 taskId) else DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, Task_CloseBattlePyramidBagMessage); break; - #if B_SEMI_INVULNERABLE_CATCH >= GEN_5 + #if B_SEMI_INVULNERABLE_CATCH >= GEN_4 case 3: // Semi-Invulnerable if (!InBattlePyramid()) DisplayItemMessage(taskId, 1, sText_CantThrowPokeBall_SemiInvulnerable, CloseItemMessage); From 1f176242aad724148a507c6adc40b72013ee5034 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Fri, 15 Oct 2021 16:06:50 -0400 Subject: [PATCH 42/85] add missing func definition --- include/battle_script_commands.h | 1 + src/battle_script_commands.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/battle_script_commands.h b/include/battle_script_commands.h index dec1596f2..b55ac1391 100644 --- a/include/battle_script_commands.h +++ b/include/battle_script_commands.h @@ -37,6 +37,7 @@ bool32 TryResetBattlerStatChanges(u8 battler); bool32 CanCamouflage(u8 battlerId); u16 GetNaturePowerMove(void); void StealTargetItem(u8 battlerStealer, u8 battlerItem); +u8 GetCatchingBattler(void); extern void (* const gBattleScriptingCommandsTable[])(void); extern const u8 gBattlePalaceNatureToMoveGroupLikelihood[NUM_NATURES][4]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 29614e09b..2c0614ada 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -12565,7 +12565,7 @@ static void Cmd_removelightscreenreflect(void) // brick break gBattlescriptCurrInstr++; } -static u8 GetCatchingBattler(void) +u8 GetCatchingBattler(void) { if (IsBattlerAlive(GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT))) return GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); From b5293cc3e2b7c38364b9bc7b39ed7e4bc6cb2bec Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sat, 16 Oct 2021 17:04:36 +1300 Subject: [PATCH 43/85] Fix multi target moves Only run CANCELLER_PRANKSTER when moving to the next target of a multi target move. If more cancellers are needed they can be added/moved after CANCELLER_PRANKSTER. --- include/battle_util.h | 27 +++++++++++++++++++++++++++ src/battle_script_commands.c | 2 +- src/battle_util.c | 27 --------------------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 7d1b99f34..3f4f4bbc7 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -34,6 +34,33 @@ #define ITEMEFFECT_LIFEORB_SHELLBELL 0x7 #define ITEMEFFECT_BATTLER_MOVE_END 0x8 // move end effects for just the battler, not whole field +// Move cancellers. Note that anything from CANCELLER_PRANKSTER onwards is +// called on each target of a multi target move, so any new cancellers should +// probably be added before CANCELLER_PRANKSTER. +#define CANCELLER_FLAGS 0 +#define CANCELLER_ASLEEP 1 +#define CANCELLER_FROZEN 2 +#define CANCELLER_TRUANT 3 +#define CANCELLER_RECHARGE 4 +#define CANCELLER_FLINCH 5 +#define CANCELLER_DISABLED 6 +#define CANCELLER_GRAVITY 7 +#define CANCELLER_HEAL_BLOCKED 8 +#define CANCELLER_TAUNTED 9 +#define CANCELLER_IMPRISONED 10 +#define CANCELLER_CONFUSED 11 +#define CANCELLER_PARALYSED 12 +#define CANCELLER_IN_LOVE 13 +#define CANCELLER_BIDE 14 +#define CANCELLER_THAW 15 +#define CANCELLER_POWDER_MOVE 16 +#define CANCELLER_POWDER_STATUS 17 +#define CANCELLER_THROAT_CHOP 18 +#define CANCELLER_PRANKSTER 19 +#define CANCELLER_END 20 +#define CANCELLER_PSYCHIC_TERRAIN 21 +#define CANCELLER_END2 22 + #define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK))) #define IS_WHOLE_SIDE_ALIVE(battler)((IsBattlerAlive(battler) && IsBattlerAlive(BATTLE_PARTNER(battler)))) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 29614e09b..ea169f52d 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5157,7 +5157,7 @@ static void Cmd_moveend(void) MoveValuesCleanUp(); gBattleScripting.moveEffect = gBattleScripting.savedMoveEffect; BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); - gBattleStruct->atkCancellerTracker = 0; // Run all cancellers on next target + gBattleStruct->atkCancellerTracker = CANCELLER_PRANKSTER; // Run Prankster canceller on next target, skip the earlier ones gBattlescriptCurrInstr = BattleScript_FlushMessageBox; return; } diff --git a/src/battle_util.c b/src/battle_util.c index 18a1bfb47..1177c316e 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3102,33 +3102,6 @@ void TryClearRageAndFuryCutter(void) } } -enum -{ - CANCELLER_FLAGS, - CANCELLER_ASLEEP, - CANCELLER_FROZEN, - CANCELLER_TRUANT, - CANCELLER_RECHARGE, - CANCELLER_FLINCH, - CANCELLER_DISABLED, - CANCELLER_GRAVITY, - CANCELLER_HEAL_BLOCKED, - CANCELLER_TAUNTED, - CANCELLER_IMPRISONED, - CANCELLER_CONFUSED, - CANCELLER_PARALYSED, - CANCELLER_IN_LOVE, - CANCELLER_BIDE, - CANCELLER_THAW, - CANCELLER_POWDER_MOVE, - CANCELLER_POWDER_STATUS, - CANCELLER_THROAT_CHOP, - CANCELLER_PRANKSTER, - CANCELLER_END, - CANCELLER_PSYCHIC_TERRAIN, - CANCELLER_END2, -}; - u8 AtkCanceller_UnableToUseMove(void) { u8 effect = 0; From 791f4164a22f24d4fffa04e59424c0a6714ef0bf Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Sat, 16 Oct 2021 17:31:27 +1300 Subject: [PATCH 44/85] Fix PP being checked when HITMARKER_NO_PPDEDUCT is set This fixes multi target moves and seems like it should be done anyway, --- src/battle_script_commands.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ea169f52d..8bd082529 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -1392,7 +1392,8 @@ static void Cmd_attackcanceler(void) return; if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBattlerTarget, 0, 0, 0)) return; - if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & (HITMARKER_x800000 | HITMARKER_NO_ATTACKSTRING)) + if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE + && !(gHitMarker & (HITMARKER_x800000 | HITMARKER_NO_ATTACKSTRING | HITMARKER_NO_PPDEDUCT)) && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) { gBattlescriptCurrInstr = BattleScript_NoPPForMove; From 3b6ceb1dfafc3a0d7fb57e4f332a92395b0ad970 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 16 Oct 2021 05:41:50 -0300 Subject: [PATCH 45/85] Turned Retaliate into a side timer --- include/battle.h | 1 + include/constants/battle.h | 1 - src/battle_main.c | 1 - src/battle_script_commands.c | 4 ++-- src/battle_util.c | 9 ++++++++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/battle.h b/include/battle.h index 826a0929e..49881bacf 100644 --- a/include/battle.h +++ b/include/battle.h @@ -210,6 +210,7 @@ struct SideTimer u8 tailwindBattlerId; u8 luckyChantTimer; u8 luckyChantBattlerId; + u8 retaliateTimer; }; struct FieldTimer diff --git a/include/constants/battle.h b/include/constants/battle.h index 39994a049..a59ea2f1a 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -220,7 +220,6 @@ #define SIDE_STATUS_WIDE_GUARD (1 << 19) #define SIDE_STATUS_CRAFTY_SHIELD (1 << 20) #define SIDE_STATUS_MAT_BLOCK (1 << 21) -#define SIDE_STATUS_RETALIATE (1 << 22) #define SIDE_STATUS_HAZARDS_ANY (SIDE_STATUS_SPIKES | SIDE_STATUS_STICKY_WEB | SIDE_STATUS_TOXIC_SPIKES | SIDE_STATUS_STEALTH_ROCK) #define SIDE_STATUS_SCREEN_ANY (SIDE_STATUS_REFLECT | SIDE_STATUS_LIGHTSCREEN | SIDE_STATUS_AURORA_VEIL) diff --git a/src/battle_main.c b/src/battle_main.c index f3f86d58f..055ec9bbe 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3583,7 +3583,6 @@ static void HandleEndTurn_ContinueBattle(void) gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); if ((gBattleMons[i].status1 & STATUS1_SLEEP) && (gBattleMons[i].status2 & STATUS2_MULTIPLETURNS)) CancelMultiTurnMoves(i); - gSideStatuses[GET_BATTLER_SIDE(i)] &= ~SIDE_STATUS_RETALIATE; } gBattleStruct->turnEffectsTracker = 0; gBattleStruct->turnEffectsBattlerId = 0; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index b301047aa..8813f2029 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3499,14 +3499,14 @@ static void Cmd_tryfaintmon(void) if (gBattleResults.playerFaintCounter < 0xFF) gBattleResults.playerFaintCounter++; AdjustFriendshipOnBattleFaint(gActiveBattler); - gSideStatuses[0] |= SIDE_STATUS_RETALIATE; + gSideTimers[0].retaliateTimer = 2; } else { if (gBattleResults.opponentFaintCounter < 0xFF) gBattleResults.opponentFaintCounter++; gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL); - gSideStatuses[1] |= SIDE_STATUS_RETALIATE; + gSideTimers[1].retaliateTimer = 2; } if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattlerAttacker].hp != 0) { diff --git a/src/battle_util.c b/src/battle_util.c index 3bf34afd5..6b43709da 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1881,6 +1881,7 @@ enum ENDTURN_PSYCHIC_TERRAIN, ENDTURN_ION_DELUGE, ENDTURN_FAIRY_LOCK, + ENDTURN_RETALIATE, ENDTURN_FIELD_COUNT, }; @@ -2312,6 +2313,12 @@ u8 DoFieldEndTurnEffects(void) } gBattleStruct->turnCountersTracker++; break; + case ENDTURN_RETALIATE: + gActiveBattler = gBattlerByTurnOrder[gBattleStruct->turnSideTracker]; + if (gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].retaliateTimer > 0) + gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].retaliateTimer--; + gBattleStruct->turnCountersTracker++; + break; case ENDTURN_FIELD_COUNT: effect++; break; @@ -7934,7 +7941,7 @@ static u32 CalcMoveBasePowerAfterModifiers(u16 move, u8 battlerAtk, u8 battlerDe MulModifier(&modifier, UQ_4_12(2.0)); break; case EFFECT_RETALIATE: - if (gSideStatuses[atkSide] & SIDE_STATUS_RETALIATE) + if (gSideTimers[atkSide].retaliateTimer == 1) MulModifier(&modifier, UQ_4_12(2.0)); break; case EFFECT_SOLARBEAM: From c2e25272b0a74402803e62383877faa5a3018489 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sat, 16 Oct 2021 07:02:26 -0300 Subject: [PATCH 46/85] Added Grav Apple's power boost --- src/battle_util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index e01c89fca..2b72fc3bc 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7702,6 +7702,10 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) if (gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH) basePower = 20; break; + case MOVE_GRAV_APPLE: + if (gFieldStatuses & STATUS_FIELD_GRAVITY) + basePower = 120; + break; } if (basePower == 0) From 611076c24def2e984c54fdd66824361184af846b Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 16 Oct 2021 10:15:15 -0400 Subject: [PATCH 47/85] move prankster to ABILITYEFFECT_MOVES_BLOCK --- src/battle_script_commands.c | 1 - src/battle_util.c | 23 ++++++++++------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index bfd4cc21a..818fd246e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -6642,7 +6642,6 @@ static void Cmd_jumptocalledmove(void) else gChosenMove = gCurrentMove = gCalledMove; - gBattleStruct->atkCancellerTracker = 0; gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } diff --git a/src/battle_util.c b/src/battle_util.c index e01c89fca..f3e1eb9aa 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3130,7 +3130,6 @@ enum CANCELLER_POWDER_MOVE, CANCELLER_POWDER_STATUS, CANCELLER_THROAT_CHOP, - CANCELLER_PRANKSTER, CANCELLER_END, CANCELLER_PSYCHIC_TERRAIN, CANCELLER_END2, @@ -3459,18 +3458,6 @@ u8 AtkCanceller_UnableToUseMove(void) } gBattleStruct->atkCancellerTracker++; break; - case CANCELLER_PRANKSTER: - if (BlocksPrankster(gCurrentMove, gBattlerAttacker, gBattlerTarget, TRUE) - && !(IS_MOVE_STATUS(gCurrentMove) && GetBattlerAbility(gBattlerTarget) == ABILITY_MAGIC_BOUNCE)) - { - if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(gBattleMoves[gCurrentMove].target & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) - CancelMultiTurnMoves(gBattlerAttacker); // Don't cancel moves that can hit two targets bc one target might not be protected - gBattleScripting.battler = gBattlerAbility = gBattlerTarget; - gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; - effect = 1; - } - gBattleStruct->atkCancellerTracker++; - break; case CANCELLER_END: break; } @@ -4572,6 +4559,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move gBattlescriptCurrInstr = BattleScript_DazzlingProtected; effect = 1; } + else if (BlocksPrankster(move, gBattlerAttacker, gBattlerTarget, TRUE) + && !(IS_MOVE_STATUS(move) && GetBattlerAbility(gBattlerTarget) == ABILITY_MAGIC_BOUNCE)) + { + if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE) || !(gBattleMoves[move].target & (MOVE_TARGET_BOTH | MOVE_TARGET_FOES_AND_ALLY))) + CancelMultiTurnMoves(gBattlerAttacker); // Don't cancel moves that can hit two targets bc one target might not be protected + gBattleScripting.battler = gBattlerAbility = gBattlerTarget; + gBattlescriptCurrInstr = BattleScript_DarkTypePreventsPrankster; + effect = 1; + } + break; case ABILITYEFFECT_ABSORBING: // 3 if (move != MOVE_NONE) From b7dcbca8718f85b87ba0d53eb0e99c98a4eae6e0 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 16 Oct 2021 11:25:20 -0400 Subject: [PATCH 48/85] remove atkCancelerTracker reset --- src/battle_script_commands.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 818fd246e..4321881bf 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5159,7 +5159,6 @@ static void Cmd_moveend(void) MoveValuesCleanUp(); gBattleScripting.moveEffect = gBattleScripting.savedMoveEffect; BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); - gBattleStruct->atkCancellerTracker = 0; // Run all cancellers on next target gBattlescriptCurrInstr = BattleScript_FlushMessageBox; return; } From 5509ceea0420afdb3628af207f28d7a7db3283d3 Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 16 Oct 2021 16:10:45 -0400 Subject: [PATCH 49/85] expand move target field --- include/battle.h | 2 +- include/battle_util.h | 2 +- include/constants/battle.h | 3 +-- src/battle_controller_player.c | 4 ++-- src/battle_util.c | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/battle.h b/include/battle.h index 22b60d6e4..26c6b3e40 100644 --- a/include/battle.h +++ b/include/battle.h @@ -491,7 +491,7 @@ struct BattleStruct u8 turnEffectsBattlerId; u8 turnCountersTracker; u16 wrappedMove[MAX_BATTLERS_COUNT]; - u8 moveTarget[MAX_BATTLERS_COUNT]; + u16 moveTarget[MAX_BATTLERS_COUNT]; u8 expGetterMonId; u8 wildVictorySong; u8 dynamicMoveType; diff --git a/include/battle_util.h b/include/battle_util.h index 7d1b99f34..ee7337ef2 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -109,7 +109,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn); void ClearFuryCutterDestinyBondGrudge(u8 battlerId); void HandleAction_RunBattleScript(void); u32 SetRandomTarget(u32 battlerId); -u8 GetMoveTarget(u16 move, u8 setTarget); +u32 GetMoveTarget(u16 move, u8 setTarget); u8 IsMonDisobedient(void); u32 GetBattlerHoldEffect(u8 battlerId, bool32 checkNegating); u32 GetBattlerHoldEffectParam(u8 battlerId); diff --git a/include/constants/battle.h b/include/constants/battle.h index 90294b4b4..c5d5601fa 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -386,7 +386,6 @@ #define MOVE_TARGET_FOES_AND_ALLY 0x20 #define MOVE_TARGET_OPPONENTS_FIELD 0x40 #define MOVE_TARGET_ALLY 0x80 - -#define MOVE_TARGET_ALL_BATTLERS (MOVE_TARGET_BOTH | MOVE_TARGET_OPPONENTS_FIELD) +#define MOVE_TARGET_ALL_BATTLERS 0x100 #endif // GUARD_CONSTANTS_BATTLE_H diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 877e44750..0d4cf51de 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -590,7 +590,7 @@ static void TryShowAsTarget(u32 battlerId) static void HandleInputChooseMove(void) { - u8 moveTarget; + u16 moveTarget; u32 canSelectTarget = 0; struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleResources->bufferA[gActiveBattler][4]); @@ -644,7 +644,7 @@ static void HandleInputChooseMove(void) // Show all available targets for multi-target moves if (B_SHOW_TARGETS) { - if ((moveTarget & MOVE_TARGET_ALL_BATTLERS) == MOVE_TARGET_ALL_BATTLERS) + if (moveTarget & MOVE_TARGET_ALL_BATTLERS) { u32 i = 0; for (i = 0; i < gBattlersCount; i++) diff --git a/src/battle_util.c b/src/battle_util.c index e01c89fca..cdacaf179 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7018,7 +7018,7 @@ u32 SetRandomTarget(u32 battlerId) return target; } -u8 GetMoveTarget(u16 move, u8 setTarget) +u32 GetMoveTarget(u16 move, u8 setTarget) { u8 targetBattler = 0; u32 i, moveTarget, side; From 964e7efba9f900db7ee3f51f3821165e81cd29ff Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Sat, 16 Oct 2021 16:23:17 -0400 Subject: [PATCH 50/85] fix MOVE_TARGET_ALL_BATTLERS and other u8 vars --- include/constants/battle.h | 2 +- include/pokemon.h | 2 +- src/battle_ai_main.c | 4 ++-- src/battle_controller_player.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/constants/battle.h b/include/constants/battle.h index c5d5601fa..577b0ba60 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -386,6 +386,6 @@ #define MOVE_TARGET_FOES_AND_ALLY 0x20 #define MOVE_TARGET_OPPONENTS_FIELD 0x40 #define MOVE_TARGET_ALLY 0x80 -#define MOVE_TARGET_ALL_BATTLERS 0x100 +#define MOVE_TARGET_ALL_BATTLERS (0x100 | MOVE_TARGET_USER) #endif // GUARD_CONSTANTS_BATTLE_H diff --git a/include/pokemon.h b/include/pokemon.h index 1524e16f4..747830412 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -216,7 +216,7 @@ struct BattleMove u8 accuracy; u8 pp; u8 secondaryEffectChance; - u8 target; + u16 target; s8 priority; u32 flags; u8 split; diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index edfd76464..972dc0ed6 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -517,7 +517,7 @@ static s16 AI_CheckBadMove(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) u8 atkPriority = GetMovePriority(battlerAtk, move); u16 moveEffect = gBattleMoves[move].effect; s32 moveType; - u8 moveTarget = gBattleMoves[move].target; + u16 moveTarget = gBattleMoves[move].target; u16 accuracy = AI_GetMoveAccuracy(battlerAtk, battlerDef, AI_DATA->atkAbility, AI_DATA->defAbility, AI_DATA->atkHoldEffect, AI_DATA->defHoldEffect, move); u8 effectiveness = AI_GetMoveEffectiveness(move, battlerAtk, battlerDef); bool32 isDoubleBattle = IsValidDoubleBattle(battlerAtk); @@ -2514,7 +2514,7 @@ static s16 AI_DoubleBattle(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) // move data u8 moveType = gBattleMoves[move].type; u16 effect = gBattleMoves[move].effect; - u8 target = gBattleMoves[move].target; + u16 target = gBattleMoves[move].target; // ally data u8 battlerAtkPartner = AI_DATA->battlerAtkPartner; u16 atkPartnerAbility = AI_DATA->atkPartnerAbility; diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 0d4cf51de..e1cb2f54f 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -644,7 +644,7 @@ static void HandleInputChooseMove(void) // Show all available targets for multi-target moves if (B_SHOW_TARGETS) { - if (moveTarget & MOVE_TARGET_ALL_BATTLERS) + if ((moveTarget & MOVE_TARGET_ALL_BATTLERS) == MOVE_TARGET_ALL_BATTLERS) { u32 i = 0; for (i = 0; i < gBattlersCount; i++) From 59cfbe55c1d7669957714379b060f81c4e7b70db Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 17 Oct 2021 09:27:35 -0300 Subject: [PATCH 51/85] Gave Grav Apple a move effect of its own --- data/battle_scripts_1.s | 4 ++++ include/constants/battle_move_effects.h | 3 ++- src/battle_util.c | 8 ++++---- src/data/battle_moves.h | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index e4fdb3038..7999091e0 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -381,6 +381,10 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectTripleHit @ EFFECT_TRIPLE_HIT .4byte BattleScript_EffectRecoilHP25 @ EFFECT_RECOIL_HP_25 .4byte BattleScript_EffectStuffCheeks @ EFFECT_STUFF_CHEEKS + .4byte BattleScript_EffectGravApple @ EFFECT_GRAV_APPLE + +BattleScript_EffectGravApple: + goto BattleScript_EffectAttackerDefenseDownHit BattleScript_EffectStuffCheeks:: attackcanceler diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 9a6efb847..20f6e110d 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -365,7 +365,8 @@ #define EFFECT_TRIPLE_HIT 359 #define EFFECT_RECOIL_HP_25 360 #define EFFECT_STUFF_CHEEKS 361 +#define EFFECT_GRAV_APPLE 362 -#define NUM_BATTLE_MOVE_EFFECTS 362 +#define NUM_BATTLE_MOVE_EFFECTS 363 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/src/battle_util.c b/src/battle_util.c index 2b72fc3bc..fb485c2e7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -7693,6 +7693,10 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) #endif break; } + case EFFECT_GRAV_APPLE: + if (gFieldStatuses & STATUS_FIELD_GRAVITY) + MulModifier(&basePower, UQ_4_12(1.5)); + break; } // move-specific base power changes @@ -7702,10 +7706,6 @@ static u16 CalcMoveBasePower(u16 move, u8 battlerAtk, u8 battlerDef) if (gBattleMons[battlerAtk].species == SPECIES_GRENINJA_ASH) basePower = 20; break; - case MOVE_GRAV_APPLE: - if (gFieldStatuses & STATUS_FIELD_GRAVITY) - basePower = 120; - break; } if (basePower == 0) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index a6b8d271c..2dcdbf5b2 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -11103,7 +11103,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_GRAV_APPLE] = { - .effect = EFFECT_DEFENSE_DOWN_HIT, + .effect = EFFECT_GRAV_APPLE, .power = 80, .type = TYPE_GRASS, .accuracy = 100, From d6304099ac822a081f259769144cf858c51cba74 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 17 Oct 2021 09:39:57 -0300 Subject: [PATCH 52/85] Review optimization Co-authored-by: Eduardo Quezada D'Ottone --- data/battle_scripts_1.s | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 7999091e0..88832325a 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -381,10 +381,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectTripleHit @ EFFECT_TRIPLE_HIT .4byte BattleScript_EffectRecoilHP25 @ EFFECT_RECOIL_HP_25 .4byte BattleScript_EffectStuffCheeks @ EFFECT_STUFF_CHEEKS - .4byte BattleScript_EffectGravApple @ EFFECT_GRAV_APPLE - -BattleScript_EffectGravApple: - goto BattleScript_EffectAttackerDefenseDownHit + .4byte BattleScript_EffectDefenseDownHit @ EFFECT_GRAV_APPLE BattleScript_EffectStuffCheeks:: attackcanceler From 5d0350cdbc86310e25ea53946b07819b98366ba2 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 17 Oct 2021 10:08:30 -0300 Subject: [PATCH 53/85] Set the right .effect to Dynamax Cannon --- src/data/battle_moves.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 2dcdbf5b2..a34055200 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10738,7 +10738,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_DYNAMAX_CANNON] = { - .effect = EFFECT_HIT, + .effect = EFFECT_DYNAMAX_DOUBLE_DMG, .power = 100, .type = TYPE_DRAGON, .accuracy = 100, From dcea8e45ed0bb72f67ef2f78513450dfb6133d70 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 17 Oct 2021 10:51:22 -0300 Subject: [PATCH 54/85] Fixed jumpifspecies --- asm/macros/battle_script.inc | 2 +- src/battle_script_commands.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9d624195b..fd20478d2 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1771,7 +1771,7 @@ .macro jumpifspecies battler:req, species:req, ptr:req various \battler, VARIOUS_JUMP_IF_SPECIES - .byte \species + .2byte \species .4byte \ptr .endm diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2a4b2e347..7b5e782c2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8427,10 +8427,10 @@ static void Cmd_various(void) } return; case VARIOUS_JUMP_IF_SPECIES: - if (gBattleMons[gBattlerAttacker].species == gBattlescriptCurrInstr[3]) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 4); + if (gBattleMons[gActiveBattler].species == T1_READ_16(gBattlescriptCurrInstr + 3)) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 5); else - gBattlescriptCurrInstr += 8; + gBattlescriptCurrInstr += 9; return; } From e7ad7319e3bb3469dba8bce076d85c42912d1dc6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 17 Oct 2021 11:54:27 -0300 Subject: [PATCH 55/85] Updated Glare --- data/battle_scripts_1.s | 4 ++++ include/constants/battle_config.h | 1 + 2 files changed, 5 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 88832325a..9806cf939 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3229,7 +3229,11 @@ BattleScript_EffectParalyze: jumpifleafguard BattleScript_LeafGuardProtects jumpifshieldsdown BS_TARGET, BattleScript_LeafGuardProtects jumpifsubstituteblocks BattleScript_ButItFailed +.if B_GLARE_GHOST >= GEN_4 + jumpifmove MOVE_GLARE, BattleScript_BattleScript_EffectParalyzeNoTypeCalc +.endif typecalc +BattleScript_BattleScript_EffectParalyzeNoTypeCalc: jumpifmovehadnoeffect BattleScript_ButItFailed jumpifstatus BS_TARGET, STATUS1_PARALYSIS, BattleScript_AlreadyParalyzed tryparalyzetype BS_ATTACKER, BS_TARGET, BattleScript_NotAffected diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index fc9bc9f4e..3aa9faea3 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -124,6 +124,7 @@ #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. // 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. From 25255475a78c29f563ddbe0a78ea26c13f053a49 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Mon, 18 Oct 2021 10:05:19 -0300 Subject: [PATCH 56/85] AI will now take Grav Apple's new effect in consideration --- src/battle_ai_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index edfd76464..324ca4934 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -3363,6 +3363,10 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) case EFFECT_PARALYZE: IncreaseParalyzeScore(battlerAtk, battlerDef, move, &score); break; + case EFFECT_GRAV_APPLE: + if (gFieldStatuses & STATUS_FIELD_GRAVITY) + score += 2; + // fall through case EFFECT_ATTACK_DOWN_HIT: case EFFECT_DEFENSE_DOWN_HIT: case EFFECT_SPECIAL_ATTACK_DOWN_HIT: From 3c6101d957fb5feabc253a6e0a302461ed647a38 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Mon, 18 Oct 2021 21:55:16 -0300 Subject: [PATCH 57/85] Clear gStatuses4 data --- src/battle_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/battle_main.c b/src/battle_main.c index 2c1597718..d18f71fe0 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2850,6 +2850,7 @@ static void BattleStartClearSetData(void) for (i = 0; i < MAX_BATTLERS_COUNT; i++) { gStatuses3[i] = 0; + gStatuses4[i] = 0; gDisableStructs[i].isFirstTurn = 2; gLastMoves[i] = 0; gLastLandedMoves[i] = 0; @@ -2981,6 +2982,8 @@ void SwitchInClearSetData(void) gBattleMons[gActiveBattler].status2 = 0; gStatuses3[gActiveBattler] = 0; } + + gStatuses4[gActiveBattler] = 0; for (i = 0; i < gBattlersCount; i++) { @@ -3054,6 +3057,7 @@ void FaintClearSetData(void) gBattleMons[gActiveBattler].status2 = 0; gStatuses3[gActiveBattler] = 0; + gStatuses4[gActiveBattler] = 0; for (i = 0; i < gBattlersCount; i++) { From 910fdfa94a97eefb49fd2aefa2a39dcf553e7e00 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Tue, 19 Oct 2021 16:25:01 +1300 Subject: [PATCH 58/85] Revert "Fix multi target moves" This reverts commit b5293cc3e2b7c38364b9bc7b39ed7e4bc6cb2bec. --- include/battle_util.h | 27 --------------------------- src/battle_script_commands.c | 2 +- src/battle_util.c | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/include/battle_util.h b/include/battle_util.h index 3f4f4bbc7..7d1b99f34 100644 --- a/include/battle_util.h +++ b/include/battle_util.h @@ -34,33 +34,6 @@ #define ITEMEFFECT_LIFEORB_SHELLBELL 0x7 #define ITEMEFFECT_BATTLER_MOVE_END 0x8 // move end effects for just the battler, not whole field -// Move cancellers. Note that anything from CANCELLER_PRANKSTER onwards is -// called on each target of a multi target move, so any new cancellers should -// probably be added before CANCELLER_PRANKSTER. -#define CANCELLER_FLAGS 0 -#define CANCELLER_ASLEEP 1 -#define CANCELLER_FROZEN 2 -#define CANCELLER_TRUANT 3 -#define CANCELLER_RECHARGE 4 -#define CANCELLER_FLINCH 5 -#define CANCELLER_DISABLED 6 -#define CANCELLER_GRAVITY 7 -#define CANCELLER_HEAL_BLOCKED 8 -#define CANCELLER_TAUNTED 9 -#define CANCELLER_IMPRISONED 10 -#define CANCELLER_CONFUSED 11 -#define CANCELLER_PARALYSED 12 -#define CANCELLER_IN_LOVE 13 -#define CANCELLER_BIDE 14 -#define CANCELLER_THAW 15 -#define CANCELLER_POWDER_MOVE 16 -#define CANCELLER_POWDER_STATUS 17 -#define CANCELLER_THROAT_CHOP 18 -#define CANCELLER_PRANKSTER 19 -#define CANCELLER_END 20 -#define CANCELLER_PSYCHIC_TERRAIN 21 -#define CANCELLER_END2 22 - #define WEATHER_HAS_EFFECT ((!IsAbilityOnField(ABILITY_CLOUD_NINE) && !IsAbilityOnField(ABILITY_AIR_LOCK))) #define IS_WHOLE_SIDE_ALIVE(battler)((IsBattlerAlive(battler) && IsBattlerAlive(BATTLE_PARTNER(battler)))) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 8bd082529..32a87b53e 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5158,7 +5158,7 @@ static void Cmd_moveend(void) MoveValuesCleanUp(); gBattleScripting.moveEffect = gBattleScripting.savedMoveEffect; BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); - gBattleStruct->atkCancellerTracker = CANCELLER_PRANKSTER; // Run Prankster canceller on next target, skip the earlier ones + gBattleStruct->atkCancellerTracker = 0; // Run all cancellers on next target gBattlescriptCurrInstr = BattleScript_FlushMessageBox; return; } diff --git a/src/battle_util.c b/src/battle_util.c index 1177c316e..18a1bfb47 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3102,6 +3102,33 @@ void TryClearRageAndFuryCutter(void) } } +enum +{ + CANCELLER_FLAGS, + CANCELLER_ASLEEP, + CANCELLER_FROZEN, + CANCELLER_TRUANT, + CANCELLER_RECHARGE, + CANCELLER_FLINCH, + CANCELLER_DISABLED, + CANCELLER_GRAVITY, + CANCELLER_HEAL_BLOCKED, + CANCELLER_TAUNTED, + CANCELLER_IMPRISONED, + CANCELLER_CONFUSED, + CANCELLER_PARALYSED, + CANCELLER_IN_LOVE, + CANCELLER_BIDE, + CANCELLER_THAW, + CANCELLER_POWDER_MOVE, + CANCELLER_POWDER_STATUS, + CANCELLER_THROAT_CHOP, + CANCELLER_PRANKSTER, + CANCELLER_END, + CANCELLER_PSYCHIC_TERRAIN, + CANCELLER_END2, +}; + u8 AtkCanceller_UnableToUseMove(void) { u8 effect = 0; From 2dea4f6782b78978ed3bd1f070fb8e64c8c95dc7 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 19 Oct 2021 07:23:02 -0300 Subject: [PATCH 59/85] Forgot to port over a return for jumpifcantreverttoprimal --- 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 dcd9c8999..b5698b51b 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8880,6 +8880,7 @@ static void Cmd_various(void) gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); else gBattlescriptCurrInstr += 7; + return; } } From da70accc3e0ee78ec11db20b24e58c697bf08a3b Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Tue, 19 Oct 2021 08:02:36 -0300 Subject: [PATCH 60/85] Oopsie --- src/battle_script_commands.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 82a6bba63..399c5469a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8953,7 +8953,6 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 4; return; - } case VARIOUS_JUMP_IF_CANT_REVERT_TO_PRIMAL: { bool8 canDoPrimalReversion = FALSE; @@ -8970,6 +8969,7 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; return; } + } gBattlescriptCurrInstr += 3; } From 150dd7c6339d6bb8e14ebb2792e49efd0d9c64b4 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 19 Oct 2021 22:39:07 +1100 Subject: [PATCH 61/85] Add damage information to the debug menus --- include/battle.h | 1 + src/battle_ai_main.c | 8 ++++++-- src/battle_debug.c | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/include/battle.h b/include/battle.h index 26c6b3e40..2ceced61c 100644 --- a/include/battle.h +++ b/include/battle.h @@ -596,6 +596,7 @@ struct BattleStruct bool8 spriteIgnore0Hp; struct Illusion illusion[MAX_BATTLERS_COUNT]; s8 aiFinalScore[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // AI, target, moves to make debugging easier + s32 aiSimulatedDamage[MAX_BATTLERS_COUNT][MAX_BATTLERS_COUNT][MAX_MON_MOVES]; // attacker, target, move to make debugging easier u8 soulheartBattlerId; u8 friskedBattler; // Frisk needs to identify 2 battlers in double battles. bool8 friskedAbility; // If identifies two mons, show the ability pop-up only once. diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index c5ed7d9a3..ecea5b2ca 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -266,8 +266,10 @@ static u8 ChooseMoveOrAction_Singles(void) AI_THINKING_STRUCT->movesetIndex = 0; } - for (i = 0; i < MAX_MON_MOVES; i++) + for (i = 0; i < MAX_MON_MOVES; i++) { gBattleStruct->aiFinalScore[sBattler_AI][gBattlerTarget][i] = AI_THINKING_STRUCT->score[i]; + gBattleStruct->aiSimulatedDamage[sBattler_AI][gBattlerTarget][i] = AI_THINKING_STRUCT->simulatedDmg[sBattler_AI][gBattlerTarget][i]; + } // Check special AI actions. if (AI_THINKING_STRUCT->aiAction & AI_ACTION_FLEE) @@ -432,8 +434,10 @@ static u8 ChooseMoveOrAction_Doubles(void) } } - for (j = 0; j < MAX_MON_MOVES; j++) + for (j = 0; j < MAX_MON_MOVES; j++) { gBattleStruct->aiFinalScore[sBattler_AI][gBattlerTarget][j] = AI_THINKING_STRUCT->score[j]; + gBattleStruct->aiSimulatedDamage[sBattler_AI][gBattlerTarget][i] = AI_THINKING_STRUCT->simulatedDmg[sBattler_AI][gBattlerTarget][i]; + } } } diff --git a/src/battle_debug.c b/src/battle_debug.c index ce5aa4a97..ff8920753 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -713,6 +713,12 @@ static void PutMovesPointsText(struct BattleDebugMenu *data) gBattleStruct->aiFinalScore[data->aiBattlerId][gSprites[data->aiIconSpriteIds[j]].data[0]][i], STR_CONV_MODE_RIGHT_ALIGN, 3); AddTextPrinterParameterized(data->aiMovesWindowId, 1, text, 83 + count * 54, i * 15, 0, NULL); + + ConvertIntToDecimalStringN(text, + gBattleStruct->aiSimulatedDamage[data->aiBattlerId][gSprites[data->aiIconSpriteIds[j]].data[0]][i], + STR_CONV_MODE_RIGHT_ALIGN, 3); + AddTextPrinterParameterized(data->aiMovesWindowId, 1, text, 110 + count * 54, i * 15, 0, NULL); + count++; } } @@ -780,7 +786,7 @@ static void Task_ShowAiPoints(u8 taskId) break; // Put text case 1: - winTemplate = CreateWindowTemplate(1, 0, 4, 27, 14, 15, 0x200); + winTemplate = CreateWindowTemplate(1, 0, 4, 30, 14, 15, 0x200); data->aiMovesWindowId = AddWindow(&winTemplate); PutWindowTilemap(data->aiMovesWindowId); PutMovesPointsText(data); From 055c1c47b7410d8d92085c4578dd60ab66ffd788 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 19 Oct 2021 23:00:04 +1100 Subject: [PATCH 62/85] Fix double battles damage scoring --- src/battle_ai_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index ecea5b2ca..b830507a1 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -436,7 +436,7 @@ static u8 ChooseMoveOrAction_Doubles(void) for (j = 0; j < MAX_MON_MOVES; j++) { gBattleStruct->aiFinalScore[sBattler_AI][gBattlerTarget][j] = AI_THINKING_STRUCT->score[j]; - gBattleStruct->aiSimulatedDamage[sBattler_AI][gBattlerTarget][i] = AI_THINKING_STRUCT->simulatedDmg[sBattler_AI][gBattlerTarget][i]; + gBattleStruct->aiSimulatedDamage[sBattler_AI][gBattlerTarget][j] = AI_THINKING_STRUCT->simulatedDmg[sBattler_AI][gBattlerTarget][j]; } } } From 4673ff30e47f3a08a3f7ad2418c36aad9a508014 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 19 Oct 2021 23:00:40 +1100 Subject: [PATCH 63/85] Allow the AI to see damage against it's partner --- src/battle_ai_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index b830507a1..a2d97f785 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -177,10 +177,10 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves) } sBattler_AI = gActiveBattler; - // Simulate dmg for all AI moves against all opposing targets + // Simulate dmg for all AI moves against all other targets for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { - if (GET_BATTLER_SIDE2(sBattler_AI) == GET_BATTLER_SIDE2(gBattlerTarget)) + if (sBattler_AI == gBattlerTarget) continue; for (i = 0; i < MAX_MON_MOVES; i++) { From 6a16813ce8ca3887d02b329c869cd3f20c139431 Mon Sep 17 00:00:00 2001 From: Xavion3 Date: Tue, 19 Oct 2021 23:01:07 +1100 Subject: [PATCH 64/85] Rename menu option to be more appropriate to changed info --- src/battle_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_debug.c b/src/battle_debug.c index ff8920753..ef78f13fd 100644 --- a/src/battle_debug.c +++ b/src/battle_debug.c @@ -228,7 +228,7 @@ static const u8 sText_InDoubles[] = _("In Doubles"); static const u8 sText_HpAware[] = _("HP aware"); static const u8 sText_Unknown[] = _("Unknown"); static const u8 sText_InLove[] = _("In Love"); -static const u8 sText_AIMovePts[] = _("AI Move Pts"); +static const u8 sText_AIMovePts[] = _("AI Pts/Dmg"); static const u8 sText_AiKnowledge[] = _("AI Info"); static const u8 sText_EffectOverride[] = _("Effect Override"); From a6315ffc75b2bd841817e16e139d21f63d05b146 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Sun, 17 Oct 2021 12:27:17 -0300 Subject: [PATCH 65/85] Implemented Plasma Fists --- asm/macros/battle_script.inc | 4 ++++ data/battle_scripts_1.s | 27 ++++++++++++++++++++++ include/constants/battle.h | 1 + include/constants/battle_move_effects.h | 3 ++- include/constants/battle_script_commands.h | 1 + src/battle_main.c | 4 ++++ src/battle_script_commands.c | 4 ++++ src/battle_util.c | 6 +++++ src/data/battle_moves.h | 2 +- 9 files changed, 50 insertions(+), 2 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 9a5c1d8ed..cceb83ac7 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1844,6 +1844,10 @@ various \battler, VARIOUS_TRY_ACTIVATE_BATTLE_BOND .endm + .macro applyplasmafists + various BS_ATTACKER, VARIOUS_APPLY_PLASMA_FISTS + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3d7dde94d..4d28d1394 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -389,6 +389,33 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectSappySeed @ EFFECT_SAPPY_SEED .4byte BattleScript_EffectFreezyFrost @ EFFECT_FREEZY_FROST .4byte BattleScript_EffectSparklySwirl @ EFFECT_SPARKLY_SWIRL + .4byte BattleScript_EffectPlasmaFists @ EFFECT_PLASMA_FISTS + +BattleScript_EffectPlasmaFists: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + seteffectwithchance + tryfaintmon BS_TARGET, FALSE, NULL + applyplasmafists + printstring STRINGID_IONDELUGEON + waitmessage B_WAIT_TIME_LONG + goto BattleScript_MoveEnd BattleScript_EffectSparklySwirl: attackcanceler diff --git a/include/constants/battle.h b/include/constants/battle.h index 0682d3503..260e6153c 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -173,6 +173,7 @@ #define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER | STATUS3_PHANTOM_FORCE) #define STATUS4_ELECTRIFIED (1 << 0) +#define STATUS4_PLASMA_FISTS (1 << 1) #define HITMARKER_x10 (1 << 4) #define HITMARKER_x20 (1 << 5) diff --git a/include/constants/battle_move_effects.h b/include/constants/battle_move_effects.h index 383e37559..f405c32c6 100644 --- a/include/constants/battle_move_effects.h +++ b/include/constants/battle_move_effects.h @@ -373,7 +373,8 @@ #define EFFECT_SAPPY_SEED 367 #define EFFECT_FREEZY_FROST 368 #define EFFECT_SPARKLY_SWIRL 369 +#define EFFECT_PLASMA_FISTS 370 -#define NUM_BATTLE_MOVE_EFFECTS 370 +#define NUM_BATTLE_MOVE_EFFECTS 371 #endif // GUARD_CONSTANTS_BATTLE_MOVE_EFFECTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 829664e75..7590cfffb 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -190,6 +190,7 @@ #define VARIOUS_JUMP_IF_NOT_ROTOTILLER_AFFECTED 117 #define VARIOUS_TRY_ACTIVATE_BATTLE_BOND 118 #define VARIOUS_CONSUME_BERRY 119 +#define VARIOUS_APPLY_PLASMA_FISTS 120 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_main.c b/src/battle_main.c index ec0ee5300..3a42d61f1 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -5156,6 +5156,10 @@ void SetTypeBeforeUsingMove(u16 move, u8 battlerAtk) { gBattleStruct->dynamicMoveType = 0x80 | TYPE_WATER; } + else if (gStatuses4[battlerAtk] & STATUS4_PLASMA_FISTS && moveType == TYPE_NORMAL) + { + gBattleStruct->dynamicMoveType = 0x80 | TYPE_ELECTRIC; + } // Check if a gem should activate. GET_MOVE_TYPE(move, moveType); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index ee3b39bcd..268509781 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8910,6 +8910,10 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 4; return; + case VARIOUS_APPLY_PLASMA_FISTS: + for (i = 0; i < gBattlersCount; i++) + gStatuses4[i] |= STATUS4_PLASMA_FISTS; + break; } gBattlescriptCurrInstr += 3; diff --git a/src/battle_util.c b/src/battle_util.c index ea8fb75d1..c5ee5220a 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2379,6 +2379,7 @@ enum ENDTURN_POWDER, ENDTURN_THROAT_CHOP, ENDTURN_SLOW_START, + ENDTURN_PLASMA_FISTS, ENDTURN_BATTLER_COUNT }; @@ -2885,6 +2886,11 @@ u8 DoBattlerEndTurnEffects(void) } gBattleStruct->turnEffectsTracker++; break; + case ENDTURN_PLASMA_FISTS: + for (i = 0; i < gBattlersCount; i++) + gStatuses4[i] &= ~(STATUS4_PLASMA_FISTS); + gBattleStruct->turnEffectsTracker++; + break; case ENDTURN_BATTLER_COUNT: // done gBattleStruct->turnEffectsTracker = 0; gBattleStruct->turnEffectsBattlerId++; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 911ae0df2..b7d5dcad9 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -10435,7 +10435,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_PLASMA_FISTS] = { - .effect = EFFECT_PLACEHOLDER, // Needs a custom move effect + .effect = EFFECT_PLASMA_FISTS, .power = 100, .type = TYPE_ELECTRIC, .accuracy = 100, From ebc86bb247d33d0457ecd88998d662b91af1547e Mon Sep 17 00:00:00 2001 From: ghoulslash Date: Tue, 19 Oct 2021 09:38:27 -0400 Subject: [PATCH 66/85] update baton pass status3 bits --- src/battle_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/battle_main.c b/src/battle_main.c index ec0ee5300..faac3806c 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2960,9 +2960,11 @@ void SwitchInClearSetData(void) } } if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) - { + { gBattleMons[gActiveBattler].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED); - gStatuses3[gActiveBattler] &= (STATUS3_LEECHSEED_BATTLER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED); + gStatuses3[gActiveBattler] &= (STATUS3_LEECHSEED_BATTLER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED + | STATUS3_GASTRO_ACID | STATUS3_EMBARGO | STATUS3_TELEKINESIS | STATUS3_MAGNET_RISE | STATUS3_HEAL_BLOCK + | STATUS3_AQUA_RING | STATUS3_POWER_TRICK); for (i = 0; i < gBattlersCount; i++) { From fa8fa322591c54b9319d1a30ebb897456336ad44 Mon Sep 17 00:00:00 2001 From: ghoulslash <41651341+ghoulslash@users.noreply.github.com> Date: Tue, 19 Oct 2021 11:52:50 -0400 Subject: [PATCH 67/85] Update src/battle_main.c Co-authored-by: LOuroboros --- src/battle_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_main.c b/src/battle_main.c index faac3806c..271db092f 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -2960,7 +2960,7 @@ void SwitchInClearSetData(void) } } if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) - { + { gBattleMons[gActiveBattler].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED); gStatuses3[gActiveBattler] &= (STATUS3_LEECHSEED_BATTLER | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED | STATUS3_GASTRO_ACID | STATUS3_EMBARGO | STATUS3_TELEKINESIS | STATUS3_MAGNET_RISE | STATUS3_HEAL_BLOCK From 34fe0c54be04d1ecb98e7573859ea69e7761f147 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 21 Oct 2021 08:50:04 -0300 Subject: [PATCH 68/85] Fixed Retaliate timer's value decrease I made an oopsie, basically. Thanks to Xavion#9504 for the fix. --- src/battle_util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index ea8fb75d1..7215706c6 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2331,9 +2331,10 @@ u8 DoFieldEndTurnEffects(void) gBattleStruct->turnCountersTracker++; break; case ENDTURN_RETALIATE: - gActiveBattler = gBattlerByTurnOrder[gBattleStruct->turnSideTracker]; - if (gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].retaliateTimer > 0) - gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].retaliateTimer--; + if (gSideTimers[0].retaliateTimer > 0) + gSideTimers[0].retaliateTimer--; + if (gSideTimers[1].retaliateTimer > 0) + gSideTimers[1].retaliateTimer--; gBattleStruct->turnCountersTracker++; break; case ENDTURN_FIELD_COUNT: From dd82e051bd16ba8dfd5fabf6381c31ef66923180 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 22 Oct 2021 06:48:24 -0300 Subject: [PATCH 69/85] 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 70/85] 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 cf027176a8ee39fc97595d84ab69db64be51396e Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 22 Oct 2021 11:43:38 -0300 Subject: [PATCH 71/85] Made ENDTURN_RETALIATE use constants --- src/battle_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/battle_util.c b/src/battle_util.c index 7215706c6..46f9cd775 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -2331,10 +2331,10 @@ u8 DoFieldEndTurnEffects(void) gBattleStruct->turnCountersTracker++; break; case ENDTURN_RETALIATE: - if (gSideTimers[0].retaliateTimer > 0) - gSideTimers[0].retaliateTimer--; - if (gSideTimers[1].retaliateTimer > 0) - gSideTimers[1].retaliateTimer--; + if (gSideTimers[B_SIDE_PLAYER].retaliateTimer > 0) + gSideTimers[B_SIDE_PLAYER].retaliateTimer--; + if (gSideTimers[B_SIDE_OPPONENT].retaliateTimer > 0) + gSideTimers[B_SIDE_OPPONENT].retaliateTimer--; gBattleStruct->turnCountersTracker++; break; case ENDTURN_FIELD_COUNT: From 4c90cbe625f926ac7551ba5c3236b48dd9f2c55c Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Fri, 22 Oct 2021 19:58:27 -0300 Subject: [PATCH 72/85] 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 8bdcbb856d1b1208340657f19f48f51d142cebc1 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 23 Oct 2021 11:41:31 -0300 Subject: [PATCH 73/85] Ghosts can now escape any wild battle --- src/battle_util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/battle_util.c b/src/battle_util.c index 33dd0f5de..733cf53f7 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -621,6 +621,12 @@ bool8 TryRunFromBattle(u8 battler) gProtectStructs[battler].fleeFlag = 1; effect++; } + #if B_GHOSTS_ESCAPE >= GEN_6 + else if (IS_BATTLER_OF_TYPE(battler, TYPE_GHOST)) + { + effect++; + } + #endif else if (gBattleMons[battler].ability == ABILITY_RUN_AWAY) { if (InBattlePyramid()) From f4ff76c8ae08cb2fa5c1ba794f3eb7a9367cd4b8 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 23 Oct 2021 11:42:33 -0300 Subject: [PATCH 74/85] MOVE_EFFECT_MEAN_LOOK now fails on ghost types. --- data/battle_scripts_1.s | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index bf65bb190..3dc41b982 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -3977,6 +3977,9 @@ BattleScript_EffectMeanLook:: accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON jumpifstatus2 BS_TARGET, STATUS2_ESCAPE_PREVENTION, BattleScript_ButItFailed jumpifsubstituteblocks BattleScript_ButItFailed +.if B_GHOSTS_ESCAPE >= GEN_6 + jumpiftype BS_TARGET, TYPE_GHOST, BattleScript_ButItFailed +.endif attackanimation waitanimation setmoveeffect MOVE_EFFECT_PREVENT_ESCAPE From 0f95adf77a11c4130a08b743e38321b5f24ef6d9 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 23 Oct 2021 11:56:56 -0300 Subject: [PATCH 75/85] Fixed AI check for Mean Look in case it's set to be GEN_5 or lower. --- src/battle_ai_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/battle_ai_main.c b/src/battle_ai_main.c index a2d97f785..b8ed21e9d 100644 --- a/src/battle_ai_main.c +++ b/src/battle_ai_main.c @@ -3335,7 +3335,7 @@ static s16 AI_CheckViability(u8 battlerAtk, u8 battlerDef, u16 move, s16 score) case EFFECT_TRAP: case EFFECT_MEAN_LOOK: if (HasMoveEffect(battlerDef, EFFECT_RAPID_SPIN) - || IS_BATTLER_OF_TYPE(battlerDef, TYPE_GHOST) + || (B_GHOSTS_ESCAPE >= GEN_6 && IS_BATTLER_OF_TYPE(battlerDef, TYPE_GHOST)) || gBattleMons[battlerDef].status2 & STATUS2_WRAPPED) { break; // in this case its a bad attacking move From 9a8b88bdb3573ea07c9b2f77196696e774285eac Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Sat, 23 Oct 2021 11:59:57 -0300 Subject: [PATCH 76/85] Updated config description --- include/constants/battle_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index 3aa9faea3..f368a12e3 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -130,7 +130,7 @@ #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_GHOSTS_ESCAPE GEN_7 // In Gen6+, Ghost-type Pokémon can escape even when trying to be blocked by abilities such as Shadow Tag or moves like Mean Look. They can also escape any Wild Battle. #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. 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 77/85] 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 78/85] 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 79/85] 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 80/85] 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 81/85] 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 From d4eaa73292dcae415bf21648f2a313cdd71fa4ae Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Tue, 26 Oct 2021 20:45:59 -0300 Subject: [PATCH 82/85] Added check in IsRunningFromBattleImpossible. --- src/battle_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/battle_main.c b/src/battle_main.c index dddd3cc79..271e97731 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3705,6 +3705,10 @@ u8 IsRunningFromBattleImpossible(void) if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN) return 0; + #if B_GHOSTS_ESCAPE >= GEN_6 + if (IS_BATTLER_OF_TYPE(gActiveBattler, TYPE_GHOST)) + return 0; + #endif if (gBattleTypeFlags & BATTLE_TYPE_LINK) return 0; if (GetBattlerAbility(gActiveBattler) == ABILITY_RUN_AWAY) From 28522f3ffb46350e9b12c884995d1402b670aec6 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 28 Oct 2021 10:39:52 -0300 Subject: [PATCH 83/85] Fixed Hyperspace Fury not breaking through protections Also repositioned VARIOUS_JUMP_IF_SPECIES. --- asm/macros/battle_script.inc | 5 ++ data/battle_scripts_1.s | 74 +++++++++++++++++++++- include/battle.h | 10 +++ include/constants/battle_script_commands.h | 1 + include/constants/battle_string_ids.h | 3 +- src/battle_message.c | 2 + src/battle_script_commands.c | 18 ++++-- 7 files changed, 105 insertions(+), 8 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 04f6e04dc..906eb1ede 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1864,6 +1864,11 @@ .4byte \ptr .endm + .macro jumpifprotected battler:req, ptr:req + various \battler, VARIOUS_JUMP_IF_PROTECTED + .4byte \ptr + .endm + @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 3fcaf1024..b68363d5d 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -394,7 +394,7 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHyperspaceFury @ EFFECT_HYPERSPACE_FURY BattleScript_EffectHyperspaceFury: - jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectAttackerDefenseDownHit + jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectHyperspaceFuryUnbound jumpifspecies BS_ATTACKER, SPECIES_HOOPA, BattleScript_ButHoopaCantUseIt printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE waitmessage B_WAIT_TIME_LONG @@ -403,6 +403,78 @@ BattleScript_ButHoopaCantUseIt: printstring STRINGID_BUTHOOPACANTUSEIT waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd +BattleScript_EffectHyperspaceFuryUnbound: + attackcanceler + jumpifprotected BS_TARGET, BattleScript_HyperspaceFuryBrokeThroughProtection + argumenttomoveeffect + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + seteffectwithchance + tryfaintmon BS_TARGET, FALSE, NULL + swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler + setstatchanger STAT_DEF, 1, TRUE + statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_HyperspaceFuryTargetDefenseCantGoLower + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printfromtable gStatDownStringIds + waitmessage B_WAIT_TIME_LONG + swapattackerwithtarget @ restore the battlers, just in case + goto BattleScript_MoveEnd + +BattleScript_HyperspaceFuryBrokeThroughProtection:: + argumenttomoveeffect + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + ppreduce + pause B_WAIT_TIME_LONG + printstring STRINGID_BROKETHROUGHPROTECTION + waitmessage B_WAIT_TIME_LONG + critcalc + damagecalc + adjustdamage + attackanimation + waitanimation + effectivenesssound + hitanimation BS_TARGET + waitstate + healthbarupdate BS_TARGET + datahpupdate BS_TARGET + critmessage + waitmessage B_WAIT_TIME_LONG + resultmessage + waitmessage B_WAIT_TIME_LONG + seteffectwithchance + tryfaintmon BS_TARGET, FALSE, NULL + swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler + setstatchanger STAT_DEF, 1, TRUE + statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_HyperspaceFuryTargetDefenseCantGoLower + setgraphicalstatchangevalues + playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 + printfromtable gStatDownStringIds + waitmessage B_WAIT_TIME_LONG + swapattackerwithtarget @ restore the battlers, just in case + goto BattleScript_MoveEnd + return + +BattleScript_HyperspaceFuryTargetDefenseCantGoLower: + printstring STRINGID_STATSWONTDECREASE + waitmessage B_WAIT_TIME_LONG + return BattleScript_EffectPlasmaFists: attackcanceler diff --git a/include/battle.h b/include/battle.h index c1ac57686..5077053e3 100644 --- a/include/battle.h +++ b/include/battle.h @@ -638,6 +638,16 @@ struct BattleStruct gBattleMons[battlerId].type3 = TYPE_MYSTERY; \ } +#define IS_BATTLER_PROTECTED(battlerId)(gProtectStructs[battlerId].protected \ + || gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_WIDE_GUARD \ + || gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_QUICK_GUARD \ + || gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_CRAFTY_SHIELD \ + || gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_MAT_BLOCK \ + || gProtectStructs[battlerId].spikyShielded \ + || gProtectStructs[battlerId].kingsShielded \ + || gProtectStructs[battlerId].banefulBunkered \ + || gProtectStructs[battlerId].obstructed) \ + #define GET_STAT_BUFF_ID(n)((n & 7)) // first three bits 0x1, 0x2, 0x4 #define GET_STAT_BUFF_VALUE_WITH_SIGN(n)((n & 0xF8)) #define GET_STAT_BUFF_VALUE(n)(((n >> 3) & 0xF)) // 0x8, 0x10, 0x20, 0x40 diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index f00695276..abce5f9bf 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -194,6 +194,7 @@ #define VARIOUS_HANDLE_PRIMAL_REVERSION 121 #define VARIOUS_APPLY_PLASMA_FISTS 122 #define VARIOUS_JUMP_IF_SPECIES 123 +#define VARIOUS_JUMP_IF_PROTECTED 124 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/include/constants/battle_string_ids.h b/include/constants/battle_string_ids.h index 05bee80a8..1d461e2a0 100644 --- a/include/constants/battle_string_ids.h +++ b/include/constants/battle_string_ids.h @@ -596,8 +596,9 @@ #define STRINGID_PKMNREVERTEDTOPRIMAL 593 #define STRINGID_BUTPOKEMONCANTUSETHEMOVE 594 #define STRINGID_BUTHOOPACANTUSEIT 595 +#define STRINGID_BROKETHROUGHPROTECTION 596 -#define BATTLESTRINGS_COUNT 596 +#define BATTLESTRINGS_COUNT 597 // The below IDs are all indexes into battle message tables, // used to determine which of a set of messages to print. diff --git a/src/battle_message.c b/src/battle_message.c index bdc7f25fd..f26726a69 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -722,9 +722,11 @@ static const u8 sText_StuffCheeksCantSelect[] = _("Stuff Cheeks cannot be\nselec static const u8 sText_PkmnRevertedToPrimal[] = _("{B_ATK_NAME_WITH_PREFIX}'s Primal Reversion!\nIt reverted to its primal form!"); static const u8 sText_ButPokemonCantUseTheMove[] = _("But {B_ATK_NAME_WITH_PREFIX} can't\nuse the move!"); static const u8 sText_ButHoopaCantUseIt[] = _("But Hoopa can't use it\nthe way it is now!"); +static const u8 sText_BrokeThroughProtection[] = _("It broke through the\n{B_DEF_NAME_WITH_PREFIX}'s protection!"); const u8 *const gBattleStringsTable[BATTLESTRINGS_COUNT] = { + [STRINGID_BROKETHROUGHPROTECTION - 12] = sText_BrokeThroughProtection, [STRINGID_BUTPOKEMONCANTUSETHEMOVE - 12] = sText_ButPokemonCantUseTheMove, [STRINGID_BUTHOOPACANTUSEIT - 12] = sText_ButHoopaCantUseIt, [STRINGID_PKMNREVERTEDTOPRIMAL - 12] = sText_PkmnRevertedToPrimal, diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 828e628aa..f99aec129 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -8698,12 +8698,6 @@ static void Cmd_various(void) gBattlescriptCurrInstr += 7; // exit if loop failed (failsafe) } return; - case VARIOUS_JUMP_IF_SPECIES: - if (gBattleMons[gActiveBattler].species == T1_READ_16(gBattlescriptCurrInstr + 3)) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 5); - else - gBattlescriptCurrInstr += 9; - return; case VARIOUS_MOVEEND_ITEM_EFFECTS: if (ItemBattleEffects(1, gActiveBattler, FALSE)) return; @@ -8983,6 +8977,18 @@ static void Cmd_various(void) for (i = 0; i < gBattlersCount; i++) gStatuses4[i] |= STATUS4_PLASMA_FISTS; break; + case VARIOUS_JUMP_IF_SPECIES: + if (gBattleMons[gActiveBattler].species == T1_READ_16(gBattlescriptCurrInstr + 3)) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 5); + else + gBattlescriptCurrInstr += 9; + return; + case VARIOUS_JUMP_IF_PROTECTED: + if (IS_BATTLER_PROTECTED(gActiveBattler)) + gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); + else + gBattlescriptCurrInstr += 7; + return; } gBattlescriptCurrInstr += 3; From 2803b840e50fb47ea50256db6727859bd3084d42 Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 28 Oct 2021 13:52:35 -0300 Subject: [PATCH 84/85] Updated Shadow Force's move data --- src/data/battle_moves.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 1079cd608..cdb3ba0d1 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -7415,6 +7415,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .target = MOVE_TARGET_SELECTED, .priority = 0, .split = SPLIT_PHYSICAL, + .argument = MOVE_EFFECT_FEINT, }, [MOVE_HONE_CLAWS] = From 82101d3581a736fcaf6b46c37c1678d102b2fdfe Mon Sep 17 00:00:00 2001 From: LOuroboros Date: Thu, 28 Oct 2021 13:59:59 -0300 Subject: [PATCH 85/85] Optimizations --- asm/macros/battle_script.inc | 5 -- data/battle_scripts_1.s | 85 ++++------------------ include/battle_scripts.h | 1 + include/constants/battle_script_commands.h | 1 - src/battle_script_commands.c | 21 ++---- src/data/battle_moves.h | 1 - 6 files changed, 22 insertions(+), 92 deletions(-) diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index 906eb1ede..04f6e04dc 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1864,11 +1864,6 @@ .4byte \ptr .endm - .macro jumpifprotected battler:req, ptr:req - various \battler, VARIOUS_JUMP_IF_PROTECTED - .4byte \ptr - .endm - @ helpful macros .macro setstatchanger stat:req, stages:req, down:req setbyte sSTATCHANGER \stat | \stages << 3 | \down << 7 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index b68363d5d..e17fd8450 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -394,86 +394,31 @@ gBattleScriptsForMoveEffects:: .4byte BattleScript_EffectHyperspaceFury @ EFFECT_HYPERSPACE_FURY BattleScript_EffectHyperspaceFury: - jumpifspecies BS_ATTACKER, SPECIES_HOOPA_UNBOUND, BattleScript_EffectHyperspaceFuryUnbound - jumpifspecies BS_ATTACKER, SPECIES_HOOPA, BattleScript_ButHoopaCantUseIt + jumpifspecies BS_ATTACKER, SPECIES_TREECKO, BattleScript_EffectHyperspaceFuryUnbound + jumpifspecies BS_ATTACKER, SPECIES_MUDKIP, BattleScript_ButHoopaCantUseIt printstring STRINGID_BUTPOKEMONCANTUSETHEMOVE waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd + +BattleScript_EffectHyperspaceFuryUnbound:: + attackcanceler + accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE + attackstring + pause B_WAIT_TIME_LONG + ppreduce + setmoveeffect MOVE_EFFECT_FEINT + seteffectwithchance + setmoveeffect MOVE_EFFECT_DEF_MINUS_1 | MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_CERTAIN + goto BattleScript_HitFromCritCalc + BattleScript_ButHoopaCantUseIt: printstring STRINGID_BUTHOOPACANTUSEIT waitmessage B_WAIT_TIME_LONG goto BattleScript_MoveEnd -BattleScript_EffectHyperspaceFuryUnbound: - attackcanceler - jumpifprotected BS_TARGET, BattleScript_HyperspaceFuryBrokeThroughProtection - argumenttomoveeffect - accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE - attackstring - ppreduce - critcalc - damagecalc - adjustdamage - attackanimation - waitanimation - effectivenesssound - hitanimation BS_TARGET - waitstate - healthbarupdate BS_TARGET - datahpupdate BS_TARGET - critmessage - waitmessage B_WAIT_TIME_LONG - resultmessage - waitmessage B_WAIT_TIME_LONG - seteffectwithchance - tryfaintmon BS_TARGET, FALSE, NULL - swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler - setstatchanger STAT_DEF, 1, TRUE - statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_HyperspaceFuryTargetDefenseCantGoLower - setgraphicalstatchangevalues - playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 - printfromtable gStatDownStringIds - waitmessage B_WAIT_TIME_LONG - swapattackerwithtarget @ restore the battlers, just in case - goto BattleScript_MoveEnd -BattleScript_HyperspaceFuryBrokeThroughProtection:: - argumenttomoveeffect - accuracycheck BattleScript_PrintMoveMissed, ACC_CURR_MOVE - attackstring - ppreduce - pause B_WAIT_TIME_LONG +BattleScript_HyperspaceFuryRemoveProtect:: printstring STRINGID_BROKETHROUGHPROTECTION waitmessage B_WAIT_TIME_LONG - critcalc - damagecalc - adjustdamage - attackanimation - waitanimation - effectivenesssound - hitanimation BS_TARGET - waitstate - healthbarupdate BS_TARGET - datahpupdate BS_TARGET - critmessage - waitmessage B_WAIT_TIME_LONG - resultmessage - waitmessage B_WAIT_TIME_LONG - seteffectwithchance - tryfaintmon BS_TARGET, FALSE, NULL - swapattackerwithtarget @ to make gStatDownStringIds down below print the right battler - setstatchanger STAT_DEF, 1, TRUE - statbuffchange STAT_BUFF_NOT_PROTECT_AFFECTED, BattleScript_HyperspaceFuryTargetDefenseCantGoLower - setgraphicalstatchangevalues - playanimation BS_TARGET, B_ANIM_STATS_CHANGE, sB_ANIM_ARG1 - printfromtable gStatDownStringIds - waitmessage B_WAIT_TIME_LONG - swapattackerwithtarget @ restore the battlers, just in case - goto BattleScript_MoveEnd - return - -BattleScript_HyperspaceFuryTargetDefenseCantGoLower: - printstring STRINGID_STATSWONTDECREASE - waitmessage B_WAIT_TIME_LONG return BattleScript_EffectPlasmaFists: diff --git a/include/battle_scripts.h b/include/battle_scripts.h index 1994aef50..ec95a4549 100644 --- a/include/battle_scripts.h +++ b/include/battle_scripts.h @@ -401,5 +401,6 @@ extern const u8 BattleScript_AttackWeakenedByStrongWinds[]; extern const u8 BattleScript_BlockedByPrimalWeatherEnd3[]; extern const u8 BattleScript_BlockedByPrimalWeatherRet[]; extern const u8 BattleScript_PrimalReversion[]; +extern const u8 BattleScript_HyperspaceFuryRemoveProtect[]; #endif // GUARD_BATTLE_SCRIPTS_H diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index abce5f9bf..f00695276 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -194,7 +194,6 @@ #define VARIOUS_HANDLE_PRIMAL_REVERSION 121 #define VARIOUS_APPLY_PLASMA_FISTS 122 #define VARIOUS_JUMP_IF_SPECIES 123 -#define VARIOUS_JUMP_IF_PROTECTED 124 // Cmd_manipulatedamage #define DMG_CHANGE_SIGN 0 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index f99aec129..e41f0982a 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3278,15 +3278,7 @@ void SetMoveEffect(bool32 primary, u32 certain) } break; case MOVE_EFFECT_FEINT: - if (gProtectStructs[gBattlerTarget].protected - || gSideStatuses[GetBattlerSide(gBattlerTarget)] & SIDE_STATUS_WIDE_GUARD - || gSideStatuses[GetBattlerSide(gBattlerTarget)] & SIDE_STATUS_QUICK_GUARD - || gSideStatuses[GetBattlerSide(gBattlerTarget)] & SIDE_STATUS_CRAFTY_SHIELD - || gSideStatuses[GetBattlerSide(gBattlerTarget)] & SIDE_STATUS_MAT_BLOCK - || gProtectStructs[gBattlerTarget].spikyShielded - || gProtectStructs[gBattlerTarget].kingsShielded - || gProtectStructs[gBattlerTarget].banefulBunkered - || gProtectStructs[gBattlerTarget].obstructed) + if (IS_BATTLER_PROTECTED(gBattlerTarget)) { gProtectStructs[gBattlerTarget].protected = 0; gSideStatuses[GetBattlerSide(gBattlerTarget)] &= ~(SIDE_STATUS_WIDE_GUARD); @@ -3302,6 +3294,11 @@ void SetMoveEffect(bool32 primary, u32 certain) BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_MoveEffectFeint; } + else if (gCurrentMove == MOVE_HYPERSPACE_FURY) + { + BattleScriptPush(gBattlescriptCurrInstr + 1); + gBattlescriptCurrInstr = BattleScript_HyperspaceFuryRemoveProtect; + } } break; case MOVE_EFFECT_SPECTRAL_THIEF: @@ -8983,12 +8980,6 @@ static void Cmd_various(void) else gBattlescriptCurrInstr += 9; return; - case VARIOUS_JUMP_IF_PROTECTED: - if (IS_BATTLER_PROTECTED(gActiveBattler)) - gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); - else - gBattlescriptCurrInstr += 7; - return; } gBattlescriptCurrInstr += 3; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index 41f577a5b..93d8fcda9 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -9701,7 +9701,6 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = .priority = 0, .flags = FLAG_MIRROR_MOVE_AFFECTED | FLAG_KINGS_ROCK_AFFECTED | FLAG_HIT_IN_SUBSTITUTE, .split = SPLIT_PHYSICAL, - .argument = MOVE_EFFECT_FEINT, }, [MOVE_SHORE_UP] =