Absorption Barrier - Create a maximum

Here is the plugin I am talking about : http://yanfly.moe/2016/02/13/yep-70-absorption-barrier-rpg-maker-mv/

I want to create a maximum number, that no skill or item can surpass when giving AP (Absorption Points).
For example, Harold has 1000 HP. I don't want the AP to surpass that number.

It would be great if the maximum AP number could be the actor's max HP.

Does anyone know how to do this ? I have looked in the parameters but there isn't such a thing.
That should be easy with a little lunatic mode assistance.
<Custom Target Barrier>
if (value plus the variable that represents current AP, I don't know what is it called, but should be easy to find) is greater than or equal to target's hp:
value = target.mhp - the variable that represents current AP
</Custom Target Barrier>
Should it be like that :

<Custom Target Barrier>
if value = target.barrierPoints() += value = target.mhp
value = target.mhp
</Custom Target Barrier>

??

I have no knowledge in javascript, this a try.
<Custom Target Barrier>
if ((value + target.barrierPoints()) >= target.mhp) {
value = target.mhp - target.barrierPoints()
}
</Custom Target Barrier>
Thank you for the eval @Poryg !
But there is an issue : this eval doesn't consider the AP the target already has. Could you add that ?
Maybe by using this eval : battler.barrierPoints()

The problem I have is that a skill that gives AP can outpass the limit of the target's maxHP...
I thought it would consider the value of AP the target already had. Wait a minute, I'll do some debugging.

Edit: No wonder it didn't work, there is nothing such as barrierPoints.
There are turn barriers and permbarrier.
So if you are using permanent points, this is the code.
<Custom Target Barrier>
value = whatever default value
if ((value + target._permBarrier) >= target.mhp) {
value = target.mhp - target._permBarrier
}
</Custom Target Barrier>
Here, attach this plugin below the Absorption Barrier plugin. Should do what you're asking for.

EDIT: Misunderstood your question last time and made the wrong edit to the plugin. Get this one instead, which I assume is what you're looking for.
Whilst that script is great for when the max is based on another attribute, what about just getting the max barrier as set in an enemies notetags?

So, any ideas how to get the maximum value of the enemies barrier? In JS?
So for example - if the notetag for an enemy gives it <Barrier Points: +48>, how can I have a JS script that gets this value?

Code:
$gameTroop.members()[0].barrierPoints()

This above is no good. It gets the current barrier points of the enemy, but I want to get the barrier points the enemy had when it entered the battle...
Assuming the enemy gains no new points in the battle, this will be its "maximum"

Any ideas?

Original thread: https://forums.rpgmakerweb.com/threads/absorption-barrier-create-a-maximum.81642/