Yay, Lunatic Mode!
Okay, so, I was reading about the Thornmail on YanFly's site, and got to wondering:
What if you could adjust that and make it heal the target after damage instead of doing recoil to the user? The state would heal, but only after the original damage was calculated and applied.
So, let's say "A" attacks "B"
B's HP: 101
A's attack does 100, B drops to 1, then heals 50% of what was done— Taking him back to 51HP. However, if the damage done would be ≥101, B would die and that heal wouldn't trigger.
Exactly how would you do that? I'm super new to JS, and simply attempted to edit YanFly's Thornmail script, but it apparently doesn't work that way.
This is what I did(feel free to laugh, because it's super bad)
This is the original:
So, if you guys don't mind, let me know what I did wrong :hswt:
Okay, so, I was reading about the Thornmail on YanFly's site, and got to wondering:
What if you could adjust that and make it heal the target after damage instead of doing recoil to the user? The state would heal, but only after the original damage was calculated and applied.
So, let's say "A" attacks "B"
B's HP: 101
A's attack does 100, B drops to 1, then heals 50% of what was done— Taking him back to 51HP. However, if the damage done would be ≥101, B would die and that heal wouldn't trigger.
Exactly how would you do that? I'm super new to JS, and simply attempted to edit YanFly's Thornmail script, but it apparently doesn't work that way.
This is what I did(feel free to laugh, because it's super bad)
Code:
<Custom React Effect>
// Check to see if any physical damage is dealt.
if (value > 0 && this.isPhysical()) {
// Sets the Recoil Rate to 15%.
var rate = 0.15;
// Determines the amount of recoil damage dealt.
var recoil = value * rate;
// Sets the DEF bonus rate to 25%.
var rate = 0.25;
// Determines the amount of bonus damage dealt.
var bonus = target.def * rate;
// Rounds up the bonus damage and recoil damage.
var dmg = Math.ceil(bonus + recoil);
// Makes the target gain HP equal to the dmg variable divided by half.
target.gainHp(dmg / 2);
}
</Custom React Effect>
This is the original:
Code:
<Custom React Effect>
// Check to see if any physical damage is dealt.
if (value > 0 && this.isPhysical()) {
// Sets the Recoil Rate to 15%.
var rate = 0.15;
// Determines the amount of recoil damage dealt.
var recoil = value * rate;
// Sets the DEF bonus rate to 25%.
var rate = 0.25;
// Determines the amount of bonus damage dealt.
var bonus = target.def * rate;
// Rounds up the bonus damage and recoil damage.
var dmg = Math.ceil(bonus + recoil);
// Makes the attacker lose damage equal to the dmg variable.
user.gainHp(-1 * dmg);
// Check to see if the attacker is dead.
if (user.isDead()) {
// If the attacker is dead, make it collapse.
user.performCollapse();
}
}
</Custom React Effect>
So, if you guys don't mind, let me know what I did wrong :hswt: