Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 10

Author Topic: Modding material properties vs. how the properties are used by the game[0.34.11]  (Read 46628 times)

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile

Toady One has accepted well-sourced material property numbers in the past (see http://www.bay12forums.com/smf/index.php?topic=80022.0 ), especially since many of the values in the raws are currently placeholders. Take a look at the values for organic materials - most are duplicates. I wanted to contribute, but knew that DF had weird physics and likely was not using the material properties in the "correct" way, at least from the perspective of an engineer.

So I went and learned DFHack and what is known of the DF memory structures, and did various testing and disassembly reading. I now have a good grasp of how DF uses the values in the material raws. I am not sure what to do now - I could post constructive criticism in the suggestion forum, but it seems like a lot of work to develop improvements to how the numbers are used. On the other hand, modders might want to know how they can change the raw values to get desired results. I don't feel too motivated to find and correct all of the misunderstandings in the wiki.

I am willing to answer specific questions from modders in this thread, based on what I have learned. Is anyone else interested in this stuff?

EDIT:

« Last Edit: August 16, 2014, 12:39:26 am by Urist Da Vinci »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Modding material properties vs. how the properties are used by the game
« Reply #1 on: October 12, 2013, 09:46:36 pm »

I'm always interested in new things, but slightly tweaking inorganic and material values does almost nothing to influence the greater scheme of things in the game. Or I did misunderstood what exactly you plan to do.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #2 on: October 12, 2013, 10:43:57 pm »

First and most important: is more or less always better?

If some are better less and some more, which?

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #3 on: October 13, 2013, 02:04:09 am »

The wounds that creatures get from slashy/stabby/smashy weapons and body part attacks, as well as from ranged projectiles that were thrown/shot/fell/driven (minecarts), and even falling damage are all handled through a few common functions. Wrestling-related bendy/pinchy wounds are handled through different code that I haven't yet explored, so the comments below don't apply there.

The incoming attack always has a certain set of properties. Even the ground, at least in the arena, is a size 7290 object with a density of 2000, contact area of 100000, and no sharpness. The key property is the momentum of the attack, which is some variation on weight*velocity. The velocity is calculated differently for melee attacks, ranged attacks, falling, and new parabolic projectiles.

There is one set of defense calculations for use against edged attacks, and another set for use against blunt attacks. Both work on a "momentum cost" basis, but use the material property numbers differently. You can switch back and forth between them if layers are not cuttable, but can be smashed to make way for continued cutting. There is no difference at this stage between armor layers and tissue layers.

For edged defense, there is:
1. A small momentum cost to start denting the layer material, if the weapon has a higher shear yield than the layer.
2. A small momentum cost to start cutting the layer material, if the weapon has a higher shear fracture than the layer.
3. A large momentum cost to cut through the volume of the layer material, using the ratio of weapon to layer shear fractures and the weapon's sharpness.

For blunt defense, there is:
1. A check on the yielding of the weapon vs the attack momentum, to prevent soft meaty fists from punching bronze colossuses etc.
2. A momentum cost to dent the layer volume, using the layer's impact yield.
3. A momentum cost to initiate fracture in the layer volume, using the difference between the layer's impact fracture and impact yield.
4. A momentum cost to complete fracture in the layer volume, which is the same as step 3.

After a layer has been defeated via cutting or blunt fracture, the momentum is reset to the original minus a portion of the "yield" cost(s). If the layer was not defeated, reduced blunt damage is passed through to the layer below depending on layer strain/denting and flexibility.

All strains: lower is better. 50000+ causes automatic blunt pass-through.
All fractures: higher is better.
All shear yields: higher is better.
Max edge and quality => sharpness: higher is better.
Impact yields: debateable. Easily dentable but hard to fracture armor might be good. If the fracture is equal to the yield, it takes zero additional momentum to fracture the layer after denting.

The momentum costs are only for the volume of layer under the weapon, so having a small contact area allows you to cut deeper and so on. Severing only occurs when all the CONNECTS tissue on a body part is completely cut/fractured. Due to the blunt bypass, normally the skin/fat/muscle on organic creatures will prevent blunt attacks from severing body parts. If you mod out their connectivity or lower their strain values, it becomes possible to sever parts by breaking the bones.

scamtank

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #4 on: October 13, 2013, 06:38:12 am »

By "automatic blunt pass-through" do you mean that the layer just passes the force down without interference? Do non-rigid STRUCTURAL_ELASTICITY_WOVEN_THREAD garments muffle blows at all?
Logged

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #5 on: October 13, 2013, 11:41:47 am »

By "automatic blunt pass-through" do you mean that the layer just passes the force down without interference? Do non-rigid STRUCTURAL_ELASTICITY_WOVEN_THREAD garments muffle blows at all?

All of the STRUCTURAL_ELASTICITY_* items have the strain properties increased to 50000 if not already higher, so they essentially automatically dent/bruise under blunt attacks and pass the blunt attack down without interference. Their value is that they can still convert edged attacks to blunt attacks. Broken bones can be healed, but severed limbs are generally not replaceable.

STRUCTURAL_ELASTICITY_WOVEN_THREAD also caps the shear yield at 20000 and shear fracture at 30000. This means that a wooden sword can cut through an adamantine cloak. This was presumably done to prevent silk clothing from protecting against animal bites and so on. Maybe we can think of it as the blade tip slipping between the threads without cutting them.

EDIT: updated original post with list of physical laws broken.

EDIT2: It's not realistic that tissue layers that bypass blunt damage will later prevent a body part from being severed. If your arm is being held on by "bypassed" tissue and all other tissue (bone) has been broken, blunt hits should cause tensile damage in the bypassed tissue.
« Last Edit: October 13, 2013, 04:59:14 pm by Urist Da Vinci »
Logged

Vattic

  • Bay Watcher
  • bibo ergo sum
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #6 on: October 14, 2013, 08:52:55 am »

Nice research. Some of your findings could be reported as tagged "Intentional/Expected?" bug reports.
Logged
6 out of 7 dwarves aren't Happy.
How To Generate Small Islands

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #7 on: October 14, 2013, 01:53:29 pm »

I remembered that I could use M$ word to make nice-looking equations:


Let me know if you have questions about these.

The next part that I can explain, when I find my notes, is how the layer volume is determined based on relative contact areas and armor/creature properties.

IRIS_EYE_AZURE

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #8 on: October 14, 2013, 03:25:50 pm »

Back to the original question, updating the values of organic materials would be madness... much pain for little gain. For every situation where you made something more realistic, you'd break something somewhere else.

There are many problems with the simplified mechanics of DF. Here are some of the major ones I see:
  • Shear mechanics are typically directional. Any material with grain, including wood, bone, or even forged metals, will have a different sheer strength depending on the direction of the blow relative to the grain. This difference can be up to an order of magnitude.
  • There's really no such thing as impact strain. Impact resistance is about energy absorption, not force (per unit area) or even momentum.
  • Different materials used in conjunction can have significantly improved material properties. Reinforced concrete would be a good example. A more relevant example is the strength of bone inside the body, with muscle pretension and support from ligaments and tendons, versus the properties of a bone item, as in a crossbow bolt.

All in all, I see the current material properties as a very reasonable compromise. I would not worry about the material property accuracy until the game mechanics are improved (or at least announced as final).

Great work on the equations. I'll likely use them in my top-secret mod project, where I already have improved raws for many inorganic materials.
Logged

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #9 on: October 14, 2013, 04:14:22 pm »


The contact area of a body part is just: area=(part size)^(2/3)
The contact area of an armor item is also identical to the volume and thickness

If the weapon has a smaller contact area than the layer, the layer's volume is reduced by the ratio of areas.

Tissue layer thickness and armor thickness use the same units as the penetration size in the weapon raws. The weapon's penetration numbers are used when deciding how far jammed bone fragments can penetrate, which is odd when considering blunt weapons.

EDIT: df structure references (not in order):
https://github.com/angavrilov/df-structures/blob/master/df.units.xml#L843
https://github.com/angavrilov/df-structures/blob/master/df.units.xml#L675
https://github.com/angavrilov/df-structures/blob/master/df.creature-raws.xml#L436
https://github.com/angavrilov/df-structures/blob/master/df.creature-raws.xml#L441
https://github.com/angavrilov/df-structures/blob/master/df.creature-raws.xml#L582
https://github.com/angavrilov/df-structures/blob/master/df.creature-raws.xml#L398
https://github.com/angavrilov/df-structures/blob/master/df.items.xml#L768
« Last Edit: October 14, 2013, 04:25:28 pm by Urist Da Vinci »
Logged

Sergarr

  • Bay Watcher
  • (9) airheaded baka (9)
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #10 on: October 16, 2013, 05:33:07 am »

It looks like mlpf equals three different things at once.
Logged
._.

scamtank

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #11 on: October 16, 2013, 07:05:45 am »

Yeah, that's part's getting a little out there for math laymen like me. That whole multi-layer part fraction(?) thing could use some more dissection. Is there some way to see the "stored fat" number? Do the fatness description strings point this out?

Also: tell us what you know about the mysterious "factors" in the momentum equation. Could the "unknown" part at the end be the squareness of the striking plane?
Logged

IRIS_EYE_AZURE

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #12 on: October 16, 2013, 01:54:10 pm »

It looks to me like mlpf is just a typo, remove the first "=" and it makes sense.

Can I also assume that (str-soft)*curse is just the unit's net STRENGTH attribute?

Logged

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #13 on: October 16, 2013, 03:00:43 pm »

It looks like mlpf equals three different things at once.

Sorry, the intent is that it equals the first thing for most tissue, the second thing if the tissue has [THICKENS_ON_ENERGY_STORAGE], and the third thing if the tissue has [THICKENS_ON_STRENGTH].

mlpf is my abbreviation for "modified layer part fraction". The game doesn't hint at any names, so I made names up when I couldn't borrow a name that the DFHack team uses in the structures.

... Is there some way to see the "stored fat" number? Do the fatness description strings point this out?

Also: tell us what you know about the mysterious "factors" in the momentum equation. Could the "unknown" part at the end be the squareness of the striking plane?

DFHack can report the "stored_fat" numbers. See https://github.com/angavrilov/df-structures/blob/master/df.units.xml#L675 or try to find "unit.counters2.stored_fat" with a lua script. The fatness descriptions are probably connected to this number.

I'll find my notes about the factors and unknowns.

...
Can I also assume that (str-soft)*curse is just the unit's net STRENGTH attribute?
It is the strength minus the attribute rust to strength, plus the curse bonuses to strength (i.e. being a vampire). This is how the game remembers your original strength if the curse is only temporary or is removed somehow.

EDIT:

In the momentum equation, "factors" is just a few "x 1.25" boosts to the base size, one of which only happens if the attacker is berserk/enraged/tantruming, and the others don't seem to be used in normal combat.

In the momentum equation, "unknown" is more interesting. It mostly shares a function with the "factors" from the layer cost equations, except that the layer cost factors also include the were-creature special material rules. The limits for weakness/strength against materials appear to be a multiplication or division of 100. I know some of the factors that the function looks at, but this is by no means a complete list:
Spoiler (click to show/hide)
« Last Edit: October 16, 2013, 11:00:27 pm by Urist Da Vinci »
Logged

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #14 on: October 25, 2013, 01:54:43 am »

Some observations related to wrestling moves:
- Pinching, bending, and shaking all ignore clothing and armor; instead, damage is directly applied to a single body part
- Internal contained body parts are ignored, so pinching and shaking can't damage the liver, ribs, or brain for examples
- Joint bending actually targets the joint part (made of just muscle and bone) and the container limb that you grabbed doesn't matter.
- Damage is applied to soft flexible tissues. You can't punch someone's leg off (due to the blunt impact bypass), but you can pinch their leg off.
- Pinching uses COMPRESSIVE properties. Joint locks use BENDING properties. Shaking uses TENSILE properties (EDIT: or TORSION in rare cases). I have not been successful in determining the formula, but it is related to strength and body size versus the material properties.
- TORSION data is not used anywhere in combat. No section of code attempts to read the torsion properties, AFAIK.

Some observations related to material properties:
- Density is capped at 200000 (200,000)
- Yield, Fracture, and Strain properties are capped at 100000000 (100,000,000), 20x larger than Adamantine (5000000)
- Max Edge is capped at 2147483647 (2,147,483,647), 21475x larger than Adamantine (100000).
- Spec Heat is capped at 65535
Modded materials that use larger numbers won't benefit from being larger than the caps (so check your mods!)
« Last Edit: October 25, 2013, 10:05:09 pm by Urist Da Vinci »
Logged
Pages: [1] 2 3 ... 10