• 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!
  • Dawn, Gloria, Juliana, or Summer - which Pokémon protagonist is your favorite? Let us know by voting in our 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.

[Scripting Question] Help for Custom Ability: Stealth Rock Problem

  • 32
    Posts
    7
    Years
    Hello!

    I've already managed to create an ability called "Wonder Mirror" for Cryogonal. Normally, Cryogonal is weak to Fire/Rock/Steel/Fighting due to its ice type. With "Wonder Mirror", however, it resists these types and is only weak to ice.

    This is the code I put in PokéBattle_Move

    Spoiler:


    Now, my problem is that despite its new ability, it still takes "effective" damage from Stealth Rock. I know that I probably have to add or change something in PokéBattle_Battle. I looked at Stealth Rock and noticed that it would take into account four aspects:
    Spoiler:


    I tried to include the custom ability, but I still get the following message and don't know how to make the ability work for Stealth Rock.
    Spoiler:
     
    Last edited:
    This isn't related to your error, but you're setting mod values to 3 sometimes. The number that means "super-effective" is 4, because it's double 2 ("normal effectiveness") and super-effective moves do twice as much damage as normal effectiveness ones.
     
    Last edited:
    This isn't related to your error, but you're setting mod values to 3 sometimes. The number that means "super-effective" is 4, because it's double 2 ("normal effectiveness") and super-effective moves do twice as much damage as normal effectiveness ones.

    Thanks for making me aware of this!
     
    Message: wrong number of arguments(5 for 4)

    This message is self explanatory: you're trying to pass 5 arguments, but the method getCombinedEffectiveness can only take 4.

    I would suggest a different approach, adding an exception case for this particular ability so that it bypasses having to use getCombinedEffectiveness.

    In approximately line 2139 of PokeBattle_Battle, marked with "# Stealth Rock" in my code, I've tried this:

    Code:
          # Stealth Rock
          if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.fainted?
            if !pkmn.hasWorkingAbility(:MAGICGUARD)
              atype=getConst(PBTypes,:ROCK) || 0
              eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
              if pkmn.hasWorkingAbility(:WONDERMIRROR)
                eff == 0.5
              end
              if eff>0
                PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
                @scene.pbDamageAnimation(pkmn,0)
                pkmn.pbReduceHP(((pkmn.totalhp*eff)/64).floor)
                pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
              end
            end
          end

    I'm assuming that setting eff to 0.5 will reduce the damage done to the pokemon by half. I haven't tested this myself, so please let me know how it goes.
     
    Last edited:
    This message is self explanatory: you're trying to pass 5 arguments, but the method getCombinedEffectiveness can only take 4.

    I would suggest a different approach, adding an exception case for this particular ability so that it bypasses having to use getCombinedEffectiveness.

    In approximately line 2139 of PokeBattle_Battle, marked with "# Stealth Rock" in my code, I've tried this:

    Code:
          # Stealth Rock
          if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.fainted?
            if !pkmn.hasWorkingAbility(:MAGICGUARD)
              atype=getConst(PBTypes,:ROCK) || 0
              eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
              if pkmn.hasWorkingAbility(:WONDERMIRROR)
                eff == 0.5
              end
              if eff>0
                PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
                @scene.pbDamageAnimation(pkmn,0)
                pkmn.pbReduceHP(((pkmn.totalhp*eff)/64).floor)
                pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
              end
            end
          end

    I'm assuming that setting eff to 0.5 will reduce the damage done to the pokemon by half. I haven't tested this myself, so please let me know how it goes.

    Hello!

    Thank you very much for your suggestion! And I'm so terribly sorry for not replying earlier. I had lots of things to do, and it's only now that I have some time to spare.
    Anyway, I tried out your code but my Cryogonal still takes "effective" damage from Stealth Rock, unfortunately.
     
    Hello!

    Thank you very much for your suggestion! And I'm so terribly sorry for not replying earlier. I had lots of things to do, and it's only now that I have some time to spare.
    Anyway, I tried out your code but my Cryogonal still takes "effective" damage from Stealth Rock, unfortunately.

    I think Screedle made a typo, and should have written "eff = 0.5", i.e.:
    Spoiler:
     
    I think Screedle made a typo, and should have written "eff = 0.5", i.e.:
    Spoiler:

    Thanks for the reply as well! However, whenever one of my Pkm with Wonder Mirror enters the battle, it would only lose 1 hp because 0.5 is rounded up.
     
    Thanks for the reply as well! However, whenever one of my Pkm with Wonder Mirror enters the battle, it would only lose 1 hp because 0.5 is rounded up.

    I dunno.
    Code:
    pkmn.pbReduceHP(((pkmn.totalhp*eff)/64).floor)
    This shouldn't round until the end, and even then it rounds down.

    Oh, but perhaps 0.5 is the wrong number. What's the range on combined effectiveness? Where does the division by 64 come from? I guess those are the questions you'll want to answer, and then ultimately change 0.5 for a bigger number that actually works out to do the damage you want.
     
    Back
    Top