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.
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.
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 🙂
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!
You sir are a genious! Thank you for your answer. That's exacly what i was looking for 🙂 !