Fix Z mirror move (#4308)

This commit is contained in:
DizzyEggg 2024-03-29 11:33:28 +01:00 committed by GitHub
parent 6abd75b055
commit 4a8551247a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 7 deletions

View file

@ -21,6 +21,7 @@ void CreateZMoveTriggerSprite(u8, bool8);
void HideZMoveTriggerSprite(void);
bool32 IsZMoveTriggerSpriteActive(void);
void DestroyZMoveTriggerSprite(void);
u16 GetTypeBasedZMove(u16 move, u8 battler);
bool32 MoveSelectionDisplayZMove(u16 zmove, u32 battler);
void SetZEffect(void);
bool32 IsZMoveUsable(u8 battler, u16 moveIndex);

View file

@ -10981,7 +10981,17 @@ static void Cmd_tryhealhalfhealth(void)
static void SetMoveForMirrorMove(u32 move)
{
gHitMarker &= ~HITMARKER_ATTACKSTRING_PRINTED;
gCurrentMove = move;
// Edge case, we used Z Mirror Move, got the stat boost and now need to use the Z-move
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] && !IS_MOVE_STATUS(move))
{
gCurrentMove = gBattleStruct->zmove.chosenZMove = GetTypeBasedZMove(move, gBattlerAttacker);
QueueZMove(gBattlerAttacker, move);
}
else
{
gCurrentMove = move;
}
SetAtkCancellerForCalledMove();
gBattlerTarget = GetMoveTarget(gCurrentMove, NO_TARGET_OVERRIDE);
gBattlescriptCurrInstr = GET_MOVE_BATTLESCRIPT(gCurrentMove);

View file

@ -3518,6 +3518,9 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
case CANCELLER_Z_MOVES:
if (gBattleStruct->zmove.toBeUsed[gBattlerAttacker] != MOVE_NONE)
{
// For Z-Mirror Move, so it doesn't play the animation twice.
bool32 alreadyUsed = (gBattleStruct->zmove.used[gBattlerAttacker] == TRUE);
//attacker has a queued z move
gBattleStruct->zmove.active = TRUE;
gBattleStruct->zmove.activeCategory = gBattleStruct->zmove.categories[gBattlerAttacker];
@ -3530,13 +3533,19 @@ u8 AtkCanceller_UnableToUseMove(u32 moveType)
if (gBattleStruct->zmove.activeCategory == DAMAGE_CATEGORY_STATUS)
{
gBattleStruct->zmove.effect = gMovesInfo[gBattleStruct->zmove.baseMoves[gBattlerAttacker]].zMove.effect;
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ZMoveActivateStatus;
if (!alreadyUsed)
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ZMoveActivateStatus;
}
}
else
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ZMoveActivateDamaging;
if (!alreadyUsed)
{
BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ZMoveActivateDamaging;
}
}
effect = 1;
}

View file

@ -47,7 +47,6 @@
// Function Declarations
static void SpriteCB_ZMoveTrigger(struct Sprite *sprite);
static u16 GetSignatureZMove(u16 move, u16 species, u16 item);
static u16 GetTypeBasedZMove(u16 move, u8 battler);
static void ZMoveSelectionDisplayPpNumber(u32 battler);
static void ZMoveSelectionDisplayPower(u16 move, u16 zMove);
static void ShowZMoveTriggerSprite(u8 battleId);
@ -376,7 +375,7 @@ static u16 GetSignatureZMove(u16 move, u16 species, u16 item)
return MOVE_NONE;
}
static u16 GetTypeBasedZMove(u16 move, u8 battler)
u16 GetTypeBasedZMove(u16 move, u8 battler)
{
u8 moveType = gMovesInfo[move].type;