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:

Code
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.



None.

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.

edit:
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...



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[02:53 am]
Mr.BurnLiquid -- Symmetry
Symmetry shouted: I'll check it out this weekend!
Thanks
[02:47 am]
Symmetry -- I'll check it out this weekend!
[02:40 am]
Mr.BurnLiquid -- Symmetry
Symmetry shouted: Another map maker? Damn we really ARE back
I invite you to try out the map I modified. I don't have the creativity to create maps from scratch, but I do have the know-how to modify existing ones; my project is to tweak community campaigns (specifically those with errors—to make them playable.
[02:27 am]
Symmetry -- Another map maker? Damn we really ARE back
[01:51 am]
Mr.BurnLiquid -- Ultraviolet
Ultraviolet shouted: Mr.BurnLiquid actually yeah though I wasn't really saying it to narc on you. It just caught me off guard because I don't usually see it (because it's against the rules) "The avatar may not be bigger than 150x150 pixels". Kinda silly that it relies on users to be well behaved rather than just limiting the dimensions on uploads :lol:
Now that I wanted to change my avatar, the error image is showing up, haha.
[01:34 am]
Mr.BurnLiquid -- Ultraviolet
Ultraviolet shouted: Mr.BurnLiquid actually yeah though I wasn't really saying it to narc on you. It just caught me off guard because I don't usually see it (because it's against the rules) "The avatar may not be bigger than 150x150 pixels". Kinda silly that it relies on users to be well behaved rather than just limiting the dimensions on uploads :lol:
Mr.BurnLiquid
Mr.BurnLiquid shouted: Ultraviolet Thanks; I'm new to the site and a Spanish speaker. I must have missed the part where it was prohibited—I'll change it now.
I invite you to try out a mission I'm modifying from *StarCraft Reversed*; I'm trying to make it more playable and challenging.
[01:33 am]
Mr.BurnLiquid -- Ultraviolet
Ultraviolet shouted: Mr.BurnLiquid actually yeah though I wasn't really saying it to narc on you. It just caught me off guard because I don't usually see it (because it's against the rules) "The avatar may not be bigger than 150x150 pixels". Kinda silly that it relies on users to be well behaved rather than just limiting the dimensions on uploads :lol:
Thanks; I'm new to the site and a Spanish speaker. I must have missed the part where it was prohibited—I'll change it now.
[01:31 am]
Ultraviolet -- Mr.BurnLiquid
Mr.BurnLiquid shouted: Ultraviolet Is it forbidden to have a large avatar?
actually yeah though I wasn't really saying it to narc on you. It just caught me off guard because I don't usually see it (because it's against the rules) "The avatar may not be bigger than 150x150 pixels". Kinda silly that it relies on users to be well behaved rather than just limiting the dimensions on uploads :lol:
[12:20 am]
Mr.BurnLiquid -- Ultraviolet
Ultraviolet shouted: https://staredit.net/profile/133367/ dude's avatar is massive
Is it forbidden to have a large avatar?
[12:04 am]
Ultraviolet -- https://staredit.net/profile/133367/ dude's avatar is massive
Please log in to shout.


Members Online: UndeadStar, Ultraviolet