engine-c: wreck draw + type variety + clash seed for KKND2 battlefield

Snapshot/live wreck silhouettes (type-aware hulls, scorch/smoke), seed ~22 clash wrecks in place_showcase, reset wreck ring on match setup.
This commit is contained in:
local-model/engine-L2-grok-4.5 2026-09-19 16:05:12 +02:00
parent 252cfd8175
commit d54d38e8df
No known key found for this signature in database
5 changed files with 176 additions and 5 deletions

View file

@ -456,6 +456,85 @@ static void draw_unit(Unit *u, int sx, int sy) {
#undef SI
}
/* Charred wreck silhouettes — dim faction paint + scorch, type-aware hull. */
static void draw_wreck(Wreck *w, int sx, int sy) {
uint8_t br = faction_r(w->faction), bg = faction_g(w->faction), bb = faction_b(w->faction);
uint8_t dr, dg, db;
darken3(br, bg, bb, 0.38f, &dr, &dg, &db);
uint8_t ok = 28, og = 24, ob = 20;
uint8_t ch = 48, cg = 42, cb = 36; /* char */
float c = cosf(w->rot), s = sinf(w->rot);
const float sc = SHOT_UNIT_SCALE * 0.92f;
#define SI(n) ((int)((n) * sc + 0.5f))
#define LX(lx, ly) (sx + (int)((((lx)-15)*sc)*c - (((ly)-15)*sc)*s))
#define LY(lx, ly) (sy + (int)((((lx)-15)*sc)*s + (((ly)-15)*sc)*c))
disc(sx + SI(2), sy + SI(4), SI(10), 42, 36, 28); /* scorch stain */
switch (w->type) {
case UT_HARVESTER:
fill_rect(sx - SI(14), sy - SI(9), SI(28), SI(18), ok, og, ob);
fill_rect(sx - SI(12), sy - SI(7), SI(24), SI(14), dr, dg, db);
fill_rect(LX(6, 12) - SI(1), LY(6, 12) - SI(1), SI(10), SI(8), ch, cg, cb);
disc(LX(8, 8), LY(8, 8), SI(4), ok, og, ob);
disc(LX(22, 8), LY(22, 8), SI(4), ok, og, ob);
disc(LX(8, 22), LY(8, 22), SI(4), ok, og, ob);
disc(LX(22, 22), LY(22, 22), SI(4), ok, og, ob);
fill_rect(sx - SI(4), sy - SI(2), SI(10), SI(5), 55, 48, 40); /* torn bed */
break;
case UT_TANK:
case UT_RAVAGER:
case UT_BEAST:
fill_rect(sx - SI(13), sy - SI(8), SI(26), SI(16), ok, og, ob);
fill_rect(sx - SI(11), sy - SI(6), SI(22), SI(12), dr, dg, db);
fill_rect(sx - SI(12), sy - SI(3), SI(4), SI(8), ch, cg, cb); /* track */
fill_rect(sx + SI(8), sy - SI(3), SI(4), SI(8), ch, cg, cb);
disc(sx, sy - SI(2), SI(6), ok, og, ob);
disc(sx, sy - SI(2), SI(4), ch, cg, cb); /* dead turret */
line(LX(15, 8), LY(15, 8), LX(15, -2), LY(15, -2), 40, 36, 30); /* bent barrel */
break;
case UT_ARTILLERY:
case UT_MISSILE:
fill_rect(sx - SI(12), sy - SI(7), SI(24), SI(14), ok, og, ob);
fill_rect(sx - SI(10), sy - SI(5), SI(20), SI(10), dr, dg, db);
disc(LX(8, 20), LY(8, 20), SI(4), ok, og, ob);
disc(LX(22, 20), LY(22, 20), SI(4), ok, og, ob);
line(LX(12, 12), LY(12, 12), LX(22, 2), LY(22, 2), ch, cg, cb);
break;
case UT_BUGGY:
case UT_JEEP:
case UT_FLAME:
case UT_MEDIC:
fill_rect(sx - SI(11), sy - SI(7), SI(22), SI(14), ok, og, ob);
fill_rect(sx - SI(9), sy - SI(5), SI(18), SI(10), dr, dg, db);
disc(LX(8, 8), LY(8, 8), SI(4), ok, og, ob);
disc(LX(22, 8), LY(22, 8), SI(4), ok, og, ob);
disc(LX(8, 22), LY(8, 22), SI(4), ok, og, ob);
disc(LX(22, 22), LY(22, 22), SI(4), ok, og, ob);
fill_rect(LX(10, 10) - SI(1), LY(10, 10) - SI(1), SI(8), SI(5), ch, cg, cb);
break;
case UT_INFANTRY:
case UT_MUTANT:
disc(sx + SI(1), sy + SI(2), SI(6), ok, og, ob);
disc(sx, sy, SI(5), dr, dg, db);
disc(sx - SI(3), sy + SI(4), SI(3), ch, cg, cb); /* crumpled kit */
disc(sx + SI(4), sy + SI(3), SI(2), 40, 36, 30);
break;
default:
fill_rect(sx - SI(10), sy - SI(6), SI(20), SI(12), ok, og, ob);
fill_rect(sx - SI(8), sy - SI(4), SI(16), SI(8), dr, dg, db);
disc(sx - SI(5), sy + SI(2), SI(3), ch, cg, cb);
disc(sx + SI(6), sy - SI(1), SI(3), ch, cg, cb);
break;
}
/* smoke puff cue */
disc(sx + SI(3), sy - SI(8), SI(3), 70, 68, 64);
disc(sx + SI(5), sy - SI(12), SI(2), 90, 88, 82);
#undef LX
#undef LY
#undef SI
}
/* Building silhouettes: bright pad + faction fill, thin black outline. */
static void draw_bld(Building *b, int sx, int sy) {
int W = b->w * TILE, H = b->h * TILE;
@ -775,6 +854,14 @@ void snapshot_capture(Game *g, const char *path) {
draw_bld(b, sx, sy);
}
/* wrecks under living units (battlefield litter) */
for (int i = 0; i < g->wreck_count; i++) {
Wreck *w = &g->wrecks[i];
int sx = (int)(w->x - camx), sy = (int)(w->y - camy);
if (sx < -24 || sy < -24 || sx > g_sw + 24 || sy > g_sh + 24) continue;
draw_wreck(w, sx, sy);
}
/* units */
for (int i = 0; i < g->unit_count; i++) {
Unit *u = &g->units[i];