MV Change windowskin for HP and states?

So in my game, i want the windowskin to change depending on the actor's current status. Basically, when an actor less than 50% HP, i want the skin to change to yellow. at 25% it becomes orange, and when one's dead it turns red. Also, the windowskin should be able to change color depending on the states. when one actor is poisoned, the windowskin turns green for example. Is there a plugin that does this?
Anyone? Isn't this easy to make?
Here you go:

/*: @plugindesc Change Battle Status based on party member with lowest HP @author Ninkoro / Crimsontail */ (function() { _Window_BattleStatus_updateTone = Window_Base.prototype.updateTone; Window_BattleStatus.prototype.updateTone = function() { var lowestHpPercent = 1.0; $gameParty.battleMembers().forEach(function(actor) { var percent = actor.hp / actor.mhp; if(lowestHpPercent > percent){ lowestHpPercent = percent; } }); if(lowestHpPercent == 0.0){ this.setTone(255,0,0); } else if(lowestHpPercent <= 0.25){ this.setTone(255,125,0); } else if(lowestHpPercent <= 0.5){ this.setTone(255,255,0); } else{ _Window_BattleStatus_updateTone.call(this); } }; })();

The color codes are in RGB format in the setTone() functions, you can just directly edit the numbers to change the color to your liking, or I can set them up as a bunch of plugin parameters if desired.

If you want a new HP range just add another if statement, or you can edit the float values to modify the current ranges.

Currently the default is to set the window color to the system default, however if you want to specify a color instead just replace
_Window_BattleStatus_updateTone.call(this);
with
this.setTone(R,G,B);
Where R,G,B is your desired color.

Let me know if this helps!
That's amazing, thanks! But the problem is i want the windowskin image to change, not the main background.... I guess i should've specified... But this will still be helpful for another project!
Oh, so you mean like swapping out window.png essentially? Having a list of image files for the various HP levels? That would definitely be a bit more involved.

Edit:
Ok, I guess I somehow missed the last sentence of your post with states and such. Sorry about that. My plugin only changes the status window, and not any others. Also like you noticed just the color of it.

Let me look into this and I'll come back with something better, something that will change the actual window skin to a specified file like you want. I'll throw in some state example section as well that you can customize with your desired state id's
yeah, that
Tada, here is you new window skin changing plugin. Took quite a bit of effort so please put it to good use! Let me know if you have any troubles or if something isn't clear.

Also if for some reason there's performance issues I can add in a type of cache.

Description for plugin:

Using this plugin, you can specify a window skin file for HP ranges
and afflicted states on an actor.

Designate a state to have a skin by putting the following meta tag in
the notes section of that state:
<skin:my_window_skin_file>
Note: Do NOT include the .png extension in the meta tag

Logic:

Afflicted state skins take priority over HP skins.
Ex: If an actor is at 25% HP afflicted by poison, and you have a skin
designated to the poison state, the windowskin will show the poison skin,
not the HP one.

State skins take priority based on their in-editor priority number.
Highest priority afflicted state in party determines the skin.
This is perfect! Thanks! Now if only there was a plugin that overwrote yanfly core engine's text colors because the white text clashes...
Why do you need to overwrite the core engine's text colors?
The plugin lets you change the text colors in the plugin parameters.
But not along with the windowskin.
Why do you need to overwrite the core engine's text colors?
The plugin lets you change the text colors in the plugin parameters.
A non-plugin way could just be to map the desired color to the same area on the skin png’s. That way you set the color ID once, but it changes for each skin since each one has a different color for that ID.
I did that, but all the text is still white anyway.

Original thread: https://forums.rpgmakerweb.com/threads/change-windowskin-for-hp-and-states.133718/