Hello Mates,
I made a Base Defense Map , where I spawn Waves that attack the Player. I added Objectives now, for killing each Wave. But now I have to set for Example Objective 1 as Complete if Wave 1 was killed.
Thats where im running in circles. I tried to put the Waves in a Group and Count the Number of Living Units each time a Unit dies. But it doesnt work properly.
Here is What I did:
Wave 1
Actions
Unit - Create (2 * SpawnMultiplier) Zergling for player 15 at waypoint1 using default facing (No Options)
Unit Group - Add (Created unit) to Zerg Group[1]
--
Completed if Dead
Events
Unit - Any Unit dies
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
1 <= EnemyWaveNumber <= 8
And
Conditions
(Number of Living units in Zerg Group[1]) == 0
Then
Objective - Mark ("Objective 1" from the Global data table) as Completed
Else
and so on...
But it doesnt work. What am I doing wrong? How to put all Units from a Wave into a Group and Complete Objective when all of the Wave dies?
Please help
when spawning units do
add last created unit to UnitGroup CurrentLevelUnitGroup
To check if they are all dead
Event:- Any Unit Dies
Var i = 0
Conditions: (what ever you want for conditions)
Actions:
- Pick each unit in (CurrentLevelUnitGroup) and do actions( set i = i + 1)
- If i > 0 then actions(Level not Over Actions) Else (Level Over Actions)
I believe units are removed from unit groups after they die
else you may need to check if they are still alive before incrementing the "i" variable
also you may need to keep track of the number of units removed from either dying or making it to the end of the of a path like in a TD
You would have to spawn the units one at a time using a loop (which isn't a bad idea)
I just checked, and SCII has a lovely "add unit group to unit group" so you could (as long as it is in the same trigger) add the Last Created Unit Group to the unit group, and you wouldn't have to worry about a loop
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Unit Group - Add (Created unit) to Zerg Group[1]
-- Completed if Dead
Events
Unit - Any Unit dies
Local Variables
Conditions
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
1 <= EnemyWaveNumber <= 8
And
Conditions
(Number of Living units in Zerg Group[1]) == 0
Then
Objective - Mark ("Objective 1" from the Global data table) as Completed
Else and so on... But it doesnt work. What am I doing wrong? How to put all Units from a Wave into a Group and Complete Objective when all of the Wave dies? Please help
Global Var: CurrentLevelUnitGroup(type:UnitGroup)
when spawning units do
add last created unit to UnitGroup CurrentLevelUnitGroup
To check if they are all dead
Event:- Any Unit Dies
Var i = 0
Conditions: (what ever you want for conditions)
Actions:
- Pick each unit in (CurrentLevelUnitGroup) and do actions( set i = i + 1)
- If i > 0 then actions(Level not Over Actions) Else (Level Over Actions)
I believe units are removed from unit groups after they die
else you may need to check if they are still alive before incrementing the "i" variable
also you may need to keep track of the number of units removed from either dying or making it to the end of the of a path like in a TD
@SouLCarveRR: Go
"when spawning units do add last created unit to UnitGroup CurrentLevelUnitGroup"
doesnt this add just ONE unit (the last) to the Group or ALL units created with 1 or 2 create commands?
You would have to spawn the units one at a time using a loop (which isn't a bad idea) I just checked, and SCII has a lovely "add unit group to unit group" so you could (as long as it is in the same trigger) add the Last Created Unit Group to the unit group, and you wouldn't have to worry about a loop