• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Detect when a unit throws it's attack projectile.

Status
Not open for further replies.
Level 19
Joined
Dec 12, 2010
Messages
2,074
you can't. you need to manage all attack speed modifiers to do so, as well as create storage for every unit attack point values. THEN, and only then, you'll be able to track down if the unit starts the attack and does not interrupt it via periodical trigger to check his current order. sounds complicated indeed
 
Level 13
Joined
Jan 2, 2016
Messages
978
The way to do it is to make a unit's attack "instant", instead of "missile", and use DDS to detect when a unit takes damage.
Then you'd need to trigger the missle tho...

I really wish there was a way to detect such an event by "normal" means, but there isn't xP
 
Level 11
Joined
Jan 23, 2015
Messages
788
Okay, I'll make the unit's attack instant and trigger the projectile, but what happens with buffs and abilities that trigger when the unit attacks someone? Since I'll first store the Damage Amount, and set it 0 (so it won't damage instantly but wait for the projectile to hit), later when the projectile hits, I'll have to damage the unit via a trigger.
There can also be units that have a chance to dodge an attack right?

I have a spell based on Cold Arrows, and all I want to do is to detect when the unit uses the Cold Arrows (I can detect when the spell is cast, but when it's activated, I can't detect when the projectile of the attack is thrown).
 
Level 13
Joined
Jan 2, 2016
Messages
978
Well, you can check out my Custom Multishot, tho I don't know if you will understand anything, as it's quite long xP
Basically I use a dummy unit, which casts a spell, based on Acid Bomb, with a custom buff. I save a struct (holding data about the damage dealt, damage dealer, damage type, attack type, etc) inside a hashtable with parent key = the dummy's handle id.
Then I create another event - when a unit takes damage, with condition "The unit has my custom buff".
If the unit does have my custom buff - I remove the buff, load the struct from the hashtable, and make my unit damage its target for the correct amount, and with the right damage type :p

The drawback of this way of doing things is that if you use an actual ability, based on Acid bomb on your map - it may malfunction when a unit, affected by it is attacked by the unit with triggered attack xP
But there isn't a problem if you don't use "Acid Bomb" based abilities on your map... for purposes different than triggering missles that is.
 
Level 11
Joined
Jan 23, 2015
Messages
788
Well, you can check out my Custom Multishot, tho I don't know if you will understand anything, as it's quite long xP
Basically I use a dummy unit, which casts a spell, based on Acid Bomb, with a custom buff. I save a struct (holding data about the damage dealt, damage dealer, damage type, attack type, etc) inside a hashtable with parent key = the dummy's handle id.
Then I create another event - when a unit takes damage, with condition "The unit has my custom buff".
If the unit does have my custom buff - I remove the buff, load the struct from the hashtable, and make my unit damage its target for the correct amount, and with the right damage type :p

The drawback of this way of doing things is that if you use an actual ability, based on Acid bomb on your map - it may malfunction when a unit, affected by it is attacked by the unit with triggered attack xP
But there isn't a problem if you don't use "Acid Bomb" based abilities on your map... for purposes different than triggering missles that is.
I don't see how this helps detect when the unit throws the projectile. 0_0
 
Level 13
Joined
Jan 2, 2016
Messages
978
I don't see how this helps detect when the unit throws the projectile. 0_0
It doesn't help detect the unit launching the missle, but it helps you trigger the damage properly :p
I suppose you could just use my Multishot to spawn the missile (set targets allowed to 1).
I have a little update on it, which I haven't uploaded yet, but it's quite minor for me to bother with it at the moment.

You only need to write one row of Custom Script to trigger the missle, and "Custom Multishot" will handle everything else. You can write whatever else you want to happen upon launching the missle
 

Rui

Rui

Level 41
Joined
Jan 7, 2005
Messages
7,551
This may be another area in which direct memory access may come in handy. By knowing the unit type, you can access the Combat - Attack Backswing fields and stuff. Use the generic event "a unit is attacked". The attacker's projectile spawns in that instant PLUS some of those fields. That, as far as I know, is what influences the time it takes from the moment the unit starts its attack animation to the instant of the projectile's actual spawn. The alternative is having it all in a hashtable for each unit whose attacks you'd like to monitor.

I've been away for long, so if I could be losing it. The other guys helping have more insight into this.
 
Level 13
Joined
Jan 2, 2016
Messages
978
This may be another area in which direct memory access may come in handy. By knowing the unit type, you can access the Combat - Attack Backswing fields and stuff. Use the generic event "a unit is attacked". The attacker's projectile spawns in that instant PLUS some of those fields. That, as far as I know, is what influences the time it takes from the moment the unit starts its attack animation to the instant of the projectile's actual spawn. The alternative is having it all in a hashtable for each unit whose attacks you'd like to monitor.

I've been away for long, so if I could be losing it. The other guys helping have more insight into this.
Yeah, I had a littel "system", which was starting a timer upon "a unit is attacked" event. The timer had duration, equal to the unit's damage point.
It was working pretty well, but it had one HUGE drawback: I couldn't make it work with attack speed alterating buffs/auras.
It would've been working correctly only when you don't use any attack speed changing skills/items on your map, which can be dull.
 
  • Like
Reactions: Rui
Level 13
Joined
Jan 2, 2016
Messages
978
I think I could come up with some algorithm, that can fix the delay, but getting the unit's attack speed modification is the hard part...
Perhaps I could manually track if the unit has items, that change attack speed, and then check if the unit has any of the buffs, which increase its attack speed, but that would be WAY too bothersome to write... And let's not forget people would need to manually add each custom item/ability to the list for the trigger to detect them...
 
Status
Not open for further replies.
Top