Bay 12 Games Forum

Dwarf Fortress => DF Modding => Topic started by: Urist Da Vinci on October 12, 2013, 08:23:11 pm

Title: Modding material properties vs. how the properties are used by the game[0.34.11]
Post by: Urist Da Vinci on October 12, 2013, 08:23:11 pm
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:

Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Meph 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.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam 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?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci 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.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank 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?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci 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.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Vattic on October 14, 2013, 08:52:55 am
Nice research. Some of your findings could be reported as tagged "Intentional/Expected?" bug reports.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci 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.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: IRIS_EYE_AZURE 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:

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.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci 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
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Sergarr on October 16, 2013, 05:33:07 am
It looks like mlpf equals three different things at once.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank 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?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: IRIS_EYE_AZURE 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?

Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci 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)
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci 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!)
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on October 25, 2013, 01:57:19 am
I've punched limbs off in the DBZ mod before; at least, I've punched a hand or maybe an arm off.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on October 25, 2013, 02:12:12 am
I've punched limbs off in the DBZ mod before; at least, I've punched a hand or maybe an arm off.

This can happen if you mod the skin, fat, and muscle materials to have less than 50000 strain at yield (so they tear instead of just bruising), or if you remove [CONNECTS] from the skin, fat, and muscle tissues.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on October 25, 2013, 02:16:54 am
Ah, the former is indeed what happened, but I think I may have fixed that due to ridiculous "cracked muscle".
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on October 25, 2013, 02:35:40 am
Ah, the former is indeed what happened, but I think I may have fixed that due to ridiculous "cracked muscle".

If the strain is 0-24999 then the words "shattering", "chipping", "fracturing" are used.
If the strain is 25000+ then the words "tearing" and "tearing apart" are used.

Chipping is less than 25% of the surface area of the body part.
Shattering and Tearing Apart imply complete destruction of the layer, whereas Fracturing and Tearing are incomplete damage.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on October 25, 2013, 11:56:25 am
Another thing to add to wrestling is that tissues with other than [TISSUE_SHAPE:LAYER] such as hair strands and feathers are vulnerable to COMPRESSIVE force. Possibly others too, but I've never experimented with joints made from hair.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on October 25, 2013, 10:38:14 pm
Another thing to add to wrestling is that tissues with other than [TISSUE_SHAPE:LAYER] such as hair strands and feathers are vulnerable to COMPRESSIVE force. Possibly others too, but I've never experimented with joints made from hair.

Interesting. I didn't notice that before because the game doesn't tell you that you broke their hair or eyebrows if you pinch their head. Only the most recently damaged layers in the part are described. Having muscle torn as a result of a spear stab implies that the skin and fat were also torn.

Torsion:
It turns out that TORSION properties are used. Earlier I mentioned that TENSILE properties are used when a creature is shaked around by a body part after being bitten and "latched on". This is only true if the "teeth" were edged. If you remove [ATTACK_FLAG_EDGE] from Giant Desert Scorpion pincers, for example, they will deal TORSION damage instead of TENSILE damage when shaking a latched victim. This also makes the pincers into blunt weapons. I don't know of any vanilla creatures that do this, but someone must have a latching tentacle monster somewhere.

Falling Damage:
As mentioned earlier, falling damage is simulated by having a large cube of rock beat the creature to death with body slams.
peregarrett (http://www.bay12forums.com/smf/index.php?topic=114594.msg4712068#msg4712068) gave me the inspiration to try using [CE_MATERIAL_FORCE_MULTIPLIER:MAT_MULT:INORGANIC:NONE:100:1] to make creatures very vulnerable to falling damage, and [CE_MATERIAL_FORCE_MULTIPLIER:MAT_MULT:INORGANIC:NONE:1:100] to make creatures very resistant to falling damage. It works, but only in the arena where the ground is made from INORGANIC:NONE.

I investigated further using a test embark, and found that the game respects the material of the floor when considering falling damage. Falling on a sand tile used sand properties, falling on a natural basalt floor used basalt properties, and falling on a constructed steel floor used steel properties. Consequences:
- If you mod a soft, low-density floor material, falling on it will likely only bruise the skin or fat (because you nerfed the "death cube" weapon)
- Plating the bottom of a pit trap with platinum floors will increase falling damage
- Falling on a slade floor really hurts!
- Were-creatures take more damage from falling on a floor made of their special weakness material than they do from falling on other floors.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Repseki on October 26, 2013, 06:30:02 am
Now I can't stop picturing dwarves falling various distances without taking damage, only to stand up and get beaten to death by a magical cube of the appropriate material...
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on October 26, 2013, 07:02:09 am
Interesting. I didn't notice that before because the game doesn't tell you that you broke their hair or eyebrows if you pinch their head. Only the most recently damaged layers in the part are described. Having muscle torn as a result of a spear stab implies that the skin and fat were also torn.

What I do in the arena is possess the victim, press Z and then check the health screen. He'll display all wounds in detail as if he was recently diagnosed, layer by layer.

I mostly dialed in on the hair business by strangling hair-covered mammals. The throat is made from SKIN and therefore has hair stuck on top of it as per the special hair body detail plans. Every wring of the neck also spends some characters "tearing apart the hair!".

Props for the torsion thing, too.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Greiger on October 26, 2013, 12:22:25 pm
This thread is relevant to my interests so I am posting to watch.

Any idea how upright spikes factor into falling damage?  My thoughts that it basically just generates a few attacks using the spike as a weapon seems likely since the game apparently levitates a chunk of the landing materiel and beats people with it.

I'm also kinda curious how it determines those factors for skill and strength when it's the game beating someone with something instead of having a critter or trap to draw stats from.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on October 26, 2013, 01:59:57 pm
This thread is relevant to my interests so I am posting to watch.

Any idea how upright spikes factor into falling damage?  My thoughts that it basically just generates a few attacks using the spike as a weapon seems likely since the game apparently levitates a chunk of the landing materiel and beats people with it.

I'm also kinda curious how it determines those factors for skill and strength when it's the game beating someone with something instead of having a critter or trap to draw stats from.

Falling onto upright spikes, and traps in general, might be interesting to look at.

There appears to be a check to see if the pointer to the attacking unit is valid before checking some of those situational factors. Therefore if the attacking unit doesn't exist, defaults of 1000 for the strength and skill factors are used. If you look at the equations, you see that it divides by a fixed 1000 after using a factor, so a default of 1000 is equivalent to "multiply by 1".

Before checking for skills or granting experience based on a skill usage, the game checks to make sure that the unit has a soul. Soulless animated corpses are skill-less and can't learn. Babies (which is a form of insanity in DF) are also unable to use or learn skills, even "natural" skills.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Sergarr on October 27, 2013, 07:59:35 am
Babies (which is a form of insanity in DF)
Wait, what?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on October 27, 2013, 10:29:25 am
Mechanically speaking, yeah. It forces a certain pattern of abnormal behavior. Haven't you ever run into the classic error "Baby 1 cancels Clean Self: Too insane."?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on October 27, 2013, 04:05:26 pm
And doesn't it make perfect sense? No point in adding new code to do something that old code already does.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on October 28, 2013, 01:58:52 am
More falling-related stuff:
- The size of the cube of ground used to bash a falling creature is not fixed. DF appears to use a cube of 1/10th the volume (current size) of the falling creature. Therefore fat dwarves are more likely to break bones when falling than thin dwarves, because they are carrying extra volume which doesn't contribute to blunt protection.
- The falling velocity is used to find the momentum during the beating from the cube. The conversion rate between "new velocities" of falling creatures and the momentum is mysterious. There is potentially a bug here.
- Upright spikes process their attacks before the overall landing function is complete. If you fall on a weapon trap, the attacks are only processed after the landing function has completed. Damage is dealt both by the ground and the upright spikes.
- Upright spikes appear to use the falling velocity in a buggy way, ending up with momentums ~800x larger than expected. This is for when a creature falls on the stationary spikes, not when the spikes are extended into the creature via a mechanism. It's hard to notice this because the spikes/spears have a small contact area, and thus usually achieve full penetration anyways.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Greiger on October 28, 2013, 01:27:18 pm
So if I fell onto a floor from a few tiles up onto a pile of upright featherwood sporks my fate would still be as grim as if I landed on a pile of adamantine spikes, because damage appears to be at 800 times what it probably should be?

Interesting.   Now to mod in sporks as a spear item...because that would make me giggle.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on October 30, 2013, 02:17:11 am
It turns out that the velocity of the ground attacks when falling (which is multiplied by the ground weight to get the momentum) is:

vel = (speed_z - 50000)/1000

where speed_z is the "new" speed of the falling creature, from 0 to 270000. This produces similar blunt impact momentums to melee weapons over 2-5 z-level falls.

However, the code that handles the "falling on spears" part seems to be the same code that handles projectiles, and perhaps other traps (hence the "spinning" and "strikes" in the combat logs for traps). This code still uses the pre-minecart projectile system. The bug is that falling on spikes inputs the speed_z in the spot where a velocity of 1000 for the typical crossbow bolt would go.

So if I fell onto a floor from a few tiles up onto a pile of upright featherwood sporks my fate would still be as grim as if I landed on a pile of adamantine spikes, because damage appears to be at 800 times what it probably should be?

Interesting.   Now to mod in sporks as a spear item...because that would make me giggle.
Yes, it would be even more overpowered than shooting a spork out of a railgun crossbow.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Etherdrinker on October 30, 2013, 09:27:34 pm
I am not a math wise. But by reading some from Urist Da Vinci.

this can sound like a silly question, but, an equal material multi-layering part, will be pierced by the same bolt because the bolt don´t lose momentum?

That could explain why those pesky goblins keep severing my dwarves with wooden/rusty bolts?  One poor armed ranged goblin do a real mess in most of my games.

I want to find a correct layering for protect- create creatures.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on October 31, 2013, 09:16:03 am
I am not a math wise. But by reading some from Urist Da Vinci.

this can sound like a silly question, but, an equal material multi-layering part, will be pierced by the same bolt because the bolt don´t lose momentum?

That could explain why those pesky goblins keep severing my dwarves with wooden/rusty bolts?  One poor armed ranged goblin do a real mess in most of my games.

I want to find a correct layering for protect- create creatures.

Yes, you are right. In real life, cutting/fracturing a layer of material would cause the bolt to slow down, because it is losing kinetic energy and momentum. Dwarf Fortress doesn't consider this, so in most cases the bolt will go through all layers if the layers are equal. Eventually the bolt would run out of Penetration (default for a bolt is 2000), and then it would have to start dealing blunt damage. This calculation might make sense if the weapon was being pushed through a target by the strength of a creature's arm, but not for bolts that have to rely on momentum.

I suggest decreasing SHOOT_FORCE and SHOOT_MAXVEL on the crossbows and bows. Several mods also do this.

Unrelated, about traps:

The velocity of a weapon trap attack is always 200, so the momentum is:

momentum=200*(weapon weight)

The mechanism quality doesn't seem to change the momentum of a hit (but does affect trap accuracy). Note that creatures will swing heavy weapons slower, but traps swing all weapons at a fixed speed. A weapon trap swings an axe about 10x faster than a dwarf could. Therefore, weapon traps will perform better when equipped with the heaviest weapons you have available.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Etherdrinker on October 31, 2013, 11:52:54 pm
So, right now exist a fix to this weird behavior of projectiles?

or a fixed vanilla raw files.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: CryptoCactus on November 01, 2013, 08:56:45 am
So, right now exist a fix to this weird behavior of projectiles?

or a fixed vanilla raw files.

Broken Arrow (http://www.bay12forums.com/smf/index.php?topic=115448.0) is one such mod. Basically, just go into your raws, edit crossbows and bows to have SHOOT_FORCE:27 and SHOOT_MAXVEL:200, and increase relevant ammos to have an EDGE of 5.

I always do this, and it work great imo. It doesn't exactly "fix" the physics, since that's something Toady would have to do, but it does make ranged weapons behave more like bows and crossbows and less like .50cal rifles.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Lukander on November 26, 2013, 11:57:29 am
  Pardon the (possible) thread necromancy, but this seemed to be the most applicable thread. So as a newer modder I was wondering how the projectile vs. armor calculations used PROJECTILE CONTACT_AREA.
 As an example if CONTACT_AREA is 30 in the RAWs should I:
    plug [30] as the CONTACT_AREA variable
    or 30% as [0.30]
    or as 30% multiplied by PROJECTILE_SIZE [0.3*(x)]

 To clarify I am trying to calculate Projectile Absorbs The Force of Collision and Armor Absorbs The Force of Collision from the formulas found on the DF2012 Wikia page Material_Science.

P.S.: Thanks to Zivilin, Urist Da Vinci and others for their !!SCIENCE!!
P.P.S.: Oh and I am aware of when you should use a Body Parts CONTACT_AREA instead (derp).
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on November 27, 2013, 09:54:06 pm
  Pardon the (possible) thread necromancy, but this seemed to be the most applicable thread. So as a newer modder I was wondering how the projectile vs. armor calculations used PROJECTILE CONTACT_AREA.
 As an example if CONTACT_AREA is 30 in the RAWs should I:
    plug [30] as the CONTACT_AREA variable
    or 30% as [0.30]
    or as 30% multiplied by PROJECTILE_SIZE [0.3*(x)]

 To clarify I am trying to calculate Projectile Absorbs The Force of Collision and Armor Absorbs The Force of Collision from the formulas found on the DF2012 Wikia page Material_Science.

P.S.: Thanks to Zivilin, Urist Da Vinci and others for their !!SCIENCE!!
P.P.S.: Oh and I am aware of when you should use a Body Parts CONTACT_AREA instead (derp).

Uh... Those equations on the wiki were ones that we developed from the Projectile thread, and were based on empirical research (arena testing and such).

The equations and discoveries in this thread are based upon my reading a disassembly of the game code to see what it actually does. Please just forget what was written on the wiki and read this thread instead.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on November 27, 2013, 10:06:28 pm
It'd be better to edit the wiki
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Lukander on November 27, 2013, 11:11:44 pm
  I will give this thread precedence over the wiki entry, and thank you for the reply (I had figured this threads data was more relevant and correct given the method of acquiring it). Just grabbing at different sources to try for some special armor properties for modded armor.

P.S.: though as more information leaks I agree with the idea of editing the wiki. Thank you both Urist Da Vinci and Putnam. Welp, no more borderline thread derailment from me : )
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: MetalRocks on December 08, 2013, 06:44:20 am
From my tests I have concluded the density of the armor protects against blunt damage. When attacking an armor with a blunt weapon there are several impact yield checks (only made against armors, not against naked dwarves or bronze colossus).

+The first thing is that the impact_yield value of the weapon must have a minimum value of 2500: If the impact yield value of the weapon material is less than that it wont go thrugh any armor.

+Then there is another check of the impact yield of the weapon against the density of the armor.
Minimum impact_yield of the weapon to go through the armor = ((INTEGER(armor density/1000)+1)*1250)
e.g.: If the armor has material density of 3234 then ((INTEGER(3234/1000)+1)*1250) = ((3+1)*1250) = 5000 would be the minimum impact yield value to go through the armor, or else there will be no damage.

+Then there is another check for the impact to go with full force or to be weak.
Minimum impact_yield to go with full force through the armor = ((INTEGER(armor density*3/1000)+1)*1250)
e.g.: If the armor has a material density of 3400, then ((INTEGER(3400*3/1000)+1)*1250) = ((10+1)*1250) = 13750 would be the minimum impact yield value to go through the armor with full force, or else go wimp.

So an artifact lead warhammer (has 35000 impact_yield) would not go through a platinum (needs 81250 impact_yield) or silver armor (needs 40000 impact_yield) with full force.

But as all the standard metals would go through all the armors this should not be something to worry much about unless you are modding.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 08, 2013, 01:39:44 pm
From my tests I have concluded the density of the armor protects against blunt damage. When attacking an armor with a blunt weapon there are several impact yield checks (only made against armors, not against naked dwarves or bronze colossus).
...
But as all the standard metals would go through all the armors this should not be something to worry much about unless you are modding.

Uh... Did you read this thread and try using some of the equations?

1. I used a disassembler and WinDbg to read the game's code, because my own arena testing could not eliminate all of the randomness from the combat system.

2. You are neglecting the effects of IMPACT_FRACTURE.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: MetalRocks on December 08, 2013, 02:32:15 pm
Uh... Did you read this thread and try using some of the equations?

1. I used a disassembler and WinDbg to read the game's code, because my own arena testing could not eliminate all of the randomness from the combat system.

I am not refuting your formulas, which I have not tested. I just wanted to make an addition from my own observations against different size creatures, with different weapons and different armors. Mine might be only useful for armored humanoids, but it works.

2. You are neglecting the effects of IMPACT_FRACTURE.

No I am not. In my observations impact_fracture didn´t have any impact at all on the formulas above explained.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 14, 2013, 04:47:12 am
...
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.
...

Back here, I made this assertion, which turns out to not be true. After looking into MetalRocks' observations, I re-examined the code and my notes.

This appears to be the actual behavior:
(http://i.imgur.com/jTjDPpT.png)

I didn't notice it before because it reuses some of the code for blunt momentum costs, except that it conflates momentum and weight.

In this case the weight units are such that a normal steel or iron battle axe weighs 6280. The weight of the portion of an adamantine plate armor layer under a bolt's contact area is 1, whereas the layer weight for steel plate would be 78. Dense or thick armors have a better chance of being able to completely negate a blunt attack using this code, especially if the blunt attack is made with a soft implement.

Warhammers (size 400, recorded as 40 in the code) that have a material IMPACT_YIELD of 2499 or less will not be able to "defeat" even a layer weight of 1, due to rounding, and will always deflect. Likewise for bolts (size 150 => 15) and IMPACT_YIELD of 6666, provided the bolts can't cut the layer.

Given what I discovered about falling damage earlier in this thread, it may be possible to create "soft ground" that deals no falling damage - at least until you are going fast enough to explode!

Thanks, MetalRocks, for your testing!
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Greiger on December 15, 2013, 11:29:09 am
So it sounds like we could theroetically make a custom block materiel called pillowtanium or something made out of feathers giant sponge and plump helmets and line the floors or our baby catching chutes with them.

Or perhaps use it to make a metal called Nerficite that we make all the danger room spears out if.  the possibilities are endless!
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 15, 2013, 02:30:08 pm
So it sounds like we could theroetically make a custom block materiel called pillowtanium or something made out of feathers giant sponge and plump helmets and line the floors or our baby catching chutes with them.

Or perhaps use it to make a metal called Nerficite that we make all the danger room spears out if.  the possibilities are endless!

It turns out that Nerficite weapons with IMPACT_YIELD:1 will deflect off any armor/clothing, no matter the material, but hit unarmored tissues normally. Similarily, floors made of the metal will only protect clothed/armored body parts from falling damage. Babies in DF don't wear clothing, so the baby chutes concept is out.

Interesting that a bronze colossus wearing bronze armor is possibly more protected than an equivalently-fatter bronze colossus.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on December 15, 2013, 09:01:14 pm
Ah, the former is indeed what happened, but I think I may have fixed that due to ridiculous "cracked muscle".

If the strain is 0-24999 then the words "shattering", "chipping", "fracturing" are used.
If the strain is 25000+ then the words "tearing" and "tearing apart" are used.

Chipping is less than 25% of the surface area of the body part.
Shattering and Tearing Apart imply complete destruction of the layer, whereas Fracturing and Tearing are incomplete damage.

Is the strain the only value that leads to the word changes? I want to make certain creatures have a steel like skin, but still use the "tearing" and such. I assume that means I can copy all of the steel values except for the strain values, and then just keep the skin strain values?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 16, 2013, 09:44:06 pm
Ah, the former is indeed what happened, but I think I may have fixed that due to ridiculous "cracked muscle".

If the strain is 0-24999 then the words "shattering", "chipping", "fracturing" are used.
If the strain is 25000+ then the words "tearing" and "tearing apart" are used.

Chipping is less than 25% of the surface area of the body part.
Shattering and Tearing Apart imply complete destruction of the layer, whereas Fracturing and Tearing are incomplete damage.

Is the strain the only value that leads to the word changes? I want to make certain creatures have a steel like skin, but still use the "tearing" and such. I assume that means I can copy all of the steel values except for the strain values, and then just keep the skin strain values?

Not exactly - copy the steel values, but then change all the strain values to something like 25001. Steel skin wouldn't be damaged under blunt impacts if the strain was 50000+, as mentioned in this thread - it would simply be ignored and bypassed.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Walkaboutout on December 17, 2013, 12:49:35 pm
Quote
Is the strain the only value that leads to the word changes? I want to make certain creatures have a steel like skin, but still use the "tearing" and such. I assume that means I can copy all of the steel values except for the strain values, and then just keep the skin strain values?

Just a note here. Urist answered already with his suggestion, but your question totally turned a light on in my own head about a personal mod I've been working on recently. While my thread about upgrading dragon scales will give the whole story, in a nutshell one thing I did is exactly what you asked about, and I wanted to tell you my results.

Thanks to input and advice from others in that thread, I had defined tooth, claw, scale, and bone on my new dragons, with material values that were that of metals; I eventually settled on steel statistics. But of course, dragon against dragon, resulted in a ton of denting and fracturing of scale, but no penetration beyond that whatsoever.

So, first, after reading your question, I removed all the strain values. That resulted in the same issue still, dents and fractures all day long, with one notable difference. The scale strain numbers were such that now, while still never penetrating each other's scale layer's completely, those attacks were now accompanied by a ton of bruising to the fat and muscle layers beneath the outer scale layer. My ultimate solution, if anyone reading is interested, was to just define their claws and teeth as just a tiny bit better than their bone and scale properties, so that they could actually inflict real woulds again.

That's probably no surprise to you, or others, in this thread but I thought I would confirm the strain thing with my own observations of some testing there. I've since decided NOT to define strain values on any creature tissue materials that I define with other properties because, until Urist gave the numbers, there was no way of knowing what those strain values would be. And I'm lazy.

But also, to me it seems a more realistic way to have a tissue, like say scale, mimic a metal, but still have the sort of give that tissues in dwarf fortress have (thus keeping realistic things like bruises happening to lower layers below the scales). Just a way to maintain a little bit of consistency in my own mind at least.

My two cents, for what it's worth :)
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on December 20, 2013, 01:56:51 pm
Not exactly - copy the steel values, but then change all the strain values to something like 25001. Steel skin wouldn't be damaged under blunt impacts if the strain was 50000+, as mentioned in this thread - it would simply be ignored and bypassed.

Using this I keep getting dented skin instead of cut or bruised. Any ideas? Not a huge problem, but it's just a little weird when looking at a dwarfs wounds.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 20, 2013, 09:56:46 pm
Not exactly - copy the steel values, but then change all the strain values to something like 25001. Steel skin wouldn't be damaged under blunt impacts if the strain was 50000+, as mentioned in this thread - it would simply be ignored and bypassed.

Using this I keep getting dented skin instead of cut or bruised. Any ideas? Not a huge problem, but it's just a little weird when looking at a dwarfs wounds.

Tissues have to be vascular (blood-containing) to bruise. Your steel skin may not be.

If it dents instead of tearing, you just haven't hit it hard enough!
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Greiger on December 21, 2013, 01:12:20 am
Don't dents show up on unmodded dwarf skin too?  Or is have I just been playing a modded game too long?? 

I remember seeing wound lists that mention denting the outermost layer.  So dents might be what it's supposed to do, the stronger values might just make it more common compared to weaker flesh.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on December 21, 2013, 02:39:45 am
I've seen dents in heads.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on December 21, 2013, 01:55:52 pm
Don't dents show up on unmodded dwarf skin too?  Or is have I just been playing a modded game too long?? 

I remember seeing wound lists that mention denting the outermost layer.  So dents might be what it's supposed to do, the stronger values might just make it more common compared to weaker flesh.

Ah, that could be. It's been awhile since I have looked at the actual wounds in vanilla.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 21, 2013, 05:13:59 pm
If the complete volume (contact area and depth) of a layer is destroyed, the message is "tearing apart" or "shattering" depending on strain. The layer also loses its structural connectivity, which is important for severing.

If only a portion of the layer has been destroyed, the message is "tearing" or "fracturing" depending on strain. If the contact area is less than 25% of the body part's surface area, fracturing becomes "chipping".

Finally if the layer yielded a bit without taking real damage, the message is "denting", or "bruising" depending on vascular tissue.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on December 21, 2013, 05:31:47 pm
Hmm, my skin tissue has VASCULAR:1 but still shows as denting. I will have to do some more testing.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Lukander on December 28, 2013, 03:34:39 pm
One quick (and potentially dumb) question: "If the weapon has a smaller contact area than the layer, the layer's volume is reduced by the ratio of areas." -Urist Da Vinci.

How is this expressed as an equation?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 28, 2013, 06:00:41 pm
One quick (and potentially dumb) question: "If the weapon has a smaller contact area than the layer, the layer's volume is reduced by the ratio of areas." -Urist Da Vinci.

How is this expressed as an equation?

(Volume damaged by weapon) = (layer volume) x (weapon contact area) / (layer contact area)

I've mentioned somewhere how to calculate body part contact areas, but IIRC the contact area of a dwarf's upper body is ~117.

Analogy: If you put a steak on a table and then hit it with a hammer, only the part under the hammer's head is damaged. The steak's resistance to damage is determined by the volume under the hammer head, and not the volume of the entire steak.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Lukander on December 28, 2013, 06:53:18 pm
Ah, thank you... Doesn't that lead to odd behavior with armor volume and area being equal?

As an example if I double armor volume the armor area scales to match exactly so thicker armor only offers better mass for deflection purposes (but not for YIELD or FRACTURE calculations, because the ratio keeps the effective contact area constant?). Derp, well it also has an effect vs. a weapons penetration value (unless that uses the effective contact area as well?)
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 28, 2013, 09:43:23 pm
Ah, thank you... Doesn't that lead to odd behavior with armor volume and area being equal?

As an example if I double armor volume the armor area scales to match exactly so thicker armor only offers better mass for deflection purposes (but not for YIELD or FRACTURE calculations, because the ratio keeps the effective contact area constant?). Derp, well it also has an effect vs. a weapons penetration value (unless that uses the effective contact area as well?)

I made this thread so people could try to wrap their brains around the zany combat mechanics of DF. Having fun yet?  :P

Length and penetration values are unscaled by contact area, so the clothing worn by large creatures such as the Demon Lords in some Human civilizations is too thick to penetrate with unmodded weapons. Clothing and armor for large creatures is also too heavy for them to carry, due to how the armor weight and creature strength scale.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: CyberUrist on December 29, 2013, 06:37:33 pm
Posting to watch, this is great! So, if you modded dwarves to be really fat, like rolling blobs of fat with beards, and then made superslade floors, and dropped them from really high up, they would probably explode or get hurt really badly?

(This is my superslade entry, in inorganic_metal, needs improvement. Help would be appreciated, but not necessary:)
Spoiler (click to show/hide)
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on December 29, 2013, 09:38:35 pm
Posting to watch, this is great! So, if you modded dwarves to be really fat, like rolling blobs of fat with beards, and then made superslade floors, and dropped them from really high up, they would probably explode or get hurt really badly?

(This is my superslade entry, in inorganic_metal, needs improvement. Help would be appreciated, but not necessary:)
...

See this post earlier in the thread: http://www.bay12forums.com/smf/index.php?topic=131995.msg4714538#msg4714538
Your very large numbers in the material definition will be ignored or may cause errors/unintended results. I recommend just using the cap values.

Creatures explode when they hit a surface while moving fast, regardless of the distance moved/fallen. See http://www.bay12forums.com/smf/index.php?topic=120502.0 . But yes, slade floors cause more falling damage than featherwood floors.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on January 16, 2014, 11:26:26 am
Do you have any idea about falling rock calculations? Not for the trap, but just if I drop a boulder from high up on a creature what will happen?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on January 16, 2014, 09:15:17 pm
Do you have any idea about falling rock calculations? Not for the trap, but just if I drop a boulder from high up on a creature what will happen?

In addition to hitting someone with a fast-moving heavy blunt projectile, the boulder will also give the creature a downwards velocity into the floor.

IF the boulder weighs more than the creature AND the boulder is moving at a speed that normally causes creatures to explode, it will cause the creature to hit the floor and explode. Otherwise the creature just smacks into the floor for more blunt damage.

Is that what you wanted to know?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on January 16, 2014, 09:25:45 pm
Exactly what I wanted to know. Do you know from about how high up for the boulder to reach the speed needed?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on January 17, 2014, 11:13:37 pm
Exactly what I wanted to know. Do you know from about how high up for the boulder to reach the speed needed?

26+ z-levels, which should take 41 ticks to fall from start to finish. Average humanoid creatures can walk ~4 tiles in that time.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on January 22, 2014, 12:48:47 am
I figured I would ask here since it pertains to what I was asking earlier, and since you are the one who wrote the killitwith script. I am trying to create a boulder high in the air and have it drop with the possibility of it hitting someone. Testing in adventure mode I am able to create a boulder, then borrowing from your script I turn it into a projectile and let it fall, but it is not hitting my unit. After a short time later (I pass the time by sitting on the ground and then standing up again) it just falls to the ground, but there is never any combat log or injury, even with using slade boulders at a high distance.

Do you have any idea if there is any other flags that need to be checked to calculate projectile damage (or any that shouldn't be checked?)
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Meph on January 22, 2014, 11:19:10 am
Stupid idea maybe: Have you tried using ProjectileExpansion with this? If the boulder counts as a projectile, you can have it emit clouds when it hits the ground. These would affect the unit standing there as well.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on January 22, 2014, 10:17:08 pm
I figured I would ask here since it pertains to what I was asking earlier, and since you are the one who wrote the killitwith script. I am trying to create a boulder high in the air and have it drop with the possibility of it hitting someone. Testing in adventure mode I am able to create a boulder, then borrowing from your script I turn it into a projectile and let it fall, but it is not hitting my unit. After a short time later (I pass the time by sitting on the ground and then standing up again) it just falls to the ground, but there is never any combat log or injury, even with using slade boulders at a high distance.

Do you have any idea if there is any other flags that need to be checked to calculate projectile damage (or any that shouldn't be checked?)

A brief check with DFHack in the arena reveals:

Falling creature has following flags enabled (true):

no_impact_destroy
piercing
parabolic
unk9


Falling ITEM has following flags enabled:

no_impact_destroy
bouncing
piercing
parabolic
unk9
no_collide


Please note that the names of the flags were assigned by DFHack researchers, and may not represent all the actual uses of the flags.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on January 22, 2014, 11:28:17 pm
Hmm thought I tried all of those, but maybe I left the no_collide on false because it seemed like I would want it to collide. Will try again. Thanks.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on January 26, 2014, 03:32:06 pm
For the less mathematically inclined, here is a early version of a DFHack lua script:

Code: (test.lua) [Select]
--Calculates combat info for weapons/armor on a creature. Alpha version!

--Future goal is to calculate info for body part weapons, wounded tissue layers
--ranged weapons
--misc objects?

unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor!  Aborting!")
return
end

print("Creature size (base/current): ", unit.body.size_info.size_base, unit.body.size_info.size_cur)
print("Creature strength (base): ", unit.body.physical_attrs.STRENGTH.value) --should update to use curse strengths etc.
print(" ")

for k,v in pairs(unit.inventory) do

--print(v.mode)
--enum-item Hauled 0
--enum-item Weapon 1
--enum-item Worn 2
--enum-item InBody 3
--enum-item Flask 4
--enum-item WrappedAround 5
--enum-item StuckIn 6
--enum-item InMouth 7
--enum-item Shouldered 8
--enum-item SewnInto 9

vitype=df.item_type[v.item:getType()]
print(vitype)
material=dfhack.matinfo.decode(v.item)
matdata=material.material.strength
vmatname=material.material.state_name.Solid
--print(vmatname, v.item.subtype.name) --WOULD ENABLE THIS BUT BUG ON QUIVERS, OTHER ITEMS W/O SUBTYPES!

vbpart=unit.body.body_plan.body_parts[v.body_part_id]
print(vbpart.name_singular[0].value)

if vitype=="WEAPON" then
print(vmatname, v.item.subtype.name)
v.item:calculateWeight()
effweight=unit.body.size_info.size_cur/100+v.item.weight*100+v.item.weight_fraction/10000
actweight=v.item.weight*1000+v.item.weight_fraction/1000
if v.item.subtype.flags.HAS_EDGE_ATTACK==true then
print("shear yield, shear fracture: ", matdata.yield.SHEAR, matdata.fracture.SHEAR)
print("Sharpness: ", v.item.sharpness)
end
print("NAME", "EDGE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for kk,vv in pairs(v.item.subtype.attacks) do
vvel=unit.body.size_info.size_base * unit.body.physical_attrs.STRENGTH.value * vv.velocity_mult/1000/effweight/1000
vmom=vvel*actweight/1000+1
vedge="blunt"
vcut=""
if vv.edged==true then
vedge="edged"
vcut=100
end
print(vv.verb_2nd, vedge, vv.contact, vv.penetration, actweight/1000, math.floor(vvel), math.floor(vmom))
end

end


if vitype=="ARMOR" or vitype=="HELM" or vitype=="GLOVES" or vitype=="SHOES" or vitype=="PANTS" then
print(vmatname, v.item.subtype.name)
actvol=v.item:getVolume()
v.item:calculateWeight()
actweight=v.item.weight*1000+v.item.weight_fraction/1000
vbca=actvol*matdata.yield.IMPACT/100/500/10
vbcb=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
vbcc=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
deduct=vbca/10
if matdata.strain_at_yield.IMPACT >= 50000 or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_METAL==true or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_ALL==true then
vbcb=0
vbcc=0
end
print("Full contact blunt momentum resist: ", math.floor(vbca+vbcb+vbcc))
print("Contact 10 blunt momentum resist: ", math.floor((vbca+vbcb+vbcc)*10/actvol))
print("Unbroken momentum deduction (full,10): ", math.floor(deduct), math.floor(deduct*10/actvol))
print("Volume: ", actvol)
print("Contact area: ", actvol)
print("Penetration: ", actvol)
print("Weight: ", actweight/1000)
vshyre=matdata.yield.SHEAR
vshfre=matdata.fracture.SHEAR
if v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true and vmatname ~= "leather" then
if vshyre>20000 then vshyre=20000 end
if vshfre>30000 then vshfre=30000 end
end
print("shear yield, shear fracture: ", vshyre, vshfre)
end

print(" ")
end

Questions/comments/suggestions are welcome.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Di on January 28, 2014, 11:55:29 am
What about armor levels, how are they used in combat?
Namely, what would be difference between mail shirt and breastplate when slashed\stabbed in upper body? Apart from mail being elastic.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on January 28, 2014, 08:52:11 pm
What about armor levels, how are they used in combat?
I don't understand this question. There is an [ARMORLEVEL:X] token where X is 1,2, or 3 that is used by the AI to decide if a certain armor is a better choice to wear, and other effects. It doesn't appear to have a combat benefit.

What about armor levels, how are they used in combat?
Namely, what would be difference between mail shirt and breastplate when slashed\stabbed in upper body? Apart from mail being elastic.

If the weapon that is doing the slashing/stabbing can cut the armor material, then no real difference.

If the weapon can't cut the armor material and does blunt damage instead, the breastplate provides superior blunt protection (to the wearer). However, if the blunt damage is enough to break the breastplate then the cutting will resume on the flesh below. The mail sucks at blunt protection, but it won't break under blunt damage, instead passing on only blunt damage to the flesh below. This means that mail-wearers can be less likely to have their arms and legs cut off in certain situations (but the bones will still be broken!).
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Vattic on February 15, 2014, 06:00:19 pm
Do the TISSUE_MAT_STATE tokens have any impact in combat? They only appear on generated creatures tissues (specifically the powder ones).

I'm not sure what values it can take. The string dump lists these:
SOLID
LIQUID
POWDER
SOLID_POWDER
PASTE
SOLID_PASTE
PRESSED
SOLID_PRESSED
ALL_SOLID

But creatures from extracted raws don't have the last five and include GAS.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on February 15, 2014, 06:15:00 pm
I think it should be the same states as the rest.

The impact should be as expected from, say, forgotten beasts made entirely out of powder.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on February 16, 2014, 03:06:48 am
Do the TISSUE_MAT_STATE tokens have any impact in combat? They only appear on generated creatures tissues (specifically the powder ones).

I'm not sure what values it can take. The string dump lists these:
SOLID
LIQUID
POWDER
SOLID_POWDER
PASTE
SOLID_PASTE
PRESSED
SOLID_PRESSED
ALL_SOLID

But creatures from extracted raws don't have the last five and include GAS.

Non-solid tissues (i.e. liquids, gases, powders) don't use the strength material properties at all - the body part automatically fails on defense, breaking away some or all of the layer. In vanilla Iron Men, only the iron tissue layer provides protection.

Punch/kick attacks from vanilla Fire Men "pass through" other creatures, causing no harm.

A bronze colossus modded in the arena to be made of liquid water was able to cause serious blunt damage with its natural attacks. However, any weapon was capable of damaging the liquid water colossus.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Vattic on February 16, 2014, 04:12:15 pm
Fair enough. I presume when you say non-solid you are also counting SOLID_POWDER and similar? I say this because SOLID_POWDER has bits breaking off with every attack also.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on February 16, 2014, 05:33:59 pm
Unless you'd call a pile of sand a solid object, yes.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on February 17, 2014, 01:38:34 am
Updated my combat calculator lua script to include creature body parts. Since we can't currently see the ATTACK data, I can't do teeth/horns/etc., but just assume that stances and grasps are attacks.

Code: (combat.lua) [Select]
--Calculates combat info for weapons/armor. Alpha version!

--Future goal is to calculate info for body part weapons (using attack info), wounded tissue layers
--ranged weapons
--misc objects?

unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor!  Aborting!")
return
end

print("Creature size (base/current): ", unit.body.size_info.size_base, unit.body.size_info.size_cur)
print("Creature strength (base): ", unit.body.physical_attrs.STRENGTH.value) --should update to use curse strengths etc.
print(" ")

for k,v in pairs(unit.inventory) do

--print(v.mode)
--enum-item Hauled 0
--enum-item Weapon 1
--enum-item Worn 2
--enum-item InBody 3
--enum-item Flask 4
--enum-item WrappedAround 5
--enum-item StuckIn 6
--enum-item InMouth 7
--enum-item Shouldered 8
--enum-item SewnInto 9

vitype=df.item_type[v.item:getType()]
print(vitype)
material=dfhack.matinfo.decode(v.item)
matdata=material.material.strength
vmatname=material.material.state_name.Solid
--print(vmatname, v.item.subtype.name) --WOULD ENABLE THIS BUT BUG ON QUIVERS, OTHER ITEMS W/O SUBTYPES!

vbpart=unit.body.body_plan.body_parts[v.body_part_id]
print(vbpart.name_singular[0].value)

if vitype=="WEAPON" then
print(vmatname, v.item.subtype.name)
v.item:calculateWeight()
effweight=unit.body.size_info.size_cur/100+v.item.weight*100+v.item.weight_fraction/10000
actweight=v.item.weight*1000+v.item.weight_fraction/1000
if v.item.subtype.flags.HAS_EDGE_ATTACK==true then
print("shear yield, shear fracture: ", matdata.yield.SHEAR, matdata.fracture.SHEAR)
print("Sharpness: ", v.item.sharpness)
end
print("NAME", "EDGE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for kk,vv in pairs(v.item.subtype.attacks) do
vvel=unit.body.size_info.size_base * unit.body.physical_attrs.STRENGTH.value *

vv.velocity_mult/1000/effweight/1000
vmom=vvel*actweight/1000+1
vedge="blunt"
vcut=""
if vv.edged==true then
vedge="edged"
vcut=100
end
print(vv.verb_2nd, vedge, vv.contact, vv.penetration, actweight/1000, math.floor(vvel), math.floor(vmom))
end
actvol=v.item:getVolume()
print("Blunt deflect if layer weight more than:", actvol * matdata.yield.IMPACT / 100 / 500)

end


if vitype=="ARMOR" or vitype=="HELM" or vitype=="GLOVES" or vitype=="SHOES" or vitype=="PANTS" then
print(vmatname, v.item.subtype.name)
actvol=v.item:getVolume()
v.item:calculateWeight()
actweight=v.item.weight*1000+v.item.weight_fraction/1000
vbca=actvol*matdata.yield.IMPACT/100/500/10
vbcb=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
vbcc=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
deduct=vbca/10
if matdata.strain_at_yield.IMPACT >= 50000 or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true or

v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_METAL==true or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_ALL==true

then
vbcb=0
vbcc=0
end
print("Full contact blunt momentum resist: ", math.floor(vbca+vbcb+vbcc))
print("Contact 10 blunt momentum resist: ", math.floor((vbca+vbcb+vbcc)*10/actvol))
print("Unbroken momentum deduction (full,10): ", math.floor(deduct), math.floor(deduct*10/actvol))
print("Volume/contact area/penetration: ", actvol)
print("Weight: ", actweight/1000)
vshyre=matdata.yield.SHEAR
vshfre=matdata.fracture.SHEAR
if v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true and vmatname ~= "leather" then
if vshyre>20000 then vshyre=20000 end
if vshfre>30000 then vshfre=30000 end
end
print("shear yield, shear fracture: ", vshyre, vshfre)
end

print(" ")
end    --end of unit inventory loop


--printall(unit.body.body_plan.attacks) --wait for next DFHack version?
--print(" ")

print("BODY PART ATTACKS (some assumptions!)")
print("NAME", " ", "SIZE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for k,v in pairs(unit.body.body_plan.body_parts) do
if v.flags.STANCE==true or v.flags.GRASP==true then
--ASSUME THAT ALL GRASP/STANCE PARTS ARE COMBAT
partsize = math.floor(unit.body.size_info.size_cur * v.relsize / unit.body.body_plan.total_relsize)
contact = math.floor(partsize ^ 0.666)
partweight = math.floor(partsize * 500 / 100) --bone, change to 8250 for bronze colossus etc.
vvel = 100 * unit.body.physical_attrs.STRENGTH.value / 1000 --some assumptions
vmom = vvel * partweight / 1000 + 1
print(v.name_singular[0].value, partsize, contact, partsize, partweight/1000, vvel, vmom)
end
end


An amusing footnote is that organic creature punches and kicks use the "bone" material of the hand/foot for attack purposes. This also determines the part weight during combat, so unless your hand is made of a single material, it will hit with a different weight than you'd see if you severed the hand and examined it. Fingers, gloves, and gauntlets don't count for anything. Not only do heavy/large body parts hit for more momentum, there is no penalty in the "swing speed" or "vel" for doing so. Giant sponges "push" with their single massive body part. Since body part sizes/weights don't benefit melee (equipped) weapon usage, a giant or colossus will do far more damage with its natural attacks than it will with any equipped weapon.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on March 09, 2014, 11:47:39 am
Never stop doing good things, Urist.

I've finally started looking at these equations to plan stuff and I'm a little stumped by the momentum deduction thing. What does "max(shear cost 1, blunt cost 1)" mean?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on March 09, 2014, 11:52:56 am
Shear cost 1 or blunt cost 1 is used, whichever is higher.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 04, 2014, 02:47:09 am
Very interesting read. Nice work. I'll have to come back to this when I have a little more time.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 04, 2014, 03:00:53 am
An amusing footnote is that organic creature punches and kicks use the "bone" material of the hand/foot for attack purposes. This also determines the part weight during combat, so unless your hand is made of a single material, it will hit with a different weight than you'd see if you severed the hand and examined it. Fingers, gloves, and gauntlets don't count for anything. Not only do heavy/large body parts hit for more momentum, there is no penalty in the "swing speed" or "vel" for doing so. Giant sponges "push" with their single massive body part. Since body part sizes/weights don't benefit melee (equipped) weapon usage, a giant or colossus will do far more damage with its natural attacks than it will with any equipped weapon.

In a way it does sort of makes sense that an absolutely massive titan sized creature would do far more damage simply buy punching you than hitting you with a relatively tiny weapon. It would be a bit like if a person came up and punched you vs trying to beat you to death with a tooth pick rather than a proper sized staff. The punch would do more damage simply because the weapon's size is so mismatched with the wielder that they couldn't get the proper leverage on it to deliver the full power of the blow through the tiny toothpick. I do see what you are getting at, though. A large man leaning his weight into a blow with a long sword would do more damage than a smaller man doing the same thing or how a fist with a 5lb iron gauntlet on it would deliver a more powerful blow than an ungloved fist.

As for a large heavy body part not suffering a velocity penalty, creatures tend to develop sufficient musculature to compensate for the weight of their limbs. In other words, a big heavy man's leg will naturally be stronger than a thin light man's leg simply because it has adapted to carrying his weight over the course of his life. A man with shorter, lighter arms can generally punch at a faster rate than a big, long armed and heavy muscled man but the speed at which their firsts are actually traveling aren't that different. The taller, heavier man with the longer arms simply has a longer distance over which his fist must travel before reaching full extension. Similarly a man with very long legs will sprint with less strides per minute than a shorter man but can usually run as fast or faster than the shorter man of the same fitness. The actual velocity at which the tall man's feet are moving isn't less than that of the short man's. If anything it will actually tend to be higher. Taking this to an extreme a mythical giant might only take a single step every ten seconds or so but that stride would cover half a football field. His foot would actually be traveling very quickly, he just wouldn't be taking many strides per minute.

Hmmm, your discovery concerning natural attacks has given me a hilarious idea. I wonder how hard it would be to mod in platinum bones for all creatures.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Hugo_The_Dwarf on April 04, 2014, 08:55:56 am
...

Hmmm, your discovery concerning natural attacks has given me a hilarious idea. I wonder how hard it would be to mod in platinum bones for all creatures.
by make them platinum you mean just the solid density (aka weight?) you can just change the bone_template for materials to have bone as heavy has platinum all the time, it will then quickly transfer to all bone bearing creatures.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 04, 2014, 02:27:10 pm
...

Hmmm, your discovery concerning natural attacks has given me a hilarious idea. I wonder how hard it would be to mod in platinum bones for all creatures.
by make them platinum you mean just the solid density (aka weight?) you can just change the bone_template for materials to have bone as heavy has platinum all the time, it will then quickly transfer to all bone bearing creatures.

That's a nice elegantly simple solution, thanks. It's not quit the same as actually turning their bone's to platinum but as far as combat goes it will work great.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Hugo_The_Dwarf on April 04, 2014, 03:09:43 pm
well if you really wanted to inject platinum bones, make a custom Tissue_Template that is a copy of the BONE_TEMPLATE however instead of [TISSUE_MATERIAL:LOCAL_CREATURE_MAT:BONE] change it to INORGANIC:PLATINUM
Add in your new tissue in the STANDARD_TISSUES body detail plan "[ADD_TISSUE:PLAT:PLAT_BONE_TEMPLATE]"
then change the VERTEBRAE_TISSUE_LAYERS body detail plan and overwrite all  ARG4:# with PLAT:#

done now all creatures that use those two body detail plans have platinum for bones
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 06, 2014, 12:02:05 am
well if you really wanted to inject platinum bones, make a custom Tissue_Template that is a copy of the BONE_TEMPLATE however instead of [TISSUE_MATERIAL:LOCAL_CREATURE_MAT:BONE] change it to INORGANIC:PLATINUM
Add in your new tissue in the STANDARD_TISSUES body detail plan "[ADD_TISSUE:PLAT:PLAT_BONE_TEMPLATE]"
then change the VERTEBRAE_TISSUE_LAYERS body detail plan and overwrite all  ARG4:# with PLAT:#

done now all creatures that use those two body detail plans have platinum for bones

Thank you for that. :)
I am quite new to modding so I know very little about it and it would have likely taken me quite a while to figure it out on my own. I was lured into the modding part of the forum from a foreign weapons thread and now I find myself unable to leave this fascinating place. Modding is quite addictive.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Zorbeltuss on April 15, 2014, 08:13:26 am
I'm assuming that whips use their full weight to add to their momentum unlike a real flexible weapon would use. Is this correct?

/Zorbeltuss
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on April 15, 2014, 08:59:45 am
Well, yeah. Vanilla whips behave more like magic picks with supernatural momentum.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 15, 2014, 09:07:19 am
I'm assuming that whips use their full weight to add to their momentum unlike a real flexible weapon would use. Is this correct?

Correct.

The real killer though is that the contact area stays small throughout the thickness of the hit (like an edged stab wound). A thin blunt weapon IRL would not "chip" bones, as the contact area would expand conically with depth. No chipping on leg bones at least - fingers might chip because of thinner tissue covering the bone.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 18, 2014, 01:30:20 pm
Updated the combat script to consider non-weapon items held in the hands as misc weapons:
Code: (combat.lua) [Select]
--Calculates combat info for weapons/armor. Alpha version!

--Future goal is to calculate info for body part weapons (using attack info), wounded tissue layers
--ranged weapons


unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor!  Aborting!")
return
end

print("Creature size (base/current): ", unit.body.size_info.size_base, unit.body.size_info.size_cur)
print("Creature strength (base): ", unit.body.physical_attrs.STRENGTH.value) --should update to use curse strengths etc.
print(" ")

for k,v in pairs(unit.inventory) do

--print(v.mode)
--enum-item Hauled 0
--enum-item Weapon 1
--enum-item Worn 2
--enum-item InBody 3
--enum-item Flask 4
--enum-item WrappedAround 5
--enum-item StuckIn 6
--enum-item InMouth 7
--enum-item Shouldered 8
--enum-item SewnInto 9

vitype=df.item_type[v.item:getType()]
print(vitype)
material=dfhack.matinfo.decode(v.item)
matdata=material.material.strength
vmatname=material.material.state_name.Solid
--print(vmatname, v.item.subtype.name) --WOULD ENABLE THIS BUT BUG ON QUIVERS, OTHER ITEMS W/O SUBTYPES!

vbpart=unit.body.body_plan.body_parts[v.body_part_id]
print(vbpart.name_singular[0].value)

if vitype=="WEAPON" then
print(vmatname, v.item.subtype.name)
v.item:calculateWeight()
effweight=unit.body.size_info.size_cur/100+v.item.weight*100+v.item.weight_fraction/10000
actweight=v.item.weight*1000+v.item.weight_fraction/1000
if v.item.subtype.flags.HAS_EDGE_ATTACK==true then
print("shear yield, shear fracture: ", matdata.yield.SHEAR, matdata.fracture.SHEAR)
print("Sharpness: ", v.item.sharpness)
end
print("NAME", "EDGE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for kk,vv in pairs(v.item.subtype.attacks) do
vvel=unit.body.size_info.size_base * unit.body.physical_attrs.STRENGTH.value *

vv.velocity_mult/1000/effweight/1000
vmom=vvel*actweight/1000+1
vedge="blunt"
vcut=""
if vv.edged==true then
vedge="edged"
vcut=100
end
print(vv.verb_2nd, vedge, vv.contact, vv.penetration, actweight/1000, math.floor(vvel), math.floor(vmom))
end
actvol=v.item:getVolume()
print("Blunt deflect if layer weight more than:", actvol * matdata.yield.IMPACT / 100 / 500)

else
if v.mode==1 then
--item held in hands treated as misc weapon
--1000 velocity mod, power math for contact and penetration
print(vmatname, "(misc weapon)") --v.item.subtype.name quiver bug
actvol=v.item:getVolume()
v.item:calculateWeight()
actweight=v.item.weight*1000+v.item.weight_fraction/1000
effweight=unit.body.size_info.size_cur/100+v.item.weight*100+v.item.weight_fraction/10000
misccontact=math.floor(actvol ^ 0.666)
miscpene=math.floor((actvol*10000) ^ 0.333)
print("NAME", "EDGE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
vvel=unit.body.size_info.size_base * unit.body.physical_attrs.STRENGTH.value/effweight/1000
vmom=vvel*actweight/1000+1
vedge="blunt"
print("strike", vedge, misccontact, miscpene, actweight/1000, math.floor(vvel), math.floor(vmom))
print("Blunt deflect if layer weight more than:", actvol * matdata.yield.IMPACT / 100 / 500)
print(" ")
end
end


if vitype=="ARMOR" or vitype=="HELM" or vitype=="GLOVES" or vitype=="SHOES" or vitype=="PANTS" then
print(vmatname, v.item.subtype.name)
actvol=v.item:getVolume()
v.item:calculateWeight()
actweight=v.item.weight*1000+v.item.weight_fraction/1000
vbca=actvol*matdata.yield.IMPACT/100/500/10
vbcb=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
vbcc=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
deduct=vbca/10
if matdata.strain_at_yield.IMPACT >= 50000 or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true or

v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_METAL==true or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_ALL==true

then
vbcb=0
vbcc=0
end
print("Full contact blunt momentum resist: ", math.floor(vbca+vbcb+vbcc))
print("Contact 10 blunt momentum resist: ", math.floor((vbca+vbcb+vbcc)*10/actvol))
print("Unbroken momentum deduction (full,10): ", math.floor(deduct), math.floor(deduct*10/actvol))
print("Volume/contact area/penetration: ", actvol)
print("Weight: ", actweight/1000)
vshyre=matdata.yield.SHEAR
vshfre=matdata.fracture.SHEAR
if v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true and vmatname ~= "leather" then
if vshyre>20000 then vshyre=20000 end
if vshfre>30000 then vshfre=30000 end
end
print("shear yield, shear fracture: ", vshyre, vshfre)
end

print(" ")
end    --end of unit inventory loop


--printall(unit.body.body_plan.attacks) --wait for next DFHack version?
--print(" ")

print("BODY PART ATTACKS (some assumptions!)")
print("NAME", " ", "SIZE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for k,v in pairs(unit.body.body_plan.body_parts) do
if v.flags.STANCE==true or v.flags.GRASP==true then
--ASSUME THAT ALL GRASP/STANCE PARTS ARE COMBAT
partsize = math.floor(unit.body.size_info.size_cur * v.relsize / unit.body.body_plan.total_relsize)
contact = math.floor(partsize ^ 0.666)
partweight = math.floor(partsize * 500 / 100) --bone, change to 8250 for bronze colossus etc.
vvel = 100 * unit.body.physical_attrs.STRENGTH.value / 1000 --some assumptions
vmom = vvel * partweight / 1000 + 1
print(v.name_singular[0].value, partsize, contact, partsize, partweight/1000, vvel, vmom)
end
end


So now you can check the combat data for shields, socks, crutches, etc.

This is currently not able to give data for:
- Stabbing someone with arrows/bolts in melee
- Using a tool that has an attack (i.e. knives)
- Shooting with a ranged weapon
- Throwing an object

As previously mentioned, some averaging assumptions had to be made, and circumstantial bonuses/penalties are neglected.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 20, 2014, 12:48:59 am
There is a question I have been trying to figure for a while now which is how does DF determine when an appendage is severed. I've done some of my own VERY primitive testing on the subject just using the arena, and I noticed some trends but have no idea how the math behind it works. Has anyone properly figured this one out?

My observations pointed to a couple of likely mechanics that are involved but this is all based on watching only the most basic of injury trends in the battle logs between various different sized creatures and how their limbs respond to being struck with edged weapons with radically different properties.

I noticed a few things. To begin with only edged weapons appear to sever body parts.

Another thing I noted is that the relative size of the contact area of the blade and the size of the appendage being struck seems to be used in some fashion to determine if the blade is wide enough to cut the body part completely off. The smaller the creature and body part was, the smaller the contact area the weapon could possess and still have a chance to cut the appendage off.

The other thing that seemed to matter was the penetration of the attack. The blade seemed to need to cut both deeply enough and widely enough for the limb to come off. It also seemed like it mattered if the body part was already damaged or not but that may have just been me seeing trends that aren't there in a small group of random results.

If people have already done some real dwarven Science! on this subject I would love a link to it.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on April 20, 2014, 01:37:43 am
All bodyparts are shaped like x cm3 cubes, the amount depending on the creature's total body volume and the bodypart's RELSIZE. If the edged implement has enough energy behind it, enough penetration depth and a wide enough contact area, it will sever the thing.

If the contact area is smaller than the width of the bodypart, it just ruins all tissue layers without taking the bodypart off. If the penetration is less than the thickness of the bodypart, the open wound stops at that certain depth and the remaining strike energy carries on as blunt force that may still crack bones. If the bodypart itself consists of nothing but rigid, breakable tissues, even a strong enough blunt strike can snap it right off. Creatures made of stone come to mind.

There isn't much nuance in common situations because contact areas, weapon sizes and material weaknesses tend towards "way way overkill".
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 20, 2014, 01:48:16 am
Thanks for the heads up. It seems like my guesswork was roughly on target. So does the game take into consideration how damaged the limb already is when determining if the blade passes all the way through it or not? I ask because one of the creatures I did a lot of testing on was a Bronze Colossus and despite running a great many battles using various weapons I never once saw a colossus lose a limb on the first strike. It was always after the body part had been hit multiple times that it finally came off. It could be that in the 30 or so fights ran I simply never had a dwarf get lucky on the first shot to a given appendage but it does seem a bit anomalous.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 20, 2014, 02:44:51 am
Body parts do accumulate damage, and it might take some time to hack through a solid metal limb. You could use the equations for a colossus arm. I should update the calculator for creature body parts. Main reason why that hasn't happened is that the list could be rather long and repetitive.

Scamtank covered most of the points.

I would add that flexible skin/fat/muscle layers, which bypass blunt damage rather than being destroyed, can't be severed by blunt damage. This allows the bones to be smashed without the limb popping off. I suppose repeated pounding with a morningstar (which has a small amount of edge attack) would eventually sever a person's arm in DF - untested.

Also the head and lower body are somewhat special in that you have to destroy the spine "organ" within before the container part is severed. This is mostly driven by the random chance for which organ is hit.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 21, 2014, 01:18:01 am
I would add that flexible skin/fat/muscle layers, which bypass blunt damage rather than being destroyed, can't be severed by blunt damage. This allows the bones to be smashed without the limb popping off. I suppose repeated pounding with a morningstar (which has a small amount of edge attack) would eventually sever a person's arm in DF - untested.

I've actually done a load of arena testing with that particular weapon due to the fact that it is highly unique in the sort of damage it does and it came up in another thread. I originally believed it was impossible for it to sever anything but teeth but then I realized this was simply because I had been doing all my tests on organic creatures that can feel pain. The injuries that morningstars cause tend to be so severe that the creatures collapse and are killed long before that little bit of edged damage can add up enough to actually sever a body part. You have to use it on something like a bronze colossus to see a morningstar sever large appendages. It only occurs after pages and pages of combat.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 21, 2014, 09:25:07 am
I would add that flexible skin/fat/muscle layers, which bypass blunt damage rather than being destroyed, can't be severed by blunt damage. This allows the bones to be smashed without the limb popping off. I suppose repeated pounding with a morningstar (which has a small amount of edge attack) would eventually sever a person's arm in DF - untested.

I've actually done a load of arena testing with that particular weapon due to the fact that it is highly unique in the sort of damage it does and it came up in another thread. I originally believed it was impossible for it to sever anything but teeth but then I realized this was simply because I had been doing all my tests on organic creatures that can feel pain. The injuries that morningstars cause tend to be so severe that the creatures collapse and are killed long before that little bit of edged damage can add up enough to actually sever a body part. You have to use it on something like a bronze colossus to see a morningstar sever large appendages. It only occurs after pages and pages of combat.

Tested in the arena with a horde of allied human morningstar users vs a single human husk. The husk quickly ended up as a heavily pulped (but still going!) limbless head/upper body/lower body. Theory confirmed.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 23, 2014, 08:07:11 pm
Tested in the arena with a horde of allied human morningstar users vs a single human husk. The husk quickly ended up as a heavily pulped (but still going!) limbless head/upper body/lower body. Theory confirmed.

Good to know. I had never actually tested it with an organic creature that could survive the beating for long enough to lose a limb. All my testing was done with Colossi and standard organic units. I assume this means that any edged weapon can eventually sever appendages since the morning star is about as extreme an example as you can get with its tiny contact area and poor penetration.



Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on April 23, 2014, 09:37:56 pm
So you can deepen existing wounds with new attacks? Huh. I've been wondering about that.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: GavJ on April 24, 2014, 04:03:10 am
Do you know how the game determines attack type and severity for flying objects?
Specifically, I am interested in knowing how to choose the most appropriate ammo for different circumstances (or overall if it's all the same except for density or something) for minecart shotguns.

Like, does a silver bar do roughly the same amount and type of damage as a flying silver serrated disc (I don't know if they weigh the same, let's say they do)? Etc.?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 24, 2014, 09:16:15 am
Do you know how the game determines attack type and severity for flying objects?
Specifically, I am interested in knowing how to choose the most appropriate ammo for different circumstances (or overall if it's all the same except for density or something) for minecart shotguns.

Like, does a silver bar do roughly the same amount and type of damage as a flying silver serrated disc (I don't know if they weigh the same, let's say they do)? Etc.?

Rough steps:
1. A flying object is a projectile. These are seperate in memory from the attacking creature, and record things like velocity, position, and direction. We get the velocity. Things like traps also use fake projectile data.
2a. If the item has defined attacks (i.e. a trap component, weapon, or certain tools) then one of those is chosen.
2b. If the item doesn't have attacks, treat it as a misc weapon with contact area that depends on size, except that we check the sharpness (melee misc weapons assume zero sharpness i.e. blunt).

So the serrated disc has the potential to sever parts if shotgunned from a minecart.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on April 24, 2014, 03:09:41 pm
I think the "chooses from attacks" also works with the minecart itself for collisions.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: GavJ on April 24, 2014, 06:51:09 pm
Quote
2a. If the item has defined attacks (i.e. a trap component, weapon, or certain tools) then one of those is chosen.
Does that mean that hurling live animals with, say, syndrome venom bite attacks would effectively cause them to randomly insta-bite and infect people they hit as they hurtle past at 100 mph?

Or that if you hurl dragons or clowns, you basically have a mortar (chance of area effect attacks upon impact with creatures)?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 24, 2014, 09:33:16 pm
Quote
2a. If the item has defined attacks (i.e. a trap component, weapon, or certain tools) then one of those is chosen.
Does that mean that hurling live animals with, say, syndrome venom bite attacks would effectively cause them to randomly insta-bite and infect people they hit as they hurtle past at 100 mph?

Or that if you hurl dragons or clowns, you basically have a mortar (chance of area effect attacks upon impact with creatures)?

Nope to both questions. Living creatures are units, not items. Units can slam into eachother, but this only seems to transfer momentum without damage. If you fall on someone from high up, they slam into the floor fast enough to take falling/collision damage.

Dead corpse or body part items no longer have attacks, and are therefore blunt misc weapons.

ONLY trap components, weapons, ammo, or tools can have raws like [ATTACK:EDGE:20000:4000:slash:slashes:NO_SUB:1250]
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Zorbeltuss on April 25, 2014, 07:50:45 am
As you said weapons fired from traps have a set speed, but how about Projectile weapons, will the projectiles have that speed, its max speed or something other than that?

/Zorbeltuss
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: GavJ on April 25, 2014, 08:47:17 am
As you said weapons fired from traps have a set speed, but how about Projectile weapons, will the projectiles have that speed, its max speed or something other than that?

/Zorbeltuss
Well I know that minecart shotguns depend on the cart's speed. 50 impulse ramps = about 75 range, 10 impulse ramps = about 25 range for the same cargo.
Dunno about a moving marksdwarf or other such silliness.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 25, 2014, 08:47:44 am
As you said weapons fired from traps have a set speed, but how about Projectile weapons, will the projectiles have that speed, its max speed or something other than that?

/Zorbeltuss

Like crossbows mounted in a weapon trap? I don't know, good question. I will look into this.

EDIT: The bolts are fired at the fixed weapon trap velocity of 200. The number of crossbows in the trap appear to merely determine the number of bolts fired at once. The trap appears to use the fake projectile method rather than actually shooting the bolts.

There doesn't appear to be a reload delay like with marksdwarves, so the trap can easily "empty the clip" into the first victim over a few ticks. It's like a machine gun hooked up to a tripwire.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 25, 2014, 10:21:42 pm
Updated combat script to (somewhat) show blunt combat data for body parts:

Code: (combat.lua) [Select]

--Calculates combat info for weapons/armor. Alpha version!

--Future goal is to calculate info for body part weapons (using attack info), wounded tissue layers
--ranged weapons


unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor!  Aborting!")
return
end

print("Creature size (base/current): ", unit.body.size_info.size_base, unit.body.size_info.size_cur)
print("Creature strength (base): ", unit.body.physical_attrs.STRENGTH.value) --should update to use curse strengths etc.
print(" ")

for k,v in pairs(unit.inventory) do

--print(v.mode)
--enum-item Hauled 0
--enum-item Weapon 1
--enum-item Worn 2
--enum-item InBody 3
--enum-item Flask 4
--enum-item WrappedAround 5
--enum-item StuckIn 6
--enum-item InMouth 7
--enum-item Shouldered 8
--enum-item SewnInto 9

vitype=df.item_type[v.item:getType()]
print(vitype)
material=dfhack.matinfo.decode(v.item)
matdata=material.material.strength
vmatname=material.material.state_name.Solid
--print(vmatname, v.item.subtype.name) --WOULD ENABLE THIS BUT BUG ON QUIVERS, OTHER ITEMS W/O SUBTYPES!

vbpart=unit.body.body_plan.body_parts[v.body_part_id]
print(vbpart.name_singular[0].value)

if vitype=="WEAPON" then
print(vmatname, v.item.subtype.name)
v.item:calculateWeight()
effweight=unit.body.size_info.size_cur/100+v.item.weight*100+v.item.weight_fraction/10000
actweight=v.item.weight*1000+v.item.weight_fraction/1000
if v.item.subtype.flags.HAS_EDGE_ATTACK==true then
print("shear yield, shear fracture: ", matdata.yield.SHEAR, matdata.fracture.SHEAR)
print("Sharpness: ", v.item.sharpness)
end
print("NAME", "EDGE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for kk,vv in pairs(v.item.subtype.attacks) do
vvel=unit.body.size_info.size_base * unit.body.physical_attrs.STRENGTH.value *

vv.velocity_mult/1000/effweight/1000
vmom=vvel*actweight/1000+1
vedge="blunt"
vcut=""
if vv.edged==true then
vedge="edged"
vcut=100
end
print(vv.verb_2nd, vedge, vv.contact, vv.penetration, actweight/1000, math.floor(vvel), math.floor(vmom))
end
actvol=v.item:getVolume()
print("Blunt deflect if layer weight more than:", actvol * matdata.yield.IMPACT / 100 / 500)

else
if v.mode==1 then
--item held in hands treated as misc weapon
--1000 velocity mod, power math for contact and penetration
print(vmatname, "(misc weapon)") --v.item.subtype.name quiver bug
actvol=v.item:getVolume()
v.item:calculateWeight()
actweight=v.item.weight*1000+v.item.weight_fraction/1000
effweight=unit.body.size_info.size_cur/100+v.item.weight*100+v.item.weight_fraction/10000
misccontact=math.floor(actvol ^ 0.666)
miscpene=math.floor((actvol*10000) ^ 0.333)
print("NAME", "EDGE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
vvel=unit.body.size_info.size_base * unit.body.physical_attrs.STRENGTH.value/effweight/1000
vmom=vvel*actweight/1000+1
vedge="blunt"
print("strike", vedge, misccontact, miscpene, actweight/1000, math.floor(vvel), math.floor(vmom))
print("Blunt deflect if layer weight more than:", actvol * matdata.yield.IMPACT / 100 / 500)
print(" ")
end
end


if vitype=="ARMOR" or vitype=="HELM" or vitype=="GLOVES" or vitype=="SHOES" or vitype=="PANTS" then
print(vmatname, v.item.subtype.name)
actvol=v.item:getVolume()
v.item:calculateWeight()
actweight=v.item.weight*1000+v.item.weight_fraction/1000
vbca=actvol*matdata.yield.IMPACT/100/500/10
vbcb=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
vbcc=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
deduct=vbca/10
if matdata.strain_at_yield.IMPACT >= 50000 or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true or

v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_METAL==true or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_ALL==true

then
vbcb=0
vbcc=0
end
print("Full contact blunt momentum resist: ", math.floor(vbca+vbcb+vbcc))
print("Contact 10 blunt momentum resist: ", math.floor((vbca+vbcb+vbcc)*10/actvol))
print("Unbroken momentum deduction (full,10): ", math.floor(deduct), math.floor(deduct*10/actvol))
print("Volume/contact area/penetration: ", actvol)
print("Weight: ", actweight/1000)
vshyre=matdata.yield.SHEAR
vshfre=matdata.fracture.SHEAR
if v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true and vmatname ~= "leather" then
if vshyre>20000 then vshyre=20000 end
if vshfre>30000 then vshfre=30000 end
end
print("shear yield, shear fracture: ", vshyre, vshfre)
end

print(" ")
end    --end of unit inventory loop


--printall(unit.body.body_plan.attacks) --wait for next DFHack version?
--print(" ")

print("BODY PART ATTACKS (some assumptions!)")
print("NAME", " ", "SIZE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for k,v in pairs(unit.body.body_plan.body_parts) do
if v.flags.STANCE==true or v.flags.GRASP==true then
--ASSUME THAT ALL GRASP/STANCE PARTS ARE COMBAT
partsize = math.floor(unit.body.size_info.size_cur * v.relsize / unit.body.body_plan.total_relsize)
contact = math.floor(partsize ^ 0.666)
partweight = math.floor(partsize * 500 / 100) --bone, change to 8250 for bronze colossus etc.
vvel = 100 * unit.body.physical_attrs.STRENGTH.value / 1000 --some assumptions
vmom = vvel * partweight / 1000 + 1
print(v.name_singular[0].value, partsize, contact, partsize, partweight/1000, vvel, vmom)
end
end

print(" ")
print("BODY PART DEFENSE (some assumptions/bugs!)")
print("Volume/Contact/Thickness/Blunt_Momentum_Resistance(full contact)")

for k,v in pairs(unit.body.body_plan.body_parts) do
if (v.flags.SMALL==false and v.flags.INTERNAL==false) or v.flags.TOTEMABLE==true or false then
--change the final "or false" to "or true" to list all body parts!
--(or just change the whole statement to "if true then" instead of checking the flags

partsize = math.floor(unit.body.size_info.size_base * v.relsize / unit.body.body_plan.total_relsize)
partthick = math.floor((partsize * 10000) ^ 0.333)
contact = math.floor(partsize ^ 0.666)

print(v.name_singular[0].value)

for kk,vv in pairs(v.layers) do


layername = vv.layer_name
matdata=nil
for x,y in pairs(unit.body.body_plan.materials.mat_type) do
--Temporary kludge
material=dfhack.matinfo.decode(y, unit.body.body_plan.materials.mat_index[x])
if material.material.id==layername then
matdata=material.material.strength
break
end
if material.material.id=="" then --kludge for bronze colossus
matdata=material.material.strength
break
end
end

if matdata~=nil then

modpartfraction= vv.part_fraction

if layername == "FAT" then
modpartfraction = unit.counters2.stored_fat * modpartfraction / 2500 / 100
end

if layername == "MUSCLE" then
--should update to consider strength bonus due to curses etc.
modpartfraction = unit.body.physical_attrs.STRENGTH.value * modpartfraction / 1000
end

layervolume = math.floor(partsize * modpartfraction / v.fraction_total)
layerthick = math.floor(partthick * modpartfraction / v.fraction_total)
if layervolume == 0 then
layervolume = 1
end
if layerthick == 0 then
layerthick = 1
end

vbca=layervolume*matdata.yield.IMPACT/100/500/10
vbcb=layervolume*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
vbcc=layervolume*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
deduct= math.floor(vbca/10)
if matdata.strain_at_yield.IMPACT >= 50000 then
vbcb=0
vbcc=0
end
fullbmr= math.floor(vbca+vbcb+vbcc)

print(" ",vv.layer_name, layervolume, contact, layerthick, fullbmr)

else
--temporary material kludge until I get tissue access
print(" ",vv.layer_name,"ERROR-material")
end
end
end
end



Did you know:
- The head has more muscle on it than an arm or leg
- The skull is smaller and weaker than the bones in the hand

EDIT:
Spoiler: large image (click to show/hide)

Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on April 25, 2014, 10:24:16 pm
That explains so much.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Sergarr on April 26, 2014, 02:03:21 am
Wait, so all creatures in DF have muscle heads?

Someone must draw that.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Roses on April 28, 2014, 10:26:14 am
Exactly what I wanted to know. Do you know from about how high up for the boulder to reach the speed needed?

26+ z-levels, which should take 41 ticks to fall from start to finish. Average humanoid creatures can walk ~4 tiles in that time.

I'm revisiting falling projectiles and I have noticed in the arena, that simply dropping a granite boulder from +3 z-levels above a Dwarfs head causes a mortal wound, if not killing them outright. Only tried it a few times, and the Dwarfs were always lying down (just pressed 's' to make frames pass while controlling them), so not sure if that could make a difference.

EDIT: I am also looking at the way normal projectiles behave (in hopes of creating a script that can shoot arrows and such) and have a couple questions, that you may know the answer to. Inspecting thrown projectiles versus created falling projectiles, the following tags seem to be important;
Code: [Select]
fall_threshold -- Seems to be able to hit units further away with larger numbers
min_hit_distance -- Seems to be unable to hit units closer than this value
min_ground_distance -- No idea (seems to be always less than the fall threshold, usually by just 1, but sometimes more)
fall_counter -- No idea (changes during projectile movement, but only sometimes)
fall_delay -- No idea (varies wildly from projectile to projectile)
hit_rating -- I think this is how likely it is to hit a unit (or to go where it should maybe?)
unk22 -- No idea (seems to usually be at 100, but not always)
I was wondering if you had any idea what modifying these numbers actually does to the projectile. I can experiment with it, but figured I would ask before I start playing around in arena mode.

Another curiosity is that a thrown projectile has a speed, in each direction, of 0. Not sure if this is also true for fired projectiles.

EDIT2: Crossbow bolts also have a zero listed speed.

EDIT3: I added what I think each of the numbers do. Changing the speed and accel values doesn't seem to have any effect on the projectile.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 28, 2014, 05:32:49 pm
My apologies for this being a little off topic but I figured this thread is likely to be one of the best places to ask this question. I've seen a lot of science which has been done on weapon and armor types and materials but very little on weapon and armor quality. My own limited testing with weapon quality was rather primitive but it seemed to suggest that quality is not as important a factor as weapon material and type as far as performance goes. Is there anyone who has looked into this subject in any any detail?

For instance I am curious if a piece of bronze artifact armor would be better in most instances than a piece of iron armor that was crafted at the lowest quality level.

Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on April 28, 2014, 07:09:45 pm
http://dwarffortresswiki.org/index.php/DF2012:Armor#Quality_and_strange_moods

http://dwarffortresswiki.org/index.php/DF2012:Weapon#Quality_and_strange_moods
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 28, 2014, 08:06:11 pm
...
I'm revisiting falling projectiles and I have noticed in the arena, that simply dropping a granite boulder from +3 z-levels above a Dwarfs head causes a mortal wound, if not killing them outright. Only tried it a few times, and the Dwarfs were always lying down (just pressed 's' to make frames pass while controlling them), so not sure if that could make a difference.

...
I was wondering if you had any idea what modifying these numbers actually does to the projectile. I can experiment with it, but figured I would ask before I start playing around in arena mode.
...

There are many miscellaneous factors which influence damage. A thirsty, hungry, nauseated dwarf rolling on the ground in agony from smashed legs will take more damage from attacks than a perfectly healthy dwarf. Lying down in combat is generally a bad idea. For the purposes of this thread, I don't know how much influence each misc factor has on the end result. The worst case is where a creature is unconscious and the melee attacker gets free automatic hits at full power. My calculator script assumes the perfectly healthy, average case.

It is kind of off topic (perhaps it is for the DFHack thread) but you have run across the divide between the old pre-minecart projectiles (fired, thrown, siege weapons) and the new parabolic projectiles (minecarts, "shotgunned" objects/creatures, dropped objects/creatures). Unk22 is the old projectile velocity, which ironically doesn't influence how fast it travels across the screen (which is a constant).

My apologies for this being a little off topic but I figured this thread is likely to be one of the best places to ask this question. I've seen a lot of science which has been done on weapon and armor types and materials but very little on weapon and armor quality. My own limited testing with weapon quality was rather primitive but it seemed to suggest that quality is not as important a factor as weapon material and type as far as performance goes. Is there anyone who has looked into this subject in any any detail?

For instance I am curious if a piece of bronze artifact armor would be better in most instances than a piece of iron armor that was crafted at the lowest quality level.

This is probably the right thread to use. I'll have to look back over my notes and previous posts to give a good answer to this problem.

EDIT: I made notes that blunt weapons seemed to ignore quality. Edged weapons use the quality and the max_edge to set the sharpness, like Quietust describes here: http://www.bay12forums.com/smf/index.php?topic=114734.msg3520721#msg3520721
Iron has [MAX_EDGE:10000], so a no-quality iron short sword has a sharpness of 5000. I mentioned earlier in this thread that the sharpness is used to find the "shear cost" in momentum units when an edged weapon damages a layer.

Using my combat calculator script, I find that on average a noob human does 67 momentum with a slash from an iron short sword. I then use the shear costs, and sharpness 5000 to find that corresponds to cutting through a volume of ~1050 muscle tissue. The calculator also tells me that the average human has a lower body muscle volume of 1148. So it is feasible, but not a given, that a noob human with a no-quality iron sword can spill a human's guts with a single slash. If the sword was masterwork quality rather than no-quality, it could cut ~2100 volume of muscle on average in the human's hands, making internal organ damage or complete bisection much more likely.

Armor quality? I have not tested this. It may be one of those "factors" that I have not explored in detail.

END OF EDIT

http://dwarffortresswiki.org/index.php/DF2012:Armor#Quality_and_strange_moods

http://dwarffortresswiki.org/index.php/DF2012:Weapon#Quality_and_strange_moods

I am suspicious of some of those numbers from the wiki, since many were just copied forwards from previous versions of the wiki.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on April 28, 2014, 10:42:30 pm
They originally came straight from Toady's mouth, though.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 29, 2014, 12:11:11 am
OK, rather than try to figure out the misc factors code, I just used WinDbg to watch the value of the factor.

The factor used in the momentum cost equations is a number that is capped to be within the range 1000 to 2000. It is created by taking an output number "X" from a spaghetti code function, adding 500, and multiplying it by 2. Therefore the useful range of X is 0 to 500.

When a human wearing a iron breastplate was being beaten on with an iron warhammer, the value of X was around 90-96. After using DFHack to make the breastplate masterwork quality, the value of X was around 180-210. This is about double, but only corresponds to a 17% increase in the armor's protective value.

IF artifact armor would increase the unknown, random X by three times, then the real protection would only increase by 33%.
My calculator is giving me this for bronze and iron armor:
Code: [Select]
ARMOR
bronze  breastplate
Full contact blunt momentum resist:     557
Contact 10 blunt momentum resist:       21
Unbroken momentum deduction (full,10):  30      1
Volume/contact area/penetration:        257
Weight:         21.2025
shear yield, shear fracture:    172000  241000

ARMOR
iron    breastplate
Full contact blunt momentum resist:     836
Contact 10 blunt momentum resist:       32
Unbroken momentum deduction (full,10):  27      1
Volume/contact area/penetration:        257
Weight:         20.1745
shear yield, shear fracture:    155000  310000

So it looks like artifact bronze armor would be weaker than no-quality iron armor. The lower blunt resistance is due to the smaller gap between IMPACT_FRACTURE and IMPACT_YIELD, i.e. bronze is brittle. In fact, copper has slightly better blunt resistance than bronze. Both bronze and iron armors have better shear fractures than copper or silver, so they would still protect against those edged weapons.

In general I would recommend choosing material over choosing quality.

I checked for changes (other than the known sharpness change) to damage when using weapons of differing quality, and found none. A future research topic might be to explore if there is an accuracy/skill bonus to using a quality weapon.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 29, 2014, 12:51:15 pm
Gotta love this thread. Thanks for working that out. :)

The increase of effectiveness in armor of higher quality is roughly what I had intuited it to be during my arena trials which is to say that it was not significant enough to trump the material properties. On the other hand, the increased effectiveness of quality edged weapons is considerably greater than what I had been assuming.

As a general rule of thumb I had been equipping my dwarves with low quality iron long swords over masterwork steal short swords and looking at these numbers I no longer think this an exceedingly good idea particularly when taking into account that one of our dwarves most common enemies tends to show up in iron armor occasionally. I guess it would really depend on the foe, but the iron long sword is not the clear winner I thought it was but more like a trade off.

The long sword is over twice the size of the short sword which is a significant advantage particularly when considering that half of a sword's attacks are blunt but its slash attack has a much wider contact area and it's made of an inferior material of inferior quality which means that the steal masterwork short sword's slash will be much better than the iron long sword's against any sort of half decent armor. The stab attack is likely closer to a wash between the two with the iron long sword being able to strike deeper into large enemies with more weight behind it but with the steal masterwork short sword being better at piercing decent armor like goblins in iron. The small contact area of stab attacks helps keep the iron long sword more competitive when it comes to piercing armor than in the case of slashing but I think the short sword probably still comes out slightly ahead overall when it comes to stabbing.

On different note, your brought up how denser armor's protect better against blunt attacks which is something I have always found interesting. Given that denser armor is heavier and thus encumbers the wearer more would it be worth throwing something like a gold artifact chest plate over some masterwork steel chain on a dwarf with decent armor user skill? It seems like it would be good for protecting against blunt attacks but the weight would be brutal.
 


Title: Re: Modding material properties vs. how the properties are used by the game
Post by: GavJ on April 29, 2014, 05:12:24 pm
Quote
They originally came straight from Toady's mouth, though.
Toady could easily  forget something like a multiplier then later being multiplied by another multiplier, such that what he thought was a 2x and 3x bonus is in fact a 0.2x and 0.3x bonus or whatever. Just because he said it doesn't mean it's what actually happens. If he had perfect knowledge of his own code, bugs wouldn't exist.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on April 29, 2014, 08:25:48 pm
Gotta love this thread. Thanks for working that out. :)
...
On different note, your brought up how denser armor's protect better against blunt attacks which is something I have always found interesting. Given that denser armor is heavier and thus encumbers the wearer more would it be worth throwing something like a gold artifact chest plate over some masterwork steel chain on a dwarf with decent armor user skill? It seems like it would be good for protecting against blunt attacks but the weight would be brutal.

The density of most metal armors will cause wood weapons and some other soft (low IMPACT_YIELD) materials to deflect. However, punches/kicks (which are treated as bone for attack purposes) and metal blunt weapons will get through your gold breastplate with no trouble. The extra weight would slow you down, probably making it hard to dodge. Gold armor would only really be useful against elves or giant sponges.

If you go to the momentum cost equations earlier in this thread, you can see how you want to have high values of IMPACT_FRACTURE and IMPACT_YIELD rather than density.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on April 30, 2014, 12:08:05 am
The density of most metal armors will cause wood weapons and some other soft (low IMPACT_YIELD) materials to deflect. However, punches/kicks (which are treated as bone for attack purposes) and metal blunt weapons will get through your gold breastplate with no trouble. The extra weight would slow you down, probably making it hard to dodge. Gold armor would only really be useful against elves or giant sponges.

If you go to the momentum cost equations earlier in this thread, you can see how you want to have high values of IMPACT_FRACTURE and IMPACT_YIELD rather than density.

That's a shame. I figured it would at least deflect punches and kicks decently given how they use the relatively light weight bones in those appendages as the basis for the calculation. I realize that impact yield and impact fracture are the most important values when it comes to determining whether a weapon will pierce armor but I was thinking of using the artifact gold chest plate on top of the steel chain simply for its ability to deflect light weight weapon impacts using poor materials such as bone and wood projectiles along with natural unarmed attacks. I know if the weapon material is poorer than that of the armor it is trying to pierce then the game does a deflection check which is based on the weight of the projectile vs that of the armor it is trying to pierce which is why steel will outperform candy in this regard. Thus I figured there would be some circumstances where gold artifact armor would similarly outperform its lighter masterwork steel counterpart.

Maybe if I paired it with some candy chain on one of my skilled armor users it would be worth it since the candy essentially weighs nothing and is particularly poor at deflecting projectiles so the gold's weight wouldn't be such a burden and it would cover the candy's one weak point. (I'm trying way too hard to find some way to justify the existence of this artifact.)
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Angle on June 16, 2014, 10:38:40 am
I am myself trying to make a roguelike (http://www.bay12forums.com/smf/index.php?topic=128099.0), and of course I had to go and make things difficult for myself and try and use real world physics, and Sergarr suggested I ask you for advice. Can you give me some advice on translating the values in the raws to metric, and/or looking up more proper values? Advice on more realistic game logic to use for combat would be appreciated too. I'm currently measuring distances in centimeters and density in g/cm^3.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on June 16, 2014, 05:01:18 pm
Density is kg/m^3 in the raws right now, I think.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Angle on June 16, 2014, 07:45:42 pm
What about the strength values? I.E. IMPACT_FRACTURE, TORSION_YIELD, COMPRESSIVE_FRACTURE, etc? Are they in mPa or something?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on June 16, 2014, 08:48:55 pm
Density is kg/m^3 in the raws right now, I think.
[SOLID_DENSITY:7850]
7850 kg/m3 = 7.850 g/cm3

Remember water is 1000 kg/m3 and 1 g/cm3

What about the strength values? I.E. IMPACT_FRACTURE, TORSION_YIELD, COMPRESSIVE_FRACTURE, etc? Are they in mPa or something?
KPa

..., and/or looking up more proper values? Advice on more realistic game logic to use for combat would be appreciated too. ...

1. Use an energy basis (DF uses a momentum basis, which has a few drawbacks)
2. Look for food processing books online. Keywords "specific cutting force" or "work of fracture" to get idea of requirements to cut meat/bone/etc.
3. If you have a mace or hammer, you might try to can-opener fight an armored opponent. Otherwise, people with swords/daggers usually aim for gaps/weak points rather than try to stab through the armor. Then again, if the enemy's armor is junk (leather or thin weak metal) you could stab through it.
4. For real metals, you will likely only be able to find a yield strength and an ultimate tensile strength (i.e. fracture), as well as other properties. These are generally measured using a tensile testing apparatus. There is no such thing as a "torsional strength" in common practice.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Angle on June 16, 2014, 09:08:00 pm
What about the strength values? I.E. IMPACT_FRACTURE, TORSION_YIELD, COMPRESSIVE_FRACTURE, etc? Are they in mPa or something?
KPa


How do the strength values relate to the thickness of the material?


1. Use an energy basis (DF uses a momentum basis, which has a few drawbacks)
2. Look for food processing books online. Keywords "specific cutting force" or "work of fracture" to get idea of requirements to cut meat/bone/etc.
3. If you have a mace or hammer, you might try to can-opener fight an armored opponent. Otherwise, people with swords/daggers usually aim for gaps/weak points rather than try to stab through the armor. Then again, if the enemy's armor is junk (leather or thin weak metal) you could stab through it.
4. For real metals, you will likely only be able to find a yield strength and an ultimate tensile strength (i.e. fracture), as well as other properties. These are generally measured using a tensile testing apparatus. There is no such thing as a "torsional strength" in common practice.

1. ...What's the difference?
2. Good idea. I hadn't thought of that...
3. Combat styles and specific tactics are a ways off yet. I'll keep this in mind, though.
4. I figure I can pull from the raws for most things, at least to start things off.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: GavJ on June 17, 2014, 05:46:22 pm
If you can't find values anywhere, keep in mind you could always just get some body parts from a butcher and test it yourself!!

You only need to find one set of known values in order to establish which units DF is using, and from there, you can obtain your own values and map them over to DF terms. I wouldn't see a need to test every stupid organ or whatever, and that may be infeasible anyway. But just cover the main bases with:
-fat
-meat
-bones
-assume organs are all pretty much interchangeable and just use something minimally messy and available like liver to extrapolate from


Most of these things are easy to test with known weights on strings and some basic wooden jigs or weights dropped from some given height and some simple math. Laboratories might use massive stainless steel monster machines, but that's only because they want 18 decimal places of precision and the need to fracture hard crystals, etc. Neither is necessary for a video game and soft tissues.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Angle on June 17, 2014, 07:21:07 pm
That sounds like a good idea, though I think I need to brush up on my basic physics first. :-[
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on June 27, 2014, 01:53:59 am
An update for the combat calculator for DFHack 0.34.11-r5 only. It now considers the proper strength of the creature due to curses (undead, vampires, etc.). Body part defense improved due to tissue data. However, body part attack data reading is bugged in DFHack 0.34.11-r5  :(

Code: (combat.lua) [Select]
--Calculates combat info for weapons/armor. DFHack 0.34.11-r5 version

--Future goal is to calculate info for body part weapons (using attack info), perhaps ranged weapons

unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor!  Aborting!")
return
end

print("Creature size (base/current): ", unit.body.size_info.size_base, unit.body.size_info.size_cur)
print("Creature strength (base): ", unit.body.physical_attrs.STRENGTH.value)
if unit.curse.attr_change ~= nil then
--print("cperc",unit.curse.attr_change.phys_att_perc.STRENGTH)
--print("cadd",unit.curse.attr_change.phys_att_add.STRENGTH)
curstrength=((unit.body.physical_attrs.STRENGTH.value * unit.curse.attr_change.phys_att_perc.STRENGTH)/100 +

unit.curse.attr_change.phys_att_add.STRENGTH)
if curstrength > 5000 then curstrength=5000 end
else
curstrength=unit.body.physical_attrs.STRENGTH.value
end
print("Creature strength (current): ", curstrength)
print("Wrestle/Charge rating: ", math.floor(curstrength/100+unit.body.size_info.size_cur/100))
race=df.global.world.raws.creatures.all[unit.race]



print(" ")

for k,v in pairs(unit.inventory) do

--print(v.mode)
--enum-item Hauled 0
--enum-item Weapon 1
--enum-item Worn 2
--enum-item InBody 3
--enum-item Flask 4
--enum-item WrappedAround 5
--enum-item StuckIn 6
--enum-item InMouth 7
--enum-item Shouldered 8
--enum-item SewnInto 9

vitype=df.item_type[v.item:getType()]
print(vitype)
material=dfhack.matinfo.decode(v.item)
matdata=material.material.strength
vmatname=material.material.state_name.Solid
--print(vmatname, v.item.subtype.name) --WOULD ENABLE THIS BUT BUG ON QUIVERS, OTHER ITEMS W/O SUBTYPES!

vbpart=unit.body.body_plan.body_parts[v.body_part_id]
print(vbpart.name_singular[0].value)

if vitype=="WEAPON" then
print(vmatname, v.item.subtype.name)
v.item:calculateWeight()
effweight=unit.body.size_info.size_cur/100+v.item.weight*100+v.item.weight_fraction/10000
actweight=v.item.weight*1000+v.item.weight_fraction/1000
if v.item.subtype.flags.HAS_EDGE_ATTACK==true then
print("shear yield, shear fracture: ", matdata.yield.SHEAR, matdata.fracture.SHEAR)
print("Sharpness: ", v.item.sharpness)
end
print("NAME", "EDGE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for kk,vv in pairs(v.item.subtype.attacks) do
vvel=unit.body.size_info.size_base * curstrength * vv.velocity_mult/1000/effweight/1000
vmom=vvel*actweight/1000+1
vedge="blunt"
vcut=""
if vv.edged==true then
vedge="edged"
vcut=100
end
print(vv.verb_2nd, vedge, vv.contact, vv.penetration, actweight/1000, math.floor(vvel), math.floor(vmom))
end
actvol=v.item:getVolume()
print("Blunt deflect if layer weight more than:", actvol * matdata.yield.IMPACT / 100 / 500)

else
if v.mode==1 then
--item held in hands treated as misc weapon
--1000 velocity mod, power math for contact and penetration
print(vmatname, "(misc weapon)") --v.item.subtype.name quiver bug
actvol=v.item:getVolume()
v.item:calculateWeight()
actweight=v.item.weight*1000+v.item.weight_fraction/1000
effweight=unit.body.size_info.size_cur/100+v.item.weight*100+v.item.weight_fraction/10000
misccontact=math.floor(actvol ^ 0.666)
miscpene=math.floor((actvol*10000) ^ 0.333)
print("NAME", "EDGE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
vvel=unit.body.size_info.size_base * curstrength/effweight/1000
vmom=vvel*actweight/1000+1
vedge="blunt"
print("strike", vedge, misccontact, miscpene, actweight/1000, math.floor(vvel), math.floor(vmom))
print("Blunt deflect if layer weight more than:", actvol * matdata.yield.IMPACT / 100 / 500)
print(" ")
end
end


if vitype=="ARMOR" or vitype=="HELM" or vitype=="GLOVES" or vitype=="SHOES" or vitype=="PANTS" then
print(vmatname, v.item.subtype.name)
actvol=v.item:getVolume()
v.item:calculateWeight()
actweight=v.item.weight*1000+v.item.weight_fraction/1000
vbca=actvol*matdata.yield.IMPACT/100/500/10
vbcb=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
vbcc=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
deduct=vbca/10
if matdata.strain_at_yield.IMPACT >= 50000 or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true or

v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_METAL==true or v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_CHAIN_ALL==true

then
vbcb=0
vbcc=0
end
print("Full contact blunt momentum resist: ", math.floor(vbca+vbcb+vbcc))
print("Contact 10 blunt momentum resist: ", math.floor((vbca+vbcb+vbcc)*10/actvol))
print("Unbroken momentum deduction (full,10): ", math.floor(deduct), math.floor(deduct*10/actvol))
print("Volume/contact area/penetration: ", actvol)
print("Weight: ", actweight/1000)
vshyre=matdata.yield.SHEAR
vshfre=matdata.fracture.SHEAR
if v.item.subtype.props.flags.STRUCTURAL_ELASTICITY_WOVEN_THREAD==true and vmatname ~= "leather" then
if vshyre>20000 then vshyre=20000 end
if vshfre>30000 then vshfre=30000 end
end
print("shear yield, shear fracture: ", vshyre, vshfre)
end

print(" ")
end    --end of unit inventory loop


--printall(unit.body.body_plan.attacks) --wait for next DFHack version? r5 caste_attack data bugged!
--print(" ")

print("BODY PART ATTACKS (some assumptions!)")
print("NAME", " ", "SIZE", "CONTACT", "PNTRT", "WEIGHT", "VEL", "MOMENTUM(+100%/-50%)")
for k,v in pairs(unit.body.body_plan.body_parts) do
if v.flags.STANCE==true or v.flags.GRASP==true then
--ASSUME THAT ALL GRASP/STANCE PARTS ARE COMBAT
partsize = math.floor(unit.body.size_info.size_cur * v.relsize / unit.body.body_plan.total_relsize)
contact = math.floor(partsize ^ 0.666)
partweight = math.floor(partsize * 500 / 100) --bone, change to 8250 for bronze colossus etc.
vvel = 100 * curstrength / 1000
vmom = vvel * partweight / 1000 + 1
print(v.name_singular[0].value, partsize, contact, partsize, partweight/1000, vvel, vmom)
end
end

print(" ")
print("BODY PART DEFENSE")
print("Volume/Contact/Thickness/Blunt_Momentum_Resistance(full contact)")

for k,v in pairs(unit.body.body_plan.body_parts) do
if (v.flags.SMALL==false and v.flags.INTERNAL==false) or v.flags.TOTEMABLE==true or false then
--change the final "or false" to "or true" to list all body parts!
--(or just change the whole statement to "if true then" instead of checking the flags

partsize = math.floor(unit.body.size_info.size_base * v.relsize / unit.body.body_plan.total_relsize)
partthick = math.floor((partsize * 10000) ^ 0.333)
contact = math.floor(partsize ^ 0.666)

print(v.name_singular[0].value)

for kk,vv in pairs(v.layers) do

tisdata=race.tissue[vv.tissue_id]
--printall(tisdata)
layername = vv.layer_name

material=dfhack.matinfo.decode(tisdata.mat_type,tisdata.mat_index)
--tissue has a mat_state, could it name properly
matdata=material.material.strength

modpartfraction= vv.part_fraction

if tisdata.flags.THICKENS_ON_ENERGY_STORAGE == true then
modpartfraction = unit.counters2.stored_fat * modpartfraction / 2500 / 100
end

if tisdata.flags.THICKENS_ON_STRENGTH == true then
modpartfraction = curstrength * modpartfraction / 1000
end

layervolume = math.floor(partsize * modpartfraction / v.fraction_total)
layerthick = math.floor(partthick * modpartfraction / v.fraction_total)
if layervolume == 0 then
layervolume = 1
end
if layerthick == 0 then
layerthick = 1
end

vbca=layervolume*matdata.yield.IMPACT/100/500/10
vbcb=layervolume*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
vbcc=layervolume*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
deduct= math.floor(vbca/10)
if matdata.strain_at_yield.IMPACT >= 50000 then
vbcb=0
vbcc=0
end
fullbmr= math.floor(vbca+vbcb+vbcc)

print(" ",vv.layer_name, layervolume, contact, layerthick, fullbmr,material.material.state_name.Solid)

end
end
end

Suggestions are welcome.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Sergarr on July 09, 2014, 04:23:43 pm
Will this be updated? I want to know how exactly pulping works...
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on July 09, 2014, 05:56:17 pm
I don't do any real modding beyond minor bug fixes in the raws so please excuse my ignorance. This script you wrote looks extremely useful since I actually like to do a lot of testing and I am currently limited to very primitive means.

Anyway what I need to know is how would I go about getting DFhack to run this? A link to a good guide to where I can find the basic information on using DFhack to run custom scripts would be great. I have rudimentary programming skills in a handful of different languages and I'm curious what languages DFhack scripts can be written in. From what I have seen it is based on Lua which is completely new to me. (It's been over ten years since I last coded anything.)

The part of programing that has always been difficult for me isn't the coding itself but mastering and setting up the environments in which the code is read and executed. For instance back in the day when I was programing in Java I found it easier to write the program than to set up accursed Tomcat and the JRE so I could actually run it. I am pretty much completely ignorant of how to get programs to interface with the environments in which they are executed so any link to information about DFhack's dependencies, plugins etc. would be very helpful.

Sorry, I know this is a bit off topic but I would like to run this script and maybe at some point write a few of my own.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on July 09, 2014, 05:57:47 pm
Take the text, save it as a .lua file, stick it in \hack\scripts and punch in the filename as a command in the DFHack console. The simplest thing in the world.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on July 09, 2014, 09:00:04 pm
Will this be updated? I want to know how exactly pulping works...

So would I, but at the moment we don't have structures or DFHack for 0.40.01
My gut feeling is that body parts seem MUCH weaker, like this: https://www.youtube.com/watch?v=nfmM59S_5EE

Some things may need to be reverified for 0.40.01 considering that two years of Toady's coding have occurred. I can confirm that the dependance of edged damage on the SHEAR values has not changed.

Attack momentums/velocities are likely different after the combat/movement speed split.

FAKE EDIT: preliminary pulping testing suggests that body parts and all their contained parts will be broken (red) if dealt a body-part-size related amount of blunt damage. However the system is not balanced as small parts burst easily. My arena martial artist kicked someone repeatedly in the lower body until it exploded in gore, which instantly killed them. The corpse was in one piece.

Relevant Toady quote:
Quote
Toady One There have been a lot of DF Talky, pressy and taxy things going on (with all the events scheduled for later, this may end up being one of the busier months on record non-programming-wise), but I managed to get most of the way through pulping as well as making some strides toward the definitive hydra test. For pulping, I just need to hit a bunch of things in the arena now to get the numbers to feel correct. Once a key body part is pulped, associated corpses won't be able to be re-animated. If a dwarf gets hit enough times to have a part pulped and still survives, which is reasonably extreme, they can still recover, since pulping isn't actually a state of being, just an accumulation of enough serious wounds -- if enough of the serious wounds heal, the dwarf can recover, but it's likely to be a mess of multiple horrifying fractures and nerve damage and so on. The "hit points" for animated creatures that were a band-aid for the damage problem have been removed.

Also throwing liquids has been nerfed, so "water guns" are possibly obsolete. The creature just gets splattered on a body part. This is likely due to the implementation of spitting.

ACTUAL EDIT: Giant Sponges can be pulped to death (i.e. their single body part "collapses")! This is probably a good place to start in understanding pulping.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on July 10, 2014, 01:06:26 am
Take the text, save it as a .lua file, stick it in \hack\scripts and punch in the filename as a command in the DFHack console. The simplest thing in the world.

Thanks   :)

Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Melting Sky on July 10, 2014, 01:14:57 am
Some things may need to be reverified for 0.40.01 considering that two years of Toady's coding have occurred. I can confirm that the dependance of edged damage on the SHEAR values has not changed.

Attack momentums/velocities are likely different after the combat/movement speed split.

FAKE EDIT: preliminary pulping testing suggests that body parts and all their contained parts will be broken (red) if dealt a body-part-size related amount of blunt damage. However the system is not balanced as small parts burst easily. My arena martial artist kicked someone repeatedly in the lower body until it exploded in gore, which instantly killed them. The corpse was in one piece.

Relevant Toady quote:
Quote
Toady One There have been a lot of DF Talky, pressy and taxy things going on (with all the events scheduled for later, this may end up being one of the busier months on record non-programming-wise), but I managed to get most of the way through pulping as well as making some strides toward the definitive hydra test. For pulping, I just need to hit a bunch of things in the arena now to get the numbers to feel correct. Once a key body part is pulped, associated corpses won't be able to be re-animated. If a dwarf gets hit enough times to have a part pulped and still survives, which is reasonably extreme, they can still recover, since pulping isn't actually a state of being, just an accumulation of enough serious wounds -- if enough of the serious wounds heal, the dwarf can recover, but it's likely to be a mess of multiple horrifying fractures and nerve damage and so on. The "hit points" for animated creatures that were a band-aid for the damage problem have been removed.

Also throwing liquids has been nerfed, so "water guns" are possibly obsolete. The creature just gets splattered on a body part. This is likely due to the implementation of spitting.

ACTUAL EDIT: Giant Sponges can be pulped to death (i.e. their single body part "collapses")! This is probably a good place to start in understanding pulping.

This is interesting. I wonder if the amount of blunt damage required to pulp a specific body part is similiar to the amount of edged damage required to sever that same part and if these two effects can be additive. For instance would it be easier to pulp somebody's arm if it was already half cut through from edged damage?

Edit: Giant creatures are extremely resilient to pulping. The zombie version are strait up almost invincible killing machines.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on July 12, 2014, 11:03:45 pm
What about the strength values? I.E. IMPACT_FRACTURE, TORSION_YIELD, COMPRESSIVE_FRACTURE, etc? Are they in mPa or something?
KPa

Where does this come from? Rather, where are the values found for this? I couldn't find anything related to iron and 155 mPa.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on July 13, 2014, 12:41:50 am
What about the strength values? I.E. IMPACT_FRACTURE, TORSION_YIELD, COMPRESSIVE_FRACTURE, etc? Are they in mPa or something?
KPa

Where does this come from? Rather, where are the values found for this? I couldn't find anything related to iron and 155 mPa.


1. How do I know it is kPa?

Quote from: material_template_default.txt
...
[MATERIAL_TEMPLATE:STONE_TEMPLATE]
...
   Used for blunt-force combat, measured in KPa.  Data scattered around the net (used compressive strength).  All very spotty.
   [IMPACT_YIELD:120000] used marble
...
   Used for cutting calculations in combat, measured in KPa.  Data scattered around the net (used tensile strength).  All very spotty.
   [SHEAR_YIELD:15000] used marble
...

Also copper has    [SHEAR_YIELD:70000], [SHEAR_FRACTURE:220000].
If you look here: http://www.efunda.com/materials/alloys/copper/properties.cfm
you can see Yield Strength: 69 MPa and Tensile Strength: 220 MPa (it varies depending on alloys, impurities, etc.)

Wrought iron can be around 155 MPa: http://en.wikipedia.org/wiki/Wrought_iron#Properties
Yield 159–221 MPa, Ultimate shear 193–310 MPa.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on July 13, 2014, 01:10:54 am
Oh boy.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Putnam on July 14, 2014, 03:36:17 pm
The raw comments suggest that the strain_at_yield values are releated to young's/bulk/shear modulus, but they... aren't. At least, I cannot find any relation whatsoever. So are those just arbitrary values?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on July 14, 2014, 03:38:32 pm
I was breaking my mind over this 2 years ago. Someone with an education in numbers knew and told me how the two translated into the other, but damn if I can find the proof anywhere anymore.

There's a twisted logic in there somewhere, just take my word for it.
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on July 14, 2014, 08:32:40 pm
The raw comments suggest that the strain_at_yield values are releated to young's/bulk/shear modulus, but they... aren't. At least, I cannot find any relation whatsoever. So are those just arbitrary values?

E=σ/ε
Young’s modulus = stress/strain
Young’s modulus = yield_stress/strain_at_yield
...
strain_at_yield = yield_stress/Young’s modulus
εy = σy/E

But that doesn't work directly...

...
There's a twisted logic in there somewhere, just take my word for it.
iron:
   [TENSILE_YIELD:155000] kPa
   [TENSILE_FRACTURE:310000]
   [TENSILE_STRAIN_AT_YIELD:73] young's modulus 211 GPa

So 155,000,000/211,000,000,000 = 0.000734597
If you then multiply by 100000 (arbitrary!) you get 73

Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Sergarr on July 28, 2014, 02:52:17 am
0.40.05 is out and I think it changed many things related to DF physics. Can you please investigate further?
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Pirate Bob on July 31, 2014, 01:24:18 pm
0.40.05 is out and I think it changed many things related to DF physics. Can you please investigate further?
This inquiry requires DFHack, which is not ready for the new version yet.  Urist has said he plans to investigate when it is.
So would I, but at the moment we don't have structures or DFHack for 0.40.01
My gut feeling is that body parts seem MUCH weaker, like this: https://www.youtube.com/watch?v=nfmM59S_5EE

First off, this is truly fantastic!  Sorry I didn't notice this before, or I would have commented long ago.  I can't say I understand it all yet (I will have to start playing with spreadsheets and real numbers when I get a chance) but this looks like you have a complete model for DF combat, which I had thought was too impossibly complicated to be possible.  I guess hacking the raw code helps...

I do have a couple of questions:

1) I see that sharpness enters into all calculations of edged weapons penetrating layers.  Does that mean that adamantine, with 10x the sharpness of other metals, should penetrate armor with 10 times less momentum?  We may never have tested this with bolts, as usually adamantine has much lower momentum due to its low density, but I can easily run this test.

2)  It isn't clear to me where the observed behavior that armor is only effective if its SHEAR_YIELD and/or SHEAR_FRACTURE is greater than or equal to that of the projectile comes out of these equations.  Am I missing something, or is this separate?  I have only skimmed this thread so far, so if its in there, feel free to tell me to just look harder.

3)  I see there are a few "unknowns" and "factors".  Do you think there are any cases where large-scale testing could help determine these?

4)  I have observed that I get slightly different rates of deflection off different body parts when using your uniarmor (uniform thickness, no overlap) to cover both parts.  In particular, I used targets with 2-part bodies, and found deflection at slightly higher force off the upper body than the lower body.  Can the material properties of the tissue layers underneath impact deflection off armor?  If the question I am asking is not clear enough, can post a detailed description of the data I have and how it was obtained (either here or elsewhere).

I think what I really should do is just download your lua script and go through that.  Is it safe to assume that all relations described in the thread are included in it?  Knowing the exact equations you found for 34.11 will be immensely helpful for testing 40.05, as it is far easier to test if a known equation is true than to try to guess equations from data.  Also, I suspect that the armor/layer end of things (which appears to be the bulk of the work here) has not changed, and only the way velocities are determined for weapons has changed. 

I also can do tests of melee weapons, and have already run a few.  I believe all that changed with melee is that Toady applied your binary patch which changed a 10,000 to 100,000 in the mass calculations.  Therefore, you should still be able to make accurate predictions for melee?  Do you have any suggestions of tests I could run to check if melee is still following your predictions?

Thanks so much for doing this!  Extremely fine work!
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: scamtank on July 31, 2014, 03:29:46 pm

1) I see that sharpness enters into all calculations of edged weapons penetrating layers.  Does that mean that adamantine, with 10x the sharpness of other metals, should penetrate armor with 10 times less momentum?  We may never have tested this with bolts, as usually adamantine has much lower momentum due to its low density, but I can easily run this test.

2)  It isn't clear to me where the observed behavior that armor is only effective if its SHEAR_YIELD and/or SHEAR_FRACTURE is greater than or equal to that of the projectile comes out of these equations.  Am I missing something, or is this separate?  I have only skimmed this thread so far, so if its in there, feel free to tell me to just look harder.

3)  I see there are a few "unknowns" and "factors".  Do you think there are any cases where large-scale testing could help determine these?

1.) Nah. More than anything, sharpness determines how much momentum the blow loses when it defeats a layer. The default MAX_EDGE:10000 on most metals is enough to halve the effect. A value of 5000 would leave the penetration entirely on the mercy of the yields and the chaotic little variables.

2.) What's there to argue? If your little bolt can't muster the shear yield to dent or shear fracture to saw through the layer, it needs to go the way of the bludgeon. That equation isn't tilted in any way by the bolt's fancy material properties, it's only the total momentum against the impact values and volume of the defending layer. So if you can't make the cut, you either need to be really really big, really really heavy or go really really fast. Bolts usually don't get to debate the first two.

There's also the matter of losing momentum as you go through the layers that's really bad for dull bolts. The gist of it is this: when you defeat a layer that takes X momentum to break, your projectile doesn't lose that X amount of momentum, as weird as it is. Instead, you look at the very first stage of contact, the denting costs. You pick either SHEAR 1 or IMPACT 1, whichever is higher, and then take 10% of it. That's how much momentum you lose when you cut or shatter the layer, be it a breastplate or a slab of beef.

The impact blunting is mostly about the armor's thickness and its impact yield with the bolt's properties contributing nothing, so unless the armor is spectacular, it loses to shear blunting - the ratio of the opposing shear yields with the total effect discounted by sharpness. If you have a shitty bolt that goes at the speed of light, it can still shatter a breastplate like a bullet, but every layer of skin and meat along the way drags it down bit by bit due to its dull edge.

3.) Check this out:
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)

Title: Re: Modding material properties vs. how the properties are used by the game[0.34.11]
Post by: Pirate Bob on July 31, 2014, 08:46:06 pm
Thanks for clarifying!  I looked at the equations again, and realized I was misreading them.  As you explain, the set for edged weapons are responsible for the SHEAR_YIELD and SHEAR_FRACTURE checks I was referring to, and if these are passed by the armor then the blunt calculations are used.  This is reassuring, as the three blunt equations added together are proportional to (2*IF-IY), which is the observed dependence for bolts.

There is still one thing that I may have missed - did Urist ever give details on how the layer volume is calculated?  I assume that it is just the layer thickness time the contact area, but (at least for projectiles) there is some weird rounding which occurs, and I wonder if he sorted this out for the general case? 

I looked at his lua script, and it appears for armor
Code: [Select]
actvol=v.item:getVolume()
vbca=actvol*matdata.yield.IMPACT/100/500/10
vbcb=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
vbcc=actvol*(matdata.fracture.IMPACT-matdata.yield.IMPACT)/100/500/10
...
print("Contact 10 blunt momentum resist: ", math.floor((vbca+vbcb+vbcc)*10/actvol))
It appears from this that item volume is divided out when calculating momentum resist for contact 10, and layer thickness does not enter at all.  Either I must be missing something (likely) or melee attacks use a different mechanism than projectiles, as projectile momentum resist is proportional to round100(layer thickness * contact area), where round100(x) = x rounded down to the nearest 100, with a min of 100.

Sorry in advance if I'm being dense again!
Title: Re: Modding material properties vs. how the properties are used by the game
Post by: Urist Da Vinci on July 31, 2014, 09:38:41 pm
...
I do have a couple of questions:
...
1. It "costs" less momentum for adamantine to cut other materials both because of the higher MAX_EDGE and because the SHEAR values of adamantine are far above other materials. If you hack up a giant sperm whale with an adamantine edged weapon, the amount of damage you can cause is mostly limited by the contact area and penetration of the weapon. You won't get the same performance from a copper sword.

By the way, "sharpness" is a combination of weapon quality and MAX_EDGE, and ranges from 50% to 100% of the MAX_EDGE. Quality doesn't matter for blunt weapons, and didn't matter for the old "railgun" crossbows+bolts.

2. As scamtank points out, I HATE the fact that DF protective layers use their full momentum costs when defending themselves, but if broken only subtract 10% of the yielding momentum. IRL breaking stuff uses up energy, so the attack should slow down. This is the main thing that prevents wearing multiple layers of armor from mattering (currently only the strongest layer really counts). I might do a binary patch eventually on this (such as a test patch for 0.34.11?) to see how combat plays out with 100% subtraction.

3. Long story short, getting some of the status effects like nausea really cripples offense and defense.

4. The game doesn't check layers underneath when processing the upper armor or tissue layers.

...
There is still one thing that I may have missed - did Urist ever give details on how the layer volume is calculated?  I assume that it is just the layer thickness time the contact area, but (at least for projectiles) there is some weird rounding which occurs, and I wonder if he sorted this out for the general case? 
...

All body parts have a volume (used for weight and used with strengths to determine momentum costs), a contact area, and a thickness (in the same units as a weapon's penetration value). Weapons or creature body part attacks also have a contact area. Armor items use the same number for volume, contact area, and thickness, which leads to silly armor thicknesses for large creatures. Somewhere in this thread I posted equations for some of these.

weapon CA > layer CA (i.e. two handed sword vs. neck): the full volume of the layer is used.

weapon CA < layer CA (i.e. bolt vs. upper leg): the "layer volume" used in the calculations depends on the ratio of the contact area of the weapon to the contact area of the body part. Also, the word "Chipping" is only used when less than 25% of the area of the body part has been damaged.

The armor/clothing UBSTEP, LBSTEP, COVERAGE, LAYER_SIZE, etc. tokens are used in combination with the unit's race and the body part to determine the item's size and volume. I never explored what happens if your custom race has an asymmetrically oversized right hand or right foot - which foot determines the boot size, or does it instamagically scale?