Preliminary research into attacks and the values in dfhack.
The attack action is currently filled with unknown variables. And currently looks like
target_unit_id = 28
unk_4 = <unit_action.T_data.T_attack.T_unk_4: 0x17234f0c>
attack_item_id = 15
target_body_part_id = 0
attack_body_part_id = -1
attack_id = 1
unk_28 = 0
unk_2c = 1
unk_30 = 57
flags = 66
unk_38 = 0
unk_3c = 58
timer1 = 3
timer2 = 4
It has been "established" that unk_30 and unk_3c are attack_velocity and attack_hitchance (or somehow related to hit chance) and I believe the names have even been changed in the new DFHack. The following research tries to investigate the other components.
Tests done. By having several groups of dwarves with the same stats attack eachother with differing skills I have been analyzing their attack actions. Currently found results.
attack.flags
Flags is a specific number, meaning you won't find just a random number between say 0 and 100. Instead it appears to be tied to the type of attack done (i.e. fast attack, wild attack, etc...). My reasoning behind this is that the attack.flag and attack.timer1/attack.timer2 is fixed, independent of attack preformed (with the exception of weapon vs non-weapon attacks). This means that if you were to tell me that the flags for a short sword attack was 66 I could tell you that the timer1 = 3 and timer4 = 4. In the couple dozen or so tests I ran with short swords, the flags values could be 2, 34, 66, 130, or 258. For the unnarmed attacks the flag values were 70, 134, or 262.
attack.unk_38
This number appears constant depending on if it is a weapon attack or creature attack. With all tested weapon attacks having unk_38 = 0 and all tested creature attacks having unk_38=102 or unk_38=103 (no idea why the difference all dwarves tested used 103, but some other animals used both, some only used 102, possibly other animals use other numbers?)
attack.unk_3c or hitchance
A highly variable number, as expected increase skill, on average, increases hit chance. The attack.flags also impacts hit chance greatly. With larger timer1 values and smaller timer2 values increasing hit chance (4,3 appearing to give the best increase for the tests done). Still need to do more work concerning varying agility, speed, and enemy dodge skills.
attack.unk_30 or velocity
Velocity values have been analyzed by Urist DaVinci in his disassemble work and appear to follow those values well.
attack.unk_28 and attack.unk_2c
No idea. Doesn't seem to be tied to anything I could think of, with unk_28 varying between 0 and 4 (usually 0, 1, or 2) and unk_2c varying between -2 and 5 (usually -2, -1, 0, or 1). Possibly related to the attack.unk_4 vector, as I have not studied the numbers in there yet.
That is my small update for now.
EDIT: After looking through about 50,000 attacks it appears that velocity and hit chance are related to eachother. For basic attacks (not fast, wild, hard, etc...) you have a higher velocity = higher hit chance (the particular equation I looked at was hit chance = velocity*0.8 - 40, but I haven't looked at the impact skills and attributes have yet). Now when you throw in different types of attacks the relationship changes, but it's a nice start.
EDIT2: Here are two simple graphs showing the velocity and hit chance of different types of attacks for dwarves with 1000 strength and 1000 agility at different skill levels.
(https://i.img.ie/jWp.png)
You will notice that the hit chance increases linearly with skill level, but the velocity seems to plateau.
Other interesting notes
Quick and Heavy have the same hit chance as Normal attacks, with Precise having more and Wild having less
Normal and Precise have the same velocities, Wild and Heavy have the same velocities, and Quick has the lowest velocities
Next step will be to check the effect attributes have on this distribution. Presumably the general shape will remain the same, with just the absolute values changing.
EDIT3: Last update for now. The reason the velocity is plateauing is because the max velocity of all attacks doesn't increase as skill goes up, just the minimum and the average. I believe you can think of there being an optimum velocity that you can reach based on your attributes and weapon (this is the velocity Urist DaVinci calculates), then the game uses a fraction of that velocity depending on how skilled you are. The more skilled, the closer that fraction goes to reaching 1. This is different from hitchance, which doesn't seem to have an upper cap, and whose max just keeps increasing along with the average at each skill level.
Quite unrelated to the research on attacks, but I haven't seen documentation on this anywhere, so here's my run-through on how to replicate the "true name" mechanics utilised by worldgen demon slabs:
Creating a "true name" and linking it to your target:
1) obtain your target unit's hist_figure_id
2) insert a new "identity" in df.global.world.identities.all and remember to increase the value of df.global.identity_next_id by +1
3) in the "identity" :
id: insert the "identity" index value
name: edit as desired and set "has_name" to true (this shall be the hidden "true name" of your target unit)
histfig_id: insert the target unit's hist_figure_id
unk_4c: not sure what this does, but apparently must be set to "2" for this to work
all other fields can be set to -1
4) df.historical_figure.find(histfigId).info.reputation.all_identities:insert("#", newidentityId)where histfigId = the hist_figure_id of your target unit
and newidentityId = the id of your previously created identity
Note that df.historical_figure.find(histfigId).info.reputation and possibly even df.historical_figure.find(histfigId).info may need to be newly created in some cases.
Of course, an entirely new histfig will need to be created for non-historical figures.
Creating a functional "true name" slab:
5) obtain or create a slab
6) in your target slab item:
engraving_type: set to "25" (DemonIdentity)
topic: insert your target unit's hist_figure_id
At this point, any unit who reads the slab will gain knowledge of the target's secret identity, and the invoke/banish conversation options will become available when talking to the target.
The effect of reading a "true name" slab:
Upon reading the slab, the following occurs:
df.historical_figure.find(x).info.secret.anon_2:insert("#", y)where 'x' is the hist_figure_id of the reader
and 'y' is the id of the identity linked to the hist_figure_id on the slab
Incidentally, this means that the slab can be entirely omitted from the procedure if so desired, by directly modifying the histfig info of the unit who is to learn the target's identity.
creature_raw.flags.unk_69
Was set to true for every race except for the following creatures in a vanilla test world:
blood man
gabbro man
amethyst man
bronze colossus
fire man
magma man
iron man
mud man
forgotten beast
forgotten beast
forgotten beast
forgotten beast
brute of brine
specter of salt
specter of steam
white ghost
steam haunt
snow haunt
fiend of ash
specter of embers
boiling demon
Being of The Hatchet
Seems to me that this flag refers to whether or not a creature is organic as opposed to inorganic.
creature_raw.flags.unk_49
Set to true for the following creatures:
dwarf
human
elf
goblin
kobold
cave fish man
olm man
bat man
cave swallow man
amphibian man
reptile man
serpent man
antman
rodent man
These are all the creatures which form civilisation-type entities at the beginning of worldgen.
creature_raw.flags.unk_6e
toad man
worm man
bluejay man
cardinal man
grackle man
oriole man
red-winged blackbird man
penguin man
peregrine falcon man
kiwi man
ostrich man
crow man
raven man
cassowary man
kea man
snowy owl man
sparrow man
white stork man
loon man
barn owl man
parakeet man
kakapo man
grey parrot man
puffin man
swan man
lorikeet man
wren man
osprey man
emu man
cockatiel man
peach-faced lovebird man
magpie man
kestrel man
albatross man
great horned owl man
eagle man
hornbill man
masked lovebird man
bushtit man
damselfly man
moth man
grasshopper man
bark scorpion man
mantis man
tick man
louse man
thrips man
slug man
mosquito man
jumping spider man
moon snail man
brown recluse spider man
snail man
leopard gecko man
desert tortoise man
gila monster man
fly man
roach man
beetle man
monarch butterfly man
firefly man
dragonfly man
mountain goat man
hoary marmot man
walrus man
narwhal man
hippo man
platypus man
grizzly bear man
black bear man
deer man
fox man
raccoon man
rhesus macaque man
cougar man
wolf man
groundhog man
alligator man
buzzard man
panda man
capybara man
badger man
moose man
red panda man
elephant man
warthog man
lion man
leopard man
jaguar man
tiger man
cheetah man
gazelle man
mandrill man
one-humped camel man
two-humped camel man
saltwater crocodile man
vulture man
rhinoceros man
giraffe man
honey badger man
giant tortoise man
armadillo man
muskox man
elk man
polar bear man
wolverine man
chinchilla man
gorlak
plump helmet man
octopus man
crab man
leopard seal man
cuttlefish man
orca man
sponge man
horseshoe crab man
sperm whale man
elephant seal man
harp seal man
nautilus man
lizard man
skink man
chameleon man
anole man
iguana man
otter man
snapping turtle man
beaver man
leech man
axolotl man
mink man
pond turtle man
rat man
gray squirrel man
red squirrel man
chipmunk man
hamster man
hedgehog man
flying squirrel man
squid man
cave fish man
olm man
bat man
cave swallow man
wild boar man
coyote man
kangaroo man
koala man
adder man
echidna man
porcupine man
kingsnake man
gray langur man
bobcat man
skunk man
green tree frog man
hare man
rattlesnake man
weasel man
copperhead snake man
ibex man
wombat man
dingo man
coati man
opossum man
mongoose man
hyena man
anaconda man
monitor lizard man
king cobra man
ocelot man
jackal man
capuchin man
sloth man
spider monkey man
pangolin man
black mamba man
sloth bear man
aye-aye man
bushmaster man
python man
tapir man
impala man
aardvark man
lion tamarin man
stoat man
lynx man
Mostly animal people, but the list also includes gorlaks and plump helmet men. Not entirely sure what to make of this.
creature_raw.flags.unk_6f
Refers to OUTSIDER_CONTROLLABLE.
creature_raw.flags[114]
wagon
chimera
centaur
griffon
sea lamprey
great white shark
frill shark
spiny dogfish
spotted wobbegong
whale shark
basking shark
nurse shark
shortfin mako shark
longfin mako shark
tiger shark
bull shark
blacktip reef shark
whitetip reef shark
blue shark
hammerhead shark
angelshark
common skate
manta ray
stingray
coelacanth
sturgeon
conger eel
milkfish
cod
opah
giant grouper
bluefish
ocean sunfish
swordfish
marlin
halibut
great barracuda
bluefin tuna
narwhal
giant narwhal
longnose gar
carp
tigerfish
pike
pond grabber
octopus
giant octopus
cuttlefish
giant cuttlefish
orca
giant orca
sponge
giant sponge
sperm whale
giant sperm whale
nautilus
giant nautilus
fluffy wambler
mussel
oyster
salmon
clownfish
hagfish
brook lamprey
bat ray
thornback ray
spotted ratfish
herring
shad
anchovy
steelhead trout
hake
seahorse
glasseye
white-spotted puffer
sole
flounder
mackerel
sea nettle jellyfish
squid
gigantic squid
clown loach
brown bullhead
yellow bullhead
black bullhead
banded knifefish
char
rainbow trout
sailfin molly
guppy
perch
sea serpent
sea monster
cave fish
Set to false for sea creatures, wagons and the non-existent chimera, centaur and griffon.
creature_raw.flags[115]
blue jay
bluejay man
giant bluejay
cardinal
cardinal man
giant cardinal
grackle
grackle man
giant grackle
oriole
oriole man
giant oriole
red-winged blackbird
red-winged blackbird man
giant red-winged blackbird
peregrine falcon
peregrine falcon man
giant peregrine falcon
crow
crow man
giant crow
raven
raven man
giant raven
kea
kea man
giant kea
snowy owl
snowy owl man
giant snowy owl
sparrow
sparrow man
giant sparrow
white stork
white stork man
giant white stork
loon
loon man
giant loon
barn owl
barn owl man
giant barn owl
parakeet
parakeet man
giant parakeet
grey parrot
grey parrot man
giant grey parrot
puffin
puffin man
giant puffin
swan
swan man
giant swan
lorikeet
lorikeet man
giant lorikeet
wren
wren man
giant wren
osprey
osprey man
giant osprey
cockatiel
cockatiel man
giant cockatiel
peach-faced lovebird
peach-faced lovebird man
giant peach-faced lovebird
magpie
magpie man
giant magpie
kestrel
kestrel man
giant kestrel
albatross
albatross man
giant albatross
great horned owl
great horned owl man
giant great horned owl
eagle
eagle man
giant eagle
hornbill
hornbill man
giant hornbill
masked lovebird
masked lovebird man
giant masked lovebird
bushtit
bushtit man
giant bushtit
damselfly
damselfly man
giant damselfly
moth
moth man
giant moth
mantis
mantis man
giant mantis
thrips
thrips man
giant thrips
mosquito
mosquito man
giant mosquito
duck
goose
fly
fly man
giant fly
large roach
roach man
giant roach
ant
monarch butterfly
monarch butterfly man
giant monarch butterfly
firefly
firefly man
giant firefly
dragonfly
dragonfly man
giant dragonfly
honey bee
bumblebee
buzzard
buzzard man
giant buzzard
vulture
vulture man
giant vulture
hungry head
bugbat
cave floater
acorn fly
blood gnat
fairy
pixie
nightwing
harpy
roc
giant bat
bat
bat man
cave swallow
cave swallow man
giant cave swallow
antman
forgotten beast
forgotten beast
forgotten beast
forgotten beast
forgotten beast
forgotten beast
forgotten beast
forgotten beast
forgotten beast
forgotten beast
forgotten beast
brute of brine
specter of salt
specter of steam
white ghost
steam haunt
snow haunt
fiend of ash
specter of embers
boiling demon
wicked man
Being of The Hatchet
Appears to to be set to false for creatures which have at least one caste capable of flight.
creature_raw.flags[116]
blind cave ogre
manera
troll
ogre
giant
blizzard man
troglodyte
dusk man
shadow creature
wicked man
woman of shadow
freak of twilight
Probably refers to SLOW_LEARNER.
creature_raw.flags[117]
to
creature_raw.flags[135]
Appear to be identical to creature_raw.flags[116].