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

155
Posts
9
Years
  • Age 31
  • 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.
 
824
Posts
8
Years
@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