Yanfly Absorption Barrier in Battle actions

I'm using Yanfly's battle extensions 1 2 3 and yanfly's absorption barrier and during the whole action I have the user take damage using the


"HP -variable 38: user, show" 


and that works just fine, problem is this damage doesn't reduce any barrier points from the absorption barrier script and I need it to.


I have tried the "user.loseBarrier(x)" and tried several things for x and it doesn't do it even for a set number like "1" 


I can't use the damage formula unfortunately which I know is the easiest fix for this problem because of other features in my design and need it to work during the <whole action> phase of the battle extension


I have tried even tried to add a state to the user then "Common Event: x" which had the common event find the battler who is inflicted with the state and remove the barrier points that way but I must be doing that wrong as well


$gameTroop.members()[3].loseBarrier($gameVariables.Value(39))


$gameActors.actor(1).loseBarrier($gameVariables.Value(39))


any help on this would be very appreciated.
Ok I found a way to do it using a custom apply effect using Yanfly's state manager plugin


can close the topic


if anyone wants to know how I did it see below.

Spoiler
during the battle action I gave the user the state X


then in the states tab go to the notebook of state X and put the following in


<Custom Apply Effect>


var armor = user.barrierPoints();


var attack = target.atk;


// Check if Armor higher than stacks.


if (armor > attack) {


armor - attack;


var damage = 0;


} else {


user.loseBarrier(attack);


var damage = attack - armor;


}


// Target takes HP damage.


user.gainHp(-damage);


// Play the popup.


user.startDamagePopup();


// Clear the results.


user.clearResult();


// Check if the target is dead.


if (user.isDead()) {


// If the target is dead, make it collapse.


user.performCollapse();


}


user.removeState(238);


</Custom Apply Effect>


alter it to fit your needs.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-absorption-barrier-in-battle-actions.68405/