Dealing extra damage to enemies with max HP

Started by PansyGum on

Topic category: Help with modding (Java Edition)

Last seen on 17:10, 25. Mar 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Dealing extra damage to enemies with max HP

Hi all, 

I'm trying to get a sword I'm working on to deal extra damage when the target's health is full - i.e Sword usually does 9 damage, but if the target is at 20/20hp it does 14 damage.

So far I've tried the following procedure :

if Target entity health = Target entity max health

  do [14] damage to Target entity of type GENERIC

with no result, Sword does its base damage regardless of the enemy's HP. I'm assuming that's because at the time of the attack, the entity technically doesn't have its maximum health any more, so the effect doesn't apply? I'm not sure what I could change here, if anyone has any insight on this, I'd appreciate it. 

Last seen on 19:15, 17. Mar 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Whats its trigger?
Wed, 02/17/2021 - 22:43

Whats its trigger?

Last seen on 17:10, 25. Mar 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It's set in the "When living…
Wed, 02/17/2021 - 23:59

It's set in the "When living entity is hit with tool" section of the sword's Triggers page, should I be changing something with the lime green Event trigger too?

Last seen on 19:15, 17. Mar 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
why dont you try if target…
Thu, 02/18/2021 - 02:15

why dont you try if target current health = max - (damage of sword so 9). 

 

hope thats helpful! :)

Last seen on 19:15, 17. Mar 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
but i guess because the…
Thu, 02/18/2021 - 02:19

but i guess because the sword can do a weak attack you might have to do cureent healt > max health -9

Last seen on 17:10, 25. Mar 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ahha! This solved it, thanks…
Thu, 02/18/2021 - 05:52

Ahha! This solved it, thanks so much! I'll post a pic of the procedure later so anyone who comes along can see how it's done. Now going through and adding conditions for all the damage enchantments. 

Last seen on 19:15, 17. Mar 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
cool glad i could help
Thu, 02/18/2021 - 15:22

cool glad i could help

Last seen on 17:10, 25. Mar 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here's a pic of the…
Mon, 02/22/2021 - 05:27

Here's a pic of the procedure I've been using that works, the main part circled in red. The base damage of the sword is 9.5, and I wanted it to do an extra 5 damage on first hit, which this achieves. The parts above the red circle are to account for Sharpness, Smite, and BoA and increase the damage done accordingly. The part below it is to heal the player sometimes, as this is meant to be a lifedraining weapon.

This method doesn't account for damage the target may have taken that is less than 9.5 however (i.e. target is at 17/20 HP), because the sword will still deal the extra damage. I could probably fix this by setting the greater than or equal to signs to straight up equals signs, but I haven't tested that. If anyone sees any additional issues with my procedures, or knows of ways I could clean them up, please let me know!

Max HP Extra Damage Procedure