Adds SleepClauseBlock enum to CanBeSlept (#5773)
This commit is contained in:
parent
7c10e024ac
commit
599f4d339b
@ -148,6 +148,12 @@ struct DamageCalculationData
|
||||
u32 padding:2;
|
||||
};
|
||||
|
||||
enum SleepClauseBlock
|
||||
{
|
||||
NOT_BLOCKED_BY_SLEEP_CLAUSE,
|
||||
BLOCKED_BY_SLEEP_CLAUSE,
|
||||
};
|
||||
|
||||
void HandleAction_ThrowBall(void);
|
||||
bool32 IsAffectedByFollowMe(u32 battlerAtk, u32 defSide, u32 move);
|
||||
void HandleAction_UseMove(void);
|
||||
@ -292,7 +298,7 @@ bool32 MoveHasChargeTurnAdditionalEffect(u32 move);
|
||||
bool32 CanTargetPartner(u32 battlerAtk, u32 battlerDef);
|
||||
bool32 TargetFullyImmuneToCurrMove(u32 battlerAtk, u32 battlerDef);
|
||||
|
||||
bool32 CanBeSlept(u32 battler, u32 ability, u32 isBlockedBySleepClause);
|
||||
bool32 CanBeSlept(u32 battler, u32 ability, enum SleepClauseBlock isBlockedBySleepClause);
|
||||
bool32 CanBePoisoned(u32 battlerAtk, u32 battlerDef, u32 defAbility);
|
||||
bool32 CanBeBurned(u32 battler, u32 ability);
|
||||
bool32 CanBeParalyzed(u32 battler, u32 ability);
|
||||
|
||||
@ -1796,7 +1796,7 @@ static s32 AI_CheckBadMove(u32 battlerAtk, u32 battlerDef, u32 move, s32 score)
|
||||
ADJUST_SCORE(-10);
|
||||
break;
|
||||
case EFFECT_REST:
|
||||
if (!CanBeSlept(battlerAtk, aiData->abilities[battlerAtk], FALSE))
|
||||
if (!CanBeSlept(battlerAtk, aiData->abilities[battlerAtk], NOT_BLOCKED_BY_SLEEP_CLAUSE))
|
||||
ADJUST_SCORE(-10);
|
||||
//fallthrough
|
||||
case EFFECT_RESTORE_HP:
|
||||
@ -3461,7 +3461,7 @@ static u32 AI_CalcMoveEffectScore(u32 battlerAtk, u32 battlerDef, u32 move)
|
||||
}
|
||||
break;
|
||||
case EFFECT_REST:
|
||||
if (!(CanBeSlept(battlerAtk, aiData->abilities[battlerAtk], FALSE)))
|
||||
if (!(CanBeSlept(battlerAtk, aiData->abilities[battlerAtk], NOT_BLOCKED_BY_SLEEP_CLAUSE)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@ -502,7 +502,7 @@ static bool32 ShouldSwitchIfBadlyStatused(u32 battler)
|
||||
{
|
||||
//Yawn
|
||||
if (gStatuses3[battler] & STATUS3_YAWN
|
||||
&& CanBeSlept(battler, monAbility, TRUE)
|
||||
&& CanBeSlept(battler, monAbility, BLOCKED_BY_SLEEP_CLAUSE)
|
||||
&& gBattleMons[battler].hp > gBattleMons[battler].maxHP / 3)
|
||||
{
|
||||
switchMon = TRUE;
|
||||
|
||||
@ -2941,7 +2941,7 @@ bool32 IsBattlerIncapacitated(u32 battler, u32 ability)
|
||||
|
||||
bool32 AI_CanPutToSleep(u32 battlerAtk, u32 battlerDef, u32 defAbility, u32 move, u32 partnerMove)
|
||||
{
|
||||
if (!CanBeSlept(battlerDef, defAbility, TRUE)
|
||||
if (!CanBeSlept(battlerDef, defAbility, BLOCKED_BY_SLEEP_CLAUSE)
|
||||
|| DoesSubstituteBlockMove(battlerAtk, battlerDef, move)
|
||||
|| PartnerMoveEffectIsStatusSameTarget(BATTLE_PARTNER(battlerAtk), battlerDef, partnerMove)) // shouldn't try to sleep mon that partner is trying to make sleep
|
||||
return FALSE;
|
||||
|
||||
@ -759,7 +759,7 @@ void BS_SetMaxMoveEffect(void)
|
||||
{
|
||||
static const u8 sSnoozeEffects[] = {TRUE, FALSE};
|
||||
if (!(gStatuses3[gBattlerTarget] & STATUS3_YAWN)
|
||||
&& CanBeSlept(gBattlerTarget, GetBattlerAbility(gBattlerTarget), TRUE)
|
||||
&& CanBeSlept(gBattlerTarget, GetBattlerAbility(gBattlerTarget), BLOCKED_BY_SLEEP_CLAUSE)
|
||||
&& RandomElement(RNG_G_MAX_SNOOZE, sSnoozeEffects)) // 50% chance of success
|
||||
{
|
||||
gStatuses3[gBattlerTarget] |= STATUS3_YAWN_TURN(2);
|
||||
@ -881,7 +881,7 @@ void BS_TrySetStatus1(void)
|
||||
}
|
||||
break;
|
||||
case STATUS1_SLEEP:
|
||||
if (CanBeSlept(gBattlerTarget, GetBattlerAbility(gBattlerTarget), TRUE))
|
||||
if (CanBeSlept(gBattlerTarget, GetBattlerAbility(gBattlerTarget), BLOCKED_BY_SLEEP_CLAUSE))
|
||||
{
|
||||
if (B_SLEEP_TURNS >= GEN_5)
|
||||
gBattleMons[gBattlerTarget].status1 |= STATUS1_SLEEP_TURN((Random() % 3) + 2);
|
||||
|
||||
@ -3266,7 +3266,7 @@ void SetMoveEffect(bool32 primary, bool32 certain)
|
||||
|
||||
if (i != gBattlersCount)
|
||||
break;
|
||||
if (!CanBeSlept(gEffectBattler, GetBattlerAbility(gEffectBattler), TRUE) && !(gBattleStruct->sleepClauseEffectExempt & (1u << gEffectBattler)))
|
||||
if (!CanBeSlept(gEffectBattler, GetBattlerAbility(gEffectBattler), BLOCKED_BY_SLEEP_CLAUSE) && !(gBattleStruct->sleepClauseEffectExempt & (1u << gEffectBattler)))
|
||||
break;
|
||||
|
||||
cancelMultiTurnMovesResult = CancelMultiTurnMoves(gEffectBattler);
|
||||
@ -10475,7 +10475,7 @@ static void Cmd_various(void)
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 2;
|
||||
else if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && CanBeParalyzed(gBattlerTarget, targetAbility))
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 3;
|
||||
else if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) && CanBeSlept(gBattlerTarget, targetAbility, TRUE))
|
||||
else if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) && CanBeSlept(gBattlerTarget, targetAbility, BLOCKED_BY_SLEEP_CLAUSE))
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 4;
|
||||
else if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_FROSTBITE) && CanGetFrostbite(gBattlerTarget))
|
||||
gBattleCommunication[MULTISTRING_CHOOSER] = 5;
|
||||
|
||||
@ -5871,7 +5871,7 @@ u32 AbilityBattleEffects(u32 caseID, u32 battler, u32 ability, u32 special, u32
|
||||
&& IsBattlerAlive(gBattlerAttacker)
|
||||
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg
|
||||
&& TARGET_TURN_DAMAGED
|
||||
&& CanBeSlept(gBattlerAttacker, ability, FALSE)
|
||||
&& CanBeSlept(gBattlerAttacker, ability, NOT_BLOCKED_BY_SLEEP_CLAUSE)
|
||||
&& GetBattlerHoldEffect(gBattlerAttacker, TRUE) != HOLD_EFFECT_PROTECTIVE_PADS
|
||||
&& IsMoveMakingContact(move, gBattlerAttacker))
|
||||
{
|
||||
@ -6732,7 +6732,7 @@ bool32 IsBattlerTerrainAffected(u32 battler, u32 terrainFlag)
|
||||
return IsBattlerGrounded(battler);
|
||||
}
|
||||
|
||||
bool32 CanBeSlept(u32 battler, u32 ability, u32 isBlockedBySleepClause)
|
||||
bool32 CanBeSlept(u32 battler, u32 ability, enum SleepClauseBlock isBlockedBySleepClause)
|
||||
{
|
||||
if(IsSleepClauseActiveForSide(GetBattlerSide(battler)) && isBlockedBySleepClause)
|
||||
return FALSE;
|
||||
@ -8614,7 +8614,7 @@ u8 GetAttackerObedienceForAction()
|
||||
obedienceLevel = levelReferenced - obedienceLevel;
|
||||
|
||||
calc = ((rnd >> 16) & 255);
|
||||
if (calc < obedienceLevel && CanBeSlept(gBattlerAttacker, GetBattlerAbility(gBattlerAttacker), FALSE))
|
||||
if (calc < obedienceLevel && CanBeSlept(gBattlerAttacker, GetBattlerAbility(gBattlerAttacker), NOT_BLOCKED_BY_SLEEP_CLAUSE))
|
||||
{
|
||||
// try putting asleep
|
||||
int i;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user