HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Move everyunit Question

07-24-2008, 02:03 AM#1
samsunglova
First off I want to thank anyone and everyone who can help me

Okay but... I will have 2 regions in my map where each of them will have 50 units...

How exactly would I be able to pick out each unit of those 50 and tell each one to go to a different point in a region (the same region that their created in BTW)

Basically pick every unit in region and issue order move to a random point in region... that will tell all 50 to go to that same random point... how would I make it tell each and every single one in the region to go to a random spot
07-24-2008, 03:49 PM#2
samsunglova
Does the question not make sense?
07-25-2008, 01:26 PM#3
samsunglova
bump
07-25-2008, 01:39 PM#4
TriangleFourChange
Sorry about the slow response.

Unit Group- Pick All Units in (Region)
Order (Picked Unit) To Move To (Random Point within (Region))

Repeat this for the other region. Units will seem to cluster in the middle. Move to can also be replaced by Attack To, depending on your situation.

Also, do not forget to apply anti-memory leak methods, if you use them.
07-25-2008, 01:41 PM#5
Tide-Arc Ephemera
Ok, you'd need a point variable and then you'd have to set it to a random point in the region, pick all the units in the region and then order them to move to the position of the point variable.

I can't access WE at the moment, so I hope someone else comes and could post the trigger.

EDIT!
Fucking when I'm typing...

@ Triangle, that'd send them everywhere. I think he mentioned wanting them to go to the same point.
07-25-2008, 02:46 PM#6
Gorman
Youll need to do something like:

"Pick every unit in (Region) and do:
Set Point = Random point in (Region)
Order Picked unit to move to Point"

I think that should do it, if not use:

"Pick every unit in (Region) and add them to (Group)
For every integer from 0 to (Number of units in (Group)) do:
Remove picked unit from Group
Order picked unit to move to random point in (Region)"

That should do the trick.

EDIT:
@ tide, he wants them to go to differnet places...
07-25-2008, 06:30 PM#7
samsunglova
thank you so much gorman that's what i needed so with 1 trigger that'll tell all the units in that specific region to go to a random spot for each one of them

EDIT: oh and btw

how do i fix memory leaks, I actually DON"T know (or is the whole ((Set Point = Random point in (Region) then Order Picked unit to move to Point)) the anti memory leak?)
07-25-2008, 08:19 PM#8
Ammorth
Quote:
Originally Posted by samsunglova
Basically pick every unit in region and issue order move to a random point in region... that will tell all 50 to go to that same random point... how would I make it tell each and every single one in the region to go to a random spot

Quote:
Originally Posted by samsunglova
thank you so much gorman that's what i needed so with 1 trigger that'll tell all the units in that specific region to go to a random spot for each one of them

For future reference, make sure you word your question exactly how you want it. People won't be as confused about what you want will be able to help you quickly.
07-26-2008, 12:13 AM#9
Tide-Arc Ephemera
Quote:
Originally Posted by samsunglova
how do i fix memory leaks, I actually DON"T know (or is the whole ((Set Point = Random point in (Region) then Order Picked unit to move to Point)) the anti memory leak?)

To fix memory leaks of point's fashion, you need to do set the point to a variable, then use the custom script command and enter.

Trigger:
Trigger
Events
Conditions
Collapse Actions
----- This is how to deal with point leaks (using global points)
Set YourPoint = Whatever you want...
Custom Script: call RemoveLocation(udg_YourPoint)
----- You do the udg_(insert the name of your variable here)
----- e.g if it was Random, call RemoveLocation(udg_Random)

----- This is how to deal with unit group leaks (using global unit groups)
Set YourGroup = Whatever you want to mess with...
----- Do a "Pick all units in group" thing, referring to the set up group
Custom Script: call DestroyGroup(udg_YourGroup)
----- Again, it's just call DestroyGroup(udg_[your variable here])

I don't have access to WE, but that's pretty much how it's done. Avoiding memory leaks just requires to set a point before and then referring only to that point, then removing it. Likewise with unit groups, set your unit group and then pick from it.

If this doesn't make any sense, mayhaps this will make more.
07-26-2008, 02:54 AM#10
Gorman
Quote:
Originally Posted by Ammorth
For future reference, make sure you word your question exactly how you want it. People won't be as confused about what you want will be able to help you quickly.

The question makes sense.

Quote:
Basically pick every unit in region and issue order move to a random point in region... that will tell all 50 to go to that same random point... how would I make it tell each and every single one in the region to go to a random spot
Hes saying he tryed it, he grouped them and ordered them to move to random point ("Basically pick every unit in region and issue order move to a random point in region... that will tell all 50 to go to that same random point"), but then he asks "HOW would I make it tell each and every single one in the region to go to a random spot"

Its not really a hard question to understand, sure he missed out a few words but its still good.
I think Tide has a habbit of not fully reading questions (or so it seems)
07-26-2008, 02:59 AM#11
samsunglova
thank you tide but i wouldn't Custom Script: call RemoveLocation(udg_YourPoint) until i was done using it?
07-26-2008, 10:24 PM#12
samsunglova
Got it to work :)
07-27-2008, 12:00 AM#13
Ammorth
You don't need the "For each Integer A" if you are using a unit group.

Trigger:
Actions
Collapse Unit Group - Pick every unit in (Units in (Region 004 <gen>) owned by Player 12 (Brown)) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Current order of (Picked unit)) Equal to (Order(<Empty String>))
Collapse Then - Actions
Unit - Order (Picked unit) to Move To (Random point in (Region 004 <gen>))
Else - Actions

"<Empty String" is actually "" (make the filed blank and hit enter). A unit has no order when it is "stopped"

If you get that to work, I would then remove the leaks. Create a new variable called "TempPoint". The type will be a point variable (not array). Then, you want to set the random point to the TempPoint variable, order the unit to move to the TempPoint and then remove the TempPoint to clean the leak. Also, add the custom script line in front of the unit group action to make sure the game removes the group once it is done (fixes another leak).

Trigger:
Actions
CustomScript: set bj_wantDestroyGroup = true
Collapse Unit Group - Pick every unit in (Units in (Region 004 <gen>) owned by Player 12 (Brown)) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Current order of (Picked unit)) Equal to (Order(<Empty String>))
Collapse Then - Actions
Set TempPoint = (Random point in (Region 004 <gen>))
Unit - Order (Picked unit) to Move To TempPoint
Custom script: call RemoveLocation(udg_TempPoint)
Else - Actions
07-27-2008, 12:16 AM#14
samsunglova
If I don't use for each integer A it'll send all 50 to the same random point.

So with using what you just said it should look like this?

Trigger:
Move
Collapse Events
Time - Every 0.01 seconds of game time
Conditions
Collapse Actions
For each (Integer A) from 1 to (Number of units in (Units in Region 004 <gen> owned by Player 12 (Brown))), do (Unit Group - Pick every unit in (Units in Region 004 <gen> owned by Player 12 (Brown)) and do (If ((Current order of (Picked unit)) Equal to (Order(<Empty String>))) then do (Unit - Order (Picked unit) to Move To (Random point in Region 004 <gen>)) else do (Do nothing
Custom script: call RemoveLocation(udg_Random)
Trigger:
Create Units Level One
Collapse Events
Time - Elapsed game time is 0.01 seconds
Conditions
Collapse Actions
CustomScript: set bj_wantDestroyGroup = true
Unit - Create 50 Slow Pecker for Player 12 (Brown) at (Center of Region 004 <gen>) facing Default building facing degrees
For each (Integer A) from 1 to (Number of units in (Units in Region 004 <gen> owned by Player 12 (Brown))), do (Unit Group - Pick every unit in (Units in Region 004 <gen> owned by Player 12 (Brown)) and do (Unit - Order (Picked unit) to Move To (Random point in Region 004 <gen>)))
07-27-2008, 07:51 AM#15
Ammorth
Quote:
Originally Posted by samsunglova
If I don't use for each integer A it'll send all 50 to the same random point.

No, actually it wont. The reason is that Pick Every Unit in Group does the actions separately for each unit in the group. This makes the random point change as it always picks a new random point for each unit. If you all wanted all units to move to the same random point, you would have to set a point variable to the random point and then do the Pick Ever Unit in Group to that point.

Are you using The Frozen Throne, or Reign of Chaos? If you are using TFT, I would highly recommend using the multiple actions version of Pick Every Unit in Group, as to clear the point leak created.