- Status Fix Pending
- Task Type Bug Report
- Category Papyrus
- Operating System All
- Severity Low
- Priority Medium
- Reported Version Fallout 4: Vanilla
- Due in Version Undecided
FS#22189 - FollowersScript - Issue with handling of SAS triggers and SAE clutter triggers
SAS triggers and SAE clutter triggers are used to toggle location and encounter specific follower dialogue. Whenever the player enters or leaves one of those triggers, the events that fire on the trigger scripts call the HandleMessageFromSASTrigger/HandleMessageFromSAEClutterTrigger functions on FollowersScript for further processing.
At some point in my game, this stopped working entirely. There were no comments from followers anymore and said functions threw ‘none’ errors on the papyrus log.
What the functions do is to add the trigger’s ref to a formlist when the player enters a trigger and to remove it when he leaves. It then checks whether the list is empty, and if not, gets the trigger from the first list position, reads a specific keyword from the trigger script and conditions the follower dialogue accodingly.
Debugging has shown that the first entry in the list was ‘none’ when the functions had stopped working. This is actually surprising because one cannot add a ‘none’ to a formlist (neither in the CK nor via script commands). It is not entirely unknown behavior though: this issue is already known from Skyrim papyrus, and it is a side effect of storing references in a formlist (NB: storing references in a formlist is generally not a good idea; arrays should be used instead). When the player leaves the cell in which the reference is persistent, the entry stored in a formlist will turn into a ‘none’, and it turns back into the valid ref if the player returns to that cell (presumably, Beth implemented it in that way to prevent references from becoming persistent if they are stored in a formlist).
Thus, what probably happened here is that the OnTriggerLeave event was processed with some delay and the reference was already ‘none’ when FollowersScript was called, so it couldn’t find it when it was told to remove it from the formlist. This should be relatively likely to occur when fast travelling while standing inside one of those triggers. Anyway, if it happens, the functions on FollowersScript will stop working forever. This is because the vanilla script does not expect that there may be a ‘none’ in the formlists, and it has no code to handle this.
To fix this, I added loops to both functions that run through the lists to find the first entry that is not ‘none’ (instead of always trying to process the first entry, irrespective of whether it was valid or not, as the vanilla script did it). Also, the script will now consider the lists as empty if they only contain ‘none’ entries.