• 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] Making Custom Perk ScrN-Compatible

poosh

Grizzled Veteran
Jan 6, 2011
3,389
324
Recently I'm receiving more and more requests about this, so I decided to write a tutorial.

The following steps allow your perk to benefit of all ScrN features, such as split perk progression to experience and bonus levels, support custom weapons by adding perk bonuses via config file, configurable spawn inventory etc.

Note that it will make your perk permanently linked to ScrnBalanceSrv, so it won't be possible to use on pure ServerPerks server, without ScrnBalance mutator.

I assume that you already have built the perk, which extends SRVeterancyTypes. Or at least you know how to do it. If not, please read Awesome Gartley's Tutorial first.

  1. Add ScrnBalanceSrv to EditPackages in KillingFloor.ini before the package with your perk.
  2. Extend perk class from ScrnVeterancyTypes.
  3. Replace all occurrences of "KFPRI.ClientVeteranSkillLevel" with "GetClientVeteranSkillLevel(KFPRI)". Use replace feature of your text editor (try Ctrl+H or Ctrl+R) to do it quickly.
  4. Add ClassIsInArray() to each function to enable custom weapon support. List of bonus arrays:
    • PerkedWeapons - weapon class is added to it, if server admin adds "W" bonus switch. Used for Reload, Recoil and FireRate bonuses.
    • PerkedDamTypes - damage type is added to it, if server admin adds "P" or "S" bonus switches. Used for damage bonus.
    • PerkedPickups - pickup class is added to it, if server admin adds "$" bonus switch. Used for discounts.
    • PerkedAmmo - ammo class is added to it, if server admin adds "A" or "B" bonus switches. Used for various ammo bonuses (total ammo, magazine size etc.)
    • SpecialWeapons - pickup class is added to it, if server admin adds "*" bonus switch.
  5. Delete AddDefaultInventory() function. This enables configurable SpawnInventory.
  6. Replace functions:
    GetMagCapacityMod() with GetMagCapacityModStatic(),
    GetReloadSpeedModifier() with GetReloadSpeedModifierStatic(),
    GetFireSpeedMod() with GetFireSpeedModStatic()
    for correct weapon stat display in the Trader Menu. The only difference between those functions is that they take "class<KFWeapon>" instead of "KFWeapon" argument, so they can be used without weapon instances.
  7. Assign DefaultDamageType and DefaultDamageTypeNoBonus in defaultproperties. Those damage types are used to allow server admin moving custom weapons to your perk. You will probably need to create a new damage type class for DefaultDamageTypeNoBonus, which allows perk progression, but doesn't add damage bonus.
  8. Fill OnHUDIcons array in defaultproperties. You can design own HUD icon for each 5 levels, or just use color modifiers.


As an example I'm posting the code of ScrnVetBruteGunnerPNW - special ScrN Edition of original Guardianknight's perk:

Spoiler!


And default damage types:
Spoiler!


Spoiler!
 
Last edited: