• 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 Conquest 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.

[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