Results 1 to 17 of 17

Thread: Nakharar's Basics: Resources

  1. #1

    Default Nakharar's Basics: Resources

    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

    Code:
    type                gold
    trade_value            20
    item                data/models_strat/resource_gold.CAS
    icon                data/ui/resources/resource_gold.tga
    has_mine
    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.
    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!
    Last edited by Nakharar; October 29, 2008 at 04:11 PM.

  2. #2

    Default Re: Nakharar's Basics: Resources

    RESERVED

  3. #3

    Default Re: Nakharar's Basics: Resources

    Thanks maybe you could show us how to create a trade new resource.

  4. #4

    Default Re: Nakharar's Basics: Resources

    lol this is it

  5. #5

    Default Re: Nakharar's Basics: Resources

    Nice, im adding gold all over the world





    Researcher for Patria Liberia

    IF you rep me i might cry

  6. #6

    Default Re: Nakharar's Basics: Resources

    wait i forgot some stuff for adding a new resource. Strat.txt and tooltips.txt

  7. #7

    Default Re: Nakharar's Basics: Resources

    Please help... explain step by step I cant to add a new resource...

    10:32:23.656 [system.rpt] [always] CPU: SSE2
    10:32:23.656 [system.rpt] [always] ==== system log start, build date: Feb 25 2008 version development ===
    10:32:23.656 [system.io] [always] mounted pack packs/data_0.pack
    10:32:23.656 [system.io] [always] mounted pack packs/data_1.pack
    10:32:23.671 [system.io] [always] mounted pack packs/data_2.pack
    10:32:23.671 [system.io] [always] mounted pack packs/data_3.pack
    10:32:23.671 [system.io] [always] mounted pack packs/data_4.pack
    10:32:23.671 [system.io] [always] mounted pack packs/localized.pack
    10:32:26.843 [script.err] [error] Script Error in mods/Stainless_Steel_6/data/descr_sm_resources.txt, at line 5, column 21
    dont recognise this resource type village

    trade_value 30

    item data/models_strat/resource_village.CAS

    icon data/ui/resources/resource_village.tga

    has_mine

  8. #8

    Default Re: Nakharar's Basics: Resources


  9. #9

    Default Re: Nakharar's Basics: Resources

    thank you very mach!!!

  10. #10
    Nevada's Avatar Domesticus
    Join Date
    Jun 2007
    Location
    Bavaria
    Posts
    2,197

    Default Re: Nakharar's Basics: Resources

    Code:
    17:44:21.254 [script.err] [error] Script Error in mods/retrofit/data/descr_sm_resources.txt, at line 133, column 21
    dont recognise this resource type elephants 
    
    trade_value            12
    
    item                data/models_strat/resource_honey.CAS
    
    icon                data/ui/resources/honey_pip.tga
    Well, i get this one when using either your or the other tutorial.
    I wanted to get honey from the teutonic campaign without wasting another resourceslot.



  11. #11

    Default Re: Nakharar's Basics: Resources

    is honey a new resource? if not then copy it and paste it with another name

  12. #12

    Default Re: Nakharar's Basics: Resources

    First of all the maximum amount of resources is 26.
    Are you sure ? There 28 resources in the vanilla descr_sm_resources.txt

  13. #13

    Default Re: Nakharar's Basics: Resources

    Reallyoh my bad

  14. #14
    EarendilElenthol's Avatar Artifex
    Join Date
    Apr 2008
    Location
    The Netherlands
    Posts
    998

    Default Re: Nakharar's Basics: Resources

    I couldn't find it yet, do you know where to change the effects of trade resources like the population growth factor grain gives? Are they hidden resources or coded somewhere in a .txt?

  15. #15

    Default Re: Nakharar's Basics: Resources

    The last three resources in descr_sm_resources look like this:

    type elephants
    trade_value 0
    item data/models_strat/resource_elephants.CAS
    icon data/ui/resources/resource_elephants.tga

    type camels
    trade_value 0
    item data/models_strat/resource_camels.CAS
    icon data/ui/resources/resource_camels.tga

    type dogs
    trade_value 0
    item data/models_strat/resource_dogs.CAS
    icon data/ui/resources/resource_dogs.tga

    is this for a reason? Can these three be used for others resources or are they unused on purpose?



  16. #16
    Swagger's Avatar Imperial Coffee-Runner
    Join Date
    Apr 2007
    Location
    Portugal
    Posts
    12,453

    Default Re: Nakharar's Basics: Resources

    they're leftovers from RTW, you can edit them
    Under the Patronage of the Dreadful cedric37!
    Ancs Guide, Emergent Factions , Yes/No Events |L'Outremer for Modders| Swagger's Skymod


  17. #17

    Default Re: Nakharar's Basics: Resources

    What is the max trade value?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •