Disclaimer: Yes I'm working in v20 but I think this error may apply to the v21 version of this plugin as well.
Please correct me if I'm wrong since I've only recently started getting into debugging code.
So I was working on a deluxe battle scenario with the raidcapture feature.
Things are going great. The add 1 hp is working, etc etc
Then things go wrong when the script tries to call the pbraidcapture.
I run into this error:
(Below is the Essentials Deluxe
v20.1 version)
=================
[2024-01-19 02:44:36 -0800]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.7]
Exception: NoMethodError
Message: undefined method `[]' for true:TrueClass
Backtrace:
[Essentials Deluxe] Midbattle_Triggers.rb:335:in `pbFaint'
Battler_UseMove:698:in `block in pbProcessMoveHit'
Battler_UseMove:698:in `each'
Battler_UseMove:698:in `pbProcessMoveHit'
Battler_UseMove:407:in `block in pbUseMove'
Battler_UseMove:405:in `times'
Battler_UseMove:405:in `pbUseMove'
Battler_UseMove:52:in `block in pbProcessTurn'
PBDebug:6:in `logonerr'
Battler_UseMove:51:in `pbProcessTurn'
BTW, I checked and the issue is the first line of the backtrace. It's possible to get completely different lines after the first line depending on what move you used to knock out the raid Pokemon, but the
[Essentials Deluxe] Midbattle_Triggers.rb:335:in `pbFaint'
appears every time.
(Below is the Deluxe Battle Kit
v21 version of the error):
=================
[2024-01-19 02:48:10 -0800]
[Pokémon Essentials version 20.1]
[v20.1 Hotfixes 1.0.7]
Exception: NameError
Message: undefined local variable or method `raid' for #<Battle::Battler>
Backtrace:
[Essentials Deluxe] Midbattle_Triggers.rb:335:in `pbFaint'
Battler_UseMove:698:in `block in pbProcessMoveHit'
Battler_UseMove:698:in `each'
Battler_UseMove:698:in `pbProcessMoveHit'
Battler_UseMove:407:in `block in pbUseMove'
Battler_UseMove:405:in `times'
Battler_UseMove:405:in `pbUseMove'
Battler_UseMove:52:in `block in pbProcessTurn'
PBDebug:6:in `logonerr'
Battler_UseMove:51:in `pbProcessTurn'
So after rigorous testing to identify just what exactly the issue was, I finally arrived at my destination.
Line 335 in midbattle_triggers, which is
pbRaidStyleCapture(self, (params[2] || 0), params[0], params[1])
in v20 and
pbRaidStyleCapture(self, raid[:capture_chance], raid[:flee_msg], raid[:capture_bgm])
in v21 is likely the issue, because when I change this line to
pbRaidStyleCapture(self, 0, nil, nil)
in v20 and
pbRaidStyleCapture(self, nil, nil, nil)
* in v21 respectively the raid capture feature then works as intended.
Please let me know if I made a mistake somewhere.
*Since I am working in v20 I didn't actually test the v21 version but I did notice when comparing the scripts that "chance" has been changed from 0 to nil so I assume the same change would apply here.