[Tutorial] Custom Perks

  • 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/

Gartley

Grizzled Veteran
Dec 27, 2010
2,339
349
83
UK
www.wildcardproductionstudios.co.uk
Ok. Now to try and continue the attempt to limit version miss matching and to help people out who wish to create custom perks or server admins who want to work custom weapons into their perks.

Note: This first post may look like a lot, but it's less than an afternoon's reading.

Part One : Prerequisites

Primers

Forum member Benjamin created some very useful tutorials. I suggest you read the first one at least as it covers the actual set up and compiling of mods/muts/packages.

Creating a Basic Mutator
Mutator Essentials
Multiplayer Mutators
Modifying Existing Weapons

C++ & UnrealScript

Unreal Script is an object based programming language derived from C++. I'm not going to teach you about C++, I'm no where near qualified (or patient) enough to do so.

http://www.cplusplus.com has all the info you need on C++ including tutorials. Take note of how object based programming works including inheritance and projected properties. In here are all the operators and statements you'll need for the maths and checks.

UnrealScriptReference Has pretty much all the info you need on the unreal script functions and more. You can also use http://wiki.beyondunreal.com/ as a resource.

This should be enough to get you started by the time you've had a skim over and maybe tried some of Benjamin's tutorials I'll have written up the next section of the tutorial.

Note: To the experienced programmers; Marco, ScaryGhost, Benjamin etc. If you spot any mistakes or omissions please do send me a message and I'll correct any mistakes I've made. Also feel free to send any suggestions.


Tutorial One – Setting Up & Testing

So now that we have covered some basics of C++/UnrealScript and compiling we need to set ourselves up to build our new perks. There are other ways of doing this but this is the way I prefer to do things.

First download and install ServerPerks from this thread. -Be sure to thank Marco while you are there. ;)

First create your mod folder; “WhiskyPerks” for this example and within that a folder called “classes”
tut1.png


Next navigate to .../KillingFloor/System and open the killingfloor.ini
In the EditPackages lines I add after ‘KFMutators’ the packages for ServerPerks and then your own.
tut2.png


Now going back to our mod folder we set up I’m going to create a simple perk extension that I will use for following tutorials. This is saved as a .uc file in the classes folder. Don't forget the file name has to be the same as the class name.

Code:
class WVetCommando extends SRVetCommando
	abstract;
defaultproperties
{
	VeterancyName="Whisky Commando"
}

This is all the code I’m going to use for the time being. What I’m doing here is extending off of the SRVetCommando which is the commando class that comes with ServerPerks. This will inherit all the functions and properties of its parent class with the exception of the Perk’s name, now “Whisky Commando” which overrides the parent class property.

Compile and if you’ve been following along you should have no problems. Next navigate to .../KillingFloor/System and open the ServerPerks.ini file (you can do this in game as well from the mutator window I just prefer doing it here) and add your new perk to the Perks= lines, in this case Perks=WhiskyPerks.WVetCommando.
tut3.png


Run the game and test. (Don’t forget to turn on ServerPerks from the mutator menu!)
-Remind me to take a picture to put here.-

And there we have it, our very own ‘custom’ perk in game. Admittedly this is only a name change but it is a start. Next tutorial will show you how to start customising bonuses and discounts.
 
Last edited:

Gartley

Grizzled Veteran
Dec 27, 2010
2,339
349
83
UK
www.wildcardproductionstudios.co.uk
Tutorial Two : Extending and Overriding Perks

We will start simply to begin with. Now you can find ALL the functions you need in other files, both in the original perks in the KFMod folder in your .../killingfloor/ directory and in Marco
 
Last edited:

rkellis

FNG / Fresh Meat
May 10, 2012
2
0
0
http://forums.tripwireinteractive.com/showthread.php?t=48277

As you may be now aware of that custom perk

My problem is i followed every instructions and everything loaded perfectly the only problems is that the perks won't show up this is probably a offtopic but its still related to adding custom perks anyways I would like to know why it doesn't show up not even in the veterancy handler.Thank you.
 

ASSAYARO

Member
Sep 12, 2010
159
14
18
Behind you...
Thank you so much...

Thank you so much...

Tutorial Three : Perk From Scratch with Custom Stats
[/CODE]

2 Qustions...

First, How do I insert another level conditions? (this part of rhe "GetPerkProgressInt" & progressArray"
Snd, Is it possible to insert a condition existing perk?
(E.g : movement, reload .. etc)
 
Last edited:

Gartley

Grizzled Veteran
Dec 27, 2010
2,339
349
83
UK
www.wildcardproductionstudios.co.uk
Hey ASSAYARO,

#1: I used an array just to keep things easy, you can do it the same way as in the orginal perks, commando or support are a good example ala:

Spoiler!

Or define a second array, either works.

And two, fully possible, just extend the perk and add the function you wish to include. Commando with speed boost?

class SpeedyCommando extends SRVetCommando abstract;

static function float GetMovementSpeedModifier(KFPlayerReplicationInfo KFPRI, KFGameReplicationInfo KFGRI)
{
if ( KFPRI.ClientVeteranSkillLevel <= 1 )
return 1.0;
return 1.05 + FMin(0.05 * float(KFPRI.ClientVeteranSkillLevel - 2),0.55); // Moves up to 25% faster @ lvl6
}

default properties {}

Replace ServerPerks.SRVetCommando with your mypackage.SpeedyCommando and job's a good'en.
 
Last edited:

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
You might also want to add in a part where you can hide weapons from the trader using something like this.

static function bool AllowWeaponInTrader( class<KFWeaponPickup> Pickup, KFPlayerReplicationInfo KFPRI, byte Level )
{
if ( class<M79healPickup>(Pickup) != none || class<VirusMistPickup>(Pickup) != none || class<DoctorRiflePickup>(Pickup) != none || class<NovaSixPickup>(Pickup) != none )
return false;
else
return true;
}
 

FluX

Grizzled Veteran
Oct 26, 2010
5,394
234
63
www.fluxiserver.co.uk
Do remember to add the bool requirement in the default to say how many requirements the perk should have:
Code:
NumRequirements=2
and also add the description as so:
Code:
Requirements(0)="Kill %x Stalkers with Bullpup/AK47/SCAR"
     Requirements(1)="Deal %x damage with Bullpup/AK47/SCAR"
 

Marco

Active member
May 23, 2009
644
232
43
Finland
You might also want to add in a part where you can hide weapons from the trader using something like this.

A better example, you could use that to make like a portal science perk and hide Portal Turret from trader if you don't have level 5 or hide portal gun before level 10 (also require that you have that perk selected):
Code:
static function bool AllowWeaponInTrader( class<KFWeaponPickup> Pickup, KFPlayerReplicationInfo KFPRI, byte Level )
{
	if( Pickup==Class'PTurretPickup' )
		return (KFPRI.ClientVeteranSkill==Default.Class && Level>=5);
	if( Pickup==Class'pgPortalGunPickup' )
		return (KFPRI.ClientVeteranSkill==Default.Class && Level>=10);
	return true;
}
 

ASSAYARO

Member
Sep 12, 2010
159
14
18
Behind you...
Hey ASSAYARO,

#1: I used an array just to keep things easy, you can do it the same way as in the orginal perks, commando or support are a good example ala:



Or define a second array, either works.

And two, fully possible, just extend the perk and add the function you wish to include. Commando with speed boost?



Replace ServerPerks.SRVetCommando with your mypackage.SpeedyCommando and job's a good'en.

Thank you so much for the answer:)
 

ASSAYARO

Member
Sep 12, 2010
159
14
18
Behind you...
one question

one question

Hey ASSAYARO,

#1: I used an array just to keep things easy, you can do it the same way as in the orginal perks, commando or support are a good example ala:



Or define a second array, either works.

And two, fully possible, just extend the perk and add the function you wish to include. Commando with speed boost?



Replace ServerPerks.SRVetCommando with your mypackage.SpeedyCommando and job's a good'en.

I would like to apply 3conditions for lvl-up.
But, see the following error messages. something wrong??

Error, Redefinition of 'function GetPerkProgressInt' differs from original in SRVeterancyTypes
Compile aborted due to errors.
 
Last edited:

FluX

Grizzled Veteran
Oct 26, 2010
5,394
234
63
www.fluxiserver.co.uk
I would like to apply 3conditions for lvl-up.
But, see the following error messages. something wrong??
Make sure that your function GetPerkProgressInt is exact same start as the original.
Code:
static function int GetPerkProgressInt( ClientPerkRepLink StatOther, out int FinalInt, byte CurLevel, byte ReqNum )
It has to match that.
 

ASSAYARO

Member
Sep 12, 2010
159
14
18
Behind you...
Make sure that your function GetPerkProgressInt is exact same start as the original.
Code:
static function int GetPerkProgressInt( ClientPerkRepLink StatOther, out int FinalInt, byte CurLevel, byte ReqNum )
It has to match that.

Thank u for the answer.
I've made a mistake... h:Da i solved
 

NeedlesKane

FNG / Fresh Meat
Jan 18, 2012
151
1
0
Big D
A better example, you could use that to make like a portal science perk and hide Portal Turret from trader if you don't have level 5 or hide portal gun before level 10 (also require that you have that perk selected):
Code:
static function bool AllowWeaponInTrader( class<KFWeaponPickup> Pickup, KFPlayerReplicationInfo KFPRI, byte Level )
{
    if( Pickup==Class'PTurretPickup' )
        return (KFPRI.ClientVeteranSkill==Default.Class && Level>=5);
    if( Pickup==Class'pgPortalGunPickup' )
        return (KFPRI.ClientVeteranSkill==Default.Class && Level>=10);
    return true;
}

Hi Marco. When I attempt to use this for the Firebug the trader ends up breaking. Is the code a little bit different for this perk from the others? Thanks!