• 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] More help please...

163
Posts
5
Years
  • I have defined this ability called Infected Fur, which badly poisons the attacker on contact but also prevents the user from being poisoned. The way it prevents the user from being poisoned works but the bad poisoning on contact doesn't!

    I also want it to be a 100% chance of badly poisoning the target on contact!

    Here's the code:
    if user.hasWorkingAbility(:INFECTEDFUR,true) && @battle.pbRandom(10)==10 &&
    target.pbCanPoison?(nil,true)
    PBDebug.log("[Ability triggered] #{user.pbThis}'s Infected Fur")
    target.pbPoison(user,_INTL("{1}'s {2} poisoned {3}!",user.pbThis,
    PBAbilities.getName(user.ability),target.pbThis(true)),toxic)
    end

    What am I doing wrong?
     

    Poq

    144
    Posts
    6
    Years
    • Seen Aug 28, 2021
    The problem is with this condition:

    @battle.pbRandom(10)==10

    That code means that the effect will only work if the random number equal ten. You have two problems. If you use == the ability will not work if the random number is anything but 10.
    That leads to your second problem. pbRandom starts at 0. So pbRandom 10 is generating a number between 0 and 9. It will never equal 10.
    If you want your ability to work 100% of the time, either change the == to < OR just remove that condition entirely. It's only there to handle a chance of failing, but you don't even want that.
     
    Last edited:
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    I think you can replace everything after target.pbPoison with (target, nil, true) to get that kind of effect of harsh poisoning.
     
    Last edited:
    163
    Posts
    5
    Years
  • The problem is with this condition:

    @battle.pbRandom(10)==10

    That code means that the effect will only work if the random number equal ten. You have two problems. If you use == the ability will not work if the random number is anything but 10.
    That leads to your second problem. pbRandom starts at 0. So pbRandom 10 is generating a number between 0 and 9. It will never equal 10.
    If you want your ability to work 100% of the time, either change the == to < OR just remove that condition entirely. It's only there to handle a chance of failing, but you don't even want that.

    Oh!
     
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    Something like this I think:
    Code:
    if user.hasWorkingAbility(:INFECTEDFUR,true) && target.pbCanPoison?(nil,false)
    target.pbPoison(target,nil,true)
    end
     
    Last edited:
    163
    Posts
    5
    Years
  • Something like this I think:
    Code:
    if user.hasWorkingAbility(:INFECTEDFUR,true) && target.pbCanPoison?(nil,false)
    target.pbPoison(target,nil,true)
    end

    Nevermind, it doesn't work!

    But will this work (it won't be a 100% toxic poisoning though)?

    if user.hasWorkingAbility(:INFECTEDFUR,true) &&
    target.pbCanPoison?(nil,false) && @battle.pbRandom(10)<3
    PBDebug.log("[Ability triggered] #{user.pbThis}'s Infected Fur")
    target.pbPoison(user,_INTL("{1}'s {2} poisoned {3}!",user.pbThis,
    PBAbilities.getName(user.ability),target.pbThis(true)),toxic)
    end
     
    Last edited:
    72
    Posts
    5
    Years
    • Seen Jan 24, 2021
    That should work. Poq said to remove the condition "&&@battle.pbRandom(10)<3" for the ability to always work.
     
    Back
    Top