Well, I have tested a lot of props multiplying the costs instead of adding them, the returned cost is always the same as in the toolset, and it even looks like the float precision is not a problem anymore, strangely. So the initial function becomes:
float GetIPCost(itemproperty ip)
{
int nProp = GetItemPropertyType(ip);
int nSub = GetItemPropertySubType(ip);
int nCostTable = GetItemPropertyCostTable(ip);
float fPropCost = StringToFloat(Get2DAString("ItemPropDef", "Cost", nProp));
float fSubCost = 1.0;
float fCostValue = 1.0;
if(fPropCost == 0.0 && nSub > -1)
{
string sSubTable = Get2DAString("ItemPropDef", "SubTypeResRef", nProp);
fSubCost = StringToFloat(Get2DAString(sSubTable, "Cost", nSub));
}
if(nCostTable > 0)
{
string sCostTable = Get2DAString("iprp_costtable", "Name", nCostTable);
fCostValue = StringToFloat(Get2DAString(sCostTable, "Cost", GetItemPropertyCostTableValue(ip)));
}
return fPropCost * fSubCost * fCostValue;
}
The negative prop costs are not included because they do not affect item value, at least in the toolset. Also, this only returns the total cost of a single prop, the final formula is applied in another function handling the item cost itself, in my case, and the final item cost always seems correct.
Thanks a lot for the help!
Kato
Modifié par Kato_Yang, 16 juillet 2012 - 08:18 .