Making a state that Raises ATK by HP/MHP difference.

Hello, I've been working on my some classes in my game and was wanting to give each one a special trait.


Basically, each Tank class gets a bonus to its secondary stat the lower it's HP is.


So my Knight (Strength and Defense based class) would get a bonus to it's ATK the lower it's HP is.


However, a Battlemage (Magic Attack and Defense based class) would get a bonus to it's MAT, and so on.


I'm currently using Yanfly's "Equip Battle Skills" plugin so the player can elect to equip these skills with these passive states attached to them.


I just need help figuring out how to write the eval functions that say to multiply ATK by (HP/MHP + 1).  


I'm having trouble finding any sources on how to write this.


Thanks for any help!
I THINK (not 100% certain) this can be done with Yanfly's Lunatic Mode. If this works, you'd need:


-Buffs and States Core (http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/)


-Base Parameter Control (http://yanfly.moe/2016/03/25/yep-86-base-parameter-control/) (EDIT: May not need this, actually. Might be good to have it, just in case, though.)


-All their prerequirements (which I'm pretty certain is only the Core Engine (http://yanfly.moe/2015/10/09/yep-1-core-engine/), but the Buffs and States Core may also require the Battle Engine Core (http://yanfly.moe/2015/10/10/yep-3-battle-engine-core/). You should have at least the Core Engine since you're using Equip Battle Skills)


You'll need to make a state to be equipped as a part of the skill. In the notetag for that skill, you will need to add:


<custom action start effect>


user.atk *= (user.hp/user.mhp + 1)


</custom action start effect>


<custom action end effect>


user.atk /= (user.hp/user.mhp + 1)


</custom turn end effect>


The use of an Action Start effect rather than a Turn Start effect is so that the ATK bonus is added directly before the user attacks, rather than at the beginning of the turn. The reason for this is that if you did a Turn Start effect, the effect might be a little lower than you intend it to be because the calculation and addition will occur at the beginning of the turn, so if the user gets attacked before they move, their attack will not increase again.


The use of the Action End effect should be to remove the attack bonus after the user moves, because I'm not certain how the Action Start would work, if it would constantly bump your attack on top of the bump from last turn, which I don't think is what you want (that would be OP).


THEORETICALLY, this should be saying "At the beginning of the user's action, raise attack by (current hp/maximum hp + 1). At the end of the user's action, lower attack to the value it was at the beginning of the turn." Obviously this will not work if your Knight/Battlemage attacks something and then the opponent counterattacks, or if the skill they use has an hp cost.


I hope this works for you! But if not, sorry. I'm just not certain of another way to do what you want.


EDIT: If that doesn't work, try replacing the ' user.atk *= ' and ' user.atk /= ' calls with ' atk Rate = '. Be aware that this fix will require the Base Parameter Control plug-in.
Ok, what would I have to change when I'm using Yanfly's ATB?


I think that might be throwing it off because I am seeing no change.
That actually shouldn't matter at all, since Action refers specifically to when the user is attacking... Have you tried changing it to the ' atk Rate ' from Base Parameter Control?

Original thread: https://forums.rpgmakerweb.com/threads/making-a-state-that-raises-atk-by-hp-mhp-difference.65242/