Dwarf Fortress Bug Tracker - Dwarf Fortress
View Issue Details
0006364Dwarf FortressCombat -- Generalpublic2013-07-30 23:402014-07-23 10:49
Toady One 
0006364: Weight fraction not considered when calculating weapon velocities
Item weight appears to be stored as two numbers. The first number is the integer weight of the item. The second is the xxxxxx/1000000 fractional weight of the item. It appears that only the integer weight is used in the calculation of the (melee or ranged) weapon's (swing/shoot) velocity.

However, the momentum of the weapon appears to be calculated using both the integer weight and the weight fraction. This puts discontinuities in the plot of weapon momentum vs weight, and causes weapons of weights 0.999999 or less to travel at the MAX_VEL.
A melee weapon of weight 0.999999 has roughly 2x the momentum of a weapon of weight 1.000001

A melee weapon of weight 1.999999 has roughly 1.5x the momentum of a weapon of weight 2.000001


I discovered the bug through various experiments in the arena, but Toady should be able to debug the numbers directly.
Bug 0006262 is a sub-bug (child) of the larger problem.
binary patch, Probable Quick Fix
related to 0006262resolved Toady One Rounding Error in Calculation of Projectile Velocities 
Issue History
2013-07-30 23:40UristDaVinciNew Issue
2013-08-02 04:28Knight OtuRelationship addedrelated to 0006262
2013-09-26 18:55UristDaVinciNote Added: 0024143
2013-09-26 18:58UristDaVinciTag Attached: binary patch
2013-09-26 18:58UristDaVinciTag Attached: Probable Quick Fix
2013-10-09 12:33UristDaVinciNote Added: 0024163
2013-10-09 21:16FootkerchiefNote Edited: 0024163bug_revision_view_page.php?bugnote_id=0024163#r8990
2014-01-15 14:49Kirig Stonebeard IIIssue Monitored: Kirig Stonebeard II
2014-01-17 10:09Kirig StonebeardIssue Monitored: Kirig Stonebeard
2014-03-25 13:22DwarfuAssigned To => Dwarfu
2014-03-25 13:22DwarfuStatusnew => acknowledged
2014-07-23 10:49Toady OneNote Added: 0027330
2014-07-23 10:49Toady OneStatusacknowledged => resolved
2014-07-23 10:49Toady OneFixed in Version => Next Version
2014-07-23 10:49Toady OneResolutionopen => fixed
2014-07-23 10:49Toady OneAssigned ToDwarfu => Toady One

2013-09-26 18:55   
The bug is due to weight_fraction being divided by 100000 instead of 10000, causing a weapon of weight x.yyyyyy to act like a weapon of weight x.0yyyyyy

The following binary patch fixes this problem in Win32 v0.34.11 SDL:
 0x006C8BE2 : 89 b5 f8 14 -> d7 c5 6d 34
 0x006C8BEE : 0D -> 0B

so you end up with this at 0x006C8BE0 :
ff b8 d7 c5 6d 34 6b db 64 f7 6f 60 cl fa 0b 8b
2013-10-09 12:33   
(edited on: 2013-10-09 21:16)
The binary patch doesn't fix the related bug 0006262, which is caused by a different problem in other code.

Toady One   
2014-07-23 10:49   
This one bizarrely had the correct calculation in the debug log on the line below it. The extra zero must have gotten in later somehow... Scamps will be blamed.