Special Skill: Need Help.

Hey all, I need help with a skill I am trying to create. This skill is called Feral Strike. What I want this skill to do is whenever an enemy's HP is below 15-25% the attack is an instant kill, otherwise it doesn't do anything. Does anybody have any ideas on what I can do?
You need to place an if-statement in the damage formula and give two different damage formulae depending on the result.


Please search the forum for "how to use damage formula" as there is a topic that explains what you can do with ruby code in the damage formula.
Thanks. If you can find the link for that thread feel free to post it here. I am going to try to search for it again.

Here is an example of the code I am using in the damage formula. I am pretty sure I messed it up.

if b.hp <= 20% b.mhp; a.atk == 9999; else a.atk == 0; end
Use:

if b.hp <=b.mhp*0.2; b.add_state(1) ; else; 0; end

this will add a "death" state if enemy's hp is below 20% or do nothing if his HP is above 20%.

~ OR ~

if b.hp <=b.mhp*0.2; 9999 ; else; 0; end

This will do 9999 dmg if enemy's hp is below 20% or do nothing if his HP is above 20%.
@Dennis89

Notice the crucial difference between the formula you suggested and the one Rikifive gave you.  He has else; you have else

That semi-colon makes all the difference between a formula that works and one that doesn't.

And that thread you are looking for is in tutorials.
This is the article you might have been looking for.

Aside from what ksjp mentioned, you also used "a.atk == 9999" in your formula.  What this does is it evaluates to true or false (not a number) based on whether the user's attack is currently equal to 9999 (true) or not (false).  "a.atk = 9999" would set the user's attack to 9999 so the attack would do lots of damage... but it would do so permanently!  You don't want that.  Rikifive gave you two correct formulae you can use; note that in the second one the value 9999 is simply passed in and because it is the last value that is evaluated (because the condition is true), that is what the damage will be set to.
Thanks guys I am still trying to improve my coding skills, as an amateur coder "if" statements and switches were actually my strongest point. I seemed to have just fallen out of practice, so I appreciate the added help!!!

Original thread: https://forums.rpgmakerweb.com/threads/special-skill-need-help.42223/