Anonymous | Login | Signup for a new account | 2024-11-01 11:31 PDT |
Main | My View | View Issues | Change Log | Roadmap |
View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | |||||
ID | Project | Category | View Status | Date Submitted | Last Update | |
0006262 | Dwarf Fortress | Throwing/Shooting | public | 2012-12-12 05:18 | 2014-08-03 13:29 | |
Reporter | Pirate Bob | |||||
Assigned To | Toady One | |||||
Priority | normal | Severity | trivial | Reproducibility | always | |
Status | resolved | Resolution | fixed | |||
Platform | Computer | OS | Windows/Linux | OS Version | all | |
Product Version | 0.34.11 | |||||
Target Version | Fixed in Version | 0.40.05 | ||||
Summary | 0006262: Rounding Error in Calculation of Projectile Velocities | |||||
Description | Projectile (bolts, arrows, blowdarts) velocities appear to be calculated using the formula: velocity=[SHOOT_FORCE]/(([SOLID_DENSITY]*[SIZE])/1,000,000), and then capped to [SHOOT_MAXVEL]. All numbers are treated as integers throughout, and therefore floored to the nearest integer after each multiplication/division. [SHOOT_FORCE], [SIZE] and [SHOOT_MAXVEL] are defined by the launcher (bow, crossbow, etc) and [SOLID_DENSITY] by the ammo material. See this thread for details and derivation: http://www.bay12forums.com/smf/index.php?topic=116151.msg3716892;topicseen#msg3716892 [^] As a result: 1) Any bolts/arrows with [SOLID_DENSITY] between 6666 and 13333 (all metals except adamantine) will have velocity equal to [SHOOT_FORCE]. 2) Bolts lighter than [SOLID_DENSITY:6666] (wood, bone, adamantine) will have velocity equal to [SHOOT_MAXVEL]. 3) Since both [SHOOT_FORCE] and [SHOOT_MAXVEL] are 1000, all bolts will have velocity 1000. 4) Armor penetration (in most cases) and damage depend on bolt momentum, so bolts made of denser materials will be more effective. | |||||
Steps To Reproduce | Download the script chkproj.lua from http://www.bay12forums.com/smf/index.php?topic=116151.msg3716892;topicseen#msg371689 [^] and use it to check projectile velocities, which are given by the variable unk22. By changing [SHOOT_FORCE], [SHOOT_MAXVAL] and bolt [SOLID_DENSITY] one can quickly verify the rounding behavior. This has also been verified by measuring deflection of bolts off armored targets. All metal bolts were found to have exactly the same rate of deflection as a function of momentum when momentum was calculated using the velocity formula described, and mass=([SOLID_DENSITY]*[SIZE])/1,000,000. See http://www.bay12forums.com/smf/index.php?topic=116151.msg3733282#msg3733282. [^] | |||||
Additional Information | This could easily be fixed by changing the velocity calculation to: velocity=1,000,000*SHOOT_FORCE/[SOLID_DENSITY]/[SIZE] If this is not possible, then the original calculation could be used with all numbers converted to floating point within the calculation, and then the final velocity rounded to an integer. The effects of this bug cannot be detected without modding/hacking in the current version because all bolts have such high momenta that small differences have no noticeable impact. I have therefore marked it as trivial. However, if bolt momenta were reduced to give armor a chance of stopping projectiles (see [url=http://www.bay12games.com/dwarves/mantisbt/view.php?id=5516 [^]]5516[/url]), then this bug would become significant. It is also possible, but I think very unlikely, that this is "intended behavior". This bug renders the [SHOOT_FORCE] parameter almost useless, as all projectiles are fired with the same velocity. If Toady wanted all projectiles fired with the same velocity, he could have just set a fixed projectile velocity rather than calculating it from [SHOOT_FORCE]. | |||||
Tags | No tags attached. | |||||
Attached Files | ||||||
Relationships | ||||||||||||||||
|
Notes | |
(0023774) Pirate Bob (reporter) 2012-12-12 05:58 |
This bug should be marked as related to 0005516, and vice versa, but I can't figure out how to do that (maybe admin privileges are required?). Also, sorry about the nasty looking links - I thought maybe BBcode would work, but apparently not... |
(0023944) Quietust (reporter) 2013-04-13 15:34 |
For reference, the "chkproj.lua" mentioned above is a script for use with DFHack and thus isn't likely to be useful to Toady in tracking down the problem (since he can debug the game directly). |
(0023947) ScegfOd (reporter) 2013-04-19 05:00 |
this bug reminded me of a C++ tutorial i was looking at once upon a time... does Toady program in C++? type casting might fix this bug easily http://www.cprogramming.com/tutorial/c/lesson11.html [^] |
(0024164) UristDaVinci (reporter) 2013-10-09 12:39 |
I used windbg on the relevant code, and this "bug" is caused by only the integer weight of the bolt being used in the integer division SHOOT_FORCE/WEIGHT. It appears that this code was imported from earlier versions of Dwarf Fortress (such as "40d"), where weight numbers were all larger. This code wasn't updated when fractional weights were introduced. It's almost not a bug, instead just a non-updated feature like siege weapons. |
Issue History | |||
Date Modified | Username | Field | Change |
2012-12-12 05:18 | Pirate Bob | New Issue | |
2012-12-12 05:51 | Pirate Bob | Issue Monitored: Pirate Bob | |
2012-12-12 05:58 | Pirate Bob | Note Added: 0023774 | |
2012-12-12 07:18 | PetWolverine | Issue Monitored: PetWolverine | |
2012-12-12 09:48 | Knight Otu | Relationship added | related to 0005516 |
2013-04-13 13:07 | Pirate Bob | Tag Attached: Probable Quick Fix | |
2013-04-13 15:34 | Quietust | Note Added: 0023944 | |
2013-04-19 05:00 | ScegfOd | Note Added: 0023947 | |
2013-08-02 04:28 | Knight Otu | Relationship added | related to 0006364 |
2013-10-09 12:39 | UristDaVinci | Note Added: 0024164 | |
2013-10-28 11:22 | JimiD | Issue Monitored: JimiD | |
2014-01-17 10:33 | Kirig Stonebeard | Issue Monitored: Kirig Stonebeard | |
2014-07-14 11:28 | Footkerchief | Relationship added | has duplicate 0006870 |
2014-07-24 09:30 | Footkerchief | Tag Detached: Probable Quick Fix | |
2014-07-24 14:35 | Footkerchief | Relationship replaced | related to 0006870 |
2014-07-24 15:05 | Toady One | Status | new => resolved |
2014-07-24 15:05 | Toady One | Fixed in Version | => Next Version |
2014-07-24 15:05 | Toady One | Resolution | open => fixed |
2014-07-24 15:05 | Toady One | Assigned To | => Toady One |
2014-08-03 13:29 | PetWolverine | Issue End Monitor: PetWolverine |
Copyright © 2000 - 2010 MantisBT Group |