Introduction
This article will cover the principle of this resource to inform mod authors loosely on how it works and then how to use it. The aim of this resource is to tidy up the order in the weapon and amrour workbench for mod added attach point keywords. Hopefully this is clear and understandable, if it isn't please leave a comment on which part needs to be explained better or differently. I will sort out armor related keywords in the near future.
Process
The order in which mod categories are listed within the weapon or armour workbench is based on the order of the attach point keyword within the formlist: do_ModMenuSlotKeywordList. Horizon adds a number of attach point keywords to the formlist directly through overwriting the data in the plugin record. That's why you have a nice neat order for ammo, fire mode, augment and the receiver upgrades when modding Horizon weapons.
Mod added weapons and armours cannot overwrite the data in the plugin record because of the last loaded wins rule when using multiple modded weapons. It is possible via script to add new keywords to the formlist but you cannot choose where to inject, the scripted added keyword(s) would always be at the bottom.
This resource overcomes this limitation by overwriting the do_ModMenuSlotKeywordList formlist to remove the Horizon (and vanilla) attach point keywords and re-adding them via script. However, before adding them in by script the manager quest within the s99_Horizon_ModAPKewordManager.espwaits for any mod patches with a quest using the ModKWAdder_TEMPLATE to add their attach point keywords to a cache array.
The manager quest then reorders the cache based on the priority number associated with that attach point keyword. With the cache organised in priority order it then adds those keywords into the do_ModMenuSlotKeywordList formlist. The Fig.1 is a screenshot of the debug code showing the result of the reordered keywords being added to the formlist. Where keywords have the same priority is not an issue as those are for different weapons and would not appear in the workbench at the same time. You will notice that the condition attach point and receiver attach points are missing from Fig.1, this is intentional as those keywords are left in the formlist record so that they are always at the top of the workbench menu list.

Fig.1 - An example of keywords being ordered in the formlist
For this system to work there can only be one instance of the manager quest, you'll need to direct your users to download the file from this
page. However, there is no need for your patch plugin to have the s99_Horizon_ModAPKewordManager.esp as a master and if the user doesn't download the manager file the adder script is designed to stop and lie dormant. This link is direct to the file to save users from downloading the wrong thing: Mod Attach Point Keyword Manager.
How to setup and use in a patch
Hopefully this is rather simple. Download the ModAPKeyword manager from this page and install via Vortex or MO2. It needs to be placed below Horizon.esp but above any patches. Find the ModKWAdder_TEMPLATE quest (Fig.2), right-click and copy as new record into your patch. Replace TEMPLATE with the name of your patch for example ModKWAdder_ServiceRifle. Do not touch the manager quest or formlist.

Fig.2 - ModKWAdder_TEMPLATE quest
Expand the properties and you'll see the struct. A dummy entry is in there by default, you can right-click next to 'Array of Struct' to add additional keywords. The struct consists of two elements apKW must point to the attach point keyword you wish to add and pri is an integer that will determine the position of the keyword in the do_ModMenuSlotKeywordList formlist. Fig.3 shows the expanded example struct.

Fig.3 - Expanded template struct.
Set the priority in relation to the other attach points within the mod and also the Horizon and Vanilla keywords, for reference Fig.4 shows the priorities associated with those keywords. For example if your modded weapon has an attach point that you want to appear between the magazine slot and muzzle slot give your keyword a priority between 276 and 299.


Fig.4 - Horizon and Vanilla keyword priority values (weapons left and armours right. Item lock is below them all).
Keep adding new structs and assigning priority values until your attach point keywords until you're done. Finally ensure you right-click Flags under DNAM-General and set the quest to Start Game Enabled and Starts Enabled, Fig.5 shows an example.

Fig.5 - Quest flags set.
In Game
At every game load the player will get two notifications relating to the process. Attempting to use a workbench before receiving the COMPLETE message will show attach point keywords in the wrong order. Exiting the workbench and waiting for the notification is sufficient to then use the workbench with the arranged mod categories. Fig.6 shows the notifications. If after a prolonged period of time (in excess of 20 seconds) the COMPLETE message does not show something has gone wrong and I'll need to see the papyrus log to understand where the code failed.

Fig.6 - Notification messages.
0 comments