Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 7 8 [9] 10

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

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #120 on: June 16, 2014, 05:01:18 pm »

Density is kg/m^3 in the raws right now, I think.

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Modding material properties vs. how the properties are used by the game
« Reply #121 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?
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #122 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.

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Modding material properties vs. how the properties are used by the game
« Reply #123 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.
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

GavJ

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #124 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.
Logged
Cauliflower Labs – Geologically realistic world generator devblog

Dwarf fortress in 50 words: You start with seven alcoholic, manic-depressive dwarves. You build a fortress in the wilderness where EVERYTHING tries to kill you, including your own dwarves. Usually, your chief imports are immigrants, beer, and optimism. Your chief exports are misery, limestone violins, forest fires, elf tallow soap, and carved kitten bone.

Angle

  • Bay Watcher
  • 39 Indigo Spear Questions the Poor
    • View Profile
    • Agora Forum Demo!
Re: Modding material properties vs. how the properties are used by the game
« Reply #125 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. :-[
Logged

Agora: open-source platform to facilitate complicated discussions between large numbers of people. Now with test site!

The Temple of the Elements: Quirky Dungeon Crawler

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #126 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.

Sergarr

  • Bay Watcher
  • (9) airheaded baka (9)
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #127 on: July 09, 2014, 04:23:43 pm »

Will this be updated? I want to know how exactly pulping works...
Logged
._.

Melting Sky

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #128 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.
Logged

scamtank

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #129 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.
Logged

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #130 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.
« Last Edit: July 09, 2014, 09:22:09 pm by Urist Da Vinci »
Logged

Melting Sky

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #131 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   :)

Logged

Melting Sky

  • Bay Watcher
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #132 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.
« Last Edit: July 10, 2014, 08:09:59 am by Melting Sky »
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #133 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.

Urist Da Vinci

  • Bay Watcher
  • [NATURAL_SKILL: ENGINEER:4]
    • View Profile
Re: Modding material properties vs. how the properties are used by the game
« Reply #134 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.
Pages: 1 ... 7 8 [9] 10