Help with compresing states (with plugins)

I want to make a living dead with transformation to another actor and having black blood (damage instead of heal when life stealed on) using three of yanfly's tips and tricks i made it with ading three different states i want to know if i can compress it into one state.


Walkind Dead:


<Custom Regenerate Effect>


// Check if the user is still affected by the Walking Dead state.


if (user.isStateAffected(15)) {


// Check if the user's HP is 0 or below.


if (user.hp <= 0) {


// Set it back to 1.


user.setHp(1);


}


}


</Custom Regenerate Effect>


<Custom Apply Effect>


// Set the amount of HP needed to recover for the Walking Dead to not kill the user.


user._walkingDeadHp = user.mhp;


// Set the flag for whether or not Walking Dead's final save has failed to false.


user._walkingDeadFailed = false;


// Create an animation on the player to indicate Walking Dead has activated.


user.startAnimation(102);


</Custom Apply Effect>


<Custom Remove Effect>


// Check if the Walking Dead HP Healed requirement is undefined.


if (user._walkingDeadHp === undefined) {


// If it is, set it to the user's MaxHP.


user._walkingDeadHp = user.mhp;


}


// If the Walking Dead HP Healed is still above 0...


if (user._walkingDeadHp > 0) {


// ...then the save has failed.


user._walkingDeadFailed = true;


// Set the user's HP to 0.


user.setHp(0);


}


</Custom Remove Effect>


<Custom Respond Effect>


// Check if the Walking Dead HP Healed requirement is undefined.


if (target._walkingDeadHp === undefined) {


// If it is, set it to the target's MaxHP.


target._walkingDeadHp = user.mhp;


}


// Check if the user received any HP healing.


if (target.result().hpDamage < 0) {


// Carry over the healing to the amount of HP the target needs left to save itself from death.


target._walkingDeadHp += target.result().hpDamage;


}


// If the target's HP is 0 or less...


if (target.hp <= 0) {


// Then set the target's HP to 1.


target.setHp(1);


}


</Custom Respond Effect>


Black Blood:


<Guard HP Life Steal>


<Custom Respond Effect>


// Check if this is an HP effect and if the target received HP damage.


if (this.isHpEffect() && target.result().hpDamage > 0) {


// Declare the type of Life steal it is.


var type = 'hp';


// Check if it is physical


if (this.isPhysical()) {


// And add the Physical type


type += 'Physical';


// Check if it is magical


} else if (this.isMagical()) {


// And add the Magical type


type += 'Magical';


// If it is neither physical or magical


} else {


// Then add the certain hit type.


type += 'Certain';


}


// Get the skill's life steal rate.


var rate = this.getLifeStealRate(target, target.result().hpDamage, 'hp');


// Add it to the user's life steal rate.


rate += user.getLifeStealRate(type + 'Rate', target);


// Get the skill's life steal flat amount.


var flat = this.getLifeStealFlat(target, target.result().hpDamage, 'hp');


// Add it to the user's life steal flat amount.


flat += user.getLifeStealFlat(type + 'Flat', target);


// Calculate the damage to be dealt.


var dmg = Math.floor(target.result().hpDamage * rate + flat);


// If the damage is above zero...


if (dmg > 0) {


// Make a copy of the user's current results.


var result = JsonEx.makeDeepCopy(user._result);


// Make the user lose HP.


user.gainHp(-dmg);


// Start the damage popup.


user.startDamagePopup();


// Start an animation on the user.


user.startAnimation(2);


// Clear the user's results.


user.clearResult();


// Return the user's results to what they were before.


user._result = result;


}


}


</Custom Respond Effect>


Transform:


<Custom Apply Effect>


// Check if user is an actor.


if (user.isActor()) {


// Archive the previous settings.


user._prevCharName = user._prevCharName || user._characterName;


user._prevCharIndex = user._prevCharIndex || user._characterIndex;


user._prevFaceName = user._prevFaceName || user._faceName;


user._prevFaceIndex = user._prevFaceIndex || user._faceIndex;


user._prevBattlerName = user._prevBattlerName || user._battlerName;


// The filename of the character graphic without the file extension.


var charName = 'Test';


// The index of the character graphic used.


var charIndex = 0;


// The filename of the face graphic without the file extension.


var faceName = 'Test';


// The index of of the face graphic used.


var faceIndex = 0;


// The filename of the battler graphic without the file extension.


var battlerName = 'Test';


// Changes the character image to the setting applied from above.


user.setCharacterImage(charName, charIndex);


// Changes the face image to the setting applied from above.


user.setFaceImage(faceName, faceIndex);


// Changes the battler image from the setting applied from above.


user.setBattlerImage(battlerName);


// Refreshes the user's appearance.


user.refresh();


}


</Custom Apply Effect>


<Custom Remove Effect>


// Retrieve archived settings.


var charName = user._prevCharName;


var charIndex = user._prevCharIndex;


var faceName = user._prevFaceName;


var faceIndex = user._prevFaceIndex;


var battlerName = user._prevBattlerName;


// Changes the character image to the archived setting.


user.setCharacterImage(charName, charIndex);


// Changes the face image to the archived setting.


user.setFaceImage(faceName, faceIndex);


// Changes the battler image from the archived setting.


user.setBattlerImage(battlerName);


// Clear archived data.


user._priorityCharacterName = undefined;


user._priorityCharacterIndex = undefined;


user._prevFaceName = undefined;


user._prevFaceIndex = undefined;


user._priorityFaceName = undefined;


user._priorityFaceIndex = undefined;


user._prevFaceName = undefined;


user._prevFaceIndex = undefined;


user._priorityBattlerName = undefined;


user._prevBattlerName = undefined;


// Refreshes the user's appearance.


user.refresh();


</Custom Remove Effect>
The way you posted it makes it confusing, but...


<Custom Regenerate Effect>
// Check if the user is still affected by the Walking Dead state.
if (user.isStateAffected(15)) {
// Check if the user's HP is 0 or below.
if (user.hp <= 0) {
// Set it back to 1.
user.setHp(1);
}
}
</Custom Regenerate Effect>

<Custom Apply Effect>
// Set the amount of HP needed to recover for the Walking Dead to not kill the user.
user._walkingDeadHp = user.mhp;
// Set the flag for whether or not Walking Dead's final save has failed to false.
user._walkingDeadFailed = false;
// Create an animation on the player to indicate Walking Dead has activated.
user.startAnimation(102);
// Check if user is an actor.
if (user.isActor()) {
// Archive the previous settings.
user._prevCharName = user._prevCharName || user._characterName;
user._prevCharIndex = user._prevCharIndex || user._characterIndex;
user._prevFaceName = user._prevFaceName || user._faceName;
user._prevFaceIndex = user._prevFaceIndex || user._faceIndex;
user._prevBattlerName = user._prevBattlerName || user._battlerName;
// The filename of the character graphic without the file extension.
var charName = 'Test';
// The index of the character graphic used.
var charIndex = 0;
// The filename of the face graphic without the file extension.
var faceName = 'Test';
// The index of of the face graphic used.
var faceIndex = 0;
// The filename of the battler graphic without the file extension.
var battlerName = 'Test';
// Changes the character image to the setting applied from above.
user.setCharacterImage(charName, charIndex);
// Changes the face image to the setting applied from above.
user.setFaceImage(faceName, faceIndex);
// Changes the battler image from the setting applied from above.
user.setBattlerImage(battlerName);
// Refreshes the user's appearance.
user.refresh();
}
</Custom Apply Effect>

<Custom Remove Effect>
// Check if the Walking Dead HP Healed requirement is undefined.
if (user._walkingDeadHp === undefined) {
// If it is, set it to the user's MaxHP.
user._walkingDeadHp = user.mhp;
}
// If the Walking Dead HP Healed is still above 0...
if (user._walkingDeadHp > 0) {
// ...then the save has failed.
user._walkingDeadFailed = true;
// Set the user's HP to 0.
user.setHp(0);
}
// Retrieve archived settings.
var charName = user._prevCharName;
var charIndex = user._prevCharIndex;
var faceName = user._prevFaceName;
var faceIndex = user._prevFaceIndex;
var battlerName = user._prevBattlerName;
// Changes the character image to the archived setting.
user.setCharacterImage(charName, charIndex);
// Changes the face image to the archived setting.
user.setFaceImage(faceName, faceIndex);
// Changes the battler image from the archived setting.
user.setBattlerImage(battlerName);
// Clear archived data.
user._priorityCharacterName = undefined;
user._priorityCharacterIndex = undefined;
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
user._priorityFaceName = undefined;
user._priorityFaceIndex = undefined;
user._prevFaceName = undefined;
user._prevFaceIndex = undefined;
user._priorityBattlerName = undefined;
user._prevBattlerName = undefined;
// Refreshes the user's appearance.
user.refresh();
</Custom Remove Effect>

<Custom Respond Effect>
// Check if the Walking Dead HP Healed requirement is undefined.
if (target._walkingDeadHp === undefined) {
// If it is, set it to the target's MaxHP.
target._walkingDeadHp = user.mhp;
}
// Check if the user received any HP healing.
if (target.result().hpDamage < 0) {
// Carry over the healing to the amount of HP the target needs left to save itself from death.
target._walkingDeadHp += target.result().hpDamage;
}
// If the target's HP is 0 or less...
if (target.hp <= 0) {
// Then set the target's HP to 1.
target.setHp(1);
}
// Check if this is an HP effect and if the target received HP damage.
if (this.isHpEffect() && target.result().hpDamage > 0) {
// Declare the type of Life steal it is.
var type = 'hp';
// Check if it is physical
if (this.isPhysical()) {
// And add the Physical type
type += 'Physical';
// Check if it is magical
} else if (this.isMagical()) {
// And add the Magical type
type += 'Magical';
// If it is neither physical or magical
} else {
// Then add the certain hit type.
type += 'Certain';
}
// Get the skill's life steal rate.
var rate = this.getLifeStealRate(target, target.result().hpDamage, 'hp');
// Add it to the user's life steal rate.
rate += user.getLifeStealRate(type + 'Rate', target);
// Get the skill's life steal flat amount.
var flat = this.getLifeStealFlat(target, target.result().hpDamage, 'hp');
// Add it to the user's life steal flat amount.
flat += user.getLifeStealFlat(type + 'Flat', target);
// Calculate the damage to be dealt.
var dmg = Math.floor(target.result().hpDamage * rate + flat);
// If the damage is above zero...
if (dmg > 0) {
// Make a copy of the user's current results.
var result = JsonEx.makeDeepCopy(user._result);
// Make the user lose HP.
user.gainHp(-dmg);
// Start the damage popup.
user.startDamagePopup();
// Start an animation on the user.
user.startAnimation(2);
// Clear the user's results.
user.clearResult();
// Return the user's results to what they were before.
user._result = result;
}
}
</Custom Respond Effect>

<Guard HP Life Steal>


I just jammed the codes of the same group together, check if it works.
Even tough the way I post is confusing thx for helping me.


(It worked)

Original thread: https://forums.rpgmakerweb.com/threads/help-with-compresing-states-with-plugins.70814/