HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Trouble Sending Unit to Region

04-13-2007, 07:26 PM#1
PsycoMarauder
Hi, and thanks for taking a look at the thread. So heres the problem. Im making a Risk-based game. What happens in the game is you kill all the units in a region and whichever kills the last unit of a region is moved instantly to the center of the region. I have no trouble doing that. Instead of moving the killing unit instantly into the middle of the region, I want the trigger to check an area around the region, and if there are units in the surrounding area, a unit from the area is randomly picked and sent to the middle of the circle. If there isnt a unit in the surrounding area, I want it to move the killing unit into the region.

Here's one of the many failing codes triggers I've tried so far:
Trigger:
Moving Killing Unit 1
Collapse Events
Unit - A unit Dies
Collapse Conditions
(Region[1] contains (Dying unit)) Equal to True
(Number of units in (Units in Region[1] matching (((Matching unit) is alive) Equal to True))) Less than or equal to 1
((Killing unit) is A structure) Equal to False
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Number of units in (Units within 512.00 of (Center of Region[1]) matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) is A structure) Equal to False)))) Greater than or equal to 1
Collapse Then - Actions
Unit - Move (Random unit from (Units within 512.00 of (Center of Region[1]) matching (((Matching unit) is A structure) Equal to False))) instantly to (Center of Region[1])
Else - Actions
If ((((Killing unit) is A structure) Equal to False) and ((All units of (Units in Region[1] matching (((Matching unit) is A structure) Equal to False)) are dead) Equal to True)) then do (Unit - Move (Killing unit) instantly to (Center of Region[1])) else do (Do nothing)

A problem I've noticed is that the trigger will occasionally work, but after there are a few decaying units inside it stops working altogether.
Note-I dont want any buildings to be moved into the region.
04-13-2007, 09:03 PM#2
tamisrah
The most obvious mistake you did is that you don't exclude dead units in your group. It should look like this:
Trigger:
Actions
Set g = (Units within 512.00 of (Center of Region[1]) matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is alive) Equal to True)))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse IF - Conditions
(Number of units in g) Greater than 0
Collapse THEN - Actions
Unit - Move (Random unit from g) instantly to (Center of Region[1])
Collapse ELSE - Actions
Unit - Move (Killing unit) instantly to (Center of Region[1])

PS: I'm sorry if I translated something wrong.
04-14-2007, 09:57 PM#3
PsycoMarauder
Do I have to use a variable? And btw am I using way too long a script for something that could be done much easier?
04-15-2007, 02:06 AM#4
PurgeandFire111
1. It'll make it much quicker and easier.
2. Kind of, why take the long way when you can take the short and easy way?