mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 19:54:21 +01:00
Change handlinf of forbidden moves for mimic metronome etc
This commit is contained in:
parent
d28992d2ed
commit
a2a9f259c8
@ -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};
|
||||
|
||||
#define MIMIC_FORBIDDEN_END 0xFFFE
|
||||
#define METRONOME_FORBIDDEN_END 0xFFFF
|
||||
#define ASSIST_FORBIDDEN_END 0xFFFF
|
||||
#define COPYCAT_FORBIDDEN_END 0xFFFF
|
||||
#define INSTRUCT_FORBIDDEN_END 0xFFFF
|
||||
#define FORBIDDEN_MIMIC 0x1
|
||||
#define FORBIDDEN_METRONOME 0x2
|
||||
#define FORBIDDEN_ASSIST 0x4
|
||||
#define FORBIDDEN_COPYCAT 0x8
|
||||
#define FORBIDDEN_SLEEP_TALK 0x10
|
||||
|
||||
static const u16 sMovesForbiddenToCopy[] =
|
||||
#define FORBIDDEN_INSTRUCT_END 0xFFFF
|
||||
|
||||
static const u8 sForbiddenMoves[MOVES_COUNT] =
|
||||
{
|
||||
MOVE_TRANSFORM,
|
||||
MOVE_METRONOME,
|
||||
MOVE_STRUGGLE,
|
||||
MOVE_SKETCH,
|
||||
MOVE_MIMIC,
|
||||
MIMIC_FORBIDDEN_END,
|
||||
MOVE_COUNTER,
|
||||
MOVE_MIRROR_COAT,
|
||||
MOVE_PROTECT,
|
||||
MOVE_DETECT,
|
||||
MOVE_ENDURE,
|
||||
MOVE_DESTINY_BOND,
|
||||
MOVE_SLEEP_TALK,
|
||||
MOVE_THIEF,
|
||||
MOVE_FOLLOW_ME,
|
||||
MOVE_SNATCH,
|
||||
MOVE_HELPING_HAND,
|
||||
MOVE_COVET,
|
||||
MOVE_TRICK,
|
||||
MOVE_FOCUS_PUNCH,
|
||||
MOVE_CIRCLE_THROW,
|
||||
MOVE_DRAGON_TAIL,
|
||||
MOVE_RAGE_POWDER,
|
||||
MOVE_MAT_BLOCK,
|
||||
MOVE_SPIKY_SHIELD,
|
||||
MOVE_SHELL_TRAP,
|
||||
MOVE_SPOTLIGHT,
|
||||
MOVE_FEINT,
|
||||
MOVE_KING_S_SHIELD,
|
||||
METRONOME_FORBIDDEN_END
|
||||
[MOVE_NONE] = 0xFF, // Can't use a non-move lol
|
||||
[MOVE_STRUGGLE] = 0xFF, // Neither Struggle
|
||||
[MOVE_AFTER_YOU] = FORBIDDEN_METRONOME,
|
||||
[MOVE_ASSIST] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
|
||||
[MOVE_BANEFUL_BUNKER] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_BEAK_BLAST] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
|
||||
[MOVE_BELCH] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
|
||||
[MOVE_BESTOW] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_BIDE] = FORBIDDEN_SLEEP_TALK,
|
||||
[MOVE_CELEBRATE] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
|
||||
[MOVE_CHATTER] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_MIMIC | FORBIDDEN_SLEEP_TALK,
|
||||
[MOVE_CIRCLE_THROW] = FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_COPYCAT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
|
||||
[MOVE_COUNTER] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_COVET] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_CRAFTY_SHIELD] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_DESTINY_BOND] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_DETECT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_DIG] = FORBIDDEN_ASSIST,
|
||||
[MOVE_DIVE] = FORBIDDEN_ASSIST,
|
||||
[MOVE_DRAGON_TAIL] = FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_DIAMOND_STORM] = FORBIDDEN_METRONOME,
|
||||
[MOVE_ENDURE] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_FEINT] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_FLEUR_CANNON] = FORBIDDEN_METRONOME,
|
||||
[MOVE_FLY] = FORBIDDEN_ASSIST,
|
||||
[MOVE_FOCUS_PUNCH] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT | FORBIDDEN_SLEEP_TALK,
|
||||
[MOVE_FOLLOW_ME] = FORBIDDEN_METRONOME | FORBIDDEN_ASSIST | FORBIDDEN_COPYCAT,
|
||||
[MOVE_FREEZE_SHOCK] = FORBIDDEN_METRONOME,
|
||||
[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[] =
|
||||
{
|
||||
EFFECT_ASSIST,
|
||||
@ -788,7 +833,6 @@ static const u16 sMoveEffectsForbiddenToInstruct[] =
|
||||
EFFECT_METRONOME,
|
||||
EFFECT_MIRROR_MOVE,
|
||||
EFFECT_NATURE_POWER,
|
||||
EFFECT_PLACEHOLDER,
|
||||
EFFECT_RECHARGE,
|
||||
EFFECT_SEMI_INVULNERABLE,
|
||||
//EFFECT_SHELL_TRAP,
|
||||
@ -799,7 +843,7 @@ static const u16 sMoveEffectsForbiddenToInstruct[] =
|
||||
EFFECT_SOLARBEAM,
|
||||
EFFECT_TRANSFORM,
|
||||
EFFECT_TWO_TURNS_ATTACK,
|
||||
INSTRUCT_FORBIDDEN_END
|
||||
FORBIDDEN_INSTRUCT_END
|
||||
};
|
||||
|
||||
static const u16 sNaturePowerMoves[] =
|
||||
@ -7435,12 +7479,7 @@ static void Cmd_various(void)
|
||||
}
|
||||
return;
|
||||
case VARIOUS_TRY_COPYCAT:
|
||||
for (i = 0; sMovesForbiddenToCopy[i] != COPYCAT_FORBIDDEN_END; i++)
|
||||
{
|
||||
if (sMovesForbiddenToCopy[i] == gLastUsedMove)
|
||||
break;
|
||||
}
|
||||
if (gLastUsedMove == 0 || gLastUsedMove == 0xFFFF || sMovesForbiddenToCopy[i] != COPYCAT_FORBIDDEN_END)
|
||||
if (gLastUsedMove == 0xFFFF || (sForbiddenMoves[gLastUsedMove] & FORBIDDEN_COPYCAT))
|
||||
{
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
}
|
||||
@ -7453,12 +7492,12 @@ static void Cmd_various(void)
|
||||
}
|
||||
return;
|
||||
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)
|
||||
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)
|
||||
{
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
|
||||
@ -9167,22 +9206,10 @@ static void Cmd_setsubstitute(void)
|
||||
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)
|
||||
{
|
||||
gChosenMove = 0xFFFF;
|
||||
|
||||
if (IsMoveUncopyableByMimic(gLastMoves[gBattlerTarget])
|
||||
|| gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED
|
||||
|| gLastMoves[gBattlerTarget] == 0
|
||||
if ((sForbiddenMoves[gLastMoves[gBattlerTarget]] & FORBIDDEN_MIMIC)
|
||||
|| (gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED)
|
||||
|| gLastMoves[gBattlerTarget] == 0xFFFF)
|
||||
{
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
|
||||
@ -9199,13 +9226,13 @@ static void Cmd_mimicattackcopy(void)
|
||||
|
||||
if (i == MAX_MON_MOVES)
|
||||
{
|
||||
gChosenMove = 0xFFFF;
|
||||
gBattleMons[gBattlerAttacker].moves[gCurrMovePos] = gLastMoves[gBattlerTarget];
|
||||
if (gBattleMoves[gLastMoves[gBattlerTarget]].pp < 5)
|
||||
gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBattlerTarget]].pp;
|
||||
else
|
||||
gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = 5;
|
||||
|
||||
|
||||
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattlerTarget])
|
||||
|
||||
gDisableStructs[gBattlerAttacker].mimickedMoves |= gBitTable[gCurrMovePos];
|
||||
@ -9222,23 +9249,11 @@ static void Cmd_metronome(void)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
gCurrentMove = (Random() % (MOVES_COUNT - 1)) + 1;
|
||||
if (gBattleMoves[gCurrentMove].effect == EFFECT_PLACEHOLDER)
|
||||
continue;
|
||||
|
||||
i = -1;
|
||||
while (1)
|
||||
{
|
||||
i++;
|
||||
if (sMovesForbiddenToCopy[i] == gCurrentMove)
|
||||
break;
|
||||
if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END)
|
||||
break;
|
||||
}
|
||||
|
||||
if (sMovesForbiddenToCopy[i] == METRONOME_FORBIDDEN_END)
|
||||
if (!(sForbiddenMoves[gCurrentMove] & FORBIDDEN_METRONOME))
|
||||
{
|
||||
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
|
||||
gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect];
|
||||
@ -9518,15 +9533,6 @@ static bool8 IsTwoTurnsMove(u16 move)
|
||||
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
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
s32 i;
|
||||
u8 unusableMovesBits = 0;
|
||||
u32 i, unusableMovesBits = 0, movePosition;
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (IsInvalidForSleepTalkOrAssist(gBattleMons[gBattlerAttacker].moves[i])
|
||||
|| gBattleMons[gBattlerAttacker].moves[i] == MOVE_FOCUS_PUNCH
|
||||
|| gBattleMons[gBattlerAttacker].moves[i] == MOVE_UPROAR
|
||||
if ((sForbiddenMoves[gBattleMons[gBattlerAttacker].moves[i]] & FORBIDDEN_SLEEP_TALK)
|
||||
|| IsTwoTurnsMove(gBattleMons[gBattlerAttacker].moves[i]))
|
||||
{
|
||||
unusableMovesBits |= gBitTable[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP));
|
||||
@ -9570,8 +9572,6 @@ static void Cmd_trychoosesleeptalkmove(void)
|
||||
}
|
||||
else // at least one move can be chosen
|
||||
{
|
||||
u32 movePosition;
|
||||
|
||||
do
|
||||
{
|
||||
movePosition = Random() & 3;
|
||||
@ -10833,14 +10833,7 @@ static void Cmd_assistattackselect(void)
|
||||
s32 i = 0;
|
||||
u16 move = GetMonData(&party[monId], MON_DATA_MOVE1 + moveId);
|
||||
|
||||
if (IsInvalidForSleepTalkOrAssist(move))
|
||||
continue;
|
||||
|
||||
for (; sMovesForbiddenToCopy[i] != ASSIST_FORBIDDEN_END && move != sMovesForbiddenToCopy[i]; i++);
|
||||
|
||||
if (sMovesForbiddenToCopy[i] != ASSIST_FORBIDDEN_END)
|
||||
continue;
|
||||
if (move == MOVE_NONE)
|
||||
if (sForbiddenMoves[move] & FORBIDDEN_ASSIST)
|
||||
continue;
|
||||
|
||||
movesArray[chooseableMovesNo] = move;
|
||||
|
Loading…
Reference in New Issue
Block a user