Started by PansyGum on Wed, 02/17/2021 - 22:22
Topic category: Help with modding (Java Edition)
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  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.
Whats its trigger?
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?
why dont you try if target current health = max - (damage of sword so 9).
hope thats helpful! :)
but i guess because the sword can do a weak attack you might have to do cureent healt > max health -9
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.
cool glad i could help
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!