HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Projectile reaches unit

08-02-2004, 05:58 AM#1
R3N3G4D3
I need some way to take the exact time when the unit takes damage from the attack while knowing which unit attacked it. The problem with "a unit is attacked" is it takes the time of when the attack begins, not when it hits the target, the problem with checking when unit's hp drops is that the game doesn't know who the attacker is. I have another solution, but it requires many variables or the projectile speed to be stored somewhere else, and is more like an approximation of the time. What my current solution does is it takes the distance between the attacker and the target and divides it by projectile speed (distance/speed=time), however this requires me to store projectile speeds for all units somewhere (currently I use their mana for that, because I'm already using point-value for something else, however I suspect that I might be needing mana for something else as well), so my question is, is there a way to get the time of when the projectile actually hits the unit (I'd prefer to stay away from solutions of making a projectile be another unit). Thanks.
08-02-2004, 07:24 AM#2
Anitarf
I'm afraid there is no event or anything close to "unit is hit by a projectile"; All that remains, as always, is the hope that blizzard may add new functionality to the world editor with a future patch.
08-02-2004, 03:14 PM#3
Mythmon
heres an idea, it will require 2 triggers and 2 variables:
the first trigger will catch the attack, and tehn store the attackiing unit in a variable, it will then set a boolean variable "go" to true.
The second trigger will catch the damage, first it will make sure go is true and if not wait for it to be, then will do what ever you want and youll have the attacker in the variable you used earlier :D good luck
08-02-2004, 05:53 PM#4
R3N3G4D3
myth, a similar solution has occured to me a while ago, however there is a problem with it. Imagine if your unit attacked, and the trigger passed on the attacking unit to the next trigger which waits until the target takes damage, now before the projectile hits the target, another unit with faster projectile speed attacks the same target and hits the target first, then the projectile hit wouldnt actually be the original unit's projectile, but another unit's projectile. This can be a big problem for my map because being a tower defense it will definatelly have many units attacking same target simultaneously.

Also, I got another idea recently, but for it to work I need the "unit is attacked" to set off a trigger everytime a unit gets attacked, not just when the attack order is first issued. So I'm wondering, does "a unit is attacked" event get triggered only the first time a unit starts attacking another unit, or with every hit? If it works with every hit I could create invisible units at the same spot as normal towers and give invisible unit an ability and make the trigger cast ability every time the tower that has the same location as invisible unit attacks, and then set the ability to travel with same speed as projectile, and just check when the ability hits instead of the projectile hitting.
08-02-2004, 06:27 PM#5
Ari
For what it's worth (and possibly this is no help at all), when I needed to do something similar, I used the "unit is attacked" event and then simply checked to see if the attacker was a melee or ranged unit. If it was melee, the impact happened instantly, and if not, it happened ~.7 seconds later. In-game, to a (very) rough approximation, this is accurate, at least for non-siege units (and excluding riflemen), since (range*projectile speed) is at least vaguely close to the same number in all non-siege units.

Edit: also, I'm 99% certain that each individual attack generates its own order. At least, in my similar spell, the "is attacked" event fires at regular intervals.
08-02-2004, 08:35 PM#6
Anitarf
The attack-order event happens only when a unit is ordered to attack, while the "unit is attacked" event happens every time a unit attacks. Note: the attack event happens when the unit begins it's attack, which can afterwards be interupted by another order or stun, but the trigger still runs. This is more or less irrelevant except if you had a slowly-attacking unit with a powerfull attack-bonus, in that case players could abuse this and get the effect more often than the tower's attack speed allows.

Anyway, there is another ability, "orb of slow", which can cast any spell at the target of the attack whenever your unit attacks (you can also set a % chance that it will cast the spell on attack). This could be used to add spells to attacks without triggers, but I am not sure if the "orb of slow" ability casts things on attack or on projectile hit.

And I don't think there is a way to determine when a spell projectile such as storm bolt hits...
08-03-2004, 01:02 AM#7
R3N3G4D3
Thanks for the telling me about "unit is attacked" thing guys, also I can't really use ~.7 second thing for range units because I need precise timing and my projectiles range from speeds of 300 to 3000. As for orb of slow, I was planning to use it earlier, but I encountered a problem with it. The thing is, the orb of slow effect only fires with "missle" or "missle (splash)" attack type, and I can only use "artillery (line)" or "missle (line)" because I need the splash radius to be upgradable, and the only way to do so is to use spill distance radius from (line) effect instead of area of effect from normal splash attacks, meaning that the slow orb will not fire. So my idea now is to use a dummy spell cast by dummy unit to get the correct timing of the projectile, and then use triggers to create area of effect buff on enemies in splash zone.
08-03-2004, 01:33 AM#8
Wolf Boy
umm... isnt there an event for a unit takes damage????
08-03-2004, 05:46 PM#9
Heptameron
Quote:
Originally Posted by DEOMONOS
umm... isnt there an event for a unit takes damage????
Yeah, but as far as I know, it doesn't let you get the unit that is dealing the damage. Plus you can't put it under Generic Unit Event.
08-04-2004, 12:30 AM#10
Grater
There are two ways I know of determining when a projectile hits a target, they are both somewhat specific in the situations they can be used:
A) The frost arrow method for missiles. Take frost arrow, give it a custom buff. Make it last 0.01 seconds, then use the unit takes damage event with the condition "unit has custom buff". Now the main problem is determining the attacking player. If theres only one hero or player that can use the ability, it's all good. Or you may be able to rule out players in other ways. This (buff detect) method can also be used for other abilities like stombolt/parasite, or I suppose something like burning oil. But detecting attacking player remains a problem.

B) The plauge ward method for artillery (splash). When an upgraded meatwagon fires, it creates a "plauge ward" unit on impact, this unit has the same owner as the meatwagon, making it really easy to detect time of impact and attacking player. There are a few ways you can use plauge ward:
1) Like it currentely is, that is, give it a damage aura of some description.
2) Replace it with a unit like clockwerk goblin, that goes kaboom on timer expiration, thus you can do upgradable splash damage by changing the level of the kaboom ability using a custom Upgrade.
3) You can directely detect the plauge ward by giving it the heal ability, and heal as the default active ability. Then detect the order issued event: "healon". You need to use this roundabout method as "unit enters region" and "unit summons a unit" don't work.

Anyway, those are the only two ways I know of precisely detecting time of projectile impact. I believe your otherwise stuck with approximations.
08-04-2004, 07:27 AM#11
Anitarf
Unit takes damage is a specific unit evet. How does it fit into the concept of dynamic target selection? You would have to create an event whenever a unit was attacked, but what happened if those events multiplied too much? I am curious, because in my map, I use periodic checks every 0.04 seconds to see when the attack-based buff appers.

p.s.: I don't know about frost arrows. Maybe they changed it by now, but when I was testing it, it wouldn't accept custom buffs; I used "cold arrows" instead, they worked.
08-04-2004, 10:49 AM#12
Grater
One of the simplist ways is that when a unit is created just create a "unit takes damage" event for it, either with a new trigger (which should be destroyed on unit removal), or add to an existing trigger.

If it's ability base (ie stormbolt) you can get away with creating a temporary trigger when the ability is cast. (ie destroy it after like 5 seconds)
08-04-2004, 01:27 PM#13
tufy
How about two triggers?

One would run at "unit is attacked" and would set variable for attacker and attacked unit. The other would run at "unit takes damage", checking the attacked unit and then applying the appropriate attacker. It's basically the same thing we used in WE for target spells prior to FT.

This might need some polishing, but I think it would work.
08-04-2004, 02:20 PM#14
Mythmon
ive alread suggestteed that and R3N3G4D3 already shot it down, what if a unit starts to attack, then anohter one attacks, resetting the variable, then the first attack does damage? it has problems. you could of course use an array to reduce the chance that the varable would be overwritten but syncronizing the variables would be nasty