HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

GetUnitDamage

04-18-2009, 02:19 PM#1
wraithseeker
Is that possible to code with EVENT_UNIT_DAMAGE or any possible circumstances?
04-18-2009, 02:34 PM#2
Ignitedstar
Er... I just checked, and- oh I see. You mean EVENT_UNIT_DAMAGED
There are tons of things you can do with this. However, because Blizzard was stupid when they wanted EventUnitDamage to only work with a single unit and not a generic unit, it's limited in what it can grab unless you sort of... "cheat". This is when I wish the World Editor can be hacked.
04-18-2009, 02:37 PM#3
wraithseeker
Yes, EVENT_UNIT_DAMAGE.

I want to know how do I get a unit's damage.
04-18-2009, 02:37 PM#4
moyack
Use a Damage detection scripts, we have several of them here.

To get the damage dealt: local real d = GetEventDamage()
04-18-2009, 02:47 PM#5
wraithseeker
Let's say, I have a spell A that sacrifices a unit that adds in 20% of the sacrificed unit's damage. That would be impossible to do it?
04-18-2009, 02:47 PM#6
Ignitedstar
There's a little more, too.

To get the unit that took the damage, use GetTriggerUnit().
To get the unit that dealt the damage, use GetEventDamageSource().

EDIT: That's not the kind of damage we're talking about. EventUnitDamage only works when a unit actually takes damage. So, in order for it to work in the way that you want it, the unit would have to hit the something, first. However, even then it won't really work, because I believe the damage will be affected by armor.

It's not impossible, though... Sorry, I don't have to the time to explain; gotta go!
04-18-2009, 02:52 PM#7
wraithseeker
The above example tells me that I cannot do that since it's a sacrifical spell that doesn't do any damage.
04-18-2009, 03:36 PM#8
Alevice
use unitproperties by cass/litany
04-18-2009, 03:41 PM#9
wraithseeker
How do I find the damage? I am using UnitProperties, that didn't explain much.
04-18-2009, 03:56 PM#10
moyack
Death pact ability, but applicable to non undead units....

Easy: local real Bonus = FACTOR * GetWidgetLife(GetSpellTargetUnit())
04-18-2009, 04:02 PM#11
wraithseeker
Huh? I want to find the damage of the unit and not the life of the unit.
04-18-2009, 04:17 PM#12
Alevice
Quote:
Originally Posted by wraithseeker
How do I find the damage? I am using UnitProperties, that didn't explain much.

local real dmg = UnitGetDamage(u) should work, IIRC
04-18-2009, 04:35 PM#13
wraithseeker
That doesn't work, that thing only gets the damage in bonuses which I did not set any bonus to it.
04-18-2009, 09:03 PM#14
Bobo_The_Kodo
...

store them all somehow on init and do a lookup + damage bonuses
04-18-2009, 09:18 PM#15
TEC_Ghost
There's no way to get the unit's damage natively, there's some scripts that can kind of simulate this effect, Another alternative is to just track the units damage in a variable and make sure you keep it up to date with what's going on, but that'd be a pain in the ass.