HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Killing units with a delay depending on distance from killer?

06-30-2004, 09:26 AM#1
GaDDeN
Ok im making a quite complicated trigger ability, but dont wanna tell you about what it really does as many noobs would start copying it. Ok basically i want so when a hero uses the skill, all units of a special type (lets say footman) would die. You cannot choose which unit, its preset that FOOTMANs would die. Now thats not a prob at all, im not noob, but here's the problem:

The units would wait a time depending on the distance from the caster, which increase each level. The level increase is not a problem, but i need to make like this:
Code:
        Unit Group - Pick every unit in (Units of type Footman) and do (Actions)
            Loop - Actions
                        Wait ((Distance between (Position of (Picked unit)) and (Position of (Random unit from (Units of type Engineers)))) / 1000.00)

Now the problem with THIS that the trigger will wait for the first unit to explode, then take the next unit and wait once the first has died etc. I need all picked units to run their trigger part at the same time. I started messing with something like this:

Picking the closest unit first, then saving his range to the engineer in a variable. Then you wait the distance, and then kill him. Then you take the second unit from the engineer, and wait the DIFFERENCE between the saved range and his range from the engineer and then save the new range, kill this unit. Then take 3rd and 4th and 5th and everybody and do the same. The problem is that i would make the trigger a bit to complicated this way. So anybody know a simple way? I can do it, but it wud cause lag and take alot of time that way...
06-30-2004, 09:40 AM#2
Anitarf
You could try killing footmen in groups: first all in 100 range, then all in 200 range, etc. It's faster than each unit individualy, but not as accurate: as always, the more intervals you have, the better it looks, but it also requires more processing power.
06-30-2004, 11:39 AM#3
AIAndy
There are 2 ways I can think of to do that.
One is to start a new timer for each unit with the time that unit needs to be delayed and tag the timer with the corresponding unit using the gamecache.
The second (and likely easier for someone without JASS knowledge but less accurate) is to create a new trigger without events for each unit. Via globals you pass the unit to that trigger and execute it. The triggers should store the unit in a local variable. Then each trigger can wait independantly.
06-30-2004, 02:31 PM#4
th15
Quite simple really.

Write all the actions you want to do to the footmen in a separate trigger (including the wait action).

Then, in the pick unit loop, just run the actual trigger for picked unit. Unit references will carry over (so you would write the action trigger as if the actions were part of your loop)
06-30-2004, 04:19 PM#5
GaDDeN
Lol so simple... and i didnt think of it! Gj (rep added)