• 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!
  • 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] Coding an Ability version of Destiny Bond

  • 143
    Posts
    11
    Years
    • Seen Jun 11, 2021
    I've been trying to create an ability that has the effects of Destiny Bond, but for some reason, it's not working at all whenever I try to test it out.
    Code:
    if target.isFainted?
            destinybond=destinybond || (target.effects[PBEffects::DestinyBond] [B][COLOR=Red]|| target.hasWorkingAbility(:FAINTINGSPIRIT))[/COLOR][/B]
          end
    This is one of the lines of code I've edited.
    Code:
    if target.hasWorkingAbility(:FAINTINGSPIRIT,true) && @battle.pbRandom(50)<3# && target.pbIsOpposing?(user.index)
            @battle.pbDisplayEffect(target)
            PBDebug.log("[Ability triggered] #{target.pbThis}'s Fainting Spirit")
            @battle.pbDisplay(_INTL("{1}'s {2} took {3} down!",target.pbThis,PBAbilities.getName(target.ability),user.pbThis))
            user.pbReduceHP(user.hp)
            user.pbFaint # no return
            @battle.pbJudgeCheckpoint(user)
          end
    And I've added this section after Destiny Bond's code. Basically, the ability's supposed to have a 50% chance to make the attacker faint if the target with the ability faints, but so far, it hasn't worked at all.
     
    @battle.pbRandom(50)<3 means that a random number from 0 to 49 must be less than 3 - a 6% chance of happening. You probably haven't triggered it yet.

    For a 50% chance, you want something more akin to @battle.pbRandom(100)<50 or @battle.pbRandom(2)==0


    Also, for testing purposes, comment out any random factors. Make it so it always happens, just to test that it works as expected, then add in the randomness.
     
    Last edited:
    Back
    Top