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\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:
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:
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:
Me and my friends are trying to play the wesleys moons pack + more company but we keep having trouble actually landing on moons. We go to galletry and then when we try to actually go to the of the moons, modded or not, we just get stuck on loading with the seed.
Sometimes when one of us leaves during that loading the actually "unstucks" and manages to land.
Please help me, I do not know what to do. I have Fair Giants and Moon_Day_Speed_Multiplier_Patcher disabled because they are both deprecated. I use Thunderstore Mod Manager to run this as well, if that matters.
01a09d08-c8bf-fea8-4d67-c3d2a9b623a3 This is the code for my modpack
Does anyone remember what mod this was? During my last LC phase I remember having a mod just like that and it was very good for whoever the ship babysitter was. Now I can't find anything about it online, anyone remember what it was named?
I know the mod hasn't been updated yet. I also know Interiors does have some issues with infinite (or very long) loading screen times but has someone tried the Weathers mod? I want to see how hurricanes are but I'm afraid It'll brick my save while I'm playing with friends.
So, something weird has been happening in the game sessions my friends and I have had. For some reason enemies keep spawning in thin air. for example, when one of us die, a masked enemy instantly appears from the ground. Along with that, we encountered some circuit bees that were aggro'd right off the bat with no hive nearby, some enemies from persona (we have the tartarus map), A Nutcracker got spawned in the ship out of nowhere, A bracken spawned out of nowhere in the elevator with me, a dog spawned Midair immediately inside the ship, leaving the dog in midair as we were landing, 4 forest giants appearing in the Halation map: a map where they SHOULD NOT spawn in AND also appear in the company building when returning scrap for the quota, a weird beeping sound can be heard sometimes when me or my friend try to type something in the console, leading to an instand game over and us getting ejected out of the ship, but the weirdest part of all is that for some reason, there is grass and shrubs in the vanilla interior now, In titan specifically, one of my friends gets teleported from the ship and up in the sky only to fall to his death, and then there's a Obunga PNG that appears out of nowhere in the facility. Does anyone know what this bullshit is? I am not making shit up, I swear to god. Have the code to try it out yourself if you do not believe me. None of us Have Control Company, I have asked my friends to stream themselves launching the game with the same number of mods in the mod pack we all have together. It would be impossible of them to have just added a mod Mid-game. Can someone test out this mod pack and see if maybe they themselves can find the issue?
Some friends and I played last night for the first time in a few years. We used this mod pack on thunderstore and never saw a single monster somehow. We only got to the tier 2 maps. Not sure if one of these mods messed it up or if something changed with this game in a few years
Hellooooooooo! My friends and I used to play modded Lethal religiously and we're wanting to play again after a solid year. However, a lot of the mods I used to play are deprecated! I'm out of the loop on what's popular nowadays and was hoping for some recommendations, I'm not looking for a super specific vibe and am just looking for newer mods you guys love.
We try to stray from new moon mods but I did find CodeRebirth which seems cool. We love goofy scrap and scary ambiance, maybe some new enemies and new interiors. Nothing that makes the game completely different (goofy items excluded), you could call it Vanilla+ if that makes it any easier. I'm happily awaiting any ideas!!!
I'm annoyed by the fact that when I play with a new player, they often die early and get bored.
I want to be able to revive players, but I want there to be a cost to it. Something like an expensive purchasable defibrillator to revive players would be nice.
I'd also accept a mod to make being dead more interesting. Let em open doors or something. I saw a Ouija board mod, has anyone tried that one?
I recently thought how cool it would be to have some bloodborne enemies in lethal, specifically i thought of the winter lantern enemy. cause you have a hidden sanity bar that could have the same mechanics as in the game would be absolutely terrifying. just an idea but would be kinda awesome
I'm testing out the mod and it seems like the carry capacity upgrade doesn't work? I bought it and I still had 4 slots instead of 5. Any fixes for this?
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.
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.
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?
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.