• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

attack detection

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,597
hi,
i know there are some ways to detect when a unit attacked a unit.
what i basically want to make: a passive ability that gives the unit a ranged magic attack for the next attack whenever he casts a spell. for the ranged magic form i'll use a passive unit transformation. so i want to transform the unit back if the attack landed on the target. what is the easiest way to do that?
thanks
 
Level 9
Joined
May 21, 2014
Messages
580
hi,
i know there are some ways to detect when a unit attacked a unit.
what i basically want to make: a passive ability that gives the unit a ranged magic attack for the next attack whenever he casts a spell. for the ranged magic form i'll use a passive unit transformation. so i want to transform the unit back if the attack landed on the target. what is the easiest way to do that?
thanks

You will really need an existing damage detection system.
I don't know what I can recommend you though.
 
Level 17
Joined
Mar 21, 2011
Messages
1,597
i already have a damage detections system, but they usually dont detect if damage is done by attack. however, because all my damage sources are done inside the trigger editor, i could sort out the attack damage. but still, is there an easier solution?
 
Level 9
Joined
May 21, 2014
Messages
580
i already have a damage detections system, but they usually dont detect if damage is done by attack. however, because all my damage sources are done inside the trigger editor, i could sort out the attack damage. but still, is there an easier solution?

The easy solution I could offer is what you just said; the damage must be triggered to let you simulate if it was an "attack" that was made. If there was an easy solution, this must be the easiest so far.

Though to detect an attack, maybe you can make use of "Unit is Attacked" event, since that event fires when the attack will be done. Maybe if that event is fired, turn on the damage detection trigger. After executing the actions in the damage detection trigger, you can turn off the damage detection trigger.
You need an extra trigger to detect when the attack is stopped/interrupted so that the damage detection trigger will be turned off even when the damage was not done.
 
Level 10
Joined
Jun 6, 2007
Messages
392
Just a small note: if you decide to use physical damage detection (which is the easiest solution), there are some abilities, which also deal physical damage, for example slow poison. Make sure that your transformed unit doesn't have these abilities and if necessary, trigger them.

If you deal physical damage from triggers, you will have to turn off dds before dealing damage, and turn it back on after dealing damage. There are also other solutions, you could for example have your own damage type variable to detect, when physical damage is triggered:

set damageFromAttack = false //true by default
-- deal physical damage --
set damageFromAttack = true

Another option is to add a buff placer ability to the transformed unit, and check if damaged unit has that buff. For that method, your dds doesn't have to detect damage types. This method can only be used if the transformed unit doesn't have orb effects, buff placers and area attacks.
 

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,550
so even if you give a damage source physical damage with triggers, it will still consider it as magical damage?

I've never used LFH's system, but in DamageType, triggered damage is a separate type "code"

It will recognize code, spells, attack, and NULL (0 damage can't be allocated a type)

Presumably LFH's system does something similar.

Edit:

Just a small note: if you decide to use physical damage detection (which is the easiest solution), there are some abilities, which also deal physical damage, for example slow poison. Make sure that your transformed unit doesn't have these abilities and if necessary, trigger them.

Those abilities aren't physical damage, they're just bugged and don't interact with Spell Damage Reduction (item ability) properly
 
Level 10
Joined
Jun 6, 2007
Messages
392
AFAIK, the code damage type only refers to damage dealt from inside an onDamage handler using UnitDamageTargetEx. I might have misunderstood it though.

Bugged or not, those abilities are detected by the system as physical damage, which will cause unintended effects.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
There is only one problem...
what if the unit attacks,
the missile flies,
the unit attacks again,
the missile that I mentioned before has now damaged the target and the unit transforms back,
the other missile hits the target.

This is not a bug but a very obvious glitch.
This means that I can have more attacks than told and so I break the system.
If you really want to do good stuff then you have to create the missile yourself and use instant damages for every unit.
I used this a pretty while until I used abilities as basic attacks where I could modify range without transforming for example or exceed attack speed limits.

For now you can just use that simple method I mentioned about indexing the basic attacks instead of detecting them.
It is pretty rewarding.
 
Status
Not open for further replies.
Top