HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Damage Detection for a Single Hero

01-01-2009, 03:02 AM#1
Zerzax
One of my spells in the Hero Contest submission involves checking whenever the hero is damaged to find whether its health has reached 10%, as well as some other conditions. If these conditions are fulfilled, the hero is healed. I've recently looked at the scripts database to find something that might suit this purpose, as I do not want to wantonly mess with damage detection. However, I thought about exactly what is going on with this spell: This hero, once created, will presumably exist for the entire duration of the game. Therefore a permanent trigger will be needed to detect damaging to this hero at various points in time. And this is only one unit, whose handle ID is never recycled and whose trigger can remain constant. Do I really need a damage detection system for this? Both that I have looked at, Adamage and Griffen's Detection, involve using DestroyTrigger as well as accumulating events for each unit that comes into existence, which I clearly don't need. My method would be MUI as each hero that learns the ability would have a permanent struct instance created and a permanent trigger indexed as a struct member. Assuming that my coding is sound and geared towards efficiency, would this method of single, permanent detection be safe?
01-01-2009, 03:04 AM#2
moyack
Quote:
Do I really need a damage detection system for this?
For your case mentioned, any damage detection is exagerated, just add a trigger for that hero and that's all.
01-01-2009, 03:12 AM#3
Zerzax
Alright, I guess then it shouldn't be a problem. I'm pretty relieved you said that, Moyack :D. It seems the major problem associated with detecting damage is the use of dynamic triggers...
01-01-2009, 03:35 AM#4
TriggerHappy
So yea in case he wasn't clear enough use the event

Trigger:
Events
Unit - <gg_unit_yourunit> takes damage
01-01-2009, 05:11 AM#5
Veev
You should probably use the event "A unit takes damage" and then as a condition you check if the unit-type is whatever hero you want. Just in case the spell needs to be MUI or whatever...

I suggest this because any hero test map has two of the same hero in it.
01-01-2009, 06:06 AM#6
Bobo_The_Kodo
Quote:
You should probably use the event "A unit takes damage" and then as a condition you check if the unit-type is whatever hero you want. Just in case the spell needs to be MUI or whatever...

I suggest this because any hero test map has two of the same hero in it.

Other than the fact that there is no "A Unit Takes Damage" event
01-01-2009, 06:23 AM#7
Veev
You are helpful. I have a damage detection system that I add units into and run triggers from that. I completely overlooked the fact that . . . He didn't have a system to begin with. =P

In less words, listen to TriggerHappy. ;)
01-01-2009, 01:40 PM#8
Zerzax
Quote:
Originally Posted by Zerzax
My method would be MUI as each hero that learns the ability would have a permanent struct instance created and a permanent trigger indexed as a struct member

It's all done in vJASS, not to worry.
01-01-2009, 02:24 PM#9
Archmage Owenalacaster
Quote:
Originally Posted by Bobo_The_Kodo
Other than the fact that there is no "A Unit Takes Damage" event
Collapse JASS:
TriggerRegisterUnitEvent( gg_trg_SpecificUnitDamageDetect, [SpecificUnit], EVENT_UNIT_DAMAGED )
01-01-2009, 10:28 PM#10
Anitarf
"A Unit Takes Damage" implies a generic unit event, not a specific unit event; such a generic unit event does not exist.

Note that in your specific case, not using a damage detection system is a more sensible solution, but at the same time one of the judging criteria is reusability; assumptions that are valid in your specific case might not be valid when considering the hypothetical reuse of your code, like the fact that the spell is only used by few heroes for the entire duration of the game; also, when used in a map with many other spells it's likely that others will already require a damage detection system, in which case your ability is actually less efficient if it creates it's own triggers than if it uses the same system as every other spell.
01-01-2009, 10:51 PM#11
Zerzax
In this case it's the only spell that would require any kind of damage detection. I can understand that using a system would seem better, but in this case I think the penalty for little usage of a stand-alone system is not as bad as using a complex system for this purpose, which I would probably get docked for. On the whole, I've implemented use of collision missiles and possibly other scripts that would be used in a blanket spell system, like xe. While this might be bad for code reuse and looked at as hubris (heh), I'm pretty confident I coded the collision well.