HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Abilty question

12-05-2003, 10:30 PM#1
weaaddar
With triggers how does one get the target of the attacking ability?

I'm sure it's been asked but I've no time right now.
12-05-2003, 10:47 PM#2
Bulletcatcher
I *hope* this is what you mean... Or do you mean something else by 'attacking ability'?

This is the easy version, which can be used when two different units will never use the ability at the same time.

Trigger A:
Code:
Events: 
An unit is issued an order targetting an object.

Conditions:
Unit Type of (Ordered unit) equal to (The unit type with the ability.)
Issued order equal to (The orderstring of the ability.)

Actions:
Set YourAbilityTarget = Target unit of issued order
Trigger B:
Code:
Events:
An unit begins the effect of an ability

Condition:
Ability Cast equal to (Your Ability)

Actions:
Do whatever you want, using 'YourAbilityTarget' for the target of the spell.

If the spell is used by many different units, it gets more complicated: Myself, I use a solution involving custom unit variables.
12-06-2003, 12:24 AM#3
weaaddar
Thanks.
Are you positive I need both triggers? Thats a bit of a bummer.

By the way, WORTHLESS POSTS CAN BE A REASON TO GET BANNED LINKMASTER23

Err sorry hairball.
12-06-2003, 01:22 AM#4
Bulletcatcher
I hear one of the modified world editors might have a way to do it with one trigger, the one that isn't UMSWE... Can't remember the name right now.

Anyway, without that, there is simply no way to catch the target when the spell is cast, so it has to be done earlier.

Of course, you *could* use a range check and activate the trigger as soon as the order is given, but a player with quick fingers would probably be able to abuse it to cast spells without cooldown or mana cost... Also, you'd have to issue move orders and all sorts of things when the target is out of range.
12-06-2003, 03:06 AM#5
Garu
A quick thought. I already have a ton of variables tied to every unit with arrays, so what if I added a generalized one for spell target? They way I'm thinking, it would be a sort of makeshift "Event Response- Target of Spell." It would be set up like this:

E: Unit is issued order targetting a unit
A: Set SpellTarget[TriggeringUnit ID]=Target of issued order

E: Unit uses an ability
C: Ability being cast is equal to ability X
A: (the effects of the spell, using SpellTarget[ID])


Basically, since the target will always be the last unit targetted with an order, the array variable should always accurately give you the spell target. Change the variable to a string, throw in a few conversions, one more trigger and the target array can be a point too. Can anyone forsee any problems with this method?

Sigh, how could Blizzard overlook such a useful function as the target of an ability? Boggles the mind.
12-06-2003, 03:13 AM#6
Bulletcatcher
I can imagine it working perfectly if one uses SpellTarget[ID] only at the beginning of the 'uses ability' trigger: For example...

Events:
Unit starts the effect of an ability
Conditions:
Ability being cast is equal to ability X
Actions:
Set AbilityXTarget[ID] = SpellTarget[ID]
(The effects of the spell, using AbilityXTarget[ID])


This would prevent abilities with waits in them from being retargetted in the middle of casting. There is probably a better way to do it using local variables, buuut I'm not going to do that much thinking right now.
12-06-2003, 03:53 AM#7
Garu
Though I can imagine some cool potential for retargettable spells, that's clearly a problem most of the time. I think I understand what you're suggesting, but there's still the problem that if the duration of the spell is longer than the cooldown, retartgetting can still occur. The only way I can think to get around this is to set up an extra couple complementary variables in addition to SpellTarget[ID]. SpellTarget[ID] is always the last thing targetted by a unit's order, keep in mind. Lets call our new variable arrays TempTargetA[ID], and TempTargetB[ID]. When the spell is cast, it checks to see if TempTargetA[ID] is in use. If not, the trigger sets TempTargetA[ID] equal to SpellTarget[ID] and continues running the spell using TempTargetA[ID] to refer to the target of the spell. When the spells run its course, the trigger clears TempTargetA[ID] for later use. Conversely, if the spell runs and TempTargetA[ID] is still in use (meaning the previous instance of the spell hasn't run its course), then it uses TempTargetB[ID] instead. Depending on how many times the spell could potentially be running at the same time, we could add further "TempTargets" as needed. Now that I think about it though, it there would have to be a TempTarget for EVERY potential instance of EVERY spell the unit could cast, if I were to use TempTarget for the unit's other abilitites. This is a very cumbersome technique, though. Is there an easier way to do this? I'd hate to do all this work if it's unnecessary.


On a side note, how many variables can I have before things start mucking up? If I have a dozen or so arrarys, all storing eight thousand or so values, will I start getting problems? Or is it really only the accessing of them that I should worry about?
12-06-2003, 05:34 AM#8
Bulletcatcher
I'm sure using a local variable for each instance of the spell would cause it to run without any problems whatsoever: There should be a local variable tutorial around here somewhere, you might want to try checking that one out.

About high variable amounts, well, I honestly have no idea.