engine-c: lasting death RUBBLE/SCRAP scars + denser scorch

This commit is contained in:
local-model/engine-L2-grok-4.5 2026-09-19 11:50:41 +02:00
parent 3fb17411dc
commit bab388723f
No known key found for this signature in database
4 changed files with 96 additions and 9 deletions

View file

@ -254,6 +254,80 @@ void map_deplete_scrap(GameMap *m, int tx, int ty, int amount) {
}
}
/* Soft scar: never overwrite WATER/ROCK; never clear walkable. */
static int map_scar_ok(Tile *t) {
if (!t) return 0;
if (t->terrain == T_WATER || t->terrain == T_ROCK) return 0;
return 1;
}
void map_scar_rubble(GameMap *m, int tx, int ty) {
Tile *t = map_tile(m, tx, ty);
if (!map_scar_ok(t)) return;
/* keep ROAD as approach cue; scrap fields stay harvestable */
if (t->terrain == T_ROAD || t->terrain == T_SCRAP) return;
t->terrain = T_RUBBLE;
t->scrap = 0;
t->walkable = 1;
}
void map_scar_scrap_fleck(GameMap *m, int tx, int ty, uint8_t amount) {
Tile *t = map_tile(m, tx, ty);
if (!map_scar_ok(t)) return;
if (t->terrain == T_ROAD) return;
if (t->terrain == T_SCRAP && t->scrap > 0) return; /* leave live fields alone */
t->terrain = T_SCRAP;
t->scrap = amount ? amount : 40;
t->walkable = 1;
}
void map_scar_unit_death(GameMap *m, float wx, float wy, UnitType type) {
int tx, ty;
map_world_to_tile(wx, wy, &tx, &ty);
map_scar_rubble(m, tx, ty);
int vehicle = (type == UT_BUGGY || type == UT_TANK || type == UT_HARVESTER
|| type == UT_ARTILLERY || type == UT_JEEP || type == UT_RAVAGER
|| type == UT_MISSILE || type == UT_BEAST);
int heavy = (type == UT_TANK || type == UT_RAVAGER || type == UT_ARTILLERY
|| type == UT_HARVESTER);
if (!vehicle) return;
/* adjacent rubble ring — still soft / walkable */
static const int ox[8] = { 1,-1, 0, 0, 1, 1,-1,-1 };
static const int oy[8] = { 0, 0, 1,-1, 1,-1, 1,-1 };
int n = heavy ? 6 : 3;
for (int i = 0; i < n; i++)
map_scar_rubble(m, tx + ox[i], ty + oy[i]);
/* small scrap flecks from wrecked chassis */
if (heavy) {
map_scar_scrap_fleck(m, tx + 1, ty - 1, (uint8_t)(55 + ((tx * 7 + ty) & 63)));
map_scar_scrap_fleck(m, tx - 1, ty + 1, (uint8_t)(40 + ((tx * 3 + ty * 5) & 47)));
} else {
map_scar_scrap_fleck(m, tx + ox[tx & 3], ty + oy[ty & 3],
(uint8_t)(35 + ((tx + ty) & 31)));
}
}
void map_scar_bld_death(GameMap *m, int tx, int ty, int w, int h) {
if (w < 1) w = 1;
if (h < 1) h = 1;
for (int y = ty; y < ty + h; y++) {
for (int x = tx; x < tx + w; x++) {
map_scar_rubble(m, x, y);
/* outer flecks just outside footprint */
if (x == tx) map_scar_rubble(m, x - 1, y);
if (x == tx + w - 1) map_scar_rubble(m, x + 1, y);
if (y == ty) map_scar_rubble(m, x, y - 1);
if (y == ty + h - 1) map_scar_rubble(m, x, y + 1);
}
}
/* one scrap pile from collapsed structure */
map_scar_scrap_fleck(m, tx + w / 2, ty + h / 2,
(uint8_t)(70 + ((tx * 11 + ty * 13) & 80)));
}
/* ----------------------------- A* ----------------------------- */
/* Binary heap of tile indices keyed by f-score in a parallel array. */
#define ASTAR_NODES (MAP_W * MAP_H)