• 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.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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
     
    I want to do something similar but for slicing moves only, but in essentials v21 I can't find the parental bond code
    is there a slicing move definition? heres my code for something similar in v21

    class Battle::Move
    alias trinket_pbNumHits pbNumHits
    def pbNumHits(user, targets)
    return 1 if defined?(powerMove?) && powerMove?
    if user.hasActiveItem?([:GALVANIZEDSETAE])
    pbDamagingMove? && !chargingTurnMove? && targets.length == 1
    user.effects[PBEffects::ParentalBond] = 3
    return 2
    end
    return trinket_pbNumHits(user, targets)
    end
    end

    a problem I've encountered that i don't know how to fix is getting the additional hits to inherit the original move animation, using this alias in a script above main causes those hits to be invisible.
     
    Back
    Top