NetDeck M3: squad vs. droids — BFS marines, droid/turret AI, cover, win/loss flow
Combat half of the MVP vertical slice on the shared coordinate space: - 2 marines (BFS to the player beacon, stop-and-fire hitscan), cover crates halve incoming hit chance, overhead + HUD HP meters - patrol/stationary security droids, heavy droid + ceiling turret on the objective terminal; feedback spike now spawns a reinforcement droid - win: marine reaches the terminal (BREACH SUCCESS); loss: SQUAD KIA; R resets either way; tracers dim in Network view - firmware build fix: Arduino auto-prototypes break Unit& params (planPath/unitMove/inCover/acquireTarget now take unit indices) - HUD fix: R:RESET no longer overlaps RESUME/PAUSE; daemon slots and SQUAD row spaced out - STATUS.md: M3 section incl. scope note — BREACH SUCCESS is gated on the M4 FRENZY/BLIND daemons; loss path + reset verified headlessly
This commit is contained in:
+444
-29
@@ -2,8 +2,8 @@
|
||||
* @file NetDeck.ino
|
||||
* @brief NetDeck — Breach & Board: Milestone 2 — network graph & traces.
|
||||
*
|
||||
* Milestone 2 (DESIGN.md §7) implementing the sub-net half of the MVP
|
||||
* vertical slice (MVP.md §2/§3) over the shared coordinate space:
|
||||
* Milestone 3 (DESIGN.md §7): adds the squad-vs-droids combat half of the
|
||||
* MVP vertical slice (MVP.md §1) on top of the M2 sub-net:
|
||||
*
|
||||
* - 3-room floorplan (airlock / main corridor / server room) with one
|
||||
* interactive blast door and the objective terminal
|
||||
@@ -18,6 +18,12 @@
|
||||
* arrival = feedback spike (links drop + 3 s OVERHEAT lockout)
|
||||
* - HUD: [1:FRENZY] [2:BLIND] slots (effects land in M4), TEMP bar,
|
||||
* RESET (R); boot goes straight into the paused encounter
|
||||
* - 2 marines (BFS to the player-placed beacon, stop-and-fire hitscan),
|
||||
* 2 corridor droids (1 patrol + 1 guard), heavy droid + ceiling turret
|
||||
* guarding the terminal; cover crates halve incoming hit chance;
|
||||
* a feedback spike spawns a reinforcement droid
|
||||
* - win: a marine reaches the objective terminal (BREACH SUCCESS);
|
||||
* loss: both marines down (SQUAD KIA) — R resets either way
|
||||
*
|
||||
* Run on the desktop: make APP=NetDeck run (from emulator/)
|
||||
* Headless smoke test: make smoke APP=NetDeck
|
||||
@@ -73,6 +79,8 @@ enum GameState { ST_BOOT, ST_RUN };
|
||||
static GameState gameState = ST_BOOT;
|
||||
enum ViewMode { VM_CAMERAS, VM_NETWORK };
|
||||
static ViewMode viewMode = VM_CAMERAS;
|
||||
enum Scenario { SC_LIVE, SC_WIN, SC_LOSS };
|
||||
static Scenario scenario = SC_LIVE;
|
||||
|
||||
static uint32_t stateT0 = 0;
|
||||
static bool paused = true; // MVP: boot straight into the paused encounter
|
||||
@@ -124,22 +132,22 @@ static char tileAt(int tx, int ty)
|
||||
return DEMO_MAP[ty][tx];
|
||||
}
|
||||
|
||||
// blocks unit movement (closed blast door included) — used from M3 on
|
||||
[[maybe_unused]] static bool walkable(int tx, int ty)
|
||||
// blocks unit movement (closed blast door included)
|
||||
static bool walkable(int tx, int ty)
|
||||
{
|
||||
char t = tileAt(tx, ty);
|
||||
if (t == '+' && !doorOpen) return false;
|
||||
return t == '.' || t == 'A' || t == 'T' || t == '+';
|
||||
}
|
||||
|
||||
// blocks line-of-sight raycasts — used from M3 on
|
||||
[[maybe_unused]] static bool blocksSight(int tx, int ty)
|
||||
// blocks line-of-sight raycasts
|
||||
static bool blocksSight(int tx, int ty)
|
||||
{
|
||||
char t = tileAt(tx, ty);
|
||||
return t == '#' || (t == '+' && !doorOpen);
|
||||
}
|
||||
|
||||
[[maybe_unused]] static int tileIdx(int tx, int ty) { return ty * nd::TILE_COLS + tx; }
|
||||
static int tileIdx(int tx, int ty) { return ty * nd::TILE_COLS + tx; }
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Sub-net (MVP.md §2): 4 nodes in the same coordinate space
|
||||
@@ -190,6 +198,9 @@ static int traceProg = 0; // 0..TRACE_TICKS
|
||||
// deck thermal: >0 = OVERHEAT lockout (ticks remaining, shown as %)
|
||||
static int heatT = 0;
|
||||
|
||||
// feedback spike queues a reinforcement droid (spawned by the combat layer)
|
||||
static bool reinforcePending = false;
|
||||
|
||||
// cursor
|
||||
static int curX = 60, curY = 120;
|
||||
static int beaconTX = AIRLOCK_TX, beaconTY = AIRLOCK_TY;
|
||||
@@ -338,9 +349,9 @@ static void feedbackSpike()
|
||||
traceActive = false;
|
||||
dropLinks();
|
||||
heatT = HEAT_TICKS;
|
||||
reinforcePending = true;
|
||||
Serial.println("[net] FEEDBACK SPIKE: links dropped, OVERHEAT 3s, reinforcement inbound");
|
||||
flashMsg("FEEDBACK!");
|
||||
// reinforcement droid spawns in M3
|
||||
}
|
||||
|
||||
static void stepNetwork()
|
||||
@@ -371,6 +382,322 @@ static void stepNetwork()
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Squad & droids (MVP.md §1) — autonomous entities in the shared space
|
||||
// ---------------------------------------------------------------------------
|
||||
enum { U_MARINE, U_DROID, U_HEAVY, U_TURRET };
|
||||
|
||||
struct UnitStat {
|
||||
uint16_t rng2; // fire range squared, in half-tiles
|
||||
uint8_t cd; // shot cooldown (ticks)
|
||||
uint8_t acc; // base hit chance %
|
||||
uint8_t dmg; // damage per hit
|
||||
uint8_t speed; // ticks per tile step (0 = stationary)
|
||||
uint8_t maxHp;
|
||||
};
|
||||
static const UnitStat STATS[4] = {
|
||||
{ 16 * 16, 5, 65, 1, 4, 6 }, // marine: rng 8.0, 4 shots / 2 s
|
||||
{ 14 * 14, 6, 55, 1, 5, 4 }, // droid: rng 7.0
|
||||
{ 14 * 14, 7, 70, 2, 7, 10 }, // heavy: rng 7.0, 2 dmg
|
||||
{ 21 * 21, 4, 80, 1, 0, 60 }, // turret: rng 10.5, high ROF
|
||||
};
|
||||
|
||||
enum { TEAM_MARINE = 0, TEAM_DROID = 1 };
|
||||
|
||||
struct Unit {
|
||||
bool alive;
|
||||
uint8_t kind, team;
|
||||
int tx, ty; // tile position
|
||||
int hp;
|
||||
int path[64]; // BFS waypoint tile indices
|
||||
int pathLen, pathIdx;
|
||||
int goalTX, goalTY; // what the current path leads to
|
||||
bool hasPath;
|
||||
int mvCd, fireCd;
|
||||
int tgt; // unit index or -1
|
||||
int patA, patB; // patrol endpoints as tileIdx (-1 = stationary)
|
||||
bool patFlip;
|
||||
};
|
||||
static Unit units[7];
|
||||
// 0,1 marines | 2 patrol droid | 3 stationary droid | 4 heavy | 5 turret
|
||||
// 6 = reinforcement slot (spawns on the feedback spike)
|
||||
|
||||
// transient hitscan tracers / impact flashes
|
||||
struct Tracer {
|
||||
int x0, y0, x1, y1, ttl;
|
||||
uint16_t color;
|
||||
bool impact; // draw a burst at the endpoint instead of a line
|
||||
};
|
||||
static Tracer tracers[8];
|
||||
|
||||
static int unitPx(int i) { return units[i].tx * nd::TILE + nd::TILE / 2; }
|
||||
static int unitPy(int i) { return units[i].ty * nd::TILE + nd::TILE / 2; }
|
||||
|
||||
static void spawnUnit(int i, uint8_t kind, int tx, int ty)
|
||||
{
|
||||
Unit &u = units[i];
|
||||
u.alive = true;
|
||||
u.kind = kind;
|
||||
u.team = (kind == U_MARINE) ? TEAM_MARINE : TEAM_DROID;
|
||||
u.tx = tx;
|
||||
u.ty = ty;
|
||||
u.hp = STATS[kind].maxHp;
|
||||
u.pathLen = u.pathIdx = 0;
|
||||
u.goalTX = u.goalTY = -1;
|
||||
u.hasPath = false;
|
||||
u.mvCd = u.fireCd = 0;
|
||||
u.tgt = -1;
|
||||
u.patA = u.patB = -1;
|
||||
u.patFlip = false;
|
||||
}
|
||||
|
||||
static void addTracer(int x0, int y0, int x1, int y1, uint16_t color, bool impact)
|
||||
{
|
||||
for (auto &t : tracers) {
|
||||
if (t.ttl > 0) continue;
|
||||
t.x0 = x0; t.y0 = y0; t.x1 = x1; t.y1 = y1;
|
||||
t.ttl = 2;
|
||||
t.color = color;
|
||||
t.impact = impact;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Bresenham tile raycast: walls and closed blast doors block sight
|
||||
static bool losClear(int x0, int y0, int x1, int y1)
|
||||
{
|
||||
int dx = abs(x1 - x0), sx = x0 < x1 ? 1 : -1;
|
||||
int dy = -abs(y1 - y0), sy = y0 < y1 ? 1 : -1;
|
||||
int err = dx + dy;
|
||||
int x = x0, y = y0;
|
||||
for (;;) {
|
||||
if (!(x == x0 && y == y0) && !(x == x1 && y == y1) && blocksSight(x, y))
|
||||
return false;
|
||||
if (x == x1 && y == y1) break;
|
||||
int e2 = 2 * err;
|
||||
if (e2 >= dy) { err += dy; x += sx; }
|
||||
if (e2 <= dx) { err += dx; y += sy; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// adjacent to a cover crate? (MVP: halves incoming hit chance)
|
||||
// (unit index, not a reference — see the planPath() note)
|
||||
static bool inCover(int ui)
|
||||
{
|
||||
const Unit &u = units[ui];
|
||||
static const int DX[4] = { 1, -1, 0, 0 }, DY[4] = { 0, 0, 1, -1 };
|
||||
for (int d = 0; d < 4; d++)
|
||||
if (tileAt(u.tx + DX[d], u.ty + DY[d]) == 'o') return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// nearest living enemy within range + LOS (unit index — see planPath() note)
|
||||
static int acquireTarget(int si)
|
||||
{
|
||||
const Unit &u = units[si];
|
||||
int best = -1;
|
||||
long bestD = 1L << 30;
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (i == si || !units[i].alive) continue;
|
||||
if (units[i].team == u.team) continue;
|
||||
int ddx = (u.tx - units[i].tx) * 2, ddy = (u.ty - units[i].ty) * 2;
|
||||
long d2 = (long)ddx * ddx + (long)ddy * ddy;
|
||||
if (d2 > STATS[u.kind].rng2) continue;
|
||||
if (!losClear(u.tx, u.ty, units[i].tx, units[i].ty)) continue;
|
||||
if (d2 < bestD) { bestD = d2; best = i; }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
// BFS over walkable tiles; returns step count written to out (or -1)
|
||||
static int bfsPath(int sx, int sy, int gx, int gy, int *out, int cap)
|
||||
{
|
||||
if (!walkable(gx, gy) || !walkable(sx, sy)) return -1;
|
||||
if (sx == gx && sy == gy) return 0;
|
||||
static int16_t par[nd::TILE_COLS * nd::TILE_ROWS];
|
||||
static int16_t q[nd::TILE_COLS * nd::TILE_ROWS];
|
||||
for (int i = 0; i < nd::TILE_COLS * nd::TILE_ROWS; i++) par[i] = -1;
|
||||
int start = tileIdx(sx, sy), goal = tileIdx(gx, gy);
|
||||
int qh = 0, qt = 0;
|
||||
q[qt++] = (int16_t)start;
|
||||
par[start] = (int16_t)start;
|
||||
bool found = false;
|
||||
while (qh < qt) {
|
||||
int cur = q[qh++];
|
||||
if (cur == goal) { found = true; break; }
|
||||
int cx = cur % nd::TILE_COLS, cy = cur / nd::TILE_COLS;
|
||||
for (int d = 0; d < 4; d++) {
|
||||
static const int DX[4] = { 1, -1, 0, 0 }, DY[4] = { 0, 0, 1, -1 };
|
||||
int nx = cx + DX[d], ny = cy + DY[d];
|
||||
if (!walkable(nx, ny)) continue;
|
||||
int ni = tileIdx(nx, ny);
|
||||
if (par[ni] != -1) continue;
|
||||
par[ni] = (int16_t)cur;
|
||||
q[qt++] = (int16_t)ni;
|
||||
}
|
||||
}
|
||||
if (!found) return -1;
|
||||
int rev[64], n = 0;
|
||||
int cur = goal;
|
||||
while (cur != start) {
|
||||
if (n >= cap) return -1;
|
||||
rev[n++] = cur;
|
||||
cur = par[cur];
|
||||
}
|
||||
for (int i = 0; i < n; i++) out[i] = rev[n - 1 - i];
|
||||
return n;
|
||||
}
|
||||
|
||||
// (re)plan a unit's path toward a goal tile
|
||||
// NOTE: takes a unit *index*, not a reference — the Arduino preprocessor
|
||||
// injects prototypes above the Unit struct, and reference params of a
|
||||
// user type break the generated firmware build (the emulator never sees it).
|
||||
static void planPath(int i, int gx, int gy)
|
||||
{
|
||||
Unit &u = units[i];
|
||||
u.pathLen = bfsPath(u.tx, u.ty, gx, gy, u.path, 64);
|
||||
u.pathIdx = 0;
|
||||
u.goalTX = gx;
|
||||
u.goalTY = gy;
|
||||
u.hasPath = u.pathLen > 0;
|
||||
}
|
||||
|
||||
static void unitKill(int i)
|
||||
{
|
||||
Unit &u = units[i];
|
||||
u.alive = false;
|
||||
u.tgt = -1;
|
||||
for (auto &o : units) if (o.tgt == i) o.tgt = -1;
|
||||
Serial.printf("[combat] %s destroyed at %d,%d\n",
|
||||
u.kind == U_MARINE ? "MARINE" :
|
||||
u.kind == U_HEAVY ? "HEAVY DROID" :
|
||||
u.kind == U_TURRET ? "TURRET" : "SECURITY DROID", u.tx, u.ty);
|
||||
}
|
||||
|
||||
static void fireAt(int si, int ti)
|
||||
{
|
||||
Unit &s = units[si];
|
||||
Unit &t = units[ti];
|
||||
s.fireCd = STATS[s.kind].cd;
|
||||
int acc = STATS[s.kind].acc;
|
||||
if (inCover(ti)) acc /= 2; // MVP cover rule
|
||||
bool hit = (int)random(100) < acc;
|
||||
uint16_t col = s.team == TEAM_MARINE ? nd::C_PACKET : nd::C_TRACE;
|
||||
if (hit) {
|
||||
addTracer(unitPx(si), unitPy(si), unitPx(ti), unitPy(ti), col, true);
|
||||
t.hp -= STATS[s.kind].dmg;
|
||||
Serial.printf("[combat] %c%d hits %c%d (%d hp left)\n",
|
||||
s.team == TEAM_MARINE ? 'M' : 'D', si,
|
||||
t.team == TEAM_MARINE ? 'M' : 'D', ti, t.hp > 0 ? t.hp : 0);
|
||||
if (t.hp <= 0) unitKill(ti);
|
||||
} else {
|
||||
addTracer(unitPx(si), unitPy(si), unitPx(ti), unitPy(ti), col, false);
|
||||
Serial.printf("[combat] %c%d misses %c%d\n",
|
||||
s.team == TEAM_MARINE ? 'M' : 'D', si,
|
||||
t.team == TEAM_MARINE ? 'M' : 'D', ti);
|
||||
}
|
||||
}
|
||||
|
||||
// any living unit standing on this tile? (units may not share a tile)
|
||||
static bool tileOccupied(int tx, int ty, int self)
|
||||
{
|
||||
for (int i = 0; i < 7; i++) {
|
||||
if (i == self || !units[i].alive) continue;
|
||||
if (units[i].tx == tx && units[i].ty == ty) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// move one tile along the current path when the step timer expires
|
||||
// (unit index, not a reference — see the planPath() note)
|
||||
static void unitMove(int i)
|
||||
{
|
||||
Unit &u = units[i];
|
||||
const int self = i;
|
||||
if (!u.hasPath) return;
|
||||
if (u.mvCd > 0) { u.mvCd--; return; }
|
||||
if (u.pathIdx >= u.pathLen) { u.hasPath = false; return; }
|
||||
int next = u.path[u.pathIdx++];
|
||||
int nx = next % nd::TILE_COLS, ny = next / nd::TILE_COLS;
|
||||
if (!walkable(nx, ny) || tileOccupied(nx, ny, self)) {
|
||||
u.hasPath = false; // door shut / another unit in the way
|
||||
return;
|
||||
}
|
||||
u.tx = nx;
|
||||
u.ty = ny;
|
||||
u.mvCd = STATS[u.kind].speed;
|
||||
if (u.pathIdx >= u.pathLen) u.hasPath = false;
|
||||
}
|
||||
|
||||
static void stepUnits()
|
||||
{
|
||||
// tracer decay runs even while a banner is up
|
||||
for (auto &t : tracers) if (t.ttl > 0) t.ttl--;
|
||||
|
||||
if (scenario != SC_LIVE) return;
|
||||
|
||||
// reinforcement droid queued by the feedback spike
|
||||
if (reinforcePending) {
|
||||
reinforcePending = false;
|
||||
if (!units[6].alive) {
|
||||
// spawn inside the server room by the blast door, first free tile
|
||||
static const int SP[5][2] = { {31,12}, {30,12}, {32,12}, {31,11}, {31,13} };
|
||||
for (int s = 0; s < 5; s++) {
|
||||
int sx = SP[s][0], sy = SP[s][1];
|
||||
if (walkable(sx, sy) && !tileOccupied(sx, sy, 6)) {
|
||||
spawnUnit(6, U_DROID, sx, sy);
|
||||
Serial.printf("[spawn] reinforcement droid at %d,%d\n", sx, sy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 7; i++) {
|
||||
Unit &u = units[i];
|
||||
if (!u.alive) continue;
|
||||
|
||||
// combat: stop and fire at the nearest enemy in range + LOS
|
||||
if (u.fireCd > 0) u.fireCd--;
|
||||
u.tgt = acquireTarget(i);
|
||||
if (u.tgt >= 0) {
|
||||
if (u.fireCd == 0) fireAt(i, u.tgt);
|
||||
continue; // hold position while firing
|
||||
}
|
||||
|
||||
// movement goals
|
||||
if (u.kind == U_MARINE) {
|
||||
if (!u.hasPath || u.goalTX != beaconTX || u.goalTY != beaconTY ||
|
||||
(simTick & 7) == 0)
|
||||
planPath(i, beaconTX, beaconTY);
|
||||
unitMove(i);
|
||||
} else if (u.patA >= 0) { // patrolling droid
|
||||
if (!u.hasPath) {
|
||||
int goal = u.patFlip ? u.patA : u.patB;
|
||||
planPath(i, goal % nd::TILE_COLS, goal / nd::TILE_COLS);
|
||||
u.patFlip = !u.patFlip;
|
||||
}
|
||||
unitMove(i);
|
||||
}
|
||||
// stationary droids / heavy / turret hold position
|
||||
|
||||
// objective + wipe checks
|
||||
if (u.kind == U_MARINE && u.tx == 34 && u.ty == 7) {
|
||||
scenario = SC_WIN;
|
||||
Serial.println("[objective] terminal reached — BREACH SUCCESS");
|
||||
flashMsg("BREACH SUCCESS");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!units[0].alive && !units[1].alive && scenario == SC_LIVE) {
|
||||
scenario = SC_LOSS;
|
||||
Serial.println("[objective] squad wiped — SQUAD KIA");
|
||||
flashMsg("SQUAD KIA");
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Scenario reset (MVP: R replays the 60-second scenario instantly)
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -382,9 +709,26 @@ static void resetScenario()
|
||||
hiveCracked = false;
|
||||
heatT = 0;
|
||||
doorOpen = false;
|
||||
reinforcePending = false;
|
||||
for (auto &t : tracers) t.ttl = 0;
|
||||
refreshOnline(); // AIRLK root comes up online
|
||||
|
||||
// squad: 2 marines in the airlock (out of enemy LOS)
|
||||
spawnUnit(0, U_MARINE, 2, 21);
|
||||
spawnUnit(1, U_MARINE, 3, 21);
|
||||
// corridor: 1 patrolling + 1 stationary security droid
|
||||
spawnUnit(2, U_DROID, 12, 2);
|
||||
units[2].patA = tileIdx(12, 2);
|
||||
units[2].patB = tileIdx(26, 18);
|
||||
units[2].patFlip = false;
|
||||
spawnUnit(3, U_DROID, 20, 12);
|
||||
// server room: heavy droid + ceiling turret guarding the terminal
|
||||
spawnUnit(4, U_HEAVY, 32, 10);
|
||||
spawnUnit(5, U_TURRET, 33, 5);
|
||||
units[6].alive = false; // reinforcement slot
|
||||
|
||||
scenario = SC_LIVE;
|
||||
paused = true;
|
||||
// entities (marines/droids) arrive in M3
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -448,13 +792,12 @@ static void registerClick()
|
||||
{
|
||||
if (viewMode == VM_CAMERAS) {
|
||||
int tx = curX / nd::TILE, ty = curY / nd::TILE;
|
||||
char t = tileAt(tx, ty);
|
||||
if (t != '#') {
|
||||
if (walkable(tx, ty)) {
|
||||
beaconTX = tx;
|
||||
beaconTY = ty;
|
||||
Serial.printf("[click] beacon -> tile %d,%d\n", tx, ty);
|
||||
} else {
|
||||
Serial.println("[click] wall tile: beacon ignored");
|
||||
Serial.println("[click] blocked tile: beacon ignored");
|
||||
}
|
||||
} else {
|
||||
// nearest node
|
||||
@@ -590,6 +933,7 @@ static void stepSim()
|
||||
{
|
||||
simTick++;
|
||||
stepNetwork();
|
||||
stepUnits();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -771,6 +1115,73 @@ static void renderBeacon()
|
||||
GFXP->fillTriangle(bx, by - 3, bx - 3, by, bx, by + 3, c);
|
||||
}
|
||||
|
||||
// entity sprites + overhead HP bars (dimmed ghosting in Network view)
|
||||
static void renderUnits(bool full)
|
||||
{
|
||||
for (int i = 0; i < 7; i++) {
|
||||
const Unit &u = units[i];
|
||||
if (!u.alive) continue;
|
||||
int px = unitPx(i), py = unitPy(i);
|
||||
uint16_t body, line;
|
||||
if (u.kind == U_MARINE) {
|
||||
body = nd::C_GOOD;
|
||||
line = nd::C_HUDBG;
|
||||
} else if (u.kind == U_TURRET) {
|
||||
body = nd::C_HOT;
|
||||
line = nd::C_HUDBG;
|
||||
} else {
|
||||
body = nd::C_TRACE;
|
||||
line = nd::C_HUDBG;
|
||||
}
|
||||
if (!full) { body = dim565(body); line = dim565(line); }
|
||||
|
||||
if (u.kind == U_TURRET) { // ceiling mount: circle + barrel
|
||||
GFXP->fillCircle(px, py - 1, 3, body);
|
||||
GFXP->drawCircle(px, py - 1, 3, line);
|
||||
GFXP->drawFastVLine(px, py + 2, 3, line);
|
||||
} else {
|
||||
int s = (u.kind == U_HEAVY) ? 7 : 6; // heavy is one size up
|
||||
GFXP->fillRect(px - s / 2, py - s / 2, s, s, body);
|
||||
GFXP->drawRect(px - s / 2, py - s / 2, s, s, line);
|
||||
GFXP->drawFastHLine(px - 1, py - s / 2 - 2, 2, line); // antenna
|
||||
}
|
||||
|
||||
// overhead HP bar
|
||||
int pct = u.hp * 100 / STATS[u.kind].maxHp;
|
||||
uint16_t hc = pct > 50 ? nd::C_GOOD : (pct > 25 ? nd::C_WARN : nd::C_HOT);
|
||||
if (!full) hc = dim565(hc);
|
||||
GFXP->fillRect(px - 4, py - 7, 8, 2, nd::C_HUDBG);
|
||||
GFXP->fillRect(px - 4, py - 7, 8 * pct / 100, 2, hc);
|
||||
}
|
||||
}
|
||||
|
||||
static void renderTracers(bool full)
|
||||
{
|
||||
for (const auto &t : tracers) {
|
||||
if (t.ttl <= 0) continue;
|
||||
uint16_t c = full ? t.color : dim565(t.color);
|
||||
if (t.impact) GFXP->fillCircle(t.x1, t.y1, 2, c);
|
||||
else GFXP->drawLine(t.x0, t.y0, t.x1, t.y1, c);
|
||||
}
|
||||
}
|
||||
|
||||
// 1-line banner on win/loss (MVP: BREACH SUCCESS / SQUAD KIA, R to replay)
|
||||
static void renderBanner()
|
||||
{
|
||||
if (scenario == SC_LIVE || (millis() / 400) & 1) return;
|
||||
uint16_t c = scenario == SC_WIN ? nd::C_GOOD : nd::C_HOT;
|
||||
GFXP->fillRect(40, 78, 240, 34, nd::C_HUDBG);
|
||||
GFXP->drawRect(40, 78, 240, 34, c);
|
||||
GFXP->setTextDatum(MC_DATUM);
|
||||
GFXP->setTextColor(c);
|
||||
GFXP->drawString(scenario == SC_WIN ? "BREACH SUCCESS" : "SQUAD KIA",
|
||||
160, 95);
|
||||
GFXP->setTextFont(1);
|
||||
GFXP->setTextColor(nd::C_TEXTDIM);
|
||||
GFXP->drawString("R: RESET", 160, 108);
|
||||
GFXP->setTextDatum(TL_DATUM);
|
||||
}
|
||||
|
||||
static void meterBar(int x, int y, int w, int h, int pct, uint16_t c)
|
||||
{
|
||||
GFXP->drawRect(x, y, w, h, nd::C_BORDER);
|
||||
@@ -786,12 +1197,12 @@ static void renderHud()
|
||||
// 2 exploit daemon slots (MVP: FRENZY + BLIND)
|
||||
static const char *const NAMES[2] = { "FRENZY", "BLIND" };
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int x = 6 + i * 58, y = nd::HUD_Y + 6;
|
||||
int x = 6 + i * 64, y = nd::HUD_Y + 6;
|
||||
GFXP->setTextDatum(TL_DATUM);
|
||||
GFXP->setTextColor(nd::C_TEXT);
|
||||
GFXP->drawString(String("[") + char('1' + i) + "]", x, y);
|
||||
GFXP->setTextColor(nd::C_TEXTDIM);
|
||||
GFXP->drawString(NAMES[i], x + 18, y);
|
||||
GFXP->drawString(NAMES[i], x + 20, y);
|
||||
meterBar(x, y + 14, 48, 6, 100, nodeOnline[N_HIVE] ? nd::C_GOOD : nd::C_BORDER);
|
||||
}
|
||||
|
||||
@@ -802,33 +1213,34 @@ static void renderHud()
|
||||
meterBar(130, nd::HUD_Y + 16, 56, 7, heatT > 0 ? heatPct : 15,
|
||||
heatT > 0 ? nd::C_HOT : nd::C_WARN);
|
||||
|
||||
// pause hint / state
|
||||
// pause hint / state (right column: SPACE / RESUME / R: RESET / VIEW)
|
||||
GFXP->setTextDatum(TR_DATUM);
|
||||
GFXP->setTextColor(paused ? nd::C_FREEZE : nd::C_TEXT);
|
||||
GFXP->drawString("SPACE", nd::HUD_X + nd::HUD_W - 6, nd::HUD_Y + 6);
|
||||
GFXP->drawString("SPACE", nd::HUD_X + nd::HUD_W - 6, nd::HUD_Y + 4);
|
||||
GFXP->setTextColor(paused ? nd::C_FREEZE : nd::C_TEXTDIM);
|
||||
GFXP->drawString(paused ? "RESUME" : "PAUSE", nd::HUD_X + nd::HUD_W - 6, nd::HUD_Y + 16);
|
||||
GFXP->drawString(paused ? "RESUME" : "PAUSE", nd::HUD_X + nd::HUD_W - 6, nd::HUD_Y + 14);
|
||||
GFXP->setTextColor(nd::C_TEXTDIM);
|
||||
GFXP->drawString("R: RESET", nd::HUD_X + nd::HUD_W - 6, nd::HUD_Y + 32);
|
||||
GFXP->drawString("R: RESET", nd::HUD_X + nd::HUD_W - 6, nd::HUD_Y + 24);
|
||||
GFXP->setTextDatum(TL_DATUM);
|
||||
|
||||
// view mode indicator
|
||||
// view mode indicator (bottom-right)
|
||||
GFXP->setTextDatum(TR_DATUM);
|
||||
GFXP->setTextColor(nd::C_FREEZE);
|
||||
GFXP->drawString(viewMode == VM_CAMERAS ? "VIEW: CAMERAS [P]" : "VIEW: NETWORK [P]",
|
||||
nd::HUD_X + 190, nd::HUD_Y + 32);
|
||||
nd::HUD_X + nd::HUD_W - 6, nd::HUD_Y + 34);
|
||||
GFXP->setTextDatum(TL_DATUM);
|
||||
|
||||
// squad readout (live marine HP in M3; placeholder now)
|
||||
// squad readout: live marine HP
|
||||
GFXP->setTextColor(nd::C_TEXTDIM);
|
||||
GFXP->drawString("SQUAD", 6, nd::HUD_Y + 30);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int x = 48 + i * 58;
|
||||
for (int s = 0; s < 5; s++) {
|
||||
GFXP->fillRect(x + s * 8, nd::HUD_Y + 34, 6, 8, nd::C_GOOD);
|
||||
}
|
||||
GFXP->setTextColor(nd::C_TEXTDIM);
|
||||
GFXP->drawString(String("M") + String(i + 1), x - 10, nd::HUD_Y + 30);
|
||||
const Unit &u = units[i];
|
||||
int x = 62 + i * 46;
|
||||
GFXP->setTextColor(u.alive ? nd::C_TEXTDIM : nd::C_HOT);
|
||||
GFXP->drawString(String("M") + String(i + 1), x - 14, nd::HUD_Y + 30);
|
||||
meterBar(x, nd::HUD_Y + 34, 30, 7,
|
||||
u.alive ? u.hp * 100 / STATS[u.kind].maxHp : 0,
|
||||
u.alive ? nd::C_GOOD : nd::C_BORDER);
|
||||
}
|
||||
|
||||
// transient message
|
||||
@@ -869,6 +1281,8 @@ static void render()
|
||||
{
|
||||
renderMap(viewMode == VM_NETWORK);
|
||||
renderNetwork(viewMode == VM_NETWORK);
|
||||
renderUnits(viewMode == VM_CAMERAS);
|
||||
renderTracers(viewMode == VM_CAMERAS);
|
||||
renderBeacon();
|
||||
renderHud();
|
||||
|
||||
@@ -880,6 +1294,7 @@ static void render()
|
||||
|
||||
renderCursor();
|
||||
if (paused) renderFreezeTint();
|
||||
renderBanner();
|
||||
}
|
||||
|
||||
static void drawBoot()
|
||||
@@ -893,7 +1308,7 @@ static void drawBoot()
|
||||
GFXP->drawString("BREACH & BOARD", 160, 108);
|
||||
GFXP->setTextFont(2);
|
||||
GFXP->setTextColor(nd::C_TEXTDIM);
|
||||
GFXP->drawString("M2 // VERTICAL SLICE", 160, 136);
|
||||
GFXP->drawString("M3 // VERTICAL SLICE", 160, 136);
|
||||
GFXP->drawString("p: cameras/network space: freeze", 160, 158);
|
||||
GFXP->drawString("ball: cursor enter: select x: sever", 160, 174);
|
||||
GFXP->setTextDatum(TL_DATUM);
|
||||
@@ -906,7 +1321,7 @@ static void drawBoot()
|
||||
static void hardwareInit()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println("NetDeck M2 — vertical slice (network & traces)");
|
||||
Serial.println("NetDeck M3 — vertical slice (squad vs. droids)");
|
||||
|
||||
pinMode(BOARD_POWERON, OUTPUT);
|
||||
digitalWrite(BOARD_POWERON, HIGH);
|
||||
|
||||
@@ -9,6 +9,7 @@ milestone lands.
|
||||
| **M0 — Emulator** | SDL2 emulator support + M1 surface tested locally | **done** |
|
||||
| **M1 — Hardware Sandbox** | Full-frame sprite rendering to ST7789, shared tactical view + HUD, cursor, `Space` freeze, `P` view switch | **compiled + emulator-verified; on-device check pending** |
|
||||
| M2 — Network Graph & Traces | 4-node sub-net in shared space (AIRLK→JUNC→DOOR/HIVE), animated link routing (1.5 s / 3.0 s ICE), door control, red trace → feedback spike + OVERHEAT, `X` sever, `R` reset | **done (emulator-verified)** |
|
||||
| M3 — Squad vs. Droids | 2 marines (BFS to the player beacon, stop-and-fire), patrol/stationary droids, heavy droid + ceiling turret on the terminal, cover crates, tracers/HP bars, win/loss banners, reinforcement on feedback spike | **done (emulator-verified; firmware build fixed)** |
|
||||
| M3 — Squad vs. Droids | Ship floorplan in Cameras view, 3 marines → beacon, 4 droids, gunfire | planned |
|
||||
| M4 — Cyber-Physical Bridge | Hive link + `1` FRENZY.EXE turns droids on each other (shared coordinate space) | planned |
|
||||
|
||||
@@ -88,3 +89,47 @@ validation spec added in this commit) on the shared 320x192 coordinate space:
|
||||
safe-sever run (trace reset, no spike), all gating messages
|
||||
(NO HIVE LINK / NO UPLINK / OVERHEAT / LINK SEVERED / NO NODE),
|
||||
and `r` reset; visual frame dumps inspected.
|
||||
|
||||
## M3 (done — emulator-verified)
|
||||
|
||||
Implements the combat half of the MVP vertical slice (`MVP.md` §1) on top of
|
||||
the M2 sub-net, in the same 320x192 coordinate space:
|
||||
|
||||
- **Squad**: 2 identical marines spawning in the airlock; BFS pathfinding to
|
||||
the player-placed beacon (re-planned while blocked or every 8 ticks),
|
||||
stop-and-fire hitscan combat with inCover() cover rule (adjacent crate
|
||||
halves incoming hit chance), overhead HP bars + live SQUAD meters in the HUD.
|
||||
- **Enemies**: 1 patrolling + 1 stationary security droid in the corridor;
|
||||
1 heavy droid (2 dmg) + 1 stationary ceiling turret (high ROF) guarding
|
||||
the objective terminal at tile (34,7). Units may not share a tile; walls
|
||||
and the closed blast door block both movement (BFS) and sight (Bresenham).
|
||||
- **Feedback spike consequence**: the M2 spike now queues a reinforcement
|
||||
droid spawning in the server room by the blast door.
|
||||
- **Flow**: win = a marine reaches the terminal (`BREACH SUCCESS`), loss =
|
||||
both marines down (`SQUAD KIA`); blinking 1-line banner, `R` resets either
|
||||
way. Tracers (2-tick) render in Cameras view, dimmed in Network view.
|
||||
- **Emulator verification** (headless, scripted taps/keys): marines clear
|
||||
both corridor droids; ICE→trace→feedback→reinforcement→cooldown still
|
||||
works on top of combat; loss path + `r` reset verified; frame dumps
|
||||
inspected (units, HP bars, tracers, banners).
|
||||
- **Firmware build fix (this commit)**: the first M3 draft did not compile
|
||||
on-device — the Arduino preprocessor injects auto-prototypes above the
|
||||
`Unit` struct, and functions taking `Unit&`/`const Unit&` parameters
|
||||
(`planPath`, `unitMove`, `inCover`, `acquireTarget`) broke the generated
|
||||
prototypes. The emulator (plain C++) never sees this. All four now take a
|
||||
unit *index* instead of a reference; `pio run -d examples/NetDeck` is green
|
||||
again.
|
||||
- **HUD layout fix (this commit)**: `R: RESET` no longer overlaps
|
||||
`RESUME`/`PAUSE` (right column re-spaced: SPACE/RESUME/R:RESET/VIEW),
|
||||
daemon slots and the SQUAD row got real gaps (frame-dump verified).
|
||||
|
||||
### Known scope note: the win path is gated on M4
|
||||
|
||||
Scripted runs show the encounter plays out but `BREACH SUCCESS` is not
|
||||
reachable yet: the marines reliably clear the corridor droids, then die at
|
||||
the blast door to the heavy droid + turret. The intended counter — `1`
|
||||
FRENZY / `2` BLIND — lands in M4 (keys already arm and show the gating
|
||||
message). The litmus-test loop (crack HIVE, FRENZY the turret, dash the
|
||||
squad through) completes in M4; until then the loss path + reset are the
|
||||
verifiable branches. On-device check still pending (inherits the M1
|
||||
checklist in §M1 above).
|
||||
|
||||
Reference in New Issue
Block a user