[English] Adding new items & upgrades

  • Hey there,


    because of a special request I'll translate the tutorial for adding new items and upgrades


    In case you want to add a simple new item for production (so no raw material but a normal product) the work is quite easy.


    Step 1: open DB/Items.dbt with an editor of your choice (I use the windows editor for dbt-files)



    Example:

    Code
    23  "Wheatbread"  3  4  3  2  2  2  1  2  0  2  120  1  20  0  0  0  0  0  25  50  |

    I will explain what every number means.


    id : 23
    This number is the ID, the identification number of the item. As all IDs it has to be unique. For your own item, take a number between 1 and 999 but choose a number that has not been taken already ;) You can use the ID for functions like "AddItems("", 23, 1, INVENTORY_STD)" but I recommand using the actual name for better reading. Some function though need the ID and only work with them.


    name: "Wheatbread"
    The name should be unique aswell obviously. Also the Name is important for the text.dbt because you will need to add Entries based on your chosen name (see below).



    type: 3


    I'm not completely sure about the importance of every type. 8 is important, because it means you need a actual source where the item can be gathered, so it does need an entry in GuildResource.dbt. 6 and 4 are not traded at the market and have no sell or buy price, normally you never should use that. Most time you will use 1,2,3 and 5. Items with 3 will be bought by the hardcoded market AI depending on the datatype.



    List of all types:


    -- ITEM_TYPE_RESOURCE = 1,
    -- ITEM_TYPE_INTERSTAGEPRODUCT = 2,
    -- ITEM_TYPE_NEED = 3,
    -- ITEM_TYPE_SUPPLY = 4,
    -- ITEM_TYPE_ARTIFACT = 5,
    -- ITEM_TYPE_ANIMAL = 6,
    -- ITEM_TYPE_PRODBYMEASURE = 7,
    -- ITEM_TYPE_GATHERING= 8,
    -- ITEM_TYPE_QUESTITEM = 9


    datatype: 4
    Also not completely sure about this, but if you look at the different items you can see that 4 is "food", 5 "alcoholic drinks" and 10 seem to be "artifacts". There seems to be some hardcoded selling/buying if you have a need-type, but other than that, I can't see any real use of this.


    weight: 3


    Every inventory slot (not counting workshops) has a weight of 10, meaning you can store 3 items with weight 3 of the same kind in that slot. Normally artifacts have 3 or 10 and every kind of raw material has 1 but you can do as you want. Obviously it might be imbalanced if you can carry 10 high-level items in one slot ...



    Datavalue: 2


    You can keep this slot at 0 if you don't have a weapon or a need item. It looks like it does influence how important a item is to fulfill a need when automaticly bought from the market, but at this point this is pure speculation from me.



    Buildtime: 2


    This is THE most important number to influence the base price of an item. Every item has the same value, but high level items will take more time to make (unless you boost your productivity). Whenever you want to have a high buildcount, you should consider raising the buildtime to at least 2 or higher because you will lose value otherwise. Also always consider the ingredients of your product - if it has expensive raw materials, you should raise the build time to make working on the item cost effective. In my experience it's a good idea to limit raw materials as much as possible and instead raise buildtime or lower build count to raise the price.



    Buildcount: 2


    How many items you will get after the work is complete. While it is nice to have multiple items quickly, every point will cut the value of a single unit by a significant amount.
    In case you wonder, the base price formular is this: math.floor((58.3*buildtime + baseprice*count of every raw material)/buildcount)


    costmodifier: 1


    You should always use 1 or 2. the cost modifier influences how strong/weak the actual buy- and sellprice will sink/raise when the market-stock of the items changes. So a high value means it will barely change and be around base price while 1 means that every bought/sold item can make a difference to the price. In my experience the gameplay works best with huge price changes based on stock. The only item-type I can think off where you maybe want a more stable price is for ressources - but that will also mean that it will be really hard to get a "green" buy/sell-price for ressources.



    substlevel: 2


    What social rank have the buyers for that item? I'm not sure if this has an actual impact in the game, but it does show "For rich/poor people" in the tooltip so it's something you should consider.


    1 - desperately poor, 5 filthy rich



    Fixedprice: 0


    if this is NOT 0 you will have always the same price for buying/selling. Never use this for production items because it will break the AI production. You can use this for special event items, like church bells, but normally you should not change this.



    Category: 2


    Choose the section of the market where this item will appear (1 = raw material, 6 = iron stuff)



    Manufacturer: 120


    This is actualy not important ingame, because only those buildings are listed which have the upgrades, but it's nice if you enter the building-ID here for the main workshop for this item just for us modders.



    Nr 1/2/3: 1


    The count of raw materials needed for this item. If you only need 1 or 2 raw materials set the rest to 0



    Prod 1/2/3: 20


    The items.dbt ID of the raw materials needed for this item. No item needed = set everything to 0



    Slot:


    This is only needed for armory and weapons



    min_stock:


    This is very important to influence the buying/selling price. If the actual stock is below this value you can buy things for a green price.



    max_stock:


    After the actual market stock is higher than this value, the price will become more and more red, but setting a high value will also have an


    effect on the sell-price (it will get more green)




    I recommand you to copy an existing entry and change the values accordingly.




    2. icon


    After this work has been done, you need to design a icon for the item, max size 45x45 with tga and alpha canal. The name has to be item_NAME.tga (depending on the name in items.dbt) put it in the folder Textures/HUD/Items




    3. text.dbt


    Add new entries at the bottom of the file (as always, IDs have to be unique, if you want to combine your work with other mods, you should take numbers +10000 to keep them compatible for updates). You don't need new entries or images for the upgrades, because it will use the same as your item.


    You need:
    18106 "_ITEM_MyItem_NAME_+0"
    18107 "_ITEM_MyItem_NAME_+1" (for plural)
    18108 "_ITEM_MyItem_TOOLTIP_+0"


    and maybe you also need
    18109 "_ITEM_MyItem_TARGET_+0"


    in case you have made a new measure/artifact where you need to choose a target first.


    4. BuildingUpgrades.dbt


    You need a new line like this one


    Code
    5613  490  "Oil"  1  0  6  998  0  0  500  -1 |

    First number is ID
    Second number is the Building ID out of buildings.dbt where the upgrade should appear (it contains also the level of the building)
    Third number is the name of the upgrade. You should use the same name as the item.
    forth number is impact receiver, 1 means the building gets the impact (and not your employees)
    The next number asks if you have the upgrade already unlocked by default (1) or not (0)
    The 6 is the impact (see impacts.dbt). 6 is a new product.
    impactvalue (998) can be multiple things. In this case we need to add the items.dbt ID here.
    Room (0) is for the display-position in the tech tree. Maybe you want it to appear below another item, then you need
    to set the buildingupgrades-ID from the other upgrade here.
    "indoorscene" can be left at 0
    "cost" if you have not set it to default, you need to set the price for the upgrade here
    "visible" -1 means you can see the item in the tech tree even if you have a lower building-level, 0 is hidden.


    That should be all. If you've done everything right, you can see the item ingame now.

  • Hello,


    thanks for the tutorial, it's really helpfull !


    I just had a few questions :
    Are items in items.dbt has to be between 1 and 999 only ? If it's more than that it wouldn't work ?
    What is the value of buildtime in game ? if buildtime = 1 then it will take 1 hour to produce it ?
    If min stock = 0, then the sell value will never be green ?
    If I want to make the mod requiring the modlauncher, i have to use text.xml and not text.dbt right ?



    Anyway i've managed to create an item thanks to you, i'm looking forward to try to make something more advanced! It's only the second game i've liked enough to try to mod it (the first one being Fallout 3), and without this kind of tutorial i'll be completly lost lol.

  • I would recommand to use not any IDs higher. Also sometimes I had issues with items but could solve them by changing the ID ... probably some things are hardcoded - or the code is just a real mess, lol.


    buildtime is about 1 hour ingame, but not really because different things reduce them (productivity, handicraft-talent ...)


    the item price can still get green with min stock 0, as I wrote, it also uses the max stock - if that number is really high, than you will still get green price values. Also if the price is changed by other factors, like high demand or low taxes it might become green.


    I experimented a lot with min-max stock and came to the conclusion that the price range works best if max stock is twice as big as min stock.


    I use 15 / 30 for high value items and artifacts and 25 / 50 for low value items and raw materials.


    I would not recommand using the modlauncher to be honest, but you can experiment with it, maybe it works for you.

  • I like a lot this game, and I meet (as most people) some problems with production automation. AI insist in using several slot in inventory for the same product type, in all building types. Also AI prioritizes production of some items on a weird manner.
    So I decided to code my own AI for this task (Production Automation), just for fun. I already got a system working as I want. Now I want to do it less dependant on the data I hardcoded in the lua scripts, and make the system able to adapt to new variations in the .dbt tables. So it will work for vanilla game, and for most mods, incuding yours (which I love), and even for any change in .dbt tables.


    What I have done is to write inside my lua scripts some hardcoded values for every item for some building types (but had plans to extend it to every building type). Now I understand better the values in items.dbt, so I plan to modify the existing items.dbt to get more accurate data to be used from the scripts, instead of hardcoding values.


    I have a single doubt that maybe you could help me to understand.
    What is (for you) the difference between:
    -- ITEM_TYPE_RESOURCE = 1,
    and
    -- ITEM_TYPE_INTERSTAGEPRODUCT = 2,
    and
    -- ITEM_TYPE_GATHERING= 8,


    and the differences between:
    -- ITEM_TYPE_NEED = 3,
    and
    -- ITEM_TYPE_SUPPLY = 4,


    I mean I don't know well all the changes you included in your mod, and I would like to not mess much with sensible data, but if it is not important for your scripts, I think some data could be changed a bit to make my scripts work without hardcoding data.


    To give you some clue on what I am doing, I will add some example for Windmill and Bakery.
    The data I'm using for these 2 building types is:
    -- Settings for WindMill
    Ingredients ={ "Wheat", "Flachs", "Fruit", "Lavender","Blackberry", "Moonflower" }
    Products = { "WheatFlour", "Oil","Dye","Saft"}
    -- Settings for Bakery
    local Ingredients ={ "WheatFlour", "Honey", "Fat", "Salt" }
    local Products = { "CakeBatter", "BreadDough", "Cookie","Wheatbread", "Pretzel","BreadRoll", "CreamPie","Cake","Candy","Pastry" }
    These data I already am able to read from items.dbt, instead of harcoding it.


    Then I use another hardcoded values to classify ingredients into "Buy" or "Gather" and Products into several categories. And these data I could also read from the 3rd column (type) in items.dbt, but the current values you have used in your mod does not fit well for my needs.


    "id" INT -1 |"name" STRING 0 |"type" INT 0 |
    ---
    BAKERY
    ---
    Ingredients
    ---
    154 "Salt" 1
    70 "WheatFlour" 1
    64 "Honey" 8
    5 "Fat" 2
    ---
    Products
    ---
    20 "BreadDough" 1
    21 "CakeBatter" 1
    23 "Wheatbread" 3
    25 "Pretzel" 3
    26 "BreadRoll" 3
    24 "Cake" 5
    27 "CreamPie" 5
    28 "Candy" 5
    29 "Pastry" 5
    ---
    WINDMILL
    ---
    Ingredients
    ---
    1 "Wheat" 8
    2 "Flachs" 8
    60 "Fruit" 8
    160 "Lavender" 8
    161 "Blackberry" 8
    164 "Moonflower" 8
    ---
    Products
    ---
    70 "WheatFlour" 1
    71 "Oil" 1
    72 "Dye" 1
    73 "Saft" 3


    If I change the coloured values, will that affect some parts of your mod?
    I would like to use that column to classify items to be usable in both vanilla and modded games, as follows:
    -- ITEM_TYPE_SPECIAL = 0, Special items, like "TowerCannonShip", not usable in production and market
    -- ITEM_TYPE_RESOURCE = 1, Resources that can be gathered/collected for free, but REQUIRES owning a field
    -- ITEM_TYPE_INTERSTAGEPRODUCT = 2, Products used as ingredients for other products
    -- ITEM_TYPE_NEED = 3, Products demanded from idle sims
    -- ITEM_TYPE_SUPPLY = 4, Other products, not demanded from idle sims, but with HIGH rate of demand renewal in market
    -- ITEM_TYPE_ARTIFACT = 5, Other products, not demanded from idle sims, but with LOW rate of demand renewal in market
    -- ITEM_TYPE_ANIMAL = 6, Animals (not important for production, if I set as type 8-Gather for sheep, pigs...)
    -- ITEM_TYPE_PRODBYMEASURE = 7, Products usable with Measures
    -- ITEM_TYPE_GATHERING= 8, Resources that can be gathered/collected for free, but DOES NOT REQUIRE owning a field
    -- ITEM_TYPE_QUESTITEM = 9 Special items, used for quests


    The distinction between type 1 and type 8 is not important for me, so type 1 could be used in another way.
    What I actually want to get from items.dbt is a way to classify items into ingredients and products, and a way to classify products into intermediate and final, and a way to classify final products depending on demands (idle sims, low rate of demand renewal and high rate of demand renewal).


    This way I can assign priorities in the production of a building, depending on product type:
    - Keep enough "Need" products to satisfy demand from idle sims
    - Keep enough ingredients (gathering/collecting free resources if possible, and purchasing other required items as needed)
    - Keep enough InterStageProducts if needed for self production, as BreadDough and CakeBatter for a Bakery
    - Produce other items depending on supply/demand on markets, or taking into account if I need some items for another building (both basic resources and intermediate products, like wheat from a farm or flour from a windmill).


    For example, WheatFlour Oil and Dye would be changed to type 2, and these will be considered as InterStage products, instead of Resources.
    Saft and Pretzel would be changed to type 4, considered as Supply, as the current idlelib.lua does not include thse as items demanded from idle sims and are not required to produce any other item. Or I could modify idlelib.lua to include these 2 items.
    For Salt, I have not studied yet the building type Mine, so I am not sure if it needs to be type 1 or type 8.


    Without my scripts, a Bakery keep producing a lot of Cookies, filling all 4 slots in Sales inventory and later more than 1 slot in normal inventory, and become at some point unable to add new bought ingredients (flour, fat, honey and salt). Idle sims cannot buy WheatBread. The profit for the building becomes negative.
    With my scripts, the Bakery keeps a balanced production, favouring in same manner both Cookies and WheatBread, and being able all the time to add new bought ingredients.
    The same for other buildings, but I'm still tweaking values, and just the Windmill could be considered almost done.


    Oh, next move would be to script the Buy and Sale automation :)