Help Ability that grants +1 Priority to super effective hits


Quite new to this so I'm not entirely sure how to work it out.

Under Pokébattle_Battler I have
p+=1 if user.hasWorkingAbility(:PRANKSTER) && thismove.pbIsStatus?
p+=1 if user.hasWorkingAbility(:GALEWINGS) && isConst?(thismove.type,PBTypes,:FLYING)
p+=1 if user.hasWorkingAbility(:OPPORTUNIST) && thismove.opponent.damagestate.typemod>8

But the problem is here with PokéBattle_Battle I believe.
# Calculate each Pokémon's priority bracket, and get the min/max priorities
for i in 0...4
# Assume that doing something other than using a move is priority 0
if @choices[0]==1 # Chose to use a move
pri+=1 if @battlers.hasWorkingAbility(:PRANKSTER) &&
pri+=1 if @battlers.hasWorkingAbility(:GALEWINGS) &&
pri+=1 if @battlers.hasWorkingAbility(:OPPORTUNIST) &&

And I can launch just fine, but when going into battle and choosing any move with the ability, I receive an error log of the spoiler below, while the turn restarts and I get to try to make a move again after the log boxes.

[Pokémon Essentials version 17]
Exception: NoMethodError
Message: undefined method `damagestate' for 0:Fixnum
PokeBattle_Battle:1032:in `pbPriority'
PokeBattle_Battle:1022:in `each'
PokeBattle_Battle:1022:in `pbPriority'
PokeBattle_Battle:2706:in `pbAttackPhase'
PokeBattle_Battle:2534:in `pbStartBattleCore'
PokeBattle_Battle:2533:in `logonerr'
PokeBattle_Battle:2533:in `pbStartBattleCore'
PokeBattle_Battle:2519:in `loop'
PokeBattle_Battle:2542:in `pbStartBattleCore'
PokeBattle_Battle:2342:in `pbStartBattle'
[Pokémon Essentials version 17]
Exception: NoMethodError
Message: undefined method `damagestate' for 0:Fixnum
PokeBattle_Battle:1032:in `pbPriority'
PokeBattle_Battle:1022:in `each'
PokeBattle_Battle:1022:in `pbPriority'
PokeBattle_Battle:2882:in `__clauses__pbEndOfRoundPhase'
PokeBattle_Clauses:42:in `pbEndOfRoundPhase'
PokeBattle_Battle:2538:in `pbStartBattleCore'
PokeBattle_Battle:2537:in `logonerr'
PokeBattle_Battle:2537:in `pbStartBattleCore'
PokeBattle_Battle:2519:in `loop'
PokeBattle_Battle:2542:in `pbStartBattleCore'

I understand that damagestate is not a proper way to define it, but I don't know what other ways to.
I've tried looking at other Moves like Sucker Punch. and Abilities like Filter, Tinted Lens, and Ludicious89 on Pokecommunity's custom ability Pounce.

This is with Mej71's Gen 6 Assets, Aswell as Marin's Gen 7 assets.

Thanks in advance
Last edited:


I guess that damagestate only starts getting computed once the move's effects are being worked out, i.e. once it's that Pokémon's time to move, which obviously has to happen after the priority calculation.

You might want to look at the code that computes typemod in the first place and see which bits of that you want to copy over into your own check. At the very least it's going to want to check the type of the move in the PBS against the current type(s) of the foe, but you might decide that you want to bring more information in (such as finding the actual type of moves like Hidden Power/Natural Gift, taking into account abilities like Volt Absorb, or taking into account modifiers like Freeze Dry's).


The error is happening because "damagestate" isn't being accessed from the right variable in your PokeBattle_Battle section. In your last line, you have "@choices[ i ][2].target.damagestate.typemod", but "target" is just a value from the PBS, not the target Pokemon that you need. I think, though, as MGriffin said, damagestate only gets affected after the priority calculations, so instead you'll need to find a way to determine whether your attack will be super effective against your target BEFORE damagestate is updated... luckily, Essentials has a method just for that:
PBTypes.isSuperEffective?(attackType, opponentType1, opponentType2=nil, opponentType3=nil)
The attack type is just the move type, but for opponent types, you'll still need to find a way to access the target first. Try looking at how the targets are determined in "pbUseMove" in PokeBattle_Battler. Remember, "@choices[ i ][2].target" does not get you the Pokemon itself, just a value from the moves PBS that can be used to get that Pokemon.