Absorbing damage as MP?

Hello! I've been trying to figure out how to make a certain element deal damage to enemies, but increase allies' MP instead.

For example, a skill of that element that hits everyone on the field would hurt all enemies and increase all allies' MP by that amount (or at least with the same damage formula).

I've got Yanfly's Element Core up and working, and I've applied the relevant absorption tag to my actors, but there isn't an obvious way to convert the healing from HP to MP. The only thing I can think of is to actually get in and mess with the plugin code, but I'm definitely not experienced enough to pull that off.

Thank you in advance!
Bump?
There may be other ways, but I think you could do this with a notetag from Yanfly's Skill Core, e.g.
Code:
<Post-Damage Eval>
// Only if damage was dealt
if (value > 0) {
  // Set MP gain amount (equal to damage dealt)
  var mpGain = value;
  // Get all living allies
  var allies = user.friendsUnit().aliveMembers();
  // Loop through all allies
  allies.forEach(function(ally) {
    // Make ally gain that much MP
    ally.gainMp(mpGain);
  });
}
</Post-Damage Eval>
At work now so I can't test, but wouldn't that always make the skill give MP to all allies? (I could totally be wrong; I'm still learning scripts)

I was hoping for something just like Element Core's element absorb, just with MP instead of HP as it's set to by default.
Oh, whoops, yes, I think I misunderstood what you're trying to do! 👋

To clarify with an example: let's say element 5 is the special "HP to MP absorb" element. Then if someone absorbs 50 HP damage of that element, you want them to recieve +0 HP and +50 MP, right? 😅

If so, I think that could probably be done with a state notetag from Buffs & States Core, e.g.
Code:
<Custom React Effect>
// Check if skill involves special element
if (this.getItemElements().contains(5)) {
  // Only for HP damage
  if (this.isHpEffect() && value > 0) {
    // Target gains MP equal to damage value
    target.gainMp(value);
    // HP damage becomes zero
    value = 0;
  }
}
</Custom React Effect>
Replace 5 with the ID of your "special absorb" element. Then you'd just need to give the state to everyone who should have it~ 😮‍💨

(Note to self: getItemElements is from Yanfly's Element Core.)

Original thread: https://forums.rpgmakerweb.com/threads/absorbing-damage-as-mp.108380/