Skip to content

Commit

Permalink
Fixes Ability Shield, Neutralizing Gas interaction (rh-hideout#4391)
Browse files Browse the repository at this point in the history
* Fixes Ability Shield, Neutralizing Gas interaction

* test was wrong
  • Loading branch information
AlexOn1ine authored and Applesmacks committed Apr 22, 2024
1 parent 6e8aad2 commit ad792b3
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/battle_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ u32 SetRandomTarget(u32 battler);
u32 GetMoveTarget(u16 move, u8 setTarget);
u8 IsMonDisobedient(void);
u32 GetBattlerHoldEffect(u32 battler, bool32 checkNegating);
u32 GetBattlerHoldEffectIgnoreAbility(u32 battler, bool32 checkNegating);
u32 GetBattlerHoldEffectInternal(u32 battler, bool32 checkNegating, bool32 checkAbility);
u32 GetBattlerHoldEffectParam(u32 battler);
bool32 IsMoveMakingContact(u32 move, u32 battlerAtk);
bool32 IsBattlerGrounded(u32 battler);
Expand Down
16 changes: 14 additions & 2 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -6128,7 +6128,9 @@ u32 GetBattlerAbility(u32 battler)
if (gStatuses3[battler] & STATUS3_GASTRO_ACID)
return ABILITY_NONE;

if (IsNeutralizingGasOnField() && gBattleMons[battler].ability != ABILITY_NEUTRALIZING_GAS)
if (IsNeutralizingGasOnField()
&& gBattleMons[battler].ability != ABILITY_NEUTRALIZING_GAS
&& GetBattlerHoldEffectIgnoreAbility(battler, TRUE) != HOLD_EFFECT_ABILITY_SHIELD)
return ABILITY_NONE;

if (IsMyceliumMightOnField())
Expand Down Expand Up @@ -8154,14 +8156,24 @@ u8 IsMonDisobedient(void)
}

u32 GetBattlerHoldEffect(u32 battler, bool32 checkNegating)
{
return GetBattlerHoldEffectInternal(battler, checkNegating, TRUE);
}

u32 GetBattlerHoldEffectIgnoreAbility(u32 battler, bool32 checkNegating)
{
return GetBattlerHoldEffectInternal(battler, checkNegating, FALSE);
}

u32 GetBattlerHoldEffectInternal(u32 battler, bool32 checkNegating, bool32 checkAbility)
{
if (checkNegating)
{
if (gStatuses3[battler] & STATUS3_EMBARGO)
return HOLD_EFFECT_NONE;
if (gFieldStatuses & STATUS_FIELD_MAGIC_ROOM)
return HOLD_EFFECT_NONE;
if (GetBattlerAbility(battler) == ABILITY_KLUTZ)
if (checkAbility && GetBattlerAbility(battler) == ABILITY_KLUTZ)
return HOLD_EFFECT_NONE;
}

Expand Down
34 changes: 34 additions & 0 deletions test/battle/hold_effect/ability_shield.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "global.h"
#include "test/battle.h"

ASSUMPTIONS
{
ASSUME(gItemsInfo[ITEM_ABILITY_SHIELD].holdEffect == HOLD_EFFECT_ABILITY_SHIELD);
}

SINGLE_BATTLE_TEST("Ability Shield prevents Neutralizing Gas")
{
u32 item;

PARAMETRIZE { item = ITEM_ABILITY_SHIELD; }
PARAMETRIZE { item = ITEM_NONE; }

GIVEN {
PLAYER(SPECIES_TORKOAL) { Ability(ABILITY_DROUGHT); Item(item); }
OPPONENT(SPECIES_KOFFING) { Ability(ABILITY_NEUTRALIZING_GAS); }
} WHEN {
TURN { }
} SCENE {
ABILITY_POPUP(opponent, ABILITY_NEUTRALIZING_GAS);
MESSAGE("Neutralizing Gas filled the area!");
if (item == ITEM_ABILITY_SHIELD) {
ABILITY_POPUP(player, ABILITY_DROUGHT);
MESSAGE("Torkoal's Drought intensified the sun's rays!");
} else {
NONE_OF {
ABILITY_POPUP(player, ABILITY_DROUGHT);
MESSAGE("Torkoal's Drought intensified the sun's rays!");
}
}
}
}

0 comments on commit ad792b3

Please sign in to comment.