HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trigger Ability Help

02-29-2004, 05:06 PM#1
ZerG.MiLk
I'm working on an ultimate spell which each chosen hero has one of their own at start. It can be used only once every 5 or so minutes. Although Hunter0000 helped me get started, it seems that after checking what he wrote to me and what I wrote in my trigger editor, although they match, the spell does not work.

Here's what I have so far. The spell is based on Spirit Wolf:

VARIABLES:

-FX = Special Effect
-i = integer
-TempGroup = Unit group

CASTING OF THE SPELL (Spinal Tap):

EVENTS:

-A unit begins casting an ability.

CONDITIONS:

-(Ability being cast) is equal to Spinal Tap (Dark Mage)

ACTIONS:

-Wait 0.01 seconds.
-Play (triggering unit)'s attack animation.
-Unit Group - Pick every unit in (Units within 700.00 of (Position of (Triggering Unit))) and do (Unit - Add (picked unit) to TempGroup).
-For each (Integer A) from (1 to Number of Units in TempGroup), do Actions:
- Loop Actions:
-Unit Group - Pick every unit in (Random 1 units from TempGroup) and do (Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Orc\EarthQuake\EarthQuakeTarget.mdl)
-Set FX[i] = (Last created special effect)
-Set i = (i + 1)
-Unit Group - Remove (Picked unit) from TempGroup


That's the initial spell casting without every special effect, simply because I can't get it to clean up properly or cast properly to even start with the other special effects. :/

CLEAN UP (Spinal Tap CleanUp):

EVENTS:

-Time - Every 7.00 seconds of game time

CONDITIONS:

-For each (Integer A) from 1 to i, do (Actions)
-Loop - Actions
-Special Effect - Destroy FX[(Integer A)]
(end loop)
-Set i = 0

When the spell is cast, it only puts the special effect on two units. And of these two units, it only removes the special effect from one of them. I'm new with advanced clean up of custom spells and their creation. I've always done it the newbie way. :x All help is appreciated. Thanks.
02-29-2004, 05:38 PM#2
Kamux
Maby the problem is in the cleanup event. Because cleanup will start every 7 seconds, when you cast the spell on the 6th second, the cleanup will start, while the other trigger is still running.
02-29-2004, 06:28 PM#3
Anitarf
Altrough I can't say any of these could cause the problems you are describing, here's a few things I would do differently.

- Replace the "begins casting an ability" with "starts the effect of an ability"; after a unit "begins casting an ability", the trigger will run while the cast can still be interupted, not using any mana or cooldown. If you use the "starts the effect of an ability", the hero will use the mana for the spell before the trigger runs. This has otherwise nothing to do with your problems, it is just a general tip about spell-triggering.

- Switch the "triggering unit" with a "casting unit". I'm not quite sure if "triggering unit" works with spell casting, so it's more certain to use "casting unit" which is used especialy in these situations.

- As Kamux said, the cleanup spell runs every 7 seconds while your spellcast-trigger can run anytime, meaning also that it can run at the same time as the cleanup spell. This, however, does not affect your triggers, because the effect trigger has no "wait" command that would give a chance for the cleanup trigger to run in the middle of the spellcast trigger. Triggers without the "wait" command will run as a whole without any other triggers interfering, so this is not the cause of your troubles. However, the cleanup spell in it's current form would still clean up the effects 0-7 seconds after they are created, even if it worked as it should.

- You say the spell is based on spirit wolf? What spell is that, you mean feral spirit? If it is feral spirit (a summon spell) then try triggering it with the generic unit event "a unit spawns a summoned unit" and then use "summoning unit" later in the trigger to refer to the caster of the spell (or "summoned unit" to refer to the unit that is summoned).

- I had some unknown problems similar to yours in my map (sometimes some units didn't get picked), here's a summary of how it works now:


TempUnitGroup(unit group array) /use an array if you have multiple players
TempUnit(unit array) /again array is used only because I can have more heroes of the same type in my map


Set TempUnitGroup(Player number of (owner of (casting unit)))=units within 1000 of (position of (casting unit)) matching (((owner of (matching unit)) is an enemy of (owner of (casting unit)))and((matching unit is (alive)) equal to (true))
For each (integer A) from 1 to (number of units in TempUnitGroup(Player number of (owner of (casting unit)))) do (actions)
Loop - Actions:
set TempUnit(Player number of (owner of (casting unit)))= random unit from TempUnitGroup(Player number of (owner of (casting unit)))
Unit Group - Remove TempUnit(Player number of (owner of (casting unit))) from TempUnitGroup(Player number of (owner of (casting unit)))
...Now here you do what you want with the unit, create special effects the same way as you did it before, storing them in your variable as you make them...
(end loop)


Hope this works for you.
02-29-2004, 06:30 PM#4
ZerG.MiLk
Maybe, but the spell doesn't even cast correctly. It only chooses 2 units and casts them. Then it only removes the special effects from the one unit. I really am at a stand still here. :P
02-29-2004, 06:39 PM#5
Anitarf
I think I see why one effect doesn't get destroyed: when you destroy effects, you go from 1 to i. However, there is no effect under FX(i) (because you increase the i AFTER you save the last effect under FX(i)), but there is an effect under FX(0) that doesn't get destroyed by the cleanup (it goes FROM 1 to i, remember). So, a solution to the cleanup would be to switch the order of "Set FX[i] = (Last created special effect)" and "Set i = (i + 1)".

As far as "only two units get selected" is concerned, try making the trigger the way it is written above.

Also, don't make the cleanup trigger run every 7 seconds, but instead give it no events and run it from your effect making trigger by adding at the end:
-wait 7 seconds
-trigger - run "cleanup"
02-29-2004, 08:35 PM#6
ZerG.MiLk
w00t. =]

So far so good. I got it to select the units but now the clean up won't work. :P I ran clean up like you said, but it's not cleaning up the special effects now. I'll check it out and see what I can find.

BTW, all I did was switch the order of the FX(i) and Set i = (i+1) and it worked. ^^

Thanks alot for your help.

I stand corrected. It does remove the special effect, but once again for only one unit.

My thoughts were maybe because the Units are removed before the special effect is destroyed or maybe an integer problem.

Here's the screens of the triggers:

Spinal Tap:



Clean up:



If you see anything wrong, let me know. I don't see anything, but like I said, I'm fairly newb with this. :p
03-01-2004, 02:11 PM#7
SirSalute
Your last created effect only refers to the special effect created on the last picked units in the unit group.
try replacing your for loop with the following:

For each (Integer A) from 1 to (Number of units in TempUnitGroup), do (Actions)
Loop - Actions
Custom script: set udg_TempUnit=FirstOfGroup(udg_TempUnitGroup)
Special Effect - Create a special effect at (Position of TempUnit) using Abilities\Spells\Orc\EarthQuake\EarthQuakeTarget.mdl
Set i = (i + 1)
Set FX[i] = (Last created special effect)
Unit Group - Remove TempUnit from TempUnitGroup
Custom script: call DestroyGroup(udg_TempUnitGroup)
Wait 4.00 seconds
Trigger - Run Spinal Tap Cleanup <gen> (ignoring conditions)
03-02-2004, 01:04 AM#8
ZerG.MiLk
Quote:
Originally Posted by SirSalute
Your last created effect only refers to the special effect created on the last picked units in the unit group.
try replacing your for loop with the following:

For each (Integer A) from 1 to (Number of units in TempUnitGroup), do (Actions)
Loop - Actions
Custom script: set udg_TempUnit=FirstOfGroup(udg_TempUnitGroup)
Special Effect - Create a special effect at (Position of TempUnit) using Abilities\Spells\Orc\EarthQuake\EarthQuakeTarget.mdl
Set i = (i + 1)
Set FX[i] = (Last created special effect)
Unit Group - Remove TempUnit from TempUnitGroup
Custom script: call DestroyGroup(udg_TempUnitGroup)
Wait 4.00 seconds
Trigger - Run Spinal Tap Cleanup <gen> (ignoring conditions)

When you tell me to do this, you want me to add those custom scripts to what I already have there? I did that and nothing happened. It still only removes it from one of the units. This Spell is really giving me a headache. :\

I appreciate all your help in advance, but I just can't seem to solve this problem myself. So I turn to you guys for help. And you've been great so far.
03-02-2004, 09:42 AM#9
SirSalute
Quote:
Originally Posted by ZerG.MiLk
When you tell me to do this, you want me to add those custom scripts to what I already have there? I did that and nothing happened. It still only removes it from one of the units. This Spell is really giving me a headache. :\

I appreciate all your help in advance, but I just can't seem to solve this problem myself. So I turn to you guys for help. And you've been great so far.
No, you just replace the 'for loop' you did onwards with the codes i gave you.
I'll explain why yours not working as you wanted.
Pick every unit in UnitGroup and do special effect
^this will do in the action in the following step
1.pick one random unit, create a special effect
2.nx pick another unit, create special effect and so on...
Therefore, your last created effect is the special effect created on the last picked unit, and thus only one effect is destroyed.

the codes i gave you, is to set the picked unit as a local tempUnit, create a special effect on it, set the last created effect, then continue to pick new unit. Since units that are picked are being remove from the group, you won't be picking on them again.

I hope you understand. Good Luck. :>
03-02-2004, 05:05 PM#10
Anitarf
Here's your problem: You have a loop that goes from 1 to number of units in unit group (for loop integer A) and inside this loop you create a special effect for EVERY unit in the group: if you have 3 units in your group, the loop will run 3 times, and every time it will create a special effect on all 3 units, and it will always store the last effect created into your variable. This way, the cleanup will clean all 3 effects on one unit, but the other 2 units will still have 3 effects each.

To correct this, replace the:

Unit group - pick every unit in TempUnitGroup and do (special effect - create special effect...)

with the following:

set TempUnit (comment: this is a unit variable) = Random unit from TempUnitGroup
unit group - remove TempUnit from TempUnitGroup (comment: these two lines pick one unit from your group and remove it from the group as well so that no unit can get picked twice)
special effect - create a special effect at (location of (TempUnit)) using model ...

this is all. the rest of the triggers seem OK. Once you replace this, whenever the integer A loop runs, one unit is picked and one effect is created and then stored into the FX variable. The loop A runs as many times as there are units in your unit group, so all units get a effect created at their position, and all effects are stored in the FX variable array.
03-04-2004, 02:56 AM#11
ZerG.MiLk
Quote:
Originally Posted by Anitar
Here's your problem: You have a loop that goes from 1 to number of units in unit group (for loop integer A) and inside this loop you create a special effect for EVERY unit in the group: if you have 3 units in your group, the loop will run 3 times, and every time it will create a special effect on all 3 units, and it will always store the last effect created into your variable. This way, the cleanup will clean all 3 effects on one unit, but the other 2 units will still have 3 effects each.

To correct this, replace the:

Unit group - pick every unit in TempUnitGroup and do (special effect - create special effect...)

with the following:

set TempUnit (comment: this is a unit variable) = Random unit from TempUnitGroup
unit group - remove TempUnit from TempUnitGroup (comment: these two lines pick one unit from your group and remove it from the group as well so that no unit can get picked twice)
special effect - create a special effect at (location of (TempUnit)) using model ...

this is all. the rest of the triggers seem OK. Once you replace this, whenever the integer A loop runs, one unit is picked and one effect is created and then stored into the FX variable. The loop A runs as many times as there are units in your unit group, so all units get a effect created at their position, and all effects are stored in the FX variable array.


Anitar, you are amazing ^^. Thanks for all the help, I finally got it working thanks to all the advice.

Say I wanna create another effect on the same units that I just destroyed the effect on. How can I do that without reselecting units within the range of the caster? Because in the previous loop, I removed all units from TempGroup. So I'm confused. :P
03-05-2004, 01:48 AM#12
ZerG.MiLk
Say I wanna create another effect on the same units that I just destroyed the effect on. How can I do that without reselecting units within the range of the caster? Because in the previous loop, I removed all units from TempGroup. So is there a way to choose those units I just removed the effect on to make a new special effect. Or is there another way? o_O