Welcome to the AFK Mods bug tracker. In order to report an issue, you need to have a VALIDATED account to post one. Once you have followed the link the registration email sent you, 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.

Please also consider sending your bug report to Bethesda if you are reporting on an issue with Skyrim Special Edition, Fallout 4, or Starfield. Doing so will help everyone on all platforms.

Issue Data
Status: New
Issue Type: Bug Report
Project: Unofficial Fallout 4 Patch
Component: Unofficial Fallout 4 Patch
Category: Settlements & Workshops
Assigned To: Nobody
Platform: Windows PC
Severity: Medium
Votes: 0
Watching: N/A
Opened By Glitchfinder on Oct 1, 2024 4:10 pm

Issue #34401: Workshop beds cannot be unassigned in specific circumstances

 
The unofficial patch makes several fixes to the various workshop scripts, but one of them in particular prevents settlers from being unassigned from a bed unless there is at least one settler with no bed in that settlement. Currently, the code block for bed unassignment looks like this:
            if UFO4P_ActorsWithoutBeds && UFO4P_ActorsWithoutBeds.Find (assignedActor) < 0
                ObjectReference[] WorkshopBeds = GetBeds (workshopRef)
                                wsTrace("        Bed - " + WorkshopBeds.Length + "beds found";)
                int countBeds = WorkshopBeds.Length
                bool ExitLoop = false
                int i = 0
                while i < countBeds && ExitLoop == false
                                        wsTrace("        Bed - Testing bed number " + i)
                    WorkshopObjectScript theBed = WorkshopBeds[i] as WorkshopObjectScript
                    if theBed && theBed.GetActorRefOwner() == assignedActor
                                                wsTrace("        Bed - Previously owned bed identified";)
                        theBed.AssignActor (none)
                        UFO4P_AddUnassignedBedToArray (theBed)
                        ExitLoop = true
                    endif
                    i += 1
                endWhile
            endif

In order to resolve the issue, the if statement at the start of that code block should be modified to something along these lines:
if UFO4P_ActorsWithoutBeds == None || UFO4P_ActorsWithoutBeds.Find (assignedActor) < 0

From my discussion in Discord with Sclerocephalus, this is also a functional alternative:
if UFO4P_ActorsWithoutBeds && UFO4P_ActorsWithoutBeds.Find (assignedActor) >= 0
;do nothing
else
...

Comments

3 comment(s)
Theyren said:
 
I would be interested to try this since I've noticed this issue (and other issues with bed assignments, like settler keeping old bed assignment when you assign them to a new bed, which is annoying), would it be possible you could package it into a mod? Or I can look into applying this patch myself

Glitchfinder said:
 
I'm not currently set up to recompile this script or share it, but I do think the issue you mentioned is the same issue, because this code block is the part that handles removing a bed assignment from a settler. The resulting behavior is that when the bug occurs, the settler is assigned to the new bed, keeps the old bed, and is then removed from one of the beds the next time you leave the area and return.

Sclerocephalus said:
 
@Theyren:

This issue is actually a result of how the engine handles empty (zero-length) arrays: they are turned into 'none' arrays upon saving and reloading. Technically though, there is a difference between a 'none' array and a zero-length array: the latter is initialized while the former is not. If all settlers have beds assigned [This is always the case when the bed count is equal to or larger than the settler count, irrespective of whether you assign the settlers to beds yourself or not. If you don't, the workshop scripts do it automatically.], the UFO4P_ActorsWithoutBeds array will be a zero-length array. Like all helper arrays, it is built by ResetWorkshop(), i.e. when your workshop loads. Thus, if you save and reload while at a workshop (or reload an older save with all settlers assigned to beds), the array becomes a 'none' array, and the re-assignment breaks. It only breaks in these specific conditions.

You can easily work around this issue by scrapping a bed (leaving one settler unassigned and forcing the script to re-built the helper array). Then build a new bed, which gets instantly assigned by the scripts to the settler whose bed was scrapped. Thus, bed counts and assignments are the same as before, but the helper array is now a zero-length array again, and the reassignment bug is gone (until you reload again, that is).

The only other known issue that leads to old beds becoming unassignable is single actor ownership defined for the respective beds in the game's master files or in a plugin. To assign a bed to a settler, the scripts make the bed owned by that settler; to unassign a bed, they clear ownership. Though, ownership defined in a plugin cannot be altered by papyrus scripts. This issue has been fixed years ago by removing ownership from all pre-placed beds (beds built at run-time obviously aren't affected by this bug). If the bug still occurs in your game with UFO4P installed, you have a mod conflict. Potential culprits are mods that make the pre-placed beds scrappable, since they modify the individual beds (i.e. the placed refs: these records also contain the ownership data).

Comment #3 Oct 4, 2024 6:28 pm  Edited by Sclerocephalus on Oct 4, 2024 6:30 pm
Showing Comments 1 - 3 of 3