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

[Scripting Question] Custom Ability

18
Posts
7
Years
    • Seen Apr 17, 2023
    Hi! I tried to add an ability, but I cant. Its very easy: when ur pokemon enters the battle, the enemy gets poisoned. Like intimidate, but with poison instead. How I add this ability? How would be the code? Thanks very much.
     
    Last edited by a moderator:
    971
    Posts
    7
    Years
    • Age 21
    • Seen Nov 28, 2022
    If you're just starting out with code, it's probably best to learn the basics of Ruby, the language RMXP uses. If you've done that, you should be able to "translate" Ruby into "English". With that I mean, being able to understand in a sentence what a line of code does, that will really help in the future. You want an ability that activates when a Pokémon is switched in, for which is already a method inside PokeBattle_Battler that's called "def pbAbilitiesOnSwitchIn". Whenever a Pokémon is switched in, it will look through all the lines below it and check if the Pokémon that's switched in meets any of the statements. If your Pokémon has the ability "CUSTOMABILITY", it will check to see if the first opponent can be poisoned and if so, poison it. If there is a second opponent and it can be poisoned, it will poison that as well. There are also other handy methods in PokeBattle_Battler, "def pbEffectsOnDealingDamage", which activates whenever a Pokémon is hit.

    As for the actual script you wanted, here it is (Paste underneath Intimidate in PokeBattle_Battler):
    Code:
    # CUSTOMABILITY
        if self.hasWorkingAbility(:CUSTOMABILITY) && onactive
          if pbOpposing1.pbCanPoison?(nil,false)
            pbOpposing1.pbPoison(pbOpposing1,_INTL("{1} was poisoned!",pbOpposing1))
          end
          if pbOpposing2.pbCanPoison?(nil,false)
            pbOpposing2.pbPoison(pbOpposing2,_INTL("{1} was poisoned!",pbOpposing2))
          end
        end
    In the future, you could look at other pieces of abilities or code in general and copy what you need and copy things from other abilities to get something that works.
     
    18
    Posts
    7
    Years
    • Seen Apr 17, 2023
    If you're just starting out with code, it's probably best to learn the basics of Ruby, the language RMXP uses. If you've done that, you should be able to "translate" Ruby into "English". With that I mean, being able to understand in a sentence what a line of code does, that will really help in the future. You want an ability that activates when a Pokémon is switched in, for which is already a method inside PokeBattle_Battler that's called "def pbAbilitiesOnSwitchIn". Whenever a Pokémon is switched in, it will look through all the lines below it and check if the Pokémon that's switched in meets any of the statements. If your Pokémon has the ability "CUSTOMABILITY", it will check to see if the first opponent can be poisoned and if so, poison it. If there is a second opponent and it can be poisoned, it will poison that as well. There are also other handy methods in PokeBattle_Battler, "def pbEffectsOnDealingDamage", which activates whenever a Pokémon is hit.

    As for the actual script you wanted, here it is (Paste underneath Intimidate in PokeBattle_Battler):
    Code:
    # CUSTOMABILITY
        if self.hasWorkingAbility(:CUSTOMABILITY) && onactive
          if pbOpposing1.pbCanPoison?(nil,false)
            pbOpposing1.pbPoison(pbOpposing1,_INTL("{1} was poisoned!",pbOpposing1))
          end
          if pbOpposing2.pbCanPoison?(nil,false)
            pbOpposing2.pbPoison(pbOpposing2,_INTL("{1} was poisoned!",pbOpposing2))
          end
        end
    In the future, you could look at other pieces of abilities or code in general and copy what you need and copy things from other abilities to get something that works.

    Hii! I could make something like.. When the poke enters, he poisons the enemy. But my code had nothing about double battles, or if the opponent was poison type. Yours is much better, but it shows me an error.. 'Argument Error', wrong number of arguments (2 for 1)
    What is that? ;_;
    Thanks very much for the code by the way!! I love you ;____;
     
    Back
    Top