FBC: NIGHT SHIFT - added a 20-minute corruption curve, a paced director and a HUD clock

This commit is contained in:
dandovlatov 2026-11-24 03:40:23 +04:00
parent f4bbce8066
commit b9051e8f96
9 changed files with 194 additions and 90 deletions

View file

@ -142,7 +142,7 @@ structure, taken deliberately:
increments `floors_` when a floor's Threshold Key is taken (§7), so the RoR2 increments `floors_` when a floor's Threshold Key is taken (§7), so the RoR2
exponential loops map onto sectors of the run. exponential loops map onto sectors of the run.
### Tier ladder (HUD: "CONTAINMENT STATUS" gauge, top right) ### Tier ladder (HUD: "CONTAINMENT STATUS" table, top right — shift clock, tier, countdowns and gauge)
| Tier | Label | Unlocks | | Tier | Label | Unlocks |
|---|---|---| |---|---|---|
@ -158,16 +158,31 @@ structure, taken deliberately:
Board is... monitoring your situation."), red flash, chanting layer intensifies. Board is... monitoring your situation."), red flash, chanting layer intensifies.
RoR2 makes difficulty theatrical; so do we. RoR2 makes difficulty theatrical; so do we.
### Current tuning (M2 credit Director; evolves at M6) ### Current tuning (M6 progression pass — the 20-minute hardcore curve)
c(t) = 0.05 + 0.0045 * t; tier = c / 0.25 (one tier per ~55s). c(t) = 0.05 + 0.0016 * t + 0.10 * floors_cleared; tier = c / 0.25.
Enemy HP x (1 + 1.1c), contact damage x (1 + 0.55c). One tier per ~2.6 min, TOTAL RESONANCE at ~20 min of untouched play. Floors
Director income = 10 + 110c credits/sec; spawn cards: Mold Spore 6 (t>15s), still jump the clock (RoR2 stage difficulty) — clearing one shaves about a
Hiss Staff 10, Hiss Brute 30 (t>40s). "Too cheap" rule: affordable cards below minute off the run, which is the greed-vs-clock trade.
35% of the bank are skipped; a bank above 2x the priciest card is spent mostly
on heavies (the RoR2 "director saved up" moment, released as a burst whenever Enemy HP x (1 + 1.1c), contact damage x (1 + 0.65c), speed x (0.75 + 0.4c).
the horde thins). Credit cap 250. Enemy cap 260. Speed and damage are re-read every tick, so the *whole* horde gets faster and
Contact hits carry a 0.5 s global i-frame so swarms cannot burst the guard down. deadlier as c rises, not only new spawns; the 0.75 base makes the opening Hiss
sluggish next to the 7.5 m/s guard.
Director income = 4 + 14c + 50c^2 credits/sec (cap 240). The quadratic term is
what keeps the first minutes quiet and the last minutes a hunt. Spawn attempts
every 1.5/(1 + 5c) s (floor 0.10 s). Cards: Hiss Staff 9 (t>0), Hiss Ghost 7
(t>25 s), Mold Spore 5 (t>90 s), Hiss Brute 24 (t>180 s). Card rolls are
weighted by cost^(0.3 + 0.65c) — cheap mobs early, heavies late; cards below
25% of the bank are skipped ("too cheap"), and a bank above 92% of the cap is
released as a 3-card squad (the RoR2 "director saved up" beat). Enemy cap 260;
contact hits keep the 0.5 s global i-frame so swarms cannot burst the guard down.
Simulated ramp with no floor clears: ~0.7 spawns/s at 0:00, ~1.6/s at 2:00,
~2.5/s at 5:00, ~4/s at 10:00, ~6.7/s at 20:00. The HUD table exposes the
shift clock plus live NEXT TIER and CASCADE IN countdowns so the player can
read the clock instead of only feeling it.
## 4. Weapons — Objects of Power (auto-fire when enabled; levels + evolutions each) ## 4. Weapons — Objects of Power (auto-fire when enabled; levels + evolutions each)

View file

@ -1,5 +1,7 @@
#include "game/corruption.hpp" #include "game/corruption.hpp"
#include <cmath>
namespace { namespace {
constexpr int kTierCount = 9; constexpr int kTierCount = 9;
const char* kTierNames[kTierCount] = { const char* kTierNames[kTierCount] = {
@ -23,7 +25,25 @@ int Corruption::tier() const {
const char* Corruption::tier_name() const { return kTierNames[tier()]; } const char* Corruption::tier_name() const { return kTierNames[tier()]; }
float Corruption::tier_progress() const { float Corruption::tier_progress() const {
if (tier() >= kTierCount - 1) return 1.0f;
const float p = (value() / config_.tier_width) const float p = (value() / config_.tier_width)
- static_cast<float>(static_cast<int>(value() / config_.tier_width)); - static_cast<float>(static_cast<int>(value() / config_.tier_width));
return p < 0.0f ? 0.0f : (p > 1.0f ? 1.0f : p); return p < 0.0f ? 0.0f : (p > 1.0f ? 1.0f : p);
} }
// Countdowns are rate estimates at the current growth pace; a floor clear
// still jumps the clock early, which is the greed-vs-clock trade.
float Corruption::seconds_to_next_tier() const {
if (tier() >= kTierCount - 1) return 0.0f;
const float v = value();
const float next = config_.tier_width
* (std::floor(v / config_.tier_width) + 1.0f);
const float remaining = next - v;
return remaining / config_.growth_per_second;
}
float Corruption::seconds_to_max_tier() const {
const float target = config_.tier_width * static_cast<float>(kTierCount - 1);
const float remaining = target - value();
return remaining <= 0.0f ? 0.0f : remaining / config_.growth_per_second;
}

View file

@ -5,12 +5,17 @@
// See docs/GAME_DESIGN.md section 3. // See docs/GAME_DESIGN.md section 3.
struct CorruptionConfig { struct CorruptionConfig {
float base = 0.05f; float base = 0.05f;
float growth_per_second = 0.0045f; // ~one tier per 55 s // Tuned so a full hardcore run reaches TOTAL RESONANCE at ~20 min of play:
float jump_per_floor = 0.35f; // RoR2 jumps difficulty on env completion (M3+) // 0.25 per tier / 0.0016 per second = one tier every 156 s.
float growth_per_second = 0.0016f;
// Clearing a floor still jumps the clock (RoR2 stage difficulty), but the
// jump is small enough that speeding through floors shaves ~1 min, not 5.
float jump_per_floor = 0.10f;
float tier_width = 0.25f; float tier_width = 0.25f;
float hp_per_point = 1.1f; // enemy hp x (1 + hp_per_point * c) float hp_per_point = 1.1f; // enemy hp x (1 + hp_per_point * c)
float damage_per_point = 0.55f; // enemy damage x (1 + damage_per_point * c) float damage_per_point = 0.65f; // enemy damage x (1 + damage_per_point * c)
float spawn_rate_per_point = 2.2f; // spawn interval / (1 + spawn_rate_per_point * c) float speed_base = 0.75f; // the first minutes are deliberately sluggish
float speed_per_point = 0.40f; // ~1.55x at TOTAL RESONANCE
}; };
class Corruption { class Corruption {
@ -18,7 +23,7 @@ public:
explicit Corruption(const CorruptionConfig& config = {}) : config_(config) {} explicit Corruption(const CorruptionConfig& config = {}) : config_(config) {}
void update(float dt) { time_ += dt; } void update(float dt) { time_ += dt; }
void floor_cleared() { floors_ += 1; } // M3 hook: threshold door taken void floor_cleared() { floors_ += 1; } // threshold door taken
float value() const { float value() const {
return config_.base + config_.growth_per_second * time_ return config_.base + config_.growth_per_second * time_
@ -28,8 +33,10 @@ public:
const char* tier_name() const; const char* tier_name() const;
float enemy_hp_mult() const { return 1.0f + config_.hp_per_point * value(); } float enemy_hp_mult() const { return 1.0f + config_.hp_per_point * value(); }
float enemy_damage_mult() const { return 1.0f + config_.damage_per_point * value(); } float enemy_damage_mult() const { return 1.0f + config_.damage_per_point * value(); }
float spawn_rate_mult() const { return 1.0f + config_.spawn_rate_per_point * value(); } float enemy_speed_mult() const { return config_.speed_base + config_.speed_per_point * value(); }
float tier_progress() const; // 0..1 progress toward the next tier float tier_progress() const; // 0..1 progress toward the next tier
float seconds_to_next_tier() const;
float seconds_to_max_tier() const;
private: private:
CorruptionConfig config_; CorruptionConfig config_;

View file

@ -7,59 +7,83 @@
namespace { namespace {
constexpr SpawnCard kCards[] = { constexpr SpawnCard kCards[] = {
{EnemyType::MoldSpore, 6.0f, 15.0f}, {EnemyType::HissStaff, 9.0f, 0.0f}, // slow baseline floater
{EnemyType::HissStaff, 10.0f, 0.0f}, {EnemyType::HissGhost, 7.0f, 25.0f}, // medium chaser
{EnemyType::HissGhost, 8.0f, 0.0f}, {EnemyType::MoldSpore, 5.0f, 90.0f}, // fast swarm, held back for the calm opening
{EnemyType::HissBrute, 30.0f, 40.0f}, {EnemyType::HissBrute, 24.0f, 180.0f}, // heavy, arrives once the run is warm
}; };
constexpr int kCardCount = sizeof(kCards) / sizeof(kCards[0]);
} // namespace } // namespace
void Director::update(float dt, const Corruption& corruption, float run_time, float Director::spawn_interval(float corruption) const {
const Player& player, EnemySystem& enemies, Rng& rng, const float interval = config_.spawn_interval_base
int max_enemies, const Floor& floor) { / (1.0f + config_.spawn_interval_decay * corruption);
credits_ += (config_.base_income return interval < config_.spawn_interval_min ? config_.spawn_interval_min : interval;
+ config_.income_per_corruption * corruption.value()) * dt; }
if (credits_ > config_.credit_cap) credits_ = config_.credit_cap;
// Most expensive unlocked card - the save-up-for-the-big-one target. const SpawnCard* Director::pick_card(float corruption, float run_time, Rng& rng) const {
float priciest = 0.0f; const SpawnCard* affordable[kCardCount] = {};
for (const SpawnCard& card : kCards) { int affordable_count = 0;
if (run_time >= card.min_time && card.cost > priciest) priciest = card.cost; for (int i = 0; i < kCardCount; ++i) {
if (run_time >= kCards[i].min_time && kCards[i].cost <= credits_) {
affordable[affordable_count++] = &kCards[i];
}
}
if (affordable_count == 0) return nullptr;
// "Too cheap": when the bank is fat, trash cards are filtered out. If the
// bank is so fat that nothing clears the bar, spend it anyway.
const SpawnCard* candidates[kCardCount] = {};
int candidate_count = 0;
for (int i = 0; i < affordable_count; ++i) {
if (affordable[i]->cost >= credits_ * config_.too_cheap_fraction) {
candidates[candidate_count++] = affordable[i];
}
}
if (candidate_count == 0) {
for (int i = 0; i < affordable_count; ++i) candidates[candidate_count++] = affordable[i];
} }
// Spawn loop: spend the bank down, one card per iteration. // Cost-weighted draw: early on every card is roughly equally likely; as
for (int guard = 0; guard < 32; ++guard) { // corruption climbs, the expensive heavies take over the roll. This is the
if (enemies.alive_count() >= max_enemies) return; // smooth version of RoR2's "the director stops wasting budget on grunts".
const float preference = config_.cost_preference_base
+ config_.cost_preference_per_corruption * corruption;
float weights[kCardCount] = {};
float total = 0.0f;
for (int i = 0; i < candidate_count; ++i) {
weights[i] = std::pow(candidates[i]->cost, preference);
total += weights[i];
}
float roll = rng.next_float() * total;
for (int i = 0; i < candidate_count; ++i) {
roll -= weights[i];
if (roll <= 0.0f) return candidates[i];
}
return candidates[candidate_count - 1];
}
const SpawnCard* pick = nullptr; void Director::update(float dt, const Corruption& corruption, float run_time,
const Player& player, EnemySystem& enemies, Rng& rng,
int max_enemies, const Floor& floor) {
const float c = corruption.value();
credits_ += (config_.base_income
+ config_.income_per_corruption * c
+ config_.income_per_corruption_sq * c * c) * dt;
if (credits_ > config_.credit_cap) credits_ = config_.credit_cap;
const bool rich_bank = priciest > 0.0f spawn_timer_ -= dt;
&& credits_ >= config_.elite_bank_factor * priciest; if (spawn_timer_ > 0.0f) return;
if (rich_bank && rng.next_float() < config_.elite_bias) { spawn_timer_ = spawn_interval(c);
// A big bank is rarely spent on trash: the director sends the heavy.
for (const SpawnCard& card : kCards) {
if (run_time >= card.min_time && card.cost == priciest) pick = &card;
}
}
if (pick == nullptr) {
// Normal case: affordable cards, weighted away from too-cheap ones.
const SpawnCard* candidates[4] = {};
const SpawnCard* cheapest = nullptr;
int candidate_count = 0;
for (const SpawnCard& card : kCards) {
if (run_time < card.min_time || card.cost > credits_) continue;
if (cheapest == nullptr || card.cost < cheapest->cost) cheapest = &card;
if (card.cost >= credits_ * config_.too_cheap_fraction) {
candidates[candidate_count++] = &card;
}
}
if (cheapest == nullptr) return; // can't afford anything yet
pick = candidate_count > 0 ? candidates[rng.range_int(0, candidate_count - 1)]
: cheapest;
}
// A full bank releases a small squad instead of trickling away: the RoR2
// "the director saved up" beat, now actually reachable with the cadence.
const bool squad = credits_ >= config_.credit_cap * config_.burst_fraction;
const int attempts = squad ? config_.burst_count : 1;
for (int i = 0; i < attempts && enemies.alive_count() < max_enemies; ++i) {
const SpawnCard* pick = pick_card(c, run_time, rng);
if (pick == nullptr) break;
const Vec2 pos = floor.spawn_near(player.pos, rng, const Vec2 pos = floor.spawn_near(player.pos, rng,
config_.spawn_radius_min, config_.spawn_radius_min,
config_.spawn_radius_max); config_.spawn_radius_max);

View file

@ -7,10 +7,12 @@
// RoR2 combat director, verbatim structure: // RoR2 combat director, verbatim structure:
// - credits accrue over time, income scaled by corruption // - credits accrue over time, income scaled by corruption
// - spawn cards cost credits (elites cost far more) // - spawn cards cost credits (heavies cost far more)
// - the "too cheap" rule: don't spend a banked war chest on trash mobs; // - the "too cheap" rule: don't spend a fat bank on trash; save it
// save for big threats. This is what turns a horde into a hunt. // - a banked war chest is released as a short squad when it fills
// - when the player thins the horde, banked credits release as a burst. // Quantity is gated twice: income (quadratic in corruption) and a spawn
// cadence that shortens as the House decays. This keeps the first minutes
// quiet while still ending in a genuine horde.
struct SpawnCard { struct SpawnCard {
EnemyType type; EnemyType type;
float cost; float cost;
@ -18,12 +20,18 @@ struct SpawnCard {
}; };
struct DirectorConfig { struct DirectorConfig {
float base_income = 10.0f; float base_income = 4.0f;
float income_per_corruption = 110.0f; float income_per_corruption = 14.0f;
float too_cheap_fraction = 0.35f; // card must cost >= this fraction of the bank float income_per_corruption_sq = 50.0f; // late-run quantity explosion
float elite_bank_factor = 2.0f; // bank above this x priciest card = heavy bias float spawn_interval_base = 1.5f; // seconds between spawn attempts at c=0
float elite_bias = 0.7f; // P(heavy) when the bank is rich float spawn_interval_decay = 5.0f; // interval = base / (1 + decay * c)
float credit_cap = 250.0f; // burst budget when the horde thins float spawn_interval_min = 0.10f;
float too_cheap_fraction = 0.25f; // cost must clear this share of the bank
float cost_preference_base = 0.30f; // card weight = cost ^ preference
float cost_preference_per_corruption = 0.65f;
float burst_fraction = 0.92f; // bank this full -> release a squad
int burst_count = 3; // cards in that squad
float credit_cap = 240.0f;
float spawn_radius_min = 22.0f; float spawn_radius_min = 22.0f;
float spawn_radius_max = 34.0f; float spawn_radius_max = 34.0f;
}; };
@ -39,6 +47,10 @@ public:
float credits() const { return credits_; } float credits() const { return credits_; }
private: private:
const SpawnCard* pick_card(float corruption, float run_time, Rng& rng) const;
float spawn_interval(float corruption) const;
DirectorConfig config_; DirectorConfig config_;
float credits_ = 0.0f; float credits_ = 0.0f;
float spawn_timer_ = 0.0f;
}; };

View file

@ -32,7 +32,7 @@ void EnemySystem::spawn(EnemyType type, Vec2 pos, const Corruption& corruption)
e.pos = pos; e.pos = pos;
e.max_hp = def.hp * corruption.enemy_hp_mult(); e.max_hp = def.hp * corruption.enemy_hp_mult();
e.hp = e.max_hp; e.hp = e.max_hp;
e.speed = def.speed; e.speed = def.speed * corruption.enemy_speed_mult();
e.contact_damage = def.contact_damage * corruption.enemy_damage_mult(); e.contact_damage = def.contact_damage * corruption.enemy_damage_mult();
e.radius = def.radius; e.radius = def.radius;
e.bob_phase = pos.x * 0.7f + pos.y * 0.3f; e.bob_phase = pos.x * 0.7f + pos.y * 0.3f;
@ -41,7 +41,8 @@ void EnemySystem::spawn(EnemyType type, Vec2 pos, const Corruption& corruption)
} }
void EnemySystem::update(float dt, Player& player, BuffSystem& buff_system, void EnemySystem::update(float dt, Player& player, BuffSystem& buff_system,
EventQueue& events, const Floor& floor) { EventQueue& events, const Floor& floor,
const Corruption& corruption) {
const std::size_t count = enemies.size(); const std::size_t count = enemies.size();
if (count == 0) return; if (count == 0) return;
@ -55,7 +56,9 @@ void EnemySystem::update(float dt, Player& player, BuffSystem& buff_system,
Enemy& e = enemies[i]; Enemy& e = enemies[i];
const EnemyMods mods = buff_system.enemy_mods(static_cast<int>(i)); const EnemyMods mods = buff_system.enemy_mods(static_cast<int>(i));
e.mods = mods; e.mods = mods;
e.speed = enemy_def(e.type).speed * mods.speed_mult; const EnemyDef& def = enemy_def(e.type);
e.speed = def.speed * corruption.enemy_speed_mult() * mods.speed_mult;
e.contact_damage = def.contact_damage * corruption.enemy_damage_mult();
// Player-channel Dot: nearby enemies deal damage to the player. // Player-channel Dot: nearby enemies deal damage to the player.
const float dist = length(e.pos - player.pos); const float dist = length(e.pos - player.pos);

View file

@ -40,7 +40,9 @@ struct EnemySystem {
void clear(); void clear();
void spawn(EnemyType type, Vec2 pos, const Corruption& corruption); void spawn(EnemyType type, Vec2 pos, const Corruption& corruption);
// Steering toward the player + spatial-hash separation + contact attacks. // Steering toward the player + spatial-hash separation + contact attacks.
// Corruption is read every tick so the whole horde — not just fresh spawns —
// gets faster and deadlier as the House decays.
void update(float dt, Player& player, BuffSystem& buff_system, EventQueue& events, void update(float dt, Player& player, BuffSystem& buff_system, EventQueue& events,
const class Floor& floor); const class Floor& floor, const Corruption& corruption);
int alive_count() const { return static_cast<int>(enemies.size()); } int alive_count() const { return static_cast<int>(enemies.size()); }
}; };

View file

@ -175,7 +175,7 @@ void Game::update(const InputState& in, float dt) {
} }
director.update(dt, corruption, run_time, player, enemy_system, rng, director.update(dt, corruption, run_time, player, enemy_system, rng,
config.max_enemies, floor); config.max_enemies, floor);
enemy_system.update(dt, player, buff_system, events, floor); enemy_system.update(dt, player, buff_system, events, floor, corruption);
// "Taken"/"Confused" push the player after player_update, so re-resolve. // "Taken"/"Confused" push the player after player_update, so re-resolve.
player.pos = floor.resolve(player.pos, 0.45f); player.pos = floor.resolve(player.pos, 0.45f);
if (config.no_player_damage) player.hp = player.stats.max_hp; // stress mode if (config.no_player_damage) player.hp = player.stats.max_hp; // stress mode

View file

@ -27,25 +27,46 @@ void draw_hud(const Game& game) {
draw_bar(20, 20, 300, 22, game.player.hp / game.player.stats.max_hp, draw_bar(20, 20, 300, 22, game.player.hp / game.player.stats.max_hp,
Color{193, 18, 31, 235}, hp_label); Color{193, 18, 31, 235}, hp_label);
// Top right: shift timer + RoR2-style CONTAINMENT STATUS gauge. // Top right: the corruption status table. The shift clock is exposed for
const int total = static_cast<int>(game.run_time); // now — it is the RoR2 clock the whole difficulty curve hangs off, and
char timer[16]; // without it the tier jumps read as arbitrary.
std::snprintf(timer, sizeof(timer), "SHIFT %02d:%02d", total / 60, total % 60);
ui_font::draw_text(timer, GetScreenWidth() - 20 - ui_font::measure_text(timer, 28), 20, 28, Color{235, 232, 224, 245});
const int tier = game.corruption.tier(); const int tier = game.corruption.tier();
char status[96]; const Color tier_color = Color{
std::snprintf(status, sizeof(status), "CONTAINMENT STATUS: %s", game.corruption.tier_name());
const int status_w = ui_font::measure_text(status, 18);
ui_font::draw_text(status, GetScreenWidth() - 20 - status_w, 58, 18, Color{245, 197, 24, 245});
const float gauge_w = 260.0f;
const float gauge_x = GetScreenWidth() - 20 - gauge_w;
const Color gauge_fill = Color{
static_cast<unsigned char>(std::min(255, 120 + tier * 24)), static_cast<unsigned char>(std::min(255, 120 + tier * 24)),
static_cast<unsigned char>(std::max(0, 180 - tier * 32)), static_cast<unsigned char>(std::max(0, 180 - tier * 32)),
static_cast<unsigned char>(std::max(0, 60 - tier * 12)), 235}; static_cast<unsigned char>(std::max(0, 60 - tier * 12)), 245};
draw_bar(gauge_x, 84, gauge_w, 12, game.corruption.tier_progress(), gauge_fill, nullptr);
const int panel_w = 300;
const int panel_x = GetScreenWidth() - 20 - panel_w;
DrawRectangle(panel_x, 16, panel_w, 124, Color{14, 14, 16, 215});
DrawRectangleLines(panel_x, 16, panel_w, 124, Color{245, 197, 24, 120});
auto clock = [](float seconds, char* out, std::size_t size) {
const int total = static_cast<int>(std::max(0.0f, seconds));
std::snprintf(out, size, "%02d:%02d", total / 60, total % 60);
};
auto row = [panel_x, panel_w](const char* label, const char* value, int y, Color color) {
ui_font::draw_text(label, panel_x + 12, y, 14, Color{170, 168, 162, 220});
const int value_w = ui_font::measure_text(value, 15);
ui_font::draw_text(value, panel_x + panel_w - 12 - value_w, y, 15, color);
};
char shift[16], next_tier[16], cascade[16];
clock(game.run_time, shift, sizeof(shift));
clock(game.corruption.seconds_to_next_tier(), next_tier, sizeof(next_tier));
clock(game.corruption.seconds_to_max_tier(), cascade, sizeof(cascade));
int y = 24;
ui_font::draw_text("CONTAINMENT STATUS", panel_x + 12, y, 12, Color{200, 198, 192, 210});
y += 18;
ui_font::draw_text(game.corruption.tier_name(), panel_x + 12, y, 21, tier_color);
y += 28;
row("SHIFT TIME", shift, y, Color{235, 232, 224, 245}); y += 19;
row("NEXT TIER", next_tier, y, Color{200, 198, 192, 230}); y += 19;
row("CASCADE IN", cascade, y, Color{200, 198, 192, 230}); y += 22;
draw_bar(static_cast<float>(panel_x + 12), static_cast<float>(y),
static_cast<float>(panel_w - 24), 10.0f,
game.corruption.tier_progress(), tier_color, nullptr);
// Floor 01 flow: current room + the key/door objective. // Floor 01 flow: current room + the key/door objective.
{ {