• We've opened up applications for site moderators! Head over to the announcement to learn more!

v19.1 Help with an ability that skips every other turn.

This thread pertains to v19.1 of Pokémon Essentials.

A¹¹

Rookie
Member
Joined
Oct 24, 2021
Posts
2
Hi, I have a question about implementing an ability that skips every other turn (for stuff like Toxic and Leech Seed) and after some time on the Relic Castle Discord we have reached this point

Python:
BattleHandlers::EORTurnsAbility.add(:STALL,
  proc { |ability,battler,battle|
  battler.effects[PBEffects::Stall] += 1
    if battler.turnCount > 0 && battler.effects[PBEffects::Stall]>=2
        battle.pbDisplay(_INTL("{1} stalls for time.",battler.pbThis))
        battle.pbEndOfRoundPhase
    end
  }
)

Right now I noticed this code loops because it adds a count for Stall every time, thus making it infinite, so how would I make it happen only once per turn?
 

A¹¹

Rookie
Member
Joined
Oct 24, 2021
Posts
2
Have you tried resetting Stall's count afterwards?
yes, but after you said it I noticed I was doing it wrong

Ruby:
BattleHandlers::EORTurnsAbility.add(:STALL,
  proc { |ability,battler,battle|
  battler.effects[PBEffects::Stall] += 1
    if battler.turnCount > 0 && battler.effects[PBEffects::Stall]>=3
        battler.effects[PBEffects::Stall] -= 3
    elsif battler.turnCount > 0 && battler.effects[PBEffects::Stall]=2
        battle.pbDisplay(_INTL("{1} stalls for time.",battler.pbThis))
        battle.pbEndOfRoundPhase
    end
  }
)
This version is working as intended.
 
Top