Guide/Settlement Building Limitations

Last updated for version `1.8.0-BETA-7`

*Main article:* Settlement
This article is a Work-in-progressWIP and a simplified version of the article from Understanding CTDs in The Triangle of Death (Sanctuary, Abernathy Farm, and Red Rocket) by snarkywriter to illustrate the impact of Horizon in terms of performance to Vanilla Fo4.

## Preface

Essentially, the article tries to show the technical background associated with parts of the Creation Engine and its connection to settlement building and to educate the player about avoiding script lag and performance tuning. All of this inevitably leads to a better Horizon experience. To understand why the performance is influenced, especially when building settlements, you have to understand how the engine works.

## Engine

The following are key factors that influence script lag and define the engine to some point:

### Triangle Rasterization

The game is rendered in triangles (real-time) and the amount depends on software and hardware, time and place. Occlusion planes can be and are used to intelligently coordinate the rendering to make up, circumvent some of the restrictions given by the system itself.

### Settler Population

The more settlers the more scripts. At a certain course (progress) in-game settlers will cause script lag (time/space).

### Rendering

The game consists of cells. Rendering those cells is done:

* `uGrids to Load`, by default 5 cells = 5x5 wide, fully **rendered** around the character.
* `uExterior Cell Buffer`, by default 36 cells wide, is a **pre-rendered** area.

Every time you move (the faster the worse) the area shifts and depending on the amount of scripts this can lead to a CTD. Therefore densely lined up settlements are critical because here the pre-rendered area with the amount of settlers, among other things, reaches its limits quite fast and can K.O. itself, though most of the time it causes script lag. Here, too, the more the game progresses, the stronger the lag, as more scripts have to be computed.

The pre-rendered area also determines whether a building is powered or not or, in a very simple way, the settlement statistics itself, like water, defense, power rating, all can suffer from it, resulting in 0 defense in your pip-boy = **Display Bug**. So buildings (settlement objects) which count towards settlement ratings consequently lead to the ratings and thus statistic being influenced. Since happiness is based on many ratings, happiness is the most affected.

Both `.ini` settings can be found in the `Fallout4Custom.ini`:

```
[General]
uGridsToLoad          = 5
uExterior Cell Buffer = 36

```

❗ Never edit the `uGridsToLoad` and `uExterior Cell Buffer`.

### Precombined Meshes / Previsualization Data

Both are strongly compressed and whenever you destroy this pre-compression e.g. with Scrap Everything or other mods which scrap objects, then the compression disappears and the game has to re-render everything by itself (One of the reasons why Horizon uses the Scrap Cleanup Station). That takes computing power and performance suffers as a result, with more gaming progress it gets even worse globally: the game staggers! Guide: Fallout 4 Optimization and Performance Systems Explained

This raises the question of whether navmeshes also have a negative impact on performance. As soon as these are removed, the NPC/AI must take over the navigation itself and can no longer fall back on templates. Therefore avoid using scrapall console command, as well as scrapping mods, which can destroy navmeshes. Navmesh exist to keep performance high.[*citation needed*]

### WorkshopParentScript

The core script of the settlement system in Fallout 4 can also be knocked out by exceeding a certain number of scripted objects (between all of your settlements) like settlers, turrets, beds, radios, everything that produces resources, etc. Solution:

* never exceed 21 settlers/settlement, *better go down to 15 settlers instead*,
* minimize scripted settlement objects, *use the new architect buildings and foundations*.

📝 **Note:** That is one of the reasons why the documentation of 1.9 will forego the Workshop Population perk and replace it by the Workshop Construction perk.[*citation needed*]

### Creation Engine & Papyrus VM

All sub-system are synchronized by the engine within a given frame rate. 60FPS on PC and 30FPS on consoles. Papyrus VM is 100% affected by your FPS. Uncapping FPS is a very bad idea (see below)!

```
60FPS  = 1 frame per 16.67ms
30FPS  = 1 frame per 33.34ms
144FPS = 1 frame per 6.9ms

```

📝 **Note:** Many players believe more is better, but more FPS here is exactly the opposite. With more FPS (60+) the game becomes faster and paradoxically the game "loses time" that it otherwise would have had between the end of the Papyrus script (1.2 - 2.4 ms, depending on `.ini` setting, details see below) and the end of the frame.

### Papyrus VM Script

Papyrus VM is always following its protocol until:

1. the script completes or
2. the game/PC/Console runs out of available memory (!)

The script does not skip the script, it can get overloaded, thus eating up memory and can cause lag as a result. Bruteforcing the script is possible with diminishing returns, more computing power means less computing possibilities because of the limitation of the engine itself. Since Papyrus VM runs until it is finished, under certain circumstances (too many scripts to be ended) this can lead to the game crashing. Overloading itself is not a problem but more overload means less script because a script is locked until it's done and if the script needs more than 1.2 ms then it is transferred to the next frame, etc.

📝 **Note:** Stretching the time to 2.4 ms via `.ini` settings means more time per script/frame and thus the probability that a script has to be processed in the next frame decreases and thus the script lag decreases. With higher FPS the game gets confused at some point, scripts run when they shouldn't, NPC's move faster, animations run faster, etc. Uncapping frames is not intended, the game is built on a "compromise" around the current engine and runs perfectly fine at 60/30FPS (depending on your computing device). If you uncap FPS the game is destabilized and you run accelerated, most likely, into a CTD at some point.

### Timescale

The default value for Timescale is 20. Changing that value beyond 20 will cause the same effect (CTD) very fast too. *Decreasing timescale is questionable here, one of the reasons why Horizon uses Timescale 10 is possibly to counteract the problem that goes along with time*[*citation needed*]. The Papryus VM system is built around time and changing time has more bad consequences than good. Since the game is very fragile in terms of time, you always drag the prerendering cells with you and only when the game has discarded the prerendering does a rendering process begin that actually is in *harmony* with the user's current task.

## INI Tweaking

In order to properly enter the data into the system, an entry in the `Fallout4Custom.ini` is required.

`📁...\Documents\My Games\Fallout 4`
### Default

Papyrus VM is a multi-threaded scripting language and anything that can speed up the calculation of the script and at the same time does not break the hardware is advisable. The default number of ms/frame Papyrus VM gets to work, is 1.2 ms:

```
[Papyrus]
fUpdateBudgetMS          = 1.2 (ms)
fExtraTaskletBudgetMS    = 1.2 (ms)
iMinMemoryPageSize       = 128 (128 bytes)
iMaxMemoryPageSize       = 512 (512 bytes)
iMaxAllocatedMemoryBytes = 153600 (156 kilobytes)

```

### Tweaked

It is advisable to double the numbers in order to guarantee absolute performance (the content in brackets must not be copied):

```
[Papyrus]
fUpdateBudgetMS          = 2.4 (ms)
fExtraTaskletBudgetMS    = 2.4 (ms)
iMinMemoryPageSize       = 256 (256 bytes)
iMaxMemoryPageSize       = 1024 (1024 bytes)
iMaxAllocatedMemoryBytes = 307200 (312 kilobytes)

```

Runtime per script is now 2.4 ms/frame (Remember: @60FPS = 1 frame per 16.67 ms). Again, more FPS doesn't mean more computing power, it means the rest of the game's systems only have X ms/frame left to perform all other functions the game needs to operate.

## Summary

* It is better to avoid building in settlements that are close to each other at the same time and it is even better to only build in one settlement. These two triangles below show a worst case scenario: the so called *Triangle of Death*:
	+ Sanctuary Hills, Abernathy Farm and Red Rocket Truck Station
	+ Warwick Homestead, Spectacle Island and The Castle
	+ 📝 **Note:** Triangles are very influential, but two settlements such as: Covenant and Taffington Boathouse can cause problems too.
* A settlement with borders within 5 cells
	+ that interfere with a commonly used player path can lead to a: Resource Display Bug (Settlement statistics don't pop-up properly; no defense, water, power, etc. shown).
	+ interfering with other settlements can lead to "rendering and script based issues/CTDs".
* Rushing into a Settlement and instantly opening the Workshop also heavily influences script. It is said to: walk to the center of a settlement and wait a few minutes to circumvent problems. *What very few players probably do*.
* When building, try to skip objects tied to scripts, use Horizon's Foundations, Buildings and keep Settler Population very low (<15 settlers).
	+ try to work with the Tenants system and whenever you can push production with Leased Utility buildings.
	+ try to limit yourself with power buildings and everything attached to power pylons (Power connections can be buggy in FO4), better use the new Architect Platform Turrets instead these are not tied to power.
* Avoid any scrapping mod, and avoid the `scrapall` console command it can break quest markers and delete navmesh (destroy settler pathing). Its for game development not a game feature, use the Scrap Cleanup Station to scrap settlement objects. It is safe and created exactly because of the points mentioned in this article.
* Enhanced Settlements can cause problems because of expanded settlement borders, though not across all settlements! *In what terms it influences precombined meshes to the bad is unclear*.
* Avoid changes to Timescale beyond 20, use the Timescale add-on which changes the value down to 10 (part of Horizon's installation).
* Don't uncap FPS, cap at 60 FPS on PC and 30 FPS on consoles.
* Don't run to many programs in background.
* Optimise your Load Order and limit yourself on mods (especially script heavy mods, altering AI and settlements objects), the absolute amount of mods also has a significant impact on performance.
* Don't change your `.ini` files to decrease performance (does look good can cause does work bad, does work bad can cause CTD).

## See Also

* Guide/INI Setting
* Guide/Launcher Options Menu
* Papyrus Anti-Patterns

## References

1. ↑ https://simsettlements.com/site/index.php?threads/understanding-ctds-in-the-triangle-of-death-sanctuary-abernathy-farm-and-red-rocket.6964/
2. ↑ 2.0 2.1 https://www.reddit.com/r/fo4/comments/54qcnt/fallout\_4s\_settlement\_resources\_bug\_collection\_of/
3. ↑ https://steamcommunity.com/app/377160/discussions/0/350542683201000263#c350542683201083726
4. ↑ https://bethesda.net/community/topic/86381/understanding-precombines-previs-and-why-mods-that-disable-them-can-cripple-game-performance?language%5B%5D=en
5. ↑ https://www.creationkit.com/fallout4/index.php?title=Papyrus\_FAQs
6. ↑ https://discord.com/channels/436824471295361025/559888073924542464/701953063073742999
7. ↑ https://discord.com/channels/436824471295361025/436840996517707777/933083951923363882
8. ↑ https://discord.com/channels/436824471295361025/436824471295361027/914380840102936646
9. ↑ https://discord.com/channels/436824471295361025/436840996517707777/933084950704566344