Increase DEF by ATK

So, I have a state called barrier, and I want for it to increase the user's defense by his attack, but I don't know how.
Any help, please?
If it is something that only works in battle you can set your damage formulae to take that into account. The state itself could as well do nothing. Whenever you would use b.def in your damage formula you can use this instead:
Code:
(b.def + (b.state?(barrier_state_id) ? b.atk : 0))
Here is a sample of how to use this in the basic attack formula.
Code:
a.atk*4 - (b.def + (b.state?(barrier_state_id) ? b.atk : 0))*2
If you want to use this outside battle then you have to use a script.
(post collision; ignore)
If it is something that only works in battle you can set your damage formulae to take that into account. The state itself could as well do nothing. Whenever you would use b.def in your damage formula you can use this instead:
Code:
(b.def + (b.state?(barrier_state_id) ? b.atk : 0))
Here is a sample of how to use this in the basic attack formula.
Code:
a.atk*4 - (b.def + (b.state?(barrier_state_id) ? b.atk : 0))*2
If you want to use this outside battle then you have to use a script.
Thank you very much for helping, the first formula will help me a lot, thank you again!

Original thread: https://forums.rpgmakerweb.com/threads/increase-def-by-atk.108131/