Adding a new stat:
StatsObject.uc
Keeps track of all stats and saves/retrieves them. There's a big list of int variables at the top, containing all the stats you're already familiar with. Add a new stat like "KnifeDamageStat".
Scroll down and you'll see GetSaveData wich lines up all stats for saving. Add your new stat like this:
Code:
Result = Result$","$KnifeDamageStat;
Go to SetSaveData and add the following code in the right order (The order is defined by where you added the DamageStat above in GetSaveData)
Code:
KnifeDamageStat = GetNextValue(S);
ServerStStats.uc
This code keeps track of all the "add something to the stats" functions. As well of wich stats should get replicated in the ClientPerkRepLink. Add a new function like this one:
Code:
function AddKnifeDamage(int Amount)
{
bHasChanged = true;
Rep.RKnifeDamageStat+=Amount;
if( MyStatsObject!=None )
MyStatsObject.KnifeDamageStat+=Amount;
DelayedStatCheck();
}
and update final function RepCopyStats, adding this line:
Code:
Rep.RKnifeDamageStat = MyStatsObject.KnifeDamageStat;
ClientPerkRepLink.uc
This code defines all the stats the client receives from the server. Add your new stat in the long list of R***Stats like this: RKnifeDamageStat. Scroll down to the replication and add it there aswell.
SrStatList.uc
Responsible for all the drawing in the "stats" tab in the menu.
Go to InitList and add your new stat. MY server uses a custom stats object so I have a different order:
Code:
StatProgress[9] = L.RKnifeDamageStat;
Go down to the defaultproperties and add a name, as well as increasing ItemCount by one.
To track your knife damage stat, you need to replace the Knife in the game with a new one that refers to new firing modes. These firing modes need a new hitDamageClass that looks like this:
Code:
class NewDamTypeKnife extends DamTypeKnife
abstract;
static function AwardDamage(KFSteamStatsAndAchievements KFStatsAndAchievements, int Amount)
{
ServerStStats(KFStatsAndAchievements).AddKnifeDamage(Amount);
}
defaultproperties
{
}
Adding a new perk:
Just write a new SRVeterancyTypes like this one:
Code:
class SRVetTank extends SRVeterancyTypes
abstract;
static function int GetPerkProgressInt( ClientPerkRepLink StatOther, out int FinalInt, byte CurLevel, byte ReqNum )
{
switch( CurLevel )
{
case 0:
FinalInt = 10000;
break;
case 1:
FinalInt = 25000;
break;
case 2:
FinalInt = 100000;
break;
case 3:
FinalInt = 500000;
break;
case 4:
FinalInt = 1500000;
break;
case 5:
FinalInt = 3500000;
break;
case 6:
FinalInt = 5500000;
break;
default:
if (CurLevel < 9)
FinalInt = 5500000 + GetDoubleScaling(CurLevel, 250000);
else if (CurLevel >= 9 && CurLevel < 19)
FinalInt = 11000000 + GetDoubleScaling(CurLevel, 500000);
else if (CurLevel >= 19)
FinalInt = 15000000 + GetDoubleScaling(CurLevel, 750000);
}
return Min(StatOther.RKnifeDamageStat, FinalInt);
}
static function int ReduceDamage(KFPlayerReplicationInfo KFPRI, KFPawn Injured, KFMonster DamageTaker, int InDamage, class<DamageType> DmgType)
{
return float(InDamage) * 0.85;
}
static function string GetCustomLevelInfo( byte Level )
{
local string S;
S = Default.CustomLevelInfo;
return S;
}
defaultproperties
{
CustomLevelInfo="15% less damage from enemy attacks"
Requirements(0)="Deal damage with the knife"
PerkIndex=4
OnHUDIcon=Texture'KillingFloorHUD.Perks.Perk_Berserker'
OnHUDGoldIcon=Texture'KillingFloor2HUD.Perk_Icons.Perk_Berserker_Gold'
VeterancyName="Tank"
}
And add it to your config file.