HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Referring to Target of Casted Ability

10-18-2003, 02:32 AM#1
Bhav_88
I'm making a wonderful little ability called Plague that causes units to be infected with a disease, and any unit infected can also pass it on to nearby units, unlike disease cloud.

It starts with a spell targeting an enemy unit. However, I cannot refer to the unit that is being cast upon in the trigger. Right now, I just have it referring to the one doing the casting, so it infects him, but also all of his enemies.

How can I refer to the unit I am targeting with the ability?

-Tobar :bangH:
10-18-2003, 03:18 AM#2
Oinkerwinkle
Here is an example of a method that works for as many as you want. I wrote this for someone else a while ago.
Quote:
You'll need two variables. Type: Unit. Yes to array. Set the size to whatever you think the max number of these spells being cast at a time is. Name is target. The other variable is of type integer, not an array. Name it counter and set the initial value to 0.

Events:
A unit is issued an order target an object
Conditions:
(Unit-type of (Ordered unit)) Equal to (Elemental Mage)
(Issued order) Equal to Undead Lich - Frost Nova
Actions:
Set counter = counter + 1
If counter > TheLengthOfTheCasterArray then set counter = 1 else do nothing
Set custom value of triggering unit = counter
Set target[counter] = target of issued order

Events:
A unit finishes casting an ability
Conditions:
(Ability comparison) Ability being cast is equal to Undead Lich - Frost Nova
(Unit-type of (Triggering unit)) Equal to (Elemental Mage )
Actions:
A) Set Ice_Spiral = target[custom value of triggering unit)
A) Unit - Create 1 IceSpirals for (Owner of Triggering Unit ) at ((Position of Ice_Spiral) offset by (100.00, 20.00)) facing (Position of (Triggering unit))
A) Unit - Create 1 IceSpirals for (Owner of Elemental Mage 0072 <gen> ) at ((Position of Ice_Spiral) offset by (-100.00, -20.00)) facing (Position of (Triggering unit))
The last part there is where you can put anything you want. It can be scaling units, hiding replacing, or anything else accomplishable by a trigger, meaning just about anything imaginable. In this example, it seems to create 'Ice spirals' at the unit this was cast upon.

Here is what it's doing, in English. Two triggers are required because you can't directly reference the target of an ability. Instead, you save that target when the order is issued, in this case in the 'target' array. To save which index of the array it is in, a custom value is set to the caster. You can retrueve the custom value and therefore the refernced unit when he actually casts.
10-18-2003, 03:52 AM#3
SpectreReturns
Event Response - Targeted unit of issued Order
10-18-2003, 03:55 AM#4
Oinkerwinkle
You can't get the target like that if it's a "Unit finishes casting an ability" event or anything. Only for order issueing.
10-18-2003, 05:15 AM#5
Bhav_88
Is there a simpler way just to make it detect what unit I set the order on? I have everything figured except how to make that first part work.


NOTE: Not vital, though, as the unit that casts the plague is undead, and thus will be immune, so it could just show up on him instead of on a target.
10-18-2003, 05:34 AM#6
FF_Behemoth
I'll try to explain a bit further, but otherwise Oinkerwinker is correct.

I named my unit varible called novaTarget

E- a unit issue order targeting an object
C- (Unit-type of (Ordered unit)) Equal to () <---- insert the hero that has the spell here
C- (Issued order) Equal to (order(frostnova)) <--- now the frostnova would be the order string if you base your spell off frostnova. to find the order string of the ability you based on, go into the ability editor and click on your spell, near the middle there will be a field that says ordersting use. that is the order string for that particilar spell
A- set novaTarget = target unit of issued order

E- a unit starts the effect of an ability
C- ability being cast equals to () <------ insert your spell here
A- create SFX on novaTarget <----- or whatever you want, since WE knows who the novaTarget is now.
10-18-2003, 05:40 AM#7
Bhav_88
I see, thanks. Use two triggers... wonder why I didn't think of that? And I like to think I'm good at triggering...
10-18-2003, 05:51 AM#8
Supra God CrK
also if you have we unlimited there is a trigger for this. coulda just used that trigger and it would be easier.