Basic steps:
1. Download the sdk off steam to get the original source code of the game, which will be found in steam/steamapps/common/killingfloor2/development/src
2. Find your MyDocuments/MyGames/Killingfloor2/KFGame folder (this should be autogenerated if you run the sdk I believe) and create a folder called "Src", then in that, make another folder with whatever you want your package to be named, AND in that, put a folder named Classes. (so now you have mydocs/mygames/killingfloor2/kfgame/src/MyPackage/Classes)
3. Create a .uc file (can be done with any text editor program, might I recommend notepad++) and name it whatever you want your gameinfo class to be called. In this file, the first line should be "class MyGameInfo extends KFGameInfo_Survival;" (MyGameInfo can be whatever you want as long as it's the same name as the file, the rest must be as is). Below that put "defaultproperties" with curly brackets under it.
Now you've got your basic setup, skip through the next few steps depending on what you want to do:
4 - Altering zeds:
To make changes to a zed, make a class that extends the zed you want to change (E.g. class KFPawn_Husk2 extends KFPawn_Husk). Now in your gameinfo class, in the brackets, add a line with the class path for your zed so your gameinfo knows to use this instead of the original. The lines are as follows
AIClassList(0)=Cyst
AIClassList(1)=Slasher
AIClassList(2)=Clot
AIClassList(3)=Crawler
AIClassList(4)=Gorefast
AIClassList(5)=Stalker
AIClassList(6)=Scrake
AIClassList(7)=Fleshpound
AIClassList(8)=Bloat
AIClassList(9)=Siren
AIClassList(10)=Husk
AIBossClassList(0)=Hans
AIBossClassList(1)=Patriarch
Add the line for the zed you changed, and past the equals sign, put " Class'Mypackage.Myzed' " (E.g. AIClassList(0) = Class'KFRebalanced.KFPawn_ZedClot_MyCyst' )
5 - Altering zed AI:
In each zed class, there is a variable called ControllerClass which is a path to the aicontroller for that zed. To alter AI, you must do step 4, then in your zed class, add the line ControllerClass=class'KFAIController_MyAIController' (you can name the aicontroller whatever you want). Then just make an AIController class that has the same name you put in that line, have it extend the original AIController class for that zed (unless you don't want it to be able to do the same things as that zed aside from the default properties).
5 - Altering/creating new Weapons:
NOTE: If you're altering a weapon that players start with (e.g. caulk n burn) you'll need to create a class that extends the perk that starts with it, and set it to use your weapon in the default properties. See step 6 for altering perks as well.
Create a class that extends the weapon you want to change or make your own weapon and have it extend one of the basic weapon classes. Might I recommend seeing some existing weapons for getting a feel of what to code to get the effects you want. Once you're happy with your weapon class, create a weapon defintion class for it by creating a class the extends KFWeaponDefinition and in defaultproperties put WeaponClassPath="Mypackage.MyWeaponClass". See existing weapon definition files for other things you'll want to add to this weapon definition such as cost and ammo cost.
Now compile your code (see step 7)
Now open up the SDK through steam and, in the content browser, create a new package with any name. Then, find the gameplay package, in that you should see GP_Trader_ARCH, and in that, you'll find DefaultTraderItems (you may need to rightclick the package and click fully load to see it). Now copy this into the package you made(you may need to click save, export, then import it back in because sometime copy is greyed out for some reason). With the DefaultTraderItems copy in your package, double click to edit it, and for an existing weapon, find the weapon in the saleitems list and replace it with your weapon. For a new weapon, click the little + and set it to use your new weapon. Then click the checkbox that says "Build now" or something to finalize your list. Now save your package (right click the package and click save).
Now you'll need a class that extends KFGameReplicationInfo, and in the default properties, add the line TraderItems=KFGFxObject_TraderItems'MySdkPackage.DefaultTraderItems'
Now add the line GameReplicationInfoClass=class'Mypackage.MyKFGameReplicationInfo' to the default properties in your gameinfo class.
Now you can find the package you made in the sdk in your mydocs/mygames/kf2/kfgame/unpublished folder. Copy paste that package into your classes folder with your source code and recompile (otherwise the traderitems line won't know where it is and give a warning/error).
Next go to your steamapps/kf2/kfgame/localization/int folder and create a .int file with a text editor and name the file the same name as your package with your source code. You'll give your weapon a description here. See the KFGameContent.int for what to put in your int file.
*NOTE* If the weapon is a projectile or melee, the associated perk info is also in the damage type for that projectile. To get perk effects to apply you must list the perk as a modifier perk in the damage type class for that projectile. E.g. I have a shotgun class: make a new projectile that extends the existing one, set the damage type to a new one that extends the existing damage type, and add a line setting the modifier perk to the perk you want.
Weapons this applies to:
All melee weapons
All shotguns
All explosive weapons
All firebug weapons (the place you set to use your new damage type is in an archetype file found in the SDK; for caulk it would be in weapons->caulk->wep_whatever_arch, just copy the archetype into your package and set the damage types to your damage types and set in the weapon class to use your archetype as the flamespray mesh instead of the original)
6 - Altering Perks:
Create a Class that extends the perk you want to alter, and change the functions/default properties you want to change.
Now all weapons this perk uses must have altered weapon classes to set their associated perk with your altered perk (e.g. my altered perk is KFPerk_Commando2, I must go through each assault rifle and make a new weapon class that extends the originals, and in default properties add a line setting the associated perk to KFPerkCommando2 instead of commando). See step 5 for the lengthy process involving altering weapons.
Now create a PlayerController class that extends KFPlayerController, add lines replacing the original perk with the perk you made to the default properties (see KFPlayerController for what these lines are).
Now add a line in your gameinfo class PlayerControllerClass = class'MyPackage.MyPlayerController'
7 - Compiling your code:
in mydocs/mygames/kf2/kfgame/config open the file KFEditor.ini , scroll near the bottom, and under [ModPackages] add a line ModPackages=MyPackage and save
Now go to steamapps/kf2/binaries/win64 , shift-rightclick and click open command window here. In it, type KFEditor make and if you did everything right, your code will compile successfully with no warnings and your compiled file will appear in mydocs/mygames/kf2/kfgame/unpublished/script
To run this, put this file in your KFGame/Brewed pc of your server folder, and add ?game=MyPackage.MyGameinfo to your command line of a server, or for the game, do the same for your steamapps folder, and in the command window you opened before, type KFGame mapname?same as above (e.g. KFGame kf-bioticslab?game=MyPackage.MyGameInfo)
--------------------------------------------------------------------------------------------------------------------------------------
Here's the source code for my Rebalance mod if you'd like to see exactly how to do certain things first hand https://www.dropbox.com/s/94b6dupqa8tzdjf/Rebalance Source Code.zip?dl=0 . If you have any questions or things to add, post them here and answer them/update the OP post to include whatever you have to add. I hope, if anything, this saved you some time and headaches that I experienced from sifting through code myself and asking around on the forums to figure all of this out.
1. Download the sdk off steam to get the original source code of the game, which will be found in steam/steamapps/common/killingfloor2/development/src
2. Find your MyDocuments/MyGames/Killingfloor2/KFGame folder (this should be autogenerated if you run the sdk I believe) and create a folder called "Src", then in that, make another folder with whatever you want your package to be named, AND in that, put a folder named Classes. (so now you have mydocs/mygames/killingfloor2/kfgame/src/MyPackage/Classes)
3. Create a .uc file (can be done with any text editor program, might I recommend notepad++) and name it whatever you want your gameinfo class to be called. In this file, the first line should be "class MyGameInfo extends KFGameInfo_Survival;" (MyGameInfo can be whatever you want as long as it's the same name as the file, the rest must be as is). Below that put "defaultproperties" with curly brackets under it.
Now you've got your basic setup, skip through the next few steps depending on what you want to do:
4 - Altering zeds:
To make changes to a zed, make a class that extends the zed you want to change (E.g. class KFPawn_Husk2 extends KFPawn_Husk). Now in your gameinfo class, in the brackets, add a line with the class path for your zed so your gameinfo knows to use this instead of the original. The lines are as follows
AIClassList(0)=Cyst
AIClassList(1)=Slasher
AIClassList(2)=Clot
AIClassList(3)=Crawler
AIClassList(4)=Gorefast
AIClassList(5)=Stalker
AIClassList(6)=Scrake
AIClassList(7)=Fleshpound
AIClassList(8)=Bloat
AIClassList(9)=Siren
AIClassList(10)=Husk
AIBossClassList(0)=Hans
AIBossClassList(1)=Patriarch
Add the line for the zed you changed, and past the equals sign, put " Class'Mypackage.Myzed' " (E.g. AIClassList(0) = Class'KFRebalanced.KFPawn_ZedClot_MyCyst' )
5 - Altering zed AI:
In each zed class, there is a variable called ControllerClass which is a path to the aicontroller for that zed. To alter AI, you must do step 4, then in your zed class, add the line ControllerClass=class'KFAIController_MyAIController' (you can name the aicontroller whatever you want). Then just make an AIController class that has the same name you put in that line, have it extend the original AIController class for that zed (unless you don't want it to be able to do the same things as that zed aside from the default properties).
5 - Altering/creating new Weapons:
NOTE: If you're altering a weapon that players start with (e.g. caulk n burn) you'll need to create a class that extends the perk that starts with it, and set it to use your weapon in the default properties. See step 6 for altering perks as well.
Create a class that extends the weapon you want to change or make your own weapon and have it extend one of the basic weapon classes. Might I recommend seeing some existing weapons for getting a feel of what to code to get the effects you want. Once you're happy with your weapon class, create a weapon defintion class for it by creating a class the extends KFWeaponDefinition and in defaultproperties put WeaponClassPath="Mypackage.MyWeaponClass". See existing weapon definition files for other things you'll want to add to this weapon definition such as cost and ammo cost.
Now compile your code (see step 7)
Now open up the SDK through steam and, in the content browser, create a new package with any name. Then, find the gameplay package, in that you should see GP_Trader_ARCH, and in that, you'll find DefaultTraderItems (you may need to rightclick the package and click fully load to see it). Now copy this into the package you made(you may need to click save, export, then import it back in because sometime copy is greyed out for some reason). With the DefaultTraderItems copy in your package, double click to edit it, and for an existing weapon, find the weapon in the saleitems list and replace it with your weapon. For a new weapon, click the little + and set it to use your new weapon. Then click the checkbox that says "Build now" or something to finalize your list. Now save your package (right click the package and click save).
Now you'll need a class that extends KFGameReplicationInfo, and in the default properties, add the line TraderItems=KFGFxObject_TraderItems'MySdkPackage.DefaultTraderItems'
Now add the line GameReplicationInfoClass=class'Mypackage.MyKFGameReplicationInfo' to the default properties in your gameinfo class.
Now you can find the package you made in the sdk in your mydocs/mygames/kf2/kfgame/unpublished folder. Copy paste that package into your classes folder with your source code and recompile (otherwise the traderitems line won't know where it is and give a warning/error).
Next go to your steamapps/kf2/kfgame/localization/int folder and create a .int file with a text editor and name the file the same name as your package with your source code. You'll give your weapon a description here. See the KFGameContent.int for what to put in your int file.
*NOTE* If the weapon is a projectile or melee, the associated perk info is also in the damage type for that projectile. To get perk effects to apply you must list the perk as a modifier perk in the damage type class for that projectile. E.g. I have a shotgun class: make a new projectile that extends the existing one, set the damage type to a new one that extends the existing damage type, and add a line setting the modifier perk to the perk you want.
Weapons this applies to:
All melee weapons
All shotguns
All explosive weapons
All firebug weapons (the place you set to use your new damage type is in an archetype file found in the SDK; for caulk it would be in weapons->caulk->wep_whatever_arch, just copy the archetype into your package and set the damage types to your damage types and set in the weapon class to use your archetype as the flamespray mesh instead of the original)
6 - Altering Perks:
Create a Class that extends the perk you want to alter, and change the functions/default properties you want to change.
Now all weapons this perk uses must have altered weapon classes to set their associated perk with your altered perk (e.g. my altered perk is KFPerk_Commando2, I must go through each assault rifle and make a new weapon class that extends the originals, and in default properties add a line setting the associated perk to KFPerkCommando2 instead of commando). See step 5 for the lengthy process involving altering weapons.
Now create a PlayerController class that extends KFPlayerController, add lines replacing the original perk with the perk you made to the default properties (see KFPlayerController for what these lines are).
Now add a line in your gameinfo class PlayerControllerClass = class'MyPackage.MyPlayerController'
7 - Compiling your code:
in mydocs/mygames/kf2/kfgame/config open the file KFEditor.ini , scroll near the bottom, and under [ModPackages] add a line ModPackages=MyPackage and save
Now go to steamapps/kf2/binaries/win64 , shift-rightclick and click open command window here. In it, type KFEditor make and if you did everything right, your code will compile successfully with no warnings and your compiled file will appear in mydocs/mygames/kf2/kfgame/unpublished/script
To run this, put this file in your KFGame/Brewed pc of your server folder, and add ?game=MyPackage.MyGameinfo to your command line of a server, or for the game, do the same for your steamapps folder, and in the command window you opened before, type KFGame mapname?same as above (e.g. KFGame kf-bioticslab?game=MyPackage.MyGameInfo)
--------------------------------------------------------------------------------------------------------------------------------------
Here's the source code for my Rebalance mod if you'd like to see exactly how to do certain things first hand https://www.dropbox.com/s/94b6dupqa8tzdjf/Rebalance Source Code.zip?dl=0 . If you have any questions or things to add, post them here and answer them/update the OP post to include whatever you have to add. I hope, if anything, this saved you some time and headaches that I experienced from sifting through code myself and asking around on the forums to figure all of this out.
Last edited: