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.
[07:46 am]
RIVE -- :wob:
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
Please log in to shout.


Members Online: jun3hong, Roy