Lethal Company - How to write your own mod from scratch!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's up guys it's minks and today I'm going to show you how to go from no mod to having a patch in uh lethal company uh there's videos and tutorials and stuff on other games and they do apply um but if you're new um you may not have realized that so here you are um so there's a couple things before we actually uh do anything that I want to uh kind of bring up here that way you have them have access to them and they're just overall really good resources um so I'm going to link two discords in the description there is a specific modding Discord and then an unofficial lethal company Discord um that has a strong modding presence uh so if you're working on a mod and you need help you can use those places to ask others that have more experience for help um I won't pretend I know uh everything or probably even at this point a lot about everything but um I uh am able to reach out and get help with things that I struggle with and I've helped others so um that's a big resource another resource that is uh pretty useful here um is the lethal company uh modding Weeki um so it doesn't uh it has the template project here um which is what we're going to get to we're going to sort of get to something similar to this um but we're going to actually do a patch um I don't think this has any patches in it no it just has the uh conf big which we won't need um I'll show you how to do what you need to do um and yeah all this extra stuff we don't need that our uh our IDE that we're going to be using for this will uh cover all that stuff what you can do is head over to the Wei tab here and this show uh has a bunch of different pages it's being built on over time so it'll get bigger um we've got last edit five days ago with 12 revisions and we've got more incoming soon um we just had a big discussion over game object destruction um so uh I'll link this as well so those two discords and this resource um but uh just like I watched a video on how to mod valheim to figure out how to do this um you're going to get a more personalized tutorial for how to uh mod uh lethal company so um it's pretty much going to be doing the same thing um but anyway let's go ahead and do a new project and actually before we go any further there's two prerequisites that you need um there's one that's more of a soft one soft prerequisite and two hard prerequisites soft prerequisite is some knowledge of C I'll be honest I don't know really much about Unity at all and my general knowledge came from General programming such as python I had made the lethal company Save Editor uh before I started modding here I knew a little bit about what we were doing before we started and it's hard to learn doing something like this if you don't already know a little bit about like the basics of coding um if you have any c knowledge then you'll be fine or any coding knowledge in general um especially if it's a c language um like C++ or actual c um moving on you need to have an IID installed we're going to be using visual studio for this Visual Studio is uh my favorite it makes things super easy it integrates very well with like Unreal Engine where more of my experience comes from um so uh you need that visual studio with the correct components installed you need like net um I'm pretty sure you need the game development one it may be optional but um you need at least the sharp.net um and then finally um they use a beex package that you can use for the N um we're just simply going to use I have a tutorial on how to install beex into the game install beex into the game you're going to be testing it anyway you might as well and you get your references directly from the beix folder here so I'll link my YouTube video on how to install beon X um into your game once you do that and you got Visual Studio installed come back and what's continue so once you've got that set up go ahead and start a new project make sure you select C at the top make sure you select library at the top um that'll make it easy to find what we're looking for and we're looking for class library.net framework a project for creating a C Class library. DL go ahead and grab that or select that hit next now what you need name your project is going to be what everything is named so go ahead and name it what you want your mod to be um so for example when I I originally made the game Master Mod which is where pretty much all of my knowledge on modding lethal company comes from at this point um it it started off as test mod and the GitHub repo still represents that despite me renaming everything in the end and after I renamed everything it made things significantly more annoying because of how uh the ID handled it so name it what you want ahead of time if you make a test mod for practice when you go into creade a new one make a new project probably easier um you know at that point so we're going to go ahead and for this one we're going to be LC tutorial mod okay Enter and it will create and if you've done everything right you should see a screen that looks like this um before we go in and start writing code let's go ahead and rename some stuff and add some references that we know we're going to need so um public class class one um we probably want to rename that so um I'm just going to do tutorial mod um I know naming convention it is what it is uh we'll say tutorial mod base it's fine um and then you want to rename your class one. CS uh it seems like the most common one is plugin so we'll do plugin. Cs and there we go so once you've got that done crl srl B to save and build and let's go ahead and add the reference ref es so these references are the dlls that we're going to be referencing that we need to um firstly hook in with Harmony and then actually uh the references to the game code um so if we right click on the uh um I don't know what this part of it's called so you have the solution and then whatever this is the namespace uh no the namespace is that I it is what it is so right click here hit add and we hit reference so since I've been doing this already with my other projects I already have everything I've referenced right here you're not going to have this stuff if this is your first time so we're going to hit browse now browse I don't remember where it takes you by default it definitely doesn't take you here um so this is where you're going to find most of your DLS um what you want to do you may have already found this your lethal company save directory or uh not save directory but uh game directory um because you installed beon X if you're struggling to find it go to steam right click on the game manage browse local files and it pops up and then what you can do copy this paste it up in here so once you've done that once you're here get here find the DXE so um first thing we want to reference is our beex and Harmony so go up into beex if you don't have all these folders you need to pause here for a second run your game it will generate these folders once you've got these folders go ahead and go into core find zero Harmony click on that hold down control and click on bonex then hit add and since mine are already here it didn't add anything to this list but it'll add them to the list for you so you can find them easier in the future um once you've added those we want to hit browse one last time let's go to the lethal company rout directory find lethal company data go into managed and there's a few things that we want um we absolutely every single time uh want this assembly c um I'm just going to go ahead and add right now and we're going to go back in and there's a couple more we want um Unity engine and unity engine. core so we find Unity engine I always get lost in the sauce here um Unity engine and unity engine. core module hold on control click those and add all right so this will cover about 90% of what you need if you need more the engine will yell at you be like hey are you missing this reference yes add this reference it'll tell you which reference to add um but for now we'll just use those we'll hit okay if it bugs us about anything we can see the process of adding it so now we've got our public class tutorial mod base let's make it a sub or a not a sub a child of a uh um base Unity plugin so hold hit your um well colon um button and then type in base Unity plugin now it's going to toss an error because we haven't actually added bonex so right click quick refactoring using bonex and it'll add it up top so now that we've done that um the next thing we need to do is tell us that this is a be andex plugin so go up to the top here and I forget what these are called in Python I oh man I don't remember what these are called in Python that's where I learned how to use these um it's essentially a modifier to what it's over so you can add these to things like functions and in this case a class um to tell it to do extra stuff um so do pep in X and in here we need to give it a couple different parameters and it may be airing out that's okay we need to add the reference um but um oops not beex W I'm ding dong beIN plugin um we need to give this three parameters a string gu ID string name String version we're not going to hardcode them we're going to make them variables so we'll just do mod guid comma mod name comma mod f which have not been defined yet so let's go ahead and Define them so uh we're going to do private const string mod U ID equals this needs to be unique something that no other mod that the user has installed is going to uh um is going to have uh so oops I didn't type in right modu ID so I like to do Poseidon dood name so LC tutorial mod uh for the mod name this one doesn't really have to be as unique but hopefully it is string mod name equals um let's see LC tutorial if I could type and then private con string string uh mod version equals 1 point zero if you're doing something like a thunderstore release you need the three um it's not it's not actually used for that but you might as well make it a line up um but you can also just do the fourth number um if I could type again wow need to get on my uh uh get on my typing skills okay so next up we need to Define Harmony that way we can use it to patch things so let's go ahead and do a private readon Harmony and we want to make sure we do Harmony since Harmony lib isn't referenced it's going to want to try and do Harmony lib we're going to do Harmony and if we hit enter it's going to reference Harmony lip for us and we'll say lowercase Harmony because we it doesn't matter um equals new so we're going to make an inst of harmony with our mod U ID go h contrs contr v to build and okay so now if you're familiar with programming uh you may understand that main is the most common way that we use or most common name we use for entry points uh we do not use that here uh for Unity we use something called a wake wake so essentially when this object is loaded it calls a wake um and this will get called uh this is is the entry point so when your mod getss loaded this is the first thing will'll happen um so a couple things we want to do um we do a private static private static instance uh and we do a uh not a private static instance but a private static tutorial mod base instance and then in here if instance is equal to null instance equals this so you probably won't need this you might at some point if you do you'll have it um this creates a static uh reference to the instance of the mod that way you can access variables when you create patches and other files if you're trying to do you know if you end up with a big mod that patches multiple things um like my game master mod um so um that may be beneficial um so let's go ahead and outside of the um um if Loop here or if statement not if Loop um outside of here um we want to go ahead and say Harmony patch all and you can do patch all um if you have things that you don't want to be patched for example another method or something you may not want to patch everything um you could do patch all type of and the tutorial mod base um we're going to be doing a second file for patching the player controller we're going to do a infinite Sprint today um see how that works um and yeah so uh when we do that we'll be patching that separately which I'll show you how to do at that point so um we've got our mod let's go ahead and actually add a logging Source um because we need to be able to log things to see what's going on for let's say testing issues thing you know basic troubleshooting um or uh yeah troubl I call it troubleshooting cuz more of an IT person that a coding person so um what we do is we create a uh um we'll do a I forget how we uh do an internal um internal manual log Source I don't think it's internal I to be honest I don't remember but we'll just do internal um if it doesn't work and we get issues then we'll do it so we'll just call it an MLS and in here do MLS equals weapon next Dot loging I put an x. log. logger oops not that create log source and uh what we put in here um you can put in I think mod U ID is the correct one it doesn't matter they're both strings all it does is say the name of it um again it shouldn't be the same as something else it should be its own log source so modu ID makes the most sense um so now we can go ahead and say uh for example mos. loginfo test mod as awen okay so that's good um something to note here uh because it's caused some recent issues ah we're g to never mind we're going to leave it alone it's not important um next up let's go ahead and figure out what we're going to patch so let's open up I use I Spy you can use DN spy or whatever alternative to these two that you want um whatever um so I already have stuff open so kind of cheating but uh we're going to go ahead and open what we want so again find your game directory open up the exe Works it'll open up everything related to exe we got lethal company and if you're unfamiliar with it everything's going to be pretty much an assembly C so we start here um if there's something not in the assembly C you can find it by searching for it up here uh but everything is almost everything's in here um so what we're looking for is actually in this point so for example if you to learn this or to find this out for the first time um you do kind of have to have an understanding there's some level of understanding that you need to have um to be honest uh but uh something that games use for example if you're uh work with on real engine is a player controller and that's what you usually see to control movement and that's what we see here so here um and if we open it up we get all this stuff again if you're familiar with it you'll know that this amount of variables is typically we expect and now we can use this to mess with them so um we don't need access to memory or anything like uh for example we don't need to like take a cheat engine and start scanning for a memory to get the Base address and uh um offsets or anything like that what we need is to find the actual uh thing that we want to mess with so we're doing a infinite Sprint so let's do a well we'll search for Sprint got a Sprint multiplier which could be interesting maybe an extra speed for if you sprint so you could have normal walk speed and then Sprint speed is better uh we have is sprinting we have a Sprint time and we have a Sprint meter UI and we have a Sprint meter U don't get confused so Sprint time I mean what does that sound like it sounds like someone who's uh like how long do you have to Sprint um like for example maybe it's like if Sprint is 100% this is how long it is I'm not really sure it doesn't sound right I'm not even sure what it's used for um there's only one that really makes sense and that's going to be Sprint meter um I know it's weirdly named but um Sprint meter so let's go ahead and search for that um looks like Sprint meter is set to one on a wake um which means one is likely going to be Max Sprint so um we'll just keep that in mind Max Sprint is one so it's going to be a zero to one which means we just need to set uh Sprint meter to one to have infinite Sprint um that's really all it is right uh damage player looks like um Sprint meter gets affected by taking damage jump performed Sprint meter equals it looks like it subtracts some stuff for uh um for jumping so that gives us an idea of we need to do so let's go ahead and fix our sprinting so to do this let's go ahead and make a new folder in here new or add excuse me new folder we'll call it patches and in I right click on it and add a new item and we're going to call it um player controller B patch add and inside of here um we've got everything we need so um just a couple things to note it says dot patches it's the folder so that's good everything lines up there um we need to do a couple things similar to the other one so if we look we haven't done any patching yet so there's nothing there but we need to do uh uh brackety stuff above us so um above the class we need to tell it what we're patching with this like obviously we know it's a player controller B patch uh Harmony needs to be told that so we do a Harmony patch and it looks like we haven't got the reference yet which we'll get in a second and we'll do our parenthesis and we'll do type of because we can actually reference the actual type player controller B not the B patch just the B and to fix this harmony patch we'll go ahead and right click actions using Harmony lip that should fix it so now we've got that we can go in here and we can patch a method so what do we need to patch um if we go back in there's a couple different options um we got a late update we've got update I know it's not on the screen here it's in here somewhere update can patch update um I think update's fine so patch update uh it happens every frame so that works so what we can do with update is um we'll create a new private static method so private static or we don't need to make it private just do a static uh static void um patch uh we'll say patch update we could just say uh or we could do like uh infinite Sprint patch something like that um if you're going to be patching more than one thing with the update method you may want to call it the patch update instead of the infinite Sprint patch but for our purposes this is perfectly fine um okay so to tell it that we want a patch update because it doesn't know that we're patching update has no idea um firstly we need to tell whether it's a prefix or a postfix so Harmony postfix we'll do a postfix for this one so what is a postfix and a prefix um those two things tell us where to put the code essentially you know this happens then the function happens and then that happens is it this or that um prefix is of course this it's the beforehand and postfix is afterwards so um that tells us how we're going about patching it there's other stuff other types um I think there's if we do type in just Harmony here um we've got some other stuff like after before cleanup debug delegate emit finalizer patch all uh that's not relevant uh just a few other things that uh transpiler is the other one that's big for something like this um just some other stuff that we're not going to be going over today um but we're going to do a post fix so when we look at it like doing you know determining when we want want to do something um so update does all the calculations so I'm pretty sure we're looking at update yeah so everything happens during the update function um so we'll do if we just look for Sprint meter here update happens it calculates Sprint meter um it looks like it uses it um it doesn't actually calculate it here at least not that early you don't see really any references to it anywhere in there so that's good um oh here it is that looks like it is calculated so it's calculated here after we do it and it looks like it does use the Sprint meter number so um it's possible it could cause issues um so what we want to do is just in case we're going to do the pro uh postfix because if it's incorrect um I don't think I actually don't think it matters here to be honest oh this is late update we're in late update okay so I imagine I don't know what late update does again that's my lack of unity knowledge um do it before late update after update so it gets set to Max before calculations are done um so Sprint meter equals math that F minus yeah so we'll be fine um since it happens every frame even if it does go down a little bit it'll go right back up so update post fix is fine and now we need to tell it to actually do update so there's two ways to go about telling it to do update um and it depends on what you find so for example Harmony patch um we could just do update that works um that will work in almost every single case there's a nicer way to do it if it picks up that you can do it and that usually is the case if it's public update's private if I'm not mistaken so if it's private um it'll likely not show um so much there it is yep it's private so um it's not going to work but you can say name of and it'll be player controller b. update we can see update's not available if we do the dot again we can see there is stuff that we can access if you can access the method this way I recommend it um but since we can't we'll just do update oops update there we go now how do we get access to the uh uh what do we call it the uh Sprint uh the Sprint meter because we don't just get it um we don't just get to say Sprint meter here or play controller Beed at Sprint meter um at least not the way we've done it um we have to reference it so we can get it by doing ref it's a float we've already looked at it and know it's a float um underscore underscore underscore Sprint meter so the ref and the underscores tell us it's a reference to uh something else uh to something in there and this will get us access to Sprint meter so to set it we can just do a couple you can do a couple different options for example for maybe a quick uh like a quicker recovery um you could do something like Sprint meter Plus 0.1f or something we're just going to do um Sprint meter uh equals what and that's it pretty much um seriously um that's it for patching it we've Now set Sprint meter to 1f every frame so every time that a frame happens it's going to give us or it's going to say our Sprint is Max so we need to tell it to actually patch this and what we can do is just harmony. patch all we probably don't even need to be patching this method if I'm not mistaken but that's okay um we're going to do player controller patch okay contrl B for build and if everything has gone smoothly we've done debug so what we'll do is we'll open and folder in file explorer go to bin debug and find your mod it's going to be your mod name. DL so LC tutorial mod. DL you may have a lot of these other things in here if you have the references you can ignore them um that's just so you can use them it's okay you don't need to copy them just the DL that you've outputed and and then you want to go to your plugins folder uh core cuz that's here so go to lethal company Vonex plugins and I have my game master there I'm going to go ahead and delete that and let's go ahead and test out our infinite Sprint see if we made any mistakes so oops over here we see LC tutorial mod 1.0 the test mod has awaken I think awoken is the actual correct term for that um we'll go ahead and go online and I've done it once again I think yep if you do this it's GNA break it you got to hit escape and I'll stop being frozen go ahead and host VI friends only is fine don't want to mess with other people considering we don't actually intend on playing right now and let's go ahead and Sprint around see if our Sprint goes down be quiet let's double check with the thing down I don't think there's infinite Sprint inside of here but just to be safe because to be honest I have no idea and let me double check and make sure my mod didn't load okay perfect just want to make sure game master wasn't running and giving me infinite Sprint either um not to say I wasn't expecting this to work I just want to make sure there's no other outside influence that would be uh um giving us bad results here but it looks like infinite Sprint is working so we have successfully patched the the game let's go ahead and steal this beehive that's mine now I'm being chased by the bees we can get away from him here there we go we've successfully escaped the bees using our infinite Sprint now that we've got this set up um you can really patch pretty much uh you can patch c a lot of stuff using that method um there's really um the sky's the limit once you get here um I mean like the the only thing we're not doing is uh um adding new like adding new stuff um so this is the player controller uh a couple other places that might be of interest is this Dash mark here um so this is where like for example all our AI is um all of our items the terminals in here tur walkie um start match start of round a big thing that controls a lot of this game is the round manager you go down to round manager a lot goes on in here so if we open it up um this controls a huge portion of the game so if you're wanting to mess with enemy AI vence uh time uh time of day round manager uh start of round those are going to be three big ones so um anyway that is it for making a mod um if you run into any issues feel free to drop a comment down below head into the discords ask some questions uh you can reach out to me um even um but yeah otherwise thank you for watching and have a wonderful day
Info
Channel: MrMiinxx
Views: 129,730
Rating: undefined out of 5
Keywords:
Id: 4Q7Zp5K2ywI
Channel Id: undefined
Length: 29min 47sec (1787 seconds)
Published: Thu Nov 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.