Jump to content

nosebleed

Member
  • Posts

    5
  • Joined

  • Last visited

nosebleed's Achievements

  1. • Version? 41.78.16 • Singleplayer/Multiplayer? All • Host or dedicated? All • Mods? None • Old or new save? New • Reproduction steps: start in debug mode set character weight to 36 set character calories to 0 open up character info and observe the chevron is indicating weight gain speed gametime up to 3x monitor character weight from debug menu. Note that it starts decreasing while the chevron is showing increase after a short wait time. After testing I managed to confirm the following: The chevron incorrectly shows an increasing weight trend between character weights 35 to 39. At weight 36 it appears to show incorrectly between -160 and 0 calories weight 37 between -120 and 0cal weight 38 between -80 and 0cal weight 39 between -40 and 0cal [EDIT] I've found a weirder thing. Below the stated minimum numbers, weightloss stabilizes. for example: at weight 39, between -930 and -40 calories, character weight does not change, however between -40 and 0 it drops. So here I'm left wondering that perhaps the character weight gains and losses are bugged, and the chevron might be showing what was intended? [/EDIT]
  2. Those 710.1cal loses do not take into account the food use reduction bonus at all, only the calorie increase bonus. If that bonus were to apply on the final use in a way it was intended instead of subtracting, the loses are actually even higher in this bug.
  3. I understand what you mean by rounding error, thanks for the additional info. It is not the case with this bug report. I've done more digging and have finally found a formula that explains the bug so I can at least in the meantime apply a workaround in my mod until it's (hopefully) fixed. TL;DR the final use when it removes an item, the cook bonus that reduces the amount used of an item applies, when we should actually be using the entire item up, hence the lost calories. It is not a small number. This is per item use in a recipe, so if we were to minmax loses with the bug, we can lose at least 710.1 calories in the example below in a single rabbit meat stew. Calculating nutrition given a cook skill: example with default rabbitmeat spawned in debug mode $foodHunger = 30 $foodCalories = 969 $recipeHungerCost = 15 $cookPerkLevel = 10 $cookReductionBonus = 1 - (0.03 * $cookPerkLevel) $cookNutritionIncrease = 1 + ($cookPerkLevel / 15) $reducedRecipeCost = $recipeHungerCost * $cookReductionBonus $percentageOfFoodToUse = MIN($reducedRecipeCost / $foodHunger, 1) $CaloriesInStew = $cookNutritionIncrease * $foodCalories * $percentageOfFoodToUse = 565.25 $foodHunger = $foodHunger * (1 - $percentageOfFoodToUse) = 19.5 $foodCalories = $foodCalories * $percentageOfFoodToUse = 629.85 These numbers checkout in-game nutrition values. Second use of the item: $CaloriesInStew += $cookNutritionIncrease * $foodCalories * $percentageOfFoodToUse = 1130.5 $foodHunger = $foodHunger * (1 - $percentageOfFoodToUse) = 9 $foodCalories = $foodCalories * $percentageOfFoodToUse = 290.7 second use also exactly checks out with in-game nutrition values. Now this is where things get funky on the final, third use now that $foodHunger is less than $recipeHungerCost. The $percentageOfFoodToUse never gets set to 1 in zomboid if the cook skill is higher than 0. For some reason, after wracking my brains somewhat while playing with this formula, $recipeHungerCost gets set to the same value as $foodHunger when it's the final use of a food item, but before the reduced recipe cost calculation, instead of setting $reducedRecipeCost to the value of $foodHunger. This means the reduction-bonus applies, and we lose calories since the item is tossed after this final use. To demonstrate in a formula: $recipeHungerCost = $foodHunger = 9 $reducedRecipeCost = $recipeHungerCost * $cookReductionBonus = 6.3 $percentageOfFoodToUse = MIN($reducedRecipeCost / $foodHunger, 1) = 0.7 In this example, we only get to use 70% of the food item instead of 100%, then throw the remaining rabbitmeat away. This equation above accurately calculates what we see ingame (with a final rounding error of 0.01 for proteins,carbs and lipids vs what is displayed ingame, but calories is high enough not to have rounding errors) Final values: Stew with 3x rabbitmeat uses has calories 1469.65 as it stands in zomboid right now. If this bug is fixed, it should be atleast 1615 calories @cook level 10. That's a 9% difference, or a 118.35 calorie difference for a single recipe ingredient in a stew which takes up to 6 ingredients. With rabbitmeat alone we could see losses up to 710.1 calories for a single stew in the right circumstances. This is a significant potential loss of nutrition during a long playthough and we're only talking about a single meal out of the hundreds if not thousands people cook. Thank you if you managed to read this far. I hope I wrote clearly enough and that perhaps a dev in the future might have a look into this. I can upload a spreadsheet file that I used to figure all this out, it might be a little easier to follow than the wall of text above.
  4. The nutrition system hasn't shown high rounding errors so far while I've been doing the mod, only at the third decimal place sometimes from what I have tested. Certainly does not explain the wild variation in the above examples nor negative values. In the first example where we edit in high nutrition numbers (which should help mitigate rounding errors), it loses ~9% of the nutrition at cook 0. At cook 10, it loses ~3%. How would a rounding error cause it to go negative? also why is it by such high amounts?
  5. • Version? 41.78.16 • Singleplayer/Multiplayer? All • Host or dedicated? All • Mods? None • Old or new save? New • Reproduction steps: Start game in debug Spawn the following items: -Open canned corned beef -Cooking Pot with Water (for exaggerating the bug): Edit the canned corned beef Reduce the hunger value lower than the cost of putting it in the stew, for this example use -0.06 to simulate the tail-end of a food item Set calories, carbs, protein and fat to 1000 each hit save right click the pot with water then create stew with the canned corned beef we edited Note that the calories, carbs, protein and fat are less than 1000. The can is fully used. Expected behaviour is that the created stew has either the same nutrition or higher (if cook level is higher than 0). With this bug, even with cooking level 10 the nutrition values are lower than the original cans values. Indepth info, and why it affects normal in-game items: This happens for all food that you use in recipes with partial leftovers. You get these leftovers generally with a higher cooking skill. For an example to prove it affects normal in-game items: Spawn in an opened canned vegetable soup and another cooking pot with water set your cook level to 3 add the first use of the can to a stew in the pot note the calories in the pot: 136.5 note the calories remaining in the can: 11.25 add the last use of the canned vegetable soup into the cooking pot with water final calories: 147.47 This increases the stew by 10.97 calories, after adding a can worth 11.25. Expected increased calories should have been higher than 11.25 since our cook skill is 3. This affects all nutrition values, not just calories. I have a hunch that this bug will affect the nutrition from rotten food when you cook with it at 7+ skill level, since they are probably in the partial food item territory. In the grand scheme of things this is small, but it really messes up a mod I am trying to create for cooking. This has been doing my head in until I realized it's actually a bug!
×
×
  • Create New...