Change handlinf of forbidden moves for mimic metronome etc

This commit is contained in:
DizzyEggg 2020-04-11 13:22:35 +02:00
parent d28992d2ed
commit a2a9f259c8

View File

@ -735,47 +735,92 @@ static const struct SpriteTemplate sSpriteTemplate_MonIconOnLvlUpBox =
static const u16 sProtectSuccessRates[] = {USHRT_MAX, USHRT_MAX / 2, USHRT_MAX / 4, USHRT_MAX / 8}; static const u16 sProtectSuccessRates[] = {USHRT_MAX, USHRT_MAX / 2, USHRT_MAX / 4, USHRT_MAX / 8};
#define MIMIC_FORBIDDEN_END 0xFFFE #define FORBIDDEN_MIMIC 0x1
#define METRONOME_FORBIDDEN_END 0xFFFF #define FORBIDDEN_METRONOME 0x2
#define ASSIST_FORBIDDEN_END 0xFFFF #define FORBIDDEN_ASSIST 0x4
#define COPYCAT_FORBIDDEN_END 0xFFFF #define FORBIDDEN_COPYCAT 0x8
#define INSTRUCT_FORBIDDEN_END 0xFFFF #define FORBIDDEN_SLEEP_TALK 0x10
static const u16 sMovesForbiddenToCopy[] = #define FORBIDDEN_INSTRUCT_END 0xFFFF
static const u8 sForbiddenMoves[MOVES_COUNT] =
{ {
MOVE_TRANSFORM, [MOVE_NONE] = 0xFF, // Can't use a non-move lol
MOVE_METRONOME, [MOVE_STRUGGLE] = 0xFF, // Neither Struggle
MOVE_STRUGGLE, [MOVE_AFTER_YOU] = FORBIDDEN_METRONOME,
MOVE_SKETCH, [MOVE_ASSIST] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
MOVE_MIMIC, [MOVE_BANEFUL_BUNKER] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MIMIC_FORBIDDEN_END, [MOVE_BEAK_BLAST] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
MOVE_COUNTER, [MOVE_BELCH] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
MOVE_MIRROR_COAT, [MOVE_BESTOW] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_PROTECT, [MOVE_BIDE] = FORBIDDEN_SLEEP_TALK,
MOVE_DETECT, [MOVE_CELEBRATE] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
MOVE_ENDURE, [MOVE_CHATTER] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_MIMIC | FORBIDDEN_SLEEP_TALK,
MOVE_DESTINY_BOND, [MOVE_CIRCLE_THROW] = FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_SLEEP_TALK, [MOVE_COPYCAT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
MOVE_THIEF, [MOVE_COUNTER] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_FOLLOW_ME, [MOVE_COVET] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_SNATCH, [MOVE_CRAFTY_SHIELD] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_HELPING_HAND, [MOVE_DESTINY_BOND] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_COVET, [MOVE_DETECT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_TRICK, [MOVE_DIG] = FORBIDDEN_ASSIST,
MOVE_FOCUS_PUNCH, [MOVE_DIVE] = FORBIDDEN_ASSIST,
MOVE_CIRCLE_THROW, [MOVE_DRAGON_TAIL] = FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_DRAGON_TAIL, [MOVE_DIAMOND_STORM] = FORBIDDEN_METRONOME,
MOVE_RAGE_POWDER, [MOVE_ENDURE] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_MAT_BLOCK, [MOVE_FEINT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_SPIKY_SHIELD, [MOVE_FLEUR_CANNON] = FORBIDDEN_METRONOME,
MOVE_SHELL_TRAP, [MOVE_FLY] = FORBIDDEN_ASSIST,
MOVE_SPOTLIGHT, [MOVE_FOCUS_PUNCH] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
MOVE_FEINT, [MOVE_FOLLOW_ME] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
MOVE_KING_S_SHIELD, [MOVE_FREEZE_SHOCK] = FORBIDDEN_METRONOME,
METRONOME_FORBIDDEN_END [MOVE_HELPING_HAND] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_HOLD_HANDS] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
[MOVE_HYPERSPACE_FURY] = FORBIDDEN_METRONOME,
[MOVE_HYPERSPACE_HOLE] = FORBIDDEN_METRONOME,
[MOVE_ICE_BURN] = FORBIDDEN_METRONOME,
[MOVE_INSTRUCT] = FORBIDDEN_METRONOME,
[MOVE_KING_S_SHIELD] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_LIGHT_OF_RUIN] = FORBIDDEN_METRONOME,
[MOVE_MAT_BLOCK] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_ME_FIRST] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
[MOVE_METRONOME] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
[MOVE_MIMIC] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_MIMIC | FORBIDDEN_SLEEP_TALK,
[MOVE_MIRROR_COAT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_MIRROR_MOVE] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
[MOVE_NATURE_POWER] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
[MOVE_ORIGIN_PULSE] = FORBIDDEN_METRONOME,
[MOVE_PRECIPICE_BLADES] = FORBIDDEN_METRONOME,
[MOVE_PROTECT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_QUASH] = FORBIDDEN_METRONOME,
[MOVE_QUICK_GUARD] = FORBIDDEN_METRONOME,
[MOVE_RAGE_POWDER] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_RELIC_SONG] = FORBIDDEN_METRONOME,
[MOVE_ROAR] = FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_SECRET_SWORD] = FORBIDDEN_METRONOME,
[MOVE_SHELL_TRAP] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
[MOVE_SKETCH] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
[MOVE_SLEEP_TALK] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
[MOVE_SNARL] = FORBIDDEN_METRONOME,
[MOVE_SNATCH] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_SNORE] = FORBIDDEN_METRONOME,
[MOVE_SPECTRAL_THIEF] = FORBIDDEN_METRONOME,
[MOVE_SPIKY_SHIELD] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_SPOTLIGHT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST,
[MOVE_STEAM_ERUPTION] = FORBIDDEN_METRONOME,
[MOVE_SWITCHEROO] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_TECHNO_BLAST] = FORBIDDEN_METRONOME,
[MOVE_THIEF] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_THOUSAND_ARROWS] = FORBIDDEN_METRONOME,
[MOVE_THOUSAND_WAVES] = FORBIDDEN_METRONOME,
[MOVE_TRANSFORM] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_MIMIC,
[MOVE_TRICK] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_V_CREATE] = FORBIDDEN_METRONOME,
[MOVE_WIDE_GUARD] = FORBIDDEN_METRONOME,
[MOVE_WHIRLWIND] = FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
[MOVE_UPROAR] = FORBIDDEN_SLEEP_TALK,
}; };
static const u16 sMoveEffectsForbiddenToInstruct[] = static const u16 sMoveEffectsForbiddenToInstruct[] =
{ {
EFFECT_ASSIST, EFFECT_ASSIST,
@ -788,7 +833,6 @@ static const u16 sMoveEffectsForbiddenToInstruct[] =
EFFECT_METRONOME, EFFECT_METRONOME,
EFFECT_MIRROR_MOVE, EFFECT_MIRROR_MOVE,
EFFECT_NATURE_POWER, EFFECT_NATURE_POWER,
EFFECT_PLACEHOLDER,
EFFECT_RECHARGE, EFFECT_RECHARGE,
EFFECT_SEMI_INVULNERABLE, EFFECT_SEMI_INVULNERABLE,
//EFFECT_SHELL_TRAP, //EFFECT_SHELL_TRAP,
@ -799,7 +843,7 @@ static const u16 sMoveEffectsForbiddenToInstruct[] =
EFFECT_SOLARBEAM, EFFECT_SOLARBEAM,
EFFECT_TRANSFORM, EFFECT_TRANSFORM,
EFFECT_TWO_TURNS_ATTACK, EFFECT_TWO_TURNS_ATTACK,
INSTRUCT_FORBIDDEN_END FORBIDDEN_INSTRUCT_END
}; };
static const u16 sNaturePowerMoves[] = static const u16 sNaturePowerMoves[] =
@ -7435,12 +7479,7 @@ static void Cmd_various(void)
} }
return; return;
case VARIOUS_TRY_COPYCAT: case VARIOUS_TRY_COPYCAT:
for (i = 0; sMovesForbiddenToCopy[i] != COPYCAT_FORBIDDEN_END; i++) if (gLastUsedMove == 0xFFFF || (sForbiddenMoves[gLastUsedMove] & FORBIDDEN_COPYCAT))
{
if (sMovesForbiddenToCopy[i] == gLastUsedMove)
break;
}
if (gLastUsedMove == 0 || gLastUsedMove == 0xFFFF || sMovesForbiddenToCopy[i] != COPYCAT_FORBIDDEN_END)
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
} }
@ -7453,12 +7492,12 @@ static void Cmd_various(void)
} }
return; return;
case VARIOUS_TRY_INSTRUCT: case VARIOUS_TRY_INSTRUCT:
for (i = 0; sMoveEffectsForbiddenToInstruct[i] != INSTRUCT_FORBIDDEN_END; i++) for (i = 0; sMoveEffectsForbiddenToInstruct[i] != FORBIDDEN_INSTRUCT_END; i++)
{ {
if (sMoveEffectsForbiddenToInstruct[i] == gBattleMoves[gLastMoves[gBattlerTarget]].effect) if (sMoveEffectsForbiddenToInstruct[i] == gBattleMoves[gLastMoves[gBattlerTarget]].effect)
break; break;
} }
if (gLastMoves[gBattlerTarget] == 0 || gLastMoves[gBattlerTarget] == 0xFFFF || sMoveEffectsForbiddenToInstruct[i] != INSTRUCT_FORBIDDEN_END if (gLastMoves[gBattlerTarget] == 0 || gLastMoves[gBattlerTarget] == 0xFFFF || sMoveEffectsForbiddenToInstruct[i] != FORBIDDEN_INSTRUCT_END
|| gLastMoves[gBattlerTarget] == MOVE_STRUGGLE || gLastMoves[gBattlerTarget] == MOVE_KING_S_SHIELD) || gLastMoves[gBattlerTarget] == MOVE_STRUGGLE || gLastMoves[gBattlerTarget] == MOVE_KING_S_SHIELD)
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
@ -9167,22 +9206,10 @@ static void Cmd_setsubstitute(void)
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
} }
static bool8 IsMoveUncopyableByMimic(u16 move)
{
s32 i;
for (i = 0; sMovesForbiddenToCopy[i] != MIMIC_FORBIDDEN_END
&& sMovesForbiddenToCopy[i] != move; i++);
return (sMovesForbiddenToCopy[i] != MIMIC_FORBIDDEN_END);
}
static void Cmd_mimicattackcopy(void) static void Cmd_mimicattackcopy(void)
{ {
gChosenMove = 0xFFFF; if ((sForbiddenMoves[gLastMoves[gBattlerTarget]] & FORBIDDEN_MIMIC)
|| (gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED)
if (IsMoveUncopyableByMimic(gLastMoves[gBattlerTarget])
|| gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED
|| gLastMoves[gBattlerTarget] == 0
|| gLastMoves[gBattlerTarget] == 0xFFFF) || gLastMoves[gBattlerTarget] == 0xFFFF)
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
@ -9199,13 +9226,13 @@ static void Cmd_mimicattackcopy(void)
if (i == MAX_MON_MOVES) if (i == MAX_MON_MOVES)
{ {
gChosenMove = 0xFFFF;
gBattleMons[gBattlerAttacker].moves[gCurrMovePos] = gLastMoves[gBattlerTarget]; gBattleMons[gBattlerAttacker].moves[gCurrMovePos] = gLastMoves[gBattlerTarget];
if (gBattleMoves[gLastMoves[gBattlerTarget]].pp < 5) if (gBattleMoves[gLastMoves[gBattlerTarget]].pp < 5)
gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBattlerTarget]].pp; gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBattlerTarget]].pp;
else else
gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = 5; gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = 5;
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattlerTarget]) PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattlerTarget])
gDisableStructs[gBattlerAttacker].mimickedMoves |= gBitTable[gCurrMovePos]; gDisableStructs[gBattlerAttacker].mimickedMoves |= gBitTable[gCurrMovePos];
@ -9222,23 +9249,11 @@ static void Cmd_metronome(void)
{ {
while (1) while (1)
{ {
s32 i;
gCurrentMove = (Random() % (MOVES_COUNT - 1)) + 1; gCurrentMove = (Random() % (MOVES_COUNT - 1)) + 1;
if (gBattleMoves[gCurrentMove].effect == EFFECT_PLACEHOLDER) if (gBattleMoves[gCurrentMove].effect == EFFECT_PLACEHOLDER)
continue; continue;
i = -1; if (!(sForbiddenMoves[gCurrentMove] & FORBIDDEN_METRONOME))
while (1)
{
i++;
if (sMovesForbiddenToCopy[i] == gCurrentMove)
break;
if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END)
break;
}
if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END)
{ {
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
@ -9518,15 +9533,6 @@ static bool8 IsTwoTurnsMove(u16 move)
return FALSE; return FALSE;
} }
static bool8 IsInvalidForSleepTalkOrAssist(u16 move)
{
if (move == 0 || move == MOVE_SLEEP_TALK || move == MOVE_ASSIST
|| move == MOVE_MIRROR_MOVE || move == MOVE_METRONOME)
return TRUE;
else
return FALSE;
}
static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2 static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2
{ {
// first argument is unused // first argument is unused
@ -9548,19 +9554,15 @@ static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a c
static void Cmd_trychoosesleeptalkmove(void) static void Cmd_trychoosesleeptalkmove(void)
{ {
s32 i; u32 i, unusableMovesBits = 0, movePosition;
u8 unusableMovesBits = 0;
for (i = 0; i < MAX_MON_MOVES; i++) for (i = 0; i < MAX_MON_MOVES; i++)
{ {
if (IsInvalidForSleepTalkOrAssist(gBattleMons[gBattlerAttacker].moves[i]) if ((sForbiddenMoves[gBattleMons[gBattlerAttacker].moves[i]] & FORBIDDEN_SLEEP_TALK)
|| gBattleMons[gBattlerAttacker].moves[i] == MOVE_FOCUS_PUNCH
|| gBattleMons[gBattlerAttacker].moves[i] == MOVE_UPROAR
|| IsTwoTurnsMove(gBattleMons[gBattlerAttacker].moves[i])) || IsTwoTurnsMove(gBattleMons[gBattlerAttacker].moves[i]))
{ {
unusableMovesBits |= gBitTable[i]; unusableMovesBits |= gBitTable[i];
} }
} }
unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP)); unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP));
@ -9570,8 +9572,6 @@ static void Cmd_trychoosesleeptalkmove(void)
} }
else // at least one move can be chosen else // at least one move can be chosen
{ {
u32 movePosition;
do do
{ {
movePosition = Random() & 3; movePosition = Random() & 3;
@ -10833,14 +10833,7 @@ static void Cmd_assistattackselect(void)
s32 i = 0; s32 i = 0;
u16 move = GetMonData(&party[monId], MON_DATA_MOVE1 + moveId); u16 move = GetMonData(&party[monId], MON_DATA_MOVE1 + moveId);
if (IsInvalidForSleepTalkOrAssist(move)) if (sForbiddenMoves[move] & FORBIDDEN_ASSIST)
continue;
for (; sMovesForbiddenToCopy[i] != ASSIST_FORBIDDEN_END && move != sMovesForbiddenToCopy[i]; i++);
if (sMovesForbiddenToCopy[i] != ASSIST_FORBIDDEN_END)
continue;
if (move == MOVE_NONE)
continue; continue;
movesArray[chooseableMovesNo] = move; movesArray[chooseableMovesNo] = move;