A Mythic rarity perk class that can start a ground fire when the player dashes. It registers UI metadata, configures highlight visuals, and on dash has a chance to spawn a fire via Manager RPCs, play a sound, highlight the perk and trigger a dodge/duck RPC on the player.
using System;
using Sandbox;
[Perk( Rarity.Mythic, alwaysOfferDebug: false, IncludedCategories = new[] { PerkCategory.Aoe, PerkCategory.Fire })]
public class PerkDashFire : Perk
{
private enum Mod { FireChance };
static PerkDashFire()
{
Register<PerkDashFire>(
name: "Rug Burn",
imagePath: "textures/icons/vector/dash_fire.png",
description: level => $"{(int)GetValue( level, Mod.FireChance, true )}% chance to\nstart a fire when you dash",
upgradeDescription: level => $"{(int)GetValue( level - 1, Mod.FireChance, true )}%→{(int)GetValue( level, Mod.FireChance, true )}% chance to\nstart a fire when you dash"
);
}
public override void Start()
{
base.Start();
HighlightColor = new Color( 1f, 1f, 1f );
HighlightDuration = 0.5f;
HighlightOpacity = 1f;
}
public override void Refresh()
{
base.Refresh();
}
public override void OnDashStartedEarly( Vector2 dir )
{
base.OnDashStartedEarly( dir );
if ( Game.Random.Float( 0f, 1f ) < GetValue( Level, Mod.FireChance ) )
{
Manager.Instance.SpawnFireGroundRpc(
Player.Position2D,
Player,
enemySource: null,
enemyType: EnemyType.None,
damage: Player.Stats[PlayerStat.FireDamage],
lifetime: Player.Stats[PlayerStat.FireLifetime],
spreadChance: Player.Stats[PlayerStat.FireSpreadChance],
canStack: Player.Stats[PlayerStat.FireDmgStack] > 0f,
scale: Player.Stats[PlayerStat.RadiusMultiplier],
colorA: Color.Red,
colorB: Color.Yellow
);
Manager.Instance.PlaySfxNearbyRpc( "burn", Player.Position2D, pitch: Game.Random.Float( 0.95f, 1f ), volume: 0.9f, maxDist: 300f );
Highlight();
Player.DodgeDuckRpc( dir, time: Game.Random.Float( 0.15f, 0.2f ) );
}
}
private static float GetValue( int level, Mod mod, bool isPercent = false )
{
switch ( mod )
{
case Mod.FireChance:
default:
return isPercent
? 25f + 25f * level
: 0.25f + 0.25f * level;
}
}
}