• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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.

[Scripting Question] New ability for v19

  • 5
    Posts
    12
    Years
    • Seen Jan 8, 2023
    Hi,
    I'm trying to make an ability that on switch in check the opponent's stats like Download does, but I wanted to make it so that if the user is faster than the opponent they get a stat boost. I'm struggling to figure out how to get the ability to check the Pokemon's speed stats and determine who is faster. I have the code to raise the stat (it's just Intrepid Sword at this point) but I just wanted the condition on it. Would love any help. Thanks.

    BattleHandlers::AbilityOnSwitchIn.add(:JUSTIFICATION,
    proc { |ability,battler,battle|
    battler.pbRaiseStatStageByAbility(:ATTACK,1,battler)
    }
    )
     
    Hi,
    I'm trying to make an ability that on switch in check the opponent's stats like Download does, but I wanted to make it so that if the user is faster than the opponent they get a stat boost. I'm struggling to figure out how to get the ability to check the Pokemon's speed stats and determine who is faster. I have the code to raise the stat (it's just Intrepid Sword at this point) but I just wanted the condition on it. Would love any help. Thanks.

    BattleHandlers::AbilityOnSwitchIn.add(:JUSTIFICATION,
    proc { |ability,battler,battle|
    battler.pbRaiseStatStageByAbility(:ATTACK,1,battler)
    }
    )

    Hi, if it's "like Download" then try to adapt the code for Download ^^
    I am not sure I understand you ability though. The user gets a boost if it is faster than the opponent? Or maybe you mean "slower"?

    Code:
    BattleHandlers::AbilityOnSwitchIn.add(:JUSTIFICATION,
      proc { |ability,battler,battle|
        battle.eachOtherSideBattler(battler.index) do |b|
          # Raises speed once if one opponent has a higher speed.
          next if battler.speed > b.speed
          battler.pbRaiseStatStageByAbility(:SPEED,1,battler)
          break 
        end
      }
    )

    The idea is: check the speed of all the opponents; if one is faster than the holder of the ability, then boost its speed just once.
     
    Yeah, I realize that I wasn't super clear with what my idea was. But the code you have was the idea, though it would raise attack if the user was slower (I changed that my self). Code is working, didn't realize it was as simple as "next if battler.speed > b.speed". I keep trying to over complicate the code and that never ends up working.
    Thanks!
     
    Back
    Top