- 4
- Posts
- 8
- Years
- Seen Apr 15, 2025
So I'm trying to get an ability that disables other abilities to work (distinct from Neutralizing Gas because this new ability also disables held items and bonuses from stat boosts). For the Ability function, I copied the code from Neutralizing Gas for this new ability in places where Neutralizing Gas is checked for, including for the abilityActive? check.
![[PokeCommunity.com] Trying to add a second Ability that turns off other Abilities, get "Stack level too deep" error [PokeCommunity.com] Trying to add a second Ability that turns off other Abilities, get "Stack level too deep" error](https://data.pokecommunity.com/attachments/86/86513-f67f0e8a1784ea7dbacff3699a01f18c.jpg)
However, it seems like I can't have more than one @battle.pbCheckGlobalAbility check in a defined function, as it causes a SystemStackError:
![[PokeCommunity.com] Trying to add a second Ability that turns off other Abilities, get "Stack level too deep" error [PokeCommunity.com] Trying to add a second Ability that turns off other Abilities, get "Stack level too deep" error](https://data.pokecommunity.com/attachments/86/86514-bd0ecf8f13886ed69a872a76f76ff59d.jpg)
It looks like something's causing @battle.pbCheckGlobalAbility to run in an endless loop if it tries to check for more than one Ability, and I'm admittedly stumped at how to fix it... some advice would be appreciated 🙏
Here's the code that's causing the issue as text:
![[PokeCommunity.com] Trying to add a second Ability that turns off other Abilities, get "Stack level too deep" error [PokeCommunity.com] Trying to add a second Ability that turns off other Abilities, get "Stack level too deep" error](https://data.pokecommunity.com/attachments/86/86513-f67f0e8a1784ea7dbacff3699a01f18c.jpg)
However, it seems like I can't have more than one @battle.pbCheckGlobalAbility check in a defined function, as it causes a SystemStackError:
![[PokeCommunity.com] Trying to add a second Ability that turns off other Abilities, get "Stack level too deep" error [PokeCommunity.com] Trying to add a second Ability that turns off other Abilities, get "Stack level too deep" error](https://data.pokecommunity.com/attachments/86/86514-bd0ecf8f13886ed69a872a76f76ff59d.jpg)
It looks like something's causing @battle.pbCheckGlobalAbility to run in an endless loop if it tries to check for more than one Ability, and I'm admittedly stumped at how to fix it... some advice would be appreciated 🙏
Here's the code that's causing the issue as text:
Ruby:
def abilityActive?(ignore_fainted = false, check_ability = nil)
echoln "this is the (Not Very Nice Person)"
return false if fainted? && !ignore_fainted
if Settings::MECHANICS_GENERATION >= 9
return true if !check_ability && self.ability == :BATTLEBOND
if @proteanTrigger && self.ability == @effects[PBEffects::OneUseAbility]
return false if !check_ability || check_ability == self.ability
return false if check_ability.is_a?(Array) && check_ability.include?(@ability_id)
end
end
return false if @effects[PBEffects::GastroAcid]
return false if (check_ability != :NEUTRALIZINGGAS && self.ability != :NEUTRALIZINGGAS &&
!activeAbilityShield?(check_ability) && @battle.pbCheckGlobalAbility(:NEUTRALIZINGGAS))
return false if check_ability != :NIHILITY && self.ability != :NIHILITY && @battle.pbCheckGlobalAbility(:NIHILITY)
return true
end