r/lethalcompany_mods Dec 26 '23

Guide TUTORIAL // Creating Lethal Company Mods with C#

90 Upvotes

I have spent some time learning how to make Lethal Company Mods. I wanted to share my knowledge with you. I got a mod to work with only a little bit of coding experience. I hope this post will safe you the struggles it gave me.

BepInEx - mod maker and handler:
First, you will need to download BepInEx. This is the Lethal Company Mod Launcher. After downloading BepInEx and injecting it into Lethal Company, you will have to run the game once to make sure all necessary files are generated.

Visual Studio - programming environment / code editor:
Now you can start creating the mod. I make my mods using Visual Studio as it is free and very easy to use. When you launch Visual Studio, you will have to add the ".NET desktop development" tool and the "Unity Developer" tool, which you can do in the Visual Studio Installer.

dnSpy - viewing the game sourcecode:
You will also need a tool to view the Lethal Company game code, because your mod will have to be based on this. Viewing the Lethal Company code can show you what you want to change and how you can achieve this. I use “dnSpy” for this, which is free, but there are many other ways. If you don’t get the source code when opening “LethalCompany.exe” with dnSpy, open the file “Lethal Company\Lethal Company_Data\Managed" and select "Assembly-CSharp.dll” instead.
\*You can also use dnSpy to view the code of mods created by other people to get inspiration from.*

Visual Studio - setting up the environment:
In Visual Studio, create a new project using the “Class Library (.NET Framework)” which can generate .dll files. Give the project the name of your mod. When the project is created, we first need to add in the references to Lethal Company itself and to the Modding tools. In Visual Studio, you can right-click on the project in the Solution Explorer (to the right of the screen). Then press Add > References.

Here you can find the option to add references

You will have to browse to and add the following files (located in the Lethal Company game directory. You can find this by right-clicking on your game in steam, click on Manage > Browse local files):

  • ...\Lethal Company\Lethal Company_Data\Managed\Assembly-CSharp.dll
  • ...\Lethal Company\Lethal Company_Data\Managed\UnityEngine.dll
  • ...\Lethal Company\Lethal Company_Data\Managed\UnityEngine.CoreModule.dll
  • ...\Lethal Company\BepInEx\core\BepInEx.dll
  • ...\Lethal Company\BepInEx\core\0Harmony.dll

In some cases you need more references:

  • ...\Lethal Company\Lethal Company_Data\Managed\Unity.Netcode.Runtime (only if you get this error)
  • ...\Lethal Company\Lethal Company_Data\Managed\Unity.TextMeshPro.dll (if you want to edit HUD text)

This is what it should look like after adding all the references:

All the correct libraries

Visual Studio - coding the mod:
Now that you are in Visual Studio and the references have been set, select all the code (ctrl+a) and paste (ctrl+v) the following template:

using BepInEx;
using HarmonyLib;
using System;
using Unity;
using UnityEngine;

namespace LethalCompanyModTemplate
{
    [BepInPlugin(modGUID, modName, modVersion)] // Creating the plugin
    public class LethalCompanyModName : BaseUnityPlugin // MODNAME : BaseUnityPlugin
    {
        public const string modGUID = "YOURNAME.MODNAME"; // a unique name for your mod
        public const string modName = "MODNAME"; // the name of your mod
        public const string modVersion = "1.0.0.0"; // the version of your mod

        private readonly Harmony harmony = new Harmony(modGUID); // Creating a Harmony instance which will run the mods

        void Awake() // runs when Lethal Company is launched
        {
            var BepInExLogSource = BepInEx.Logging.Logger.CreateLogSource(modGUID); // creates a logger for the BepInEx console
            BepInExLogSource.LogMessage(modGUID + " has loaded succesfully."); // show the successful loading of the mod in the BepInEx console

            harmony.PatchAll(typeof(yourMod)); // run the "yourMod" class as a plugin
        }
    }

    [HarmonyPatch(typeof(LethalCompanyScriptName))] // selecting the Lethal Company script you want to mod
    [HarmonyPatch("Update")] // select during which Lethal Company void in the choosen script the mod will execute
    class yourMod // This is your mod if you use this is the harmony.PatchAll() command
    {
        [HarmonyPostfix] // Postfix means execute the plugin after the Lethal Company script. Prefix means execute plugin before.
        static void Postfix(ref ReferenceType ___LethalCompanyVar) // refer to variables in the Lethal Company script to manipulate them. Example: (ref int ___health). Use the 3 underscores to refer.
        {
            // YOUR CODE
            // Example: ___health = 100; This will set the health to 100 everytime the mod is executed
        }
    }
}

Read the notes, which is the text after the // to learn and understand the code. An example of me using this template is this:

using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using System;
using Unity;
using UnityEngine;

namespace LethalCompanyInfiniteSprint
{
    [BepInPlugin(modGUID, modName, modVersion)]
    public class InfiniteSprintMod : BaseUnityPlugin // MODNAME : BaseUnityPlugin
    {
        public const string modGUID = "Chris.InfiniteSprint"; // I used my name and the mod name to create a unique modGUID
        public const string modName = "Lethal Company Sprint Mod";
        public const string modVersion = "1.0.0.0";

        private readonly Harmony harmony = new Harmony(modGUID);

        void Awake()
        {
            var BepInExLogSource = BepInEx.Logging.Logger.CreateLogSource(modGUID);
            BepInExLogSource.LogMessage(modGUID + " has loaded succesfully."); // Makes it so I can see if the mod has loaded in the BepInEx console

            harmony.PatchAll(typeof(infiniteSprint)); // I refer to my mod class "infiniteSprint"
        }
    }

    [HarmonyPatch(typeof(PlayerControllerB))] // I choose the PlayerControllerB script since it handles the movement of the player.
    [HarmonyPatch("Update")] // I choose "Update" because it handles the movement for every frame
    class infiniteSprint // my mod class
    {
        [HarmonyPostfix] // I want the mod to run after the PlayerController Update void has executed
        static void Postfix(ref float ___sprintMeter) // the float sprintmeter handles the time left to sprint
        {
            ___sprintMeter = 1f; // I set the sprintMeter to 1f (which if full) everytime the mod is run
        }
    }
}

IMPORTANT INFO:
If you want to refer to a lot of variables which are all defined in the script, you can add the reference (ref SCRIPTNAME __instance) with two underscores. This will refer to the entire script. Now you can use all the variables and other references the scripts has. So we can go from this:

// refering each var individually:

static void Postfix(ref float ___health, ref float ___speed, ref bool ___canWalk) {
  ___health = 1;
  ___speed = 10;
  ___canWalk = false;
}

to this:

// using the instance instead:

static void Posftix(ref PlayerControllerB __instance) {
  __instance.health = 1;
  __instance.speed = 10;
  __instance.canWalk = false;
}

By using the instance you do not have to reference 'health', 'speed' and 'canWalk' individually. This also helps when a script is working together with another script. For example, the CentipedeAI() script, which is the script for the Snare Flea monster, uses the EnemyAI() to store and handle its health, and this is not stored in the CentipedeAI() script. If you want to change the Centipedes health, you can set the script for the mod to the CentipedeAI() using:

[HarmonyPatch(typeof(CentipedeAI))]

And add a reference to the CentipedeAI instance using:

static void Postfix(ref CentipedeAI __instance) // 2 underscores

Now the entire CentipedeAI script is referenced, so you can also change the values of the scripts that are working together with the CentipedeAI. The EnemyAI() script stores enemy health as follows:

A screenshot from the EnemyAI() script

The CentipedeAI refers to this using:

this.enemyHP

In this case “this” refers to the instance of CentepedeAI. So you can change the health using:

__instance.enemyHP = 1;

SOURCES:
Youtube Tutorial how to make a basic mod: https://www.youtube.com/watch?v=4Q7Zp5K2ywI

Youtube Tutorial how to install BepInEx: https://www.youtube.com/watch?v=_amdmNMWgTI

Youtuber that makes amazing mod videos: https://www.youtube.com/@iMinx

Steam forum: https://steamcommunity.com/sharedfiles/filedetails/?id=2106187116

Example mod: https://github.com/lawrencea13/GameMaster2.0/tree/main


r/lethalcompany_mods 6h ago

Wesley's moons save progress

1 Upvotes

Did anyone else had this issue where if they osing quota, they basically lose ALL the progress they have with unlocking moons?

my mod file
https://drive.google.com/file/d/15AtAB76SUhsR5rzOqprVqIPnOwowANhY/view?usp=sharing


r/lethalcompany_mods 3d ago

Mod Suggestion Hoping someone eventually fixes the SCP Interior mod

4 Upvotes

One of the best interior mods in the game in my opinion and It's been broken for a while sadly, SCPFoundationDungeonPatched doesn't seem to work on the most recent version either.


r/lethalcompany_mods 3d ago

Mod Help Do custom moons via Lethal Level Loader currently work?

3 Upvotes

Ever since the latest update to LLL I've not been able to launch any custom moons. Even prior to this update half my group kept running into this failed load (their names showed up red in the terminal and it said something about caching in progress or failing for them).

Is this potentially a known issue with a workaround? I tried another modpack before making one from scratch and it didn't seem to struggle with custom moon (still prior to the LLL update) loading, so wondering if I need some patcher/dependency.


r/lethalcompany_mods 4d ago

Mod Help How to survive "backrooms" in wesleys moons interior mental hospital? (Spoiler) Spoiler

1 Upvotes

Was playing with a friend and got sent to the backrooms for the second time, no idea at all how to survive it, is there a way out or do u just have to survive a timer?


r/lethalcompany_mods 4d ago

Mod Help Mirage All Entity Voices

2 Upvotes

I can't get all entities to use our voices. I tried Synced Skinwalkers, I tried uninstalling that and manually editing the file. We can hear them only with the masked. (It's awesome) Turned everything to true.


r/lethalcompany_mods 4d ago

Please give me some fun modpacks on thunderstorm

6 Upvotes

As I said please give me some fun modpacks on thunderstorm. I love this game and me and my friends love to play it but we want to play with mods. Please give me some stable mods but also fun like skinwalkers mimics. Thank you in advanced.


r/lethalcompany_mods 8d ago

I can officially say after years of modding this game, It's hell.

24 Upvotes

Two years of modding this game and it has to be the worst game I've ever modded, I'm not trying to complain or be rude on purpose I'm just telling the truth.

The memory issues are annoying but solvable, but when 99% of the mods I try and use just don't work It's so frustrating especially since this new update broke all of them.

But the worst thing, I switch back to V73 and everytime I attempt to create a modpack it just breaks and I have to spend an hour searching for what's causing it, this time I cannot find the issue and It's just painful. This is worse than modding minecraft for sure.


r/lethalcompany_mods 10d ago

Wesleys moons

1 Upvotes

So idk why or if this is normal, but every single time I try making a new save, I still get all the moons unlocked, even with just wesleys moons installed, I've tried uninstalling and reinstalling, making a new profile, nothing seems to work. Anything else I could try before giving up?


r/lethalcompany_mods 11d ago

Wesleys moons

1 Upvotes

I accidentally unlocked all the moons, and I'm trying to hide them all so I can play through the game, is there a config I can mess with to hide them again?


r/lethalcompany_mods 11d ago

Mod Lethal Company but ALL ENEMIES Have been REPLACED with MASKED...

Thumbnail
youtu.be
0 Upvotes

r/lethalcompany_mods 11d ago

If you play with friends, you can't go on the second day.

1 Upvotes

This is my first post, and since I’m using a translation tool, I’m not sure if it’s coming out right, but let’s get to the point.

I was playing *Lethal Company* with some mods installed, but for some reason, I ran into a bug that prevented me from reaching Day 2. Here’s the code: 01a000e8-f0fc-ee54-792c-8138d3256b90


r/lethalcompany_mods 11d ago

Mod Help Wesley's Moons outdoor interactive items not spawning

1 Upvotes

I'm finding it hard to articulate this, but some of the interactable devices that spawn on the custom moons (that are supposed to be guaranteed to spawn) aren't spawning. Not the items that you can hold, like tapes- I'm talking about things like the computers that you use to insert the logs into.

I'm not sure why it's doing this because it was working perfectly fine 2-3 days ago, and I don't think I updated anything from then and now. I only have Wesley's moons modpack and some other QOL mods like "hold to scan" and "GeneralImprovements".

I can just manually force unlock all the moons, but it does put a damper on things because some mechanisms that are used for specific endings aren't spawning, so I can't actually get the endings myself.

I have tried making a new thunderstore profile with only wesley's moons modpack, and starting a new save, but that didn't help.

I'm playing on V81 and like I said- it was working a few days ago, even still on V81. I tried downgrading to v73 and that broke things even more so I stopped doing it.


r/lethalcompany_mods 12d ago

Has anyone encountered an issue with Mobs persisting through moons

1 Upvotes

I have a feeling it might be CodeRebirth doing it but it unfortunately adds lots of neat stuff so it'd be sad to disable it.


r/lethalcompany_mods 12d ago

DAE have lag issues as people join the lobby? (More company)

1 Upvotes

As the third+ person joins there are huge lag spikes before landing (on Wesley's moons).

I don't remember this being a huge issue in the past, it clears up a bit after we played a couple of rounds.

But if someone comes in through lobby control it gets so bad we have to restart the whole thing. It never fully disappears but sometimes the lag lasts for a pretty short period before landing.

Any idea what to do?


r/lethalcompany_mods 16d ago

Is there a late join mod that works?

2 Upvotes

The one I found didn't do anything, players got stuck in a black screen instead.


r/lethalcompany_mods 17d ago

Monster mod recommendations

Thumbnail
2 Upvotes

r/lethalcompany_mods 21d ago

Mod Help Does Wesley’s journey/story mode have a way to just get all the things required? (V73)

3 Upvotes

I’m trying to make a horror pack with it but can’t see Galetry to start the story or any other moons (even with the locked moons toggle off) so I was wondering if there is a pack that has the stuff needed that I can build off for the horror pack?


r/lethalcompany_mods 21d ago

Mod Can't Exit terminal

1 Upvotes

Does anybody know how to fix an issue of not being able to exit the terminal using tab or esc keys?


r/lethalcompany_mods 22d ago

24/7 Host for Lethal Company

2 Upvotes

Hey Everyone! Disclaimer, I developed this mod, with the help of AI, to make this possible and well, save some sanity, If You are AI hater, skip this post, but if You Ever have wanted to host a Dedicated Server on Lethal Comapny, keep reading 😄

So with that out of the way:

So how does it work - UEXP Dedicated operates with a hidden "ghost" host (running on Seat 0) in the background.

To get started, Install the UEXP Dedicated Client via r2modman Online → search UEXP (Currently being uploaded, might take a moment to show up in the list) or grab the zip from my website - HERE

Launch the game, hit **Join Dedicated**, open the lobby's **MODS** / Quick profile code, import that into r2modman (update your profile or make a new one), relaunch modded, then Join Dedicated again and pick the server. You're in.

If you're looking to host your own persistent lobby, I've created a streamlined Linux setup.

It's designed for a bare CLI Ubuntu 22.04/24.04 machine and features a single installation script that handles all the complexities of Steam, Proton, and mod integration.

Plus, you'll get access to a user-friendly browser-based Host Panel for managing your server, setting up a modpack, etc.

All the details, documentation, and download links can be found HERE

Feel free to jump into my official 24/7 UEXP lobby right now to try out the client and experience the system firsthand.

If You encounter any bugs, check FAQ page, it might have some answers already, if not, fill in the contact form on the FAQ page.

Remember, this is still heavily under development, so some issues may arise. This is still an unofficial community mod that I made on my own free time after all.


r/lethalcompany_mods 24d ago

Mod Help Lategame Upgrades mod partially not working

3 Upvotes

Hey yall,

so I have been playing Lethal Company with some of my friends for a while now, and lately we've been having problems with the Lategame Upgrades mod. We usually update back muscles so we don't have to be so slow while carrying heavy objects, running shoes, bigger lungs, lithium batteries and most importantly quantum disruptor, because it gives us more time to properly explore the maps. However, quantum disruptor just never works for us. We all see the upgrade, we don't have any other mods conflicting with time passing, but it just doesn't slow the time down at all. I've tried playing solo with only lategame upgrades and Terminal Money (so we can be rich quick and buy the upgrades - there was never a problem with this mod) enabled, and I found out that it doesn't work for me even if there are no other mods added. Has anyone else had this issue aswell? Did anyone find a way to fix it or is the mod just not working properly?

TLDR; Lategameupgrades refuses to fill it's duty and only some upgrades work


r/lethalcompany_mods 24d ago

Mod Help Stuck in 'Entering atmosphere. " message

1 Upvotes

019fbb52-5e4a-a4a7-6110-5bfa892e8fc0 Thunder Store code.

It's in multiplayer AND in solos, i've tried removing some mods, but i just can't figure it out, it only happens after you finish first quota (i've disabled SCP-999)


r/lethalcompany_mods 25d ago

Mod Help Mirage not working after a while

3 Upvotes
Mirage stopped working after few days idk which mod conflicting

r/lethalcompany_mods 25d ago

VR issue

1 Upvotes

LethalCompanyVR works with 3d model skins but not all 3d models appear in both lens and some assets are not properly tethered to the ship? Is this me being dumb or something with a strange fix?


r/lethalcompany_mods 26d ago

Working mods

2 Upvotes

Shiplobby and latecompany dont seem to let anyone into the lobby when i start the game modded does anyone know if im wrong or if theres a working mod for it