Lethal Company is an online multiplayer horror game created by a developer called Zeekerss. It gained global popularity in late 2023, garnering attention from millions of players and viewers.
For this study, I developed a mod to the game to change a design flaw that negatively affected part of the gameplay. The mod aims to encourage players to pick a wider variety of levels by adding random modifiers to each level every round.
In order to do this, I had to learn the modding process, using tools such as dnSpy and Unity Explorer to sweep the codebase and decompile the .dll of a unity project. Following which, I create my own .dll file using visual studio in a .NET environment and insert it as a plugin to modify the game.
When Lethal Company gained incredible popularity in late 2023, I would play the game regularly with different groups of friends. A common complaint I had was that there was no incentive to play new levels (moons) in the game. Players would simply keep picking the moons that had lots of loot, and didn't have any intrusive weather effects that round.
To fix this, I designed and implemented a Moon Modifier system that randomly assigns positive and negative modifiers to every moon. A positive modifier that gives triple loot might be given to a moon that players might not otherwise go to, or a negative modifier that spawns more enemies might be given to a moon that players would often go to.
Modding Pipeline
In order to make a change to the base game, it is necessary to understand the codebase and scene setup of Lethal Company. To do this, I learned two popular modding tools: dnSpy and Unity Explorer.
DnSpy is a .NET assembly editor, allowing the user to edit and debug assemblies even without the source code. This can be used to view every script used in Lethal Company, giving me vital insight on how the game logic works, and which functions and variables need to be edited to achieve a desired effect.
Unity Explorer is an in-game UI for exploring, debugging, and modifying Unity games. It gives the user a menu at runtime that shows the entire Unity inspector, with every game object and their variables. It provides necessary information for debugging, to make sure that edits I make to the game's code are actually doing anything in-game.
Modding Pipeline (cont.)
In order to inject code into the game, I created a visual studio project with the Harmony library. Harmony allows scripts to "Patch" a function in a game, allowing me to write code that will run at the start or end of any given function.
I use this to patch the start function of the main menu, which starts when the game first loads. I create a game object (the ModManager) that persists between scenes and is accessible from any script. It contains data such as the modifiers on each moon, and the current selected moon.
Moon Modifier System
Once the Mod Manager is created, it fills in the list of every moon in the game. I patch the weather generation function to grab the current weather of every moon and assign each moon its weather in the Mod Manager. Immediately afterwards, the Mod Manager generates modifiers for each moon.
First, an intensity value is given to each moon. This ranges from 0 to 25, and the minimum value depends on the weather. More dangerous weather gives a higher minimum intensity value. The intensity value determines the amount of negative and positive modifiers, as well as their scale.
If a moon is eclipsed (a very dangerous weather condition) and given an intensity of 25, then the mod manager will first try to reach -25 value for negative modifiers. An eclipse counts for -15 value, and so it picks out 2 negative modifiers, and scales them to meet -10 value.
It then picks out 3 positive modifiers to meet positive 25 value, and scales them as well. Once the value reaches 0, the modifiers for that moon are finished generating.
Modifiers
Six modifiers were implemented for this project. Three positive modifiers (loot rate, movement speed, and time increase), and three negative modifiers (more enemies, more turrets, and less player health).
The loot rate modifier increases the amount of loot (scrap) that spawns in a level, which incentivizes a player to go to a moon since the entire goal of the game is to earn money by collecting scrap. The movement speed modifier increases player sprint speed, which lets them collect scrap faster and evade threats, which is an incentive to go to a moon. The time increase modifier gives players more time in the day, which gives them more leeway on when to return to the ship and more time to collect loot.
The enemy modifier increases the max enemies permitted to spawn in the level, which makes levels become more threatening over time. The turret modifier spawns more turrets in the level, which can be very dangerous in large numbers. The player health modifier decreases player health, which can turn insignificant fall damage into deadly mistakes.
The goal with this system was to make positive and negative modifiers with considerable consequences to give the player a more interesting risk-reward when selecting moons, and I think I succeeded in this goal! I like the way the mod turned out, and I learned a lot about developing game mods and working off of existing codebases.