HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

a unit takes damage, which type of damage?

05-18-2006, 07:31 AM#1
StockBreak
Is there a way to detect (in the specific unit event "unit takes damage") which type of damage is received (physical, magic etc...)? I saw that there are variables for damage type, but no idea how to use them. Thanks.
05-18-2006, 08:12 AM#2
Anitarf
Sadly, no.
05-25-2006, 04:38 PM#3
StockBreak
Is there at least a way to detect if the attack was caused by an "attack" or by something else (spells and triggers, according to Vexorian)? I can use the specific unit events (my units are in the map), so the damage detection it's not a problem. Thanks.
05-25-2006, 04:49 PM#4
Anitarf
Sadly, not in a simple or absolutely foolproof way, at least spell damage. For triggered damage, you can always turn off damage detection triggers before you deal it. If you have only triggered spells, then you can easily isolate attack damage, since it's the only non-triggered source of damage left.
05-25-2006, 05:25 PM#5
StockBreak
Quote:
Originally Posted by Anitarf
Sadly, not in a simple or absolutely foolproof way, at least spell damage. For triggered damage, you can always turn off damage detection triggers before you deal it. If you have only triggered spells, then you can easily isolate attack damage, since it's the only non-triggered source of damage left.
Unfortunately I have not only triggered spell... In my map it should be important to know if the damage is physical (caused by an attack damage), I don't care about spells. The only check I was able to put on my trigger was the condition: damage source's current order is "attack", but I don't think it's enough, right? Thanks.

EDIT: well, actually it's not enough. I was thinking about ranged units, if they change order while the projectile it's still flying, the event won't trigger, isn't it?
05-25-2006, 08:06 PM#6
shadow1500
Yes, you can detect if damage was caused by an attack or a spell.
You take frost orb ability, and modify it so it leaves a dummy buff for 0.01 seconds. Then use a trigger which, upon damage, will check if the buff is on the damaged unit, if it is, remove the buff and do all actions on attack damage, if the unit doesnt have the buff then the damage was caused by a spell.

You can also make elements for spells, by adding a decimal to the damage. For example, if you want to detect fire damage, add 0.02 to the damage the spell causes, if fireball in your map deals 50 damage, set damage to 50.02, then you can find if its fire damage like this:
Collapse JASS:
if (GetEventDamage() - R2I(GetEventDamage()))==0.02 then 
     // <do actions on fire damage>
endif
This doesnt work for some spells, like Chain Lightning, which reduces the damage with each jump.
05-25-2006, 09:31 PM#7
StockBreak
Quote:
Originally Posted by shadow1500
Yes, you can detect if damage was caused by an attack or a spell.
You take frost orb ability, and modify it so it leaves a dummy buff for 0.01 seconds. Then use a trigger which, upon damage, will check if the buff is on the damaged unit, if it is, remove the buff and do all actions on attack damage, if the unit doesnt have the buff then the damage was caused by a spell.

You can also make elements for spells, by adding a decimal to the damage. For example, if you want to detect fire damage, add 0.02 to the damage the spell causes, if fireball in your map deals 50 damage, set damage to 50.02, then you can find if its fire damage like this:
Collapse JASS:
if (GetEventDamage() - R2I(GetEventDamage()))==0.02 then 
     // <do actions on fire damage>
endif
This doesnt work for some spells, like Chain Lightning, which reduces the damage with each jump.

Thank you, I already had a similar idea (putting a buff on hero attacks) but I'll follow your advices (very very nice the decimal idea, REP ADDED of course). Actually I can use slow poison ability (so it stacks on melee. Do you know a buff ability that stacks on ranged units ?) or, better, I had an idea: what about enabling/disabling this dummy ability (hiding it with a SB) using the event "a unit is under attack"? So I can add this ability only when I need detect damage, should it work? Thanks.
05-25-2006, 09:53 PM#8
shadow1500
I used frost orb ability (Alft), it causes a chill slow, for both melee and ranged.