• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Akari, Red, Kris, May - which Pokémon protagonist is your favorite? Let us know by voting in our semifinal favorite protagonist poll!
  • 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] Need Help Implementing an Ability

  • 9
    Posts
    2
    Years
    Hey! I've been trying to program in an ability that automatically activates the effects of taunt when the Pokemon switches in.

    Code:
    BattleHandlers::AbilityOnSwitchIn.add(:ANNOYING,
      proc { |ability,battler,battle|
        battle.pbShowAbilitySplash(battler)
        battle.pbDisplay(_INTL("{1} is annoying!",battler.pbThis))
        battle.pbHideAbilitySplash(battler)
      
      
        def pbEffectAgainstTarget(user,target)
        target.effects[PBEffects::Taunt] = 4
        @battle.pbDisplay(_INTL("{1} fell for the taunt!",target.pbThis))
        target.pbItemStatusCureCheck
      end
      }
    )

    As you can see, I simply tried copying the effects of the move taunt into the ability on switch in. This isn't working. If anyone could help me with this, that would be awesome.
     
    Hey,
    I have to go to work so I don't have uch time to explain this code: basically, when we say you need to copy the code of another move or ability, you have to adapt it so your code shares the same variables.
    Also don't forget that Taunt shouldn't work if the target is already taunted or if the target has Oblivious.
    Finally, when you have an ability on switch-in, there is no designated "target", you have to apply your ability to every opposing Pokémon.
    This code is in Essentials v18 but I assume it should work for v20.

    Code:
    BattleHandlers::AbilityOnSwitchIn.add(:ANNOYING,
      proc { |ability,battler,battle|
        battle.pbShowAbilitySplash(battler)
        battle.pbDisplay(_INTL("{1} is annoying!",battler.pbThis))
       
        # The ability applies to every opposing Pokémon
        battler.eachOpposing { |b| 
          # Don't taunt a Poké that's already taunted.
          next if b.effects[PBEffects::Taunt]>0
          # Oblivious protects from Taunt:
          if b.hasActiveAbility?(:OBLIVIOUS) && !battle.moldBreaker
            battle.pbShowAbilitySplash(b)
            if PokeBattle_SceneConstants::USE_ABILITY_SPLASH
              battle.pbDisplay(_INTL("But it failed!"))
            else
              battle.pbDisplay(_INTL("But it failed because of {1}'s {2}!",
                 b.pbThis(true),b.abilityName))
            end
            battle.pbHideAbilitySplash(b)
            next
          end
          b.effects[PBEffects::Taunt] = 4
          battle.pbDisplay(_INTL("{1} fell for the taunt!",b.pbThis))
          b.pbItemStatusCureCheck
        }
        battle.pbHideAbilitySplash(battler)
      }
    )
     
    Back
    Top