How to lower own health with a skill?

Hi guys! Im making a super dooper attack , but it has a big mp cost , and it lowers your health.. or at least it should..

Maybe i can just put success rate at 30% and the mp cost will be the gambling piece of the attack..

But i would like to know how to hurt oneself nevertheless... i really have probelms with these skills...

once i put +atk on an enemy skill, and later i couldnt figure out why i had 10 more atk than when i tried enemies out in the troop screen 😛
Yanfly has a skill cost script which will let you assign an HP cost and an MP cost. Maybe that is what you need for this?
Or simply write into the damage formula box

Code:
a.hp -= own damage; regular damage
i make integers with .max?

oh wait.. i figured it out.. Shaz said that if you dont introduce non-integers to your formula, that you wont get any decimals... so i just replaced 0.1 with 1/10 😛

current formula : a.hp-=(a.mhp*1/10);(a.atk  - b.def)*3
If you want to actually show it in the log, you could also do

a.result.hp_damage=(a.mhp*1/10);a.execute_damage(a);(a.atk-b.def)*3
i make integers with .max?

oh wait.. i figured it out.. Shaz said that if you dont introduce non-integers to your formula, that you wont get any decimals... so i just replaced 0.1 with 1/10 😛

current formula : a.hp-=(a.mhp*1/10);(a.atk  - b.def)*3
.max is for comparing two values and taking the greater of the two.  For an interger, use .to_i

As Shaz said, the formula will take the same precision as what you enter.  But you have to be careful.  For example, a.mhp * 1 / 10 will work just fine, but a.mhp * (1 / 10) will always result in 0 no matter what the user's MHP is because (1/10) is less than 1 so it will multiply their MHP by 0.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-lower-own-health-with-a-skill.39863/