From b17d1f7816bde54b64c306968a1c6fdc0d42da85 Mon Sep 17 00:00:00 2001 From: sneed Date: Mon, 2 May 2022 17:56:09 +0300 Subject: [PATCH] Add generation specific interactions --- data/battle_scripts_1.s | 4 ++++ include/constants/battle_config.h | 2 ++ src/battle_util.c | 32 +++++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 6574e26ab..a58dc1339 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -1272,6 +1272,7 @@ BattleScript_StrengthSapTryHp: attackanimation waitanimation BattleScript_StrengthSapHp: + jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_MoveEnd jumpiffullhp BS_ATTACKER, BattleScript_MoveEnd manipulatedamage DMG_BIG_ROOT healthbarupdate BS_ATTACKER @@ -3103,6 +3104,7 @@ BattleScript_EffectAbsorb:: waitmessage B_WAIT_TIME_LONG resultmessage waitmessage B_WAIT_TIME_LONG + jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_AbsorbHealBlock setdrainedhp manipulatedamage DMG_BIG_ROOT orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE @@ -3122,6 +3124,7 @@ BattleScript_AbsorbUpdateHp:: waitmessage B_WAIT_TIME_LONG BattleScript_AbsorbTryFainting:: tryfaintmon BS_ATTACKER +BattleScript_AbsorbHealBlock:: tryfaintmon BS_TARGET goto BattleScript_MoveEnd @@ -3228,6 +3231,7 @@ BattleScript_DreamEaterWorked: waitmessage B_WAIT_TIME_LONG resultmessage waitmessage B_WAIT_TIME_LONG + jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_DreamEaterTryFaintEnd setdrainedhp manipulatedamage DMG_BIG_ROOT orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE diff --git a/include/constants/battle_config.h b/include/constants/battle_config.h index a3ef7cc94..29395dc80 100644 --- a/include/constants/battle_config.h +++ b/include/constants/battle_config.h @@ -170,6 +170,8 @@ #define B_BRICK_BREAK GEN_7 // In Gen4+, you can destroy your own side's screens. In Gen 5+, screens are not removed if the target is immune. #define B_WISH_HP_SOURCE GEN_7 // In Gen5+, Wish heals half of the user's max HP instead of the target's. #define B_RAMPAGE_CANCELLING GEN_7 // In Gen5+, a failed Thrash, etc, will cancel except on its last turn. +#define B_HEAL_BLOCKING GEN_7 // In Gen5+, Heal Block prevents healing by Black Sludge, Leftovers, Shell Bell. Affected Pokémon will not consume held HP-restoring Berries or Berry Juice. + // Draining abilities will not heal but will prevent damage. In Gen6+, Heal Block prevents the use of most HP-draining moves. // Ability settings #define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters. diff --git a/src/battle_util.c b/src/battle_util.c index 775c8eebc..1aa917f82 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -1680,7 +1680,11 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move) switch (gBattleMoves[move].effect) { +#if B_HEAL_BLOCKING >= GEN_6 case EFFECT_ABSORB: + case EFFECT_STRENGTH_SAP: + case EFFECT_DREAM_EATER: +#endif case EFFECT_MORNING_SUN: case EFFECT_MOONLIGHT: case EFFECT_RESTORE_HP: @@ -1688,8 +1692,6 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move) case EFFECT_ROOST: case EFFECT_HEALING_WISH: case EFFECT_WISH: - case EFFECT_DREAM_EATER: - case EFFECT_STRENGTH_SAP: return TRUE; default: return FALSE; @@ -4908,7 +4910,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move if (effect == 1) // Drain Hp ability. { +#if B_HEAL_BLOCKING >= GEN_5 if (BATTLER_MAX_HP(battler) || gStatuses3[battler] & STATUS3_HEAL_BLOCK) +#else + if (BATTLER_MAX_HP(battler)) +#endif { if ((gProtectStructs[gBattlerAttacker].notFirstStrike)) gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless; @@ -6083,7 +6089,11 @@ bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId) static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2) { +#if B_HEAL_BLOCKING >= GEN_5 if (HasEnoughHpToEatBerry(battlerId, 2, itemId) && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)) +#else + if (HasEnoughHpToEatBerry(battlerId, 2, itemId)) +#endif { PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, flavorId); @@ -6269,7 +6279,11 @@ u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 exec static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) { +#if B_HEAL_BLOCKING >= GEN_5 if (HasEnoughHpToEatBerry(battlerId, 2, itemId) && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK) +#else + if (HasEnoughHpToEatBerry(battlerId, 2, itemId) +#endif && !(gBattleScripting.overrideBerryRequirements && gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)) { if (percentHeal) @@ -6708,8 +6722,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) break; case HOLD_EFFECT_LEFTOVERS: LEFTOVERS: - if (gBattleMons[battlerId].hp < gBattleMons[battlerId].maxHP && !moveTurn - && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)) +#if B_HEAL_BLOCKING >= GEN_5 + if (gBattleMons[battlerId].hp < gBattleMons[battlerId].maxHP && !moveTurn && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)) +#else + if (gBattleMons[battlerId].hp < gBattleMons[battlerId].maxHP && !moveTurn) +#endif { gBattleMoveDamage = gBattleMons[battlerId].maxHP / 16; if (gBattleMoveDamage == 0) @@ -7139,8 +7156,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn) if (gSpecialStatuses[gBattlerAttacker].damagedMons // Need to have done damage && gBattlerAttacker != gBattlerTarget && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP - && gBattleMons[gBattlerAttacker].hp != 0 - && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)) +#if B_HEAL_BLOCKING >= GEN_5 + && gBattleMons[gBattlerAttacker].hp != 0 && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK)) +#else + && gBattleMons[gBattlerAttacker].hp != 0) +#endif { gLastUsedItem = atkItem; gPotentialItemEffectBattler = gBattlerAttacker;