HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Why does this only work for one unit?

08-22-2004, 04:42 PM#1
Reaprojects
I have created this chunk of garbage in hopes to make a spell that is triggered through a dummy spell (Halo(Trigger)) and that creates for every unit in a range from the casting hero (500 range) a dummy caster (Halo(Caster) which casts inner fire on the picked units. For some reason it only casts it on one unit.

Code:
 Halo
 	Events
 		Unit - A unit Starts the effect of an ability
 	Conditions
 		(Ability being cast) Equal to Halo (Trigger)
 	Actions
 		Unit Group - Pick every unit in (Units within 500.00 of (Position of (Casting unit))) and do (Actions)
 			Loop - Actions
 			    Unit - Create 1 Halo (Caster) for (Owner of (Casting unit)) at (Position of (Picked unit)) facing Default building facing degrees
 			    Unit Group - Add (Last created unit) to halo_casters
 			    Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
 		Wait 1.00 seconds
 		For each (Integer A) from 1 to (Number of units in halo_casters), do (Actions)
 			Loop - Actions
 			    Unit - Remove (Random unit from halo_casters) from the game
 		Unit Group - Remove all units from halo_casters
 

I can't figure out why.
08-22-2004, 04:57 PM#2
iNfraNe
Quote:
Originally Posted by Reaprojects
I have created this chunk of garbage in hopes to make a spell that is triggered through a dummy spell (Halo(Trigger)) and that creates for every unit in a range from the casting hero (500 range) a dummy caster (Halo(Caster) which casts inner fire on the picked units. For some reason it only casts it on one unit.

Code:
 Halo
 	Events
 		Unit - A unit Starts the effect of an ability
 	Conditions
 		(Ability being cast) Equal to Halo (Trigger)
 	Actions
 		Unit Group - Pick every unit in (Units within 500.00 of (Position of (Casting unit))) and do (Actions)
 			Loop - Actions
 			    Unit - Create 1 Halo (Caster) for (Owner of (Casting unit)) at (Position of (Picked unit)) facing Default building facing degrees
 			    Unit Group - Add (Last created unit) to halo_casters
 			    Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
 		Wait 1.00 seconds
 		For each (Integer A) from 1 to (Number of units in halo_casters), do (Actions)
 			Loop - Actions
 			    Unit - Remove (Random unit from halo_casters) from the game
 		Unit Group - Remove all units from halo_casters
 

I can't figure out why.
I dont know why it only works on one unit, but for the last part, that for loop, will probably not remove all units cause the units stay in the unit group even if it is removed from the game (correct me if im wrong)

Edit: Maybe if u split the order and the creation from eachother, if will work...
08-22-2004, 05:17 PM#3
Anitarf
I don't see why this doesn't work, so what I'm suggesting you to change is just some random thing that I do differently and it works for me, I can't know if that's causing the problem, in fact, I don't think it does, but if you don't know what to do, you can try this as well. Instead of adding the casters to a unit group and then removing them, give each individual caster an expiration timer ("unit - add expiration timer") of about two seconds. That way, they will remove themselves after a while, no need for you to do it.

Oh, and another thing, your trigger will create casters for dead units and enemy units as well, so instead of "pick all units in range", use "pick all units in range matching condition" and use two conditions (together in an "and" condition): one that checks if matching unit is alive, and one that checks if it belongs to an ally of the owner of casting unit.
08-22-2004, 06:17 PM#4
Dalten
I think it's because you have a wait 1.0 second which is erasing the unit group variable.

I could be wrong but try it without the wait.
08-22-2004, 07:56 PM#5
Azhag
Dalten is right, never ever put a wait command in a loop action.
08-22-2004, 08:09 PM#6
Reaprojects
The wait is not in the loop. Please note the indentation. It is between the the loop in which the dummy unit is supposed to cast inner fire on all the units in the region around the main caster and the loop which removes all those dummy casters to clean up.
08-22-2004, 08:16 PM#7
Azhag
Code:
     Events
 		Unit - A unit Starts the effect of an ability
 	Conditions
 		(Ability being cast) Equal to Halo (Trigger)
 	Actions
 		Unit Group - Pick every unit in (Units within 500.00 of (Position of (Casting unit))) and do (Actions)
 			Loop - Actions
 			    Unit - Create 1 Halo (Caster) for (Owner of (Casting unit)) at (Position of (Picked unit)) facing Default building facing degrees
 			    Unit Group - Add (Last created unit) to halo_casters
 			    Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
 		[b]Wait 1.00 seconds[/b]
 		[b]For each (Integer A) from 1 to (Number of units in halo_casters), do (Actions)[/b]
 			[b]Loop - Actions[/b]
 			    [b]Unit - Remove (Random unit from halo_casters) from the game
 		Unit Group - Remove all units from halo_casters[/b]

I am not going to argue with you about this, but from my past experience I have learned that a wait command connot be anywhere near a loop action. I have pointed out what the wait command is screwing up in bold. Please just try removing the wait command and test the map and see if it works. If it doesn't work I will take back my comment, and you can get advice from someone else.
08-22-2004, 09:36 PM#8
Vexorian
Quote:
Originally Posted by Azhag
I am not going to argue with you about this, but from my past experience I have learned that a wait command connot be anywhere near a loop action. I have pointed out what the wait command is screwing up in bold. Please just try removing the wait command and test the map and see if it works. If it doesn't work I will take back my comment, and you can get advice from someone else.
that isn't true at all.

And for the problem, instead of adding them to a group you can just add them an expiration timer of 1 second after creating the casters

Code:
Events
 		Unit - A unit Starts the effect of an ability
 	Conditions
 		(Ability being cast) Equal to Halo (Trigger)
 	Actions
 		Unit Group - Pick every unit in (Units within 500.00 of (Position of (Casting unit))) and do (Actions)
 			Loop - Actions
 			    Unit - Create 1 Halo (Caster) for (Owner of (Casting unit)) at (Position of (Picked unit)) facing Default building facing degrees
 			    Unit - Order (Last created unit) to Human Priest - Inner Fire (Picked unit)
                                                   Unit - Add An expiration timer of 1 second to last created unit
08-23-2004, 01:10 AM#9
iNfraNe
Quote:
Originally Posted by Azhag
Dalten is right, never ever put a wait command in a loop action.
U can actually use in inside a for loop, just not in pick every loops. But as said, its not the problem here