• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

HELP NEEDED Removing/De-spawning Unit Groups

Status
Not open for further replies.
Level 1
Joined
Feb 9, 2016
Messages
5
Hello All! I'm very new to WC3 World Editor and am attempting to make a wave-based tower defense.

My plan is to have the waves run around your base for a set amount of time (i.e 60 seconds) and any remaining mobs after this time will die, removing your lives (1 life per remaining mob) and the next wave will then spawn.

Everything I have tested will not remove the previous mobs, but WILL spawn in the next wave. So far I have set the mobs to spawn on 3 players bases, Red(rd) Blue(bl) and Teal(tl). Brown is the NPC.

Here what I've come up with so far and everything works okay other than removing the previous wave.

  • Example
    • Events
      • Time - RestTimer expires
    • Conditions
    • Actions
      • Set WaveCount = (WaveCount + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WaveCount Equal to 1
        • Then - Actions
          • Countdown Timer - Destroy (Last created timer window)
          • Countdown Timer - Create a timer window for RestTimer with title Next round in
          • Countdown Timer - Start RestTimer as a One-shot timer that will expire in 10.00 seconds
          • Unit - Create 5 Acolyte for Player 12 (Brown) at (Center of rdwavespawn1 <gen>) facing (Center of rdwavespawn2 <gen>)
          • Unit - Create 5 Acolyte for Player 12 (Brown) at (Center of blwavespawn1 <gen>) facing (Center of blwavespawn2 <gen>)
          • Unit - Create 5 Acolyte for Player 12 (Brown) at (Center of tlwavespawn1 <gen>) facing (Center of tlwavespawn2 <gen>)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WaveCount Equal to 2
        • Then - Actions
          • Unit Group - Pick every unit in (Units in rddespawn <gen> owned by Player 12 (Brown)) and do (Unit - Remove (Triggering unit) from the game) //THIS IS WHERE I NEED THE MOST HELP
          • Countdown Timer - Destroy (Last created timer window)
          • Countdown Timer - Create a timer window for RestTimer with title Next round in
          • Countdown Timer - Start RestTimer as a One-shot timer that will expire in 10.00 seconds
          • Unit - Create 5 Ghoul for Player 12 (Brown) at (Center of rdwavespawn1 <gen>) facing (Center of rdwavespawn2 <gen>)
          • Unit - Create 5 Ghoul for Player 12 (Brown) at (Center of blwavespawn1 <gen>) facing (Center of blwavespawn2 <gen>)
          • Unit - Create 5 Ghoul for Player 12 (Brown) at (Center of tlwavespawn1 <gen>) facing (Center of tlwavespawn2 <gen>)
        • Else - Actions
Please help me figure out how to remove the previous waves and also feel free to give me any more efficient ways of achieving what my current code achieves.

Thanks to all in advance!

P.S. I have looked around for info on this and can't seem to find anything that explains how to do this, hence my posting. Please link me to anything available!
 
Last edited:
Level 12
Joined
Jan 2, 2016
Messages
973
Well, I would do: Loop from 1 to 5
Create 1 Accolyte for Player 12 at .... facing ....
Unit Group - Add Last Created Unit to LastWaveGroup

and for the next wave:
Unit Group - Pick every unit in LastWaveGroup and do actions:
Remove Picked Unit from the game (and from the unit group)
Set Lives = Lives - 1
.....

You also need 1 more trigger:
When a unit dies
If triggering unit is in unit group "LastWaveGroup"
then Remove Triggering unit from LastWaveGroup

That's probobly the easiest way to do it in GUI.

By the way, you can GREATLY reduce your trigger lenght.
Have one trigger, that runs during the map initialization:
Set (Unit-Type variable array) WaveCreeps[1] = Acolyte
Set WaveCreeps[2] = Ghoul
..........

And in your main trigger do:
Loop from 1 to 5
Create 1 WaveCreeps[WaveCount] for Player 12 .............
Unit Group - Add Last Created Unit to LastWaveGroup

This way you wouldn't need the "ifs".
And last but not least...
Also in the initialization do:
Set Point1 = Center of rdwavespawn1
Set Point2 = Center of blwavespawn1
Set Point3 = Center of tlwavespawn1

And in your trigger use Point1/2/3 instead of "Center of region".
 
Last edited:
Level 1
Joined
Feb 9, 2016
Messages
5
Awesome WereElf,

Thanks for the info and quick reply! Just from reading your tips it already sounds like this will be a much better way of setting up my map.

Anyone else with input please feel free! I need to hear it all, been on these forums all day reading up on guides and such hopefully this turns out!

Edit: Quick question, is "point1-...." a variable? I can't seem to find it otherwise, going to make a variable until further notice.
71144e7e05b33af247c05ddf8f1d1b1e.png
 
Last edited:
Level 1
Joined
Feb 9, 2016
Messages
5
Alright well, before I mess this up further ;d Here's where am at. Is this looking like what you've explained?
  • Melee Initialization
    • Events
      • Map initialization
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Visibility - Disable fog of war
      • Visibility - Disable black mask
      • Countdown Timer - Start RestTimer as a One-shot timer that will expire in 10.00 seconds
      • Countdown Timer - Show TimerWindow
      • Countdown Timer - Create a timer window for RestTimer with title Next Round In:
      • Set TimerWindow = (Last created timer window)
      • Set WaveSpawnPoint[1] = (Center of rdwavespawn1 <gen>)
      • Set WaveSpawnPoint[2] = (Center of blwavespawn1 <gen>)
      • Set WaveSpawnPoint[3] = (Center of tlwavespawn1 <gen>)
      • Set Waves[1] = Acolyte
      • Set Waves[2] = Ghoul
      • Set Waves[3] = Abomination
  • NewSpawningTest
    • Events
      • Time - RestTimer expires
    • Conditions
    • Actions
      • Set WaveCount = (WaveCount + 1)
      • For each (Integer WaveCount) from 1 to 5, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Waves[1] for Player 12 (Brown) at WaveSpawnPoint[1] facing (Center of rdwavespawn2 <gen>)
          • Countdown Timer - Destroy (Last created timer window)
          • Countdown Timer - Create a timer window for RestTimer with title Next round in
          • Countdown Timer - Start RestTimer as a One-shot timer that will expire in 10.00 seconds
 
Please do not do this:
  • Melee Initialization
    • Events
    • Map initialization
    • Time - Elapsed game time is 5.00 seconds

Just do what you want at intialization, then do what you want at 5.00 seconds.
There is no need to disable fog of war twice and set all of those variables again.

And your last trigger is all wrong.

  • NewSpawningTest
  • Events
    • Time - RestTimer expires
  • Conditions
  • Actions
    • Set WaveCount = (WaveCount + 1)
    • For each (iA) from 1 to 3, do (Actions)
      • Loop - Actions
        • For each (iB) from 1 to 5, do (Actions)
          • Loop - Actions
            • Unit - Create (iB) Waves[WaveCount] for Player 12 (Brown) at WaveSpawnPoint[iA] facing WaveSpawnAngle[iA]
    • Countdown Timer - Destroy TimerWindow*
    • Countdown Timer - Create a timer window for RestTimer with title Next round in
    • Countdown Timer - Start RestTimer as a One-shot timer that will expire in 10.00 seconds
Don't run the countdown timers through the loop.
Also, your loops did not create 5 units in 3 regions. This one does.

I used variables named iA and iB for (Integer A) and (Integer B).
Now we loop once for each region and each time we do that we
loop once to create each spawn. We also set the spawn type with
WaveCount. Also, you created TimerWindow, please don't forget
to use it.*
If you use faceing (center of region) it will leak.
Set the angle with your other variables and use that.
(center of ___) and (Random point in ___) are locations.
And what do locations do? That's right! They leak!

Does this help?
 
Level 12
Joined
Jan 2, 2016
Messages
973
Yeah, do what Legel_Ease said.
Don't forget about the "Unit Group - Add unit (Last Created Unit) to (LastWaveGroup)" - do this right after creating the unit (inside the loop)
And In the begining of the trigger do the "Unit Group - Pick all units in LastWaveGroup and do actions:
Remove Picked Unit from LastWaveGroup
Remove Picked Unit from the game
Set Lives = Lives - 1
 
Level 1
Joined
Feb 9, 2016
Messages
5
I used variables named iA and iB for (Integer A) and (Integer B).
Now we loop once for each region and each time we do that we
loop once to create each spawn. We also set the spawn type with
WaveCount. Also, you created TimerWindow, please don't forget

Could you show me how the variables would be setup? I had it working previously using 3 lines but I'm not able to create multiple units in various regions with just one line as you have described.

If you use faceing (center of region) it will leak.
Set the angle with your other variables and use that.
(center of ___) and (Random point in ___) are locations.
And what do locations do? That's right! They leak!

What do you mean when you say they will leak. I can set it up the way you've explained just not really sure what the difference will be.
 
Last edited:
Could you show me how the variables would be setup? I had it working previously using 3 lines but I'm not able to create multiple units in various regions with just one line as you have described.

Just hit cntrl-B and create integer variables. I often name them Loop_A and Loop_B. I just used iA and iB to save space. You don't need to set them because they are 0 by default and the function sets them from 1-x. And that's just what it does.

Chonsie said:
What do you mean when you say they will leak. I can set it up the way you've explained just not really sure what the difference will be.

All locations leak a point. Which means that the point is saved into memory during the game. If you keep creating points then it will end up using up this memory and the game will lag. To prevent this you must remove the point. That's called removing the leak. Unit groups also leak in this way. Please read http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Status
Not open for further replies.
Top