HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

is there an action to detect the target of a spell??

07-05-2003, 10:36 PM#1
STURMguy22
i need to know if there is something that can detect if a unit is the target of an ability. Well not really that, but like If unit is casted upon, then...... something like that. Like i would want to know when a unit is targetted by a spell and is hit by the spell
07-06-2003, 01:07 AM#2
Ultramagnetic
HEre's how you do it...


e: Unit is issued an order targeting an object

c: issued order = base abtility of custom spell.


That will generate the target unit for you.

Now, if you want to trigger extra actions for a spell on the targeted unit you'll need to 'save' it in a unit variable. In my map I use a unit array variable called 'victim'. The action for that would be..


a: set variable[x] (in this case 'victim') = target unit of issued order.

Target unit of issued order is what you're lookin' for. But it's not so much just one action as it is an event response that's generated from that 'unit is issued an order targeting an object' event.

From there on out (even in other triggers) you can refer to that variable for all your target unit of issued order needs... especially when you use an array, because the index number holds that info forever.

That trigger would stand alone, and would run alongside another trigger that looks like:

e: Unit - begins casting an ability

c: Ability being cast = your custom spell.

a: whatever you want. Use your 'victim' variable here in place of 'targeted unit' in the trigger functions.


'begins casting an ability' will work just fine if your ability doesnt have a casting time of over like 1 or 2 seconds, otherwise, if it does, you'd wanna use, 'Unit finishes casting an ability'.
07-06-2003, 01:19 AM#3
angelofdeathx
I have a simillar problem but the thing is i don't know when the spell will hit the target and if the effect starts too early things will get messed up is there a way to konw when a unit is hit by a spell?
07-06-2003, 01:23 AM#4
Ultramagnetic
yeah, the event 'unit - finishes casting an ability'.


you can find out when your spell will hit in the ability editor. Look for the 'casting time' field. Whatever that is, that's how long you got.
07-06-2003, 12:51 PM#5
STURMguy22
Quote:
Originally posted by Ultramagnetic
HEre's how you do it...


e: Unit is issued an order targeting an object

c: issued order = to whatever


That will detect the target unit for you.

Now, if you want to trigger extra actions for a spell on the targeted unit you'll need to 'save' it in a unit variable. In my map I use a unit array variable called 'victim'. The action for that would be..


a: set variable[x] (in this case 'victim') = target unit of issued order.

Target unit of issued order is what you're lookin' for. But it's not so much just one action as it is an event response that's generated from that 'unit is issued an order targeting an object' event.

From there on out (even in other triggers) you can refer to that variable for all your target unit of issued order needs... especially when you use an array, because the index number holds that info forever.

That trigger would stand alone, and would run alongside another trigger that looks like:

e: Unit - begins casting an ability

c: Ability being cast = whatever

a: whatever you want. Use your 'victim' variable here.


'begins casting an ability' will work just fine if your ability doesnt have a casting time of over like 1 or 2 seconds, otherwise, if it does, you'd wanna use, 'Unit finishes casting an ability'.



ya, thats exactly what i thought of but i couldnt get it to work. Ill try to follow urs exactly. but its a custom skill, and how can i detect if an order is a custom skill? do i have to put in the custom skill name like a001 or something instead of like stop? all it looks like is that i can only do thw ones that are in the game
oh and how can i detect what level a hero skill is?
07-06-2003, 02:37 PM#6
Arche
Quote:
Originally posted by NAMguy222
ya, thats exactly what i thought of but i couldnt get it to work. Ill try to follow urs exactly. but its a custom skill, and how can i detect if an order is a custom skill? do i have to put in the custom skill name like a001 or something instead of like stop? all it looks like is that i can only do thw ones that are in the game
You just make the order of the spell the custom spell is based of. SHouldn't be a problem, it works perfectly. (Just remember - The order, not the ability code)
Quote:
oh and how can i detect what level a hero skill is?
http://www.wc3campaigns.com/forums/s...threadid=21024 read at bottom.
07-06-2003, 02:58 PM#7
Ultramagnetic
Actually you dont really need the custom code in the first trigger. Just whatever spell/ability the custom one is based off of because the target will still generate off that order string. No hero or unit can have more than one ability that uses the same order string on them at a time, so it'll always detect whatever spell the unit has that uses that string, no matter what you call it, or what the effects are.

You don't really NEED to, unless you have more than one ability based off the same spell on a different unit, but if you want to make the first trigger even more specific, you can add a Unit Comparison condition, using Unit-Type of triggering unit = whatever unit/hero has the spell..

Only the second triigger needs to specify what the actual custom ability is. And you need it so the extra actions of a spell dont trigger from halfway across the map.

This is why spell editing was so much harder before the tft we, because we didn't have these handy little 'spell is cast' events. :)

I shoulda been a little more specific in my reply though. As a matter of fact I'm gonna go edit it... The condition of the first trigger should be

issued order = base abtility of custom spell.

you should get by just fine with the two triggers I gave ya. Hope it works out.
07-06-2003, 07:34 PM#8
STURMguy22
actually i figure i dont even need to check what order it is cause only one unit is going to have that and there will be only one type of that unit. So thx
07-06-2003, 07:37 PM#9
STURMguy22
Quote:
Originally posted by Arche
You just make the order of the spell the custom spell is based of. SHouldn't be a problem, it works perfectly. (Just remember - The order, not the ability code)
http://www.wc3campaigns.com/forums/s...threadid=21024 read at bottom.


id like to use thiws just in case. soooo, if my spell were to be called woopa or something. I would replace "stop" with "woopa" (without quotes). so no "A004"?
07-06-2003, 07:59 PM#10
Arche
Quote:
Originally posted by NAMguy222
id like to use thiws just in case. soooo, if my spell were to be called woopa or something. I would replace "stop" with "woopa" (without quotes). so no "A004"?


No, you can't have custom orders. But let's say you base it on hex, just replace the stop with "hex" (w/o quotes)

You can change the order to some other spell (not custom), but I never got that to work.
07-06-2003, 08:18 PM#11
STURMguy22
but if my spell was based off of the one i entered as the order, would it still recognize it (even if a lot are based off of it would it recognize all of them?)
07-06-2003, 08:33 PM#12
STURMguy22
ok here, ive attached the map with the shrink spell that im trying to make and a cool giant strength spell that i made. Please look at it and tell me what the problems are with my shrinking spell and maybe some ways to fix the condition problem i have with the shrink target trigger.
07-06-2003, 08:34 PM#13
Ultramagnetic
Quote:
Originally posted by NAMguy222
but if my spell was based off of the one i entered as the order, would it still recognize it (even if a lot are based off of it would it recognize all of them?)


yes because even though a spell is a custom spell it still needs to be based of a spell that's already in the game. And the original spells have specific order strings that trigger them... Like if you based a spell off blizzard and called it rain of poo and made it rain poo instead of ice shards both spells are still essentially blizzard, and use the same 'blizzard' spell code which is triggered by the 'blzzard' order string in the game engine, one of them just has different art/stats/etc, dig?

You could have 40 different spells all based off blizzard, and they'd all use the blizz order string to activate. Withouth that order string the game engine wont know what spell code to run when the spell is trigger.

What you need to do to make sure your trigger recognizes the right one though, and to do that you need to use that second trigger I gave you with the 'ability being cast = whatever'... That condition will use your custom spell ID# for you. And that's what you need to tell it apart from the rest of the spells that use the 'blizzard' order string to activate.

Just like arche said there's no such thing as a custom order string in Warcraft3.

All your custom spell id # does is tell the code how to act. It's the order string that makes it activate in the first place.
07-06-2003, 08:42 PM#14
STURMguy22
ok thx, that clears it all up for me. Well problem is. Say i have multiple units with with a spell that is based from storm bolt. A unit comes by and casts a spell, thereby adding the unit to the variable, and give it an ability. Then 30 seconds later, i take the ability away (using the unit variable again). Well what if in that 30 seconds, another unit casts a spell on another unit and adds that unit to the group (or replaces the other... it doesnt matter same problem) so now after 30 seconds, actions happen to that unit when i dont want them to. Do u get what im saying. Is there anyway around it.

Also, how do i find out the command string for spells?
07-08-2003, 12:07 PM#15
Ultramagnetic
Quote:
Originally posted by NAMguy222
ok thx, that clears it all up for me. Well problem is. Say i have multiple units with with a spell that is based from storm bolt. A unit comes by and casts a spell, thereby adding the unit to the variable, and give it an ability. Then 30 seconds later, i take the ability away (using the unit variable again). Well what if in that 30 seconds, another unit casts a spell on another unit and adds that unit to the group (or replaces the other... it doesnt matter same problem) so now after 30 seconds, actions happen to that unit when i dont want them to. Do u get what im saying. Is there anyway around it.

I'm not too sure I follow what you're sayin' here, BUT I think what you'd wanna do is after whatever happens to the unit being cast on happens, then you'd probably want to take that unit out of whatever unit group it was put into in the first place. Then the actions wont happen to it... if that's how they get triggered.

Quote:
Also, how do i find out the command string for spells?


In the object editor, scroll down a bit. Look for a couple fields that say 'string to activate/turn on/turn off/order/etc'. In most cases you only need the main one at the bottom, but if you wanna trigger an action like say when you turn immolation off, then you'd use the deactivate string, which is something like unimmolation I think.