"Decimate-like" Skill?

● ARCHIVED · READ-ONLY
Started by Mozumin 5 posts View original ↗
  1. I want a skill to kill every enemy that is under 25% of their max HP, but do nothing (0 damage) if their HP is over that threshold. I believe that there's a formula for that, but i still haven't found one that works exactly how i want it to.
    If you guys know the skill "Decimate" from Bravely Default, that effect is exactly what i'm talking about.
    I tried b.mhp - ( b.hp * 3 ) but, of course, this one inflicts damage (albeit not lethal) even if the target's HP is from 26 to 33% of their max HP.
    Could you guys help me out a little? Thank you in advance.
  2. Try this:
     

    b.hp_rate < 0.25 ? b.hp : 0

    The  a ? b : c  operation is a conditional branch: If the condition (a) is fulfilled <in this case: the targets HP rate is less than 25%>, the command in the first branch (b) is executed <deal damage equal to the targets remaining HP>, otherwise the second one (c) <deal zero damage>.

    This operation is useful in a lot of more complex damage formulas.

    If you want, you might also take a look at this thread: How to make the most of custom formulae
  3. Thank you for responding! The formula that you gave me, for some reason, didn't work, but then i tried b.hp / b.mhp < 0.25 ? b.hp : 0 and it worked exactly as i wanted. Again, thanks a bunch. I didn't even know about the a ? b : c thingy, but now i do.
  4. Huh, that's funny... I would have expected  b.hp / b.mhp < 0.25 ? b.hp : 0  not to work at all:

    Usually, when you divide integers, the game will truncate the result into an integer value as well. So b.hp / b.mhp would either result in 1 if the target is at full health or 0 if it's not. If you are running into issues with that formula in other projects, you might have to modify the division a bit so the game does not round the result:

    b.hp.to_f / b.mhp

    However, glad it works :)
  5. Edit: Corrected.