• 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] I need help to make an ability

  • 12
    Posts
    5
    Years
    • Seen Jan 24, 2020
    I want to make an ability that lowers the opponents Special Defense every turn. I copied the speed boost ability and changed a few things, but i cant get it to lower the opponents sp def. The only thing it works is lowering my special defense. if i.pbReduceStatWithCause(PBStats::DEFENSE,2,i,PBAbilities.getName(i.ability)) This script lowers my def how can i make it so it lowers the opponents sp def, pls help
     
    So obviously "i" refers to the Pokémon with the ability and that's why it's lowering your Pokémon's special defense. What you need is a way to get the opposing Pokémon, which you can do with a variety of things depending on how you want it to work for double battles. Search for pbOpposing and see if you can work out which one you think is appropriate for your use case.
     
    But what '' i'' should I change, i tried replacing them with opponent or target but it shows a no method error. And I want to lower every opposing pokemons spdef, if you have any ideas I would appreciate it
     
    Last edited:
    The first "i"—because that's the Pokémon you're reducing the stat of (foo.pbReduceStatWithCause(...) reduces foo's stats). As for what to replace it with, I already suggested searching for pbOpposing to see how that's used.
     
    Well is better you check how Intimidate works to decrease opponent's ATK and then create your ability to dec. SP.ATK, using Speed Boost to check every turn.
     
    Last edited:
    With Intimidate it puts user instead of I which I have tried and it didn't work.
     
    I still need help, i cant find out how to do it. Can anyone just send me the script?
    Update: I figured out how to lower the opponents spdef upon entering the battle but when i try using if i.turncount>0 instead of onactive so it can last every turn it says there is a syntax error.
     
    Last edited:
    See, the reason you don't get a useful answer is because you don't provide enough information.
    When asking a coding related question always provide: What you want to do (as specific as possible), What you have tried so far, What exactly is it that you are stuck on, Error Messages (if any) and of course the part of the code that is not working and in what script section it is.
    Pro tip: use
    Code:
     tags to submit code, as it is easier t read.
    
    Right now we have no clue what your whole attempt looks like and therefore can't tell you what you would need to put in, for it to work as expected. I appreciate that u already tried to solve it on your own, bu you can't expect any help without doing anything and you especially can't expect people to just give out finished code. If someone feels like doing this it's one thing, but in most case you would just get general advice/help.
    
    This is not meant to be a rude reply or anythin, but I feel like this needs to be made clear more often and I want you to be able to improve your future postings, instead of getting the feeling that no one wants to help you, without knowing why. Cause we all like to help and answer question, but not if we have to ask for every little detail in order to help.
     
    I think i was clear but i will say it again. I want to make an ability that lowers the opponents spdef every turn, like speed boost. Right now i have this code
    [if i.turncount>0 && i.hasWorkingAbility(:TORMENT)
    if opponent.pbReduceStatWithCause(PBStats:: SPECIALDEFENSE,2,i,PBAbilities.getName(i.ability))
    PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
    end
    end]
    but every time i try to run it it gives me a nomethod error for the 'opponent' and i dont know why.
    I have tried changing it to target and self but still no luck. It is below the speed boost ability.
    Also i dont know how to use the code tags sorry. Also i put a gap between the SpecialDefense and the '':'' because it turned into an emoji.
     
    Last edited:
    Okay but where is this code written, like in what method?

    Also, you misunderstood the use of code tags, but I appreciate you trying to use them. Click on the </> symbol in the editor to insert the code blocks and then paste your code in between those tags
     
    A method is the thing that starts with "def". So we need to know what "def" it is in (like "def abillitiesOnActive")
     
    What def is what in? The code? It gives undefined method in pbReduceStatWithCause
    Exception: NoMethodError
    Message: undefined method `pbReduceStatWithCause' for nil:NilClass
    PokeBattle_Battle:3736:in `__clauses__pbEndOfRoundPhase'
    PokeBattle_Battle:3725:in `each'
    PokeBattle_Battle:3725:in `__clauses__pbEndOfRoundPhase'
    PokeBattle_Clauses:42:in `pbEndOfRoundPhase'
    PokeBattle_Battle:2540:in `pbStartBattleCore'
    PokeBattle_Battle:2539:in `logonerr'
    PokeBattle_Battle:2539:in `pbStartBattleCore'
    PokeBattle_Battle:2521:in `loop'
    PokeBattle_Battle:2544:in `pbStartBattleCore'
    PokeBattle_Battle:2341:in `pbStartBattle'
    Thats the error msg
     
    Last edited:
    The info I was looking for was that your code is part of "def pbEndOfRoundPhase"

    Then your code for the ability should look like this:

    Code:
    if i.hasWorkingAbility(:TORMENT)
    for j in priority
    next if !pbIsOpposing?(i)
    if j.pbReduceStatWithCause(PBStats:: SPECIALDEFENSE,2,i,PBAbilities.getName(i.ability))
    PBDebug.log("[Ability triggered] #{i.pbThis}'s #{PBAbilities.getName(i.ability)}")
    end
    end
    end

    I removed the turncount, as I believe it is not neccassary, but of course it can be added back in if it turns out you actually need it.
     
    Last edited:
    It kinda worked. Now it lowers the opponents spdef but it lowers mine as well
    Update: Ok thank you for helping me.
     
    Last edited:
    Oh yeah I forgot to exclude the users side.
    I edited my previous answer, so now it should only lowr the opposing sides spdef
     
    Yea now it works so thank you, i would like to ask one more thing. I have made another thread about an interesting idea i have about an ability. Would you mind checking it out?
     
    Back
    Top