Absorb ailments (Resolved)

Hello,
Once again I need your help to modify a formula taken from a "Tips & Tricks" from Yanfly. It's "Absorb Ailments"
It's an effect of skill that can be used to remove all status effects of a certain type and place it onto the user instead, then healing each ally for each ailment removed.
I show you the formula and then I explain what I would like to do with it.

Spoiler: Spoile
The damage formula ==> this._absorbHeal || 0

Code:
<Before Eval>
// Check if the absorption hasn't begun yet.
if (!this._absorbedAllStates) {
  // Enable the absorption flag.
  this._absorbedAllStates = true;
  // Initialize the amount to be healed.
  this._absorbHeal = 0;
  // This is how much healing each absorbed state will do.
  var heal = user.mdf;
  // Create a list of all the states that can be absorbed.
  var absorbedStates = [];
  // Put all the states that will get absorbed here.
  absorbedStates.push(21, 22, 23, 24, 25, 26, 27, 28, 29, 30);
  absorbedStates.push(31, 32, 33, 34, 35, 36, 37, 38, 39, 40);
  // Get the group of alive allies
  var group = user.friendsUnit().aliveMembers();
  // Loop through each member in the group
  for (var i = 0; i < group.length; ++i) {
    // Get the currently looped member
    var member = group[i];
    // Check if the member exists and isn't the user
    if (member && member !== user) {
      // Loop through each of the absorbable states
      for (var j = 0; j < absorbedStates.length; ++j) {
        // Get the currently looped state's ID
        var id = absorbedStates[j]
        // Check if the state exists and if the member is affected by it
        if ($dataStates[id] && member.isStateAffected(id)) {
          // Get the turns on the state
          var turns = member.stateTurns(id);
          // Remove the state from the member
          member.removeState(id);
          // Add the state to the user
          user.addState(id);
          // Set the turns of it to the user
          user.setStateTurns(id, turns);
          // Increase the amount healed
          this._absorbHeal += heal;
        }
      }
    }
  }
}
</Before Eval>


In my game, I would like to use this effect on a single target ability. I would like the effect to apply only to the selected character. It is therefore not necessary to remove the states of all the other members of the group.
I also don't want the states to be transferred to the user of the spell (he can also use this spell on himself).
What I want is just a purification spell that can also heal based on how many states are removed. I'll manage for the amount of healing and the list of states.
Could someone adapt the formula for me please?
Because when I try to make a modification, I end up with a heal at 0 but I don't know why.

(Translation made by google, please ask me to rephrase if necessary)
Code:
<damage formula>
   //setting to zero, just to be sure. this would be the starting value to heal.
   value = 0;
   //how much to heal, replace zero to meet your needs.
   var healingValue = 0;

   // from the tips and tricks:
   // Create a list of all the states that can be absorbed.
   var absorbedStates = [];
   // Put all the states that will get absorbed here.
   absorbedStates.push(21, 22, 23, 24, 25, 26, 27, 28, 29, 30);
   absorbedStates.push(31, 32, 33, 34, 35, 36, 37, 38, 39, 40);

   for(var j = 0; j < absorbedStates.length; ++j){
      // Get the currently looped state's ID.
      var id = absorbedStates[j]
      // Check if the state exists and if the member is affected by it.
      if($dataStates[id] && target.isStateAffected(id)){
         //increase the value by the healing value
         value += healingValue;
      }
   }
</damage formula>

put just this code in the notetag of a new skill and test it. set the skill to heal hp in its settings.
Everything works correctly. That's exactly what I wanted.
Thank you very much for your help =)

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/absorb-ailments-resolved.149011/