In the map I'm working on, I want to make tons of stuff randomized. it include the following and many more to come...
Bridge location, mineral/gas amount on the mineral field/gas geiser, enemie units spawning points, presence of unit / item / buildings or not
I'm encountering lots of problems while basing a map gameplay on random stuff. I discovered that random must still be not sooooo random...
First exemple : Here is a trigger to create a mineral field containing a andom amount of mineral situated in a region which is on a random point of the playable area... Basically, the mineral could be anywhere, but I discovered that it needed some restriction.
The up to date is that I want to restrict the random region placement (mineral field) to playable area minus a region in the center of the map. In other words, the mineral can be anywhere exept to restricted area which are region (or will be I suppose)
Here is the trigger up to date... I searched a lot in condition, but ound nothing like : If X Region is in Y Region = true (do not spawn mineral)
I think the easiest way is to look at your region (Mineral Agglomeration 1) and set it up in the way you see fit by adding extra rectangles/circles. You can make a square with an empty gap in the center by having 4 rectangles.
Yea, there is a geometrical way to make a square with a hole in the center, but thats not what I'm searching for, Even then, I still don't know how to make a trigger choose randomly between 4 regions.
I'm sure there is a simpler way to acheive this, no?
I'm sure there is a simpler way to acheive this, no?
Region properties> set it to negative instead of positive. Negative regions are meant to be removed from positive regions, so if you do a huge square region positive, you can remove any shape you want from it by adding negative regions on top of it. Haven't tried yet, but I'm pretty sure it's how it works.
Finally, it's not working properlly. The negative region doesn't do his job and some stuff still spawn in it...
I looked if it would be a staking problem and if I had to specifie which region was on top... But I don't find it. Maybe the problem is somewhere else?
The way you do "negative" regions is not by placing multiple regions, you place ONE region.
Then double click the region to open up its properties, and click on the "Shapes" tab. Add a new shape (Circle or rectangle, whatever fits best), set it's center and size, and then set it to negative and press ok. You'll see that the previously placed region will now have a hole in it exactly where you placed the negative shape in it. The negative shape won't affect any other regions except the region it belongs to.
However, that doesn't change the fact that RegionRandomPoint has a difficult time getting a point when your region looks like swiss cheese.
I think after 32 (or 16 ?) unsuccessful attempts it just gives up.
See Blizzard's comments in the API:
Quote:
RegionRandomPoint attempts to find a random point somewhere within the region. For regions containing only a single positive shape, this is guaranteed to work, but for more complex sets of shapes it may give up after a maximum number of tries and return (0, 0).
Ok, thanks. Random point has a chance of not working then, but i wanted to point out the mistake they made why the negative region part of the swiss cheese didn't work.
Cheese... *drool*
Anyways, in that case, go with "point with polar offset" as soulcarver suggested. Works almost the same way, except it's circular and can't fail due to negative regions.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
In the map I'm working on, I want to make tons of stuff randomized. it include the following and many more to come...
Bridge location, mineral/gas amount on the mineral field/gas geiser, enemie units spawning points, presence of unit / item / buildings or not
I'm encountering lots of problems while basing a map gameplay on random stuff. I discovered that random must still be not sooooo random...
First exemple : Here is a trigger to create a mineral field containing a andom amount of mineral situated in a region which is on a random point of the playable area... Basically, the mineral could be anywhere, but I discovered that it needed some restriction.
The up to date is that I want to restrict the random region placement (mineral field) to playable area minus a region in the center of the map. In other words, the mineral can be anywhere exept to restricted area which are region (or will be I suppose)
Here is the trigger up to date... I searched a lot in condition, but ound nothing like : If X Region is in Y Region = true (do not spawn mineral)
Anybody already faced that problem? The map called Stranded on Krydon had such a tigger...
I think the easiest way is to look at your region (Mineral Agglomeration 1) and set it up in the way you see fit by adding extra rectangles/circles. You can make a square with an empty gap in the center by having 4 rectangles.
@rkmx52: Go
Yea, there is a geometrical way to make a square with a hole in the center, but thats not what I'm searching for, Even then, I still don't know how to make a trigger choose randomly between 4 regions.
I'm sure there is a simpler way to acheive this, no?
Region properties> set it to negative instead of positive. Negative regions are meant to be removed from positive regions, so if you do a huge square region positive, you can remove any shape you want from it by adding negative regions on top of it. Haven't tried yet, but I'm pretty sure it's how it works.
@ZealNaga: Go
It's working perfectly.
Now next Question about random stuff...
I whish to integrate a lot of it in the gameplay and make some event only happen once every 3-4 game. Something like :
Map initialisation Generate random real between 0 and 100
If integer is = or less than 30, spawn ultralisk at random point on playable area if integer is more than 30, do nothing
Turn off current trigger
___
I Made it :
Random Rich Mineral Field Spawn Integer 1 = (Random integer between 0 and 100) <Integer>
Do not random points from regions with negative areas.... It causes serious issues.
@SouLCarveRR: Go
Tx for the advice, I wont be doing it.
Right now, I'm just randoming point in area less a negative region. The region in which I random point is a positive. Should not be causing problem...
@ZealNaga: Go
Finally, it's not working properlly. The negative region doesn't do his job and some stuff still spawn in it...
I looked if it would be a staking problem and if I had to specifie which region was on top... But I don't find it. Maybe the problem is somewhere else?
@Claymuffin: Go
Bump up
Why is the negative region not working at all?
I'm clueless... Isn't there any topic here about negative regions and how they work? I'd suggest you take a look, if you haven't already.
@ZealNaga: Go
what you should do is .....
random point = point with polar off set of "x" from point
This allows you to set a random angle from another point and a random distance off set form a specific point such as the center of the map
Heres a link to more info that might help you its a topic of mine I had going.
http://forums.sc2mapster.com/development/triggers/15555-trigger-gui-random-point-failure/
Stranded on Krydon does it, it hasn't broken yet.
Then again, the regions aren't very complex.
The way you do "negative" regions is not by placing multiple regions, you place ONE region.
Then double click the region to open up its properties, and click on the "Shapes" tab. Add a new shape (Circle or rectangle, whatever fits best), set it's center and size, and then set it to negative and press ok. You'll see that the previously placed region will now have a hole in it exactly where you placed the negative shape in it. The negative shape won't affect any other regions except the region it belongs to.
@TheAlmaity: Go
However, that doesn't change the fact that RegionRandomPoint has a difficult time getting a point when your region looks like swiss cheese.
I think after 32 (or 16 ?) unsuccessful attempts it just gives up.
See Blizzard's comments in the API:
@s3rius: Go
Ok, thanks. Random point has a chance of not working then, but i wanted to point out the mistake they made why the negative region part of the swiss cheese didn't work.
Cheese... *drool*
Anyways, in that case, go with "point with polar offset" as soulcarver suggested. Works almost the same way, except it's circular and can't fail due to negative regions.