(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Tutorials > Miscellaneous Tutorials

Miscellaneous Tutorials Warcraft III tutorials that do not fit into any other category.
Read the Rules before posting.

Reply
 
LinkBack Thread Tools Display Modes
Old 05-23-2008, 08:57 AM   #1 (permalink)
 
Dagguh's Avatar

WorldEditor Lame'O
 
Join Date: May 2008
Posts: 101

Dagguh has little to show at this moment (10)Dagguh has little to show at this moment (10)


Work In Progress 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
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)
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
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)
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)]
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
Dagguh is offline   Reply With Quote
Old 05-23-2008, 04:38 PM   #2 (permalink)
 
Dagguh's Avatar

WorldEditor Lame'O
 
Join Date: May 2008
Posts: 101

Dagguh has little to show at this moment (10)Dagguh has little to show at this moment (10)


Exclamation 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
Events
Map initialization
Conditions
Actions
Player Group - Pick every player in (All players) and do (Actions)
Loop - Actions
Camera - Set (Picked player)'s camera Far Z to 9000.00 over 0.00 seconds
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...
Dagguh is offline   Reply With Quote
Old 05-23-2008, 06:28 PM   #3 (permalink)
 
mokkil123's Avatar

adv. triggers and modelin
 
Join Date: Apr 2008
Posts: 159

mokkil123 has little to show at this moment (5)


nice thank you
__________________
mokkil123 is offline   Reply With Quote
Old 07-19-2008, 02:01 AM   #4 (permalink)
Community Director
 
Ghan_04's Avatar

Hive - The Helper Liaison
 
Join Date: Feb 2008
Posts: 1,263

Ghan_04 is just really nice (395)Ghan_04 is just really nice (395)Ghan_04 is just really nice (395)Ghan_04 is just really nice (395)Ghan_04 is just really nice (395)


[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."
Ghan_04 is offline   Reply With Quote
Reply

Bookmarks

Tags
terrain, trigger

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Trigger] Random not random...\ too many player spawns Big Dub Triggers & Scripts 4 07-03-2008 06:44 AM
Supermj's Random Terrain Generator Supermj Map Development 31 03-04-2008 02:10 AM
Random Terrain Generator Chaos Overlord Triggers & Scripts 6 07-06-2007 07:41 PM
Random Integer not being random?? xD.Dunedain Triggers & Scripts 8 07-03-2006 10:11 AM
Are random numbers random? Dr Super Good Map Development 3 03-23-2005 03:29 AM

All times are GMT. The time now is 09:17 AM.






Your link here 
Guitar Lessons | 3dge Viral Emails | Loan | Debt Consolidation | Debt Consolidation
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle