mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-17 03:57:38 +01:00
Fix protect-like moves
Make Protect-like moves (King's Shield etc.) activate only if the attacker would've touched the target. This does not handle Sucker Punch, because that's not working correctly with Protect currently and will need to be addressed separately.
This commit is contained in:
parent
38120afbac
commit
ea6ce80ad4
@ -100,6 +100,7 @@ struct DisableStruct
|
|||||||
u8 truantCounter:1;
|
u8 truantCounter:1;
|
||||||
u8 truantSwitchInHack:1;
|
u8 truantSwitchInHack:1;
|
||||||
u8 mimickedMoves:4;
|
u8 mimickedMoves:4;
|
||||||
|
u8 touchedProtectLike: 1;
|
||||||
u8 rechargeTimer;
|
u8 rechargeTimer;
|
||||||
u8 autotomizeCount;
|
u8 autotomizeCount;
|
||||||
u8 slowStartTimer;
|
u8 slowStartTimer;
|
||||||
|
@ -1454,6 +1454,8 @@ static void Cmd_attackcanceler(void)
|
|||||||
&& (gCurrentMove != MOVE_CURSE || IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_GHOST))
|
&& (gCurrentMove != MOVE_CURSE || IS_BATTLER_OF_TYPE(gBattlerAttacker, TYPE_GHOST))
|
||||||
&& ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))))
|
&& ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS))))
|
||||||
{
|
{
|
||||||
|
if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT)
|
||||||
|
gDisableStructs[gBattlerAttacker].touchedProtectLike = 1;
|
||||||
CancelMultiTurnMoves(gBattlerAttacker);
|
CancelMultiTurnMoves(gBattlerAttacker);
|
||||||
gMoveResultFlags |= MOVE_RESULT_MISSED;
|
gMoveResultFlags |= MOVE_RESULT_MISSED;
|
||||||
gLastLandedMoves[gBattlerTarget] = 0;
|
gLastLandedMoves[gBattlerTarget] = 0;
|
||||||
@ -4776,10 +4778,11 @@ static void Cmd_moveend(void)
|
|||||||
switch (gBattleScripting.moveendState)
|
switch (gBattleScripting.moveendState)
|
||||||
{
|
{
|
||||||
case MOVEEND_PROTECT_LIKE_EFFECT:
|
case MOVEEND_PROTECT_LIKE_EFFECT:
|
||||||
if (gBattleMoves[gCurrentMove].flags & FLAG_MAKES_CONTACT)
|
if (gDisableStructs[gBattlerAttacker].touchedProtectLike)
|
||||||
{
|
{
|
||||||
if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
|
if (gProtectStructs[gBattlerTarget].spikyShielded && GetBattlerAbility(gBattlerAttacker) != ABILITY_MAGIC_GUARD)
|
||||||
{
|
{
|
||||||
|
gDisableStructs[gBattlerAttacker].touchedProtectLike = 0;
|
||||||
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8;
|
gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 8;
|
||||||
if (gBattleMoveDamage == 0)
|
if (gBattleMoveDamage == 0)
|
||||||
gBattleMoveDamage = 1;
|
gBattleMoveDamage = 1;
|
||||||
@ -4790,6 +4793,7 @@ static void Cmd_moveend(void)
|
|||||||
}
|
}
|
||||||
else if (gProtectStructs[gBattlerTarget].kingsShielded)
|
else if (gProtectStructs[gBattlerTarget].kingsShielded)
|
||||||
{
|
{
|
||||||
|
gDisableStructs[gBattlerAttacker].touchedProtectLike = 0;
|
||||||
i = gBattlerAttacker;
|
i = gBattlerAttacker;
|
||||||
gBattlerAttacker = gBattlerTarget;
|
gBattlerAttacker = gBattlerTarget;
|
||||||
gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable
|
gBattlerTarget = i; // gBattlerTarget and gBattlerAttacker are swapped in order to activate Defiant, if applicable
|
||||||
@ -4800,6 +4804,7 @@ static void Cmd_moveend(void)
|
|||||||
}
|
}
|
||||||
else if (gProtectStructs[gBattlerTarget].banefulBunkered)
|
else if (gProtectStructs[gBattlerTarget].banefulBunkered)
|
||||||
{
|
{
|
||||||
|
gDisableStructs[gBattlerAttacker].touchedProtectLike = 0;
|
||||||
gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER;
|
gBattleScripting.moveEffect = MOVE_EFFECT_POISON | MOVE_EFFECT_AFFECTS_USER;
|
||||||
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_BANEFUL_BUNKER);
|
PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_BANEFUL_BUNKER);
|
||||||
BattleScriptPushCursor();
|
BattleScriptPushCursor();
|
||||||
|
Loading…
Reference in New Issue
Block a user