Hey everyone, I've been working on a map and have got a good amount of it complete. I am now working on adding a random spawn location. I haven't had any luck looking for reference materials or getting it to run by trial and error. Heres my desired effect.
I have 12 locations that I want players to be randomly placed, and have been pre-designed. I want players to be randomly spawned between the 12 starting locations even if the game isn't full. Upon random selection of a players spawn place. I want it to build a building(not the default start location point, as that has a build-in random option) so I don't want a nexus/cc/hatch with workers. Just the building. During this process I haven't had any luck. I have tried to change the start location stuff, but failed to find a way. I then proceeded to try it with regular points, and when I thought I was onto something, everytime i tried the map, nothing happened. I found i messed up with a trigger and did a few mods to the actions, and still nothing. baffled i switched to regions...still nothing. I then rounded my wits around the internet and found absolutely nothing that either helped me explain what was going wrong, or defer me in the right direction. So here I am now asking for the wise people of sc2mapster for help.
Just to recap after my sad story.
12 random locations.
after selected build a building
and then pan camera to the newly built building.
I can get the camera part going, just can't get the random spawn to work.
@mcmelord:
Not too hard... Except for the possibility of the building itself....
First, you're going to need an 11 index point array variable, and a little initializing with it. In your initialize, you're going to take each point that you're going to have as a starting place and place it in a separate index in your array, starting at 0 for the first point, and ending at 11 for the final point. Then, in another trigger which determines where your going to start, you're going to need 3 local variables: an integer named random, an integer named i, and an integer named players. In your actions, your going to want the following:
Variable - Set players = (Number of players in (Active Players)
General - For each integer i from 0 to players with increment 1, do (Actions)
Actions
Variable - Set random = (Random integer between 0 and 11)
Unit - Create 1 Command Center for player i at point[random] using default facing (Under Construction)
That is essentially it. The Command Center can be replaced with whatever building you're intending it to be. But here is the hitch: if it's a terran building, you'll need to also create an SCV to start work immediately on it, or it won't ever complete, where as the other two races will not need a unit to do it (using standard SC2 rules.)
So... to do that, you could just add another unit create and issue a smart command on the building.... so you'd need a fourth local variable that would be a unit.... and your new action list would look like this...
Variable - Set players = (Number of players in (Active Players))
General - For each integer i from 0 to players with increment 1, do (Actions)
Actions
Variable - Set random = (Random integer between 0 and 8)
Unit - Create 1 Command Center for player i at point[random] using default facing (Under Construction)
Variable - Set building = (Last created unit)
Unit - Create 1 SCV for player i at point[random] facing 270.0 degrees (No Options)
Unit - Order (Last created unit) to (Smart Command targeting building) (Replace Existing Orders)
Anything else that confuses you, or if this isn't what you were looking for, let us know and I'm sure we'll try to help.
@mcmelord:
When making a variable, there's an option to make an array. The index just refers to the specific part of the array.
varriableArray[indexNumber]
and on the 2nd part of the action list you posted...is the random integer meant to be 8 instead of 11?
EDIT:
actually nevermind. I was able to get it working. I appreciate all your help! Just to clarify, will that trigger do it for every player or just 1? in other words will I need to duplicate?
If it does it for more than 1 player, will it try to spawn on the same place at all? or will they all spawn in a different location? Thanks
Ok; I now have a new problem. With a trigger list similar(almost identical) to what you gave me now has the random spawning working. It creats a bunker at the location fully built and operational, didn't need the "In construction" or scv for it to work. My new problem is that everyone once in awhile, the random spawn will spawn 2 bunkers at the same location, not on top of each other but right next to the other. One is the correct players bunker and one seems to be another players bunker(during development its just a computer one, but still non-the-less this is a problem. I only want 1bunker at the location along with an observer.
In map initialization i have it do a variety of things like dialog boxes, camera panning, setting variables(along with spawn point variable index) and 2 timers, one for the overtime countdown, and 1 hidden timer to expire in 30 seconds. In another trigger i have it run the random spawn trigger after that 30 second timer has expired. so far working flawlessly. I dont think it has anything to do with map init or the other triggers by the random spawn trigger itself, I'll post it here if anyone could help me identify the problem that would be great. Thanks!
Local Variables
i <integer>
random <integer>
players <integer>
Actions
Variable - Set players = (number of players in (Active Players))
General - For Each Integer i from 0 to players with increment 1, do (Actions)
Actions
Variable - Set random = (random integer from 0 to 11)
Unit - Create 1 bunker for player i at point[random] with default facing (no options)
Unit - Create 1 observer for player i at point[random] with default facing (no options)
Camera - Pan the camera to (position of unit (last created unit)) over 2.0 seconds...blaw 10 % decel, do not use smart panning
I think the problem is you have the two things running in parallel, so they are creating at the same time without checking to see what the other is doing. There could also be a problem with the function itself not checking if there is already something created at that point. What you could do is create an array of Boolean values and update that to show that something is already in the random position selected, then just do an if statement to check and see if something is there or not. If there is something already there (i.e. the Boolean value is true), then pick another random number.
Well the problem is that its spawning an extra bunker than is needed. when I test the map only player 1 should spawn. but with the testing i've been doing, player 1(Local Player) spawns with the bunker and observer just fine, but also an un-manned or even computer bunker & observer is spawned. and every so often happens to be on where I spawn while testing. If published like so, in every game 1 person would have an uncontrolable bunker/observer in their base.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hey everyone, I've been working on a map and have got a good amount of it complete. I am now working on adding a random spawn location. I haven't had any luck looking for reference materials or getting it to run by trial and error. Heres my desired effect.
I have 12 locations that I want players to be randomly placed, and have been pre-designed. I want players to be randomly spawned between the 12 starting locations even if the game isn't full. Upon random selection of a players spawn place. I want it to build a building(not the default start location point, as that has a build-in random option) so I don't want a nexus/cc/hatch with workers. Just the building. During this process I haven't had any luck. I have tried to change the start location stuff, but failed to find a way. I then proceeded to try it with regular points, and when I thought I was onto something, everytime i tried the map, nothing happened. I found i messed up with a trigger and did a few mods to the actions, and still nothing. baffled i switched to regions...still nothing. I then rounded my wits around the internet and found absolutely nothing that either helped me explain what was going wrong, or defer me in the right direction. So here I am now asking for the wise people of sc2mapster for help.
Just to recap after my sad story. 12 random locations. after selected build a building and then pan camera to the newly built building.
I can get the camera part going, just can't get the random spawn to work.
I appreciate all help in advance.
@Feithless: Go
@Feithless
Ok i understand most of that, but the index arrays for the different spawn locations threw me off, how exactly do I put those in?
@Feithless: Go
@Feithless
so it would be a global variable then?
and on the 2nd part of the action list you posted...is the random integer meant to be 8 instead of 11?
EDIT:
actually nevermind. I was able to get it working. I appreciate all your help! Just to clarify, will that trigger do it for every player or just 1? in other words will I need to duplicate?
If it does it for more than 1 player, will it try to spawn on the same place at all? or will they all spawn in a different location? Thanks
@mcmelord: Go
Ok; I now have a new problem. With a trigger list similar(almost identical) to what you gave me now has the random spawning working. It creats a bunker at the location fully built and operational, didn't need the "In construction" or scv for it to work. My new problem is that everyone once in awhile, the random spawn will spawn 2 bunkers at the same location, not on top of each other but right next to the other. One is the correct players bunker and one seems to be another players bunker(during development its just a computer one, but still non-the-less this is a problem. I only want 1bunker at the location along with an observer. In map initialization i have it do a variety of things like dialog boxes, camera panning, setting variables(along with spawn point variable index) and 2 timers, one for the overtime countdown, and 1 hidden timer to expire in 30 seconds. In another trigger i have it run the random spawn trigger after that 30 second timer has expired. so far working flawlessly. I dont think it has anything to do with map init or the other triggers by the random spawn trigger itself, I'll post it here if anyone could help me identify the problem that would be great. Thanks!
Local Variables i <integer> random <integer> players <integer>
Actions Variable - Set players = (number of players in (Active Players)) General - For Each Integer i from 0 to players with increment 1, do (Actions) Actions Variable - Set random = (random integer from 0 to 11) Unit - Create 1 bunker for player i at point[random] with default facing (no options) Unit - Create 1 observer for player i at point[random] with default facing (no options) Camera - Pan the camera to (position of unit (last created unit)) over 2.0 seconds...blaw 10 % decel, do not use smart panning
@mcmelord: Go
I think the problem is you have the two things running in parallel, so they are creating at the same time without checking to see what the other is doing. There could also be a problem with the function itself not checking if there is already something created at that point. What you could do is create an array of Boolean values and update that to show that something is already in the random position selected, then just do an if statement to check and see if something is there or not. If there is something already there (i.e. the Boolean value is true), then pick another random number.
@xHawkEyex: Go
@xHawkEyex
Well the problem is that its spawning an extra bunker than is needed. when I test the map only player 1 should spawn. but with the testing i've been doing, player 1(Local Player) spawns with the bunker and observer just fine, but also an un-manned or even computer bunker & observer is spawned. and every so often happens to be on where I spawn while testing. If published like so, in every game 1 person would have an uncontrolable bunker/observer in their base.