I wouldn't have thought that would function, but I'll take your word for it!
Yeah, you have some flaws in your code.
I'm not sure exactly what you want this line to do, but you're setting mercuryPoison equal to the result of an evaluation. When you say "this equals this or this," the result will be true or false. In this case, it will always be true because Math.ceil() will always provide you with an integer value, and thus be true. So after this line of code, target._mercuryPoison has no numerical value, it will be equal to "true."
That means this won't do anything because you're telling it to damage the barrier by an amount of "true." I'm surprised this doesn't pop any kind of error in your console, but JavaScript is overly forgiving for my tastes.
And then I wouldn't expect this to do anything, because nothing is taking damage.
The same happens when you get all the way down here, you're telling the target to gain negative "true" HP.
So if you fix that line to more accurately do what you want (and if you're not sure how, just tell me what you're trying to achieve), I think it should do what you want.
I was able to duplicate this. This, to me, is undesirable behavior, so I'll see if I can't work up a snippet for you to make all of this coding unnecessary, as I would also want DoTs to hit the barrier.
Copy this and save it as a .js file in your plugins folders, then add it into your plugin manager beneath the Absorption Barrier.
Code:
Game_Battler.prototype.gainHp = function(value) {
var blocked=false;
if (value<0 && !BattleManager._subject && this.barrierPoints()>0)
{
var damage=-value;
damage = this.loseBarrier(damage, 1, 0);
if (!damage)
blocked=true;
else
value=-damage;
}
if (!blocked)
{
this._result.hpDamage = -value;
this._result.hpAffected = true;
this.setHp(this.hp + value);
}
};
This should cause all sources of damage, even outside of direct damage from a skill, to get absorbed by the barrier. It should not interfere with the normal functioning of barriers, or cause them to get double hit or anything.
The limitation is that outside of using a skill/item, the game doesn't know where the damage came from. So you can't modify your DoTs with the barrier penetration tags or anything like that. But this should eliminate the need for most of your code in your state...just directly call gainHp() with the calculation you want.