HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Specific Unit Event - Takes Damage

06-06-2004, 04:50 AM#1
YellowSubmarine
I need this event as a part of a custom spell. The problem? I can't make the Event be a Unit variable taking damage. The only units that I can define are those already on the map that I can click to select.

Is there a way of making the GUI select a Unit variable I've defined? If not, is there a JASS workaround?
06-06-2004, 06:35 AM#2
Scyze
Quote:
Originally Posted by YellowSubmarine
I need this event as a part of a custom spell. The problem? I can't make the Event be a Unit variable taking damage. The only units that I can define are those already on the map that I can click to select.

Is there a way of making the GUI select a Unit variable I've defined? If not, is there a JASS workaround?

You could use: Unit - Generic Unit Event, with When Unit is Attacked, and see which unit is attacked and if your looking for a certain amount of health, check it's health also. I'm assuming this is a passive skill, so it will probably work.
06-06-2004, 09:17 AM#3
Anitarf
The only way to use a variable with a specific unit event is to create a new event with that variable ("trigger - add new event"). Of course, that event will then stay there, even if the variable ever changes.

That does not make the whole thing impossible, you could add a new event whenever the variable changes, and have a condition in that trigger that would make it work only if the triggering unit was equal to the variable (so that you would neutralise all the events you added previously). You would also need a unit-group variable where you would store all the units that were already added to the events, so you wouldn't be able to add a same unit twice.

Of course, that way, you could accumulate quite a bit of events in that trigger, causing it to run often/take up memory. How much lag would that cause? I have no idea, experiment. The specific unit events are supposed to be very efficient, I guess, so even with the variable changing a lot it might not be a problem. You have to test it to find out.
06-06-2004, 01:10 PM#4
linkmaster23
Your best bet is just to do A unit is attacked. Then in the variable set its health to a variable. Then wait about .50-1.50 seconds. And then compare its current health with its old health. Then do what you want to do from there. Make sure you put a If/Then/Else after it saying IF the unit even took dmg. Then do what you want. Otherwise, just put one of those nifty skip remaining actions.
06-06-2004, 09:06 PM#5
YellowSubmarine
These methods are still rather iffy. What if he took damage from an AoE spell? Spells that target him specifically could be done through Target Unit of Ability Being Cast, but there's not much for area of effect.

Anitar: I'll experiment with that soon. Interesting thought.
06-07-2004, 10:30 AM#6
Kolibri
If you were to use JASS you could destroy and create triggers as needed with the Specific Unit -> Unit takes Damage Event. You may want to take a look at it.