Fix Corrosion, Poison Touch

- CanBePoisoned now calls CanPoisonType instead of overriding it. Poison Touch now activates only if the attacker actually damaged the target. Partially implemented Pastel Veil.
This commit is contained in:
BuffelSaft 2021-10-30 21:12:18 +13:00
parent 6b65ef5bcf
commit 52054e4bfe
4 changed files with 19 additions and 23 deletions

View File

@ -167,7 +167,7 @@ bool32 IsEntrainmentBannedAbilityAttacker(u16 ability);
bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability); bool32 IsEntrainmentTargetOrSimpleBeamBannedAbility(u16 ability);
bool32 CanSleep(u8 battlerId); bool32 CanSleep(u8 battlerId);
bool32 CanBePoisoned(u8 battlerId); bool32 CanBePoisoned(u8 gBattlerAttacker, u8 battlerTarget);
bool32 CanBeBurned(u8 battlerId); bool32 CanBeBurned(u8 battlerId);
bool32 CanBeParalyzed(u8 battlerId); bool32 CanBeParalyzed(u8 battlerId);
bool32 CanBeFrozen(u8 battlerId); bool32 CanBeFrozen(u8 battlerId);

View File

@ -2616,7 +2616,7 @@ bool32 AI_CanPutToSleep(u8 battlerAtk, u8 battlerDef, u16 defAbility, u16 move,
bool32 AI_CanBePoisoned(u8 battler, u16 ability) bool32 AI_CanBePoisoned(u8 battler, u16 ability)
{ {
if (ability == ABILITY_IMMUNITY if (ability == ABILITY_IMMUNITY
|| ability == ABILITY_PASTEL_VEIL || IsAbilityOnSide(battler, ABILITY_PASTEL_VEIL)
|| gBattleMons[battler].status1 & STATUS1_ANY || gBattleMons[battler].status1 & STATUS1_ANY
|| IsAbilityStatusProtected(battler) || IsAbilityStatusProtected(battler)
|| gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SAFEGUARD) || gSideStatuses[GetBattlerSide(battler)] & SIDE_STATUS_SAFEGUARD)

View File

@ -2682,9 +2682,7 @@ void SetMoveEffect(bool32 primary, u32 certain)
gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STATUS_HAD_NO_EFFECT; gBattleCommunication[MULTISTRING_CHOOSER] = B_MSG_STATUS_HAD_NO_EFFECT;
RESET_RETURN RESET_RETURN
} }
if (!CanPoisonType(gBattleScripting.battler, gEffectBattler)) if (!CanBePoisoned(gBattleScripting.battler, gEffectBattler))
break;
if (!CanBePoisoned(gEffectBattler))
break; break;
statusChanged = TRUE; statusChanged = TRUE;
@ -2809,11 +2807,8 @@ void SetMoveEffect(bool32 primary, u32 certain)
} }
if (gBattleMons[gEffectBattler].status1) if (gBattleMons[gEffectBattler].status1)
break; break;
if (CanPoisonType(gBattleScripting.battler, gEffectBattler)) if (CanBePoisoned(gBattleScripting.battler, gEffectBattler))
{ {
if (!CanBePoisoned(gEffectBattler))
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.
gBattleMons[gEffectBattler].status1 &= ~(STATUS1_TOXIC_POISON); gBattleMons[gEffectBattler].status1 &= ~(STATUS1_TOXIC_POISON);
gBattleMons[gEffectBattler].status1 &= ~(STATUS1_POISON); gBattleMons[gEffectBattler].status1 &= ~(STATUS1_POISON);
@ -7257,9 +7252,8 @@ static void HandleTerrainMove(u32 moveEffect)
bool32 CanPoisonType(u8 battlerAttacker, u8 battlerTarget) bool32 CanPoisonType(u8 battlerAttacker, u8 battlerTarget)
{ {
return (GetBattlerAbility(battlerAttacker) == ABILITY_CORROSION return ((GetBattlerAbility(battlerAttacker) == ABILITY_CORROSION && gBattleMoves[gCurrentMove].split == SPLIT_STATUS)
|| !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON) || !(IS_BATTLER_OF_TYPE(battlerTarget, TYPE_POISON) || IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
|| IS_BATTLER_OF_TYPE(battlerTarget, TYPE_STEEL)));
} }
bool32 CanParalyzeType(u8 battlerAttacker, u8 battlerTarget) bool32 CanParalyzeType(u8 battlerAttacker, u8 battlerTarget)

View File

@ -4961,7 +4961,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
&& gBattleMons[gBattlerAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattlerAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& TARGET_TURN_DAMAGED && TARGET_TURN_DAMAGED
&& CanBePoisoned(gBattlerAttacker) && CanBePoisoned(gBattlerAttacker, gBattlerTarget)
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
@ -5148,8 +5148,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattlerTarget].hp != 0 && gBattleMons[gBattlerTarget].hp != 0
&& !gProtectStructs[gBattlerTarget].confusionSelfDmg && !gProtectStructs[gBattlerTarget].confusionSelfDmg
&& CanBePoisoned(gBattlerTarget) && CanBePoisoned(gBattlerAttacker, gBattlerTarget)
&& IsMoveMakingContact(move, gBattlerAttacker) && IsMoveMakingContact(move, gBattlerAttacker)
&& TARGET_TURN_DAMAGED // Need to actually hit the target
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
gBattleScripting.moveEffect = MOVE_EFFECT_POISON; gBattleScripting.moveEffect = MOVE_EFFECT_POISON;
@ -5589,18 +5590,19 @@ bool32 CanSleep(u8 battlerId)
return TRUE; return TRUE;
} }
bool32 CanBePoisoned(u8 battlerId) bool32 CanBePoisoned(u8 battlerAttacker, u8 battlerTarget)
{ {
u16 ability = GetBattlerAbility(battlerId); u16 ability = GetBattlerAbility(battlerTarget);
if (IS_BATTLER_OF_TYPE(battlerId, TYPE_POISON)
|| IS_BATTLER_OF_TYPE(battlerId, TYPE_STEEL) if (!(CanPoisonType(battlerAttacker, battlerTarget))
|| gSideStatuses[GetBattlerSide(battlerId)] & SIDE_STATUS_SAFEGUARD || gSideStatuses[GetBattlerSide(battlerTarget)] & SIDE_STATUS_SAFEGUARD
|| gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerTarget].status1 & STATUS1_ANY
|| ability == ABILITY_IMMUNITY || ability == ABILITY_IMMUNITY
|| ability == ABILITY_COMATOSE || ability == ABILITY_COMATOSE
|| gBattleMons[battlerId].status1 & STATUS1_ANY || IsAbilityOnSide(battlerTarget, ABILITY_PASTEL_VEIL)
|| IsAbilityStatusProtected(battlerId) || gBattleMons[battlerTarget].status1 & STATUS1_ANY
|| IsBattlerTerrainAffected(battlerId, STATUS_FIELD_MISTY_TERRAIN)) || IsAbilityStatusProtected(battlerTarget)
|| IsBattlerTerrainAffected(battlerTarget, STATUS_FIELD_MISTY_TERRAIN))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }