You must be logged in to post messages.
Please login or register

AI & RM Scripting
Moderated by Leif Ericson

Hop to:    
Welcome! You are not logged in. Please Login or Register.1 reply
Age of Kings Heaven » Forums » AI & RM Scripting » creating new forest-types using User-Patch
Bottom
Topic Subject:creating new forest-types using User-Patch
HenkDeSuperNerd
Squire
posted 08-25-18 10:21 PM CT (US)         
-----------------------------------------------------

creating new forest-types using User-Patch

Userpatch 1.5 enables the feature of upgrading a unit type in random map scripts. This can be used to create many different types of (new) forests.

Today I wanna show a neat trick that will open a huge number of new forest types. This is especially useful when using WololoKingomds which is limited to a small number of terrain-ID's. With the current version of WololoKingdoms it is impossible to create the Rainforest and Dragon Forest terrains.
Ofcourse, by using SLP files you can change other forest-types appearance into these kind of expansion-forests but that would require the addition of slp, which has the disadvantage of not succesfully being nested in if-statements.

However using the upgrade-unit feature will provide a solution for this.

I've used the custom forest-types in a number of maps I've created:
- REDv2 (enables dragon forest and rain forest)
- ECLTreasureIslands (enables rainforest)
- ECLRiftValley (enables a new forest type which consists of dragon trees that are sparsely scattered on the baseterrain of Baobab forest: the red-green dirt mixture known as dirt4 in the expansions)
- ForestNothing2018 (enables a huge variety of custom forest types)

(see my topic about Forest Nothing 2018 here:

)


Introduction of the different type of trees

In every random map there are two possible sources of trees:
- straggler trees
- forest trees

The straggler trees are objects that can be placed in the OBJECT_GENERATION part of the script. The straggler trees can be placed on any terrain that can support them, which can result in funny combinations such as snow-pine trees on desert terrain.
Straggler trees are unique in that they can be deleted once they are chopped down. Placing a building foundation over a half-chopped straggler tree will remove that tree.

There are two sub-classes within the straggler trees:

a) standard Straggler Trees: these can be cut by Siege, since they have a blast-defense-level of 1. Any of the standard forest terrain types also has a straggler tree. these straggler trees have multiple visual variants (many of the forests created as terrains show a variety of different trees)

All standard trees are:

BAMBOO_TREE, BAMBOO_FOREST_TREE
JUNGLETREE, JUNGLE_TREE
OAKTREE, FOREST_TREE, OAK_FOREST_TREE
PALMTREE, PALM_FOREST_TREE
PINETREE, PINE_FOREST_TREE
SNOWPINETREE, SNOW_PINE_TREE

and the Trees/bushes from the expansions (with the constants for WololoKingdoms):

#const bush 302
#const DLC_ACACIATREE 1063
#const DLC_AFRICANBUSH 1053
#const DLC_AFRICANBUSH_2 1054
#const DLC_BAOBABTREE 1052
#const DLC_DRAGONTREE 1051
#const RAINFOREST_TREE 1146
#const MANGROVE_TREE 1144
most of the trees have these stats: 20hp and 100wood.
However, there are a few exceptions:
Baobab: has 200wood
Acacia: has 150wood
Forest Tree: they look like oak-forest-trees but the forest-tree has 30hp instead of 20hp!

b) Unique straggler trees: these straggler trees have only 1 variant and CAN NOT BE CUT BY SIEGE, , since they have a blast-defense-level of 0.

TREE_A, TREE1, TREE_TD
TREE_B, TREE2
TREE_C, TREE3
TREE_D, TREE4
TREE_E, TREE5
TREE_F
TREE_G
TREE_H
TREE_I
TREE_J
TREE_K
TREE_L


The Forest trees are trees that are generated with terrain. The terrain can be placed in the random mapscript from TERRAIN_GENERATION, from LAND_GENERATION and even in the CONNECTION_GENERATION part.

The types of forests are (terrain IDs from WololoKingdoms):

#const FOREST 10
#const PALM_DESERT 13
#const BAOBAB_FOREST 16 /* also spawns as 'cliff-grass' */
#const JUNGLE 17
#const BAMBOO 18
#const PINE_FOREST 19
#const MANGROVE_FOREST 20 /* previously was 'Oak Forest' */
#const SNOW_FOREST 21
#const ACACIA_FOREST 41 /* previously was grass which was black on minimap */

Jungle, bamboo, Pine Forest, oak forest, and forest all has the LEAVES terrain as underlying soil. Once the trees are cut the minimap still shows the dark green color of Forest.

Palm desert has DESERT as underlying terrain

Snow Forest has GRASS_SNOW as underlying terrain.

Acacia forest has a ~50% coverage of trees. The underlying terrain is Savannah

Baobab forest has a ~25% coverage of trees. The underlying terrain is Dirt4 (green-red soil mixture)

Mangrove forest has a ~75% coverage of trees. The underlying terrain is Mangrove Shallow.

--------------------------------------------------------

using the UPGRADE_UNIT function

By using the upgrade function (UPGRADE_UNIT, or GAIA_UPGRADE_UNIT), the type of tree in a forest can be interchanged. This is very useful to create some unique forest types and to imitate the HD-forest types such as dragon forest and rainforest that are not available in WololoKingdoms.

The code to achieve this looks like this:
effect_amount GAIA_UPGRADE_UNIT FOREST_TREE RAINFOREST_TREE 0



This line will replace ALL forest trees with the Rain forest tree. This means that everywhere where the mapscript generates forests (terrainID 4) it will replace the forest-trees with rain-forest trees. Also, any forest-tree stragglers will be replaced by rainforest trees.

likewise it is possible to create more unique forests. Since the BAOBAB forests only have ~25% coverage, replacing baobab trees with pine trees would result in sparsely covered pine forests:

effect_amount GAIA_UPGRADE_UNIT DLC_BAOBABTREE PINE_FOREST_TREE 0



It is even possible to replace the trees of certain forests by some invisible object which has no interaction. This would in practice lead to the deforestation of a certain forest-terrain, which can be used to get acess to the Savannah terrain (replace acacia trees) or the dirt4 terrain (replace baobab terrains)

There are many different combinations to make where you can use the underlying soil of forests:

- desert + your tree of choice (by using palm_desert and upgrade palm_trees into another type of tree)
- leaves + your tree of choice (by using forest/jungle/etc and upgrade forest trees/jungle trees/etc into another type of tree)
- snowy grass + your tree of choice (by using snow pine forest and upgrade snow pine trees into another type of tree)
- savannah + your tree of choice (by using acacia forest and upgrade acacia trees into another type of tree. NOTE: the forest will remain a 50% coverage)
- dirt4 + your tree of choice (by using baobab forest and upgrade baobab trees into another type of tree. NOTE: the forest will remain a 25% coverage)
- mangrove shallow + your tree of choice (by using mangrove forest and upgrade mangrove trees into another type of tree. NOTE: the forest will remain a 75% coverage)

--------------------------------------------------------

Optional changes

if you like your trees to have a different amount of wood stored you can change that by changing the storage value of the SOURCE-trees.

For example when you changed forest trees(100w) to baobab trees(200w), you can set their wood value back to 100wood by adding this code:

effect_amount SET_ATTRIBUTE FOREST_TREE ATTR_STORAGE_VALUE 100

Also you can change other properties of the trees.
The hp can be altered (if you are bothered by the 30hp forest trees, while all other trees have 20hp, you can change the hitpoints of the forest-trees).

Or maybe you have some other creative ideas such as replacing the dead_ID of the trees (once the tree is completely out of wood it turns into a new object, maybe a relic, a wolf, an explosion;the possibilities are endless)

-----------------------------------------------------

Conclusion / Take Home Message

using the UPGRADE_UNIT feature allows to change forests appearance and functionality. Combine any king of forest trees with a subsurface (desert, leaves, snowy grass, savannah, dirt4 or mangrove), or upgrade your trees into other objects (invisible objects with no interaction to remove the trees on these forest-terrains).
Changing the attributes of the (source) trees gives even more control to the scripter and can be especiallyusefull for changing thee amount of wood stored in the trees.

-----------------------------------------------------

The following constants were used:

#const GAIA_UPGRADE_UNIT -4
#const SET_ATTRIBUTE 0
#const ATTR_ATTR_STORAGE_VALUE 21


#const FOREST 10
#const PALM_DESERT 13
#const BAOBAB_FOREST 16 /* also spawns as 'cliff-grass' */
#const JUNGLE 17
#const BAMBOO 18
#const PINE_FOREST 19
#const MANGROVE_FOREST 20 /* previously was 'Oak Forest' */
#const SNOW_FOREST 21
#const ACACIA_FOREST 41 /* previously was grass which was black on minimap */

#const bush 302
#const DLC_ACACIATREE 1063
#const DLC_AFRICANBUSH 1053
#const DLC_AFRICANBUSH_2 1054
#const DLC_BAOBABTREE 1052
#const DLC_DRAGONTREE 1051
#const RAINFOREST_TREE 1146
#const MANGROVE_TREE 1144

#const TREE_TD 284 /* this tree is exactly the same as TREE_A (id:399) ? */

#const BAMBOO_FOREST_TREE 348 /* Varies. Same created by BAMBOO terrain */
#const OAK_FOREST_TREE 349 /* Varies. Same created by FOREST terrain */
#const PINE_FOREST_TREE 350 /* Varies. Same created by PINE_FOREST terrain */
#const PALM_FOREST_TREE 351 /* Varies. Same created by PALM_DESERT terrain */
#const SNOW_PINE_TREE 413 /* Varies. Same created by SNOW_FOREST terrain */
#const JUNGLE_TREE 414 /* Varies. Same created by JUNGLE terrain */

#const TREE_A 399 /* Oak forest, alternative TREE1, or TREE_TD? */
#const TREE2 400 /* Oak forest, alternative TREE_B */
#const TREE3 401 /* Oak forest, alternative TREE_C */
#const TREE4 402 /* Oak forest, alternative TREE_D */
#const TREE5 403 /* Oak forest, alternative TREE_E */
#const TREE_F 404 /* Dry, no leaves */
#const TREE_G 405 /* Brown leaves */
#const TREE_H 406 /* Oak forest */
#const TREE_I 407 /* Dry, no leaves */
#const TREE_J 408 /* Oak forest */
#const TREE_K 409 /* Oak forest */
#const TREE_L 410 /* Oak forest */

[This message has been edited by HenkDeSuperNerd (edited 08-25-2018 @ 10:33 PM).]

AuthorReplies:
scripter64
Wolved
posted 08-26-18 12:44 PM CT (US)     1 / 1       
Great post! I love those mixed forests. Incidentally, if you'd like to use SET_ATTRIBUTE for trees or other gaia objects without causing the !C warning, you can use GAIA_SET_ATTRIBUTE instead, which is -1, I think.
You must be logged in to post messages.
Please login or register

Hop to:    

Age of Kings Heaven | HeavenGames