• 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

This all depends on how you have setup your mod for your server. If you use Marco's ServerPerks, then you'll have to do some extending unless you have your own customised version and prefer to hard code it with the other stats.

Extending of ServerPerks (or your own):
[url]http://forums.tripwireinteractive.com/showpost.php?p=1068546&postcount=3[/URL]

Hard coding stats (if your own renamed ServerPerks version):
Look at files ClientRepLink.uc, ServerStStats.uc, StatsObject.uc and SRStatList.uc (I think that is it). They all are part of the creation of the custom stat you would like to make but the function for it would be set in ServerStStats so make sure you double check for the stats ready made and compare.

Any problems, contact me :)

Yep, nailed the above tutorial extending my own perks to keep the serverperks and serverperksmut packages standard, trying to accomplish things in my custom serverperksp package, renamed of course, but i think this one is serverside only from what i read.

The tutorial goes through a a stat that awards the damage, just not sure about how to go about making it incremental for each kill (or bSniperWeapon heasdshot kill in this exact case)

Haven't tried editing the base serverperks yet, but i should be able to extend on them as another package right?
 
Last edited:
Upvote 0
It will always record a successful head shot. If you want to record a head shot with a certain mob then just use a check.

In the perk.
Code:
static function AddCustomStats( ClientPerkRepLink Other )
{
	Other.AddCustomValue(Class'BigZedKill');
}


The Integer Count
Code:
class BigZedKill extends SRCustomProgressInt;

function NotifyPlayerKill( Pawn Killed, class<DamageType> damageType )
{
	if(( ZombieFleshPound(Killed)!=None || ZombieScrake(Killed)!=None ) && Default.bSniperWeapon )
		IncrementProgress(1);
}

defaultproperties
{
     ProgressName="Head Shots on the Big'en"
}

NOTE: Not tested the above. But give it ago.
 
Upvote 0
It will always record a successful head shot. If you want to record a head shot with a certain mob then just use a check.

In the perk.
Code:
static function AddCustomStats( ClientPerkRepLink Other )
{
	Other.AddCustomValue(Class'BigZedKill');
}


The Integer Count
Code:
class BigZedKill extends SRCustomProgressInt;

function NotifyPlayerKill( Pawn Killed, class<DamageType> damageType )
{
	if(( ZombieFleshPound(Killed)!=None || ZombieScrake(Killed)!=None ) && Default.bSniperWeapon )
		IncrementProgress(1);
}

defaultproperties
{
     ProgressName="Head Shots on the Big'en"
}

NOTE: Not tested the above. But give it ago.


Cheers Gartley,
Just had a try using the above code but get an error compiling due to this line

Code:
	if(( ZombieFleshPound(Killed)!=None || ZombieScrake(Killed)!=None ) && Default.bSniperWeapon )
Error, Bad or missing expression in parenthesis
 
Upvote 0
Cheers Gartley,
Just had a try using the above code but get an error compiling due to this line

Code:
    if(( ZombieFleshPound(Killed)!=None || ZombieScrake(Killed)!=None ) && Default.bSniperWeapon )
Error, Bad or missing expression in parenthesis

Try this
Code:
if( ZombieFleshPound(Killed)!=None || ZombieScrake(Killed)!=None && Default.bSniperWeapon )
and Whisky I want to contribute something agian, if someone wants to per say have a start weapon at a certain level then give them a different weapon after another, and agian after another level do something like this

Code:
// Give Extra Items as default
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{
    if ( KFPRI.ClientVeteranSkillLevel < 25 )
    {
        KFHumanPawn(P).CreateInventoryVeterancy("ForrestPerks.WTFEquipKatana", GetCostScaling(KFPRI,class'WTFEquipKatanaPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("ForrestPerks.IDRPGTurret", GetCostScaling(KFPRI, class'IDRPGTurret_Pickup'));
    }

    if ( KFPRI.ClientVeteranSkillLevel >= 25 && KFPRI.ClientVeteranSkillLevel < 50 )
    {
        P.ShieldStrength = 100;
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M99", GetCostScaling(KFPRI, class'M99Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("ForrestPerks.PTurret", GetCostScaling(KFPRI, class'PTurretPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("ForrestPerks.IDRPGTurret", GetCostScaling(KFPRI, class'IDRPGTurret_Pickup'));
    }
    if ( KFPRI.ClientVeteranSkillLevel >= 50 )
    {
        P.ShieldStrength = 100;
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M99", GetCostScaling(KFPRI, class'M99Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("ForrestPerks.SentryGun", GetCostScaling(KFPRI, class'SentryGunPickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("ForrestPerks.IDRPGTurret", GetCostScaling(KFPRI, class'IDRPGTurret_Pickup'));
        KFHumanPawn(P).CreateInventoryVeterancy("ForrestPerks.PTurret", GetCostScaling(KFPRI, class'PTurretPickup'));
    }
}
At any level below 25 it gives them a Katana and turret, at level 25-49 it gives them a Turret, Portal Turret, M99, and armor and finally at level 50 it gives them all the above and a Doom 3 Sentry

Here is a example of code to replace a weapon

Code:
// Give Extra Items as Default
static function AddDefaultInventory(KFPlayerReplicationInfo KFPRI, Pawn P)
{
    // If Level 24 or below, give them a M14EBR
    if ( KFPRI.ClientVeteranSkillLevel < 25 )
    {
        KFHumanPawn(P).CreateInventoryVeterancy("ForrestPerks.M14EBRBattleRifle", GetCostScaling(KFPRI, class'M14EBRPickup'));
    }

    // If Level 25 or above, give them armor, and a M99
    if ( KFPRI.ClientVeteranSkillLevel >= 25 )
    {
        P.ShieldStrength = 100;
        KFHumanPawn(P).CreateInventoryVeterancy("KFMod.M99SniperRifle", GetCostScaling(KFPRI, class'M99Pickup'));
    }
}
At level 24 and below it gives them a BattleRifle, and at 25+ it gives them a M99
 
Last edited:
Upvote 0
More correct HS kill detection would be:
Code:
function NotifyPlayerKill( Pawn Killed, class<DamageType> damageType )
{
	if( (ZombieFleshPound(Killed)!=None || ZombieScrake(Killed)!=None) && KFMonster(Killed).bDecapitated
	 && Class<KFWeaponDamageType>(damageType)!=None
	 && Class<KFWeaponDamageType>(damageType).Default.bSniperWeapon )
		IncrementProgress(1);
}
 
Upvote 0
How do i do this the tutorial is unclear

Follow the same section as adding in the G36C, try post #3 More specifically, part 3b. But you need to use the existing function for awarding commando damage and not a brand new custom function.

In your new DamType for the weapon:
Code:
static function AwardDamage(KFSteamStatsAndAchievements KFStatsAndAchievements, int Amount)
{
	KFStatsAndAchievements.AddBullpupDamage(Amount);
}


in your commando perk you'll need to refer to the new damtype
Code:
static function AddCustomStats( ClientPerkRepLink Other )
{
	Class'AK47Fire'.Default.DamageType = Class'DamTypeAK47AssaultRifleSYK';
}


Different issue,
I'm still having trouble compiling the custom headshot check :( does anyone have a similar check in place that they can compare it to, not sure what's causing the error. If anyone could help out still that would be great, not sure what i'm missing.

Marco's code:
Code:
function NotifyPlayerKill( Pawn Killed, class<DamageType> damageType )
{
	if( (ZombieFleshPound(Killed)!=None || ZombieScrake(Killed)!=None) && KFMonster(Killed).bDecapitated
	 && Class<KFWeaponDamageType>(damageType)!=None
	 && Class<KFWeaponDamageType>(damageType).Default.bSniperWeapon )
		IncrementProgress(1);
}

I'm still getting the Error, Bad or missing expression in parenthesis.
 
Last edited:
Upvote 0
i want to add the following weapons to a perk i created using tutorial one i added the weapons and the discount if on the Assault perk

How do i add the weapons damages to be the same damage as those of the normal commando perk to help me level ex. if i shoot with the bullpup i get assault rifle damage how to i make the new weapons i added to do the same damage as the bullpup does to level assault rifle damage. Heres my coding ive done so far. Please guys im a newbie when it comes to killing floor mutating

class GeneralsAssault extends SRVetCommando
abstract;
defaultproperties
{
VeterancyName="Assault Squadron"
}

#exec obj load file="FX-KFG36C.u"
#exec obj load file="AK74uMut.u"
#exec obj load file="AKC74Mut.u"
#exec obj load file="PKMMut.u"
#exec obj load file="ValMut.u"
#exec obj load file="KFPPSHMut.u"
#exec obj load file="Saiga12cMut.u"
// Change the cost of particular items
static function float GetCostScaling(KFPlayerReplicationInfo KFPRI, class<Pickup> Item)
{
if (( Item == class'G36CPickup' ) ||
( Item == class'AK74uPickup' ) ||
( Item == class'AKC74Pickup' ) ||
( Item == class'PKMPickup' ) ||
( Item == class'VALPickup' ) ||
( Item == class'PPSHPickup' ) ||
( Item == class'Saiga12cPickup' ))
{
return 0.9 - fmin(0.10 * float(KFPRI.ClientVeteranSkillLevel),0.6f); // Up to 70% discount on Assault Rifles
}

return super.GetCostScaling(KFPRI, Item);
 
Upvote 0
i want to add the following weapons to a perk i created using tutorial one i added the weapons and the discount if on the Assault perk

How do i add the weapons damages to be the same damage as those of the normal commando perk to help me level ex. if i shoot with the bullpup i get assault rifle damage how to i make the new weapons i added to do the same damage as the bullpup does to level assault rifle damage. Heres my coding ive done so far. Please guys im a newbie when it comes to killing floor mutating

Go in the Commando perk, find the code relating to damage with commando type weapons.

Copy the code into your new perk, adjust the weapon classes for the required weapons.
 
Upvote 0
Still cant seem to get it working

static function int AddDamage(KFPlayerReplicationInfo KFPRI, KFMonster Injured, KFPawn DamageTaker, int InDamage, class<DamageType> DmgType)
{
if ( DmgType == class'DamTypeBullpup' || DmgType == class'DamTypeAK47AssaultRifle'
|| DmgType == class'DamTypeSCARMK17AssaultRifle' || DmgType == class'DamTypeM4AssaultRifle' || DmgType == class'DamageTypePortalTurret' )
{
if ( KFPRI.ClientVeteranSkillLevel == 0 )
return float(InDamage) * 1.05;
return float(InDamage) * (1.00 + (0.10 * float(Min(KFPRI.ClientVeteranSkillLevel, 5)))); // Up to 50% increase in Damage with Bullpup
}
return InDamage;
}

Copied this to my new perk from the commando perk and edited

The new damagetype for the turret

class DamageTypePortalTurret extends KFWeaponDamageType
abstract;

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


defaultproperties
{
DeathString="%o was shot by %k."
FemaleSuicide="%o was shot."
MaleSuicide="%o was shot again."
bArmorStops=False
bAlwaysGibs=True
bLocationalHit=False
GibPerterbation=1.000000
bCheckForHeadShots=False
}

The Progress for the turret
class PTurretProgress extends SRCustomProgressInt;

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

defaultproperties
{
ProgressName= "Portal Turret Damage"
}

Do i have to assign the portal turret to use the new damage type i created and if i do how to i do this. Im using server perks v5.51 and im using marco's portal turret.
Trying to get it to add damage to the commandos perk progression
 
Upvote 0
Still cant seem to get it working


Do i have to assign the portal turret to use the new damage type i created and if i do how to i do this. Im using server perks v5.51 and im using marco's portal turret.
Trying to get it to add damage to the commandos perk progression

Easier way, just add this into your damage type for the turret, It doesnt need its own custom stat, since your using the existing commando weapon damage one.

Code:
static function AwardDamage(KFSteamStatsAndAchievements KFStatsAndAchievements, int Amount)
{
	KFStatsAndAchievements.AddBullpupDamage(Amount);
}


Check out #3b of Gartley's post to bind the new damage type to the weapon's fireclass
http://forums.tripwireinteractive.com/showpost.php?p=1068546&postcount=3
 
Upvote 0
I think that's all of for now. If there are any other bits and pieces I'll try and answer what I can but remember the answers are all out there. You just need to look for them. ;)

Gartley! i need ur help! here my pictures,
Note: Im copy and paste ur codes to *.txt file and change it to *.uc
Also: Im using ServerPerksV6

http://imageshack.us/photo/my-images/708/picture1nxk.png/

http://imageshack.us/photo/my-images/832/picture2bee.png/

http://imageshack.us/photo/my-images/232/picture3eo.png/

http://imageshack.us/photo/my-images/525/picture4en.png/

http://imageshack.us/photo/my-images/844/picture5jb.png/

I got failed to load problem :/
 
Last edited:
Upvote 0

Have you compiled the new perk mutator? It needs to be compiled first.
 
Upvote 0