Lightfoot8 wrote...
First let me Give the formula for the value of an item. Oh an I should state that this is all copied and pasted from Documentation: Item Format
ItemCost = [BaseCost + 1000*(Multiplier^2 - NegMultiplier^2) + SpellCosts]*MaxStack*BaseMult +
The [color=blue">Multiplier ]Item Properties[/color] whose costs are positive.
So now we need the formula to find the value of a [color=green">Item Properties. ]Item Properties[/color] values are going to be added together, Squared them multiplied by 1000 before being added to the value of the item. example an item with only one [color=green">Item Properties with a value of 5. would end up adding ]Item Properties[/color] with values of 5 it would add (5+5)^2 * 1000 = 100,000 to the value of the item. This is why most number you see for the cost will be low.
Any way here is the formula :
ItemPropertyCost = PropertyCost + SubtypeCost + CostValue
PropertyCost
In itempropdef.2da, get the floating point value in the Cost column, at the row indexed by the
PropertyName Field of the ItemProperty Struct. If the Cost column value is ****, treat it as 0. This
floating point value is the PropertyCost
SubtypeCost
If the PropertyCost obtained above from itempropdef.2da was 0, then get the ResRef in the
SubTypeResRef column of itempropdef.2da, at the row indexed by the 2PropertyName Field of the
ItemProperty Struct. This is the resref of the subtype table 2da.
In the subtype 2da, get the floating point value in the Cost column at the row indexed by the Subtype
Field of the ItemProperty Struct. This floating point value is the SubtypeCost.
Only get the SubtypeCost if the PropertyCost was 0. If the PropertyCost was greater than 0, then the
SubtypeCost is automatically 0 instead.
CostValue
In iprp_costtable.2da, get the string in the Name column at the row indexed by the CostTable Field in
the ItemProperty Struct. This is the ResRef of the cost table 2da.
In the cost table, get the floating point value in the Cost column in the row indexed by the CostValue
Field in the ItemProperty Struct. This floating point value is the CostValue.
I hope that helps.
Sincere apologies if it's way too late to post anything more in this thread(I don't seem to be very lucky with the search engine), but since it's an extremely interesting subject clearly explained by a community senior, I could not resist, mostly considering that I'm currently coding a custom item upgrade system lol, so I would have a few questions, if I may:
1- The additional cost should be added to the final formula result, right?
2- Does the formula work well with ammo and throwing weapons, and should the additional cost be calculated for a single item in the stack or rather the whole stack?
3- What would be the most efficient way to retrieve the additional cost of an item, considering I would need to use vanilla NWN instead of the function defined in nwnx_funcs which does this?
Thanks to L8 for the posted infos + to anyone else who might answer these few questions or provide any additional infos on the subject.
EDIT: Purely as a suggestion for the OP(or maybe for a moderator, respectfully), it might be wise to make the title of this thread a bit more explicit as no doubt that the infos presented here can be very useful for a lot of builders in the community
'>
Kato
Modifié par Kato_Yang, 14 juillet 2012 - 05:58 .