HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help with special effects and triggers.

02-14-2004, 06:01 AM#1
Prophecy
Currently I have a trigger that activates when the player types a chat message containing the trigger activation word. Once this trigger is active it creates a lot of special effects on the player's hero's origin. I have another trigger that turns those special effects off after a certain amount of time.

Or at least that's what my second trigger is supposed to do. Instead my second trigger destroys only part of the special effects on the hero. I'm left with "TownBurningFireEmitterBlue" and few other special effects still attachtted to the unit. I can't seem to find a way to get rid of those effects once they are active. I really want them gone, it looks stupid for the unit to finish the map with "TownBurningFireEmitterBlue" surrounding him everywhere he goes.

Is there a destroy all special effects on a unit command i'm not aware of?
02-14-2004, 02:24 PM#2
DaKaN
First of all please do not post questions in the repository.

2nd:
Every special effect you create, you must store into a variable (preferably an array) Immediately after creating it so you can reference it later to destroy it.

In the destroy trigger, then you need to destroy every special effect you stored in the variable.
02-14-2004, 04:01 PM#3
MysticGeneral
Yeah, like Dakan said, set the special effect as a variable. But, make it an array as well. So in order to destroy all the special effects, there would be a trigger looking like:

For Each Integer A from 1 to X (Where x is the size of the array)
Destroy SpecialEffect_SFXA[Integer A]

That would remove all special effects that you set as SpecialEffect_SFXA[#]
02-14-2004, 05:39 PM#4
Prophecy
Thanks for the help, but I've never used variables up till now, is there a tutorial dealing with how to set special effects as variables and arrays like you've mentioned? Is the array number the number of special effects in the variable?

I have this currently, would this set the FX?
Quote:
Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
Loop - Actions
Special Effect - Create a special effect attached to the origin of Saiyan 0000 <gen> using Abilities\Spells\Other\ImmolationRed\ImmolationREDTarget.mdl
Set SSJ5[((Integer A) + 1)] = (Last created special effect)
Special Effect - Create a special effect attached to the origin of Saiyan 0000 <gen> using Abilities\Spells\Items\SpellShieldAmulet\SpellShieldCaster.mdl
Set SSJ5[((Integer A) + 2)] = (Last created special effect)
02-14-2004, 08:33 PM#5
MysticGeneral
Did you type that out? I can't read it. Do this -- Click on the trigger's title name. Then right click it --> Copy as Text.
02-14-2004, 08:42 PM#6
Vexorian
BTW, certain effects can be destroyed just after you create them, like

Create Special effect at ...
Destroy (lastcreated special effect)
02-14-2004, 11:08 PM#7
Prophecy
Quote:
Originally posted by Lord Vexorian
BTW, certain effects can be destroyed just after you create them, like

Create Special effect at ...
Destroy (lastcreated special effect)



Well I wanted the unit to be able to have all the effects turned on and off at the same time. Hopefully he could walk around for a limited amout of time then have the effect turn off. I have the timer trigger to turn the effects off worked out.


The destroy trigger looks like this:

For each (Integer A) from 1 to 11, do (Special Effect - Destroy SSJ5[11])

what is the last eleven supposed to be?



MysticGeneral I'll try, here it is

Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
Loop - Actions

Special Effect - Create a special effect attached to the origin of Saiyan 0000 <gen> using Abilities\Spells\Other\ImmolationRed\ImmolationREDTarget.mdl
Set SSJ5[((Integer A) + 1)] = (Last created special effect)

Special Effect - Create a special effect attached to the origin of Saiyan 0000 <gen> using Abilities\Spells\Items\SpellShieldAmulet\SpellShieldCaster.mdl
Set SSJ5[((Integer A) + 2)] = (Last created special effect)

Special Effect - Create a special effect attached to the origin of Saiyan 0000 <gen> using Abilities\Spells\Other\Awaken\Awaken.mdl
Set SSJ5[((Integer A) + 3)] = (Last created special effect)

Special Effect - Create a special effect attached to the origin of Saiyan 0000 <gen> using Abilities\Spells\Items\AIlb\AIlbTarget.mdl
Set SSJ5[((Integer A) + 4)] = (Last created special effect)
02-15-2004, 01:33 AM#8
DaKaN
unless that unit group loop is inside a "for each integer a" loop, that interger a will not function the way you are thinking.

Also even if it did:

When the loop count is 1 it will be:
1+1
1+2
1+3 ect...

when its 2 it will be
2+1 = 3

which will erase the handle that is in the array that 1+2 put there in the first loop
02-15-2004, 02:47 AM#9
Prophecy
Quote:
Originally posted by DaKaN
unless that unit group loop is inside a "for each integer a" loop, that interger a will not function the way you are thinking.

Also even if it did:

When the loop count is 1 it will be:
1+1
1+2
1+3 ect...

when its 2 it will be
2+1 = 3

which will erase the handle that is in the array that 1+2 put there in the first loop



*sighs* No the unit group isn't inside a "for each integer A" loop. I'm completely lost. Would it be possible for you to treat me like the completely ignorant person I am and walk me through these steps so I can see what I'm doing wrong. All that I know about this editor I've learned myself through touch and go and I think I've hit a wall. I have no idea how the array number works nor the way these triggers should work. :( Any and all help would be a god send. If I ever get this thing to work you guys are certainly going to be in my thank you section of my map.
02-15-2004, 08:33 AM#10
DaKaN
if you are going to apply these effects to every unit player 1 owns, you are best off using a jass and sub functions with a local variable. Now i know you will not know how to do this, so the best thing to do is just PM me and link me to the map, and I can fix this for you
02-15-2004, 11:30 AM#11
Alakafizz
Ill try to explain as best i can. It might be a little thorough, but just ignore the parts you already know; it's easier this way.

First of all, when you do a "Unit Group - Pick every unit", you do so in order to be able to refer to all the "Picked" units later.
In your snippet of code here, the first "Pick" you do isnt actually needed:
Code:
Unit Group - Pick every unit in (Units owned by Player 1 (Red)) and do (Actions)
Loop - Actions
Special Effect - Create a special effect attached to the origin of Saiyan 0000 <gen> using Abilities\Spells\Other\ImmolationRed\ImmolationREDTarget.mdl

The "Unit Group - Pick every unit" works like this: For each unit matching the conditions (if any; in this case it'll just be all units owned by player 1), it'll carry out the actions specified. In other words, if Red has 15 units of any kind on the map when this trigger fires, you'll repeat the "Loop - Actions" 15 times, in this case creating the same special effect on the particular unit 15 times.

Now, how do i use the "Unit Group - Pick every unit" then, you might ask?

Well, you can use it like this, for instance:
Code:
Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    Loop - Actions
        Special Effect - Create a special effect attached to the overhead of ([color=red]Picked unit[/color]) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Notice i refer to the Picked Unit instead of a particular unit, which will carry out the "Loop - Actions" on each unit matching the conditions specified in the "Pick" command. - In this case, they only need to be in (Playable map area), effectively creating the special effect on all units in the entire map.

Now, you also need to store these special effects in a variable, otherwise you have NO way of removing them ever again. For this, you need to create a Special Effects Array, lets call it "Effects", with roughly the size of the expected number of special effects - lets say 100, since you pick every unit on the map.


Ill explain real quick how an array works in case you dont know.

Think of an array as a file cabinet, with a number of drawers. Each drawer can store a specific value (a special effect, in the case of a Special Effects Array), and is numbered from 1 to n, where n is the maxinum, set by you when creating it. So, if you want to store a special effect in your special effect array, you need to specify which drawer. For this, we need an Integer variable, lets call it "i", which will be our "counter", to pinpoint the place in the array.

Look at this trigger, which will create an effect on each unit in the map, and store the effect in the Effect-array, using the interger "i" as navigator:
Code:
Create Effects
    Events
    Conditions
    Actions
        Set i = 1
        Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            Loop - Actions
                Special Effect - Create a special effect attached to the overhead of (Picked unit) using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
                Set Effects[i] = (Last created special effect)
                Set i = (i + 1)
        

This will put the first created effect in drawer 1 of the array, the next effect in drawer 2, and so forth. This is accomplished by adding 1 to the integer i after the effect is created on one unit, and then assigning the effect to Effects[i].

[notice, you ONLY put the set i = 1 at the beginning of the trigger, and before any loops that use it. This is done to reset the counter (i) to 1 every time the trigger runs, otherwise "i" would have a value other than 1 if the trigger runs again, and the trigger that destroys the effects would be screwed]

Now, to destroy the effects again:
Code:
Destroy Effects
    Events
    Conditions
    Actions
        For each (Integer A) from 1 to i, do (Actions)
            Loop - Actions
                Special Effect - Destroy Effects[(Integer A)]
Remember, "i" will be the number of special effects, since i added 1 after each created effect. What i do here, is start a loop from 1 to i, which thus will include all the used drawers in the Effects-array, and destroy them using the "For Loop - Integer A". Remember that a For loop just creates an integer variable called Integer A, which can be used to refer to actions inside the loop.

Breaking it down: First time the loop runs, the value of "For Loop Integer A" is 1. Thus it destroys the special effect at Effects[1] - "clears" drawer no. 1 in the array.
Next time the loop runs, the value of "For Loop Integer A" is 2, destroying Effects[2] - clearing drawer no# 2 in the array. This continues till all the effects in Effects[] are cleared (till "For Loop Integer A" = i).

If you dont want to use "Unit Group - Pick every unit" to add effects (if it's a specific unit you need to add a sfx to), the procedure is the same:
1) create the effect on the unit
2) add the effect to Effects[i]
3) set i = i + 1

Um, yeah. Hope this helps, otherwise feel free to reply again or check out the turorial sections.
02-15-2004, 11:07 PM#12
Prophecy
Okay, I finally got my trigger to work correctly. :ggani: Thanks to everyone in this thread that helped.