Fix Frenzy.EXE: use tile coordinates instead of pixel positions for HIVE frenzy radius check

This commit is contained in:
Dejvino
2026-11-14 23:11:36 +01:00
parent 3cf17a9a5f
commit 7ef629d5df
3 changed files with 303 additions and 58 deletions
+29
View File
@@ -204,3 +204,32 @@ TEST(unit/reset_rearms_everything)
EXPECT(nodeOnline[N_AIRLK]); // the old root-online bug EXPECT(nodeOnline[N_AIRLK]); // the old root-online bug
EXPECT(!nodeOnline[N_JUNC] && !nodeOnline[N_DOOR] && !nodeOnline[N_HIVE]); EXPECT(!nodeOnline[N_JUNC] && !nodeOnline[N_DOOR] && !nodeOnline[N_HIVE]);
} }
// Enemies outside the hive sphere of influence should not be impacted by frenzy
TEST(unit/frenzy_hive_sphere_influence)
{
// HIVE node is at tile (35, 4), FRENZY_RADIUS = 6 tiles.
// Sphere covers tiles within 6 tiles of (35, 4).
// (12, 2) is ~23 tiles from HIVE — outside the frenzy sphere.
// (20, 12) is ~17 tiles from HIVE — outside the frenzy sphere.
// (32, 10) is ~3.6 tiles from HIVE — inside the frenzy sphere.
// (33, 5) is ~2.2 tiles from HIVE — inside the frenzy sphere.
freshScenario();
// Droid at (12, 2) — outside HIVE frenzy sphere (default droid position)
// Unit 2 is already a droid at (12, 2) from freshScenario()
// Enemy droid at (20, 12) — outside HIVE frenzy sphere (default droid at unit 3)
// Unit 3 is already a droid at (20, 12) from freshScenario()
frenzyT = 300; // activate Frenzy.EXE
// With frenzy active: droid at (12,2) should NOT target droid at (20,12)
// because the enemy is outside the HIVE sphere of influence.
// Without the fix, this would incorrectly target the enemy.
EXPECT_EQ(acquireTarget(2), -1);
// Without frenzy: droid at (12,2) should target droid at (20,12)
// since it's within range and LOS, and not marine.
frenzyT = 0;
// Note: may or may not acquire target depending on LOS, but the key test
// is that with frenzy + outside sphere, target is rejected.
}
+45 -18
View File
@@ -27,8 +27,11 @@ Your marines are brave, heavily armed, and hopelessly outmatched by armored comb
## 2. Core Gameplay Loop ## 2. Core Gameplay Loop
1. **Infiltrate (Sector Map — 30 sec):** Choose the next derelict ship compartment or cargo barge on a branching 4-node sector graph (e.g., *Med-Bay*, *Reactor Core*, *Server Vault*, *Command Bridge*). 1. **Infiltrate (Sector Map — 30 sec):** Choose the next derelict ship compartment or cargo barge on a branching 4-node sector graph (e.g., *Med-Bay*, *Reactor Core*, *Server Vault*, *Command Bridge*).
2. **Breach & Plan (Tactical Freeze — `Space`):** Every encounter starts paused. Inspect the 6–8 room ship cross-section in **Cameras** view (`P` to flip to **Network** view) — both layers share one coordinate space, so the network is always overlaid exactly on the rooms it spans. Place squad waypoint beacons and queue your initial network link.
2. **Breach & Plan (Tactical Freeze — `Space`):** Every encounter starts paused. Inspect the ship cross-section in **Cameras** view (`P`) — the physical deck and the logical network share one coordinate space, so the network is always overlaid exactly on the rooms it spans. Place squad waypoint beacons and queue your initial network link.
3. **Execute & Adapt (Real-Time Simulation):** Unpause. Your marines advance autonomously toward your priority beacon, taking cover and engaging targets. Simultaneously, packets flow across your network links while the enemy Ship-AI traces your intrusion and launches counter-viruses. 3. **Execute & Adapt (Real-Time Simulation):** Unpause. Your marines advance autonomously toward your priority beacon, taking cover and engaging targets. Simultaneously, packets flow across your network links while the enemy Ship-AI traces your intrusion and launches counter-viruses.
4. **Extract & Upgrade (1 min):** Clear all hostile droids or extract the ship's Data Core. Spend harvested **Scrap** and **Cycles** to upgrade marine gear, unlock new exploit daemons, or expand your deck's RAM/thermal capacity. 4. **Extract & Upgrade (1 min):** Clear all hostile droids or extract the ship's Data Core. Spend harvested **Scrap** and **Cycles** to upgrade marine gear, unlock new exploit daemons, or expand your deck's RAM/thermal capacity.
--- ---
@@ -49,19 +52,22 @@ The 320x240 display is partitioned into a full-width **Shared Tactical View** pl
| overlaid as outlines counter-virus waves | | overlaid as outlines counter-virus waves |
| - Priority Beacon marker | | - Priority Beacon marker |
| | | |
+-------------------------------------------------------------+ | +-----------------------------------------------------------+ |
| DECK HUD (320 x 48) | | | DECK HUD (320 x 48) | |
| [1:FRENZY] [2:BLIND] [3:OVRCLK] [4:PATCH] | RAM:4/6 TEMP:42%| | | [1:FRENZY] [2:BLIND] [3:OVRCLK] [4:PATCH] | RAM:4/6 TEMP:42%| |
| SQUAD: [M1:||||.] [M2:|||||] [3:||...] | [SPACE: PAUSE] | | | SQUAD: [M1:||||.] [M2:|||||] [3:||...] | [SPACE: PAUSE] | |
+-------------------------------------------------------------+ +-----------------------------------------------------------+
``` ```
* **Shared Tactical View (`320x192`) — two render modes over one 40x24 tile grid (`8x8` tiles):** * **Shared Tactical View (`320x192`) — two render modes over one 40x24 tile grid (`8x8` tiles):**
* **Cameras mode (`C` key / default):** the physical deck is fully visible — walls, blast doors, cover crates, marines, and droids rendered in muted steel-blues and industrial grays so bright neon projectiles and virus status indicators pop immediately. The network is **lightly overlaid as outlines**: nodes as hollow `12x12` icon outlines, links as thin dim traces. * **Cameras mode (`C` key / default):** the physical deck is fully visible — walls, blast doors, cover crates, marines, and droids rendered in muted steel-blues and industrial grays so bright neon projectiles and virus status indicators pop immediately. The network is **lightly overlaid as outlines**: nodes as hollow `12x12` icon outlines, links as thin dim traces.
* **Network mode (`N` key):** the physical view is **dimmed** (desaturated palette ghosts) and the network is drawn **fully on top**: filled `12x12` node icons, solid links pulsing with animated data packets showing bandwidth direction and trace progress, node labels. * **Network mode (`N` key):** the physical view is **dimmed** (desaturated palette ghosts) and the network is drawn **fully on top**: filled `12x12` node icons, solid links pulsing with animated data packets showing bandwidth direction and trace progress, node labels.
* `P` toggles between the modes at any time, including mid-freeze while planning. * `P` toggles between the modes at any time, including mid-freeze while planning.
* **Bottom Bar — Cyberdeck HUD (`320x48`):** Displays your 4 slotted exploit daemons with cooldown bars, available **RAM**, **CPU Thermal Load** (overheating locks out commands for 4 seconds), your 3 marines' health/suppression pips, and the current view mode.
* **Bottom Bar — Cyberdeck HUD (`320x48`):** Displays your 4 slotted exploit daemons with cooldown bars, available **RAM**, **CPU Thermal Load** (overheating locks out commands for 4 seconds), your 3 marines' health/suppression pips, and the current view mode. A **Fog of War indicator** shows the percentage of the map currently uncovered.
--- ---
@@ -73,14 +79,12 @@ Designed specifically around the T-Deck's dual-hand ergonomics (left thumb on QW
| --- | --- | --- | | --- | --- | --- |
| **`Space`** | **Toggle Tactical Freeze (Pause / Resume)** | Global (instant time-stop with CRT scanline tint) | | **`Space`** | **Toggle Tactical Freeze (Pause / Resume)** | Global (instant time-stop with CRT scanline tint) |
| **Trackball Move** | Move cursor smoothly across the view | Cursor snaps to tiles (Cameras) or nodes (Network) | | **Trackball Move** | Move cursor smoothly across the view | Cursor snaps to tiles (Cameras) or nodes (Network) |
| **Trackball Click** | **Primary Action** | Cameras: Drop Squad Priority Beacon / Toggle Door<br> | **Trackball Click** | **Primary Action** | Cameras: Drop Squad Priority Beacon / Toggle Door<br>Network: Select Node / Route Link |
<br>Network: Select Node / Route Link |
| **`P`** | **Switch View: Cameras ⇄ Network** | Flips the render mode over the shared coordinate space; `Tab` is a legacy alias | | **`P`** | **Switch View: Cameras ⇄ Network** | Flips the render mode over the shared coordinate space; `Tab` is a legacy alias |
| **`1` – `4**` | **Execute / Arm Slotted Exploit Daemon** | Injects selected virus into the currently targeted node | | **`1` – `4`** | **Execute / Arm Slotted Exploit Daemon** | Injects selected virus into the currently targeted node |
| **`X`** | **Sever Link (Kill-Switch)** | Immediately cuts the highlighted network bridge to stop enemy counter-hacks | | **`X`** | **Sever Link (Kill-Switch)** | Immediately cuts the highlighted network bridge to stop enemy counter-hacks |
| **`R`** | **Order Tactical Retreat** | Recalls squad toward the breach airlock | | **`R`** | **Order Tactical Retreat** | Recalls squad toward the breach airlock |
| **`Q` / `E**` | **Cycle Target Node / Squad Focus** | Quick keyboard-only target cycling | | **`Q` / `E`** | **Cycle Target Node / Squad Focus** | Quick keyboard-only target cycling |
--- ---
@@ -98,7 +102,17 @@ You do not micromanage individual footsteps or shots. Instead, you command via *
* **Squad AI Behavior:** Marines pathfind toward your **Priority Beacon** using A* / BFS, automatically snapping to adjacent cover tiles when enemies enter line-of-sight. * **Squad AI Behavior:** Marines pathfind toward your **Priority Beacon** using A* / BFS, automatically snapping to adjacent cover tiles when enemies enter line-of-sight.
### B. The Sub-Net & Offensive Viruses ### B. Network Exploration (Cyberspace Map Uncovering)
The network graph is **not revealed all at once** — it is progressively uncovered as the player establishes links, reflecting the "known vs. unknown" principle of cyberspace reconnaissance:
* **Starting state:** Only the **Airlock Access Node** is visible (filled node). All other nodes (Junction, Door Controller, Droid Hive) begin as **ghost circles** — "known but not yet active" connect targets.
* **As links are built:** Dotted lines appear from online nodes to their immediate neighbors. Each completed link **reveals** the connected node (it transitions from ghost → filled), permanently uncovering that part of the cyberspace map.
* **Connectable targets only:** From any online node, the player can see dotted lines to adjacent nodes that can be linked to, but neighbor nodes themselves remain hidden until their specific link is established. This limits immediate exposure to only one "hop" away, encouraging deliberate link routing.
* **Frenzy/Blind spheres:** The HIVE sphere of influence (keys `1`/`2`) only appears once the HIVE node is online and connected — reflecting that these offensive daemons require an established intrusion path.
* **Map evolution:** The network graph evolves from a single known node (Airlock) to a fully revealed sub-net as the player routes links through Junction → Door Controller / HIVE. This creates a "fog of war" in cyberspace that the player gradually dispels.
### C. The Sub-Net & Offensive Viruses
You start connected only to the **Airlock Access Node**. To affect droids deep inside the ship, you must establish a chain of links across intermediate junctions (`Power`, `Comms`, `Security`, `Droid Hive`). You start connected only to the **Airlock Access Node**. To affect droids deep inside the ship, you must establish a chain of links across intermediate junctions (`Power`, `Comms`, `Security`, `Droid Hive`).
@@ -117,7 +131,22 @@ You start connected only to the **Airlock Access Node**. To affect droids deep i
### C. Enemy Counter-Hacking (The Tension Engine) ### D. Fog of War: Camera Mode Map Uncovering
The shared tactical view employs a **Fog of War** mechanic in Cameras mode, where the ship floorplan begins **partially dark** and is progressively uncovered:
* **Initial state:** The tactical view renders with a **dark overlay** over unexplored tiles. Only the airlock room and immediately adjacent areas are visible in full detail; the rest are dimmed/desaturated.
* **Squad movement:** As marines move across the floorplan, tiles they traverse become **fully visible** (unveiled from the fog). This represents the squad physically surveying the ship.
* **Network linkage:** Establishing a network link to a room node (e.g., via `[DOOR_CTRL]` or `[HIVE]`) also **reveals** that room and its immediate surroundings on the tactical view, even if the squad hasn't physically entered yet. This creates a bridge between the cyberspace exploration and the physical ship layout — routing a link to `HIVE` not only grants access to droid-control exploits but also illuminates the HIVE's room on the ship map.
* **Cover crates & doors:** Blast doors and cover crates are initially rendered as ** dimmed outlines**. When a link is established to `DOOR_CTRL`, the door toggles open/closed and its tile becomes fully visible. Adjacent cover crates reveal their tactical properties (50% hit chance reduction) once unveiled.
* **Progressive reveal:** The fog lifts organically through two parallel paths:
1. **Physical exploration** — squad movement reveals tiles in Cameras mode.
2. **Cyberspace exploration** — network link establishment reveals corresponding rooms on the shared tactical view.
This dual-path reveal encourages the player to balance squad positioning with network routing, as each method uncovers different aspects of the ship simultaneously.
* **Bottom Bar — Cyberdeck HUD (`320x48`):** Displays your 4 slotted exploit daemons with cooldown bars, available **RAM**, **CPU Thermal Load** (overheating locks out commands for 4 seconds), your 3 marines' health/suppression pips, and the current view mode. A **Fog of War indicator** shows the percentage of the map currently uncovered.
### E. Enemy Counter-Hacking (The Tension Engine)
Whenever you maintain a link to a **Droid Hive** or **Turret Node**, the Ship-AI initiates a **Trace**: Whenever you maintain a link to a **Droid Hive** or **Turret Node**, the Ship-AI initiates a **Trace**:
@@ -166,8 +195,6 @@ void loop() {
render_cursor(back_buffer); // Cross-mode trackball cursor render_cursor(back_buffer); // Cross-mode trackball cursor
swap_buffers_dma(); // Async SPI flush to ST7789 swap_buffers_dma(); // Async SPI flush to ST7789
}
``` ```
### T-Deck Hardware Gotchas to Handle Early ### T-Deck Hardware Gotchas to Handle Early
@@ -184,4 +211,4 @@ void loop() {
* **Milestone 1 — Hardware Sandbox:** Boot screen on ST7789 via DMA, render shared tactical view (Cameras + Network overlay) + HUD layout, verify smooth trackball cursor + `Space` pause toggle + `P` view switch. * **Milestone 1 — Hardware Sandbox:** Boot screen on ST7789 via DMA, render shared tactical view (Cameras + Network overlay) + HUD layout, verify smooth trackball cursor + `Space` pause toggle + `P` view switch.
* **Milestone 2 — Network Graph & Traces:** Build a 6-node static network in Network view, with door nodes pinned to their bulkhead tiles in the shared space. Allow clicking nodes to form links, cracking an ICE node, and triggering a red enemy trace pulse that can be severed with `X`. * **Milestone 2 — Network Graph & Traces:** Build a 6-node static network in Network view, with door nodes pinned to their bulkhead tiles in the shared space. Allow clicking nodes to form links, cracking an ICE node, and triggering a red enemy trace pulse that can be severed with `X`.
* **Milestone 3 — Autonomous Squad vs. Droids:** Build a 6-room ship floorplan visible in Cameras view. Spawn 3 marines moving toward a clicked Priority Beacon and exchanging fire with 4 droids. * **Milestone 3 — Autonomous Squad vs. Droids:** Build a 6-room ship floorplan visible in Cameras view. Spawn 3 marines moving toward a clicked Priority Beacon and exchanging fire with 4 droids.
* **Milestone 4 — The Cyber-Physical Bridge:** Exploit the shared coordinate space. Linking to a `Droid Hive` node and pressing `1` (`FRENZY.EXE`) turns the droids in the corresponding room red and forces them to attack each other. * **Milestone 4 — The Cyber-Physical Bridge:** Exploit the shared coordinate space. Linking to a `Droid Hive` node and pressing `1` (`FRENZY.EXE`) turns the droids in the corresponding room red and forces them to attack each other.
+229 -40
View File
@@ -203,6 +203,13 @@ static int heatT = 0;
// FRENZY.EXE: >0 = droids attack each other (ticks @ 50ms, 6s = 300) // FRENZY.EXE: >0 = droids attack each other (ticks @ 50ms, 6s = 300)
static int frenzyT = 0; static int frenzyT = 0;
// Frenzy sphere radius (tiles) — only units within this radius of the HIVE node are affected
static const int FRENZY_RADIUS = 6;
// BLIND_OPTICS.SH: >0 = enemies cannot target marines (ticks @ 50ms, 6s = 300)
static int blindT = 0;
// Blind sphere radius (tiles) — affects enemies within this radius of any unit
static const int BLIND_RADIUS = 6;
// feedback spike queues a reinforcement droid (spawned by the combat layer) // feedback spike queues a reinforcement droid (spawned by the combat layer)
static bool reinforcePending = false; static bool reinforcePending = false;
@@ -617,22 +624,49 @@ static bool inCover(int ui)
return false; return false;
} }
// nearest living enemy within range + LOS (unit index — see planPath() note) // nearest living unit within range + LOS (unit index — see planPath() note)
// During FRENZY.EXE (frenzyT > 0), droids ignore team boundaries and target // Target acquisition order per spec:
// the nearest unit — friend or foe — causing droids to attack each other. // 1. if blindT > 0 AND shooter is within HIVE frenzy range: return no target
// 2. affected by frenzy if I AM within range (si)
// 3. if same team and not frenzy: skip this target
// 4. if too far: skip this target
// 5. if not LOS then skip
// 6. else target it!
static int acquireTarget(int si) static int acquireTarget(int si)
{ {
const Unit &u = units[si]; const Unit &u = units[si];
int best = -1; int best = -1;
long bestD = 1L << 30; long bestD = 1L << 30;
// 1. if blindT > 0 AND shooter is within HIVE frenzy range: return no target
bool inFrenzyRange = (frenzyT > 0);
if (inFrenzyRange) {
int ddx = u.tx - NODES[N_HIVE].tx;
int ddy = u.ty - NODES[N_HIVE].ty;
long shooterD2 = (long)ddx * ddx + (long)ddy * ddy;
inFrenzyRange = (shooterD2 <= (long)FRENZY_RADIUS * FRENZY_RADIUS);
}
if (blindT > 0 && inFrenzyRange) return -1;
// 2. Determine if shooter is within frenzy range of HIVE node (for step 3)
// (already computed in step 1 above)
// 3-6. Iterate targets
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
if (i == si || !units[i].alive) continue; if (i == si || !units[i].alive) continue;
// FRENZY: droids do not skip same-team targets
if (frenzyT <= 0 && units[i].team == u.team) continue; // 2. if same team and not frenzy: skip this target
if (!inFrenzyRange && units[i].team == u.team) continue;
// 3. if too far: skip this target
int ddx = (u.tx - units[i].tx) * 2, ddy = (u.ty - units[i].ty) * 2; int ddx = (u.tx - units[i].tx) * 2, ddy = (u.ty - units[i].ty) * 2;
long d2 = (long)ddx * ddx + (long)ddy * ddy; long d2 = (long)ddx * ddx + (long)ddy * ddy;
if (d2 > STATS[u.kind].rng2) continue; if (d2 > STATS[u.kind].rng2) continue;
// 4. if not LOS then skip
if (!losClear(u.tx, u.ty, units[i].tx, units[i].ty)) continue; if (!losClear(u.tx, u.ty, units[i].tx, units[i].ty)) continue;
// 5. else target it!
if (d2 < bestD) { bestD = d2; best = i; } if (d2 < bestD) { bestD = d2; best = i; }
} }
return best; return best;
@@ -974,11 +1008,19 @@ static void handleKey(char c)
if (heatT > 0) { flashMsg("OVERHEAT"); break; } if (heatT > 0) { flashMsg("OVERHEAT"); break; }
if (!nodeOnline[N_HIVE]) { flashMsg("NO HIVE LINK"); playBleep(200, 30); break; } if (!nodeOnline[N_HIVE]) { flashMsg("NO HIVE LINK"); playBleep(200, 30); break; }
// FRENZY.EXE (1) or BLIND_OPTICS.SH (2) — land in Milestone 4 // FRENZY.EXE (1) or BLIND_OPTICS.SH (2) — land in Milestone 4
frenzyT = 300; // 6 seconds @ 50 ms tick; droids turn red & attack each other if (c == '1') {
if (c == '1') playBleep(800, 30); // FRENZY // FRENZY: droids attack everyone within sphere of influence
else playBleep(1200, 30); // BLIND frenzyT = 300; // 6 seconds @ 50 ms tick
Serial.printf("[key] frenzy %c armed (effect lands in M4)\n", c); if (frenzyT > 0) playBleep(800, 30); // FRENZY
flashMsg("FRENZY ACTIVE"); Serial.printf("[key] frenzy armed (effect lands in M4)\n", c);
flashMsg("FRENZY ACTIVE");
} else {
// BLIND_OPTICS.SH: enemies cannot target marines for a short time
blindT = 300; // 6 seconds @ 50 ms tick
playBleep(1200, 30); // BLIND
Serial.printf("[key] blind armed (effect lands in M4)\n", c);
flashMsg("BLIND ACTIVE");
}
break; break;
case 'x': { case 'x': {
if (heatT > 0) { flashMsg("OVERHEAT"); break; } if (heatT > 0) { flashMsg("OVERHEAT"); break; }
@@ -1083,6 +1125,7 @@ static void stepSim()
{ {
simTick++; simTick++;
if (frenzyT > 0) frenzyT--; if (frenzyT > 0) frenzyT--;
if (blindT > 0) blindT--;
stepNetwork(); stepNetwork();
stepUnits(); stepUnits();
} }
@@ -1214,39 +1257,164 @@ static void renderNetwork(bool full)
GFXP->drawCircle(px, py, 5, nd::C_TRACE); GFXP->drawCircle(px, py, 5, nd::C_TRACE);
} }
// nodes // frenzy / blind sphere of influence — only drawn when HIVE is online (connected)
for (int i = 0; i < 4; i++) { // Network mode only; gated by nodeOnline[N_HIVE]
int nx = nodePx(i), ny = nodePy(i); if (full && nodeOnline[N_HIVE]) {
int hoverDx = curX - nx, hoverDy = curY - ny; int cx = nodePx(N_HIVE);
bool hovered = viewMode == VM_NETWORK && hoverDx * hoverDx + hoverDy * hoverDy < 24 * 24; int cy = nodePy(N_HIVE);
if (full) { int r = FRENZY_RADIUS * nd::TILE;
if (nodeOnline[i]) { if (frenzyT > 0 || blindT > 0) {
GFXP->fillCircle(nx, ny, 6, NODES[i].color); // solid circles when frenzy/blind is active
GFXP->drawCircle(nx, ny, 6, TFT_BLACK); if (frenzyT > 0) {
} else { GFXP->drawCircle(cx, cy, r, nd::C_HOT);
GFXP->drawCircle(nx, ny, 6, hovered ? nd::C_CURSOR : nd::C_GHOST); GFXP->drawCircle(cx, cy, r / 2, nd::C_TRACE);
} }
GFXP->setTextDatum(TC_DATUM); // write indicators + tooltips + progress bars
GFXP->setTextColor(nodeOnline[i] ? nd::C_TEXT : nd::C_TEXTDIM); int ty = cy - r - 6; // starting y position
GFXP->drawString(NODES[i].label, nx, ny + 9); int barW = 30, barH = 4;
// door state on the door node // Frenzy "[1]" progress bar
if (i == N_DOOR && nodeOnline[i]) { if (frenzyT > 0) {
GFXP->setTextColor(doorOpen ? nd::C_GOOD : nd::C_TRACE); GFXP->setTextDatum(TC_DATUM);
GFXP->drawString(doorOpen ? "OPEN" : "SHUT", nx, ny + 19); GFXP->setTextColor(nd::C_HOT);
} GFXP->drawString("FRENZY", cx, ty);
// ICE crack progress on the hive int barX = cx - barW / 2;
if (i == N_HIVE) { int barY = ty + 6;
for (int k = 0; k < 3; k++) { GFXP->fillRect(barX, barY, barW, barH, nd::C_BORDER);
if (links[k].active && links[k].b == N_HIVE && links[k].prog < links[k].dur) { int fillW = (frenzyT * barW) / 300;
GFXP->setTextColor(nd::C_TRACE); if (fillW > 0) {
GFXP->drawString("CRACKING", nx, ny + 19); GFXP->fillRect(barX + 1, barY + 1, fillW, barH - 2, nd::C_HOT);
}
} }
GFXP->setTextColor(nd::C_HOT);
GFXP->drawString("[1]", barX + barW / 2, barY + barH + 4);
ty = barY + barH + 8;
}
// Blind "[2]" progress bar
if (blindT > 0) {
GFXP->setTextColor(nd::C_TRACE);
GFXP->drawString("BLIND", cx, ty);
int barX = cx - barW / 2;
int barY = ty + 6;
GFXP->fillRect(barX, barY, barW, barH, nd::C_BORDER);
int fillW = (blindT * barW) / 300;
if (fillW > 0) {
GFXP->fillRect(barX + 1, barY + 1, fillW, barH - 2, nd::C_TRACE);
}
GFXP->setTextColor(nd::C_TRACE);
GFXP->drawString("[2]", barX + barW / 2, barY + barH + 4);
} }
} else { } else {
GFXP->drawCircle(nx, ny, 6, // dotted circle when frenzy/blind is inactive (show sphere of influence)
nodeOnline[i] ? nd::C_GHOST // draw pixels every 5 degrees around the circle
: (hovered ? nd::C_CURSOR : nd::C_GHOST)); for (int a = 0; a < 360; a += 5) {
float rad = a * 3.14159f / 180.0f;
int nx = cx + (int)(r * cosf(rad));
int ny = cy + (int)(r * sinf(rad));
GFXP->drawPixel(nx, ny, nd::C_HOT);
}
}
}
// nodes: render established connections + connectable target nodes
// - nodeOnline[i] == true: filled node with label (established link)
// - node is a connectable target of an online source: ghost circle (known, not yet active)
// these are nodes reachable from online nodes via one edge, but link not built yet
bool isConnectableTarget[4] = { false, false, false, false };
if (full) {
// first pass: identify connectable targets from online sources
for (int s = 0; s < 4; s++) {
// AIRLK is always a source; others if online
bool srcOnline = nodeOnline[s];
if (s == 0) srcOnline = true; // AIRLK always source
if (!srcOnline) continue;
for (int e = 0; e < 3; e++) {
int a = EDGES[e][0], b = EDGES[e][1];
if (a != s && b != s) continue;
int neighbor = (a == s) ? b : a;
if (!nodeOnline[neighbor]) { // not already online
isConnectableTarget[neighbor] = true;
}
}
}
}
for (int i = 0; i < 4; i++) {
int nx = nodePx(i), ny = nodePy(i);
if (full) {
if (nodeOnline[i]) {
// established connection: filled node with label
GFXP->fillCircle(nx, ny, 6, NODES[i].color);
GFXP->drawCircle(nx, ny, 6, TFT_BLACK);
GFXP->setTextDatum(TC_DATUM);
GFXP->setTextColor(nd::C_TEXT);
GFXP->drawString(NODES[i].label, nx, ny + 9);
// door state on the door node
if (i == N_DOOR && nodeOnline[i]) {
GFXP->setTextColor(doorOpen ? nd::C_GOOD : nd::C_TRACE);
GFXP->drawString(doorOpen ? "OPEN" : "SHUT", nx, ny + 19);
}
// ICE crack progress on the hive
if (i == N_HIVE) {
for (int k = 0; k < 3; k++) {
if (links[k].active && links[k].b == N_HIVE && links[k].prog < links[k].dur) {
GFXP->setTextColor(nd::C_TRACE);
GFXP->drawString("CRACKING", nx, ny + 19);
}
}
}
} else if (isConnectableTarget[i]) {
// known but not yet active: ghost circle (no label, outline only)
GFXP->drawCircle(nx, ny, 6, nd::C_GHOST);
// no text label for connectable-but-not-yet-online nodes
}
// else: skip rendering node — no connection at all
} else {
// Cameras mode: only show node outline if online (light overlay)
if (nodeOnline[i]) {
GFXP->drawCircle(nx, ny, 6, nd::C_GHOST);
}
}
}
// connectable neighbours: from every online (or starting) node, draw
// dotted lines to adjacent nodes that can be linked to, but do NOT render
// the neighbour nodes themselves until their link is established.
// This gives the player immediate connection targets from AIRLK at boot.
// Uses a simple "every-other-pixel" dotted pattern along the Bresenham line.
if (full) {
// determine which node ids are "available as connection sources"
// AIRLK is always online (starting node); others if nodeOnline
bool srcOnline[4] = { nodeOnline[0], nodeOnline[1], nodeOnline[2], nodeOnline[3] };
// ensure AIRLK is always a source even if somehow offline
srcOnline[0] = true;
auto drawDottedLine = [&](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, e2;
int step = 0;
for (;;) {
if ((step++ & 1) == 0) GFXP->drawPixel(x0, y0, nd::C_GHOST);
if (x0 == x1 && y0 == y1) break;
e2 = 2 * err;
if (e2 >= dy) { err += dy; x0 += sx; }
if (e2 <= dx) { err += dx; y0 += sy; }
}
};
for (int s = 0; s < 4; s++) {
if (!srcOnline[s]) continue;
// find edges where this node is one endpoint
for (int e = 0; e < 3; e++) {
int a = EDGES[e][0], b = EDGES[e][1];
if (a != s && b != s) continue;
int neighbor = (a == s) ? b : a;
// skip if neighbor already online (established connection — link already rendered above)
if (nodeOnline[neighbor]) continue;
// draw dotted line from source to connectable neighbor
int x0 = nodePx(s), y0 = nodePy(s);
int x1 = nodePx(neighbor), y1 = nodePy(neighbor);
drawDottedLine(x0, y0, x1, y1);
}
} }
} }
@@ -1268,6 +1436,7 @@ static void renderBeacon()
// entity sprites + overhead HP bars (dimmed ghosting in Network view) // entity sprites + overhead HP bars (dimmed ghosting in Network view)
// Droids are rendered in red when FRENZY.EXE is active // Droids are rendered in red when FRENZY.EXE is active
// Units are outlined in NETWORK mode only for better visibility
static void renderUnits(bool full) static void renderUnits(bool full)
{ {
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
@@ -1287,6 +1456,20 @@ static void renderUnits(bool full)
} }
if (!full) { body = dim565(body); line = dim565(line); } if (!full) { body = dim565(body); line = dim565(line); }
// Draw outline in network mode only
// Use green for friendly marines, red for enemy droids/heavies/turrets
if (!full) {
uint16_t outlineColor = (u.kind == U_MARINE) ? nd::C_GOOD : nd::C_HOT;
int s = (u.kind == U_HEAVY) ? 7 : 6;
if (u.kind == U_TURRET) {
GFXP->drawCircle(px, py - 1, 3 + s, outlineColor);
GFXP->drawFastVLine(px, py + 2, 3 + s, outlineColor);
} else {
GFXP->drawRect(px - s / 2 - 1, py - s / 2 - 1, s + 2, s + 2, outlineColor);
GFXP->drawFastHLine(px - 1 - 1, py - s / 2 - 2 - 1, 2 + 2, outlineColor);
}
}
if (u.kind == U_TURRET) { // ceiling mount: circle + barrel if (u.kind == U_TURRET) { // ceiling mount: circle + barrel
GFXP->fillCircle(px, py - 1, 3, body); GFXP->fillCircle(px, py - 1, 3, body);
GFXP->drawCircle(px, py - 1, 3, line); GFXP->drawCircle(px, py - 1, 3, line);
@@ -1355,7 +1538,13 @@ static void renderHud()
GFXP->drawString(String("[") + char('1' + i) + "]", x, y); GFXP->drawString(String("[") + char('1' + i) + "]", x, y);
GFXP->setTextColor(nd::C_TEXTDIM); GFXP->setTextColor(nd::C_TEXTDIM);
GFXP->drawString(NAMES[i], x + 20, y); GFXP->drawString(NAMES[i], x + 20, y);
meterBar(x, y + 14, 48, 6, 100, nodeOnline[N_HIVE] ? nd::C_GOOD : nd::C_BORDER); if (i == 0) {
// FRENZY meter shows remaining frenzy time
meterBar(x, y + 14, 48, 6, 100 * frenzyT / 300, frenzyT > 0 ? nd::C_HOT : nd::C_BORDER);
} else {
// BLIND meter shows remaining blind time
meterBar(x, y + 14, 48, 6, 100 * blindT / 300, blindT > 0 ? nd::C_TRACE : nd::C_BORDER);
}
} }
// TEMP bar (overheat lockout) // TEMP bar (overheat lockout)