Tweaks + RETURN_MOVE_HAS_MOVE_EFFECT_WITH macro
Macro makes it easier to build functions that check a move's move effects
This commit is contained in:
parent
ce4dd729f4
commit
436ef7e59a
2 changed files with 27 additions and 50 deletions
|
@ -10740,20 +10740,6 @@ bool32 IsBattlerAffectedByHazards(u32 battler, bool32 toxicSpikes)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool32 MoveIsAffectedBySheerForce(u16 move)
|
||||
{
|
||||
u32 i;
|
||||
GET_ADDITIONAL_EFFECTS_AND_COUNT(move, additionalEffectsCount, additionalEffects);
|
||||
|
||||
for (i = 0; i < additionalEffectsCount; i++)
|
||||
{
|
||||
if (additionalEffects[i].chance > 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool32 TestSheerForceFlag(u32 battler, u16 move)
|
||||
{
|
||||
return GetBattlerAbility(battler) == ABILITY_SHEER_FORCE && MoveIsAffectedBySheerForce(move);
|
||||
|
@ -11026,43 +11012,35 @@ bool32 IsGen6ExpShareEnabled(void)
|
|||
return FlagGet(I_EXP_SHARE_FLAG);
|
||||
}
|
||||
|
||||
#define R_CHECK_MOVE_EFFECT(...) RECURSIVELY(R_FOR_EACH(CHECK_MOVE_EFFECT, __VA_ARGS__))
|
||||
#define CHECK_MOVE_EFFECT(_condition) && effects[i]._condition
|
||||
|
||||
/* Quick way of checking if a move has move effects with match a few
|
||||
comma-separated conditions. Each condition has to check a field of AdditionalEffect. */
|
||||
#define RETURN_MOVE_HAS_MOVE_EFFECT_WITH(condition1, ...) \
|
||||
u32 i; \
|
||||
GET_ADDITIONAL_EFFECTS_AND_COUNT(move, count, effects); \
|
||||
for (i = 0; i < count; i++) \
|
||||
{ \
|
||||
if (effects[i].condition1 R_CHECK_MOVE_EFFECT(__VA_ARGS__)) \
|
||||
return TRUE; \
|
||||
} \
|
||||
return FALSE;
|
||||
|
||||
|
||||
bool32 MoveHasMoveEffect(u32 move, u32 moveEffect)
|
||||
{
|
||||
u32 i;
|
||||
GET_ADDITIONAL_EFFECTS_AND_COUNT(move, count, effects);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (effects[i].moveEffect == moveEffect && effects[i].self == FALSE)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
RETURN_MOVE_HAS_MOVE_EFFECT_WITH(moveEffect == moveEffect, self == FALSE)
|
||||
}
|
||||
|
||||
bool32 MoveHasMoveEffectWithChance(u32 move, u32 moveEffect, u32 chance)
|
||||
{
|
||||
u32 i;
|
||||
GET_ADDITIONAL_EFFECTS_AND_COUNT(move, count, effects);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (effects[i].moveEffect == moveEffect && effects[i].chance == chance)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
RETURN_MOVE_HAS_MOVE_EFFECT_WITH(moveEffect == moveEffect, chance == chance)
|
||||
}
|
||||
|
||||
bool32 MoveHasMoveEffectSelf(u32 move, u32 moveEffect)
|
||||
{
|
||||
u32 i;
|
||||
GET_ADDITIONAL_EFFECTS_AND_COUNT(move, count, effects);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (effects[i].moveEffect == moveEffect && effects[i].self == TRUE)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
RETURN_MOVE_HAS_MOVE_EFFECT_WITH(moveEffect == moveEffect, self == TRUE)
|
||||
}
|
||||
|
||||
bool32 MoveHasMoveEffectSelfArg(u32 move, u32 moveEffect, u32 argument)
|
||||
|
@ -11072,13 +11050,12 @@ bool32 MoveHasMoveEffectSelfArg(u32 move, u32 moveEffect, u32 argument)
|
|||
|
||||
bool32 MoveHasChargeTurnMoveEffect(u32 move)
|
||||
{
|
||||
u8 i = 0;
|
||||
for (i = 0; i < gMovesInfo[move].numAdditionalEffects; i++)
|
||||
{
|
||||
if (gMovesInfo[move].additionalEffects[i].onChargeTurnOnly)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
RETURN_MOVE_HAS_MOVE_EFFECT_WITH(onChargeTurnOnly == TRUE)
|
||||
}
|
||||
|
||||
bool32 MoveIsAffectedBySheerForce(u16 move)
|
||||
{
|
||||
RETURN_MOVE_HAS_MOVE_EFFECT_WITH(chance > 0)
|
||||
}
|
||||
|
||||
bool8 CanMonParticipateInSkyBattle(struct Pokemon *mon)
|
||||
|
|
|
@ -99,12 +99,12 @@ SINGLE_BATTLE_TEST("Upper Hand fails if the target moves first")
|
|||
}
|
||||
}
|
||||
|
||||
SINGLE_BATTLE_TEST("Upper Hand is boosted by Sheer Force")
|
||||
SINGLE_BATTLE_TEST("Upper Hand is boosted by Sheer Force") // why does this move need a special test?
|
||||
{
|
||||
GIVEN {
|
||||
ASSUME(gMovesInfo[MOVE_EXTREME_SPEED].category == DAMAGE_CATEGORY_PHYSICAL);
|
||||
ASSUME(gMovesInfo[MOVE_EXTREME_SPEED].priority == 2);
|
||||
ASSUME(gMovesInfo[MOVE_UPPER_HAND].sheerForceBoost == TRUE);
|
||||
ASSUME(MoveIsAffectedBySheerForce(MOVE_UPPER_HAND) == TRUE);
|
||||
PLAYER(SPECIES_HARIYAMA) { Ability(ABILITY_SHEER_FORCE); }
|
||||
OPPONENT(SPECIES_WOBBUFFET);
|
||||
} WHEN {
|
||||
|
|
Loading…
Reference in a new issue