• 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] Creating an Inverse Battle Effect

10
Posts
8
Years
I'm working in Pokemon Essentials v17.2, and trying to create a move that turns the battle into an Inverse Battle, Trick Room style. I'm currently running into an error though, in the PokeBattle_Battle script, with a NoMethodError, with the text underneath being "undefined method 'effects' for nil:NilClass". The code I'm using is as follows, and the error is on "if @field.effects[PBEffects::InverseRoom]>0"

# Inverse Room
if @field.effects[PBEffects::InverseRoom]>0
@field.effects[PBEffects::InverseRoom]-=1
if @field.effects[PBEffects::InverseRoom]==0
pbDisplay(_INTL("Inverse Room wore off, and type effectiveness returned to normal!"))
PBDebug.log("[End of effect] Inverse Room ended")
end
end

I've set up an effect in PBEffects and PokeBattle_ActiveSideField in the correct section, and set up the effect in PokeBattle_MoveEffects, and what it actually does in PokeBattle_Move (since it directly changes type effectiveness). Everything is spelled the same way everywhere.

Anyone know why I'm getting this error and how to fix it?

I've set up an effect in PBEffects and PokeBattle_ActiveSideField in the correct section, and set up the effect in PokeBattle_MoveEffects, and what it actually does in PokeBattle_Move (since it directly changes type effectiveness). Everything is spelled the same way everywhere.

Anyone know why I'm getting this error and how to fix it?
 
Last edited:
233
Posts
5
Years
  • Age 33
  • Seen Oct 9, 2023
You put this in the PokeBattle_Battler script? I see similar effects like Trick Room, Wonder Room, and Magic Room are all in PokeBattle_Battle, NOT PokeBattle_Battler. Your code itself looks correct, but it's in the wrong place - try putting it under the code for those three effects in PokeBattle_Battle.
 
10
Posts
8
Years
Sorry, typo. It's in PokeBattle_Battle. I tried removing the offending script to try and see if anything else was also causing an error, but the error pops up on the same line... Which is now Wonder Room. The specific line it points to is "if @field.effects[PBEffects::InverseRoom]>0" or, now, "if @field.effects[PBEffects::WonderRoom]>0". I have absolutely zero idea what's causing this.


Edit: Commenting out Wonder Room's code there, now it points to Magic Room, the same line. The same line in Trick Room, which is still above, is causing no errors, oddly. That tells me that the problem probably isn't in this script, it's somewhere else, but showing up here?
 
Last edited:
233
Posts
5
Years
  • Age 33
  • Seen Oct 9, 2023
Can you post the full error instead of just one line, and also when the error actually happens, like while trying to launch the game or in battle? You could try removing all Inverse Room related code from all scripts and see if the error persists, in which case you'd be right that it's coming from somewhere else.
 
10
Posts
8
Years
https://prnt.sc/tbtpjj
Like I said, the error now points even to Wonder Room and Magic Room. Even after commenting out the code, the same error persists, just pointing to the same line of Wonder Room and Magic Room. For some reason, Trick Room is not affected, despite no actual differences in the code.

It pops up on launch.
 
233
Posts
5
Years
  • Age 33
  • Seen Oct 9, 2023
It sounds like you might've messed up part of the existing code while trying to add your new code. Can you show the code starting from Trick Room down to the end of Magic Room? And a few lines before and after, too.
 
10
Posts
8
Years
Ah, found the problem.

At some point, an extra end made its way into the bottom of Trick Room's code. Managed to fix it now, so I guess that does it. Moved the end (without it I was getting the error that happens when you miscount your ends), so I guess that does it. Must have happened while I was adding Psychic Terrain earlier, I guess?
 
5
Posts
3
Years
  • Age 26
  • Seen Oct 10, 2023
Which type is the move and how many PP does it have? Can i use it in the v20.1 essentials or do i need to change the code?
 
Last edited:
Back
Top