I'm trying to figure out the best way to store a group of units to spawn a random group at different times, and I think waves is how I should do it but I can't figure out how they work.
What do you suggest doing, or how do waves work?
Post has been edited 2 time(s), last time on Aug 14 2010, 6:38 pm by JB4times4.
None.
Clarification:
He wants a way to trigger something that would select a random set of units out of multiple preset combos of units.
For example:
Make it select between spawning "2 marines + 1 medic" and "1 goliath + 1 scv".
Not sure if this helps.
None.
not select between 2 things, but randomly between (potentially) 100's of things.
None.
Could you elaborate a bit more? Are the units already created, or are they created when they need to be sent?
I'm creating a map that spawns waves of units every 15 seconds or so, and has them all target a random enemy unit on the map and attacks them. I don't have access to it right now (I'm not on my home computer), but it essentially goes like this:
SpawnEvent -Every 15.0 seconds of game time
Actions -For each integer from 1 to 12
-Spawn 1 of Unit Type at location X facing Default Angle
-Add (Last Created Unit) to GlobalUnitGroupVariable
-Order (Last Created Unit) to Attack Position of Unit (Random Unit from Enemies of Computer Player (Replace existing Orders)
DeathEvent -Any Unit Dies
Conditions -Owner of (Dying Unit) == ComputerPlayer
Actions -Remove (Dying Unit) from GlobalUnitGroupVariable
Where of course, Unit Type is the unit you wish to spawn, X is the location they are spawning at, and GlobalUnitGroupVariable is a global variable of type Unit group. You don't necessarily need this, but it makes them easier to command if they complete their objective, as you could do something like
ReassignEvents -Timer - Every 1.0 seconds of Game Time
Conditions -(Unit Type order at index 0) == ( Stop)
Actions -Unit - Order Unit to ( Attack targeting Position of Unit (Random Unit from Enemies of Computer Player) (Replace Existing Orders)
None.
Ok, so they haven't been created and won't be created until needed.
ex.
Groups like this:
2 marines 2 medics
2 zerglings 2 hydras
2 zealots 2 stalkers
Then via trigger I need it to randomly spawn 1 of those groups for a certain player. A little while later, I need it to spawn another group (can be the same one) for another player and so on.
None.
Ah, between several things. Devourer posted a nice tutorial on this in
http://www.staredit.net/topic/11586/ .
Essentially, you create a unit group called random unit group, or something similar, create one of each type of unit you wish to choose between, add them to the group, then kill them.
Later, when you want to select a random unit, just use the function "Pick random unit from Unit group" that matches the condition of "Dead", and it will select one of those. Quite innovative, if I do say so myself.
Other than that, you could create a variable that is randomly generated every time a unit is spawned using the Random function, then create a switch to create a corresponding unit. For instance, if you had 6 possible units, Marines, Firebats, Medics, Goliaths, Siege Tanks, and Thors, then do:
Unit = Random integer between 1 and 6
Switch Unit
Case 1
Spawn Marine
Case 2
Spawn Firebat
Case 3
Spawn Medic
Case 4
Spawn Goliath
Case 5
Spawn Siege Tank
Case 6
Spawn Thor
Both will work fine, whichever works easier for you.
None.
Well, I need to figure out how to spawn a specific group of units though so in the example above the first person gets 2 marines and 2 medics spawned. the second person gets 2 zerglings and 2 hydras spawned. Understand?
None.
Yeah, then the easiest way to do it if you have specific group set ups is to use a switch, if you had 3 groups, then you would do the same as before, it would look like this:
SpawnEvents -Time SpawnTimer Expires
Actions -Set Variable (Unit) = Random integer between 1 and 3
-Switch (Unit)
-Case 1
Spawn 2 Marines, 2 Medics
-Case 2
Spawn 2 Hydralisks, 2 Zerglings
-Case 3
Spawn 2 Zealots, 2 Stalkers
If you model the actual unit creating trigger from my above post (create a for loop from 1 to the number of units of that type you need spawned, then add each one to a unit group and order it to attack), it should work well.
None.
You lost me.

I read it 6 times and I still don't get what you are saying.
Thanks so much for your help by the way.
None.
I keep catching you just as you are writing a post too >.<.
No problem lol, let me see if I can get access to the editor and actually write up a trigger instead of just posting things from memory.
For clarification, are these being spawned for human players? Can i assume they wont need any AI if that's the case?
None.
Okay, here's what I came up with, this will cycle through four players (player 1, player 2, player 3, player 4), and generate a random unit group from three different possibilities.
Spawn
Events
Timer - Spawn Timer expires
Local Variables
Counter = 0 <Integer>
Random Unit = 0 <Integer>
Conditions
Actions
General - For each integer Counter from 1 to 4 with increment 1, do (Actions)
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Status of player Counter) == Playing
(Controller of player Counter) == User
Then
Variable - Set Random Unit = (Random integer between 1 and 3)
General - Switch (Actions) depending on Random Unit
Cases
General - If (1)
Actions
Unit - Create 2 Marine for player Counter at (Start location of player Counter) using default facing (No Options)
Unit - Create 2 Medivac for player Counter at (Start location of player Counter) using default facing (No Options)
General - If (2)
Actions
Unit - Create 2 Hydralisk for player Counter at (Start location of player Counter) using default facing (No Options)
Unit - Create 2 Zergling for player Counter at (Start location of player Counter) using default facing (No Options)
General - If (3)
Actions
Unit - Create 2 Zealot for player Counter at (Start location of player Counter) using default facing (No Options)
Unit - Create 2 Stalker for player Counter at (Start location of player Counter) using default facing (No Options)
Default
Else
If you need more players, just increase the number 4 in the "For each integer Counter from 1 to 4 with increment 1, do (Actions)" to the maximum players.
Granted, you will have to create a new case for each unit combination, and change the 3 in "Variable - Set Random Unit = (Random integer between 1 and 3)" to the number of combinations, but this will work.
This also does have the possibility of giving two players the same unit combination.
Attachments:
None.
That's a lot simpler then I was expecting. Thanks so much for your help. I will go ahead and throw it in the map and see how it goes.
None.
Only one little twist is missing there:
The Event should be based on Players clicking a button, and not Time.

Basically, think of it as 2v2:
The first player of each team to press the button gets his Random Unit Combo generated and sent into the Arena while their partner receive automatically (without requiring them to press the button) their own Random Unit Combo, placed in some Waiting Rooms.
None.
Ah, well it should be pretty simple if you've already got that running. You can write in a condition to make sure that there are no copies of the trigger in the action queue (IE, it is only run once at a time) so there are no glitches from perfect timing between the players.
None.
The reason I didn't say anything is because I can figure it out from there, and it's just more work for you.
None.
Haha, no problem, that is what we're here for anyways.
None.
Perfect, got it working great.
Thanks again for your help!
None.