Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0001821Dwarf FortressItemspublic2010-05-10 04:552020-02-28 09:20
Knight Otu 
0001821: Armor with [UBSTEP:MAX] and [LBSTEP:MAX] protects child bodyparts of parts it doesn't protect.
I've noticed this with a modded armor, but this behavior manifests with robes (and presumably dresses) as well. An armor that has the [UBSTEP:MAX] and [LBSTEP:MAX] tags protects eyes, noses, ears, facial features, fingers, and toes, but does not protect the head, hands, or feet of the armored character.
Put a human in a rope reed robe into the arena, and add a few foxes allied with each other. Attacks should glance away from toes and the like, while denting hands and feet.
Shouldn't be necessary to add, but the armor with which I first noticed this behavior is the following:

    [NAME:knuckle plate:knuckle plates]
armor, body parts, coverage, fingers, LBSTEP, protection, toes, UBSTEP
has duplicate 0000144closed Footkerchief Dress reflects attack on fingers [Armor Coverage Problem] 
has duplicate 0002111closed Footkerchief My leather shirt is protecting my cheeks. 
has duplicate 0002346resolved Footkerchief Reports show that cloak protects face 
has duplicate 0003636resolved Footkerchief Mail shirts protect lips, eyelids etc. 
related to 0001060resolved Toady One Toes, fingers, ears, cheeks, etc. are not protected by armor. 
Issue History
2010-05-10 04:55Knight OtuNew Issue
2010-05-10 07:38derigoNote Added: 0006498
2010-05-10 07:38derigoNote Edited: 0006498bug_revision_view_page.php?bugnote_id=0006498#r2405
2010-05-10 07:41derigoNote Edited: 0006498bug_revision_view_page.php?bugnote_id=0006498#r2406
2010-05-10 07:54derigoNote Edited: 0006498bug_revision_view_page.php?bugnote_id=0006498#r2407
2010-05-10 07:55derigoIssue Monitored: derigo
2010-05-10 21:19derigoNote Added: 0006536
2010-05-10 21:49derigoNote Edited: 0006536bug_revision_view_page.php?bugnote_id=0006536#r2421
2010-05-10 21:54derigoTag Attached: armor
2010-05-10 21:54derigoTag Attached: body parts
2010-05-10 21:54derigoTag Attached: coverage
2010-05-10 21:54derigoTag Attached: fingers
2010-05-10 21:54derigoTag Attached: LBSTEP
2010-05-10 21:54derigoTag Attached: protection
2010-05-10 21:54derigoTag Attached: toes
2010-05-10 21:54derigoTag Attached: UBSTEP
2010-05-11 09:01derigoNote Added: 0006547
2010-05-11 09:50derigoNote Edited: 0006547bug_revision_view_page.php?bugnote_id=0006547#r2430
2010-05-11 11:08derigoNote Edited: 0006547bug_revision_view_page.php?bugnote_id=0006547#r2431
2010-05-11 11:10derigoNote Edited: 0006547bug_revision_view_page.php?bugnote_id=0006547#r2432
2010-05-31 08:55FootkerchiefRelationship addedhas duplicate 0000144
2010-05-31 08:56FootkerchiefRelationship addedhas duplicate 0002111
2010-05-31 10:17FootkerchiefRelationship addedrelated to 0001060
2010-06-15 20:33Logical2uRelationship addedparent of 0002346
2010-11-15 17:03FootkerchiefRelationship addedhas duplicate 0003636
2010-11-28 06:19Hieronymous AlloyIssue Monitored: Hieronymous Alloy
2014-01-27 20:22FootkerchiefRelationship replacedhas duplicate 0002346
2020-02-28 08:47friendguy13Note Added: 0040252
2020-02-28 08:48friendguy13Note Edited: 0040252bug_revision_view_page.php?bugnote_id=0040252#r16369
2020-02-28 09:12friendguy13Issue Monitored: friendguy13
2020-02-28 09:14FantasticDorfNote Added: 0040253
2020-02-28 09:20FantasticDorfNote Added: 0040254
2020-02-28 09:22FantasticDorfNote Edited: 0040253bug_revision_view_page.php?bugnote_id=0040253#r16371

2010-05-10 07:38   
(edited on: 2010-05-10 07:54)
for coherency's sake (this is a confusing topic), here's toady's comments on the subject:

"Okay, lessee... for armor, start at the body part you are checking. If it the part the item is being worn on, or it is a lower body and it's parent is the part the item is being worn on, then it gets the main blocking number.

Otherwise, does the part have a descendant that is a stance point as does not have an intervening upper/lower body? Stance points determine whether it's upper or lower (UBSTEP or LBSTEP). Stance points must be connected through [LIMB]s to the part for the stance point to be recognized as relevant.

We still need to check if the part is related to the item at all. Go up the part's ancestors, counting steps (do not count steps as you pass through bodies). If you hit the parent, good, use that number, plus whether it is "lower" or not, and compare it to the proper steps variable. However, if you pass through an UPPER/LOWERBODY on the way, and then aren't in one, you aren't related to the armor item, and it bails. If you do something odd like attach a lower body to another lower body which is attached to the upper body the item is on, I think it will respond poorly, covering any legs attached to the lower-lower body, but not covering the lower-lower body itself, so bodies attached to bodies attached to bodies aren't supported yet as far as armor goes.

In short, armor protects an upper body and any attached lower body with the main number, as well as any other attached non-bodies attached to the bodies, without intervening bodies. Descendant stance points determine if UBSTEP or LBSTEP is used.

I tested this a bit back when I added it, and a few times since then, but there might also be problems of course.

So if I'm reading the code right and haven't missed anything, if you have a bipedal creature with wings and a tail, the wings will be covered by [UBSTEP:<N>] if N>=1, and the tail is the same way, even though it goes up through a lower body first, since it has no stance point. If you add a foot on the end of the tail, you'd use [LBSTEP:<N>], N>=1 instead. Extra limbs are all covered as regular limbs. Quadrupeds would have their "arms" covered by LBSTEP instead of UBSTEP." -Toady One

The thread where the discussion takes place is here:
http://www.bay12forums.com/smf/index.php?topic=18536.0 [^]

If I am reading and understanding this all completely (and I may easily be not), an ARMOR item with UBSTEP:MAX and LBSTEP:MAX should protect all body parts. It should protect fingers, eyeballs, and toes. But it should _also_ protect hands, feet, and heads. If your experimental data is correct, the problem is not that its protecting the little bits, but that its NOT protecting the non-body non-limb parts.

2010-05-10 21:19   
(edited on: 2010-05-10 21:49)
Hmm! OK I take back my previous statement, I don't think hands and feet (or fingers or toes etc) are supposed to be protected by armor in the way I said above. I swear I had to read toady's post like 10 times before it even began to make sense to me. ;p

First of all, I verified the behavior you reported. I made an armor called cheats:


I put a dwarf in an adamantine cheat against about 15 foxes. They nibbled off his feet, hands, and head without touching the toes, fingers or facial features. Then I tried some adamantine greaves.


Notice greaves have [LBSTEP:MAX] but not the [UPSTEP:MAX]

The dwarf was riddled with fox bites on all his parts except for his lowerbody, upper legs, and lower legs. His feet and toes were also chewed to shreds. This makes sense by the rules. Since feet ARE a [STANCE] point, and not a [LIMB], they don't get protected at all by [LBSTEP:MAX], and neither do toes.

Then, I made some superpants:


Notice the addition of [UBSTEP:MAX] to the pants.

Wearing only these pants, the wounds behaved just like they did wearing normal greaves. So no amount of UBSTEP allows pants to protect any part of the upperbody. This isn't mentioned in toady's explaination above. I was expecting something like this, but I was also expecting the toes to be protected as they were with the body armor. That was not the case, toes got chewed up just fine.

To be clear, the strange behavior reported by the OP _only_ happens when both MAX tags are present, and _only_ on body armor, that is to say ITEM_ARMOR.

Finally I tried adamantine Gauntlets and Boots and Helms both with and without MAX UBSTEP and LBSTEP. As reported in 0001060, gauntlets boots and helms do NOT protect toes, fingers, or facial features. Gauntlets with LBSTEP and boots with UBSTEP will protect arms and legs respectively, as expected. But neither will protect toes or fingers.


-The only way to protect [STANCE], [GRASP], or [HEAD] parts (feet, hands and head) is with armor worn on them specifically.
-[LIMB]s are correctly protected by UBSTEP and LBSTEP
-The ONLY way to protect parts that are not [LIMB],[STANCE],[GRASP],[HEAD] or [UPPER/LOWERBODY] parts (such as facial features, toes, fingers, throat, vestigial wings, any cosmetic custom parts, etc)is by exploiting the bug reported by the OP. You need a robe, or a dress; a body armor with UBSTEP:MAX and LBSTEP:MAX.
-dwarves getting nibbled to death by many foxes is hilarious

2010-05-11 09:01   
(edited on: 2010-05-11 11:10)
Ah here's why it only affects ITEM_ARMOR and not ITEM_PANTS

"ITEM_PANTS_SUPERPANTS:Unrecognized Item Definition (Pants) Token: UBSTEP
*** Error(s) found in the file "raw/objects/item_pants.txt"

UBSTEP is an invalid token for pants. Helms don't allow UBSTEP, LBSTEP, or UPSTEP which explains why its not possible to protect the throat or facial features with a helm. Similarly, neither gloves nor boots allow LBSTEP(you can't reasonably attach feet to feet or feet to hands, so this makes sense).

Also worth noting, the ITEM_GLOVES and ITEM_SHOES use the UPSTEP token rather than UBSTEP, as can be seen on gauntlets, chauses, or high boots. UPSTEP is invalid for pants and helms. UPSTEP is a valid token for body armor(it doesn't throw an error), but neither does it seem to have any effect.

Another update, very relevant to the stated bug:
LBSTEP is working fine, its UBSTEP that's being buggy. If you make body armor with UBSTEP:MAX but LBSTEP:0, it will still cover the toes. The only difference is that the legs won't be covered (because LBSTEP is 0). Also, the UBSTEP needn't be MAX. It just needs to be high enough to reach the parts in question. You need a UBSTEP>=4 to reach fingers and toes, and a UBSTEP>=2 to reach facial features.

It is stepping through in the following manner:
step 0: the lower body
step 1: the upper leg (but this is a LBSTEP part, so it doesn't actually protect this part)
step 2: the lower leg (same)
step 3: the foot (but body armor doesn't protect feet, so it doesn't actually protect this part)
step 4: toes

From Toady's perspective, you step in the other direction of course (from toes to UPPERBODY).

2020-02-28 08:47   
(edited on: 2020-02-28 08:48)
I tested it yesterday and this bug still exists in 47.03.. 10 years later. :(

2020-02-28 09:14   
(edited on: 2020-02-28 09:22)
To quickly add to @friendguy13 it may be especially prevalent with the addition of shaking inside your armor now within recent versions past 42.xx in response to force, since the force exerpted may cause certain connected STEP parts & tissues to take damage.

Taking the OP's original statement into consideration, you wouldn't want the [UB_STEP:MAX] and [LP_STEP:MAX] armor described to deflect a heavy hit to your armor piece and your eye sockets, teeth, nose, fingers & toes to simultaneously explode into gore through the shaking connection on top of the damage, fly out or collapse.

2020-02-28 09:20   
Coincidentally, injuries to finger digits and toes are very common regarding accidents while wood-cutting, falling rocks & items & also justice beatings where the digit isn't protected and usually ends up mangled (if they dont go for other targets like the throat)

A specific example of biting the neck through a cloak can be found at 0010861 by the related guards bad behaviour.