From ee68f0f826ae686a8ad7e1348df8f45513e6707e Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Sat, 25 Apr 2020 11:17:59 +0200 Subject: [PATCH] Fix switch-in abilities when shift style switch --- data/battle_scripts_1.s | 16 ++++++++++++---- include/battle.h | 2 +- include/constants/battle_script_commands.h | 2 +- src/battle_script_commands.c | 6 +----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index a2a523c830..06642142e8 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -4921,6 +4921,7 @@ BattleScript_GiveExp:: end2 BattleScript_HandleFaintedMon:: + setbyte sSHIFT_SWITCHED, 0x0 atk24 BattleScript_82DA8F6 jumpifbyte CMP_NOT_EQUAL, gBattleOutcome, 0, BattleScript_FaintedMonEnd jumpifbattletype BATTLE_TYPE_TRAINER | BATTLE_TYPE_DOUBLE, BattleScript_FaintedMonTryChooseAnother @@ -4931,7 +4932,7 @@ BattleScript_HandleFaintedMon:: jumpifbyte CMP_EQUAL, gBattleCommunication + 1, 0x0, BattleScript_FaintedMonTryChooseAnother jumpifplayerran BattleScript_FaintedMonEnd printstring STRINGID_CANTESCAPE2 -BattleScript_FaintedMonTryChooseAnother:: +BattleScript_FaintedMonTryChooseAnother: openpartyscreen 0x3, BattleScript_FaintedMonEnd switchhandleorder BS_FAINTED, 0x2 jumpifnotbattletype BATTLE_TYPE_TRAINER, BattleScript_FaintedMonChooseAnother @@ -4966,9 +4967,8 @@ BattleScript_FaintedMonTryChooseAnother:: hidepartystatussummary BS_ATTACKER switchinanim BS_ATTACKER, 0x0 waitstate - switchineffects BS_ATTACKER - resetsentmonsvalue -BattleScript_FaintedMonChooseAnother:: + setbyte sSHIFT_SWITCHED, 0x1 +BattleScript_FaintedMonChooseAnother: drawpartystatussummary BS_FAINTED getswitchedmondata BS_FAINTED switchindataupdate BS_FAINTED @@ -4979,11 +4979,19 @@ BattleScript_FaintedMonChooseAnother:: waitstate various7 BS_ATTACKER trytrainerslidelastonmsg BS_FAINTED + jumpifbytenotequal sSHIFT_SWITCHED, sZero, BattleScript_FaintedMonShiftSwitched +BattleScript_FaintedMonChooseAnotherEnd: switchineffects BS_FAINTED jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_FaintedMonEnd cancelallactions BattleScript_FaintedMonEnd:: end2 +BattleScript_FaintedMonShiftSwitched: + copybyte sSAVED_BATTLER, gBattlerTarget + switchineffects BS_ATTACKER + resetsentmonsvalue + copybyte gBattlerTarget, sSAVED_BATTLER + goto BattleScript_FaintedMonChooseAnotherEnd BattleScript_82DA8F6:: openpartyscreen 0x5, BattleScript_82DA8FC diff --git a/include/battle.h b/include/battle.h index d59623410d..6a9ecd89c6 100644 --- a/include/battle.h +++ b/include/battle.h @@ -594,7 +594,7 @@ struct BattleScripting u16 tripleKickPower; u8 moveendState; u8 savedStatChanger; // For further use, if attempting to change stat two times(ex. Moody) - u8 unused_16; + u8 shiftSwitched; // When the game tells you the next enemy's pokemon and you switch. Option for noobs but oh well. u8 battler; u8 animTurn; u8 animTargetsHit; diff --git a/include/constants/battle_script_commands.h b/include/constants/battle_script_commands.h index 325e533577..71b3b1fca2 100644 --- a/include/constants/battle_script_commands.h +++ b/include/constants/battle_script_commands.h @@ -12,7 +12,7 @@ #define sTRIPLE_KICK_POWER gBattleScripting + 0x12 #define sMOVEEND_STATE gBattleScripting + 0x14 #define sSAVED_STAT_CHANGER gBattleScripting + 0x15 -#define sUNUSED_16 gBattleScripting + 0x16 +#define sSHIFT_SWITCHED gBattleScripting + 0x16 #define sBATTLER gBattleScripting + 0x17 #define sB_ANIM_TURN gBattleScripting + 0x18 #define sB_ANIM_TARGETS_HIT gBattleScripting + 0x19 diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 1757454665..e4d8ed6bc1 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7006,11 +7006,7 @@ static void Cmd_various(void) statId = (Random() % NUM_BATTLE_STATS) + 1; } while (!(bits & gBitTable[statId])); - if (gBattleMons[gActiveBattler].statStages[statId] >= 11) - SET_STATCHANGER(statId, 1, FALSE); - else - SET_STATCHANGER(statId, 2, FALSE); - + SET_STATCHANGER(statId, 2, FALSE); gBattlescriptCurrInstr += 7; } else