Staredit Network > Forums > SC2 Assistance > Topic: [Solved] Waves
[Solved] Waves
This topic is locked. You can no longer write replies here.
Aug 13 2010, 12:40 am
By: LooKe  

Aug 13 2010, 12:40 am LooKe Post #1



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. :blush:

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.

Aug 13 2010, 1:23 am payne Post #2

:payne:

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. :P



None.

Aug 13 2010, 1:25 am LooKe Post #3



not select between 2 things, but randomly between (potentially) 100's of things.



None.

Aug 13 2010, 1:33 am shmeeps Post #4



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:

Spawn
Event
-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)

Death
Event
-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

Reassign
Events
-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.

Aug 13 2010, 1:36 am LooKe Post #5



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.

Aug 13 2010, 1:40 am shmeeps Post #6



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

Code
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.

Aug 13 2010, 1:44 am LooKe Post #7



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.

Aug 13 2010, 1:44 am shmeeps Post #8



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:

Spawn
Events
-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.

Aug 13 2010, 1:47 am LooKe Post #9



You lost me. :bleh: 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.

Aug 13 2010, 1:49 am shmeeps Post #10



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.

Aug 13 2010, 1:53 am LooKe Post #11



Yep, no AI needed.



None.

Aug 13 2010, 2:06 am shmeeps Post #12



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.

Code
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:
Spawn Micro Units.JPG
Hits: 5 Size: 69.7kb



None.

Aug 13 2010, 2:10 am LooKe Post #13



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.

Aug 13 2010, 2:20 am payne Post #14

:payne:

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.

Aug 13 2010, 2:23 am shmeeps Post #15



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.

Aug 13 2010, 2:32 am LooKe Post #16



The reason I didn't say anything is because I can figure it out from there, and it's just more work for you. :bleh:



None.

Aug 13 2010, 3:20 am shmeeps Post #17



Haha, no problem, that is what we're here for anyways.



None.

Aug 14 2010, 6:37 pm LooKe Post #18



Perfect, got it working great.

Thanks again for your help!



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2024-4-27. : 9:38 pm]
NudeRaider -- Ultraviolet
Ultraviolet shouted: NudeRaider sing it brother
trust me, you don't wanna hear that. I defer that to the pros.
[2024-4-27. : 7:56 pm]
Ultraviolet -- NudeRaider
NudeRaider shouted: "War nie wirklich weg" 🎵
sing it brother
[2024-4-27. : 6:24 pm]
NudeRaider -- "War nie wirklich weg" 🎵
[2024-4-27. : 3:33 pm]
O)FaRTy1billion[MM] -- o sen is back
[2024-4-27. : 1:53 am]
Ultraviolet -- :lol:
[2024-4-26. : 6:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[2024-4-26. : 6:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[2024-4-26. : 6:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
[2024-4-26. : 6:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[2024-4-26. : 6:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
Please log in to shout.


Members Online: Roy