From bdbb4b5f7e79ddaf454af56c67dd8717be9115b9 Mon Sep 17 00:00:00 2001 From: BuffelSaft Date: Mon, 6 Sep 2021 18:27:42 +1200 Subject: [PATCH] Fix many Disguise bugs Use an unused hitmarker flag to indicate that an HP change shouldn't break Disguise. --- data/battle_scripts_1.s | 10 +++++----- include/constants/battle.h | 3 ++- src/battle_script_commands.c | 3 ++- src/battle_util.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index eef725903..b43afb5c6 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -2202,7 +2202,7 @@ BattleScript_EffectAbsorb:: waitmessage B_WAIT_TIME_LONG setdrainedhp manipulatedamage DMG_BIG_ROOT - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE jumpifability BS_TARGET, ABILITY_LIQUID_OOZE, BattleScript_AbsorbLiquidOoze setbyte cMULTISTRING_CHOOSER, B_MSG_ABSORB goto BattleScript_AbsorbUpdateHp @@ -2804,7 +2804,7 @@ BattleScript_MoveMissedDoDamage:: .else bichalfword gMoveResultFlags, MOVE_RESULT_MISSED .endif - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER tryfaintmon BS_ATTACKER, FALSE, NULL @@ -6570,7 +6570,7 @@ BattleScript_MoveEffectRecoil:: jumpifmove MOVE_STRUGGLE, BattleScript_DoRecoil jumpifability BS_ATTACKER, ABILITY_ROCK_HEAD, BattleScript_RecoilEnd BattleScript_DoRecoil:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_IGNORE_DISGUISE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER printstring STRINGID_PKMNHITWITHRECOIL @@ -7594,7 +7594,7 @@ BattleScript_AirBaloonMsgPop:: return BattleScript_ItemHurtRet:: - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_IGNORE_DISGUISE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER printstring STRINGID_HURTBYITEM @@ -7612,7 +7612,7 @@ BattleScript_ItemHealHP_Ret:: playanimation BS_ATTACKER, B_ANIM_HELD_ITEM_EFFECT, NULL printstring STRINGID_PKMNSITEMRESTOREDHPALITTLE waitmessage B_WAIT_TIME_LONG - orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE + orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE healthbarupdate BS_ATTACKER datahpupdate BS_ATTACKER return diff --git a/include/constants/battle.h b/include/constants/battle.h index b158076bd..73d5c3deb 100644 --- a/include/constants/battle.h +++ b/include/constants/battle.h @@ -185,7 +185,8 @@ #define HITMARKER_IGNORE_SAFEGUARD (1 << 13) #define HITMARKER_SYNCHRONISE_EFFECT (1 << 14) #define HITMARKER_RUN (1 << 15) -// 3 free spots because of change in handling of UNDERGROUND/UNDERGWATER/ON AIR +#define HITMARKER_IGNORE_DISGUISE (1 << 16) +// 3 free spots because of change in handling of UNDERGROUND/UNDERWATER/ON AIR #define HITMARKER_UNABLE_TO_USE_MOVE (1 << 19) #define HITMARKER_x100000 (1 << 20) #define HITMARKER_x200000 (1 << 21) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5d2249e03..26cd1e0e2 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -11869,7 +11869,8 @@ bool32 DoesDisguiseBlockMove(u8 battlerAtk, u8 battlerDef, u32 move) if (GetBattlerAbility(battlerDef) != ABILITY_DISGUISE || gBattleMons[battlerDef].species != SPECIES_MIMIKYU || gBattleMons[battlerDef].status2 & STATUS2_TRANSFORMED - || gBattleMoves[move].power == 0) + || gBattleMoves[move].power == 0 + || gHitMarker & HITMARKER_IGNORE_DISGUISE) return FALSE; else return TRUE; diff --git a/src/battle_util.c b/src/battle_util.c index c6f64d60a..5bd3ba2d2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -859,7 +859,7 @@ void HandleAction_ActionFinished(void) gHitMarker &= ~(HITMARKER_DESTINYBOND | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_ATTACKSTRING_PRINTED | HITMARKER_NO_PPDEDUCT | HITMARKER_IGNORE_SAFEGUARD | HITMARKER_x100000 | HITMARKER_OBEYS | HITMARKER_x10 | HITMARKER_SYNCHRONISE_EFFECT - | HITMARKER_CHARGING | HITMARKER_x4000000); + | HITMARKER_CHARGING | HITMARKER_x4000000 | HITMARKER_IGNORE_DISGUISE); gCurrentMove = 0; gBattleMoveDamage = 0;