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

  • 16
    Posts
    5
    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
     
    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)
     
    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!
     
    I want to do something similar but for slicing moves only, but in essentials v21 I can't find the parental bond code
     
    Back
    Top