A perk class 'PerkFireBullet' that adds a chance for bullets to ignite targets. It registers metadata (name, icon, descriptions) and on Refresh applies a modifier to the player's ShootFireIgniteChance stat, with values scaled by perk level.
using System;
using Sandbox;
[Perk( Rarity.Common, alwaysOfferDebug: false, IncludedCategories = new[] { PerkCategory.Fire })]
public class PerkFireBullet : Perk
{
private enum Mod { ShootFireIgniteChance };
static PerkFireBullet()
{
Register<PerkFireBullet>(
name: "Burning Bullets",
imagePath: "textures/icons/vector/fire_bullet.png",
description: level => $"{(int)GetValue( level, Mod.ShootFireIgniteChance, true )}% chance for bullet-icon to ignite",
upgradeDescription: level => $"{(int)GetValue( level - 1, Mod.ShootFireIgniteChance, true )}%→{(int)GetValue( level, Mod.ShootFireIgniteChance, true )}% chance for\nbullet-icon to ignite"
);
}
public override void Start()
{
base.Start();
}
public override void Refresh()
{
base.Refresh();
Player.Modify( this, PlayerStat.ShootFireIgniteChance, GetValue( Level, Mod.ShootFireIgniteChance ), ModifierType.Add );
}
private static float GetValue( int level, Mod mod, bool isPercent = false )
{
switch ( mod )
{
case Mod.ShootFireIgniteChance:
default:
return isPercent
? 3f + 6f * level
: 0.03f + 0.06f * level;
}
}
}