# Absorb ailments (Resolved)

Status
Not open for further replies.

#### Jay19

##### Veteran
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.

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
// 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.
Because when I try to make a modification, I end up with a heal at 0 but I don't know why.

#### oooNUKEooo

##### Veteran
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.

#### Jay19

##### Veteran
Everything works correctly. That's exactly what I wanted.
Thank you very much for your help =)

#### slimmmeiske2

##### Little Red Riding Hood

Status
Not open for further replies.

### Latest Profile Posts

Uploaded my short game to itch.io just to see how it works... It doens't. Failed to load IconSet.png it says.
Yeah okay. Not wasting another second on it. :\
I wonder if anyone would be interested in free character art from me...
I remade/fixed my Elf XP Mack Templates. The Ears are looking better now.

You can check them out, they are in 12 recolours, both Human and Elf Versions!