Enemy stats raise as HP goes down.

I'm trying to make a battler which Attack and Defense go up as he takes damage, but there are no commands to do this.

To be exact, his Attack and Defense should raise up to 50% when it hits 0 HP.

Example: The enemy has 1000 HP, 200 ATK and 100 DEF.
When the enemy reaches 500 HP, its ATK would be 250 and it DEF 125 and so on. 

I could make mutliple battlers with different stats and use the enemy transform command, but I'm looking for something smoother, is there a way to do this, even just adjusting the stat raise to 100%?
I can see how to do this for ATK using the damage formula.  I think if you want to do it for DEF as well, you would probably have to use a script - maybe one of Yanfly's Lunatic scripts, but I don't know them well enough to recommend which one.

If you want just ATK then you have 2 options.  The first scales things very smoothly, and looks like this:

[SIZE=10.5pt]Basically you need to add a factor to the damage that gets higher with low HP.[/SIZE]

[SIZE=10.5pt]If you keep it simple with a linear percentage-based progression, that would be:[/SIZE]

[SIZE=10.5pt]a.atk *4 - b.def * 2 + ((a.atk*4 - b.def * 2) * (a.mhp - a.hp)/a.mhp)[/SIZE]

[SIZE=10.5pt]If you want it to apply a different percentage then you need to alter the final part of the formula.  So for 1% increase for every 2% HP loss, it would read:[/SIZE]

[SIZE=10.5pt]a.atk *4 - b.def * 2 + ((a.atk*4 - b.def * 2) * (a.mhp - a.hp)/(a.mhp/0.5))[/SIZE]

[SIZE=10.5pt]Your second option [/SIZE][SIZE=10.5pt]A simple skill which does a lot more damage once the HP falls below a certain level, (in this example 50%) but above it does something normal would be:[/SIZE]

[SIZE=10.5pt]if (a.hp / a.mhp) <0.5; big_damage_formula_here; else; normal_attack_formula_here; end[/SIZE]

[SIZE=10.5pt]Instead of a percentage, it could be a fixed amount in which case it would be[/SIZE]

[SIZE=10.5pt]if a.hp <500; big_damage_formula_here; else; normal_attack_formula_here; end[/SIZE]

[SIZE=10.5pt]You can have lots of small variations.  It might be 25% for one skill, but 30% for another.  Or 500HP for your tank, but 300HP for a weaker character. [/SIZE]
Awesome, this will be really useful.

Thanks for your help!
Hey thanks for posting this awesome sauce. 
@LexnNitro

Please do not hijack someone else's thread with a different query, but start a new one.  One thread, one question.  It's the only way to keep things organised and to make it possible for people to search for existing answers to their problem.
Well to be honest at first I thought this was doable and related to this. 

Then I came back and edited my post to share what I have found. 

I'll go make a new post. 
Is there something wrong with my formula? It's not working for me now.

if (b.hp / b.mhp) <0.26; b.mhp; else; 0; end

What I want to occur: If the enemy HP is less than 25% of his max, he takes his MHP as damage. If not he takes 0. 

What it's currently doing: He always takes his MHP as damage, never 0, even if he is at 100% health. 

Original thread: https://forums.rpgmakerweb.com/threads/enemy-stats-raise-as-hp-goes-down.42278/