# Dealing a Percentage of Damage

Status
Not open for further replies.

#### Korimax

##### Architect of Procrastination
Okay basically I am asking how exactly I set up a battle formula when I want a skill to deal 50% of the target's current HP, I know how to do total HP by using a Negative Heal, but I don't know how to use Current HP.

Also if it is at all possible, I was wondering if it were possible for skills to have a sort of conditional damage, like if the target's HP falls below a specific % then it deals a specific amount of damage rather than 50% (That or just additional damage alongside the 50% when it gets that low).

EDIT: ALSO, I apologize if somehow I am posting this in the wrong place. (I do believe I am right, but I could somehow be mistaken.)

Last edited by a moderator:

#### Andar

##### Veteran
the damage formula can process any ruby operation, that includes checking conditions and more.

But for your half.damage, the formula is very simple - you just have to remember that a is the placeholder for the user and b the placeholder for the target. So your formula is simply:

Code:
``b.hp/2``
Place that in the skills damage formula and it will always deal half of the current HP of the target as damage (rounded down in case of uneven numbers)

#### Korimax

##### Architect of Procrastination
*Sigh* I should have realized it was divided by 2, I was being a bit ignorant. (I was trying to write it out as b.hp-50%)

Anyway, thank you for answering my question, any chance you might be able to answer the 2nd part. (I kinda just need to know if I need scripts or something of that nature for that really.)

#### Zevia

##### Veteran
For the conditional, you can do an if statement in the damage formula, too. So, let's say if the target is under 30% health, then you want the ability to deal 100 damage, and otherwise, it does 50% of their current HP. For the damage formula box, do:

if (b.hp*1.0)/(b.mhp*1.0)<0.3;x=100;else;x=b.hp/2;end;xThe reason you're multiplying b.hp and b.mhp by 1.0 is because, by default, the engine will ignore any decimals and just return the integer, but if you tell it to multiply by 1.0 first, then it will read decimals properly (so without the 1.0, b.hp/b.mhp will always return 0). So it will divide the target's HP by the target's max HP, and give you a decimal (your percentage of health remaining). If it's less than 0.3 (or less than 30%, for this example), then it sets a variable x equal to 100. Otherwise, x will equal half the target's current HP (b.hp/2). It will then do X damage.

Last edited by a moderator:
BCj

#### Korimax

##### Architect of Procrastination
THANK You so much. (That was actually quite easy to understand.)

Anyway I dunno if these threads get closed but my question has been answered.

#### Shaz

##### Global Moderators

Status
Not open for further replies.

### Latest Profile Posts

Today's my first login since Jan 2020. Time sure flies. Sorry to everyone's messages i missed.
It's satisfying to master the usage of a hard plugin, then making it do what you want. ( o w o)!!
I'll be redesigning some of the main characters from my many wip stories

Starting with the (chronologically) first of them, Cedric!
gotta love when a plugin you thought had nothing to do with why something else wasn't working winds up being the issue...
Doing RPG Maker News for 26th September 2021