# Modding Abiotic Factor Please contact Swept or LocalHyena on Discord if something in this guide is wrong or outdated. ## Useful Links - [Mappings File Download](https://github.com/SweptWasTaken/AbioticFactorMappings/releases/download/release1.0.0/Mappings_v1.0.0.usmap) - [UAsset GUI Starter Kit Download](https://discord.com/channels/1190637278222094436/1248409230713683989/1416884320496255017) - [UnrealPak Download](https://discord.com/channels/1190637278222094436/1248409230713683989/1416884323671343184) ## Basics ### Clarifications There are two ways to mod Abiotic Factor. **PAK Loading** involves using the Unreal editor to pack your own content files for the game that will load *after* the original game content files. This is commonly used to make simple asset-swap mods like for example the [Half-Life Audio Replacement mod](https://www.nexusmods.com/abioticfactor/mods/11). This method works well, but has a limit to it's functionality. Any asset defined in a pak will literally replace the asset, so if you have multiple pak mods that replace the same thing, you'll run into problems fast. **UE4SS** is a robust mod injector (among other things) for Unreal games. There is a purpose-built version for Abiotic Factor [here](https://www.nexusmods.com/abioticfactor/mods/35). Documentation for UE4SS will not be discussed in this guide, since it already has lots of documentation - but if you want to make complex modifications to Abiotic Factor or add new stuff to the game than this is your tool. ### Prereq - **Current** Abiotic Factor Mappings - This is required for FModel and other tools. Things will break if they're out of date. [This repository](https://github.com/SweptWasTaken/AbioticFactorMappings/releases/tag/release) should have the latest release of the mappings. - [FModel](https://fmodel.app/) - Consider downloading [BinkadecWithWavHeader](https://github.com/Keisawaakira/BinkadecWithWavHeader) for clean extraction of WAV files which is crucial for sound extracting/playback. - Linked [here](https://www.youtube.com/watch?v=yQrNur-a24o) is a video guide for converting UE5 binka files to WAV using FModel. - [Unreal Engine 5.4](https://www.unrealengine.com/en-US/download) - **NOTE:** This could maybe be replaced if someone finds a tool to properly make `pak`, `utoc` and `utac` files. There are already other pak tools online but none I could find made compatible patch files for Abiotic Factor. - [Windows SDK](https://download.microsoft.com/download/2/6/f/26f7aa55-ef6f-4882-b19b-a1be0e7328fe/KIT_BUNDLE_WINDOWSSDK_MEDIACREATION/winsdksetup.exe) - **Optional** [AbioticFactor-UnrealProject](https://github.com/HW12Dev/AbioticFactor-UnrealProject) - I used the Blueprint Mod tutorial on YouTube [here](https://www.youtube.com/watch?v=fB3yT85XhVA), but this premade Unreal Project could speed things up for you. ### FModel When you first open FModel, you'll be greeted by it attempting to detect a game. Simply click "Add Undetected Game" at the bottom, and enter **AbioticFactor** for the name, and the location of your Abiotic Factor steam install for the directory. **Make sure the UE version is specified as "GAME_UE5_4"** in the UE Versions box. If all goes well you should see `pakchunk0-Windows.pak` and `pakchunk0-Windows.utoc` in the FModel Archive tab. Before doing anything, go into `Settings > General > Advanced` and toggle *Local Mapping File*. Then set your mapping file path to the mappings provided in the Prereq section. ![FModel_2024-07-20_10-22-34](https://hackmd.io/_uploads/BkvxdFK_A.png) Once done you should be able to browse Abiotic Factor's game files to your heart's content. Reminder that if you installed the `BinkadecWithWavHeader` plugin you can double-click `.uasset` sound files to play them natively in FModel. Wow! ### Unreal Engine Now it's time to setup Unreal Engine. First make sure you have **Unreal 5.4** downloaded and launched. When creating a new project, make sure it's a "Blueprint" project, and you've specifically named the project **AbioticFactor**. This is very important. Once done, you should be greeted with the Unreal Engine window. Immediately go to `Edit > Editor Preferences > Experimental > User Interface` and check **Allow ChunkID Assignments**. Once done, go to `Edit > Project Settings > Project > Packaging > Packaging` and check **Generate Chunks**. Then save the project. Now, when creating a patch mod, it's important that you are exactly mimicking the folder structure of Abiotic Factor. This is because your patch `pak` is loading after the default game `pak`'s, and will override the default game files. This is where FModel comes back into play. When exploring `pakchunk0-Windows.utoc`, you'll see the folder structure of the game assets, which you would then replicate in UE's content browser to patch the file you wanted to. So for example, if I wanted to replace the sound the flashlight makes when it clicks on, I would look through FModel to find the location of the flashlight sound effect, which is `AbioticFactor/Content/Audio/Equipment/Flashlight/flashlight_click_on.uasset`. So then in Unreal I would mirror this directory location, then place my custom flashlight sound into the `Flashlight` folder, and rename it to `flashlight_click_on`. ![UnrealEditor_2024-07-20_10-38-10](https://hackmd.io/_uploads/r1mWuYYdR.png) ### Packing and Loading Once you've made the changes you want to make, it's time to create the mod files. First things first however, you'll need to *isolate* the changes you've made in Unreal to a separate `pak` file so that you can easily load it into Abiotic Factor without a bunch of other random Unreal stuff. To do this, simply go to the root of your `Content` folder in Unreal, and right-click. Then do select the *Miscellaneous* tab and create a **Data Asset**. In the menu that appears, select **Primary Asset Label**. Then right-click your created data asset, select *Edit*. Set the **Priority** box to 1, the **Chunk ID** box to a number you can remember, like 69. Then check the **Label Assets in My Directory** checkbox, and save the asset. If you don't want to create a separate Unreal project for each of your mods, you can create an asset collection and assign your DataAsset to that. Then any asset in that collection will be packed into the individual pak file for that mod. Just make sure you uncheck the **Label Assets in My Directory** box. Now to pack. Click on *Platforms* in the top Unreal Editor tab, *Windows*, and then click *Package Project*. If you're packaging for the first time, make sure it's a directory apart from your main Unreal directory so that you can find the files easier. Once Unreal is done packaging, go into the folder's it created, and find the 3 `pakchunk`'s that have your data asset number at the end. Copy these files, (Usually will be a `pak`, `ucas` and `utoc` file) and paste them into your `AbioticFactor/Content/Paks` folder. The final step is to add `_P` to the end of the file name so that they load as patches. ![explorer_2024-07-20_11-50-13](https://hackmd.io/_uploads/rJjbdttO0.png) Then simply start the game! If all is well, you should have a working patch mod. ## Specifics ### Change Weapon Stats Guide partially adapted from a [post on the Discord](https://discord.com/channels/1190637278222094436/1190642090456125480/1362075398367609025) by vyrias. 1. Download [StarterKit]() folder and edit the "extract" bat file via notepad. Replace the first quoted line with the path to your ABF Pak folder ("PATH/AbioticFactorFolder\AbioticFactor\Content\Paks") and the second quoted line with any folder you want (it will be the OUTPUT folder for all the extracted assets) Run extract.bat Inside your OUTPUT, go to AbioticFactor\Content\Blueprints\Items\ and find "ItemTable_Weapons.uasset" and "ItemTable_Weapons.uexp". Copy these 2 files and put them into a folder with a folder structure of AbioticFactor\Content\Blueprints\Items\ [PUT HERE] Go back to the StarterKit folder and open UAssetGUI. Click the Utils dropdown on the top left and click Import Mappings. Select the .usmap file you got from Step 1. On the top rightmost of UAssetGUI, click on the version drop down and select 5.4 On the top leftmost, select and import "ItemTable_Weapons.uasset" from step 5. If all goes well, you should be able to see a dropdown called "Table Info (84)". Click on it, find the weapons that you want to change. The [ItemName] file itself contains the attributes for Durability and RepairItem The WeaponData file contains all the juicy parts like Firerate, Damage, Mag size, etc Once done, save the file. [PakTemplate Section] Copy packagestore.manifest and scriptobjects.bin from the OUTPUT folder from step 2 into the PakTemplate folder. Now, go the PakTemplate folder and edit BuildUncompressed.bat, ResponseFile.txt (check step 11), and IoStoreCommands.txt. Change ALL instances of "E:((FOLDERCHAINGOESHERE))" into the path leading to the folder, for example: "E:((FOLDERCHAINGOESHERE))\UnrealPak\UnrealPak.exe" --> "D:\Tools\UnrealPak\UnrealPak.exe" For ResponseFile.txt, change "E:((FOLDERCHAINGOESHERE))\PakTemplate\RENAME_P\AbioticFactor\Content\Blueprints\DataTables\Customization\EXAMPLE.uasset" AND "../../../AbioticFactor/Content/Blueprints/DataTables/Customization/EXAMPLE.uasset" INTO "YOURPATH\AbioticProject\UassetGUI_StarterKit\PakTemplate\RENAME_P\AbioticFactor\Content\Blueprints\Items\ItemTable_Weapons.uasset" AND "../../../AbioticFactor/Content/Blueprints/Items\ItemTable_Weapons.uasset" Run BuildUncompressed.bat Provided step 12 was a success, go into the RENAMEBuilt folder and copy RENAME_P.pak, RENAME_P.ucas, and RENAME_P.utoc and paste all 3 files into YOUR GAME PATH\AbioticFactor\Content\Paks Pray to god it works and start the game. Note:The starterkit also has a readme if you want a super simplified version.