• 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] Stealth Rock changes help

79
Posts
8
Years
    • Seen Jan 12, 2024
    Hello, I'm trying to rebalance Stealth Rock so that it no longer takes quad ineffectiveness or quad effectiveness into account, instead dealing 1/16th if Rock is Not Very Effective, 1/8th if Neutral, and 1/4th if Super Effective. This is the script I have so far:

    Spoiler:

    It successfully deals 1/16th HP if Rock is Not Very Effective and 1/8th if neutral, however Super Effective also deals 1/8th damage. What changes should I make? Thanks!
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    I have trouble understanding how type effectiveness works, so I can relate.

    Fortunately, the module PBTypes has useful functions:
    Code:
      def PBTypes.ineffective?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
      def PBTypes.notVeryEffective?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
      def PBTypes.resistant?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
      def PBTypes.normalEffective?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
      def PBTypes.superEffective?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
    and all these functions can take the result of PBTypes.getCombinedEffectiveness() in place of attackType.

    I suggest the following code:
    Code:
          if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.fainted?
            if !(pkmn.hasWorkingAbility(:MAGICGUARD) ||
                pkmn.hasWorkingItem(:HEAVYDUTYBOOTS))
              atype=getConst(PBTypes,:ROCK) || 0
              eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
              if eff>0
                PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
                @scene.pbDamageAnimation(pkmn,0)
                if PBTypes.resistant?(eff)
                  pkmn.pbReduceHP((pkmn.totalhp/16).floor)
                elsif PBTypes.superEffective?(eff)
                  pkmn.pbReduceHP((pkmn.totalhp/4).floor)
                else # Normal effective 
                  pkmn.pbReduceHP((pkmn.totalhp/8).floor)
                end
                pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
              end
            end
          end

    PS: Also, when you have several "if" and "elsif", it's good practice to leave one of these as a default case, just in case ^^
     
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    I have trouble understanding how type effectiveness works, so I can relate.

    Fortunately, the module PBTypes has useful functions:
    Code:
      def PBTypes.ineffective?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
      def PBTypes.notVeryEffective?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
      def PBTypes.resistant?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
      def PBTypes.normalEffective?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
      def PBTypes.superEffective?(attackType,targetType1=nil,targetType2=nil,targetType3=nil)
    and all these functions can take the result of PBTypes.getCombinedEffectiveness() in place of attackType.

    I suggest the following code:
    Code:
          if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.fainted?
            if !(pkmn.hasWorkingAbility(:MAGICGUARD) ||
                pkmn.hasWorkingItem(:HEAVYDUTYBOOTS))
              atype=getConst(PBTypes,:ROCK) || 0
              eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
              if eff>0
                PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
                @scene.pbDamageAnimation(pkmn,0)
                if PBTypes.resistant?(eff)
                  pkmn.pbReduceHP((pkmn.totalhp/16).floor)
                elsif PBTypes.superEffective?(eff)
                  pkmn.pbReduceHP((pkmn.totalhp/4).floor)
                else # Normal effective 
                  pkmn.pbReduceHP((pkmn.totalhp/8).floor)
                end
                pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
              end
            end
          end

    PS: Also, when you have several "if" and "elsif", it's good practice to leave one of these as a default case, just in case ^^

    Thanks for the help! I tried using your code, but I get the following error:

    Spoiler:


    I'm using V17, is that an issue? I also tried using the following code:

    Spoiler:

    But received this error instead:

    Spoiler:
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    Ah, v17, of course.
    Check the module PBTypes, and check if there is any function that looks like those that I mentioned.
     
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    Ah, v17, of course.
    Check the module PBTypes, and check if there is any function that looks like those that I mentioned.

    I only see PBTypes_Extra, not PBTypes. It does have functions for PBTypes.isNotVeryEffective?, PBTypes.isNormalEffective?, and PBTypes.isSuperEffective?, which is what I based the last script I posted on, but they give me argument errors.
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    I only see PBTypes_Extra, not PBTypes. It does have functions for PBTypes.isNotVeryEffective?, PBTypes.isNormalEffective?, and PBTypes.isSuperEffective?, which is what I based the last script I posted on, but they give me argument errors.

    What what arguments do they expect? Please post the "def XXX.isSuperEffective?" and such.
    What errors do they show? How do you call these functions?
     
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    What what arguments do they expect? Please post the "def XXX.isSuperEffective?" and such.
    What errors do they show? How do you call these functions?

    Here's the functions:

    Spoiler:

    And here's the error:

    Spoiler:
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    Ok, it's because the new functions in v18 can take the "eff" as a parameter, while the old functions from v17 cannot.

    The good news is that it's easy to fix:
    Code:
          if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.fainted?
            if !(pkmn.hasWorkingAbility(:MAGICGUARD) ||
                pkmn.hasWorkingItem(:HEAVYDUTYBOOTS))
              atype=getConst(PBTypes,:ROCK) || 0
              eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
              if eff>0
                PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
                @scene.pbDamageAnimation(pkmn,0)
                if eff < 8
                  pkmn.pbReduceHP((pkmn.totalhp/16).floor)
                elsif eff > 8
                  pkmn.pbReduceHP((pkmn.totalhp/4).floor)
                else # Normal effective 
                  pkmn.pbReduceHP((pkmn.totalhp/8).floor)
                end
                pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
              end
            end
          end
     
    79
    Posts
    8
    Years
    • Seen Jan 12, 2024
    Ok, it's because the new functions in v18 can take the "eff" as a parameter, while the old functions from v17 cannot.

    The good news is that it's easy to fix:
    Code:
          if pkmn.pbOwnSide.effects[PBEffects::StealthRock] && !pkmn.fainted?
            if !(pkmn.hasWorkingAbility(:MAGICGUARD) ||
                pkmn.hasWorkingItem(:HEAVYDUTYBOOTS))
              atype=getConst(PBTypes,:ROCK) || 0
              eff=PBTypes.getCombinedEffectiveness(atype,pkmn.type1,pkmn.type2,pkmn.effects[PBEffects::Type3])
              if eff>0
                PBDebug.log("[Entry hazard] #{pkmn.pbThis} triggered Stealth Rock")
                @scene.pbDamageAnimation(pkmn,0)
                if eff < 8
                  pkmn.pbReduceHP((pkmn.totalhp/16).floor)
                elsif eff > 8
                  pkmn.pbReduceHP((pkmn.totalhp/4).floor)
                else # Normal effective 
                  pkmn.pbReduceHP((pkmn.totalhp/8).floor)
                end
                pbDisplayPaused(_INTL("Pointed stones dug into {1}!",pkmn.pbThis))
              end
            end
          end

    This works! Thank you! I have a question, if I've already implemented all of the gen 7 mechanics into V17, would it still be worth it to update to 18? I only hesitate because I have quite a few custom scripts that would probably break
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    This works! Thank you! I have a question, if I've already implemented all of the gen 7 mechanics into V17, would it still be worth it to update to 18? I only hesitate because I have quite a few custom scripts that would probably break

    I would update to v18 if and only if I needed gen 8 stuff + some scripts that don't exist for v17 (Mid Battle Dialogue, Z-moves/Dynamax...).

    However, v17 and v18 seem to be quite close, as far as I can tell. Some functions are altered, but it should be easy to debug.

    You will spend a hard time making those changes though.
     
    233
    Posts
    5
    Years
    • Seen Oct 9, 2023
    I would update to v18 if and only if I needed gen 8 stuff + some scripts that don't exist for v17 (Mid Battle Dialogue, Z-moves/Dynamax...).

    However, v17 and v18 seem to be quite close, as far as I can tell. Some functions are altered, but it should be easy to debug.

    You will spend a hard time making those changes though.

    The two versions are relatively close if you're NOT talking about battle scripts. For battle scripts, they are leagues apart (v18 broke nearly ALL battle scripts that used to be on v17).

    This works! Thank you! I have a question, if I've already implemented all of the gen 7 mechanics into V17, would it still be worth it to update to 18? I only hesitate because I have quite a few custom scripts that would probably break

    Ideally, you would want to move to v18. If you plan on working on your game for a long time, then you will only be making it harder on yourself by working on an outdated version of Essentials. Though, if you're just making a shorter game and are planning to release it soon, then it's more understandable if you decide to stay on v17. Either way, there are more advantages than disadvantages to upgrading your game, so I would strongly consider it.
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    The two versions are relatively close if you're NOT talking about battle scripts. For battle scripts, they are leagues apart (v18 broke nearly ALL battle scripts that used to be on v17).

    Oh, ok, I didn't know that! Thanks :)
     
    Back
    Top