MV State Resist not working properly

Not sure if this belongs here or in JS Plugin Support.

I have an enemy that's supposed to be immune to a state – it has State Resist for that state. However, somehow, the state gets applied anyway. Does anyone have any idea how that could happen?

I use a lot of plugins, including many custom ones, so it's entirely possible that some of my custom modifications (or another plugin) is causing this.

I'm not sure how much it'll help since so many of these plugins are my own that I haven't released, but… here's my plugin list.
temp4.png
temp5.png
temp6.png

There's one more plugin not pictured there that contains a bunch of miscellaneous changes that I didn't bother creating a separate plugin for; it's entirely possible that something in there is the culprit. I can post specific functions that may be relevant, if it seems necessary.

Some of the plugins that aren't my own have also been modified – for example, SRD_NameInputUpgrade and YEP_KeyboardConfig. I doubt either of those are related to this issue though.
There's one more plugin not pictured there that contains a bunch of miscellaneous changes that I didn't bother creating a separate plugin for; it's entirely possible that something in there is the culprit. I can post specific functions that may be relevant, if it seems necessary.
sounds like a culprit, but no idea ultimately.

Since a number of your plugins are custom, you should know better than anyone else whats in them. best i can say is to set up a breakpoint for addState() and look to see whats happening as youre stepping through the functions. Cause for a battler with a resist trait for a state to get it, isStateAddable() needs to have returned true, isStateResist() returned false, and since its not being removed on refresh() either, the state isnt in the stateResistSet()
Yeah, I'm pretty sure it wasn't removed in refresh(). It had a negative HP regen and the enemy died from it, so…

Let's see… there is in fact an addNewState override. I don't think it would be relevant, but I'll post it just in case.
JavaScript:
	// Enable a chance to escape death on a killing blow.
	const old_battlerDie = Game_BattlerBase.prototype.die;
	Game_BattlerBase.prototype.die = function() {
		if(Math.random() > this.stateRate(this.deathStateId())) {
			this._hp = 1;
		} else {
			old_battlerDie.call(this);
		}
	};
	const old_addState = Game_BattlerBase.prototype.addNewState;
	Game_BattlerBase.prototype.addNewState = function(id) {
		if(id === this.deathStateId()) {
			this.die();
			if(this.hp > 0) {
				// You lucked out, so skip the rest.
				this.result().pushAddedState(this.deathStateId());
				return;
			}
		}
		// Skip my die override temporarily
		this.die = old_battlerDie;
		old_addState.call(this, id);
		delete this.die;
	};

I'm not seeing any overrides of isStateAddable or isStateResist… nor of stateResistSet.

I did try debugging it already and wasn't able to find anything, but perhaps I'll try temporarily giving the skill a 100% chance to apply the state and see if that helps… any other ideas of what to look for would also be welcome.
I did try debugging it already and wasn't able to find anything
just to be sure, when you pause on a breakpoint placed at the start of addState(), if you use the console to run the other functions i mentioned on the battler, do they return the expected values? You want to determine if the validation is failing, or if its just being bypassed entirely
just to make sure of any other possible causes, can you post screenshots of the enemy, the state and the skill that applies the state?
because in bughunting you should check the easy possibilities before going deep into the code...
Sure!
temp7.png
temp8.png
temp9.png


Actually, in the process of making those, I might have figured out the issue. I'll get back to you once I've taken the time to check it.
Here’s a small tip:
Develop a good habit of taking notes.
That way, when you suspect plugin conflicts, you’ll be able to identify the root cause more effectively.

1777508843866.png
I might have figured out the issue.
my suspicion is the placeholder states:
the enemy is weak to fire, which means the state should be replaced by a different one.
but the enemy additionally resist burning, so this state should not be triggered at all.

even if this is intentional, those two settings still might conflict in the plugins depending how they are programmed.
Yes, looks like that was it. I briefly debated between editing Hime's plugin and modifying the enemies, but I only have 3 enemies that both resist burn and are weak to fire, so I decided to change them to resist enhanced burn instead, which works.

I think there is probably a use-case for using Hime's plugin to substitute a state that a battler resists, so in a bigger project I probably wouldn't've even considered editing the plugin, but this was actually the only place I was using it, so it would've been fine here.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/state-resist-not-working-properly.183432/