Forumla for removing a % of a characters health.

Master100000

Graphic Design/Complex Eventer
Veteran
Joined
Jan 5, 2015
Messages
108
Reaction score
9
First Language
Spanish
Primarily Uses
N/A
I'm trying to inflict the player with 25% of his maximum HP as the cost to use the skill. I am not looking for a method for the skill to check if the player has enough HP to use the skill i simply want the skill to be used with the cost of 0MP and 0TP and a common event removing 25% of the users HP after the skill has been used. Therefore the user would die soon after using the skill if his remaining HP is less than 25% of his maximum HP. What method could i go about for doing this?

Thank you in advance for any support. This community is amazing. It has helped me solve quite a couple problems already.
 

dkun

Veteran
Veteran
Joined
Jul 7, 2012
Messages
42
Reaction score
24
First Language
Tagalog
Primarily Uses
RMMV
Well, I think the easiest way to do this is use one of Yanfly's plugin: the Skill Core one. Using it, you can simply put <HP Cost: 25%> on the notetag of the skill.

I can think of a method using just common events where you'd have to have multiple skills each one for different characters (if you intend the skill to be usable because as far as I know, there's no way of changing hp cost of the user using the default event commands.
 

Master100000

Graphic Design/Complex Eventer
Veteran
Joined
Jan 5, 2015
Messages
108
Reaction score
9
First Language
Spanish
Primarily Uses
N/A
Yanflys skill core does that? Dang it.. The last think i wanted to add is another plug in to a game that isn't allowed to reach 100mb lol.. Oh well.. Thanks anyway for answering. I'm going to give it a try :)
 

Tagris

Veteran
Veteran
Joined
Oct 22, 2015
Messages
35
Reaction score
12
First Language
English
No need to add a plugin!

Just use this formula:

a.gainHp(-Math.floor(a.mhp * .25); a.atk * 6 - b.def  < you can replace everything after the ; with whatever damage formula you want.

Then you have an attack that does damage to you = 25% hp

There are a few downsides to note though...

Yanfly's engine goes around these issues.

1) if the player is affected by a state that reduces that type of damage you would need to alter the formula.  So, if you have a state that reduces damage the player takes by 50%...then it would affect this 'cost' since it isn't actually a cost, but damage being delt back to the player.

You can get around this, if you have such states you can just add it as a variable into the equation.

a.isStateAffected(3) ? a.gainHp(-Math.floor(a.mhp * .50); a.atk * 6 - b.def : a.gainHp(-Math.floor(a.mhp * .25); a.atk * 6 - b.def

Just put the number of the state in the equation and it would deal increased damage back to the player in that situation.  Giving the program an 'else' conditional branch within the damage.  However, if you have a lot of these states, then it could get annoying, but not mathmatically a problem.

2) Also, the damage is damage being delt to the player...which means it can miss.  This is the biggest 'downside' to the equation option.  Because of this, when I use this ability type, I use 'certain hit' and save my hp cost abilities as being very powerful and should not miss.  You can up the chance to hit, if you don't want to use 'certain hit' and just make it impossible to miss...but that means that it can't miss the enemy.

3) On hit effects will proc for both the player and the enemy.  If you have 'add state normal hit' on this attack, then the enemy will be hit with the effects of the weapon the character has and so won't the player.  Because of this, I don't use the add state normal hit, and say in my skill descriptions that these attacks do not apply on-hit effects

Yanfly's plugin gets around all this and lets you just type in the cost in the notes...but I have found a way to make it work using the default engine.

Hope that helps!
 

Master100000

Graphic Design/Complex Eventer
Veteran
Joined
Jan 5, 2015
Messages
108
Reaction score
9
First Language
Spanish
Primarily Uses
N/A
You sir are a genious! Thank you for your answer. That's exacly what i was looking for :) !
 

Master100000

Graphic Design/Complex Eventer
Veteran
Joined
Jan 5, 2015
Messages
108
Reaction score
9
First Language
Spanish
Primarily Uses
N/A
Ok so i tried out the formula and it wouldn't do any damage to me or the enemy until i altered it from
a.gainHp(-Math.floor(a.mhp * .25); a.atk * 6 - b.def

To

a.gainHp(-Math.floor(a.mhp * .25)); a.atk * 6 - b.def

But now it does the same amount of damage to me that it does to the enemy x.x


Lmao nvm the formula is doing what it's supposed to be doing. the Yanfly action sequencly that I've placed on the

attack uses the "action effect" many times and so it causes the formula to be used many times which means 

the character is inflicted with 25% several times lmao... i'lll figure it out on my side. Thank you for the formula :)

1448910422914.jpg
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top