I want to place a unit in many spots all over the map and i want to run the trigger again when my level completes so the units re-spawn. the problem is i made a point in all the spots i want it, and there ate 189 points. Is there a way to place all of those without individually creating 1 unit at each point cause that would take hours.
well the best thing i can do right now is to create the units at random points 189 times through a repeat. the only thing is that some points will probably have many units and some might have none.
Well in that case you could devide the map into smaller regions and place units randomly in those. That way they will be more consistent throughout the map.
That's the point of the random point function (Pun not intended). Pre placed points aren't random.
And you can use variable arrays for multiple values. Create a point variable, give its first index the size of 189, then use "set variable" at map init and set each slot of the variable to one of your pre placed points. After that just use "For each integer X from 1 to 189", "Create unit at PointArray[X]"
I think he wanted to avoid doing all that work. Maybe there is a way to get the preplaced points without adding them to a variable? But I don't think so, at least I haven't found it.
What you are looking for is a function that grabs a random point, which does not require you to specifically assign each point to a variable or individually name it somehow. In other words, some kind of 'for each point' function. As far as I know, no function like that exists- because if it did, I'd be very happy :)
That said, I do have one idea that *may* just work ^.^
Global Variable "Points". Array size 189
Local Variable:
int ticker = 0
unit u = none
For each unit u in (Units in Entire Map)
{
// We're going to keep track of how many units we have counted so far
modify variable (ticker) += 1
// Now we're going to grab the unit's current position and store it for later
Set variable Points[ticker] = Position of Unit (u)
}
After running that, every single unit's position in your map will be saved in your point variable. I'm not sure how your map is set up specifically, but if there are more units than the 189 you want to respawn, then you're going to somehow only loop through the ones you want. Finally, if your units are all different types, you can save their type just like we save their point.
To respawn everything:
For each integer x from 1 to 189
{
Create unit (my unit) at point (Points[x])
}
Much easier than explicitly identifying 169 points- that wouldn't be fun! :)
Rollback Post to RevisionRollBack
Feel free to Send me a PM if you have any questions/concerns!
So you would have to place a dummy unit at each point, assign the point variable to that position and then remove the dummy unit? Well at least that is faster than putting them in a variable manually. And yes I also would like a "for each point" function and also "for each region"
If you created all the points after another, without adding additional objects (like other points or units) inbetween, then all of them should have a consecutive id. You cannot use that id in Gui, but you can make use of Galaxy Script to loop these points by their respective ids:
inti;for(i=1;i<189;i++){MyPoints[i]=PointFromId(i+Offset)//the offset depends on the number of objects on the map}
I want to place a unit in many spots all over the map and i want to run the trigger again when my level completes so the units re-spawn. the problem is i made a point in all the spots i want it, and there ate 189 points. Is there a way to place all of those without individually creating 1 unit at each point cause that would take hours.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
@fishy77: Go
If you already made the point then you can put them in a variable and then loop through it, creating a unit in each.
@LaxSalmon:
can you put multiple points in a variable? cause if not then it would take just as long as creating a unit at each point
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
@fishy77:
well the best thing i can do right now is to create the units at random points 189 times through a repeat. the only thing is that some points will probably have many units and some might have none.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
@fishy77: Go
Well in that case you could devide the map into smaller regions and place units randomly in those. That way they will be more consistent throughout the map.
@LaxSalmon:
well actually it doesnt spawn them in the points i placed for some reason... it just randomly places then around the map.
New to the Editor? Need a tutorial? Click Here
Want data assets? Click Here
@fishy77: Go
That's the point of the random point function (Pun not intended). Pre placed points aren't random.
And you can use variable arrays for multiple values. Create a point variable, give its first index the size of 189, then use "set variable" at map init and set each slot of the variable to one of your pre placed points. After that just use "For each integer X from 1 to 189", "Create unit at PointArray[X]"
@TheAlmaity: Go
I think he wanted to avoid doing all that work. Maybe there is a way to get the preplaced points without adding them to a variable? But I don't think so, at least I haven't found it.
@LaxSalmon: Go
What you are looking for is a function that grabs a random point, which does not require you to specifically assign each point to a variable or individually name it somehow. In other words, some kind of 'for each point' function. As far as I know, no function like that exists- because if it did, I'd be very happy :)
That said, I do have one idea that *may* just work ^.^
After running that, every single unit's position in your map will be saved in your point variable. I'm not sure how your map is set up specifically, but if there are more units than the 189 you want to respawn, then you're going to somehow only loop through the ones you want. Finally, if your units are all different types, you can save their type just like we save their point.
To respawn everything:
Much easier than explicitly identifying 169 points- that wouldn't be fun! :)
I could think of a way to do it randomly, even though zelda has a good way to do it so I wont explain it, also, mine would have taken a bit more work.
@zeldarules28: Go
So you would have to place a dummy unit at each point, assign the point variable to that position and then remove the dummy unit? Well at least that is faster than putting them in a variable manually. And yes I also would like a "for each point" function and also "for each region"
If you created all the points after another, without adding additional objects (like other points or units) inbetween, then all of them should have a consecutive id. You cannot use that id in Gui, but you can make use of Galaxy Script to loop these points by their respective ids: