feat: the cost warning says what stage 9 measured (D306)
All checks were successful
PR Checks / plugin-checks (pull_request) Successful in 6s

Stage 9 measured the released NPC on both frameworks (6000 map): about 3 ms of
median frame per 100 idle while a player keeps them awake, 0.5 ms once they
sleep with nobody near, and 9 ms per 100 fighting, with each NPC reacting about
every 3 s under Rust's shared AI budget. The warning now says idle twice
(awake and asleep) and uses those figures, the worst of the two rigs rounded up.
The awake-idle overhead over the bare swap is runicnpc-rust#13.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E14m6SuuY6i1vASFeGDBeY
This commit is contained in:
2026-10-06 21:33:49 -05:00
parent 6a384d0a28
commit b5e7ecc4ed

View File

@@ -3661,9 +3661,11 @@ namespace Oxide.Plugins
#region The cost warning (D227) #region The cost warning (D227)
/// <summary> /// <summary>
/// What <paramref name="total"/> NPCs cost the server, from stage 1's measurements on both /// What <paramref name="total"/> NPCs cost the server, from stage 9's measurements of the
/// frameworks (PLAN.md §9, stage 1, Q5). The rig ran about 50 fps empty, so the warning /// released NPC on both frameworks (PLAN.md §9, stage 9, D306; stage 1, Q5, first): the worst
/// says what NPCs ADD to a frame, not an fps. /// of the two rigs, rounded up. Idle is said twice, because an NPC with no player within its
/// sleep distance sleeps (D235) and costs a sixth of an awake one. The warning says what NPCs
/// ADD to a frame, not an fps, since a server's own frame time varies far more than that.
/// </summary> /// </summary>
private static string CostWarning(int total) private static string CostWarning(int total)
{ {
@@ -3672,9 +3674,10 @@ namespace Oxide.Plugins
float hundreds = total / 100f; float hundreds = total / 100f;
string estimate = total > 100 ? " (measured up to 100; beyond that this is an estimate)" : ""; string estimate = total > 100 ? " (measured up to 100; beyond that this is an estimate)" : "";
return $"RunicNPC: {total} NPC(s) on this server{estimate}. Measured on a test server, they add about " + return $"RunicNPC: {total} NPC(s) on this server{estimate}. Measured on a test server, they add about " +
$"{Mathf.Max(0.1f, hundreds * 1.5f):0.#} ms to every server frame while idle. If all fight at once they add about " + $"{Mathf.Max(0.1f, hundreds * 3f):0.#} ms to every server frame while idle with a player near enough to wake them, " +
$"{hundreds * 5f:0.#} ms, and Rust's shared 2 ms AI budget then lets each react only every " + $"and about {Mathf.Max(0.1f, hundreds * 0.5f):0.#} ms once they sleep with nobody near. If all fight at once they add about " +
$"{Mathf.Max(0.3f, hundreds * 2.5f):0.#} s. Fighting other NPCs (a faction setting) was measured to cost about " + $"{hundreds * 9f:0.#} ms, and Rust's shared 2 ms AI budget then lets each react only every " +
$"{Mathf.Max(0.3f, hundreds * 3f):0.#} s. Fighting other NPCs (a faction setting) was measured to cost about " +
$"what fighting players does; on a map whose own AI is busy, each then reacts only every " + $"what fighting players does; on a map whose own AI is busy, each then reacts only every " +
$"{Mathf.Max(0.5f, hundreds * 7f):0.#} s."; $"{Mathf.Max(0.5f, hundreds * 7f):0.#} s.";
} }