Staredit Network > Forums > SC2 Assistance > Topic: Spawn units when another enters a region?
Spawn units when another enters a region?
Feb 18 2013, 8:07 pm
By: sharf  

Feb 18 2013, 8:07 pm sharf Post #1



Alright, so I'm entirely overwhelmed with sc2 triggers and what I should be doing to learn, so I thought I'd try to make my own and see how it goes.
Already I've hit a wall. I want to make a region (several actually) that when a unit controlled by a human player (perhaps I'll have to use unit groups?) enters a region, 5 of a unit will be spawned there, and no more will spawn until there are 0 of that spawned unit in that location, then 5 more will spawn.

In SC1 I'd do currentplayer bring 1, AI Player bring 0, create 5 unit, preserve. I've got the unit enter region part, but then it's just going to spam the unit spawn...

Any tips on how to go about this?

Thanks, sharf.



None.

Feb 18 2013, 8:20 pm DevliN Post #2

OVERWATCH STATUS GO

With triggers in SC2, you can use "If, then" actions with conditions to do things like this. It's been a while since I've done triggering, but I think you would start with an event that runs the trigger every second. Then create an "if, then" action with a condition that states there are no units in the region (of the 5 units you want to create, similar to what you'd do in SC1), then create those units.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 18 2013, 8:32 pm sharf Post #3



I don't understand enough of how SC2 triggers work to really understand how to use what you just said, events look to me like what old conditions were. and I don't fully understand how to combine conditions and events to manipulate the scenario.



None.

Feb 18 2013, 8:42 pm DevliN Post #4

OVERWATCH STATUS GO

Events determine when a trigger fires. One of them allows you to run the trigger over and over again. Instead of creating a trigger and using "Preserve trigger" as you would in SC1, you'd just use this event to run a SC2 trigger over again.

Conditions are literally specific conditions for the trigger to run, similar to how conditions work in SC1.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 18 2013, 8:46 pm sharf Post #5



Ok, so I have an event that runs every 1 game second. But then I only have 6 conditions, all boolean, I don't see how I use that to determine the unit count in a region and by what player...



None.

Feb 18 2013, 8:50 pm DevliN Post #6

OVERWATCH STATUS GO

You'd add a Condition that compares the amount of units in a region to 0, and then compares the player owning the units to whatever player is supposed to own them. I don't have the editor on this computer so I can't look up what the exact conditions you need would be, unfortunately.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 18 2013, 9:25 pm sharf Post #7



Alright well I have something, but it doesn't work and I'm sure it's wrong.




None.

Feb 18 2013, 9:40 pm DevliN Post #8

OVERWATCH STATUS GO

Off the top of my head, one thing I'd suggest is putting all 3 of your conditions together. I was using the "If, then" action as an example earlier, but as far as I know if you're putting the Conditions in that part of the trigger then you shouldn't need that.

The only thing I can think of that would be wrong with that is the "Global data table" portion. I'd create a variable (unit group) for the zerglings and use that instead, and see if that works. As for the Zealot, I'd create a variable for that as well.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 18 2013, 10:06 pm sharf Post #9



Ok, then how do I do that? In the data editor?



None.

Feb 18 2013, 10:18 pm DevliN Post #10

OVERWATCH STATUS GO

Nope, in the triggers. Right click on your list of triggers, and create a new variable. You can use triggers to modify and set variables, as well.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 18 2013, 10:22 pm sharf Post #11



alright so I'm in the variable creation screen, but I'm not sure how (or what) I am defining the units to be used. So far I have created a variable of type unit group, but I don't know what to set the initial value to.



None.

Feb 18 2013, 10:27 pm DevliN Post #12

OVERWATCH STATUS GO

Create a trigger with the "Map initialization" event that sets the unit group variable to whatever you want the units to be.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 18 2013, 10:40 pm sharf Post #13



Alright fair enough, but what do I set the value to be? under the value radio button, there is no option, so I can go to function, preset, variable, or custom script. Which is where I got the idea to use the data table thing. I'm really starting to miss the sc1 trigger editor lol.



None.

Feb 18 2013, 10:44 pm DevliN Post #14

OVERWATCH STATUS GO

Don't worry about the default value, since you'll be setting that using a trigger.

Yeah SC1 triggers were much easier. SC2 just lets you have a ton of options.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 18 2013, 10:47 pm sharf Post #15



Well with no value it has the red diamond and doesn't like that it's not set. Then what's the next step to add the unit to it?



None.

Feb 18 2013, 11:13 pm DevliN Post #16

OVERWATCH STATUS GO

The "set variable" action, or something like that.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 18 2013, 11:26 pm sharf Post #17



Right and that was what I was describing, what value do I set it to? There is no way that I can find to set it to a specific unit.



None.

Feb 19 2013, 1:06 am DevliN Post #18

OVERWATCH STATUS GO

I just threw this together as a basic guide for how to do it. It isn't perfect, since the variable resets each time you create new Zerglings. This also wont work for random Zerglings you run into, either. To do that, you'd have to set the condition to any and all Zerglings, which takes some manipulation. I didn't have time to set that up since I'm getting ready to go out of town for a week. Sorry. :(

http://www.staredit.net/devlin/ZlingGroupTest.SC2Map



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Feb 19 2013, 2:25 am sharf Post #19



Thanks DevliN, that's actually exactly what I want (The idea is to make a training area similar to that of the old school town defense maps) and I want to create groups of enemies to train on, so I would need to make a new region and series of triggers for each area anyway.

Thanks again!

Edit: I have another question for you or someone else.

I got the hang of assigning units to variables to keep track of them, and that will work for now, but say I want to duplicate a unit spawn trigger for multiple players. As in, if Player 1 brings a unit here, spawn another for player 1, or if player 2 brings a unit to that same spot, spawn another for player 2 instead, without having to write two triggers for each player (sort of a current player situation from SC1). How would I do that, if it's possible?

Post has been edited 1 time(s), last time on Feb 19 2013, 5:37 am by sharf.



None.

Feb 19 2013, 7:00 am DevliN Post #20

OVERWATCH STATUS GO

You can add an array to the variable which will add a number on the side (i.e. it will look like "Zergling Group [0]"). You can then set the units that are created to a specific number in that unit group (or whatever variable has the array). In your example, you can set all of player 1's units to "Zergling Group [1]" and all of player 2's to "Zergling Group [2]" and so on.

Or you can create a variable for each player.



\:devlin\: Currently Working On: \:devlin\:
My Overwatch addiction.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[01:53 am]
Ultraviolet -- :lol:
[06: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.
[06: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
[06: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?
[06:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[06:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
[06:48 pm]
Vrael -- Perhaps that utilizes cutting-edge technology and eco-friendly cleaning products?
[06:47 pm]
Vrael -- Do you know anyone with a deep understanding of the unique characteristics of your carpets, ensuring they receive the specialized care they deserve?
[06:45 pm]
NudeRaider -- Vrael
Vrael shouted: I've also recently becoming interested in Carpet Cleaning, but I'd like to find someone with a reputation for unparalleled quality and attention to detail.
beats me, but I'd make sure to pick the epitome of excellence and nothing less.
[06:41 pm]
Vrael -- It seems like I may need Introductions to multiple companies for the Topics that I care deeply about, even as early as Today, 6:03 am.
Please log in to shout.


Members Online: Roy