Hello to the third edition of Nakharar's basics in coding. This one will be on the coding part of adding resources ingame. The other part of it is moddeling
and skinning the resource however i won't go into that. First of all the maximum amount of resources is 26. You are allowed 64 different hidden resources
. Hidden resources can be used to make an AOR system, to make special buildings available and make special things available to specific regions and setlements.
I will not go into hidden resources in this tutorial. The main file needed here is the descr_sm_resources. In the file it has a list of all the resources and the
place that there .cas files are and there .tga files are.
The Coding
__________________
We will implement a new resource
As we can see first is the type the name of the resource. The trade_value indicates how expensive the resource is. It will always stay at one strict price.Code:type gold trade_value 20 item data/models_strat/resource_gold.CAS icon data/ui/resources/resource_gold.tga has_mine
However the price can be changed by closeness to capital of the resource, closeness to settlements and the how rare it is.(i think?) The maximum trade_value is
...... .
Here are the list of resources:
coal, fish, amber, cotton, furs, gold, marble, ivory, silver, tobacco, chocolate , wool, wine, textures, timber, sulphur, sugar, slaves, silk, graid, dyes
tin, iron, spices and grain
The Moddeling
____________________
The model as it says is in models_strat. It is in .CAS format. In MTW2 .CAS format is used for strat stuff. To edit you must use the .CAS exporter here:
http://www.twcenter.net/forums/showthread.php?t=73692
The other part is the icon. The icon is the icon in the city or town places where it shows what you trade.
May upgrade later
-------------
from a Kingdoms tutorial : Please read
The Basics - skip this part if you already know which files are used by resources. This section is for the novice modder.
File paths mentioned below assume Medieval II Total War/mods/(one of the Kingdoms campaigns or your own mod) then /data etc.
Resource graphics use 3 files.
The little "pip" icons which show up in the settlement details trade window are located in /data/ui/resources and are .tga files.
The strat map 3-D graphics require 2 files. In /data/models_strat you will find the .cas files and in /data/models_strat/textures are the .tga textures which match with the .cas files.
You won't see .CAS files named resource_fruit or resource_salt. This is because CA used substituted new graphics for resources not used in the campaign. Only the .tga files, the pip icon and the texture used by the .cas file, use the names of the resources as they appear in the game. And sometimes even those are not named as they appear in the game.
Which brings us to the 4 text files which determine the resource files used for each resource, where they appear on the strat map and the text which goes with the resource name for mouse-over tooltips and trade details and what the merchant is trading when he is on that spot.
In /data you will find the descr_sm_resources.txt file. This file points to the path and file names for the graphics for each resource, the base value of the resource, and whether or not it uses a mine. This is where CA pointed to the graphics in the /data/models_strat and /data/ui above.
There are 27 available resource slots. The 24 we usually see and 3 slots left over from RTW and unused: elephants, dogs and camels. You can use those three extra slots, as shown below. You may not rename any of these resources. The game engine expects only these 27 resource names.
This is why CA used the graphics names for some of these; but substituted new graphics inside the file for the new resource. So, in /teutonic/data/models_strat, the resource_sugar.cas file is actually a 3-D model for salt. In /data/ui/resources, however, the file is actually called salt_pip.tga instead and the texture .tga used by the .CAS file in /textures is called resource_salt.tga too. You will notice that the lines in descr_sm_resources.txt point to the .CAs and pip icon files the same way:
Code:
type sugar
trade_value 10
item data/models_strat/resource_sugar.CAS
icon data/ui/resources/salt_pip.tga
has_mine
The difference between the .cas file and the _pip.tga file easily show you which files CA substituted. So a little further up in the file, you'll see that the resource marble has a tar_pip.tga file. So marble is the resource in which they've put the graphics for tar. :wink:
In some of the campaigns however, CA used the old resource name for both the .CAS file and the pip icon .tga file. So be careful. Use a graphics viewer like Irfanview (freeware) to check that you're using the right .tga file.
In the /data/world/maps/campaign/imperial_campaign folder is your descr_strat.txt file. Near the top of the file is the list of resources and their X, Y coordinates on the map. The resource names in this file must match the resource names in the descr_sm_resources.txt file. You can't try and place "salt" on the map here. You have to use one of the 27 resource names already in descr_sm_resources.
The last two files are located in /data/text and are easily overlooked.
strat.txt.strings.bin
tooltips.txt.string.bin
Your mod likely already has a strat.txt and tooltips.txt file plus the related .bin files. The versions in Kingdoms are .bin files. You will need .txt versions of the files to edit them, then you delete the .bin versions and the game builds new .bin files the first time you run it from the edited .txt files. Retrofit mod 1.0 (and thus most mods for Kingdoms using it) already has the .txt versions of strat.txt.string.bin and tooltips.txt.string.bin included. So you can download Retrofit Mod 1.0 for those files. You can also edit the .bin versions using a hex editor.
Once you have the .txt versions, open them with a text editor like Notepad.
In tooltips.txt scroll down until you find the entries for the resources. They will look like this:
Code:
{TMT_SILVER_TOOLTIP}Silver Mines can be constructed at the nearby settlement
{TMT_GOLD_TOOLTIP}Gold Mines can be constructed at the nearby settlement
{TMT_IRON_TOOLTIP}Iron - a valuable trade resource
{TMT_GRAIN_TOOLTIP}Grain - a valuable resource\nIncreases population growth in local settlement
{TMT_IVORY_TOOLTIP}Ivory - a valuable trade resource
{TMT_WINE_TOOLTIP}Wine - a valuable trade resource
{TMT_SLAVES_TOOLTIP}Slaves - a valuable resource\n
{TMT_CHOCOLATE_TOOLTIP}Weapons - a valuable trade resource
Do NOT change anything inside the {} brackets!
This file tells the game which text to display when you hold your mouse over it on the strat/campaign map. We will be changing some of the text after the {} later.
In strat.txt you will find similar lines which look like this:
Code:
{SMT_RESOURCE_GOLD}Gold
{SMT_RESOURCE_SILVER}Silver
{SMT_RESOURCE_IRON}Iron
{SMT_RESOURCE_FISH}Fish
{SMT_RESOURCE_FURS}Furs
Again, don't mess with anything inside the brackets. This file tells the game what text to use in various windows and other places on the strat map. For resources, it determines the text which displays when you hold your mouse over the little pip icons in the settlement details trade window and also the text which shows when you open up your merchant details window to see what he is trading. Examples in the pics below.
That's it for the basics!