State Damage Bypasses YAP Absorption Barrier

I've googled this and asked on some of the Discords, but haven't found anything yet.

I have a state that should deal damage when it wears off. I'm using Yanfly's Absorption Barrier and Buff/States. I can run a script when it wears off to apply damage. However, the process I've seen for this has always been

user.gainHp(-1 * damage_here);

user.startDamagePopup();

user.clearResult();

This works fine for bleed or poison - anything that needs to apply directly to HP. However, the damage from the state I'm working on needs to be handled like any other external source of damage. I could write a more complex process that finds the current barrier and hp, then works out the correct numbers and applies it to both, but this seems likely to be an issue that comes up repeatedly.

Is there a method I can call to have the game process damage for me the way it normally does? That way I don't have to reinvent the wheel here and can avoid missing any other damage triggers I may have overlooked?
I dealt with this issue myself, and through extensive trial and error, I figured out how to fix it. I PM'd you, I'd like to confirm with you that what you're trying to do is the same thing I figured out, and if it is, I'll post the working method here.
See my snippets post in my signature for the fix for this.
See my snippets post in my signature for the fix for this.
It looks like the plugin in your will apply all damage to the barrier first. Can this still be overcome by the barrier penetration notetags? I have some poison and bleed type effects and skills that need to affect HP directly.

Edit:
I slipped this in for now:
user.startAnimation(29);
var total_damage = 100;
var barrier_damage = Math.min(user.barrierPoints(), total_damage);
var hp_damage = Math.max(0, total_damage - barrier_damage);
if (barrier_damage > 0) {
user.loseBarrier(barrier_damage);
}
if (hp_damage > 0) {
user.gainHp(-1 * hp_damage);
user.startDamagePopup();
user.clearResult();
}
But I still this this will fail to trigger any effects or consequences that would normally be triggered by damage. Say you have a setup where a character gains atk whenever they are hurt. I think this would usually bypass setups like that unless they actually rewrote the gainHp method
It looks like the plugin in your will apply all damage to the barrier first. Can this still be overcome by the barrier penetration notetags?
No. Once you get to the gainHp function, the code doesn't know where the damage is coming from. That's kind of why Yanfly wrote it that way to begin with - if you want damage applied to the barrier when possible, use the notetags or functions included with the original plugin.

If you want the code you supplied in your first post to apply to a barrier, everything will be applied to the barrier. I don't use the plugin myself, so I hadn't thought of the piercing notetags, but that's what you get.

The alternative is to write an alternate version of gainHp that you call from states and such, or add an operator to gainHp that says whether the damage is supposed to be barrier-piercing.

Original thread: https://forums.rpgmakerweb.com/threads/state-damage-bypasses-yap-absorption-barrier.143619/