- Joined
- May 23, 2008
- Messages
- 148
Alright, so we want some more randomness in our map. Well, there's a way to make your terrain be shaped a bit randomly at every instance of the game. The idea is simple: execute multiple random permanent terrain deformations. We will need a region to have the changes applied and that would be pretty much everything if it were to be a one-shot map.
Note 1: Radii and depths are also random. Obviosly you might use different ranges for them. My advise is not to exaggerate them as it might result in unnatural looks of the generated terrain ('spikes', sharp edges, too deep depressions, etc). You might want to have some deep valley (it looks cool if custom fog kicks in and you can really feel the distance) apart from the general terrain. In that case just copy the trigger and give few tries to other parameters (e.g. only negative depths with high values).
Note 2: The number of deformations totally depends on the size of the region and the extent of randomness we want to achieve (I would advise 300+ in a general case).
Note 3: The trigger is executed at Map Initialization, so it will affect the loading time (in some cases even greatly). On my few maps I made it fire during the game-time periodically for a certain number of iterations and with random deformation time (not 0.01 seconds ^^) . Players had the chance to actually see how the terrain is formed over time (along with trees slowly growing from the ground, patches of grass popping out as well as debris, flowers, shells and other stuff ). So consider it as an option as well.
Note 4: Outer part of the region (approximately the average radius length away from edges) will be less affected than the other parts of the region.
Okay, now we've got a nice terrain. Unfortunately, when we save the game and load it later on, all the deformations are 'forgotten'. If we want to be more professional, we have to handle this problem. Once again, the concept is simple: we will save all the parameters in variables (arrays of them).
We have to change the terrain generator to:
Note 5: You don't have to predict the size of arrays, they might the size of 4 and even if you need access to 4735th position, Warcraft will handle this. However, the arrays have a limit of 8192 capacity, so don't set the NumberOfDeformations over 8192 .
Now, the trigger regenerating the original terrain after loading the saved game:
Should work just fine. That's all.
Have fun with your custom randomized maps.
Jees, this forum surely could use some 'horizontal line' thingie.
Variables:
TheRegion <gen> - the region to be deformed
TheRegion <gen> - the region to be deformed
-
TerrainGenerationSimple
-
Events
- Map initialization
- Conditions
-
Actions
-
For each (Integer A) from 0 to 459, do (Actions)
-
Loop - Actions
- Environment - Create a 0.01 second Permanent crater deformation at (Random point in TheRegion <gen>) with radius (Random real number between 500.00 and 1100.00) and depth (Random real number between -40.00 and 40.00)
-
Loop - Actions
-
For each (Integer A) from 0 to 459, do (Actions)
-
Events
Note 1: Radii and depths are also random. Obviosly you might use different ranges for them. My advise is not to exaggerate them as it might result in unnatural looks of the generated terrain ('spikes', sharp edges, too deep depressions, etc). You might want to have some deep valley (it looks cool if custom fog kicks in and you can really feel the distance) apart from the general terrain. In that case just copy the trigger and give few tries to other parameters (e.g. only negative depths with high values).
Note 2: The number of deformations totally depends on the size of the region and the extent of randomness we want to achieve (I would advise 300+ in a general case).
Note 3: The trigger is executed at Map Initialization, so it will affect the loading time (in some cases even greatly). On my few maps I made it fire during the game-time periodically for a certain number of iterations and with random deformation time (not 0.01 seconds ^^) . Players had the chance to actually see how the terrain is formed over time (along with trees slowly growing from the ground, patches of grass popping out as well as debris, flowers, shells and other stuff ). So consider it as an option as well.
Note 4: Outer part of the region (approximately the average radius length away from edges) will be less affected than the other parts of the region.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Okay, now we've got a nice terrain. Unfortunately, when we save the game and load it later on, all the deformations are 'forgotten'. If we want to be more professional, we have to handle this problem. Once again, the concept is simple: we will save all the parameters in variables (arrays of them).
We have to change the terrain generator to:
Variables:
NumberOfDeformations - (integer) self explanatory
TheRegion <gen> - the region to be deformed
RandomPoint - (point) - position of currently applied deformation
RandomRadius - (real) - radius of current deformation
RandomDepth - (real) - depth of current deformation
Points - (array of points) - saving all positions here
Radii - (array of reals) - saving all radii here
Depths - (array of reals) - saving all depths here
NumberOfDeformations - (integer) self explanatory
TheRegion <gen> - the region to be deformed
RandomPoint - (point) - position of currently applied deformation
RandomRadius - (real) - radius of current deformation
RandomDepth - (real) - depth of current deformation
Points - (array of points) - saving all positions here
Radii - (array of reals) - saving all radii here
Depths - (array of reals) - saving all depths here
-
TerrainGeneration
-
Events
- Map initialization
- Conditions
-
Actions
- Set NumberOfDeformations = 460
-
For each (Integer A) from 0 to (NumberOfDeformations - 1), do (Actions)
-
Loop - Actions
- Set RandomPoint = (Random point in TheRegion <gen>)
- Set RandomRadius = (Random real number between 500.00 and 1100.00)
- Set RandomDepth = (Random real number between -40.00 and 40.00)
- Set Points[(Integer A)] = RandomPoint
- Set Radii[(Integer A)] = RandomRadius
- Set Depths[(Integer A)] = RandomDepth
- Environment - Create a 0.01 second Permanent crater deformation at RandomPoint with radius RandomRadius and depth RandomDepth
- Custom script: call RemoveLocation(udg_RandomPoint)
-
Loop - Actions
-
Events
Note 5: You don't have to predict the size of arrays, they might the size of 4 and even if you need access to 4735th position, Warcraft will handle this. However, the arrays have a limit of 8192 capacity, so don't set the NumberOfDeformations over 8192 .
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, the trigger regenerating the original terrain after loading the saved game:
-
TerrainReGeneration
-
Events
- Game - A saved game is loaded
- Conditions
-
Actions
-
For each (Integer A) from 0 to (NumberOfDeformations - 1), do (Actions)
-
Loop - Actions
- Environment - Create a 0.01 second Permanent crater deformation at Points[(Integer A)] with radius Radii[(Integer A)] and depth Depths[(Integer A)]
-
Loop - Actions
-
For each (Integer A) from 0 to (NumberOfDeformations - 1), do (Actions)
-
Events
Should work just fine. That's all.
Have fun with your custom randomized maps.
Jees, this forum surely could use some 'horizontal line' thingie.
Last edited: