• 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!
  • Cyndy, May, Hero (Conquest), or Wes - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • 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] Help with custom ability

  • 31
    Posts
    9
    Years
    • Seen Dec 18, 2017
    So, I'm new to this for the most part. I ask that you take that into consideration.

    But getting strait into the matter at hand,
    The first new ability in my game is called "Tranquilize" it is a "Flame Body" clone with the goal of it putting the opponent asleep instead.

    Code:
              user.pbBurn(target,_INTL("{1}'s {2} burned {3}!",target.pbThis,
                 PBAbilities.getName(target.ability),user.pbThis(true)))
            end
            if target.hasWorkingAbility(:Tranquilize,true) && @battle.pbRandom(10)<3 &&
               user.pbCanSleep?(nil,false)
              PBDebug.log("[Ability triggered] #{target.pbThis}'s Tranquilize")
              user.pbSleep(target,_INTL("{1}'s {2} put to sleep {3}!",target.pbThis,
                 PBAbilities.getName(target.ability),user.pbThis(true)))
            end
            if target.hasWorkingAbility(:MUMMY,true) && !user.fainted?
              if !isConst?(user.ability,PBAbilities,:MULTITYPE) &&
                 !isConst?(user.ability,PBAbilities,:STANCECHANGE) &&
                 !isConst?(user.ability,PBAbilities,:MUMMY)

    That is the code I used in script. What am I doing wrong?
     
    Last edited:
    First off, have you defined the TRANQUILIZE ability in abilities.txt?

    If so, did you make the internal name TRANQUILIZE?

    If so, you'll need to call target.hasWorkingAbility(:TRANQUILIZE) instead of what you have now.

    Are you getting an error? Does it not work as intended? Does it not activate at all? We need more info.

    Some context as to where you put this code would be nice too.
     
    Here is the updated version, but as far as I can tell it still doesn't work.

    Code:
    if target.hasWorkingAbility(:FLAMEBODY,true) && @battle.pbRandom(10)<3 &&
               user.pbCanBurn?(nil,false)
              PBDebug.log("[Ability triggered] #{target.pbThis}'s Flame Body")
              user.pbBurn(target,_INTL("{1}'s {2} burned {3}!",target.pbThis,
                 PBAbilities.getName(target.ability),user.pbThis(true)))
            end
            if target.hasWorkingAbility(:TRANQUILIZE,true) && @battle.pbRandom(10)<3 &&
               user.pbCanSleep?(nil,false)
              PBDebug.log("[Ability triggered] #{target.pbThis}'s Tranquilize")
              user.pbSleep(target,_INTL("{1}'s {2} put to sleep {3}!",target.pbThis,
                 PBAbilities.getName(target.ability),user.pbThis(true)))
            end
            if target.hasWorkingAbility(:MUMMY,true) && !user.fainted?
              if !isConst?(user.ability,PBAbilities,:MULTITYPE) &&
                 !isConst?(user.ability,PBAbilities,:STANCECHANGE) &&
                 !isConst?(user.ability,PBAbilities,:MUMMY)
                PBDebug.log("[Ability triggered] #{target.pbThis}'s Mummy copied onto #{user.pbThis(true)}")
                user.ability=getConst(PBAbilities,:MUMMY) || 0
                @battle.pbDisplay(_INTL("{1} was mummified by {2}!",
                   user.pbThis,target.pbThis(true)))
              end

    162,VICTORYSTAR,Victory Star,"Boosts the accuracy of its allies and itself."
    163,TURBOBLAZE,Turboblaze,"Moves can be used regardless of Abilities."
    164,TERAVOLT,Teravolt,"Moves can be used regardless of Abilities."
    165,TRANQUILIZE,Tranquilize,"Contact with the Pokémon may induce sleep"


    You said you wanted some context as to where I put the code? What do you mean?
     
    Last edited:
    It could just be a run of bad luck. Try removing the pbRandom check from Tranquilize—it'll ensure the ability activates every time the conditions are met and if your ability does work, you can put the pbRandom check back in.
     
    Custom Ability Trouble

    Okay, so this is my second post. (My first one vanished into thin air).
    I've been testing a clone of the ability "Flame Body" and I've yet to actually have it activate.
    Yes, I've done this part: 165,TRANQUILIZE,Tranquilize,"Contact with the Pokémon may induce sleep"
    Here is what the code looks like,
    Code:
    if target.hasWorkingAbility(:TRANQUILIZE,true) && @battle.pbRandom(10)<3 &&
               user.pbCanSleep?(nil,false)
              PBDebug.log("[Ability triggered] #{target.pbThis}'s Tranquilize")
              user.pbSleep(target,_INTL("{1}'s {2} put to sleep {3}!",target.pbThis,
                 PBAbilities.getName(target.ability),user.pbThis(true)))
            end

    Question 1: Does anything look off or out of place?
    Question 2: Is there a way to increase the likely-hood of the ability activating and if yes, what is it?
     
    What I usually do to check if an effect can trigger, is to make the effect occur 100% of the time. In the code you have, the chance of the effect occurring is in the @battle.pbRandom(10) < 3 part. This part of the code takes a random number between 0 and 9 and then checks whether it is smaller than 3 and only continues if it is. This essentially gives the ability a 30% chance of occurring, if you want to increase the chance, you can tweak the numbers a bit, for example:
    @battle.pbRandom(10) < 10 will always occur, since a random number from 0-9 is always smaller than 10 and @battle.pbRandom(4) < 1, will occur 25% of the time, since a random number from 0-3 has a 25% chance of being smaller than 1.
    I hope this is clear enough for you, but let me know if it isn't!
     
    ---------------------------
    Pokemon Essentials
    ---------------------------
    [Pokémon Essentials version 17.2]

    Exception: ArgumentError

    Message: wrong number of arguments(2 for 1)

    PokeBattle_Battler:1341:in `pbSleep'

    PokeBattle_Battler:1341:in `pbEffectsOnDealingDamage'

    PokeBattle_Battler:2771:in `pbProcessMoveAgainstTarget'

    PokeBattle_Battler:2692:in `each'

    PokeBattle_Battler:2692:in `pbProcessMoveAgainstTarget'

    PokeBattle_Battler:3168:in `pbUseMove'

    PokeBattle_Battler:3148:in `loop'

    PokeBattle_Battler:3171:in `pbUseMove'

    PokeBattle_Battler:3369:in `pbProcessTurn'

    PokeBattle_Battler:3368:in `logonerr'



    This exception was logged in

    C:\Users\Patricia\Saved Games\Pokemon Essentials\errorlog.txt.

    Press Ctrl+C to copy this message to the clipboard.
    ---------------------------
    OK
    ---------------------------


    R.i.p?
    What did I do wrong?
    P.s. at least I know it can trigger now.
     
    Last edited:
    Okay, so this is my second post. (My first one vanished into thin air).
    I've been testing a clone of the ability "Flame Body" and I've yet to actually have it activate.
    Yes, I've done this part: 165,TRANQUILIZE,Tranquilize,"Contact with the Pokémon may induce sleep"
    Here is what the code looks like,
    Code:
    if target.hasWorkingAbility(:TRANQUILIZE,true) && @battle.pbRandom(10)<3 &&
               user.pbCanSleep?(nil,false)
              PBDebug.log("[Ability triggered] #{target.pbThis}'s Tranquilize")
              user.pbSleep([B]target,[/B]_INTL("{1}'s {2} put to sleep {3}!",target.pbThis,
                 PBAbilities.getName(target.ability),user.pbThis(true)))
            end

    Question 1: Does anything look off or out of place?
    Question 2: Is there a way to increase the likely-hood of the ability activating and if yes, what is it?

    Just on a quick glance, this bolded part doesn't look right to me. Remove it and try.
     
    Back
    Top