• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

Detecting Overdamage

Status
Not open for further replies.
Level 2
Joined
Aug 11, 2009
Messages
22
Is there a way to detect the amount of damage that a spell or attack does beyond the lethal part?
Example: Spell does 300 damage. Target has 100 life and no damage reduction towards spell damage. Difference is 200, this is what I need.
In a scenario where units have different damage reductions this will be kind of complicated.
I was thinking about dealing a little damage (A), getting the actual damage done (B) and calculating the reduction from the quotient (A-B) / A. Then one could calculate the damage needed to kill this unit and thus get the difference. I wonder if there's a more efficient way though, because these seems rather complicated. Help please :)
 
Level 12
Joined
May 22, 2015
Messages
1,051
This is a piece of cake with a damage detection system. It tells you how much damage they are about to take (after all forms of resistance / protection) and you can just compare that with remaining life.
 
Level 2
Joined
Aug 11, 2009
Messages
22
I used the (admittedly GUI) dds from this website and it doesn't work like that. If a unit dies, it still gives me the total damage done, not the damage needed to kill the unit. So it's different for other systems?

EDIT: I have the feeling that I didn't explain it good enough. Here's a proper example: I have a spell that deals 500 damage. The target has 300 life and 30% resistance to the spell's damage and attack type. So it deals 500*0.7=350 damage. It kills the unit. What I want is the damage which exceeds the lethal amount: 350-300=50 damage

EDIT: Nevermind, I had a huuuge brain lag. You are so right :)
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,170
Just to clarify why it was the solution. The "Unit takes damage" event fires before the damage that triggered it is removed from the unit's life. Hence one can tell if the damage is fatal if the event response damage is greater than their current life minus 0.505 (the fatal threshold?).

It is possible for a unit to die from damage less than its current life due to the fatal threshold. It is important that you factor it in to any calculations involving death.
 
Last edited:
Status
Not open for further replies.
Top