HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unit grouping issue

07-04-2011, 03:54 PM#1
Xindaris
Okay, all the triggers involved are inside the hidden tags below.
Hidden information:
Trigger:
Make Round
Collapse Events
Time - BetweenRounds expires
Conditions
Collapse Actions
Countdown Timer - Destroy BetweenRoundsWindow
Collapse For each (Integer A) from 1 to NumPlayers, do (Actions)
Collapse Loop - Actions
Set CurrentSpawn = (Random integer number between 0 and 5)
Collapse For each (Integer i) from 1 to EnemyTypes[Round], do (Actions)
Collapse Loop - Actions
Collapse For each (Integer B) from 1 to EnemyNum[((Round x MaxTypes) + (i - MaxTypes))], do (Actions)
Collapse Loop - Actions
Set TempPoint = (Random point in SpawnPoints[CurrentSpawn])
Unit - Create 1 EnemyType[((Round x MaxTypes) + (i - MaxTypes))] for Player 12 (Brown) at TempPoint facing Default building facing degrees
If (((Last created unit) is A Hero) Equal to True) then do (Hero - Set (Last created unit) Hero-level to BossLevel[(Round / 5)], Hide level-up graphics) else do (Do nothing)
Unit Group - Add (Last created unit) to Attackers[(Integer A)]
Set LiveEnemies = (LiveEnemies + 1)
Custom script: call RemoveLocation (udg_TempPoint)
Set InRound = True
Trigger - Run Keep Going <gen> (ignoring conditions)
Game - Display to (All players) the text: RoundText[Round]

Trigger:
Keep Going
Collapse Events
Time - Every 10.00 seconds of game time
Collapse Conditions
InRound Equal to True
Collapse Actions
Collapse For each (Integer A) from 1 to (Number of players in (All players controlled by a User player)), do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Beaten[Players[(Integer A)]] Equal to False
Collapse Then - Actions
Set TempPoint = (Random point in BaseZones[(Integer A)])
Unit Group - Order Attackers[(Integer A)] to Attack-Move To TempPoint
Custom script: call RemoveLocation (udg_TempPoint)
Collapse Else - Actions
Set Rand = (Random integer number between 0 and NumPlayers)
Set TempPoint = (Random point in BaseZones[Rand])
Unit Group - Order Attackers[(Integer A)] to Attack-Move To TempPoint
Custom script: call RemoveLocation (udg_TempPoint)

Trigger:
Enemy Death
Collapse Events
Unit - A unit owned by Player 12 (Brown) Dies
Conditions
Collapse Actions
Set LiveEnemies = (LiveEnemies - 1)
If (LiveEnemies Equal to 0) then do (Trigger - Run Round End <gen> (checking conditions)) else do (Do nothing)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
((Dying unit) is A Hero) Equal to True
Collapse Then - Actions
Hero - Instantly revive (Dying unit) at (Random point in Pit of Shame <gen>), Hide revival graphics
Set DyingScore = (Hero level of (Dying unit))
Collapse Else - Actions
Set DyingScore = 1
Set Kills[(Player number of (Owner of (Killing unit)))] = (Kills[(Player number of (Owner of (Killing unit)))] + DyingScore)
Trigger - Run Update Scorerboard <gen> (ignoring conditions)

Trigger:
Round End
Events
Collapse Conditions
LiveEnemies Equal to 0
Collapse Actions
Set InRound = False
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
IsSpecial[Round] Equal to False
Collapse Then - Actions
Countdown Timer - Start BetweenRounds as a One-shot timer that will expire in 30.00 seconds
Set Round = (Round + 1)
Countdown Timer - Create a timer window for BetweenRounds with title (Time until Round + (String(Round)))
Set BetweenRoundsWindow = (Last created timer window)
Countdown Timer - Show BetweenRoundsWindow
Collapse Else - Actions
Trigger - Run Special End <gen> (checking conditions)
Collapse For each (Integer A) from 1 to NumPlayers, do (Actions)
Collapse Loop - Actions
Unit Group - Remove all units of (Units in (Playable map area)) from Attackers[(Integer A)]


What these are supposed to do is spawn units, making one group for each player that's in the game, then have each group attack-move to the corresponding player's base. Everything works perfectly in round 1, but in round 2 and beyond only some of the units seem to get selected, while the other ones just stand around in the spawn area doing nothing. I have tried everything I can think of to fix it, including destroying and recreating all the unit groups with custom script, and nothing seems to work. (That loop at the end of the round end trigger was among my efforts to try and fix the problem, with and without it it still messes up.)

I should note that every function other than moving the units works perfectly; the spawning and the hero revival work just fine. And those units that do move go to the correct places, too.

Can anyone help me with this? If it can't happen, I might as well stop work on the map right now and never return.
07-04-2011, 05:32 PM#2
Anitarf
Are your unit groups larger than 12 units? The "issue order to unit group" action does not work with more than 12 units (you can't select more than 12 units, so it's possible the code for group movements that makes sure the units maintain formation was hardcoded to work with a maximum of 12 units at once). If this is your problem, the only thing you can do is either issue the orders to each unit in the group individually or split your attack waves into multiple groups that are each smaller than 12 units.
07-04-2011, 10:17 PM#3
Xindaris
Some are and some aren't, but it's possible that it's trying to select units that are already dead too. So, would a "pick every unit in attackers[blah] and do (order unit to attack-move)" do the trick? I'm gonna try that. (Would I need anything special to keep that from leaking since these are established variable groups?)

EDIT: It works perfectly now, thank you so much.
Here's the revised version of the keep going trigger:
Trigger:
Keep Going
Collapse Events
Time - Every 10.00 seconds of game time
Collapse Conditions
InRound Equal to True
Collapse Actions
Collapse For each (Integer A) from 1 to (Number of players in (All players controlled by a User player)), do (Actions)
Collapse Loop - Actions
Collapse Unit Group - Pick every unit in Attackers[(Integer A)] and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Beaten[Players[(Integer A)]] Equal to False
Collapse Then - Actions
Set TempPoint = (Random point in BaseZones[Players[(Integer A)]])
Unit - Order (Picked unit) to Move To TempPoint
Custom script: call RemoveLocation (udg_TempPoint)
Collapse Else - Actions
Set TempPoint = (Random point in BaseZones[Players[(Random integer number between 0 and NumPlayers)]])
Unit - Order (Picked unit) to Move To TempPoint
Custom script: call RemoveLocation (udg_TempPoint)
07-04-2011, 10:26 PM#4
Anitarf
That should do the trick, it also shouldn't leak.