codeAPI Reference

s&box ScientistNpc: Fear-based NPC

calendar_today May 12, 2026 schedule ~1 min read person PatrickJr verified 50

ScientistNpc Class API Reference

ScientistNpc is an NPC with a fear system that flees when damaged. When not afraid, wanders or inspects nearby props. Implements IDamageable.

Type Signature

CSHARP
public class ScientistNpc : Npc, Component.IDamageable
{
    [Property, ClientEditable, Range(1, 100), Sync] public float Health { get; set; } = 100f;
    public float AfraidLevel { get; }

    [Property, Group("Balance")] private float FearGracePeriod { get; set; } = 3f;
    [Property, Group("Balance")] private float FearDecayRate { get; set; } = 0.15f;
}

Properties

Behavior

Fear System:

  • Fear escalates with each hit (damage / 50, clamped to 1)

  • Fear stays at peak for grace period, then decays

  • When afraid, flees from attacker

  • When not afraid, wanders or inspects nearby props

IDamageable Implementation

Usage

CSHARP
// Create a scientist NPC
var npc = GameObject.Components.Create<ScientistNpc>();
npc.Health = 50f;

Notes

  • Uses schedules: ScientistFleeSchedule, ScientistWanderSchedule, ScientistInspectPropSchedule, ScientistIdleSchedule
  • Tracks stats for scares and kills
  • Finds nearby props within 2048 units to inspect
  • Fear decays over time after grace period
Was this helpful?