• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Question] Help Coding Ability that reduce Priority before turn order calculation

  • 10
    Posts
    10
    Years
    • Seen Apr 23, 2022
    I'm trying to program an ability that will treat all incoming increased priority moves as 0 priority, as long as the move is targeting the Pokemon with this ability.
    So say if Kadabra has this ability, is faster and wants to use Signal Beam while Sneasel wants to use Sucker Punch or Quick Attack, Kadabra will use Signal Beam before Sucker Punch or Quick Attack.

    I've tried this but it does not work as expected.

    My Script:
    Code:
    BattleHandlers::PriorityChangeAbility.add(:SUDDENREFLEX,
      proc { |ability,battler,move,pri|
        if move.damagingMove?
          pri = 0 if pri > 0
        end
      }
    )

    Should I implement new ability handlers not part of Essentials code? Or can it be done upon existing codebase?
     
  • 54
    Posts
    4
    Years
    Unsure if this is the problem, but try adding "next" (without quotation marks) before
    Code:
    pri = 0 if pri > 0
    so that you'd have
    Code:
    next pri = 0 if pri > 0
     
  • 10
    Posts
    10
    Years
    • Seen Apr 23, 2022
    Unsure if this is the problem, but try adding "next" (without quotation marks) before
    Code:
    pri = 0 if pri > 0
    so that you'd have
    Code:
    next pri = 0 if pri > 0

    Didn't work. The problem appears to be, event handler is triggering for the Pokemon WITH the ability, not for the Pokemon OPPOSING the ability.
    So move and pri belongs to Kadabra (the one with the ability), not Sneasel (the one who's priority should be reduced).

    I need to trigger an event for a pokemon when facing a certain ability.
     
  • 54
    Posts
    4
    Years
    Sorry, I'll check back later because my PC is very good at finding problems it hadn't had

    Edit: I have looked for a bit, but I have found nothing regarding the enemy pokémon's moves' priority. I'm afraid I can't help
     
    Last edited:
    Back
    Top