Rizarttt Posted August 2 Share Posted August 2 Developing Mods for 7 Days to Die Using Harmony Mod Example A good example of a mod I created can be found at Immersive Crosshair Mod on GitHub. Use this as a starting point for your projects. Tools You'll Need IDE: Visual Studio 2022 or JetBrains Rider. Both IDEs are excellent choices, but Rider is particularly effective due to its robust features and user-friendly interface. .NET Framework: Mods work well with .NET Framework version 4.8.1. Refer to the linked GitHub .csproj file to verify these settings. Setting Up Your Mod Project Start by cloning my mod example from GitHub. This approach saves time and ensures you have a working base. Clone an Existing Project: Use the GitHub repository as a template and clone the project files to create a new mod. Update Paths: Ensure they are linked to your game path. Understanding the Code The **vp_FPCamera** class is located in the **Assembly-CSharp.dll**. Here’s how you can patch this class. This example demonstrates how to use a postfix method to modify behavior after the original method executes: using HarmonyLib; using UnityEngine; namespace ReplaceWithYourNamespace.Harmony { [HarmonyPatch(typeof(vp_FPCamera))] [HarmonyPatch("OnEnable")] public static class VpFPCameraPatch { public static void Postfix(vp_FPCamera __instance) { // Example: Code to run after OnEnable method } } } Using a **Postfix** method allows you to run code after the original method. This can be particularly useful for making changes or performing actions that depend on the original method's execution. Leveraging AI for Development Enhance your development workflow by combining ChatGPT with your modding process. Testing Your Mod Compile and Deploy the Mod: Build your project in the IDE. Ensure the .csproj path has been updated with your game path. Launch the Game: Use 7dLauncher.exe to run the game and apply the mod. Press the F1 button to check the logs and ensure your mod is loaded correctly. Speed Up Development Modify the debug build path to point directly to your mods folder to streamline testing: <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> ... <OutputPath>..\..\..\..\vortex_udf_7_days_to_die\Mods\ReplaceWithYourModName</OutputPath> ... </PropertyGroup> Conclusion By starting with an existing mod project and making strategic updates, you can efficiently develop mods for "7 Days to Die" using Harmony. For more detailed information, refer to the Harmony documentation at Harmony Documentation and the 7 Days to Die Modding API at 7 Days to Die Modding API. Link to comment Share on other sites More sharing options...
Rizarttt Posted August 2 Author Share Posted August 2 Caused by someone asking help with modding the vp_FPCamera class. Quote Could you teach me how to start the class with harmony and how do I modify the existing class in the game? Link to comment Share on other sites More sharing options...
Rizarttt Posted August 3 Author Share Posted August 3 Quote If you make a version of this that works for all ranged weapons as well, I will sing your praises. Or tell me the tools you used and I'll do it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now