Counter + Stun causes crash

Status
Not open for further replies.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,122
Reaction score
11,491
First Language
English
Primarily Uses
RMVXA
Yami's Battle symphony can be found here

I have a character who has a 50% chance of counter attacking when hit.  He also gets a sword with a 40% chance of stunning.  When he counter attacks, and the stun also kicks in, there is a chance, but not a certainty, that the following error message comes up.

Script 'Yami Battle Symphony' line 806: NoMethodError occurred

undefined method 'item' for nil: NilClass

As a precaution I removed the tag I'd put in the note box, so this is running on the script's default way of handling Attack i.e. skill #1

Does anyone have any suggestions about what might be causing this and how to fix it?

Thanks.
 

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
454
Reaction score
209
First Language
English
Primarily Uses
RMMV
Question did you add an extra line to that script what I am getting on line 806 is:

targets = @action_targets.uniq805 though has a reference to item in:

return unless @subject.current_action.itemI am fairly certain that you tried it on a new game (but just thought I'd mention it just in case).
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,122
Reaction score
11,491
First Language
English
Primarily Uses
RMVXA
 You're right, there is an extra line in mine because I needed to set the position of a 5th actor in the battle party.  Sorry, I forgot about that.

And yes, in new game.  
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,229
Reaction score
13,782
First Language
English
Primarily Uses
RMVXA
I just tested it on a blank project, and that crash occurs every time if you have someone attack something that counterattcks you and stuns you (I tested it by setting a slime to CNT and Attack State Stun to 100%, crashed every time after I attacked it and it did the counter attack attack). What appears to be happening is the engine is unsure what to do since the original attacker just got stunned, and it is crashing.

Wonder if there is a patch for it? Will investigate. But at least we know the cause now (hopefully).
 

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
454
Reaction score
209
First Language
English
Primarily Uses
RMMV
I've strangely haven't gotten it to crash.... (tested it with enemies on 100% counter and stun rates and an actor with 100% counter and a weapon with 100% stun using feature lists). Just to confirm how are you setting up your counter attack and stun rates? Feature lists or note tags?

Also when was it you added the script to your project? From the git-hub link there was a message that said this: fixed crash with always_counter. Which was posted 11 months ago.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,229
Reaction score
13,782
First Language
English
Primarily Uses
RMVXA
@Sarlecc: If both the actor and enemy have CNT and Stun, it works, But if one does and one doesn't, then it crashes. Try it with only the enemy having 100% CNT and 100% chance of attack adding Stun. I still haven't been able to figure out how to fix it, tried adding rescue return to the offending line, but then another line crashed. So, its deeper than just that line.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,122
Reaction score
11,491
First Language
English
Primarily Uses
RMVXA
And what makes it worse is that it is not guaranteed to crash.  It usually will, and then - for reasons which are beyond me - just occasionally it won't.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,229
Reaction score
13,782
First Language
English
Primarily Uses
RMVXA
I found a little more. It seems the person who got stunned has to have attack times +1 (or more) on them, and the stun has to occur before the actor does their *last* attack. So, to summarize:

Give the enemy 100% CNT, 100% chance of adding Stun on attack

Give the actor attack times +1 (or more).

Crashed every time, unless the actor somehow missed on their first attack.

Edit: Adding rescue return to the offending line and line 768 (769 for ksjp17 I believe) seems to have stopped it from crashing for me though. No idea if that will introduce another bug, so maybe a more advanced scripter can come up with a better solution?
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,122
Reaction score
11,491
First Language
English
Primarily Uses
RMVXA
But my actor only has 50% CNT and 40% Stun, and does not have Action times +1 - which, I suppose, might account for the fact that sometimes counter + stun does not have a crash.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,229
Reaction score
13,782
First Language
English
Primarily Uses
RMVXA
I meant attack times +1. Sorry. Edited my post above. Does your actor have attack times +1 anywhere at all? Or can ever have it?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,122
Reaction score
11,491
First Language
English
Primarily Uses
RMVXA
He has one skill where he hits twice, but that is not the skill which is called upon for counter attack.  His ordinary attack skill is vanilla skill #1
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,229
Reaction score
13,782
First Language
English
Primarily Uses
RMVXA
Ok, that wouldn't cause it. However, based on what I found, if any enemy were to ever attack him 2x, and he counterattacked the first attack and stunned them, then it would crash. See if you can duplicate it that way (may have to raise CNT and Stun short term to test it like I did). If so, at least we found the source of the crash (if not the solution).
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,122
Reaction score
11,491
First Language
English
Primarily Uses
RMVXA
This is being tested by someone else (Indinera) who is in a different time zone to you, and so will almost certainly be asleep by now.  However, I do know that at least one of the enemies where this happens does indeed have dual attack.  If that is the main trigger, then that would explain why this enemy sometimes causes the crash and sometimes doesn't, as obviously there will be times when a different skill is being used.
 

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
454
Reaction score
209
First Language
English
Primarily Uses
RMMV
Okay it is the double attack thing (finally got it to crash on me). Try turning this line to false: 135 should look like this:

ALWAYS_COUNTER = falseEdit: never mind worked the first 15 or so times then got the error again.... Edit2: realized it was due to the enemy using a different skill that I was getting this lucky in not getting the error with the above.

Edit3: Okay some more information: I've been able to fix it if the player inflects a state with the can not move restriction on it. However this problem can also happen for states that have any of the other restrictions i.e attack ally for instance. Well I can fix the error for those too my current fix causes enemies that have those states to not inflect damage after they get inflicted with them.

The problem occurs (to the best of my knowledge) due to how the action list gets set before they get used. Since states that cause restrictions would alter that list they will cause problems with this battle engine if the subject also has an attack times greater that 1. And the problem will only occur if that enemy get's inflicted with a restriction well attacking.

Battle Systems are still rather out of my league but hopefully the above information can help someone solve it for you.
 
Last edited by a moderator:
  • Like
Reactions: Kes

Xypher

Veteran
Veteran
Joined
Apr 1, 2012
Messages
148
Reaction score
26
Primarily Uses
try adding

return unless @subject.movable?below the line
 

Sarlecc

Veteran
Veteran
Joined
Sep 16, 2012
Messages
454
Reaction score
209
First Language
English
Primarily Uses
RMMV
@Xypher since the subject will still be on it's attack sequence it will still be moving thus the problem. Consequently though the attack sequence acts like it gets cleared when there is a state that adds a restriction onto the subject and when it tries to finish it's attack sequence it gives the above error cause the sequence no longer exists.
 

Xypher

Veteran
Veteran
Joined
Apr 1, 2012
Messages
148
Reaction score
26
Primarily Uses
add it before the line

edit:

add the line after

   when "SKILL ANIMATION", "ANIMATION"as well near line 760
 
Last edited by a moderator:
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,122
Reaction score
11,491
First Language
English
Primarily Uses
RMVXA
@Xypher

I am confused by the instruction to add the line "near" line 760 as well as after line 767

What do you mean by "near"?

EDIT

I think I've worked out what you mean.

Add that line before line 806 and after line 767 (i.e. the "near line 760" was an instruction about where to find the line.)

EDIT AGAIN

It worked for me.  I've asked Indy to test it as well, so I won't get the thread closed until I have his confirmation that it works for him too.

But it's looking good.  Thank you.

AND EDIT ONCE MORE

it looks like the solution is stable, so I think we can count this one as solved.

Thank you to everyone who contributed to the identification and solution of this.  I am very grateful.
 
Last edited by a moderator:
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

We'll be doing another giveaway of MZ on the stream tomorrow! Thank you SykoGaming for contributing a copy for the community! :D
Sorry guys! Been away for long this time. Got attacked by my anxieties again. At least no more bedbugs. Got logged out of here and layout seems strange now a bit.
My old project is now a sitcom
How to do implementation the social politcal mechanics in rpg maker? Thank you for quick spark of ideas. Fear of going to the thread lol.

Forum statistics

Threads
100,781
Messages
979,471
Members
132,419
Latest member
memakegamemekillminority
Top