Merging two mods

Introduction
This is a tutorial on combining two mods which alter the same files. We’ll be merging two basebuilding mods as an example: Star Trek Player Flags and Ultra Base Building.

Tools used:


 * PSArcTool:         https://github.com/periander/PSArcTool
 * Notepad++:        https://notepad-plus-plus.org/downloads
 * MBINCompiler:   https://github.com/monkeyman192/MBINCompiler

There are 4 steps involved:


 * 1)     Unpacking and decompiling the files.
 * 2)     Editing DEFAULTSAVEDATA, DEFAULTSAVEDATACREATIVE, BASEBUILDINGTABLE, NMS_REALITY_GCPRODUCTTABLE.
 * 3)   C  ompiling the files.
 * 4)     Repacking the files.

1. Unpacking & decompiling
Create a working folder (C:\Merge UltraBase-Star Trek Flags).

Your folder will now look like this:
 * Copy MBINCompiler and PSArcTool to this folder. Unzip the mods also into this folder.
 * First unpack zz-UltraBaseBuilding.pak by dragging over PSArcTool.
 * Rename METADATA to METADATA2.
 * Now unpack _MOD.ST.PlayerFlagsFull.pak
 * Delete the two .pak files, you don’t need them anymore.




 * Copy MBINCompiler.exe + .libMBIN.dll to METADATA\REALITY\TABLES   and METADATA2\REALITY\TABLES
 * Decompile all .MBINs by dragging them on MBINCompiler.exe

2. Editing
Open BASEBUILDINGTABLE.EXML from both mods in Notepad++. They are shown in 2 tabs for easy copying.

Now locate "TREKFLAG1”:                                                              </Property>               </Property>   </Property>       </Property>       <Property name="BuildableAboveWater" value="True" /> <Property name="GlobalLimit" value="0" /> <Property name="SystemLimit" value="0" /> <Property name="PlanetLimit" value="0" /> <Property name="RegionLimit" value="0" /> <Property name="PlanetBaseLimit" value="0" /> <Property name="FreighterBaseLimit" value="0" /> <Property name="CheckPlaceholderCollision" value="True" /> <Property name="CollisionScale" value="0.75" /> <Property name="EnableCollision" value="True" /> <Property name="CanPlaceOnItself" value="True" /> <Property name="CanRotate3D" value="True" /> <Property name="CanScale" value="True" /> <Property name="Groups"> <Property value="NMSString0x10.xml"> <Property name="Value" value="ADDIT" /> </Property> </Property> <Property name="StorageContainerIndex" value="-1" /> <Property name="CanChangeColour" value="True" /> <Property name="CanChangeMaterial" value="True" /> <Property name="CanPickUp" value="True" /> <Property name="ScanRadius" value="0" /> <Property name="RemovesAttachedDecoration" value="True" /> <Property name="EditsTerrain" value="False" /> <Property name="BaseTerrainEditShape" value="Cube" /> <Property name="TerrainEditBaseYOffset" value="0" /> <Property name="TerrainEditTopYOffset" value="0" /> <Property name="TerrainEditBoundsScalar" value="1" /> <Property name="IsSealed" value="False" /> <Property name="CloseMenuAfterBuild" value="False" /> <Property name="LinkGridData" value="GcBaseLinkGridData.xml"> <Property name="Connection" value="GcBaseLinkGridConnectionData.xml"> <Property name="Network" value="GcLinkNetworkTypes.xml"> <Property name="LinkNetworkType" value="Power" /> </Property> <Property name="NetworkSubGroup" value="0" /> <Property name="NetworkMask" value="0" /> <Property name="ConnectionDistance" value="0.1" /> <Property name="UseMinDistance" value="False" /> <Property name="LinkSocketPositions" /> <Property name="LinkSocketSubGroups" /> </Property> <Property name="Rate" value="0" /> <Property name="Storage" value="0" /> <Property name="DependsOnEnvironment" value="None" /> <Property name="DependsOnHotspots" value="None" /> <Property name="DependentConnections" /> </Property> <Property name="GhostsCountOverride" value="0" /> <Property name="SnappingDistanceOverride" value="0" /> <Property name="RegionSpawnLOD" value="1" /> </Property>

Select this whole GcBaseBuildingEntry section. Copy this to the other mod’s BASEBUILDINGTABLE.EXML, right below <Property name="Objects"> Repeat this for the other flags. Save.

Next, locate “Star Trek Flags A”: <Property value="GcBaseBuildingGroup.xml"> <Property name="ID" value="ADDIT" /> <Property name="ParentGroup" value="DECORATION" /> <Property name="Name" value="Star Trek Flags A" /> <Property name="Icon" value="TkTextureResource.xml"> <Property name="Filename" value="TEXTURES/UI/FRONTEND/ICONS/BUILDABLE/GROUPS/BUILDGROUP.STFLAGS.DDS" /> </Property> <Property name="DefaultColourIdx" value="0" /> <Property name="DefaultItem" value="" /> </Property> <Property value="GcBaseBuildingGroup.xml"> <Property name="ID" value="ADDIT2" /> <Property name="ParentGroup" value="DECORATION" /> <Property name="Name" value="Star Trek Flags B" /> <Property name="Icon" value="TkTextureResource.xml"> <Property name="Filename" value="TEXTURES/UI/FRONTEND/ICONS/BUILDABLE/GROUPS/BUILDGROUP.STFLAGS2.DDS" /> </Property> <Property name="DefaultColourIdx" value="0" /> <Property name="DefaultItem" value="" /> </Property>

Select this section and copy it into the other mod’s BASEBUILDINGTABLE.EXML. Save. You’re done with this file.

Open NMS_REALITY_GCPRODUCTTABLE.EXML from both mods in Notepad++. Locate TREKFLAG1: <Property value="GcProductData.xml"> <Property name="Id" value="TREKFLAG1" /> <Property name="Name" value="ANDORIA" /> <Property name="NameLower" value="Andoria" /> <Property name="Subtitle" value="VariableSizeString.xml"> <Property name="Value" value="Andoria" /> </Property> <Property name="Description" value="VariableSizeString.xml"> <Property name="Value" value="The Andorian Mining Consortium runs from no one." />     </Property> <Property name="Hint" value="" /> <Property name="GroupID" value="" /> <Property name="DebrisFile" value="TkModelResource.xml"> <Property name="Filename" value="MODELS/EFFECTS/DEBRIS/TERRAINDEBRIS/TERRAINDEBRIS4.SCENE.MBIN" /> </Property> <Property name="BaseValue" value="1" /> <Property name="Level" value="0" /> <Property name="Icon" value="TkModelResource.xml"> <Property name="Filename" value="TEXTURES/UI/FRONTEND/ICONS/BUILDABLE/DECORATION.STFLAG1.DDS" /> </Property> <Property name="HeroIcon" value="TkModelResource.xml"> <Property name="Filename" value="" /> </Property> <Property name="Colour" value="Colour.xml"> <Property name="R" value="0.172549" /> <Property name="G" value="0.4862745" /> <Property name="B" value="0.6235294" /> <Property name="A" value="1" /> </Property> <Property name="SubstanceCategory" value="GcRealitySubstanceCategory.xml"> <Property name="SubstanceCategory" value="BuildingPart" /> </Property> <Property name="Type" value="GcProductCategory.xml"> <Property name="ProductCategory" value="BuildingPart" /> </Property> <Property name="Rarity" value="GcRarity.xml"> <Property name="Rarity" value="Common" /> </Property> <Property name="Legality" value="GcLegality.xml"> <Property name="Legality" value="Legal" /> </Property> <Property name="Consumable" value="False" /> <Property name="ChargeValue" value="0" /> <Property name="StackMultiplier" value="0" /> <Property name="DefaultCraftAmount" value="1" /> <Property name="CraftAmountStepSize" value="1" /> <Property name="CraftAmountMultiplier" value="1" /> <Property name="Requirements"> <Property value="GcTechnologyRequirement.xml"> <Property name="ID" value="LAND2" /> <Property name="InventoryType" value="GcInventoryType.xml"> <Property name="InventoryType" value="Substance" /> </Property> <Property name="Amount" value="5" /> </Property> <Property value="GcTechnologyRequirement.xml"> <Property name="ID" value="FUEL1" /> <Property name="InventoryType" value="GcInventoryType.xml"> <Property name="InventoryType" value="Substance" /> </Property> <Property name="Amount" value="5" /> </Property> </Property> <Property name="AltRequirements" /> <Property name="Cost" value="GcItemPriceModifiers.xml"> <Property name="SpaceStationMarkup" value="0" /> <Property name="LowPriceMod" value="0" /> <Property name="HighPriceMod" value="0" /> <Property name="BuyBaseMarkup" value="0" /> <Property name="BuyMarkupMod" value="0" /> </Property> <Property name="RecipeCost" value="1" /> <Property name="SpecificChargeOnly" value="False" /> <Property name="NormalisedValueOnWorld" value="0" /> <Property name="NormalisedValueOffWorld" value="0" /> <Property name="TradeCategory" value="GcTradeCategory.xml"> <Property name="TradingClass" value="None" /> </Property> <Property name="WikiCategory" value="Construction" /> <Property name="IsCraftable" value="True" /> <Property name="DeploysInto" value="" /> <Property name="EconomyInfluenceMultiplier" value="0" /> <Property name="PinObjeective" value="" /> <Property name="PinObjeectiveTip" value="" /> <Property name="CookingIngredient" value="False" /> <Property name="CookingValue" value="0" /> </Property>

Select this whole GcProductData.xml section and paste this into the other mod’s NMS_REALITY_GCPRODUCTTABLE.EXML. Do this for all the flags. Save. You’re done with this file.

Open DEFAULTSAVEDATA.EXML for both mods. Locate "KnownProducts": <Property value="NMSString0x10.xml"> <Property name="Value" value="TREKFLAG1" /> </Property> Copy this section for all 40 flags to the other mod's DEFAULTSAVEDATA.EXML. Save. Repeat this for the file DEFAULTSAVEDATACREATIVE.EXML.

3. Compiling

 * Delete METADATA
 * Rename METADATA2 to METADATA
 * Drag all .EXML files over MBINCompiler.exe. You'll get new .MBINs.
 * Delete or move all .EXML files.
 * Delete libMBIN.dll, MBINCompiler.exe, MBINCompiler.log from all folders.

4. Packing
Select and drag all folders + files over PSArcTool.exe. You now have a psarc.pak, give it a proper name and copy it to the NMS mod folder.