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

Code [Tutorial] Custom Perks

Hate to necro a thread but.


static function bool AllowWeaponInTrader( class<KFWeaponPickup> Pickup, KFPlayerReplicationInfo KFPRI, byte Level )
{
if( Pickup==Class'ZabuzasSwordPickup' )
return (KFPRI.ClientVeteranSkill==Default.Class && Level >=10);
return true;
}

I tryed to use that code, and it allows them to buy it at lvl 9? i thought that made it only lvl 10+ could
 
Upvote 0
Removing Perk Prerequisite

Removing Perk Prerequisite

Hey guys
Loving the Tutorial, although I wanna remove the "Kill so many stalkers" thing on the Commando, what would I need to implement for that? It would be an override function, but me being me, if its not spelled out, I'm clueless.
Would it then be possible to re-name the existing prerequisite with something else, and yet keep the same perk progression?

Example: Get x amounts of head shots
Turn that into
Get x amounts of headshots on clots, gorefasts and crawlers

Example: Deal x amount of shotgun damage
Turn that into
Get x amount of pistol damage

Another thing (sorry guys!)
Is it possible to change the bonuses a perk gets with a single weapon? I dont want to create my own perk, I'm clueless and don't understand it, but would it be possible to give, say, a sharpshooter a bonus on the M37 Grenade Launcher? (A damage bonus and a merchant bonus)
So it becomes included in the perk progression, but doesnt count towards it?
I have no idea if this makes sense, or if people will read this. I hope you do :p

Peace out guys
 
Upvote 0
To change what weapon damage you want to check, you need to make a custom stat and replace it. For the removing Stalkers count, you remove the second stat on Commando to make it damage only.


Going to be a complete and doshing noob here
How?
I've tried making a custom perk, didn't work. How do I remove the second stat? Like I said, I need things spelt out the first time (cause I suck)
Sorry FluX :(
 
Upvote 0
Help

Help

Okay guys

So I coppied the Sharpshooter perk from KF so I wouldn't have to worry about trying to create new perk progression
Here's my code:

class WVetSharpshooter extends SRVetSharpshooter
abstract;

// Removed all General Damage additions for the Sharpshooter in Balance Round 6 in favor of a headshot focus
//static function int AddDamage(KFPlayerReplicationInfo KFPRI, KFMonster Injured, KFPawn Instigator, int InDamage, class<DamageType> DmgType)

static function float GetHeadShotDamMulti(KFPlayerReplicationInfo KFPRI, KFPawn P, class<DamageType> DmgType)
{
local float ret;

// Removed extra SS Crossbow headshot damage in Round 1(added back in Round 2) and Removed Single/Dualies Damage for Hell on Earth in Round 6
// Added Dual Deagles back in for Balance Round 7
if ( DmgType == class'DamTypeCrossbow' || DmgType == class'DamTypeCrossbowHeadShot'|| DmgType == class'DamTypeMac10MP' ||
(KFPRI.Level.Game.GameDifficulty < 7.0) )
{
if ( KFPRI.ClientVeteranSkillLevel <= 3 )
{
ret = 1.05 + (0.05 * float(KFPRI.ClientVeteranSkillLevel));
}
else if ( KFPRI.ClientVeteranSkillLevel == 4 )
{
ret = 1.30;
}
else if ( KFPRI.ClientVeteranSkillLevel == 5 )
{
ret = 1.50;
}
else
{
ret = 1.60; // 60% increase in Crossbow/Mac10MP/Shotgun/M4203AssaultRifle damage
}
}
// Reduced extra headshot damage for Single/Dualies in Hell on Earth difficulty(added in Balance Round 6)
else if ( DmgType == class'DamTypeDualies' && KFPRI.Level.Game.GameDifficulty >= 7.0 )
{
return (1.0 + (0.08 * float(Min(KFPRI.ClientVeteranSkillLevel, 5)))); // 40% increase in Headshot Damage
}
else
{
ret = 1.0; // Fix for oversight in Balance Round 6(which is the reason for the Round 6 second attempt patch)
}

if ( KFPRI.ClientVeteranSkillLevel == 0 )
{
return ret * 1.05;
}

return ret * (1.0 + (0.10 * float(Min(KFPRI.ClientVeteranSkillLevel, 5)))); // 50% increase in Headshot Damage
}

static function float ModifyRecoilSpread(KFPlayerReplicationInfo KFPRI, WeaponFire Other, out float Recoil)
{
if ( Crossbow(Other.Weapon) != none || Mac10MP(Other.Weapon) != none
|| Shotgun(Other.Weapon) != none || M4203AssaultRifle(Other.Weapon) != none)
{
if ( KFPRI.ClientVeteranSkillLevel == 1)
{
Recoil = 0.75;
}
else if ( KFPRI.ClientVeteranSkillLevel == 2 )
{
Recoil = 0.50;
}
else
{
Recoil = 0.25; // 75% recoil reduction with Crossbow/Mac10MP/Shotgun
}

return Recoil;
}

Recoil = 1.0;
Return Recoil;
}

static function float GetReloadSpeedModifier(KFPlayerReplicationInfo KFPRI, KFWeapon Other)
{
if ( Crossbow(Other) != none || Mac10MP(Other) != none || Shotgun(Other) != none || M4203AssaultRifle(Other) != none)
{
if ( KFPRI.ClientVeteranSkillLevel == 0 )
{
return 1.0;
}

return 1.0 + (0.10 * float(KFPRI.ClientVeteranSkillLevel)); // Up to 60% faster reload with Crossbow/Mac10/Shotgun
}

return 1.0;
}

// Change the cost of particular items
static function float GetCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
if ( Item == class'ShotgunPickup' || Item == class'Mac10Pickup'|| Item == class'CrossbowPickup'|| Item == class'M4203Pickup')
{
return 0.9 - (0.10 * float(KFPRI.ClientVeteranSkillLevel)); // Up to 70% discount on Crossbow/Mac10/Shotgun/M4203
}

return 1.0;
}

static function float GetAmmoCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
if ( Item == class'CrossbowPickup' )
{
return 1.0 - (0.07 * float(KFPRI.ClientVeteranSkillLevel)); // Up to 42% discount on Crossbow Bolts(Added in Balance Round 4 at 30%, increased to 42% in Balance Round 7)
}

return 1.0;
}

static function int AddCarryMaxWeight(KFPlayerReplicationInfo KFPRI)
{
if ( KFPRI.ClientVeteranSkillLevel == 0 )
{
return 0;
}
else if ( KFPRI.ClientVeteranSkillLevel <= 4 )
{
return 1 + KFPRI.ClientVeteranSkillLevel;
}
else if ( KFPRI.ClientVeteranSkillLevel == 5 )
{
return 8; // 8 more carry slots
}

return 9; // 9 more carry slots
}

// Give Extra Items as Default
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{
local Inventory I;

// Delete standard guns
I = P.FindInventoryType(Class'Single');
if( I!=None )
I.Destroy();
KFHumanPawn(P).RequiredEquipment[0] = "";
KFHumanPawn(P).RequiredEquipment[1] = "";

// If Level 7 or below, give them a Crossbow and Mac10
if ( KFPRI.ClientVeteranSkillLevel < 7 )
{
KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Mac10MP", GetCostScaling(KFPRI, class'Mac10Pickup'));
KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Crossbow", GetCostScaling(KFPRI, class'CrossbowPickup'));
}

static function AddCustomStats( ClientPerkRepLink Other )
{
Other.AddCustomValue(Class'HeadshotProgress');
}
class HeadshotProgress extends SRCustomProgressInt;

static function AwardDamage(KFSteamStatsAndAchievements KFStatsAndAchievements, int Amount)
{
if( SRStatsBase(KFStatsAndAchievements)!=None && SRStatsBase(KFStatsAndAchievements).Rep!=None )
SRStatsBase(KFStatsAndAchievements).Rep.ProgressCustomValue(Class'HeadshotProgress',Amount);
}

defaultproperties
{
ProgressName= "Headshot Crossbow Kills"
}
}
defaultproperties
{
PerkIndex=7
OnHUDIcon=Texture'KillingFloorHUD.Perks.Perk_SharpShooter'
OnHUDGoldIcon=Texture'KillingFloor2HUD.Perk_Icons.Perk_SharpShooter_Gold'
VeterancyName="Ada Wong"
Requirements[0]="Get %x headshot kills with the Crossbow"

LevelEffects[0]="5% more damage with Crossbow, Mac10 and Shotgun|5% extra Headshot damage with all weapons|10% discount on Crossbow/Mac10/Shotgun"
LevelEffects[1]="10% more damage with Crossbow, Mac10 and Shotgun|25% less recoil with Crossbow, Mac10 and Shotgun|10% faster reload with Crossbow, Mac10 and Shotgun|10% extra headshot damage|20% discount on Crossbow, Mac10 and Shotgun"
LevelEffects[2]="15% more damage with Crossbow, Mac10 and Shotgun|50% less recoil with Crossbow, Mac10 and Shotgun|20% faster reload with Crossbow, Mac10 and Shotgun|20% extra headshot damage|30% discount on Crossbow, Mac10 and Shotgun"
LevelEffects[3]="20% more damage with Crossbow, Mac10 and Shotgun|75% less recoil with Crossbow, Mac10 and Shotgun|30% faster reload with Crossbow, Mac10 and Shotgun|30% extra headshot damage|40% discount on Crossbow, Mac10 and Shotgun"
LevelEffects[4]="30% more damage with Crossbow, Mac10 and Shotgun|75% less recoil with Crossbow, Mac10 and Shotgun|40% faster reload with Crossbow, Mac10 and Shotgun|40% extra headshot damage|50% discount on Crossbow, Mac10 and Shotgun"
LevelEffects[5]="50% more damage with Crossbow, Mac10 and Shotgun|75% less recoil with Crossbow, Mac10 and Shotgun|50% faster reload with Crossbow, Mac10 and Shotgun|50% extra headshot damage|60% discount on Crossbow, Mac10 and Shotgun"
LevelEffects[6]="60% more damage with Crossbow, Mac10 and Shotgun|75% less recoil with Crossbow, Mac10 and Shotgun|60% faster reload with Crossbow, Mac10 and Shotgun|50% extra headshot damage|70% discount on Crossbow, Mac10 and Shotgun"
}

It keeps saying, though, at line 148 that function is not allowed here...
Why is that? Am I doing something wrong?
I had it working before, but I need to change it because I wan't other custom perks to be able to use the Sharpshooter base once more.
Thank's for any help!
 
Upvote 0
use code tags please. It's very hard to see.

Spoiler!
 
Last edited:
Upvote 0
Right a little hint, highlight the line also as I had to copy it and find it myself. So...

Code:
static function AddCustomStats( ClientPerkRepLink Other )
{
Other.AddCustomValue(Class'HeadshotProgress');
}

This code here is your problem. Now due to you extending one of the other perks, this will not count as it's not in their code (seems that way). Also another thing I noticed is this:
Code:
class HeadshotProgress extends SRCustomProgressInt;

static function AwardDamage(KFSteamStatsAndAchievements KFStatsAndAchievements, int Amount) 
{
if( SRStatsBase(KFStatsAndAchievements)!=None && SRStatsBase(KFStatsAndAchievements).Rep!=None )
SRStatsBase(KFStatsAndAchievements).Rep.ProgressCu stomValue(Class'HeadshotProgress',Amount);
}

This is a class within a class. Do NOT ever do that. All class files should be in their own seperate class file.
 
Upvote 0
Right a little hint, highlight the line also as I had to copy it and find it myself. So...

Code:
static function AddCustomStats( ClientPerkRepLink Other )
{
Other.AddCustomValue(Class'HeadshotProgress');
}

This code here is your problem. Now due to you extending one of the other perks, this will not count as it's not in their code (seems that way). Also another thing I noticed is this:
Code:
class HeadshotProgress extends SRCustomProgressInt;

static function AwardDamage(KFSteamStatsAndAchievements KFStatsAndAchievements, int Amount) 
{
if( SRStatsBase(KFStatsAndAchievements)!=None && SRStatsBase(KFStatsAndAchievements).Rep!=None )
SRStatsBase(KFStatsAndAchievements).Rep.ProgressCu stomValue(Class'HeadshotProgress',Amount);
}

This is a class within a class. Do NOT ever do that. All class files should be in their own seperate class file.

Ahh I see. Noob error, sounds alot like me.
Thanks Flux :3
Sorry I suck at the whole Forum thing :(
 
Upvote 0
Problems

Problems

Okay
So I deleted the line Flux pointed out and it compiled. Yay!
A few more problems though:
1. If I changed SRVetSharpshooter to SRVeterancyTypes, my perk comes up at level 6, and doesn't display any information. Any idea on what could be causing this?
2. How do I add weapons to increase perk progression? Like Mac10 headshots to my class here.

Heres ALL of my code for the class, dunno what you would need for it:


Spoiler!
 
Upvote 0
How do I make it so that when I level I keep my old weapons and new weapons are added to my inventory(so at lvl 50 i have a lot of weapons to start with)

Code:
// Give Extra Items as Default
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{    
    if ( KFPRI.ClientVeteranSkillLevel >= 50 )
    KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M99SniperRifle", GetCostScaling(KFPRI, class'M99Pickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 40 )
    KFHumanPawn(P).CreateInventoryVeterancy("KFMod.SPSniperRifle", GetCostScaling(KFPRI, class'SPSniperPickup'));
    if ( KFPRI.ClientVeteranSkillLevel >= 30 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M14EBRBattleRifle", GetCostScaling(KFPRI, class'M14EBRPickup'));
    if ( KFPRI.ClientVeteranSkillLevel >= 20 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Crossbow", GetCostScaling(KFPRI, class'CrossbowPickup'));
    if ( KFPRI.ClientVeteranSkillLevel >= 10 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Winchester", GetCostScaling(KFPRI, class'WinchesterPickup'));
    if ( KFPRI.ClientVeteranSkillLevel >= 7 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.GoldenDualDeagle", GetCostScaling(KFPRI, class'GoldenDualDeaglePickup'));
    if ( KFPRI.ClientVeteranSkillLevel >= 6 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dual44Magnum", GetCostScaling(KFPRI, class'Dual44MagnumPickup'));
    if ( KFPRI.ClientVeteranSkillLevel >= 5 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
    if ( KFPRI.ClientVeteranSkillLevel >= 0 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));        
}
This is what I have but it just deletes the dualies on lvl 5 and replaces them with dualmk23
 
Upvote 0
That should look like this, adds new stuff to the old equipment instead of exchanging it.

Code:
// Give Extra Items as Default
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{    
    if ( KFPRI.ClientVeteranSkillLevel >= 50 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M99SniperRifle", GetCostScaling(KFPRI, class'M99Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.SPSniperRifle", GetCostScaling(KFPRI, class'SPSniperPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M14EBRBattleRifle", GetCostScaling(KFPRI, class'M14EBRPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Crossbow", GetCostScaling(KFPRI, class'CrossbowPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Winchester", GetCostScaling(KFPRI, class'WinchesterPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.GoldenDualDeagle", GetCostScaling(KFPRI, class'GoldenDualDeaglePickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dual44Magnum", GetCostScaling(KFPRI, class'Dual44MagnumPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 40 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.SPSniperRifle", GetCostScaling(KFPRI, class'SPSniperPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M14EBRBattleRifle", GetCostScaling(KFPRI, class'M14EBRPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Crossbow", GetCostScaling(KFPRI, class'CrossbowPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Winchester", GetCostScaling(KFPRI, class'WinchesterPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.GoldenDualDeagle", GetCostScaling(KFPRI, class'GoldenDualDeaglePickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dual44Magnum", GetCostScaling(KFPRI, class'Dual44MagnumPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 30 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M14EBRBattleRifle", GetCostScaling(KFPRI, class'M14EBRPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Crossbow", GetCostScaling(KFPRI, class'CrossbowPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Winchester", GetCostScaling(KFPRI, class'WinchesterPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.GoldenDualDeagle", GetCostScaling(KFPRI, class'GoldenDualDeaglePickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dual44Magnum", GetCostScaling(KFPRI, class'Dual44MagnumPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 20 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Crossbow", GetCostScaling(KFPRI, class'CrossbowPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Winchester", GetCostScaling(KFPRI, class'WinchesterPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.GoldenDualDeagle", GetCostScaling(KFPRI, class'GoldenDualDeaglePickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dual44Magnum", GetCostScaling(KFPRI, class'Dual44MagnumPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 10 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Winchester", GetCostScaling(KFPRI, class'WinchesterPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.GoldenDualDeagle", GetCostScaling(KFPRI, class'GoldenDualDeaglePickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dual44Magnum", GetCostScaling(KFPRI, class'Dual44MagnumPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 7 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.GoldenDualDeagle", GetCostScaling(KFPRI, class'GoldenDualDeaglePickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dual44Magnum", GetCostScaling(KFPRI, class'Dual44MagnumPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 6 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dual44Magnum", GetCostScaling(KFPRI, class'Dual44MagnumPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 5 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.DualMK23Pistol", GetCostScaling(KFPRI, class'DualMK23Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));    
    if ( KFPRI.ClientVeteranSkillLevel >= 0 )
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.Dualies", GetCostScaling(KFPRI, class'DualiesPickup'));        
}
 
Upvote 0