- 428
- Posts
- 5
- Years
- Zekko
- Seen Nov 21, 2023
Code:
BattleHandlers::AbilityOnSwitchIn.add(:TRICKSTER,
proc { |ability,battler,battle|
@battle.field.effects[PBEffects::TrickRoom] = 5
@battle.pbDisplay(_INTL("{1} twisted the dimensions!",user.pbThis))
}
)
This code should work. Probably. But instead, when a Pokemon with this ability is sent out, the game crashes and the error message says this:
Code:
[Pokémon Essentials version 19.1]
[Generation 8 Project v1.1.0]
[v19.1 Hotfixes 1.0.7]
Exception: NoMethodError
Message: undefined method `field' for nil:NilClass
Backtrace:
142:BattleHandlers_Abilities:2840:in `block in <main>'
035:Event_Handlers:199:in `trigger'
141:BattleHandlers:454:in `triggerAbilityOnSwitchIn'
154:Battler_AbilityAndItem:14:in `pbEffectsOnSwitchIn'
176:Battle_Action_Switching:312:in `block in pbOnActiveAll'
176:Battle_Action_Switching:312:in `each'
176:Battle_Action_Switching:312:in `pbOnActiveAll'
173:Battle_StartAndEnd:301:in `pbStartBattleCore'
173:Battle_StartAndEnd:258:in `pbStartBattle'
230:Overworld_BattleStarting:291:in `block (2 levels) in pbWildBattleCore'
Why does this happen? How can it be fixed?