Merge pull request #2105 from Sneed69/healblock

Add missing Heal Block functionalities
This commit is contained in:
ghoulslash 2022-05-07 09:13:18 -04:00 committed by GitHub
commit adfb336a3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 2 deletions

View File

@ -1317,6 +1317,7 @@ BattleScript_StrengthSapTryHp:
attackanimation attackanimation
waitanimation waitanimation
BattleScript_StrengthSapHp: BattleScript_StrengthSapHp:
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_MoveEnd
jumpiffullhp BS_ATTACKER, BattleScript_MoveEnd jumpiffullhp BS_ATTACKER, BattleScript_MoveEnd
manipulatedamage DMG_BIG_ROOT manipulatedamage DMG_BIG_ROOT
healthbarupdate BS_ATTACKER healthbarupdate BS_ATTACKER
@ -2454,6 +2455,8 @@ BattleScript_EffectHealPulse:
attackcanceler attackcanceler
attackstring attackstring
ppreduce ppreduce
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_MoveUsedHealBlockPrevents @ stops pollen puff
jumpifstatus3 BS_TARGET, STATUS3_HEAL_BLOCK, BattleScript_MoveUsedHealBlockPrevents
accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON accuracycheck BattleScript_ButItFailed, NO_ACC_CALC_CHECK_LOCK_ON
jumpifsubstituteblocks BattleScript_ButItFailed jumpifsubstituteblocks BattleScript_ButItFailed
tryhealpulse BS_TARGET, BattleScript_AlreadyAtFullHp tryhealpulse BS_TARGET, BattleScript_AlreadyAtFullHp
@ -3148,6 +3151,7 @@ BattleScript_EffectAbsorb::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
resultmessage resultmessage
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_AbsorbHealBlock
setdrainedhp setdrainedhp
manipulatedamage DMG_BIG_ROOT manipulatedamage DMG_BIG_ROOT
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_IGNORE_DISGUISE
@ -3167,6 +3171,7 @@ BattleScript_AbsorbUpdateHp::
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
BattleScript_AbsorbTryFainting:: BattleScript_AbsorbTryFainting::
tryfaintmon BS_ATTACKER tryfaintmon BS_ATTACKER
BattleScript_AbsorbHealBlock::
tryfaintmon BS_TARGET tryfaintmon BS_TARGET
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -3273,6 +3278,7 @@ BattleScript_DreamEaterWorked:
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
resultmessage resultmessage
waitmessage B_WAIT_TIME_LONG waitmessage B_WAIT_TIME_LONG
jumpifstatus3 BS_ATTACKER, STATUS3_HEAL_BLOCK, BattleScript_DreamEaterTryFaintEnd
setdrainedhp setdrainedhp
manipulatedamage DMG_BIG_ROOT manipulatedamage DMG_BIG_ROOT
orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE

View File

@ -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_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_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_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 // Ability settings
#define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters. #define B_EXPANDED_ABILITY_NAMES TRUE // If TRUE, ability names are increased from 12 characters to 16 characters.

View File

@ -7872,7 +7872,7 @@ static void Cmd_various(void)
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 3);
return; return;
case VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS: case VARIOUS_CHECK_IF_GRASSY_TERRAIN_HEALS:
if ((gStatuses3[gActiveBattler] & (STATUS3_SEMI_INVULNERABLE)) if ((gStatuses3[gActiveBattler] & (STATUS3_SEMI_INVULNERABLE | STATUS3_HEAL_BLOCK))
|| BATTLER_MAX_HP(gActiveBattler) || BATTLER_MAX_HP(gActiveBattler)
|| !gBattleMons[gActiveBattler].hp || !gBattleMons[gActiveBattler].hp
|| !(IsBattlerGrounded(gActiveBattler))) || !(IsBattlerGrounded(gActiveBattler)))

View File

@ -1690,7 +1690,11 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move)
switch (gBattleMoves[move].effect) switch (gBattleMoves[move].effect)
{ {
#if B_HEAL_BLOCKING >= GEN_6
case EFFECT_ABSORB: case EFFECT_ABSORB:
case EFFECT_STRENGTH_SAP:
case EFFECT_DREAM_EATER:
#endif
case EFFECT_MORNING_SUN: case EFFECT_MORNING_SUN:
case EFFECT_MOONLIGHT: case EFFECT_MOONLIGHT:
case EFFECT_RESTORE_HP: case EFFECT_RESTORE_HP:
@ -1698,7 +1702,7 @@ bool32 IsHealBlockPreventingMove(u32 battler, u32 move)
case EFFECT_ROOST: case EFFECT_ROOST:
case EFFECT_HEALING_WISH: case EFFECT_HEALING_WISH:
case EFFECT_WISH: case EFFECT_WISH:
case EFFECT_DREAM_EATER: case EFFECT_HEAL_PULSE:
return TRUE; return TRUE;
default: default:
return FALSE; return FALSE;
@ -4917,7 +4921,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u16 ability, u8 special, u16 move
if (effect == 1) // Drain Hp ability. if (effect == 1) // Drain Hp ability.
{ {
#if B_HEAL_BLOCKING >= GEN_5
if (BATTLER_MAX_HP(battler) || gStatuses3[battler] & STATUS3_HEAL_BLOCK) if (BATTLER_MAX_HP(battler) || gStatuses3[battler] & STATUS3_HEAL_BLOCK)
#else
if (BATTLER_MAX_HP(battler))
#endif
{ {
if ((gProtectStructs[gBattlerAttacker].notFirstStrike)) if ((gProtectStructs[gBattlerAttacker].notFirstStrike))
gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless; gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless;
@ -6092,7 +6100,11 @@ bool32 HasEnoughHpToEatBerry(u32 battlerId, u32 hpFraction, u32 itemId)
static u8 HealConfuseBerry(u32 battlerId, u32 itemId, u8 flavorId, bool32 end2) 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)) if (HasEnoughHpToEatBerry(battlerId, 2, itemId))
#endif
{ {
PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, flavorId); PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, flavorId);
@ -6278,7 +6290,11 @@ u8 TryHandleSeed(u8 battler, u32 terrainFlag, u8 statId, u16 itemId, bool32 exec
static u8 ItemHealHp(u32 battlerId, u32 itemId, bool32 end2, bool32 percentHeal) 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) if (HasEnoughHpToEatBerry(battlerId, 2, itemId)
#endif
&& !(gBattleScripting.overrideBerryRequirements && gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP)) && !(gBattleScripting.overrideBerryRequirements && gBattleMons[battlerId].hp == gBattleMons[battlerId].maxHP))
{ {
if (percentHeal) if (percentHeal)
@ -6717,7 +6733,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
break; break;
case HOLD_EFFECT_LEFTOVERS: case HOLD_EFFECT_LEFTOVERS:
LEFTOVERS: LEFTOVERS:
#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) if (gBattleMons[battlerId].hp < gBattleMons[battlerId].maxHP && !moveTurn)
#endif
{ {
gBattleMoveDamage = gBattleMons[battlerId].maxHP / 16; gBattleMoveDamage = gBattleMons[battlerId].maxHP / 16;
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
@ -7147,7 +7167,11 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
if (gSpecialStatuses[gBattlerAttacker].damagedMons // Need to have done damage if (gSpecialStatuses[gBattlerAttacker].damagedMons // Need to have done damage
&& gBattlerAttacker != gBattlerTarget && gBattlerAttacker != gBattlerTarget
&& gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP
#if B_HEAL_BLOCKING >= GEN_5
&& gBattleMons[gBattlerAttacker].hp != 0 && !(gStatuses3[battlerId] & STATUS3_HEAL_BLOCK))
#else
&& gBattleMons[gBattlerAttacker].hp != 0) && gBattleMons[gBattlerAttacker].hp != 0)
#endif
{ {
gLastUsedItem = atkItem; gLastUsedItem = atkItem;
gPotentialItemEffectBattler = gBattlerAttacker; gPotentialItemEffectBattler = gBattlerAttacker;