engine-c: scaffold beams + bld damage FX + wear showcase

This commit is contained in:
local-model/engine-L2-grok-4.5 2026-09-19 12:03:13 +02:00
parent a086ab23a6
commit b2469dbcde
No known key found for this signature in database
3 changed files with 114 additions and 4 deletions

View file

@ -66,6 +66,39 @@ static void bld_force_complete(Game *g) {
}
}
/* After force-complete: leave a few incomplete yards + battle-worn
* fortifications near the raid locus so scaffold/damage FX show in KKND_SHOT. */
static void showcase_bld_battle_wear(Game *g) {
int incomplete_n = 0, damaged_n = 0;
float wx, wy;
map_tile_to_world(g->map.spawn_x[g->human], g->map.spawn_y[g->human], &wx, &wy);
float rx = wx + 88.0f, ry = wy - 48.0f;
for (int i = 0; i < g->bld_count; i++) {
Building *b = &g->buildings[i];
if (b->dead) continue;
float cx = (b->tx + b->w * 0.5f) * (float)TILE;
float cy = (b->ty + b->h * 0.5f) * (float)TILE;
float dx = cx - rx, dy = cy - ry;
float d2 = dx * dx + dy * dy;
/* mid-base construction yards (away from clash) */
if (incomplete_n < 2 && b->faction == g->human && d2 > 180.0f * 180.0f &&
(b->type == BT_REPAIR || b->type == BT_RESEARCH || b->type == BT_WARFACTORY)) {
b->build = (incomplete_n == 0) ? 0.55f : 0.72f;
b->hp = b->max_hp * b->build * 0.9f;
incomplete_n++;
continue;
}
/* clash fortifications: turrets / walls / power take hits */
if (damaged_n < 6 && d2 < 160.0f * 160.0f &&
(b->type == BT_TURRET || b->type == BT_WALL || b->type == BT_POWER)) {
float frac = (damaged_n % 3 == 0) ? 0.35f
: (damaged_n % 3 == 1) ? 0.55f : 0.72f;
b->hp = b->max_hp * frac;
damaged_n++;
}
}
}
static void place_start(Game *g, Faction f) {
int sx = g->map.spawn_x[f], sy = g->map.spawn_y[f];
int bx = sx - 1, by = sy - 1;
@ -465,6 +498,9 @@ void engine_setup_match(Game *g, int mission_id) {
bld_force_complete(g);
}
/* demo incomplete yards + damaged clash fortifications for scaffold/FX */
showcase_bld_battle_wear(g);
/* centre camera on player base */
int hx = g->map.spawn_x[g->human], hy = g->map.spawn_y[g->human];
g->cam.x = (float)(hx*TILE - VIEW_W/2);