Modular Design - jackeys/Power-Armor-to-the-People GitHub Wiki

Power Armor to the People is modular by design, meaning that parts of it can be taken or left out depending on what the user wants. This poses a challenge, as there are many things cannot be counted on to exist from one user to another. To achieve the main vision of integrating power armor mods into the world without requiring that every user use every power armor mod, Power Armor to the People is made up of a core module and some scripts, plus a large number of optional patches.

The core Power Armor to the People module, Power Armor to the People.esp, is designed to support all of these patches. Essentially, this works by following a simple principle: features should be supported within the core module with support for injection from other patches. By putting the features in the core (e.g. providing power armor to Gunners), every patch is able to take advantage of them. By using script-based injection, any number of patches, loaded in any order, will work. Not all of these features are actually used in the core module, but by putting them in a central location, all patches can rely on their existence.

Script Injection and Upgrades

The scripts that come with Power Armor to the People should be used for injection because they include special hooks to allow for changes to configuration and upgrades. Any time a configuration value that affects injected lists is changed, or if the upgrade manager within the mod is set to a higher version in a subsequent release, all of the leveled lists that were injected into within Power Armor to the People get reverted and an event is emitted telling all of the injection scripts to inject again. This allows for greater flexibility across releases, including the removal of injected items and the addition of new ones without adding new quests. This is essential to allow for this mod to grow and change over time because its modularity requires script injection.

Power Armor Sets

The changes required to give power armor to enemies are included in the core, with leveled lists set up to include power armor sets from the base game. Each patch then uses script injection (PAttP:InjectItemIntoPAttPLeveledList) to add items to these lists.

Excavator Power Armor Mixed Sets

The Raider enhancement for Excavator Power Armor only works with certain types of power armor without clipping. To allow for sets of mixed power armor to be used by Raiders, the leveled lists for every piece that can go with the Raider version of the Excavator Power Armor are in the core module. Each patch then uses script injection (PAttP:InjectItemIntoPAttPLeveledList) to add items to these lists. If a user does not have the Excavator Power Armor patch installed, these lists won't get used, but this method means that none of the other patches have to care whether the Excavator Power Armor patch is installed or not.

Vendors

The core Power Armor to the People module injects a few leveled lists into appropriate vendor inventories (using PAttP:InjectItemIntoExternalLeveledList). These injections are never automatically reverted. Other patches can then inject into these leveled lists (using PAttP:InjectItemIntoPAttPLeveledList), enabling re-injection after an update or configuration change without reverting the vendor lists in the base game. This provides flexibility without causing issues for other mods that inject items into vendor inventories.

Legendary Power Armor Tiers

Legendary power armor drops are split into tiers based on the zone level to make drops feel relevant as the player progresses through the game. Since the levels that power armor are available can vary depending on which power armor sets have been patched in, the tier that a power armor piece should fall into is automatically determined by the injection script (PAttP:InjectLegendaryPowerArmor). A new tier occurs every 7 levels, following the pattern used in the base game's progression. The drop rates for these tiers can then be balanced in a leveled list in the core module.

Legendary Naming

Legendary naming rules exist both for the base game and for Far Harbor's new effects, but the patches for each of the power armor sets do not require Far Harbor. This is achieved by creating new keywords for all of Far Harbor's legendary effects within the core module, which are then used for legendary naming rules in all of the patches. The Far Harbor patch then adds these keywords in addition to the default ones to the legendary mods from Far Harbor, which allows these names to be applied.

This approach does not work well with other mods that add legendary effects, however, as it would require changes to Power Armor to the People and every power armor patch whenever a new mod should be supported. Instead, each power armor patch can register using a script (PAttP:LegendaryNamingRuleListener) to find out when an external mod has added new naming rules so they can be merged into the naming rules for that particular power armor set.

For more details on how an external mod can use this mechanism, see Integrating Other Mods.

Power Armor Paint Jobs

Gunners have painted power armor that can be augmented with additional patches. This is achieved using mod collections (OMOD with the Mod Collection flag) and using that as the paint mod on the power armor instead of a specific paint. This prevents conflicts from multiple patches trying to alter the armor records.

The Gunners paint jobs are based on lining level, so there is a different mod collection for each lining B-E for each set of power armor. The mod collection for Lining B contains only the default paint job, and the mod collections for Linings C-E all refer to the mod collection for Lining B by default. This means that the default causes every paint job to be the same, but by overriding the individual mod collections, new paint jobs can be added.

Specifically, one patch overrides the mod collection for Lining B to change the default paint job, and another patch changes the mod collections for Linings C-E to use the three Creation Club Gunner paint jobs. If only the patch for Lining B is used, then all of the paints change to the new default because Linings C-E refer back to that mod collection. If only the Creation Club patch is used, then the standard default is still used for Lining B and the new paints apply to Linings C-E. If both are used together, then Lining B gets the new default and Linings C-E keep the new paints from Creation Club. Note that this method has a limit to how many paint jobs it can support, as only one paint job can be used for each lining. However, more can be supported by adding more instantiation filters and object templates.

A copy of the power armor entries was made for the painted power armor the Gunners wear to ensure that these mod collections and linings could be used without conflicts or the possibility of the wrong paints showing up for the Gunners or other NPCs. Critically, doing this requires that the constructible objects used to repair the original power armor are also copied and pointed at the new copies to allow a player to repair them.

Advanced Power Armor Mod Compatibility

This same concept can be expanded to provide additional compatibility for mods that change the keywords and/or attach points for a set of power armor as well, such as the Overboss Power Armor Constructible No Chain Mesh mod. Similar to the situation with paint, a copy of the power armor records (and the corresponding constructible objects for repairing them) was made. Then, a new attach point was added to each piece of the power armor to host a compatibility OMOD. That new OMOD was added to every object template for the copied power armor, then overridden in the No Chain patches to include the Parent Attach Points and Keywords that the No Chain mod adds to the original Overboss power armor. Finally, using the same approach as paints, a Mod Collection was created and added to the object templates which was overridden by the No Chains patches to use the real OMOD and attach point from the No Chains mod.

By using these two methods together, the Overboss power armor was able to have both additional paint jobs and alternate meshes without any need to worry about load order or additional patching between the combinations of mods that provided each change.

Supporting Other Weapon Mods

Most of the power armored enemies use standard weapon lists from the base game, corresponding to the enemy type, which are common injection points for other mods to put their weapons. This means that many weapon mods will work by default. However, there are some custom weapon lists that may benefit from having weapons from other mods injected into them, and there are some weapon mods that don't inject into the leveled lists that might benefit from being available only to power armored enemies (such as the Creation Club Tesla Cannon and Heavy Incinerator). For these cases, a quest called PATTP_ListInjection_DetectWeapons exists, which uses a script to check for the plugins that contain these weapons and gets the appropriate weapon / leveled list form (with a leveled list being preferred when available) to inject into a Power Armor to the People leveled list. This uses the same injection management logic that allows for changes to the lists when there are updates, and also exposes configuration to allow players to enable or disable each weapon injection in MCM. The trade-off in allowing that, however, is that the script used is purpose-built: it must be modified whenever a new weapon is added instead of being reusable by passing in different property values.

Installer

Power Armor to the People uses a FOMOD installer to help users install the right patches for their modding setup. Taking advantage of FOMOD's ability to automatically detect active mods, the installer will automatically enable patches in the installation wizard if the corresponding mod is present.

Every power armor set, and prominent patches like Some Assembly Required or AWKCR, will also set a flag when they have been selected. These flags are then used by parts of the installer to decide if an additional page with more patches should be shown. For example, there are some patches that can only be used if you are using the X-03 power armor, so there is an installer page that is only shown if that flag has been set.

There are some conditional installations within the FOMOD based on the patches and power armor sets that are in use, such as choosing the right permutation of AWKCR/Some Assembly Required patch to apply, but critically, all of these conditional installations are based on flags that are set by checkboxes in the wizard. None of these are based solely on the presence of an active mod so that a user still has control over what should be installed.

Included Content

The published mod only contains the fomod and Content directories from the mod. As such, it is critical that the installer only ever make reference to these two directories. Images used in the installer should be included in the fomod directory, typically as 960x540 JPEGs with a quality rating of 7 to keep the file size down, and everything that can be installed with the mod should be included in the Content directory.

⚠️ **GitHub.com Fallback** ⚠️