Staredit Network > Forums > SC2 Assistance > Topic: Random Point in Region
Random Point in Region
Sep 14 2010, 12:31 am
By: payne  

Sep 14 2010, 12:31 am payne Post #1

:payne:

Well, I thought the "Random Point in Region" function was selecting an actual Point you had placed on the map, but it looks like it really just sets some random numbers in a (X,Y) coordinate.
Is there any way to do a "real" Random Point in Region function?

I always thought the Spawn systems were done with this function. :/



None.

Sep 14 2010, 12:39 am Temp Post #2



You would need a way to keep track of all the points in the region :/



None.

Sep 14 2010, 10:27 pm Sand Wraith Post #3



My solution:

1) Enumerate all relevant Points (tag each Point with an integer, in order).
2) Select a random integer and convert it to the corresponding Point.

To be more specific, you should have:
-a tracking variable, say randN.
-an array of Points, say arrayPoints.

In one trigger, at the start of the game (or whenever), assign each relevant Point on the map to an index of arrayPoints.
In a second trigger, you would do set randN to "Random integer between <minimum index of arrayPoints> and <maximum index of arrayPoints>", then "Create a unit at point<arrayPoints[randN]"




Sep 15 2010, 12:56 am Roy Post #4

An artist's depiction of an Extended Unit Death

If the points are in a linear pattern, you could just have one point plus random offsets.




Sep 15 2010, 4:54 am payne Post #5

:payne:

I've made this for now.
http://www.staredit.net/starcraft2/Spawn_system

Anyone has ideas on how to improve this? Lets say I'd have 100 points... isn't there a way to -not- make me waste hours in this trigger?



None.

Sep 15 2010, 9:31 am Ahli Post #6

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

Quote from payne
I've made this for now.
http://www.staredit.net/starcraft2/Spawn_system

Anyone has ideas on how to improve this? Lets say I'd have 100 points... isn't there a way to -not- make me waste hours in this trigger?
Except that you could use Arrays? not that I would know one :S




Sep 15 2010, 2:13 pm Temp Post #7



Using array would be a big improvement to the trigger but would require you to also populate the trigger before hand (so another trigger with a number of actions equal to the number of points).



None.

Sep 15 2010, 2:33 pm payne Post #8

:payne:

I'm still not very comfortable with Arrays (while I know they are simple >_>). Any example/wiki? :awesome:



None.

Sep 15 2010, 2:45 pm Temp Post #9



Quick example

have an array variable where the size of the array is equal to the number of points you have.

Then have a trigger where you set each index in the array to a different point that runs on init.

Then in your spawn trigger pick a random number >=0 and <= size of the array - 1. When you go to get the point you do not need an if statement and can simply go Set select point = PointArray[RandomNumber].



None.

Sep 15 2010, 2:48 pm Ahli Post #10

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

Array:
An Array has a length/size. It is set when it was created and cannot be changed.
You can read/write values with the index number. These start with 0 and go up to size-1.

Example:
An Array "test" with a size 5 is created. With test[0] you can access the first value, with test[1] the second, with test[4] the last entry.




Sep 15 2010, 10:39 pm payne Post #11

:payne:

And I guess I can put Maths functions linked to Variables as an Array?



None.

Sep 17 2010, 6:35 pm Ahli Post #12

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

Quote from payne
And I guess I can put Maths functions linked to Variables as an Array?
ewwwww... I don't understand you... you can't put a function into arrayys... only variables...

Array is simply a bunch of variables of equal type below each other with an index (just like a key) to access the variables.

As an example, you could store mineral and gas values of all players in an array created like this: ressources[16][2]... (the indexes would be "player#" [0; 15] and ressource type (minerals; gas) [0;1] in this example.
You would access the gas ressources for player 4 like this: "ressources[3][1]".




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: O)FaRTy1billion[MM], Mr.BurnLiquid