I’m trying to update the defense values of all clothing items for the DDA wiki, but it looks like the said values are determined by A) the materials each piece of clothing is made out of and B) the # of layers which are present.
Currently, values for some items made of a single material are now displayed correctly on the wiki (excluding those with incorrect layer values), but values for items consisting of different materials are still goofed up. My question is: How are armor values calculated? I’d like to figure this out so I can finish updating all the armor/clothing entries. Thanks in advance!
I suppose you mean the “Protection: Bash” / “Cut” entries in the item information window in game. They are calculated in [tt]item::bash_resist[/tt] and [tt]item::cut_resist[/tt] in src/item.cpp, I’ll paraphrase:
bash protection is [tt]resist * eff_thickness * 1.5[/tt] (rounded the usual way at 0.5)
[tt]resist[/tt] is the average of the bash resistance of all the contained materials (sum of resistance of all materials divided by number of materials). Bash resistance is defined in the json data of the material.
[tt]eff_thickness[/tt] is the thickness of the armor (lowered for damaged values). Thickness is defined in the json data of the armor (it’s called [tt]material_thickness[/tt] there).
It’s the same for cutting, just with the materials cutting resistance.
I can’t find any reference to the layering there.
Wow, BevapDin, this is exactly what I was looking for- you are a lifesaver! Thanks for digging through the code and translating it into something I can understand, I guess I can get back to working on the wiki now.