• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Need help with writing mutators

dakkafex

Grizzled Veteran
Aug 7, 2014
88
1
So yea.. how do i do it? :p

I am an experienced developer so no issues there, i just cant seem to find a good hook or documentation on how to specifically write for KF2, ive tried to cannibalize an existing mod but when trying to compile that i just run into odd errors which i cant figure out why.
Im also not really sure where to lookup KF2 references.

If anyone could point me in the right way, would be great.
 
I only recently got into modding, and trust me, it's tough to get started. There really isn't any guide on how to do it. I learned by piecing together bits and pieces from lots of questions about modding from KF1, and a bit from questions on the KF2 forums too. Also, I looked through the code of ProjectOne which was reasonably well documented.

Firstly, you'll want to setup your project structure. There's a short tutorial on that here:

https://tripwireinteractive.atlassian.net/wiki/display/KF2SW/KF2+Code+Modding+How-to

If you haven't already, you'll want to download the KF2 SDK from the Tools section in Steam. This will provide you with a lot of the source code of KF2, as well as allow you to view animations, meshes (models), textures and sounds used in the game through the SDK. You'll be able to find the source code in your Killing Floor 2 folder in your Steam directory, in the Development folder. For me, the path is: C:\Program Files (x86)\Steam\steamapps\common\killingfloor2\Development\Src

You will need to learn Unrealscript. Luckily there's heaps of documentation on the internet.



Now to the actual modding part...

You need to decide if you're going to make a mutator, or a game mode. For a mutator, you extend KFMutator, and for a game mode, you extend KFGameInfo_Survival, unless you're making a completely different game mode, where you might want to instead extend KFGameInfo. Have a look in the code for Mutator and KFMutator (KFMutator extends Mutator) to see what sort of stuff is already integrated into those classes and see if that's what you're looking for. Particular things are much easier to do through a game mode though.

From here, you need to have some idea of what you want to change. If you want to change how a particular thing works in KF2, let's say you want to stop zeds targeting players, you have to find where in the source code the zeds target players. There is likely to be a lot of different pieces of code that should be changed to make it work nicely. For each piece of code, you need to override the class that it is located in, and in that child class you've made, you need to override the function that the code is contained in. Then you need to modify all of the classes that used the class you overrode to now use your child class. You do this by extending again. This can get nasty quickly, so some things will be quite difficult to change.

Some things are actually really easy to change, like changing the class for humans. This class is used in a huge amount of classes, so it would be a nightmare to try to change it. However, there is a variable in KFGameInfo called DefaultPawnClass. In the 'defaultproperties' (which is sort of like a constructor) for KFGameInfo, we have:

DefaultPawnClass=class'KFGame.KFPawn_Human'

So in our class that extends KFGameInfo_Survival, we can put:

DefaultPawnClass=class'SomeClassName'

Where 'SomeClassName' is the name of our class that extends KFPawn_Human. It will need to extend this. Note that we don't need to put the package name here (KFGame was the package name of the original default human class).

Other things can be changed like this, such as the DifficultyInfoClass, as well as the list of zeds to spawn. You can actually make fleshpounds spawn in the place of bloats with just a single line:

AIClassList(AT_Bloat)=class'KFPawn_ZedFleshpound'



Here's some links to threads that I found very useful:

http://forums.tripwireinteractive.c...-aa/44542-tutorial-mutator-essentials?t=43534
http://forums.tripwireinteractive.c...494-tutorial-creating-a-basic-mutator?t=43484
http://forums.tripwireinteractive.c...ing-discussion-ad/115198-coding-mutators-help

Also, here's a mutator that you might be able to cannibalise. I modified it and it worked just fine for me:

http://forums.tripwireinteractive.c...ifying-the-trader-sales-list-via-unrealscript

I'm currently working on a mod for a harder difficulty that changes a lot of things, and is reasonably well documented. I could upload the source code for that after a bit of fixing up if you want.

Let me know exactly what you need help with for getting started with modding, and I'll try to respond as soon as I can. Feel free to add me on Steam too if you want to discuss it easier and you think I can help. My username is the same as on here. Good luck, and I look forward to seeing what you create.
 
Upvote 0
I only recently got into modding, and trust me, it's tough to get started. There really isn't any guide on how to do it. I learned by piecing together bits and pieces from lots of questions about modding from KF1, and a bit from questions on the KF2 forums too. Also, I looked through the code of ProjectOne which was reasonably well documented.

Firstly, you'll want to setup your project structure. There's a short tutorial on that here:

https://tripwireinteractive.atlassian.net/wiki/display/KF2SW/KF2+Code+Modding+How-to

If you haven't already, you'll want to download the KF2 SDK from the Tools section in Steam. This will provide you with a lot of the source code of KF2, as well as allow you to view animations, meshes (models), textures and sounds used in the game through the SDK. You'll be able to find the source code in your Killing Floor 2 folder in your Steam directory, in the Development folder. For me, the path is: C:\Program Files (x86)\Steam\steamapps\common\killingfloor2\Development\Src

You will need to learn Unrealscript. Luckily there's heaps of documentation on the internet.



Now to the actual modding part...

You need to decide if you're going to make a mutator, or a game mode. For a mutator, you extend KFMutator, and for a game mode, you extend KFGameInfo_Survival, unless you're making a completely different game mode, where you might want to instead extend KFGameInfo. Have a look in the code for Mutator and KFMutator (KFMutator extends Mutator) to see what sort of stuff is already integrated into those classes and see if that's what you're looking for. Particular things are much easier to do through a game mode though.

From here, you need to have some idea of what you want to change. If you want to change how a particular thing works in KF2, let's say you want to stop zeds targeting players, you have to find where in the source code the zeds target players. There is likely to be a lot of different pieces of code that should be changed to make it work nicely. For each piece of code, you need to override the class that it is located in, and in that child class you've made, you need to override the function that the code is contained in. Then you need to modify all of the classes that used the class you overrode to now use your child class. You do this by extending again. This can get nasty quickly, so some things will be quite difficult to change.

Some things are actually really easy to change, like changing the class for humans. This class is used in a huge amount of classes, so it would be a nightmare to try to change it. However, there is a variable in KFGameInfo called DefaultPawnClass. In the 'defaultproperties' (which is sort of like a constructor) for KFGameInfo, we have:

DefaultPawnClass=class'KFGame.KFPawn_Human'

So in our class that extends KFGameInfo_Survival, we can put:

DefaultPawnClass=class'SomeClassName'

Where 'SomeClassName' is the name of our class that extends KFPawn_Human. It will need to extend this. Note that we don't need to put the package name here (KFGame was the package name of the original default human class).

Other things can be changed like this, such as the DifficultyInfoClass, as well as the list of zeds to spawn. You can actually make fleshpounds spawn in the place of bloats with just a single line:

AIClassList(AT_Bloat)=class'KFPawn_ZedFleshpound'



Here's some links to threads that I found very useful:

http://forums.tripwireinteractive.c...-aa/44542-tutorial-mutator-essentials?t=43534
http://forums.tripwireinteractive.c...494-tutorial-creating-a-basic-mutator?t=43484
http://forums.tripwireinteractive.c...ing-discussion-ad/115198-coding-mutators-help

Also, here's a mutator that you might be able to cannibalise. I modified it and it worked just fine for me:

http://forums.tripwireinteractive.c...ifying-the-trader-sales-list-via-unrealscript

I'm currently working on a mod for a harder difficulty that changes a lot of things, and is reasonably well documented. I could upload the source code for that after a bit of fixing up if you want.

Let me know exactly what you need help with for getting started with modding, and I'll try to respond as soon as I can. Feel free to add me on Steam too if you want to discuss it easier and you think I can help. My username is the same as on here. Good luck, and I look forward to seeing what you create.
Hi!

Do you know where we can find player attribute variables? I cant seem to find the variable for player size in the KFPawn_Human Class ):
 
Upvote 0