Welcome to the AFK Mods bug tracker. In order to report an issue, please select a project from the drop down menu below. Select “Open New Issue” and fill out the form with as many details as possible.

An account will be required to submit an issue, so if you need one and are unable to register, please contact us via the forums at https://afkmods.iguanadons.net/

Issue Data
Status: Closed
Issue Type: Bug Report
Project: Unofficial Fallout 4 Patch
Component: Fallout 4: Vanilla
Category: Papyrus
Assigned To: Sclerocephalus
Platform: All
Severity: Low
Votes: 0
Watching: N/A
Opened By Sclerocephalus on Mar 30, 2017 10:40 am
Last Edited By Arthmoor on May 8, 2017 4:53 pm
Closed By Arthmoor on May 8, 2017 4:53 pm
Resolution: Fixed
Comment: Fixed for UFO4P 2.0.1.

Issue #22245: WorkshopParentScript - ProduceFood function operates on bogus chance values

This is called by the daily updates on workshop script with a number of food items passed in (this is the 'totalFoodToProduce' value) which the respective workshop is allowed to produce.

The script then has to check which food types exist at the workshop, how many crops exist for each food type and to calculate individual production chances based on these values.

It's actually a very simple calculation: sum up the resources, then calculate individual production chances by dividing the resource count for each food type by the grand total.

Instead however, the vanilla script gets the production chances per division by totalFoodToProduce (it nowhere calculates a grand total of resources, btw):

<code php> while i < WorkshopFoodTypes.Length
ActorValue foodType = WorkshopFoodTypes[i].resourceValue
foodTypeChance[i] = workshopRef.GetValue(foodType)/totalFoodToProduce
wsTrace(self + " " + foodType + "=" + foodTypeChance[i] + " chance";)
i += 1

This results in outright wrong chance values. Moreover, the values may easily get over 1 (i.e. 100%). The rest of the function performs a number of random rolls (one for each food item to prodiuce) and compares the roll values with the borked chance values in the array to decide which food type to produce.

The result of this procedure (because it is using bogus chance values) is that the chance for actual production is proportionally higher for food types that are at lower array positions. Since the food types have been filled into the array alphabetically, this means that you're easily drowning in corn and carrots while you rarely have a surplus on tatos. Even Abernathy farm in vanilla conditions (i.e. no new crops planted) will produce significantly more melons than tatos.