My game crashes from state damage...?

First off I don't know if this is the right thread, I didn't know where else to ask.

For some reason, I get this error when an actor is about to take damage from a state (like poison) outside of battle.

tumblr_nxze3pSIr71rb9glpo1_400.png


The actors take damage from poison during battle just fine, this is only when they take damage while walking. I've been working on this game for a while, and this just started happening. (or rather, it's been a pretty long time since I got myself poisoned while testing, and the last time that was, this did not happen.)

I'll assume it's because of a script I added, but could someone maybe narrow down what sort of script could have caused it? Or whatever else could have caused it. I have absolutely no scripting knowledge.
Hi,

According to the message, this line causes the error:

if state.remove_by_walking
  @state_steps[state.id] -= 1 if @state_steps[state.id] > 0


  remove_state(state.id) if @state_steps[state.id] == 0

...which usually means that one of your actors is inflicted with a state that was not properly added (and thus the entry for the remaining state steps is missing). So I'd probably start checking the scripts that can control your battlers state effects if you have some.
Well, what scripts have you added? Are you playing a saved game, or have you started a new game after adding all of your scripts? Does it happen when you choose New Game from the menu? (You may have to set up a temporary event to give you the state and just do a lot of walking to see if you can reproduce it).


If the message above comes from a game that you've reloaded after adding some scripts, and the game was first started before adding the scripts, then there's something in those scripts that's causing it. If it doesn't happen when you start a new game, there isn't an issue.


That line and that error indicates that @state_steps isn't defined. So if it's a script that you've added, it'll be something to do with actor states.
Do you happen to have Yanfly's buff and state manager by chance? I ran into this error with a specific notetag not working right as somewhere in the code Yanfly never set the state_steps under one specific tag (a one line add to the script fixes it though). I'd have to see a screenshot of the state to say more on if that could be the cause.
@Another Fen

The strange thing about that is, the state in question is Poison, which I have left unchanged (at least I think I left it unchanged, I don't remember, I know I changed the messages though) from the default poison state that is there from when you begin a vanilla project.

@Shaz

Yeah I loaded a saved game. Thing is I didn't think that loading saved games would be an issue anymore because I'm using this script (Source's Save File Doctor) to prevent errors like that when I test from a save file. I started a new game and got myself poisoned on the new game, and I still got the same error. I'd give you a list of all the scripts I have but I think bgillisp might have already found the script causing the issue ↓

@bgillisp

Yes, I do have the buff and state manager, in fact that was one of the latest scripts I added. The weird thing is the only notetag the Poison state has is from a different script. (yanfly state animations) Here's the state in question. Could the problem be I was supposed to add a notetag to it or something? I only got the buff and state manager because the main protagonist of my game is status effect oriented so I found the 'turn countdown' on the states that the script gives very useful for him so I didn't really look into the notetags.

Spoiler
ezimba15791991665200.png
Hmmm....maybe? I ran into the bug when I used the reapply ignore notetag, as in that case it was skipping adding the turn steps. But logically the setup looks good. You will probably need to list all the scripts you have then, as it seems one of them is causing the turns left to not be added somehow when you are not in battle.
Okay here's all the scripts:

Spoiler
Yanfly (23) - Ace Core Engine, Ace Battle Engine, Victory Aftermath, Status Menu, Enemy HP Bars Add-on, Elemental Popups Add-on, Cast Animations, Anti-Fail Message, Message System, Ace Save Engine, Party System, Target Manager, State Animations, Ace Item Menu, Ace Shop Options, Element Absorb, Element Reflect, Combat Log Display, Battle Command List, Hide Menu Skills, Steal Items, Command Autobattle, Buff & State Manager

Hime (6) - Troop Battle BGM, Class Changing, Message Skip, State Faces, Eight Directional Movement, FenixFyreX Player Turn-in-Place Bug-fix

Source (3) - Save File Doctor, Menu Scrollbars, Enhanced Camera

Allusion (2) -Message Window Sound Effect, Alternate Currency

Blackmorning (2) - Basic Module, Yanfly Status Menu Add-on

Casper Gaming (2) - Splash Screen, Game Info

DiamondandPlatinum3 (2)- Never Null Damage, Critical Hit Sound Effect

Kred-EX (2)- Frozen Transfer Bug-fix, Offscreen Event Bug-fix

Neon Black (2) - Event Jitter Bug-fix, Star Tile Bug-fix

TheoAllen (2) - Yanfly Battle Engine Critical Popup Bug-fix,
Yanfly Victory Aftermath Dynamic Add-on

Venka (2) - Bestiary, Actor’s Input Bestiary Add-on

AdiktuzMiko (1) - Critical EX

Apoclaydon (1) - Class Specific Normal Attack

Dekita (1) - Battle Weather Effects

FenixFyreX (1) - Player Turn-in-Place

Galv (1) -Yanfly Ace Save Engine Confirmation Add-on

Hiino (1) - Screen Shake Bug-fix

KilloZapit (1)- Word Wrapping

LoneWolf (1)- Enemy Self-Target Bug-fix

MakoInfused - Yanfly Command Autobattle Rush Add-on

Rikifive (1) - Extra Menu Window

Shadowmaster (1) - Item Use Message

SiChainlinks (1)- Yanfly Ace Save Engine Add-on

Snow (1) - Battle Tint Control

TDS (1) - Yanfly Party System Bug-fix

Ventwig (1) - Single Column Menus

Vlue -(1) Restore/Set after Battle/Level

Xypher (1) - Battle Command Help Window

Yami (1) - Yanfly Ace Battle Engine Animation Bug-fix

Zeus81 (1)- Fullscreen++
Does the error continue to show up if you remove the "Buff & State Manager"?

If not, since you have a lot of scripts installed, would you mind uploading a copy of the "data" folder from your project directory? This might save someone the trouble looking up every single script themselves and ensure everyone ends up with the same script versions and database settings.

The Save File Doctor script attempts to add missing properties when you load an old savefile after adding new scripts. It might work in many cases, but it's still recommended to use a new game if you're tracking down script errors.
Just tried it and removing the Buff & State Manager does get rid of the error.

I really want to use that script though, like I said the protagonist of my game is oriented around status effect spells so having the features that script gives otherwise makes him more useful, (especially since he's required for most of the game) could it be possible to make a bugfix for the script? Of course, I could just get rid of Poison's walking damage but... what kind of RPG's poison status effect does not cause walking damage? It's like, the trademark thing about getting poisoned in an RPG.

EDIT: I found a bug fix for this script, but wasn't sure if it was for this error in question. It sounded like it was, but unfortunately it didn't work. Unless I didn't add it correctly or whatever.

http://rpgmaker.net/scripts/372/

Of course, if no fixes work out, I will settle without the script, it's not like my entire game depends on that script unlike a lot of the scripts I'm using (the protagonist will have a bit less versatility but... oh well, not too big of a deal.) but if there's a way to fix it I want to try to find it.
Didn't test it, but you could try this script in addition to the fix you posted. This should initialize the "Step Count" correctly if you specified  REAPPLY_STATE_RULES = 2. (Insert both of them below the "Buff & State Manager" and save your project afterwards)

Spoiler
Code:
class Game_Battler   def total_state_counts(state_id)    #state = $data_states[state_id]    #value = state_turn_mod(state_id)    #state_change_turns(state_id, value + state_turns(state_id))    last_turns = state_turns(state_id)    last_steps = state_steps(state_id)    reset_state_counts(state_id) # <- Called for convenience    state_change_turns(state_id, last_turns + state_turns(state_id))    @state_turns[state_id] += last_steps  endend
I'm sorry I didn't respond earlier, I couldn't get to a computer.

That script worked! Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/my-game-crashes-from-state-damage.50788/