Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Random placement of units and buildings during gameplay
Random placement of units and buildings during gameplay
Apr 27 2025, 11:01 pm
By: sethmachine  

Apr 27 2025, 11:01 pm sethmachine Post #1



Hi,

I have a map where I randomly place enemy structures and units (the structures can spawn enemies and/or give rewards) over time. The placements are meant to be random to increase replayability and unpredictability each time. Ignoring edge cases (like not spawning inside someone's base), the simplest solution I've found is Junk Yard Dog with a small air unit, like Protoss Observer, that flies around the map and periodically drops these random units.

I know Warcraft 3/JASS for example solves this by allow you to simply generate random points within a region/location/radius. I wouldn't be surprised if EUDs allowed a similar approach, but for this discussion no EUD solutions.

That can work decently, but it has some flaws because players can follow the observer to find out where things will go, and I've heard that the Junk Yard Dog script isn't actually true random movement but tends to clump units in a certain direction (correct me if this isn't the case).

One alternative I've been considering is to have a set of "evenly" spaced locations around the map (e.g. think like N points evenly spaced out along/within a circle/location). At some interval T, go through each point and do the following:

* flip a (weighted) coin to decide if a unit should be spawned near that location
* if heads, create a small fast air unit like Scourge or Protoss Observer
* randomly choose another point/location as the destination for that air unit
* start a small death counter timer (you could randomize this too for added variability)
* when the timer ends, drop the payload at the air unit's location (e.g. move the spawned structure)

So I'm wondering if this sort of system has been used before. It's more complicated and requires tuning a lot of things: the weight of the coin flip, the terrain of the map (hard to place terrain is essentially making the coin flip more weighted in the tails/no spawn outcome), delay/time to allow air unit to move, which locations a source location can target, etc.

But I could see this solving the issue with the Junk Yard Dog / Protoss Observer approach.

What are other approches or thoughts here?

I did some "simulations" with Gemini. It's clearly not random but it does seem to cover many different places as shown in the diagram:

Attachments:
random-points-starcraft.png
Hits: 2 Size: 155.02kb
random-points-starcraft.png
Hits: 2 Size: 155.02kb

Post has been edited 1 time(s), last time on Apr 27 2025, 11:14 pm by sethmachine.



None.

Apr 28 2025, 8:25 am Sie_Sayoka Post #2



Without EUDs your approach of using JYD and iterations of it is a good idea. This problem has three points: the randomness, preventing predictability from the player (observer shimmer), and the system of getting a location at a random point on the map.

For the second and third point you could use a system that does not implement JYD. We will exploit the properties of locations to do this. Because locations cannot exit a map border, and because they always create a unit in the middle (if there's space) we can use this to place a unit anywhere on the map, albeit in a grid although it can be fine tuned depending on the number of locations and units. To recycle locations we have a row of units on the top and bottom (or left and right) on the map borders.



Centering a location on a unit will create the desired unit in its middle. The location can be centered on both top and bottom rows of units. Because there are no EUDs doing a large area would run into issues of both location and unit type limits.

A step further would be to implement JYD and have the units on the border use JYD in a small box to give even more randomness as well as an imprecise grid.

A variation of this system would depend on the frequency you need the action to be performed. If it's low frequency then you can save on unit types by just having horizontal lanes on the top and bottom map borders. Then you can have a few units randomly created that go from left to right (or vice versa) and center the location when needed.

Post has been edited 2 time(s), last time on Apr 28 2025, 10:52 am by Sie_Sayoka.



None.

Apr 29 2025, 8:35 am SPyro_Malin Post #3



I did exactly this with JYD for ny brother's C&C themed map and it used one of the Kakaru's (there was couple of them and only one had location permanently attached to it).

Also I wanted to suggest exactly what Sayoka said - long locations. This is a very good system.

I'm going to state the obvious: remember to spawn the building on a placeholder location and then have it moved towards the desired location until it is actually moved there. Otherwise you can spam the error placement for the players if it was put on not-buildable terrain.

You could use 2 sets of randomized, long locations: Horizontal and Vertical. Unit spawning in the middle of Horizontal location and having move order towards middle of Vertical location - try to move the building you want to spawn while the unit is on the way.
You can have a switch which prevents placing the building if player base is too close as well (something like 10x10 location centered on that unit). If you do this make sure to create a fail save - restart the process if unit reached the destination location without spawning the building.

Edit: To not have ugly units stuck on the sides of map you could use 2 cloaked units with different speeds (by default Observer and Wraith) patrolling along the edge of map and use simple switches to randomly use Wraith or Observers position (different speeds, more randomness and it's less units used).

You could also prepare any amount of locations and just use switches to randomly determine which one is used as spawn point. While very simple, this solution guarantees that the building won't be spawned in inaccessible location like small island, cliff ect and it doesn't look weirdly out of place.

Post has been edited 1 time(s), last time on Apr 29 2025, 3:59 pm by SPyro_Malin.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[11:30 am]
NudeRaider -- I would like 3000 minerals, please
[07:32 pm]
Zoan -- I got $2000 bonus. I would like 2000 minerals, please
[2026-4-16. : 4:15 am]
DarkenedFantasies -- you eat lots of beans
[2026-4-16. : 3:46 am]
IskatuMesk -- how do i get gas
[2026-4-15. : 11:43 pm]
Moose -- you don't
[2026-4-15. : 10:06 pm]
Zoan -- how do i get minerals
[2026-4-14. : 11:45 pm]
ClansAreForGays -- Anyone wanna played Skewed StarCraft?
[2026-4-14. : 12:07 am]
Vrael -- NudeRaider
NudeRaider shouted: Vrael ranting still is though
you're a gentleman and a scholar, thank you
[2026-4-13. : 10:07 pm]
NudeRaider -- ya why phone people when you can just write letters
[2026-4-13. : 9:37 pm]
IskatuMesk -- I have never and will never own a phone
Please log in to shout.


Members Online: Roy