Prevent damage/heal for the prevented damage taken?

Hello, I am using yanfly's plugins and want to recreate Medivh's force of will skill from HOTS in MV. It goes as follows:
"Protect an allied Hero from all damage for 1.5 seconds. Upon expiration, Force of Will heals the target for 20% of the damage it absorbed."

There's also an extra version which deals damage upon expiring:
"When Force of Will expires, it deals 80 damage to nearby enemies, plus 50% of the damage it prevented."

Is this possible to recreate? I'm not sure how to reference damage taken if you don't actually take damage.
it is possible if you know lunatic mode (I dont) but my best guess it require 2 states.
one for the 20% absorbed and the chain (or when expire) the 80 dmg with 50% prevented.

does that mean it deal 40 damage? or 50% dmg to teh user on the next attack?
it is possible if you know lunatic mode (I dont) but my best guess it require 2 states.
one for the 20% absorbed and the chain (or when expire) the 80 dmg with 50% prevented.

does that mean it deal 40 damage? or 50% dmg to teh user on the next attack?
Sorry for the misunderstanding, it'd do 50% of whatever damage the target took during the "protected" state. So the total effect with both combined would be a state that protects the target from damage, heals 20% of the total damage that would've hit them but it prevented it, and deals 50% of the total damage prevented back at the enemy. The 80 could be left out, it's just a base damage added to the 50% variable.
For the first effect using Buffs & States Core:

Code:
<Custom React Effect>
target._absorb = value;
value = 0;
</Custom React Effect>

<Custom Leave Effect>
target.gainHp(Math.floor(target._absorb * 0.2));
delete target._absorb;
</Custom Leave Effect>

Second effect:

Code:
<Custom React Effect>
target._absorb = value;
value = 0;
</Custom React Effect>

<Custom Leave Effect>
let targets = $gameTroop.aliveMembers();
let damage = 80 + Math.floor(target._absorb * 0.5);
targets.forEach(function(target) {
  target.gainHp(-damage);
  target.startDamagePopup()
});
delete target._absorb;
</Custom Leave Effect>
For the first effect using Buffs & States Core:

Code:
<Custom React Effect>
target._absorb = value;
value = 0;
</Custom React Effect>

<Custom Leave Effect>
target.gainHp(Math.floor(target._absorb * 0.2));
delete target._absorb;
</Custom Leave Effect>

Second effect:

Code:
<Custom React Effect>
target._absorb = value;
value = 0;
</Custom React Effect>

<Custom Leave Effect>
let targets = $gameTroop.aliveMembers();
let damage = 80 + Math.floor(target._absorb * 0.5);
targets.forEach(function(target) {
  target.gainHp(-damage);
  target.startDamagePopup()
});
delete target._absorb;
</Custom Leave Effect>
This looks like it's perfect, thank you very much! Since I'm sort of just learning this stuff, I'm assuming I make a skill, have it apply both of those states (I made the effects two different states, expire in a turn)? I went into a battle, put it on an actor, they took no damage from the enemy that hit them which is great, but they didn't heal or deal damage (I kept getting 0's) is that on my end or do I have to reference something in the skill note section?

EDIT: I also noticed that even after the state expired the enemy kept getting a damage popup after it's turn for 0. When I apply it to one actor, and a different actor gets hit I get this error
I was able to fix the other issues by putting in at the beginning:

<Custom Apply Effect>

//store a new param to track HP damage

target._absorb = 0;

</Custom Apply Effect>

but it seems like they only work individually and applying both to a single actor results in the 0's.

Original thread: https://forums.rpgmakerweb.com/threads/prevent-damage-heal-for-the-prevented-damage-taken.124567/