• 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.

Adding a counter value for a new ability

Wootius

Glah
300
Posts
11
Years
  • Seen May 31, 2022
A hopefully simple question. I have an ability, BALLOONS(Balloons!!) on a alternate form of Pikachu that currently mimics the effect of the Air balloon item. Switching forms works fine. However, I want it to take three hits to ground this Pikachu after which its abillity will change to GROUNDED until swapped back in and out.

So I added added an accessor, attr_accessor(:ballons=hit=counter) with equal signs due to censorship, to the PokeBattle_Pokemon to count these hits. However, when I try to set this to any value I get a undefined method error.

Here's the error in full

Spoiler:


and the code that causes it

Spoiler:


As you can see, I try to set the hit counter for the Pikachu that just switched in to 0 and run into an undefined method error. Thank you for any help given!
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
A Pokémon in the party is an instance of PokeBattle_Pokemon. A Pokémon that's out in battle is an instance of PokeBattle_Battler. The two are separate (but related) things. The reason is that, in battle, a Pokémon's features can change (most notably by using Transform), yet those changes are only supposed to be temporary and not affect the actual Pokémon.

So you put the attr_accessor(:balloonshitcounter) in the wrong place. Your best bet is to instead add another value into PBEffects, and then the counter can by accessed with battler.effects[PBEffects::BalloonsCounter] (or @effects[PBEffects::BalloonsCounter] if you're in PokeBattle_Battler).

Then in PokeBattle_Battler, def pbInitEffects, set it to the default value of 0. Stick this at the end of the method.

A little further down is def pbAbilitiesOnSwitchIn. I'm guessing this is where you put your code, and that's the right place for it. However, you should set the value to 3 here rather than 0. It's going to count how many balloons the Pokémon has left, and each pop will reduce the number by 1.

As for the popping itself, I assume it works the same way as the Air Balloon item does. So add code in all the same places as it which do (roughly) the same things.
 

Wootius

Glah
300
Posts
11
Years
  • Seen May 31, 2022
Thank you, Maruno. I know enough about programming to know that I don't know enough. It's 100% working now, including losing then resetting the ability by switch out then back in. The only thing "wrong" is the listed ability doesn't change on the Status screen when I change the ability, due to that info being from PokeBattle_Pokemon I assume. Does Mummy do the same thing? Mummy Doesn't update on the Status screen while under its effects either. I may try and "fix" this.

You're awesome.


In looking to help others with this/something similar I'll add the code here. Using this will give you a Pokemon with an ability
that mimics Air Balloon for 3 hits after which it changes abilities to one without an effect until the next time it's switched out/in.
Spoiler:
 
Last edited:
Back
Top