Welcome to the TWC Wiki! You are not logged in. Please log in to the Wiki to vote in polls, change skin preferences, or edit pages. See HERE for details of how to LOG IN.

Difference between revisions of "Techtree - M2TW"

From TWC Wiki
Jump to navigationJump to search
m (Overview: +cap)
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
Techtree slots are the mechanism in M2TW where buildings such as barracks and churches appear within the 3d models of settlements that have built those buildings.
+
{{M2TW Modding Logo}}
 +
==Overview==
 +
Techtree buildings and slots are the mechanism in M2TW where buildings such as barracks and churches that are defined in '''[[export_descr_buildings.txt]]''' appear within the 3d models of settlements that have constructed those buildings. Most vanilla settlements have a variety of techtree slots with different category names and sizes. 
  
===Editing techtrees===
+
When the game loads a campaign battle-map with a settlement it searches the pre-loaded '''[[.worldpkgdesc]]''' files for matches to the category name and size of slot,  if available it will load the ones for the buildings that have been constructed at that settlement, if no EDB buildings are built or are available for a slot it will load the result of pkgs that match category name and size with '''[[#slot_fillers|slot_filler]]''' as the type.
  
===Link to EDB===
+
When the game loads a custom battle battle-map with a settlement selected it loads the matching pkgs for the highest level of EDB building that can be built for that settlement level.
  
===Useage===
+
If no matching .worldpkgdesc is found to fill a slot that area will simply be left blank on the battle-map. As with other uses of the .worldpkgdesc files the game can sometimes be over-enthusiastic in trying to fill slots and you may get vanilla slot_fillers appearing that shouldn't be a 100% match!
As well as the obvious use of allowing a barracks to appear as built within a settlement, a techtree can be used to load more-or-less anything! For instance in certain TATW mods a techtree is used to load a dummy settlement outside the main actual settlement, to represent a closely adjacent settlement without having to import all the models manually. To achieve this (as the dummy settlement is obviously not built via EDB) the techtree slot is set up with a unique category name and size and a [[.worldpkgdesc]] created to match that category and size but with "slot_filler" as the 'type'.
 
  
 +
<big>Important note: '''The same EDB building cannot be loaded in two different slot categories, or sizes, for the same faction.''' See [[#Showing_EDB_buildings|below]].</big>
 +
 +
==Editing TechTreeSlots==
 +
[[File:Techtree in hex editor.png|400px|thumb|view of techtree section of .world in hex editor]]
 +
[[File:Techtree slot in IWTE.png|400px|thumb|view of techtree update in IWTE]]
 +
 +
===With Hex Editor===
 +
The picture at the top right shows the TechTreeSlot section of the .world file viewed in a hex editor.  It would be possible to edit the TechTreeSlot name, size and location in the .world file, but please note that each string e.g. the 'market' name, is preceded by an integer that gives the count of characters, this must be correct or the game will CTD.  The 'size' e.g. 64x64 is also a text string, so 64x64 requires a preceding integer of 5, and 128x64 an integer of 6.  The location and rotation are given as float values.  Attempting to add a new slot via hex-editor is not recommended.
 +
===With IWTE===
 +
The second image on the right shows a large town settlement open in IWTE with the 2d view of the world switched on and then 'View TechTrees and Change TechTree selected.  The IWTE functions allow the location to be changed by dragging the selected techtree in the 2d view.  Changes to the rotation, tech category, and tech tree size are made in the bottom left panel.  Click the OK button (not shown) when done, and remember to go back to 'WorldFiles' tab and 'Save 3 binaries'.  Techtree slots can also be added or deleted.
 +
 +
IWTE shows graphically in the 2d view the location and nominal size of the techtree slot, this it to aid planning of pathfinding and to avoid overlaps with other structures, however the building loaded is not limited to this area, see [[#size|size]] notes below.
 +
===Slot Parameters===
 +
Techtree slots have only four parameters, name, size, location and rotation:
 +
====Slot name====
 +
This must match the '[[.worldpkgdesc_-_M2TW#Category:|category]]' in the .worldpkgdesc you want to load in the slot. Vanilla settlements use the following slot names:
 +
*generic
 +
*market
 +
*smithy
 +
*church
 +
*guild
 +
*tavern
 +
*university
 +
*cultural_building_small
 +
*cultural_building_large
 +
There is no correspondence between these names and EDB trees or buildings, or any other file except the .worldpkgdesc, so you can change these or add new names.  The main purpose behind the slot/category names is to allow some urban planning, e.g. if you want your religious buildings to appear on a hill in the settlement, or if you want your 'large cultural buildings' to appear near the plaza, etc.
 +
====Size====
 +
The 'size' of the techtree slot is actually just a text string which needs to match the equivalent string in the .worldpkgdesc you want to load.  The 'size' given does not make the building loaded scale to fit, or cut it off at the edges, so you can load a small building in a large slot, you'll just get space around it, and you can load a large building in a small slot, but that might mean it overlaps adjacent structures unless you've planned for it.
 +
 +
The standard sizes used in the vanilla settlements are:
 +
*32x32
 +
*64x32
 +
*64x64
 +
*128x64
 +
====Location====
 +
The location of the techtree slot is given as x,y coordinates to the center.  Height is not given, the height of the building terrain that loads in the slot is established by the game in relation the height of the settlement terrain at that point.  Note that if the techtree building has a large flat terrain area and the slot where it loads is on sloping terrain you will get 'cliff edges' around the flattened area.
 +
====Rotation====
 +
A rotation can also be applied to the techtree slot.  Please note that masks applied to the terrain of a techtree building don't work when the slot is rotated, this appears to be an engine bug.
 +
 +
==Use of Techtree Slots==
 +
===Showing EDB buildings===
 +
[[File:EDB building name.png|300px|thumb|name of building in EDB for techtree]]
 +
The main purpose of the slots is to load 3d model representations of buildings from [[export_descr_buildings.txt]] that have been constructed at the settlement.  When loaded in battle if you hover the cursor over a techtree loaded building you will see the building name displayed.  If the AI attacker has siege firing weapons they may target the techtree buildings and damage sustained will show up in the settlement when the game returns to campaign mode.
 +
 +
To get an EDB building to load in a slot it must have a .worldpkgdesc where the slot name/category and size match and the internal name of the building must be used in the pkg as the '[[.worldpkgdesc_-_M2TW#Type:|type]]'  in the example pic shown c_cannon_maker is an example of the building name required.  The EDB tree name e.g. castle_cannon, is not relevant at all, and different buildings within that EDB tree ''could'' be assigned to different slot categories.
 +
 +
'''The same techtree building model .world file can be used to represent multiple EDB buildings''', e.g. the same forge model could be used to represent c_gunsmith and c_cannon_maker simply by having a separate .worldpkgdesc for each of the buildings which uses the same path to the .world file.  The same building would load but the hover over name would change to show which building it was representing.
 +
 +
'''The same EDB building <u>cannot</u> be loaded in two different slot categories or sizes for the same faction.'''
 +
For non-vanilla EDB's you may be tempted to try to have different sized models representing the same building to suit larger/smaller settlements.  This does not work!  You could have a .worldpkgdesc for 'roman' faction, with 'generic' category, 32x32 size and type c_cannon_maker, and another .worldpkgdesc for 'france' faction, with 'generic' category, 64x32 size and type c_cannon_maker, that would work but is of limited usefulness as you normally can't predict that 'france' will only construct that building in settlements with the 64x32 slot.  If you attempt to have two .worldpkgdesc files for the same EDB building that are applicable to the same faction then only one will be used, even if the slot size for the non-working version is the only slot present in the settlement.  There doesn't seem to be any logic to which pkg is used so it's probably based on loading order.  This issue may be one reason why the vanilla EDB has different building trees for castles and cities, as castles are smaller and have smaller techtree slots this allows them to load a smaller set of models for their churches etc.
 +
 +
===slot_fillers===
 +
When no matching .worldpkgdesc for an export_descr_buildings.txt building is found the game will load a matching .worldpkgdesc with '''slot_filler''' as the type.  The .worlds loaded are normally designed to look like blocks of housing which blend in with the rest of the settlement, no name is displayed when you hover over a slot_filler loaded building in battle. 
 +
 +
Slot_fillers can be used as an easy way of adding repeat generic structures to settlements.
 +
 +
===Other Uses===
 +
A techtree slot can be used to load more-or-less anything!  For instance, in certain TATW mods a techtree is used to load a dummy settlement outside the main actual settlement, to represent a closely adjacent settlement without having to import all the models manually. To achieve this (as the dummy settlement is obviously not built via EDB) the techtree slot is set up with a unique category name and size and a .worldpkgdesc created to match that category and size but with "slot_filler" as the 'type'.  Note that settlements loaded in techtree slots lack some of the normal functionality such as plazas and firing arrow towers and whilst it is possible to get onto walls the AI will not use dummy settlements defensively or attempt to captrue them.
 +
 +
==Techtree Building .world files==
 +
The file set-up for the techtree buildings is very similar to that for full settlements except they don't usually have a .worldpathfinding file assigned. Vanilla techtree buildings are all found in ''data/settlements/techtree/culture_name'', but they can be located elsewhere.
 +
===Terrain===
 +
The .worldterrain for techtree buildings is normally flat but that can be varied.
 +
===Vegetation===
 +
Specifically located trees (the green leafy type!) can be added in the .worldvegetation file - these will be randomly selected from the available tree models for the climate where the settlement is located.
 +
===Pathfinding===
 +
Normally the area under the techtree slot should be blocked in the settlement's .worldpathfinding file.  However, if the different buildings that can be loaded in a slot are likely to be of vastly different sizes, or you are not intending to allow a slot_filler building to load, you can instead leave the pathfinding area under the slot open in the settlement file and add a blocked .worldpathfinding file to the techtree buildings' .world files instead.
 +
 +
To add a .worldpathfinding file to the techtree building you will need to edit the reference to it in by using the 'update referenced paths' button in IWTE.
  
  
 
[[Category:M2TW Battle Map Modding]]
 
[[Category:M2TW Battle Map Modding]]

Latest revision as of 16:19, 8 March 2023

M2TW Modding Index


Overview

Techtree buildings and slots are the mechanism in M2TW where buildings such as barracks and churches that are defined in export_descr_buildings.txt appear within the 3d models of settlements that have constructed those buildings. Most vanilla settlements have a variety of techtree slots with different category names and sizes.

When the game loads a campaign battle-map with a settlement it searches the pre-loaded .worldpkgdesc files for matches to the category name and size of slot, if available it will load the ones for the buildings that have been constructed at that settlement, if no EDB buildings are built or are available for a slot it will load the result of pkgs that match category name and size with slot_filler as the type.

When the game loads a custom battle battle-map with a settlement selected it loads the matching pkgs for the highest level of EDB building that can be built for that settlement level.

If no matching .worldpkgdesc is found to fill a slot that area will simply be left blank on the battle-map. As with other uses of the .worldpkgdesc files the game can sometimes be over-enthusiastic in trying to fill slots and you may get vanilla slot_fillers appearing that shouldn't be a 100% match!

Important note: The same EDB building cannot be loaded in two different slot categories, or sizes, for the same faction. See below.

Editing TechTreeSlots

view of techtree section of .world in hex editor
view of techtree update in IWTE

With Hex Editor

The picture at the top right shows the TechTreeSlot section of the .world file viewed in a hex editor. It would be possible to edit the TechTreeSlot name, size and location in the .world file, but please note that each string e.g. the 'market' name, is preceded by an integer that gives the count of characters, this must be correct or the game will CTD. The 'size' e.g. 64x64 is also a text string, so 64x64 requires a preceding integer of 5, and 128x64 an integer of 6. The location and rotation are given as float values. Attempting to add a new slot via hex-editor is not recommended.

With IWTE

The second image on the right shows a large town settlement open in IWTE with the 2d view of the world switched on and then 'View TechTrees and Change TechTree selected. The IWTE functions allow the location to be changed by dragging the selected techtree in the 2d view. Changes to the rotation, tech category, and tech tree size are made in the bottom left panel. Click the OK button (not shown) when done, and remember to go back to 'WorldFiles' tab and 'Save 3 binaries'. Techtree slots can also be added or deleted.

IWTE shows graphically in the 2d view the location and nominal size of the techtree slot, this it to aid planning of pathfinding and to avoid overlaps with other structures, however the building loaded is not limited to this area, see size notes below.

Slot Parameters

Techtree slots have only four parameters, name, size, location and rotation:

Slot name

This must match the 'category' in the .worldpkgdesc you want to load in the slot. Vanilla settlements use the following slot names:

  • generic
  • market
  • smithy
  • church
  • guild
  • tavern
  • university
  • cultural_building_small
  • cultural_building_large

There is no correspondence between these names and EDB trees or buildings, or any other file except the .worldpkgdesc, so you can change these or add new names. The main purpose behind the slot/category names is to allow some urban planning, e.g. if you want your religious buildings to appear on a hill in the settlement, or if you want your 'large cultural buildings' to appear near the plaza, etc.

Size

The 'size' of the techtree slot is actually just a text string which needs to match the equivalent string in the .worldpkgdesc you want to load. The 'size' given does not make the building loaded scale to fit, or cut it off at the edges, so you can load a small building in a large slot, you'll just get space around it, and you can load a large building in a small slot, but that might mean it overlaps adjacent structures unless you've planned for it.

The standard sizes used in the vanilla settlements are:

  • 32x32
  • 64x32
  • 64x64
  • 128x64

Location

The location of the techtree slot is given as x,y coordinates to the center. Height is not given, the height of the building terrain that loads in the slot is established by the game in relation the height of the settlement terrain at that point. Note that if the techtree building has a large flat terrain area and the slot where it loads is on sloping terrain you will get 'cliff edges' around the flattened area.

Rotation

A rotation can also be applied to the techtree slot. Please note that masks applied to the terrain of a techtree building don't work when the slot is rotated, this appears to be an engine bug.

Use of Techtree Slots

Showing EDB buildings

name of building in EDB for techtree

The main purpose of the slots is to load 3d model representations of buildings from export_descr_buildings.txt that have been constructed at the settlement. When loaded in battle if you hover the cursor over a techtree loaded building you will see the building name displayed. If the AI attacker has siege firing weapons they may target the techtree buildings and damage sustained will show up in the settlement when the game returns to campaign mode.

To get an EDB building to load in a slot it must have a .worldpkgdesc where the slot name/category and size match and the internal name of the building must be used in the pkg as the 'type' in the example pic shown c_cannon_maker is an example of the building name required. The EDB tree name e.g. castle_cannon, is not relevant at all, and different buildings within that EDB tree could be assigned to different slot categories.

The same techtree building model .world file can be used to represent multiple EDB buildings, e.g. the same forge model could be used to represent c_gunsmith and c_cannon_maker simply by having a separate .worldpkgdesc for each of the buildings which uses the same path to the .world file. The same building would load but the hover over name would change to show which building it was representing.

The same EDB building cannot be loaded in two different slot categories or sizes for the same faction. For non-vanilla EDB's you may be tempted to try to have different sized models representing the same building to suit larger/smaller settlements. This does not work! You could have a .worldpkgdesc for 'roman' faction, with 'generic' category, 32x32 size and type c_cannon_maker, and another .worldpkgdesc for 'france' faction, with 'generic' category, 64x32 size and type c_cannon_maker, that would work but is of limited usefulness as you normally can't predict that 'france' will only construct that building in settlements with the 64x32 slot. If you attempt to have two .worldpkgdesc files for the same EDB building that are applicable to the same faction then only one will be used, even if the slot size for the non-working version is the only slot present in the settlement. There doesn't seem to be any logic to which pkg is used so it's probably based on loading order. This issue may be one reason why the vanilla EDB has different building trees for castles and cities, as castles are smaller and have smaller techtree slots this allows them to load a smaller set of models for their churches etc.

slot_fillers

When no matching .worldpkgdesc for an export_descr_buildings.txt building is found the game will load a matching .worldpkgdesc with slot_filler as the type. The .worlds loaded are normally designed to look like blocks of housing which blend in with the rest of the settlement, no name is displayed when you hover over a slot_filler loaded building in battle.

Slot_fillers can be used as an easy way of adding repeat generic structures to settlements.

Other Uses

A techtree slot can be used to load more-or-less anything! For instance, in certain TATW mods a techtree is used to load a dummy settlement outside the main actual settlement, to represent a closely adjacent settlement without having to import all the models manually. To achieve this (as the dummy settlement is obviously not built via EDB) the techtree slot is set up with a unique category name and size and a .worldpkgdesc created to match that category and size but with "slot_filler" as the 'type'. Note that settlements loaded in techtree slots lack some of the normal functionality such as plazas and firing arrow towers and whilst it is possible to get onto walls the AI will not use dummy settlements defensively or attempt to captrue them.

Techtree Building .world files

The file set-up for the techtree buildings is very similar to that for full settlements except they don't usually have a .worldpathfinding file assigned. Vanilla techtree buildings are all found in data/settlements/techtree/culture_name, but they can be located elsewhere.

Terrain

The .worldterrain for techtree buildings is normally flat but that can be varied.

Vegetation

Specifically located trees (the green leafy type!) can be added in the .worldvegetation file - these will be randomly selected from the available tree models for the climate where the settlement is located.

Pathfinding

Normally the area under the techtree slot should be blocked in the settlement's .worldpathfinding file. However, if the different buildings that can be loaded in a slot are likely to be of vastly different sizes, or you are not intending to allow a slot_filler building to load, you can instead leave the pathfinding area under the slot open in the settlement file and add a blocked .worldpathfinding file to the techtree buildings' .world files instead.

To add a .worldpathfinding file to the techtree building you will need to edit the reference to it in by using the 'update referenced paths' button in IWTE.