StrangerFromTheInternet Posted September 6, 2016 Posted September 6, 2016 For a few items with high health points and low decay values, item decay does not occur unless the game is heavily accelerated (e.g. sleeping / passing time). This is because - for whatever reasons - only single precision floating point values are used for the item's internal health points. Let's take a player on Pilgrim difficulty with constant 60 FPS who has a brand new pack of beef jerky lying around outside. This gives us the following constants float hp = 1000f float decayPerDay = 0.1f float deltaTimeSeconds = 1 / 60f float dayLengthSeconds = 7200f; // Assuming not sped up, 12 in-game seconds per real-life second float decayScale = 0.25; // Due to Pilgrim float decay = (deltaTimeSeconds / dayLengthSeconds) * decayPerDay * decayScale; // = 5.7870377E-8 which is a lot smaller than the 3.0517578E-5 that is needed to get "hp" to go to the next smaller value. This means that (hp - decay) == hp is true, as long as timeScale is lower than 527.3437. And even then, there would be quite severe rounding errors. How to fix this: The easiest fix would be to just use double-precision floating point numbers instead of single-precision ones. There aren't even any real drawbacks to this as double-precision calculations are just as fast as single-precision calculations on CPUs. There's just the memory aspect, but even with 200'000 items, the added 4 bytes / item would result in less than 1 MB of additional RAM usage. Devs, please fix.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.