mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-27 22:03:53 +01:00
Implement Leaf Guard.
This commit is contained in:
parent
a61f282668
commit
029ab67ff4
@ -1782,3 +1782,9 @@
|
|||||||
goto \jumpptr
|
goto \jumpptr
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
.macro jumpifleafguard jumpptr:req
|
||||||
|
jumpifhalfword CMP_NO_COMMON_BITS, gBattleWeather, WEATHER_SUN_ANY, 1f
|
||||||
|
jumpifability BS_TARGET, ABILITY_LEAF_GUARD, \jumpptr
|
||||||
|
1:
|
||||||
|
.endm
|
||||||
|
|
||||||
|
@ -2002,6 +2002,7 @@ BattleScript_EffectSleep::
|
|||||||
jumpifcantmakeasleep BattleScript_CantMakeAsleep
|
jumpifcantmakeasleep BattleScript_CantMakeAsleep
|
||||||
jumpifflowerveil BattleScript_FlowerVeilProtects
|
jumpifflowerveil BattleScript_FlowerVeilProtects
|
||||||
jumpifability BS_TARGET_SIDE, ABILITY_SWEET_VEIL, BattleScript_SweetVeilProtects
|
jumpifability BS_TARGET_SIDE, ABILITY_SWEET_VEIL, BattleScript_SweetVeilProtects
|
||||||
|
jumpifleafguard BattleScript_LeafGuardProtects
|
||||||
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
||||||
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
||||||
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
|
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
|
||||||
@ -2047,6 +2048,18 @@ BattleScript_AromaVeilProtects:
|
|||||||
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
|
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
|
||||||
goto BattleScript_MoveEnd
|
goto BattleScript_MoveEnd
|
||||||
|
|
||||||
|
BattleScript_LeafGuardProtectsRet::
|
||||||
|
pause 0x20
|
||||||
|
call BattleScript_AbilityPopUp
|
||||||
|
printstring STRINGID_ITDOESNTAFFECT
|
||||||
|
waitmessage 0x40
|
||||||
|
return
|
||||||
|
|
||||||
|
BattleScript_LeafGuardProtects:
|
||||||
|
call BattleScript_LeafGuardProtectsRet
|
||||||
|
orhalfword gMoveResultFlags, MOVE_RESULT_FAILED
|
||||||
|
goto BattleScript_MoveEnd
|
||||||
|
|
||||||
BattleScript_AlreadyAsleep::
|
BattleScript_AlreadyAsleep::
|
||||||
setalreadystatusedmoveattempt BS_ATTACKER
|
setalreadystatusedmoveattempt BS_ATTACKER
|
||||||
pause 0x20
|
pause 0x20
|
||||||
@ -2487,6 +2500,7 @@ BattleScript_EffectToxic::
|
|||||||
ppreduce
|
ppreduce
|
||||||
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
|
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
|
||||||
jumpifflowerveil BattleScript_FlowerVeilProtects
|
jumpifflowerveil BattleScript_FlowerVeilProtects
|
||||||
|
jumpifleafguard BattleScript_LeafGuardProtects
|
||||||
jumpifsubstituteblocks BattleScript_ButItFailed
|
jumpifsubstituteblocks BattleScript_ButItFailed
|
||||||
jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
|
jumpifstatus BS_TARGET, STATUS1_POISON | STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
|
||||||
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
||||||
@ -2813,6 +2827,7 @@ BattleScript_EffectPoison::
|
|||||||
ppreduce
|
ppreduce
|
||||||
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
|
jumpifability BS_TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected
|
||||||
jumpifflowerveil BattleScript_FlowerVeilProtects
|
jumpifflowerveil BattleScript_FlowerVeilProtects
|
||||||
|
jumpifleafguard BattleScript_LeafGuardProtects
|
||||||
jumpifsubstituteblocks BattleScript_ButItFailed
|
jumpifsubstituteblocks BattleScript_ButItFailed
|
||||||
jumpifstatus BS_TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned
|
jumpifstatus BS_TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned
|
||||||
jumpifstatus BS_TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
|
jumpifstatus BS_TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned
|
||||||
@ -2835,6 +2850,7 @@ BattleScript_EffectParalyze:
|
|||||||
ppreduce
|
ppreduce
|
||||||
jumpifability BS_TARGET, ABILITY_LIMBER, BattleScript_LimberProtected
|
jumpifability BS_TARGET, ABILITY_LIMBER, BattleScript_LimberProtected
|
||||||
jumpifflowerveil BattleScript_FlowerVeilProtects
|
jumpifflowerveil BattleScript_FlowerVeilProtects
|
||||||
|
jumpifleafguard BattleScript_LeafGuardProtects
|
||||||
jumpifsubstituteblocks BattleScript_ButItFailed
|
jumpifsubstituteblocks BattleScript_ButItFailed
|
||||||
typecalc
|
typecalc
|
||||||
jumpifmovehadnoeffect BattleScript_ButItFailed
|
jumpifmovehadnoeffect BattleScript_ButItFailed
|
||||||
@ -4064,6 +4080,7 @@ BattleScript_EffectWillOWisp::
|
|||||||
jumpiftype BS_TARGET, TYPE_FIRE, BattleScript_NotAffected
|
jumpiftype BS_TARGET, TYPE_FIRE, BattleScript_NotAffected
|
||||||
jumpifability BS_TARGET, ABILITY_WATER_VEIL, BattleScript_WaterVeilPrevents
|
jumpifability BS_TARGET, ABILITY_WATER_VEIL, BattleScript_WaterVeilPrevents
|
||||||
jumpifflowerveil BattleScript_FlowerVeilProtects
|
jumpifflowerveil BattleScript_FlowerVeilProtects
|
||||||
|
jumpifleafguard BattleScript_LeafGuardProtects
|
||||||
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
jumpifstatus BS_TARGET, STATUS1_ANY, BattleScript_ButItFailed
|
||||||
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE
|
||||||
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
|
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
|
||||||
@ -4327,6 +4344,7 @@ BattleScript_EffectYawn::
|
|||||||
jumpifability BS_TARGET, ABILITY_VITAL_SPIRIT, BattleScript_PrintBankAbilityMadeIneffective
|
jumpifability BS_TARGET, ABILITY_VITAL_SPIRIT, BattleScript_PrintBankAbilityMadeIneffective
|
||||||
jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_PrintBankAbilityMadeIneffective
|
jumpifability BS_TARGET, ABILITY_INSOMNIA, BattleScript_PrintBankAbilityMadeIneffective
|
||||||
jumpifflowerveil BattleScript_FlowerVeilProtects
|
jumpifflowerveil BattleScript_FlowerVeilProtects
|
||||||
|
jumpifleafguard BattleScript_LeafGuardProtects
|
||||||
jumpifsubstituteblocks BattleScript_ButItFailed
|
jumpifsubstituteblocks BattleScript_ButItFailed
|
||||||
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
|
jumpifsideaffecting BS_TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected
|
||||||
accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON
|
accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON
|
||||||
|
@ -16,6 +16,7 @@ bool8 UproarWakeUpCheck(u8 battlerId);
|
|||||||
bool32 DoesSubstituteBlockMove(u8 battlerAtk, u8 battlerDef, u32 move);
|
bool32 DoesSubstituteBlockMove(u8 battlerAtk, u8 battlerDef, u32 move);
|
||||||
bool32 CanUseLastResort(u8 battlerId);
|
bool32 CanUseLastResort(u8 battlerId);
|
||||||
u32 IsFlowerVeilProtected(u32 battler);
|
u32 IsFlowerVeilProtected(u32 battler);
|
||||||
|
u32 IsLeafGuardProtected(u32 battler);
|
||||||
|
|
||||||
extern void (* const gBattleScriptingCommandsTable[])(void);
|
extern void (* const gBattleScriptingCommandsTable[])(void);
|
||||||
extern const u8 gUnknown_0831C494[][4];
|
extern const u8 gUnknown_0831C494[][4];
|
||||||
|
@ -2151,7 +2151,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
if (GetBattlerAbility(gEffectBattler) == ABILITY_VITAL_SPIRIT
|
if (GetBattlerAbility(gEffectBattler) == ABILITY_VITAL_SPIRIT
|
||||||
|| GetBattlerAbility(gEffectBattler) == ABILITY_INSOMNIA
|
|| GetBattlerAbility(gEffectBattler) == ABILITY_INSOMNIA
|
||||||
|| IsAbilityOnSide(gEffectBattler, ABILITY_SWEET_VEIL)
|
|| IsAbilityOnSide(gEffectBattler, ABILITY_SWEET_VEIL)
|
||||||
|| IsFlowerVeilProtected(gEffectBattler))
|
|| IsFlowerVeilProtected(gEffectBattler)
|
||||||
|
|| IsLeafGuardProtected(gEffectBattler))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CancelMultiTurnMoves(gEffectBattler);
|
CancelMultiTurnMoves(gEffectBattler);
|
||||||
@ -2194,7 +2195,9 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
break;
|
break;
|
||||||
if (gBattleMons[gEffectBattler].status1)
|
if (gBattleMons[gEffectBattler].status1)
|
||||||
break;
|
break;
|
||||||
if (GetBattlerAbility(gEffectBattler) == ABILITY_IMMUNITY || IsFlowerVeilProtected(gEffectBattler))
|
if (GetBattlerAbility(gEffectBattler) == ABILITY_IMMUNITY
|
||||||
|
|| IsFlowerVeilProtected(gEffectBattler)
|
||||||
|
|| IsLeafGuardProtected(gEffectBattler))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
statusChanged = TRUE;
|
statusChanged = TRUE;
|
||||||
@ -2231,7 +2234,9 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
}
|
}
|
||||||
if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_FIRE))
|
if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_FIRE))
|
||||||
break;
|
break;
|
||||||
if (GetBattlerAbility(gEffectBattler) == ABILITY_WATER_VEIL || IsFlowerVeilProtected(gEffectBattler))
|
if (GetBattlerAbility(gEffectBattler) == ABILITY_WATER_VEIL
|
||||||
|
|| IsFlowerVeilProtected(gEffectBattler)
|
||||||
|
|| IsLeafGuardProtected(gEffectBattler))
|
||||||
break;
|
break;
|
||||||
if (gBattleMons[gEffectBattler].status1)
|
if (gBattleMons[gEffectBattler].status1)
|
||||||
break;
|
break;
|
||||||
@ -2247,7 +2252,9 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
break;
|
break;
|
||||||
if (noSunCanFreeze == 0)
|
if (noSunCanFreeze == 0)
|
||||||
break;
|
break;
|
||||||
if (GetBattlerAbility(gEffectBattler) == ABILITY_MAGMA_ARMOR || IsFlowerVeilProtected(gEffectBattler))
|
if (GetBattlerAbility(gEffectBattler) == ABILITY_MAGMA_ARMOR
|
||||||
|
|| IsFlowerVeilProtected(gEffectBattler)
|
||||||
|
|| IsLeafGuardProtected(gEffectBattler))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CancelMultiTurnMoves(gEffectBattler);
|
CancelMultiTurnMoves(gEffectBattler);
|
||||||
@ -2290,7 +2297,9 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
}
|
}
|
||||||
if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_ELECTRIC))
|
if (IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_ELECTRIC))
|
||||||
break;
|
break;
|
||||||
if (GetBattlerAbility(gEffectBattler) == ABILITY_LIMBER || IsFlowerVeilProtected(gEffectBattler))
|
if (GetBattlerAbility(gEffectBattler) == ABILITY_LIMBER
|
||||||
|
|| IsFlowerVeilProtected(gEffectBattler)
|
||||||
|
|| IsLeafGuardProtected(gEffectBattler))
|
||||||
break;
|
break;
|
||||||
if (gBattleMons[gEffectBattler].status1)
|
if (gBattleMons[gEffectBattler].status1)
|
||||||
break;
|
break;
|
||||||
@ -2331,7 +2340,9 @@ void SetMoveEffect(bool32 primary, u32 certain)
|
|||||||
break;
|
break;
|
||||||
if (!IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) && !IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL))
|
if (!IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_POISON) && !IS_BATTLER_OF_TYPE(gEffectBattler, TYPE_STEEL))
|
||||||
{
|
{
|
||||||
if (GetBattlerAbility(gEffectBattler) == ABILITY_IMMUNITY || IsFlowerVeilProtected(gEffectBattler))
|
if (GetBattlerAbility(gEffectBattler) == ABILITY_IMMUNITY
|
||||||
|
|| IsFlowerVeilProtected(gEffectBattler)
|
||||||
|
|| IsLeafGuardProtected(gEffectBattler))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// It's redundant, because at this point we know the status1 value is 0.
|
// It's redundant, because at this point we know the status1 value is 0.
|
||||||
@ -6632,6 +6643,14 @@ u32 IsFlowerVeilProtected(u32 battler)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 IsLeafGuardProtected(u32 battler)
|
||||||
|
{
|
||||||
|
if (WEATHER_HAS_EFFECT && (gBattleWeather & WEATHER_SUN_ANY))
|
||||||
|
return GetBattlerAbility(battler) == ABILITY_LEAF_GUARD;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void Cmd_various(void)
|
static void Cmd_various(void)
|
||||||
{
|
{
|
||||||
struct Pokemon *mon;
|
struct Pokemon *mon;
|
||||||
|
@ -1731,7 +1731,8 @@ u8 DoBattlerEndTurnEffects(void)
|
|||||||
gStatuses3[gActiveBattler] -= 0x800;
|
gStatuses3[gActiveBattler] -= 0x800;
|
||||||
if (!(gStatuses3[gActiveBattler] & STATUS3_YAWN) && !(gBattleMons[gActiveBattler].status1 & STATUS1_ANY)
|
if (!(gStatuses3[gActiveBattler] & STATUS3_YAWN) && !(gBattleMons[gActiveBattler].status1 & STATUS1_ANY)
|
||||||
&& gBattleMons[gActiveBattler].ability != ABILITY_VITAL_SPIRIT
|
&& gBattleMons[gActiveBattler].ability != ABILITY_VITAL_SPIRIT
|
||||||
&& gBattleMons[gActiveBattler].ability != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBattler))
|
&& gBattleMons[gActiveBattler].ability != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBattler)
|
||||||
|
&& !IsLeafGuardProtected(gActiveBattler))
|
||||||
{
|
{
|
||||||
CancelMultiTurnMoves(gActiveBattler);
|
CancelMultiTurnMoves(gActiveBattler);
|
||||||
gBattleMons[gActiveBattler].status1 |= (Random() & 3) + 2;
|
gBattleMons[gActiveBattler].status1 |= (Random() & 3) + 2;
|
||||||
@ -3346,6 +3347,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
|||||||
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_VITAL_SPIRIT
|
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_VITAL_SPIRIT
|
||||||
&& !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)
|
&& !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)
|
||||||
&& !IsFlowerVeilProtected(gBattlerAttacker)
|
&& !IsFlowerVeilProtected(gBattlerAttacker)
|
||||||
|
&& !IsLeafGuardProtected(gBattlerAttacker)
|
||||||
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
|
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
|
||||||
&& (Random() % 3) == 0)
|
&& (Random() % 3) == 0)
|
||||||
{
|
{
|
||||||
@ -3369,6 +3371,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
|||||||
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_IMMUNITY
|
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_IMMUNITY
|
||||||
&& !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)
|
&& !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)
|
||||||
&& !IsFlowerVeilProtected(gBattlerAttacker)
|
&& !IsFlowerVeilProtected(gBattlerAttacker)
|
||||||
|
&& !IsLeafGuardProtected(gBattlerAttacker)
|
||||||
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
|
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
|
||||||
&& (Random() % 3) == 0)
|
&& (Random() % 3) == 0)
|
||||||
{
|
{
|
||||||
@ -3390,6 +3393,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
|||||||
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_LIMBER
|
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_LIMBER
|
||||||
&& !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)
|
&& !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)
|
||||||
&& !IsFlowerVeilProtected(gBattlerAttacker)
|
&& !IsFlowerVeilProtected(gBattlerAttacker)
|
||||||
|
&& !IsLeafGuardProtected(gBattlerAttacker)
|
||||||
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
|
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
|
||||||
&& (Random() % 3) == 0)
|
&& (Random() % 3) == 0)
|
||||||
{
|
{
|
||||||
@ -3410,6 +3414,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
|
|||||||
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_WATER_VEIL
|
&& GetBattlerAbility(gBattlerAttacker) != ABILITY_WATER_VEIL
|
||||||
&& !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)
|
&& !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY)
|
||||||
&& !IsFlowerVeilProtected(gBattlerAttacker)
|
&& !IsFlowerVeilProtected(gBattlerAttacker)
|
||||||
|
&& !IsLeafGuardProtected(gBattlerAttacker)
|
||||||
&& (Random() % 3) == 0)
|
&& (Random() % 3) == 0)
|
||||||
{
|
{
|
||||||
gBattleScripting.moveEffect = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN;
|
gBattleScripting.moveEffect = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user