• Mods are now organized as resources. Use the Mods link above to browse for or submit a mod, tool, or prefab.

    The TFP Official Modding Forum Policy establishes the rules and guidelines for mod creators and mod users.

Materials versus blocks for MaxDamage?

I'm updating one of my older mods that modifies traps. What I am noticing is that both blocks.xml AND materials.xml have a MaxDamage variable. Why? Do they do the same thing? Let's look at wood spikes.

Blocks:
Code:
<block name="trapSpikesWoodMaster">
    <property name="Damage" value="33"/>
    <property name="Damage_received" value="33"/>
    <property name="Material" value="MtrapSpikesWood"/>
    <property name="MaxDamage" value="100"/>
</block>

Materials:
Code:
<material id="MtrapSpikesWood">
    <property name="MaxDamage" value="33"/>
</material>
So this is a tad confusing. I did leave out lines there were not important to this query, but both XML sections had more lines of code. Now, what I take from the blocks.xml code is that, when a zombie or player hits the block, the player/zed takes 33 damage and the block takes 33 damage. If I run into the block three times it should have 1hp left as I interpret "MaxDamage" to be it's hit-points. So if I hit it again, it breaks. If this is true, then what does the 33 value in the material accomplish?
 
'MaxDamage' property here is material's HP (for the blocks actually). When a block is using some material by setting property name="Material" value="SomeMaterial", it will use 'MaxDamage' property of the material. But you can override this property and set different value in the block's properties.
So your wood spikes is using 'MtrapSpikesWood' material with HP 33 ('MaxDamage'), but you overrode this value and set spikes HP to 100.
 
Last edited:
The code I showed is stock, not mine. I was using it as an example, but I understand what you're saying now. If I create a block and set Damage to 500 and MaxDamage to 20, it has 20 health and will hit a target (before armor calculations, perks, whatever) for 500. However, if I omit MaxDamage in the block and instead specify a material, the block receives the "health" (MaxDamage) of the material via inheritance. Thank you!
 
Back
Top