Lunatic State Passives Helpout

So I thought I can add lunatic states to achieve what I need with my passive states but the only problem is I do not know how to use lunatic state. Would someone give me a hand?

-I am planning to make a lunatic state that makes the character deal %1 more damage per %10 health its enemy is missing. For example if the enemy has 4500 but its max health is 9000, it will deal %5 increased damage.

-The buff will double the increased damage if the character has X buff. When the character has X buff and attacks a monster with 4500 health but the monster's max health is still 9000, it will deal %10 increased damage instead of %5.
I'm assuming you're using Yanfly's plugins. You can give this a try. I used one of Yanfly's Tips & Tricks as reference:

<Custom Confirm Effect>
if (this.isHpEffect() && value > 0) {
// change x below to the id of your state that doubles the bonus.
var stateX = x;
var bonus = (1.00 - target.hpRate()) * 0.1;
if (user.isStateAffected(stateX)) {
value *= (1.00 + bonus * 2.0);
} else {
value *= (1.00 + bonus);
}
value = Math.ceil(value);
}
</Custom Confirm Effect>

Hope that works for you!
Thank you. ^^

Original thread: https://forums.rpgmakerweb.com/threads/lunatic-state-passives-helpout.78405/