Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

New Premium Module: Tyrants of the Moonsea! Read More
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

Building Item Property Descriptions from 2das/Talk table?

See screen shot (highlighted yellow): https://i.imgur.com/Rsu2kXN.png

I'm trying to build those strings for the ItemProperties from 2da/tlk.

I found the GameStrRef in itempropdef.2da which gives me the Base Property names, but having troubles finding and referencing the SubTypeProperties descriptions.

For example the GameStrRef has "Armor Bonus vs:", but don't know where to find the "Piercing" and "+1 (AC Armor modification)" string references (I have the int values of both parameters).


Comments

  • meaglynmeaglyn Member Posts: 55
    "Piercing" is at row 1032. There's a "+1" at 1045 but I didn't find the rest of that AC string in the base game version of dialog.tlk. At 2200 is "AC Armor Modifier". I'm not sure the int for the subtype will get you to the right tlk row though...

  • dimecoindimecoin Member Posts: 13
    Thanks for looking. Which program are you using to view? and/or how to just dump entire tlk to plain text? I'm assuming there has to be some type of reference structure from 2das, but could be wrong.

  • KamirynKamiryn Member Posts: 9
    edited February 14
    dimecoin wrote: »
    I'm assuming there has to be some type of reference structure from 2das, but could be wrong.
    You are correct actually. The name of an item property can consist of up to four parts.

    The first part you've featured out for yourself already.

    For the second part look at column 'SubTypeResRef'. If the item property has a subtype that column holds the name of a 2da file. Look at that file and in Column 'Name' you'll find the 2nd part of the name. Row number is of course the subtype.

    Third and fourth part are slightly more difficult to get:

    The third parameter a item property can have is Param1Value. If you look at 'itempropdef.2da' you'll see a column 'Param1ResRef'. Usually this column is empty as most item properties don't have that parameter. If it's not empty it holds a number. Now look at the 'iprp_paramtable.2da'. That 2da-file has a column 'TableResRef' which holds the name of another 2da-file. Row number is the number from 'itempropdef.2da' (well actually it's not always that number because there are item properties where that number depends on the subtype (and then the subtype 2da-file has a column 'Param1ResRef') so it would be best to use GetItemPropertyParam1() to get the number - unfortunately however GetItemPropertyParam1() does not work for dynamically created item properties). Now look at that 2da-file (the one you've found in 'iprp_paramtable.2da'). That file has a column 'Name' and this column holds the strref for the third part. Row number is Param1Value (you can get that using GetItemPropertyParam1Value()).

    For the fourth part look at 'itempropdef.2da' again. It also has a column 'CostTableResRef'. If the item property has costtablevalue that column holds a number >0. Now look at 'iprp_costtable.2da'. Using the number from 'itempropdef.2da' you can get the fourth 2da-file in column 'Name'. Looking at that 2da-file you'll find the fourth strref in column 'Name', row number is the costTableValue (GetItemPropertyCostTableValue()).

    [edit]Just realized that third and fourth part are mixed up: costtable is supposed to be third and param1 is fourth.[/edit]

    And that's all :D
    int MK_Get2DAInt(string s2DA, string sColumn, int nRow, int nDefault=0)
    {
        string sValue = Get2DAString(s2DA, sColumn, nRow);
        return (sValue!="" ? StringToInt(sValue) : nDefault);
    }
    
    // the same as GetItemPropertyParam1() but works for dynamically created item properties too
    int MK_IPRP_GetParam1ResRefID(itemproperty iProp)
    {
        int nType = GetItemPropertyType(iProp);
        int nSubType = GetItemPropertySubType(iProp);
    
        int nParam1ResRef = MK_Get2DAInt("itempropdef", "Param1ResRef", nType, -1);
        if (nSubType!=-1)
        {
            string sSubTypeResRef = MK_IPRP_GetSubTypeResRefByID(nType);
            if (sSubTypeResRef!="")
            {
                string sParam1ResRef = Get2DAString(sSubTypeResRef, "Param1ResRef", nSubType);
                if (sParam1ResRef!="")
                {
                    nParam1ResRef = StringToInt(sParam1ResRef);
                }
            }
        }
    }
    
    string MK_IPRP_GetItemPropertyName(itemproperty iProp)
    {
        string sName="";
        if (GetIsItemPropertyValid(iProp))
        {
            int nType = GetItemPropertyType(iProp);
            sName = GetStringByStrRef(MK_Get2DAInt("itempropdef", "GameStrRef", nType, 0));
    
            int nSubType = GetItemPropertySubType(iProp);
            if (nSubType!=-1)
            {
                string sSubTypeResRef = Get2DAString("itempropdef", "SubTypeResRef", nType);
                if (sSubTypeResRef!="")
                {
                    sName+=(" " + GetStringByStrRef(MK_Get2DAInt(sSubTypeResRef, "Name", nSubType, 0)));
                }
            }
            int nCostTableValue = GetItemPropertyCostTableValue(iProp);
            int nCostTable = GetItemPropertyCostTable(iProp);
    
            if ((nCostTable>0) && (nCostTableValue!=-1))
            {
                string sCostTableResRef = Get2DAString("iprp_costtable", "Name", nCostTable);
                if (sCostTableResRef!="")
                {
                    int nCostTableValue = GetItemPropertyCostTableValue(iProp);
                    sName += (" " + GetStringByStrRef(MK_Get2DAInt(sCostTableResRef, "Name", nCostTableValue, 0)));
                }
            }
            int nParam1Value = GetItemPropertyParam1Value(iProp);
            if (nParam1Value!=-1)
            {
                // int GetItemPropertyParam1(itemproperty iprop) does not work for dynamically created
                // item properties (or dynamically created item properties do not set that value).
                // Therefor to get param1 we need a workaround:
                int nParam1 = MK_IPRP_GetParam1ResRefID(iProp);
                if (nParam1!=-1)
                {
                    string sParam1ResRef = Get2DAString("iprp_paramtable", "TableResRef", nParam1);
                    if (sParam1ResRef!="")
                    {
                        sName+=(" " + GetStringByStrRef(MK_Get2DAInt(sParam1ResRef, "Name", nParam1Value, 0)));
                    }
                }
            }
        }
        return sName;
    }
    

    Post edited by Kamiryn on
    meaglyn
  • meaglynmeaglyn Member Posts: 55
    Nice!

    Fwiw, dimecoin, I wrote a little tool to "de/compile" tlk files to text so I could store them in git. I suspect it only works on Linux although it might be able to be tweaked to build on windows. You can find it here and on github.

  • SherincallSherincall Member Posts: 375
    I did this by generating all the possible strings, adding them to the database and then looking them up from there. You can also add them to a custom 2DA file and use Get2DAString() for the lookup.

    These are all the vanilla IPs:
    https://gist.github.com/mtijanic/54a85e2e455b90e7b3a0f8d23823dcab

    And here is the code used to generate it:
    https://gist.github.com/mtijanic/153271e463918c52a252893a623bbfdc
    (requires Liareth's nwn tools: https://github.com/Liareth/NWNFileFormats )

Sign In or Register to comment.