• 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] Help for Custom Ability: Stealth Rock Problem

  • 32
    Posts
    6
    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:

    Maruno

    Lead Dev of Pokémon Essentials
  • 5,286
    Posts
    16
    Years
    • Seen May 3, 2024
    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:
  • 32
    Posts
    6
    Years
    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!
     
  • 19
    Posts
    4
    Years
    • Seen Jan 14, 2021
    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:
  • 32
    Posts
    6
    Years
    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.
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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:
     
  • 32
    Posts
    6
    Years
    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.
     
  • 1,403
    Posts
    10
    Years
    • Seen Apr 29, 2024
    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