• 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.

Trying to add Parental Bond

1,224
Posts
10
Years
  • Title says all

    tried adding this code
    Code:
    if isConst?(attacker.ability,PBAbilities,:PARENTALBOND)
          basedmg=(basedmg*8/10).floor
          def pbisMultiHit
            return true
          end
          def pbNumHits
        return 2
      end
      end
    to PokeBattle Move. It doesn't crash the game, but it also doesn't hit twice. I pretty much just copied the coding for double hit moves (0BD).
     

    Nickalooose

    --------------------
    1,309
    Posts
    16
    Years
    • Seen Dec 28, 2023
    Question.

    Why do you have the def parts here?
    Code:
    if isConst?(attacker.ability,PBAbilities,:PARENTALBOND)
          basedmg=(basedmg*8/10).floor
          [COLOR="Red"]def[/COLOR] pbisMultiHit
            return true
          end
          [COLOR="Red"]def[/COLOR] pbNumHits
        return 2
      end
      end

    The first one should be an if and the second one, non existent.

    You've literally just copied move function 0BD, you shouldn't have... I don't know what Parental Bond does, so I have no idea what you're trying to do... So I'm going to Google it............Searching............Bulbapedia............Reading..............
    At first read;
    Bulbapedia said:
    Parental Bond allows the Pokémon to attack twice each turn on the same target (even if it fainted), with the second attack being half as strong as the first.
    That is the very first line of In Battle.
    All you're doing is changing the basedmg to... I have no idea what tbh... Then creating a def (which already exists) returning something true (I don't know what) creating another def (which already exists) and returning 2 for something... Well since I don't know what any of that code is doing, let me try something.

    Add all this to PokeBattle_Battler.
    Underneath:
    Code:
            elsif isConst?(user.ability,PBAbilities,:STENCH) && @battle.pbRandom(10)==0
              if !isConst?(target.ability,PBAbilities,:INNERFOCUS) &&
                 target.effects[PBEffects::Substitute]==0 &&
                 thismove.function!=0x009 && # Thunder Fang
                 thismove.function!=0x00B && # Fire Fang
                 thismove.function!=0x00E && # Ice Fang
                 thismove.function!=0x00F && # flinch-inducing moves
                 thismove.function!=0x010 && # Stomp
                 thismove.function!=0x011 && # Snore
                 thismove.function!=0x012 && # Fake Out
                 thismove.function!=0x078 && # Twister
                 thismove.function!=0x0C7    # Sky Attack
                target.effects[PBEffects::Flinch]=true
              end
            end
          end
    Add:
    Code:
          # Parental Bond
          if isConst?(user.ability,PBAbilities,:PARENTALBOND) && thismove.basedamage>0 && realnumhits==2
            @battle.pbDisplay(_INTL("{1}'s {2} hit twice with Parental Bond!",user.pbThis,thismove.name))
          end
    This will make sure that the attack will double attack, if the user has ability Parental Bond and the attack has a base damage, i.e. not a status attack, but will also only display a message on the second attack... Now, after each line like this:
    Code:
          break if target.hp<=0
    Add:
    Code:
          break if target.hp<=0[COLOR="Red"] && !isConst?(user.ability,PBAbilities,:PARENTALBOND)[/COLOR]
    There should be 3 that looks like this... And then there is one more line nearer the end of the def, which is this one:
    Code:
        # Opponent faints if 0 HP
        if [COLOR="red"]target.hp<=0[/COLOR]
          target.pbFaint # no return
        end
    Add this:
    Code:
        # Opponent faints if 0 HP
        if target.hp<=0[COLOR="red"] && (!isConst?(user.ability,PBAbilities,:PARENTALBOND) || realnumhits==2)[/COLOR]
          target.pbFaint # no return
        end
    These will make sure that even when the Pokémon faints, it still attacks, because
    Bulbapedia said:
    Parental Bond allows the Pokémon to attack twice each turn on the same target (even if it fainted)...
    Which is weird beating a Pokémon while it's down... But hey, I didn't make the move... Anyway, on to the last part, find this line, a few lines down:
    Code:
        # Number of hits
        @battle.pbDisplay(_INTL("Hit {1} time(s)!",realnumhits))
    And change it to this:
    Code:
        # Number of hits
        if !isConst?(user.ability,PBAbilities,:PARENTALBOND)
          @battle.pbDisplay(_INTL("Hit {1} time(s)!",realnumhits))
        end
    This will ensure that the move DOESN'T say "Hit 2 time(s)!" at the end of every move, but will say the custom phrase, "Bulbasaur's Tackle hit twice with Parental Bond!", for example.

    Next, go down to pbUseMove(choice), find this:
    Code:
            numhits=thismove.pbNumHits
    And change it to this:
    Code:
            if isConst?(user.ability,PBAbilities,:PARENTALBOND)
              numhits=2
            else
              numhits=thismove.pbNumHits
            end
    This is because, a move like tackle for example will always return 1 for numhits and won't attack a second time... Then finally, find:
    Code:
            if thismove.pbIsMultiHit
              pbProcessMultiHitMove(thismove,user,target,numhits,alltargets,showanimation)
            else
              pbProcessNonMultiHitMove(thismove,user,target,false,alltargets,showanimation)
            end
    And add this:
    Code:
            if thismove.pbIsMultiHit [COLOR="Red"]|| isConst?(self.ability,PBAbilities,:PARENTALBOND)[/COLOR]
              pbProcessMultiHitMove(thismove,user,target,numhits,alltargets,showanimation)
            else
              pbProcessNonMultiHitMove(thismove,user,target,false,alltargets,showanimation)
            end
    This will ensure that a Pokémon with Parental Bond as their ability will always do a multi hit.
    Don't forget this:
    Code:
    XXX,PARENTALBOND,Parental Bond,"All damage moves hit twice, the second attack does half damage."
    In abilities.txt.

    All this code allows is attacking twice if user has Parental Bond as their ability... Base damages and moves that aren't effected by this or Pokémon it shouldn't effect or whatever, will still act as normal, don't assume because I have given you this, that it will work 100% like it should... I've put most of the ingredients in a pot, it's up to you to add more and not to burn them.

    Have fun.
     
    Last edited:
    1,224
    Posts
    10
    Years
  • Thank you so much! I created the defs because they do that multiple times in pokebattle moveeffects, but now I'm realizing it's because they're in different classes. Anyway, works like a charm now.
     
    4
    Posts
    12
    Years
    • Seen Mar 30, 2024
    How can I do that the second hit does only the half damage?
     
    Back
    Top