Perk class that defines the "Bullet Force" epic perk. It registers the perk metadata (name, icon, descriptions) and applies a multiplicative modifier to the player's BulletForce stat when refreshed.
using System;
using Sandbox;
[Perk( Rarity.Epic, locked: true, alwaysOfferDebug: false )]
public class PerkBulletForce : Perk
{
private enum Mod { BulletForce };
static PerkBulletForce()
{
Register<PerkBulletForce>(
name: "Bullet Force",
imagePath: "textures/icons/vector/bullet_force.png",
description: level => $"+{GetValue( level, Mod.BulletForce, true )}% bullet-icon knockback",
upgradeDescription: level => $"+{GetValue( level - 1, Mod.BulletForce, true )}%→{GetValue( level, Mod.BulletForce, true )}% bullet-icon knockback"
);
}
public override void Start()
{
base.Start();
}
public override void Refresh()
{
base.Refresh();
Player.Modify( this, PlayerStat.BulletForce, GetValue( Level, Mod.BulletForce ), ModifierType.Mult );
}
private static float GetValue( int level, Mod mod, bool isPercent = false )
{
switch ( mod )
{
case Mod.BulletForce:
default:
return isPercent
? 100f + 200f * level
: 1f + 1f + 2f * level;
}
}
}