| 02-25-2008, 11:05 AM | #1 |
I'm not good with attacks so here are few questions. Is it possible to detect the damage type? Like detect if damage is done is piercing, magical, siege etc... If yes how? Can triggers that reduce damage etc differentiate damage done by units from "damage" done using set life? |
| 02-25-2008, 11:25 AM | #2 |
give each unit a distinct orb effect and then use some damage detection system out there. Now if you associate an orb with a unit, you got the damage type. Other than that, i can see no way. But maybe someone knows an underused native for you to work with. |
| 02-25-2008, 11:41 AM | #3 |
I saw some orb detection system but (I think it was Vex's) not sure but I think they were bugged. After some time it stopped dealing regular damage and just inflicted spell damage as well as swapping effects of orbs. |
| 02-25-2008, 05:48 PM | #4 | ||
Quote:
You could use a custom DamageUnit function that attaches that information to the unit. Wouldn't be difficult at all, but you'd have to replace all of the old damage function calls. Quote:
The event "Unit Takes Damage" only fires when the unit actually takes damage, not when a unit's life is changed. So yes. |
| 02-25-2008, 11:32 PM | #5 |
Just make a function GetUnitDamageType(u) and fill it out by hand to return the correct damage type based on the unit's typeid. |
| 02-26-2008, 01:17 AM | #6 |
Oh crap I was thinking of the wrong thing. Grim's method would work better (especially considering that mine wouldn't really work at all :)). |
| 02-27-2008, 05:19 AM | #7 |
Well, TaintedReality, your method could work: JASS:library DamageEx struct DamageInfo unit whichUnit unit target real amount boolean attack boolean ranged attacktype attackType damagetype damageType weapontype weaponType boolean result static method create takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns DamageInfo local DamageInfo D = DamageInfo.allocate() set D.whichUnit = whichUnit set D.target = target set D.amount = amount set D.attack = attack set D.ranged = ranged set D.attackType = attackType set D.damageType = damageType set D.weaponType = weaponType set D.result = UnitDamageTarget(whichUnit, target, amount, attack, ranged, attackType, attackType, damageType, weaponType) return D endmethod endstruct function UnitDamageTargetEx takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean local DamageInfo D = DamageInfo.create() call SetUnitUserData(target, D) return D.result endfunction endlibrary //And an example of code: function OtherFunc takes nothing returns nothing local DamageInfo D = DamageInfo(GetUnitUserData(<Some Unit>)) if D.attackType == ATTACK_TYPE_PIERCING then //Whatever endif endfunction |
| 02-27-2008, 07:23 PM | #8 |
But that wouldn't detect the attack type of units, which is what I thought of after grim posted that. It would work fine for triggered stuff though. |
| 02-28-2008, 06:24 AM | #9 |
And you were talking about triggered damage :P |
| 07-11-2008, 11:57 PM | #10 |
I'm having difficulty discerning what your question is. |
| 07-11-2008, 11:58 PM | #11 |
The "A Unit is Attacked" event fires before the unit actually attacks and before damage is done; most precisely it happens when the unit initiates the attack, so... And next time just create your own thread because this isn't really related. |
