"Remove By Damage" on States When Damage is Zero

So.. Another oddball question from my end.

I know you can set a State to remove when an Actor takes damage. I currently have an effect set up that applies SP-Parameter trait "Physical Damage * 0%," which is absolutely what I want, but I need the state to remove when an attack connects, regardless of whether or not any damage is applied.

Is there a way to have a State remove when the damage taken equals zero?

Any thoughts on how this might be achieved? I'm stumped at the moment.
You'll need to modify the code, or use a plugin, basically. Yanfly's Buffs & States Core gives you the tools you need via Lunatic Mode tags.
Thank you!

For confirmation, regarding YEP-B&SC, I assume the appropriate Lunatic Mode tag in this case would likely be the Custom React Effect. Action connects, before damage executes, socket in appropriate code.
As far as I know, you'll need a Plugin to handle that logic, because when an Action deals damage, it only calls the logic to remove states by damage if the damage value is greater than 0.

Try this:
Code:
/*:
* @plugindesc This Plugin causes states removed by damage to be removed when an attack
* that deals HP damage lands, even if it does 0 damage.
* @author Zevia
*
* @help This Plugin has no parameters.
*/

(function(module) {
    'use strict';

    module.Zevia = module.Zevia || {};
    var RemoveStatesByZeroDamage = module.Zevia.RemoveStatesByZeroDamage = {};

    RemoveStatesByZeroDamage.executeHpDamage = Game_Action.prototype.executeHpDamage;
    Game_Action.prototype.executeHpDamage = function(target, value) {
        if (this.isDrain()) {
            value = Math.min(target.hp, value);
        }
        this.makeSuccess(target);
        target.gainHp(-value);
        target.onDamage(value);
        this.gainDrainedHp(value);
    };
})(window);

EDIT: Changed the override to just remove the conditional on calling onDamage.
.. That also is a direction to go.

JFC, Zevia. You're a freaking beast. Thank you!
@The Real Sye I edited my Plugin to account for remove by damage chance being less than 100%. I had originally just changed the executeHpDamage function to call the removeStatesByDamage method, then otherwise call the original function - however, if the damage value is greater than 0, it meant that removeStatesByDamage was being called twice. In the case of 100% removal, no problem, but it meant that states were being given two chances every time the battler was damaged to remove a state by damage.

I changed it to instead just get rid of the conditional around calling onDamage, so that removeStatesByDamage is always called, but only once. It will now always call chargeTpByDamage, but if the value is 0, it should ultimately just add 0 to the target's TP.

Original thread: https://forums.rpgmakerweb.com/threads/remove-by-damage-on-states-when-damage-is-zero.105193/