• 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] Help with custom ability

31
Posts
8
Years
  • Age 27
  • 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:
971
Posts
7
Years
  • Age 21
  • Seen Nov 28, 2022
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.
 
31
Posts
8
Years
  • Age 27
  • Seen Dec 18, 2017
I have not received an error thus far.
I did define the ability already.
So, it hasn't activated in 25+ moves that made contact with me. So could it just be luck?
Is is there a way to increase the odds of it activating?
 
Last edited:
31
Posts
8
Years
  • Age 27
  • Seen Dec 18, 2017
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:
188
Posts
9
Years
  • Age 39
  • Seen Jan 21, 2024
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.
 
31
Posts
8
Years
  • Age 27
  • Seen Dec 18, 2017
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?
 
16
Posts
10
Years
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!
 
31
Posts
8
Years
  • Age 27
  • Seen Dec 18, 2017
---------------------------
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:
1,396
Posts
10
Years
  • Age 35
  • Online now
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