 |   |  |  |
Miscellaneous Tutorials Warcraft III tutorials that do not fit into any other category. Read the Rules before posting. |
 |
05-23-2008, 08:57 AM
|
#1 (permalink)
|
WorldEditor Lame'O
Join Date: May 2008
Posts: 101
|
Random terrain geometry
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.
Variables:
TheRegion <gen> - the region to be deformed
 TerrainGenerationSimple 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
 TerrainGeneration 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 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 by Dagguh; 05-23-2008 at 09:07 PM..
Reason: memory leak
|
|
|
05-23-2008, 04:38 PM
|
#2 (permalink)
|
WorldEditor Lame'O
Join Date: May 2008
Posts: 101
|
Malfunctions
Important (an overgrown note 6): when a terrain deformation is applied, it doesn't affect buildings nor some units. They will behave as if the terrain was not changed, what can result in e.g. siege tanks driving in the air (and leaving trackprints in the air), flying units hovering under the ground, buildings hanging in the air etc.
Q: Which units particularily are effected?
A: All flying units, all buildings that were created before the deformation, all units with Art - Elevation Sample Points value different than 0 (this parameter determines how well the unit's animation is handling the curves of the terrain).
Q: What can be done about it?
A:- Generally: Don't exaggerate the deformation's heights. Anything above 100 is much as for my opinion.
- About buildings: Well, you can remove it by triggers and instantly recreate it. It shall correct its position.
- About units with Elevation Sample Points: You can set this paramerer to 0 in the Object Editor. However, it will affect the unit's animation on uneven terrain (like having Siege Tanks' model all the time rotated horizontally in the opposition to default slope.
- About flying units: nothing helpful can be done. At your best you might try to manually change flyers flying height so that it doesn't collide with the ground (e.g. defalt flying height + maximum expected peak), but it is a half-measure.
You might also notice, that in extreme cases, you might see black areas far away when having your camera slided down. It's just like the World Editor's view distance limit, which can be adjusted by CTRL+MOUSEWHEEL. You can fix that in-game by changing the camera's Far Z parameter. FarZ To be 100% sure you will not see black areas, lets assume the most pessimistic case. That is: you are looking through the map's diagonal. Then set the Far Z to (MapWidth2 + MapHeight2)0.5. On the other hand, the higher value Far Z has, the worse is the performance (I wouldn't care much about it, though... unless you are playing on Commodore64 or a really unoptimized map).
Oh and you can save more than 8192 deformations by using extra arrays, but what is the point... 
|
|
|
05-23-2008, 06:28 PM
|
#3 (permalink)
|
adv. triggers and modelin
Join Date: Apr 2008
Posts: 159
|
nice thank you 
|
|
|
07-19-2008, 02:01 AM
|
#4 (permalink)
|
Community Director
Hive - The Helper Liaison
Join Date: Feb 2008
Posts: 1,263
|
[hr]50[/hr]
Parses to:
Well, this looks pretty good. Though, is there any way to reduce the page stretching that I'm getting? That would be nice.
Anyway, I think that this is is more of a How-To. But I am going to approve it.
__________________
Visit The Helper's City!
The Helper Administrator, The Area Administrator, Hive Administrator
"With the first link, the chain is forged. The first speech censured, the first thought forbidden, the first freedom denied, chains us all irrevocably."
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|  |  |  |  |   |  |
|