I have a passive state active on a character, and currently, it's effect is that if the user deals a critical strike, their agility is increased by 33% for 2 turns (code as follows):
However, I'd like to modify it to include an if statement, where, if the state which increases agility is already applied, and another critical strike is scored, it will heal the user for 33% of the damage the hit did. Mind you, I have little idea at all what I'm doing with this, the above code was basically copy/pasted from a yanfly tutorial that used it. I did google "js how to write an if statement", and followed the instructions, but it doesn't seem to help much, here is the code I now have (currently, none of it works).
If anyone could fix it for me AND go in-depth to explain how and why it needed to be changed, or simply just help explain how I can fix it myself, it would be tremendously appreciated!
<Custom Establish Effect>
// Check if the attack is a physical attack that dealt HP damage from a critical hit.
if (this.isPhysical() && target.result().hpDamage > 0 && target.result().critical) {
// Create an AGI buff that lasts 3 turns.
user.addState(997);
}
</Custom Establish Effect>
// Check if the attack is a physical attack that dealt HP damage from a critical hit.
if (this.isPhysical() && target.result().hpDamage > 0 && target.result().critical) {
// Create an AGI buff that lasts 3 turns.
user.addState(997);
}
</Custom Establish Effect>
However, I'd like to modify it to include an if statement, where, if the state which increases agility is already applied, and another critical strike is scored, it will heal the user for 33% of the damage the hit did. Mind you, I have little idea at all what I'm doing with this, the above code was basically copy/pasted from a yanfly tutorial that used it. I did google "js how to write an if statement", and followed the instructions, but it doesn't seem to help much, here is the code I now have (currently, none of it works).
<Custom Establish Effect>
// Check if the attack is a physical attack that dealt HP damage from a critical hit.
if (this.isPhysical() && target.result().hpDamage > 0 && target.result().critical) {
// Create an AGI buff that lasts 3 turns.
if a.State(997) exists
{
user.gainHP (value = user.MaxHP / 5);
}
else
{
user.addState(997);
}
}
</Custom Establish Effect>
// Check if the attack is a physical attack that dealt HP damage from a critical hit.
if (this.isPhysical() && target.result().hpDamage > 0 && target.result().critical) {
// Create an AGI buff that lasts 3 turns.
if a.State(997) exists
{
user.gainHP (value = user.MaxHP / 5);
}
else
{
user.addState(997);
}
}
</Custom Establish Effect>
If anyone could fix it for me AND go in-depth to explain how and why it needed to be changed, or simply just help explain how I can fix it myself, it would be tremendously appreciated!