HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Detecting melee & Ranged damage -

09-30-2007, 01:57 AM#1
Blackroot
Heya, I'm look for a good way to detect how much damage an individual unit is doing reguardless of being ranged/melee. I'm trying to avoid detecting every unit in an event, but blizzard seems to only support unit's taking damage anyway -,-.

Thanks for the help.
09-30-2007, 07:34 AM#2
Pyrogasm
Set up these triggers:
Trigger:
Collapse Initialization Trigger
Collapse Events
Map Initialization
Conditions
Collapse Actions
Set TempPoint = (Center of (Playable map area))
Unit - Create 1 Footman for (Player 1 (Red)) at TempPoint facing (Default building facing) degrees
Custom script: call RemoveLocation(udg_TempPoint)
Trigger - Add to Damaged <gen> the event (Last created Unit) takes damage
Collapse Damaged
Events
Conditions
Collapse Actions
Collapse If (All conditions are true) then do (Then actions) else do (Else actions)
Collapse If - Conditions
(Unit-type of (Damage Source)) equal to Footman
Collapse Then - Actions
Set UnitIndex = 1
Collapse Else - Actions
Collapse If (All conditions are true) then do (Then actions) else do (Else actions)
Collapse If - Conditions
(Unit-type of (Damage Source)) equal to Archer
Collapse Then - Actions
Set UnitIndex = 2
Collapse Else - Actions
Collapse If (All conditions are true) then do (Then actions) else do (Else actions)
Collapse If - Conditions
(Unit-type of (Damage Source)) equal to Grunt
Collapse Then - Actions
Set UnitIndex = 3
Collapse Else - Actions
----- And so on and so forth -----
Set DamageTotal[UnitIndex] = (DamageTotal[UnitIndex] + (Damage done))
Set TimesDamage[UnitIndex] = (TimesDamaged[UnitIndex] + 1)
Set DamageAverage[UnitIndex] = (DamageTotal[UnitIndex] / TimesDamaged[UnitIndex])
Unit - Set (Triggering Unit) life to 100%

Then, you'll have to find some way of getting multiple units to attack this dummy unit. My suggestion is to repeatedly create a duplicate of different unit-types on the map and have them attack it at init to get an average.
09-30-2007, 07:58 AM#3
Malf
Since this is about damage, might I also ask a question?

With the native:
Collapse JASS:
native UnitDamageTarget             takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean

what does boolean attack and boolean ranged do? What are the differences?

Damage1: call UnitDamageTarget(u, t, 1, true, false, null, null, null)
Damage2: call UnitDamageTarget(u, t, 1, true, true, null, null, null)
Damage3: call UnitDamageTarget(u, t, 1, false, false, null, null, null)
Damage4: call UnitDamageTarget(u, t, 1, false, true, null, null, null)
Oh, and I'm also curious about passing attacktypes and damagetypes as null, what would happen then?
09-30-2007, 12:54 PM#4
moyack
boolean attack defines in how the hardcoded AI will make react the attacked unit. If it's set to true, the attacked unit will know who was the attacker and it will attack the damage source if it's in the attack range. If it's set to false, the attacked unit won't know who is attacking and it will move away, trying to "avoid more damage".

About ranged boolean, I'm not sure, but I suggest to set it according to the situation.

About the damage types, only set to null the weapon type, the others control the damage, but I think that setting them to null would be equivalent to dealt a chaos damage (honestly I haven't tested it).
09-30-2007, 06:08 PM#5
Pyrogasm
I forgot to mention, my method would give you an average for each unit-type that you could reference later in the game. It's not a method for getting it on-the-fly, nor will it be 100% accurate.
09-30-2007, 11:45 PM#6
Blackroot
I tried your function pyro, it wont work for my map, several units have the same damage, and hero's that level will change there damage. Even if I update it for heros, there's to big of a chance that several units will conflict in damage.

I've made about four functions trying to test damage, none of them are very accurate and seem to return the wrong mob about 8-12% of the time. Still, that wont stop me.