Does anyone know what tends to cause this crash in battle?
Game_Battler line 288: NoMethodError occurred
undefined method 'z' for NilClass error
As far as I can see it can occur when a buff is being applied either by an item or by a skill. It only happens in one particular battle with items or skills that have been used often previously.
Any suggestions on where to start looking would be gratefully received.
Thanks.
EDIT
Forgot to say, I'm using Yanfly's Battle Engine. I'm not on my computer so can't provide a link at this time. I will add one later when I can, though I have never had this problem before with this set of scripts.
Causes of this crash?
● ARCHIVED · READ-ONLY
-
-
need more information =(
It doesn't think the object is defined. Like 288 of the default Game_Battler is just an "end" tag. If you could post the whole method that the error points to, that will be a bit more useful. -
I'm not on my computer so don't have access to Ace, but it's a default script that the error message is pointing to, so I was hoping that it wouldn't be necessary.
-
The project you're playing must have edited the default scripts =(
this is the default code
#-------------------------------------------------------------------------- # * Automatically Remove Buffs/Debuffs #-------------------------------------------------------------------------- def remove_buffs_auto @buffs.size.times do |param_id| next if @buffs[param_id] == 0 || @buff_turns[param_id] > 0 remove_buff(param_id) end endSorry if the numbers are off.. I don't usually post code with line numbers.. in case it is wonky. Line 288 is the 2nd to last "end". -
Oh, I see what you mean. I've got access to my computer now for a short time. The script looks like this:
# * Automatically Remove Buffs/Debuffs #-------------------------------------------------------------------------- def remove_buffs_auto @buffs.size.times do |param_id| next if @buffs[param_id] == 0 || @buff_turns[param_id] > 0 remove_buff(param_id) end endI can't get line numbers to come up. My line 288 is
next if @buffs[param_id] == 0 || @buff_turns[param_id] > 0 -
We need to see the whole script, not just snippets. Please provide a LINK (do NOT copy and paste the entire script here) to the original, and state if you've made any changes.
In fact, looking at your error message again, the script snippet you've shown is not the script that causes the error. There is no reference to .z anywhere in that script snippet. So do you have ANOTHER script that's called Game_Battler that has .z on line 288?
If you play in an unmodified project, does the error still happen? -
That makes no sense.
Someone else might have an idea..but there is no z being called here. You can do a few things to try to debug further.
#-------------------------------------------------------------------------- # * Automatically Remove Buffs/Debuffs #-------------------------------------------------------------------------- def remove_buffs_auto @buffs.size.times do |param_id| print "param_id: "; p param_id print "@buffs: "; p @buffs next if @buffs[param_id] == 0 || @buff_turns[param_id] > 0 remove_buff(param_id) end endAdd in those two lines and then play test the game with the console open. It should look something like this when it prints the info to the console:
The other thing would be to use hime's script to back trace the problem because every now and then it's something along the way that's messed up and hime's script can help track it down.
http://himeworks.com/redirect.php?type=script&name=Full_Stack_Trace
I'm sorry if I over explain, I just don't know your comfort level with handling script things. To use Hime's script, you'll want to replace all the text in the "Main" script at the bottom of the script editor and replace it with Hime's script. Then play the game again. Again you will want the console turned on. I assume you have used this feature of Ace before, but if you haven't, then you can turn it on by going to "Game" on the tool bar and check marking "Show Console".
Then post the picture of the error when it prints in the console. -
@shaz
I've had to put the script into my dropbox, as I can't think how to link to a default script in my project. It's here https://www.dropbox.com/s/gh485izeqzk0y48/Game_Battler.txt?dl=0
It doesn't happen anywhere else in the game, and the game is 25+ hours long. Nor has it happened in other projects using this set of scripts.
@venka
okay, I'll try that. I'm not very good with scripts, so this may take some time for me to work out. -
I just grabbed your script and there's no .z in there ANYWHERE.
Okay - so can you have a look through your script list and see if there's ANOTHER script in there that's also called Game_Battler?
Are you SURE the error message says Game_Battler? Any chance it might say Sprite_Battler?
Have you made any recent changes to the scripts? Is this the one you recently released? -
I didn't think about another script having the same name.. that could be it too :)
Also you don't have to use the console. I forgot that it will create a text file in the game's directory with all the same info, so you could just upload the text file after it crashes if you get hime's script working. It's pretty easy to put in.
This is what the Main Script looks like by default
https://www.dropbox.com/s/jd0k9y5kskgdhb6/Screenshot%202014-10-20%2021.13.52.png?dl=0
This is how it will look once you put Hime's Script in. You're just replacing all the stuff inside the Main Script from above.
https://www.dropbox.com/s/97n37csucnc2591/Screenshot%202014-10-20%2021.15.05.png?dl=0 -
My question would be what notetags are on those particular items/skills? See if you have set them up correctly if you are using notetags on them. If it happens for only one battle in particular, check to see if enemies in that battle are using notetags and if they are also setup correctly. Also if any states are being applied that may be another thing to look into.
-
@venka
here is the printout from the console

@shaz
There is no other script with that name, and Sprite_Battler doesn't have a line 288
It is the game that's just been released. This never came up in play testing beforehand.
BUT
This time when it crashed, it said:
Script 'Game_Battler' line 290: NoMethodError occurred
undefine method '>' for nil:NilClass
line 290 - this change would be because of the 2 lines that venka suggested I put in. And I now see that it's '>' not 'z' My bad, I'm sorry.
@Sarlecc
No notetags on any of those skills or items, except for the item, there is the note tag <image: Potion 04> because I'm using Yanfly's Item Menu script. However, that notetag is used elsewhere without problems. -
Ok that makes a lot more sense on the error message :)
This will work as a hot fix.
#-------------------------------------------------------------------------- # * Automatically Remove Buffs/Debuffs #-------------------------------------------------------------------------- def remove_buffs_auto @buffs.size.times do |param_id| turn_check = @buff_turns[param_id] && @buff_turns[param_id] > 0 next if @buffs[param_id] == 0 || turn_check remove_buff(param_id) end endI don't know enough about the buff/debuff system to say if there's a better fix. So someone else might have some better advice. I can't really play test it to make sure it works. It's getting late here and my thinking might not be the clearest. -
@venka
That seems to have done it! I've played through a couple of times now without problems.
I fall at your feet in exhausted admiration (I've spent half the night on this). Thank you very much for this; a life saver.
