Staredit Network > Forums > SC2 Assistance > Topic: dynamic circular/polygonal boundary regions
dynamic circular/polygonal boundary regions
May 16 2011, 4:48 pm
By: NicholasBeige  

May 16 2011, 4:48 pm NicholasBeige Post #1

Hey, so the Trigger editor is my weakness! I hate it, it hates me. We get along just great.

What I want to do is this:

Create a building for each player in the game at a random point in the playable map area. But no two buildings can be within 24 range of each other. I can't get this to work, and this is the simple/easy part I believe.

I was doing something like this:

Create 1 building for Player 1 at random point in map
Set Building[1] to last created unit
Set Temp_Point == random point in map
Do While - Distance between Temp_Point & Building[1] is equal to <24
Set Temp_Point == random point in map
End Do While
Create 1 Building for Player 2 at TempPoint
Set Building[2] to last created unit

Then this was repeated for each of the remaining 4 players, with another condition being added to the Do While statement, with an 'And' thingy. Eg. When creating player 6's location, the While loop will keep randomising the point until it is further than 24 away from P1, P2, P3, P4 AND p5.

I realise that there might be rare cases in which it is impossible for player 6 to have a start location - so I was going about adding validation to check the number of attempts it has taken to give player 6 a home. And if the attempts was over 1000, i would reset and start again at player 1.

BUT, for some reason, the above trigger (as shown) would spawn 2 buildings for player 1, and 2 buildings for player 2 - they wouldn't be closer than 24 to each other but for some reason, the trigger having only 2 lines as 'Create Unit' would end up creating 4 units.

----------------------------------------------------------- I rage quitted my map editor at this point -----------------------------------

I'm going to rebuild it from scratch again and hopefully try and figure it out myself - but in the mean time if anyone has any clues, I'd love to hear em.

Later on, I would like to create a 'circle' of units around the building (I can do this fine), to make a boundary of that buildings 'influence'. However, if two players boundaries overlap (which is impossible in the starting instance due to the 24 range limit on how close they can spawn), then the boundary units will move to an average point between each of them. The reason for this is, later on in the game your main (starting) building can be upgraded to increase it's 'control radius' - which gives you more land to exploit (currently leaving your control radius reverts your units to AI control).


This is ultimately a sort of proof of concept for emulating features such as in Civilisation IV (Culture), and even the Settlers game series, where you would build structures at strategic points to choke off enemy 'control' and gain more resources.

Edit: I cannot use 'Regions' for this since they are too limiting in their shapes. Since, yes, at the start everyone has a perfect 'circle' of control, but as the map fills up, you might get squashed or stretched depending on other players expanding territories around yours.

I will also like to know how to calculate 'if a unit is in the region', although i'm not using a region, i'm using a circle/group of units to define a boundary. I presume I will have to calculate the distance between the nearest boundary unit (to the unit that to the Starting Building. And so, if the unit (being checked)'s distance is greater to the starting building than the nearest boundary's distance - it would be outside? am I right?

Post has been edited 1 time(s), last time on May 16 2011, 4:54 pm by Cardinal.


May 16 2011, 5:59 pm Ahli Post #2

I do stuff and thingies... Try widening and reducing the number of small nooks and crannies to correct the problem.

@ your ragequit
Programs won't do something without a good reason. Ragequitting is the wrong approach to solve/understand a problem.
I guess that you've had messed up your reset functionality because your approach seems fine.

Since I'm not an algorithm genius I can't give you a perfect solution. :(

But because you didn't hit the execution time limit (you didn't implement a wait every few thousand random point attempts).
So I guess you have enough space to get a working positioning after a few attempts.

You could fill the map with units at start, too. Then you pick a random one, create your building and remove every of these units within the radius. Then you pick another random one and do the same. If you have 0 units left, it failed.

At region checking:
I'm imagine what you describe as it is shown in Bluebyte's "The Settlers"'s games where 2 close ruler building's of different factions will result in a split in the controllable ground.
Your idea should work and I've no better idea right now.

Post has been edited 1 time(s), last time on May 16 2011, 6:11 pm by Ahli.

May 16 2011, 6:25 pm NicholasBeige Post #3

Well re: my ragequit... it was 4am and I had started off with the circular radius implementation, and detecting units with in it. Then I decided I wanted it to be random start points, so I tried to salvage bits of the triggers I had already done. I ended up with confusing For each Integer loops and wasn't naming my variables sensibly... Passing parameters like a noob and end result: not understanding my code. It was destined for failure.

I'm gonna play Terraria for a few days and then attempt it again, I always find when I'm triggering (coding) that I jump right in it and decide 'this is what I want to do'. But then it just gets messy. When I have made a successful system, I actually spent about 10 minutes writing down in notepad some pseudocode exactly how it would work and then just translated that into triggers.

I'm too impatient :P...


  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2020-10-19. : 7:29 am]
C(a)HeK -- sraw531
sraw531 shouted: GGmano just fyi, might be a good idea in the future to link to the thread in the shoutbox when you reference a new thread
here it is -
[2020-10-19. : 7:19 am]
sraw531 -- GGmano
GGmano shouted: i made a topic about it if anyone knows something about this please check the topic
just fyi, might be a good idea in the future to link to the thread in the shoutbox when you reference a new thread
[2020-10-19. : 4:46 am]
C(a)HeK -- SiberianTiger
SiberianTiger shouted: C(a)HeK yes correct it is a multiplayer map
Unfortunately, I don't have free time for multiplayer
[2020-10-18. : 10:06 pm]
SiberianTiger -- C(a)HeK
C(a)HeK shouted: GGmano I answered you as best I could
yes correct it is a multiplayer map
[2020-10-18. : 9:12 pm]
GGmano -- thanks c(a)hek
[2020-10-18. : 9:05 pm]
lil-Inferno -- mad AF
[2020-10-18. : 8:57 pm]
*KrayZee angrily uses a pen and fills in the circle for Joe Biden*
[2020-10-18. : 4:59 pm]
C(a)HeK -- GGmano
GGmano shouted: i made a topic about it if anyone knows something about this please check the topic
I answered you as best I could
[2020-10-18. : 2:01 pm]
GGmano -- i made a topic about it if anyone knows something about this please check the topic
[2020-10-18. : 2:00 pm]
GGmano -- hi all does anyone knows what difference save files does??
Please log in to shout.

Members Online: Roy, jun3hong, UndeadStar, IlyaSnopchenko