Lethal Company

Lethal Company

131 betyg
How the Ghost Girl Picks Her Victims (Programmatically)
Av Cain
This guide will explain explicitly what the DressGirlAI (Ghost Girl) looks for when choosing who to Haunt next. Information taken directly from the Games Code.
7
   
Utmärkelse
Favorit
Favoritmarkerad
Avfavoritmarkerad
Introduction
❗ IF YOU FIND IT MORE INTERESTING TO NOT PEAK BEHIND THE CURTAIN, PLEASE DON'T READ THIS. IT'LL JUST RUIN YOUR ENJOYMENT OF THE GAME, IF YOU WANT TO MIN-MAX EVERYTHING. READ ON 🤘

Intro
After being targeted by the Ghost Girl nearly every game and always being marked as 'Paranoid' I had to do some investigation into why this was happening. Since this game is a UnityGame, it's code can easily be decompiled into C# but to respect the privacy of the Developers I will not be showing any of their code, but will be explaining how it works, its actually pretty interesting and it uses Weighted RNG 😁
Part 1 - What Affects Your Hidden FEAR Stat
The first thing the Girl does when deciding who to hunt is loop through all the current players in the game and checks your 'Insanity Level' and 'Total Turn Amount'. Whoever has the highest of these two stats will be saved and used for later.

Your Insanity Level is affected by a few things, but on a basic level it's a number that is slowly increasing over the game affected by a scaling multiplier. I will go into more depth on this stat on another guide. Just know if you're alone, you will lose Sanity at varying rates based on location but if you're with someone else (or listening to someone talk on the Walkie) you gain Sanity.

Your Total Turn Amount is updated every time your Camera's View is rotated. Basically just turning left or right, shaking your mouse etc.

After noting which Player turns the most and which Player has the highest Insanity Level, she begins to build a FEAR Stat for every player as well, this hidden stat starts at a base level of 80 for every player. She loops through all players and tries to apply each case to them. These are the 4 Cases.
  • If player has the highest Insanity Level = +50 FEAR
  • If player has the highest Turn Amount = +30 FEAR
  • Has the player been critically injured before? = +10 FEAR
    * Critically Injured is defined in the Game's Code as falling under 20 HP.
  • At Round Start, Is the player holding an item worth more than 150 scrap? Yes = +30 FEAR

So if you have Turned the Most (+30), Been Critically Injured (+10) and Held an Expensive Item (+30) you would have a total Fear of 150.

These all make sense but since I'm pretty new to the game I still find it hard to believe you'll start the round holding an item over 150 Scrap. To my knowledge there are very few items that meet this quota. But to avoid this I'd just drop everything that isn't your basic tools.

(Don't forget to trick your friends into holding the Jet-pack to artificially inflate their FEAR and increase their chances of being c̷̛̹̖̥̹͍̃͗̏̉̃̅̂̆̑͝ḩ̵̳͔̠̙̪̟̭̳͎̥̌̎̌̏̅̀̇̚ͅo̸̢̢̹̰̺̘̤̮͇̼̙͛͂̒͆͌́̚͝s̸̲̲͕͇̟͆̇̄͆͐̄ę̸̖͍̹̩͖͖̞̲̣̖̩̻͇̤͑̽̄͛̋̂͠ṉ̷̡̨̱͎͖̥̥͚͍͚̼͂͌̃̓͌͑͜͝)
Part 2 - Weighted RNG And How it Works (Technical)
I will be showing the code for this as its pretty standard Weighted RNG Code and it can be found on the Unity Forums. If you don't know exactly what Weighted RNG is, just know on a basic level, it's the bigger your fear stat, the higher chance you have of being chosen.

I'll go over a few variables really quick to make this easier to follow.
  • randomSeed = RANDOM_INT(MAP_SEED + 158)
  • num = TOTAL_OF_PLAYER_FEARS
  • num2 = RANDOM FLOAT BETWEEN 0.0 AND 1.0
  • num3 = TOTAL OF AVERAGED FEARS (CURRENT_PLAYER_FEAR / TOTAL_OF_PLAYERS_FEARS)
  • 'weights' refers to a list of your teams FEAR stats.

Time to break down every section of code to make it easier to understand.
  1. This code simply adds together all the players Fears.

  2. This code is error checking code, If the Total Fear is less than or equal to 0. Just pick a random player instead.

  3. This assigns the num2 variable a Float Value between 0.0 and 1.0 This is what will be used to choose the player to Haunt.

  4. This section of code is the core of everything and makes the final decision, so let me break it down.

    First it checks if a players FEAR stat is bigger than 0. If it is, it proceeds to grab the Average of the Fear and add it to the Total of Averaged Fears. (num3)

    It then checks if the TOTAL_OF_AVERAGED_FEARS (num3) is greater or equal to, the Random Variable we got in section #3 (num2). If it is, it will select that player to Haunt, if it isn't, it'll try again with the next player. But since the Variable num3 already has the previous players value in it, the second player will have a higher chance of being chosen when their FEAR AVERAGE is added. This repeats until a player is chosen to haunt. If the player is dead they are skipped.

  5. This is more error checking code, if it fails to pick a player using the weighted index, it just picks a completely random player. You can see it writes the current values to a Debug Log so they can be checked by the developer later to see which values (or lack there of) that caused the Weighted Index to fail.
Part 3 - TLDR and More
I know this is a lot of text to read but I just found it interesting and I'm sure other people love to know the actual numbers of what goes on behind the game.

The main things to take away from this are.
  • Don't Hold Expensive Items at Round Start
  • Make sure your friends are holding Expensive Items at Round Start (150+ Scrap)
  • Try not to get critically injured (Fall Below 20 HP)
  • Try to keep a low Turn Amount score.

Thanks for reading and thanks to the Devs for making such an awesome and interesting game. I'll maybe make more guides explaining how other monsters choose their victims, I just don't wanna min-max everything so early into release 😁

I'd also like to add as a disclaimer: I may be misunderstanding some of the Developers code and some parts might be slightly off or incorrect but I have tried to reverse it to the best of my ability. I completely welcome all and any criticism.
41 kommentarer
AlmightyTitus 8 sep @ 14:37 
ummmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
Cain  [skapare] 8 jan @ 12:06 
@Кирик If you do please add what @Parasyte added as a correction.
Mutata 7 jan @ 13:24 
Hello. Thanks for the guide. Is it still relevant? If that's so, do you mind If I translate this guide from English into Russian giving all the neccessary credits to the original guide?
parasyte 4 dec, 2023 @ 17:23 
looking through this, i've been doing some source diving too and your guide says
At Round Start, Is the player holding an item worth more than 150 scrap? Yes = +30 FEAR
I'm not sure that's quite accurate. ChoosePlayerToHaunt() does do that check and add that value, and that function is only called by DressGirlAI.Start() and DressGirlAI.ChooseNewHauntingPlayerClientRpc(). The RPC function will only be called if the girl's haunt target dies, but Start() is called when the girl is spawned and not at round start.

so what I think happens is that at the moment the game spawns an enemy, if that enemy is the girl, she'll look at what everyone has in their hands and add 30 to the 'fear' level of everyone who has an item worth more than 150
Cain  [skapare] 29 nov, 2023 @ 8:45 
@Anilosi There is actually a Modding API made for this game now as well. But I can't speak to how effective it is as I haven't used it.
Anilosi 28 nov, 2023 @ 17:37 
@Cain i code as a hobby but i've never made a mod, i've found a few guides so i'll try cause i really want to make it. Thank you so much!
Cain  [skapare] 25 nov, 2023 @ 11:36 
If you don't know how to code it'll be pretty hard to understand. Google 'BepInEx' and 'HarmonyX'.
Anilosi 25 nov, 2023 @ 10:27 
@Cain what is Harmony Patching??
Cain  [skapare] 25 nov, 2023 @ 9:56 
@Anilosi I think you can do Harmony Patching to overwrite the Game's functions and variables. You could just modify their function to always pick player 0.
Anilosi 25 nov, 2023 @ 9:26 
Is it posible in any way to make a mod that causes the little girl to only show to the host and never the rest of the crew?