• 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] Parenting Bond but only with super effective attacks

16
Posts
4
Years
    • Seen May 1, 2023
    Hey guys,
    as the title suggests i am trying to implement a custom ability that attacks twice if the attack is super effective. However i have a problem with the necessary condition for the script.
    Code:
      def pbNumHits(user,targets)
        if user.hasActiveAbility?(:ONCEMORE) && pbDamagingMove? && Effectiveness::SUPER_EFFECTIVE_ONE &&
           !chargingTurnMove? && targets.length==1
          user.effects[PBEffects::OnceMore] = 3
          return 2
        end
        return 1
      end
    I tried variations like "Effectiveness.super_effective?(target.damageState.typeMod)" but i get an error saying that damageState is undefined.
    My code above works but it always hits twice and seems to ignore the effectiveness.
    Hope anybody can help
    Cheers
     

    StCooler

    Mayst thou thy peace discover.
    9,301
    Posts
    4
    Years
    • Seen May 5, 2024
    Hey guys,
    as the title suggests i am trying to implement a custom ability that attacks twice if the attack is super effective. However i have a problem with the necessary condition for the script.
    Code:
      def pbNumHits(user,targets)
        if user.hasActiveAbility?(:ONCEMORE) && pbDamagingMove? && Effectiveness::SUPER_EFFECTIVE_ONE &&
           !chargingTurnMove? && targets.length==1
          user.effects[PBEffects::OnceMore] = 3
          return 2
        end
        return 1
      end
    I tried variations like "Effectiveness.super_effective?(target.damageState.typeMod)" but i get an error saying that damageState is undefined.
    My code above works but it always hits twice and seems to ignore the effectiveness.
    Hope anybody can help
    Cheers

    Usually I don't respond to Essentials v19 questions but I've also coded a similar "Parental Bond" ability so I figured I might have enough background to help this time ^^
    So actually target.damageState.typeMod doesn't exist here. I think it's because you wrote targets.damageState.typeMod (with the "s") ? Then it's an array and not a PokeBattle_Battler, and damageState indeed doesn't exist.
    You'd have to go with Effectiveness.super_effective?(targets[0].damageState.typeMod). But to do that, you need to be sure that targets is an array that contains exactly one item, so you should put it at the end of the condition.
    Also, you shouldn't remove the existing Parental Bond code from the original function, or you'll be breaking something.
    Finally, I suggest you use the same PBEffect as Parental Bond, instead of creating your own one OnceMore, because you'll be duplicating the same code for something that does exactly the same, but under different conditions. Also note that OnceMore and ParentalBond don't seem to stack together, are both are triggered by a different ability, and every Pokémon has only one ability.

    In summary, the function should look like this:

    Code:
      def pbNumHits(user,targets)
        if user.hasActiveAbility?(:PARENTALBOND) && pbDamagingMove? && # Keep the existing code.
           !chargingTurnMove? && targets.length==1
          # Record that Parental Bond applies, to weaken the second attack
          user.effects[PBEffects::ParentalBond] = 3
          return 2
        elsif user.hasActiveAbility?(:ONCEMORE) && pbDamagingMove? &&  # Your added code.
          !chargingTurnMove? && targets.length==1 && 
          Effectiveness.super_effective?(targets[0].damageState.typeMod)
          user.effects[PBEffects::ParentalBond] = 3
          return 2
        end
        return 1
      end

    (We're talking about pbNumHits in the script 002_Move_Usage)
     
    16
    Posts
    4
    Years
    • Seen May 1, 2023
    Thank you so much, man. It worked like a charm. I clearly don't know enough about scripting, haha. I actually created a new effect because i don't want to weaken the second hit with Once More. For obvious balancing reasons, only Baby-Pokemon should be able to use this ability.
    Thanks again!
     
    Back
    Top