# 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

Regret that I wasn't able to actually finish my igmc entry in time for the actual igmc. Will probably just offload it as a standalone thing.
I'm a master in procrastination and have finally decided to educate people in this art in a seminar in Calais. Please don't come. I won't be there.
Testing some of my custom battlers (they're all trash, sorry).

a friend of mines said I need an elevator pitch for my game. he then went and gave me his for his comic... then I realized I have no idea how to explain my game the way he did his comic lol.