engine-c: denser mid-fight fire/smoke/muzzle/impact for KKND2 combat read
This commit is contained in:
parent
72b2c0dc0a
commit
01c7ab8b76
5 changed files with 112 additions and 57 deletions
|
|
@ -147,40 +147,74 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
if (n > 0) { cx /= n; cy /= n; }
|
||||
else { cx = clash_x; cy = clash_y; }
|
||||
particle_burst(g, cx, cy, 56, 1, 255, 140, 40);
|
||||
particle_burst(g, cx + 22, cy - 12, 36, 0, 110, 100, 90);
|
||||
particle_burst(g, cx - 18, cy + 14, 40, 2, 255, 230, 90);
|
||||
particle_burst(g, cx + 36, cy + 8, 30, 1, 255, 90, 30);
|
||||
particle_burst(g, cx - 8, cy - 28, 32, 3, 95, 80, 65);
|
||||
particle_burst(g, cx + 12, cy + 30, 28, 1, 255, 170, 55);
|
||||
particle_burst(g, cx - 30, cy - 6, 26, 1, 255, 120, 40);
|
||||
particle_burst(g, cx + 28, cy + 22, 24, 2, 255, 210, 80);
|
||||
particle_burst(g, cx - 40, cy + 18, 22, 1, 255, 100, 35);
|
||||
particle_burst(g, cx + 44, cy - 16, 20, 2, 255, 240, 100);
|
||||
particle_burst(g, cx + 8, cy - 40, 18, 1, 255, 150, 45);
|
||||
particle_burst(g, cx - 22, cy + 36, 18, 0, 120, 110, 95);
|
||||
/* denser mid-fight plate: fire cores + smoke columns + sparks */
|
||||
particle_burst(g, cx, cy, 72, 1, 255, 140, 40);
|
||||
particle_burst(g, cx + 22, cy - 12, 48, 0, 110, 100, 90);
|
||||
particle_burst(g, cx - 18, cy + 14, 52, 2, 255, 230, 90);
|
||||
particle_burst(g, cx + 36, cy + 8, 40, 1, 255, 90, 30);
|
||||
particle_burst(g, cx - 8, cy - 28, 42, 3, 95, 80, 65);
|
||||
particle_burst(g, cx + 12, cy + 30, 36, 1, 255, 170, 55);
|
||||
particle_burst(g, cx - 30, cy - 6, 34, 1, 255, 120, 40);
|
||||
particle_burst(g, cx + 28, cy + 22, 32, 2, 255, 210, 80);
|
||||
particle_burst(g, cx - 40, cy + 18, 30, 1, 255, 100, 35);
|
||||
particle_burst(g, cx + 44, cy - 16, 28, 2, 255, 240, 100);
|
||||
particle_burst(g, cx + 8, cy - 40, 26, 1, 255, 150, 45);
|
||||
particle_burst(g, cx - 22, cy + 36, 26, 0, 120, 110, 95);
|
||||
particle_burst(g, cx + 52, cy + 4, 24, 1, 255, 110, 30);
|
||||
particle_burst(g, cx - 48, cy - 14, 22, 0, 100, 95, 85);
|
||||
particle_burst(g, cx + 16, cy + 48, 20, 3, 85, 70, 55);
|
||||
particle_burst(g, cx - 12, cy - 48, 20, 1, 255, 160, 50);
|
||||
/* building smoke / fire columns near clash (HQ, walls, turrets) */
|
||||
for (int i = 0; i < g->bld_count; i++) {
|
||||
Building *bl = &g->buildings[i];
|
||||
if (bl->dead || bl->build < 1.0f) continue;
|
||||
float bx = (float)(bl->tx * TILE + bl->w * TILE / 2);
|
||||
float by = (float)(bl->ty * TILE + bl->h * TILE / 2);
|
||||
float bdx = bx - clash_x, bdy = by - clash_y;
|
||||
if (bdx * bdx + bdy * bdy > r2) continue;
|
||||
int smoke_n = (bl->type == BT_BASE || bl->type == BT_TURRET) ? 18 : 12;
|
||||
particle_burst(g, bx, by - 10.0f, smoke_n, 0, 105, 95, 85);
|
||||
if (bl->hp < bl->max_hp * 0.85f || bl->type == BT_TURRET) {
|
||||
particle_burst(g, bx + 4.0f, by - 6.0f, 14, 1, 255, 130, 40);
|
||||
particle_burst(g, bx - 3.0f, by - 14.0f, 8, 3, 90, 75, 60);
|
||||
}
|
||||
}
|
||||
/* muzzle flashes on units in the clash radius */
|
||||
{
|
||||
int muz = 0;
|
||||
for (int i = 0; i < g->unit_count && muz < 28; i++) {
|
||||
Unit *u = &g->units[i];
|
||||
if (u->dead) continue;
|
||||
float ux = u->x - clash_x, uy = u->y - clash_y;
|
||||
if (ux * ux + uy * uy > r2) continue;
|
||||
if ((i + muz) % 3 != 0) continue;
|
||||
particle_burst(g, u->x + 6.0f, u->y - 4.0f, 6, 2, 255, 230, 120);
|
||||
particle_burst(g, u->x + 4.0f, u->y - 2.0f, 4, 1, 255, 160, 50);
|
||||
muz++;
|
||||
}
|
||||
}
|
||||
/* Mid-flight shells/missiles/lasers: after ~1s sim most live
|
||||
* bullets have already impacted. Reseed between nearby opposing
|
||||
* pairs so the PNG shows KKND2-like tracers across the clash. */
|
||||
{
|
||||
int spawned = 0;
|
||||
const float pair_r2 = 170.0f * 170.0f;
|
||||
for (int i = 0; i < g->unit_count && spawned < 56; i++) {
|
||||
const float pair_r2 = 180.0f * 180.0f;
|
||||
for (int i = 0; i < g->unit_count && spawned < 72; i++) {
|
||||
Unit *a = &g->units[i];
|
||||
if (a->dead) continue;
|
||||
float ax = a->x - clash_x, ay = a->y - clash_y;
|
||||
if (ax * ax + ay * ay > r2) continue;
|
||||
int shots = 0;
|
||||
for (int j = 0; j < g->unit_count && spawned < 56 && shots < 2; j++) {
|
||||
for (int j = 0; j < g->unit_count && spawned < 72 && shots < 3; j++) {
|
||||
Unit *b = &g->units[j];
|
||||
if (b->dead || b->faction == a->faction) continue;
|
||||
float dx = b->x - a->x, dy = b->y - a->y;
|
||||
float d2 = dx * dx + dy * dy;
|
||||
if (d2 > pair_r2 || d2 < 24.0f * 24.0f) continue;
|
||||
if (d2 > pair_r2 || d2 < 20.0f * 20.0f) continue;
|
||||
int kind = (spawned % 4 == 0) ? 3
|
||||
: (spawned % 4 == 1) ? 1
|
||||
: (spawned % 4 == 2) ? 2 : 0;
|
||||
float t = 0.22f + 0.55f * ((spawned * 37) % 100) / 100.0f;
|
||||
float t = 0.18f + 0.60f * ((spawned * 37) % 100) / 100.0f;
|
||||
float sx = a->x + dx * t;
|
||||
float sy = a->y + dy * t;
|
||||
bullet_spawn(g, sx, sy, b->id, -1, 1.0f, a->faction, kind);
|
||||
|
|
@ -189,7 +223,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
/* turret / base guns → nearest enemy in clash */
|
||||
for (int i = 0; i < g->bld_count && spawned < 64; i++) {
|
||||
for (int i = 0; i < g->bld_count && spawned < 88; i++) {
|
||||
Building *bl = &g->buildings[i];
|
||||
if (bl->dead || (bl->type != BT_TURRET && bl->type != BT_BASE))
|
||||
continue;
|
||||
|
|
@ -208,9 +242,10 @@ int main(int argc, char **argv) {
|
|||
if (best < 0) continue;
|
||||
Unit *tgt = &g->units[best];
|
||||
float dx = tgt->x - bx, dy = tgt->y - by;
|
||||
float t = 0.30f + 0.40f * ((spawned * 19) % 100) / 100.0f;
|
||||
float t = 0.25f + 0.45f * ((spawned * 19) % 100) / 100.0f;
|
||||
bullet_spawn(g, bx + dx * t, by + dy * t, tgt->id, -1,
|
||||
2.0f, bl->faction, (spawned & 1) ? 1 : 2);
|
||||
particle_burst(g, bx, by - 4.0f, 5, 2, 255, 220, 100);
|
||||
spawned++;
|
||||
}
|
||||
}
|
||||
|
|
@ -227,39 +262,41 @@ int main(int argc, char **argv) {
|
|||
sx2 += u->x; sy2 += u->y; n2++;
|
||||
}
|
||||
if (n2 > 0) { c2x = sx2 / n2; c2y = sy2 / n2; }
|
||||
particle_burst(g, c2x, c2y, 40, 1, 255, 135, 35);
|
||||
particle_burst(g, c2x + 18, c2y - 10, 28, 0, 115, 105, 90);
|
||||
particle_burst(g, c2x - 14, c2y + 12, 30, 2, 255, 220, 85);
|
||||
particle_burst(g, c2x + 26, c2y + 8, 22, 1, 255, 95, 28);
|
||||
particle_burst(g, c2x - 6, c2y - 20, 24, 3, 90, 78, 62);
|
||||
particle_burst(g, c2x + 10, c2y + 24, 20, 1, 255, 160, 50);
|
||||
particle_burst(g, c2x, c2y, 52, 1, 255, 135, 35);
|
||||
particle_burst(g, c2x + 18, c2y - 10, 36, 0, 115, 105, 90);
|
||||
particle_burst(g, c2x - 14, c2y + 12, 40, 2, 255, 220, 85);
|
||||
particle_burst(g, c2x + 26, c2y + 8, 30, 1, 255, 95, 28);
|
||||
particle_burst(g, c2x - 6, c2y - 20, 32, 3, 90, 78, 62);
|
||||
particle_burst(g, c2x + 10, c2y + 24, 28, 1, 255, 160, 50);
|
||||
particle_burst(g, c2x - 28, c2y + 8, 24, 0, 100, 95, 80);
|
||||
particle_burst(g, c2x + 32, c2y - 16, 22, 1, 255, 120, 40);
|
||||
{
|
||||
int spawned2 = 0;
|
||||
const float pair_r2 = 150.0f * 150.0f;
|
||||
const float pair_r2 = 160.0f * 160.0f;
|
||||
const float r2b = 140.0f * 140.0f;
|
||||
for (int i = 0; i < g->unit_count && spawned2 < 36; i++) {
|
||||
for (int i = 0; i < g->unit_count && spawned2 < 48; i++) {
|
||||
Unit *a = &g->units[i];
|
||||
if (a->dead) continue;
|
||||
float ax = a->x - clash2_x, ay = a->y - clash2_y;
|
||||
if (ax * ax + ay * ay > r2b) continue;
|
||||
int shots = 0;
|
||||
for (int j = 0; j < g->unit_count && spawned2 < 36 && shots < 2; j++) {
|
||||
for (int j = 0; j < g->unit_count && spawned2 < 48 && shots < 3; j++) {
|
||||
Unit *b = &g->units[j];
|
||||
if (b->dead || b->faction == a->faction) continue;
|
||||
float dx = b->x - a->x, dy = b->y - a->y;
|
||||
float d2 = dx * dx + dy * dy;
|
||||
if (d2 > pair_r2 || d2 < 20.0f * 20.0f) continue;
|
||||
if (d2 > pair_r2 || d2 < 18.0f * 18.0f) continue;
|
||||
int kind = (spawned2 % 4 == 0) ? 3
|
||||
: (spawned2 % 4 == 1) ? 1
|
||||
: (spawned2 % 4 == 2) ? 2 : 0;
|
||||
float t = 0.20f + 0.55f * ((spawned2 * 41) % 100) / 100.0f;
|
||||
float t = 0.18f + 0.58f * ((spawned2 * 41) % 100) / 100.0f;
|
||||
bullet_spawn(g, a->x + dx * t, a->y + dy * t,
|
||||
b->id, -1, 1.0f, a->faction, kind);
|
||||
spawned2++;
|
||||
shots++;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < g->bld_count && spawned2 < 44; i++) {
|
||||
for (int i = 0; i < g->bld_count && spawned2 < 56; i++) {
|
||||
Building *bl = &g->buildings[i];
|
||||
if (bl->dead || (bl->type != BT_TURRET && bl->type != BT_BASE))
|
||||
continue;
|
||||
|
|
@ -278,7 +315,7 @@ int main(int argc, char **argv) {
|
|||
if (best < 0) continue;
|
||||
Unit *tgt = &g->units[best];
|
||||
float dx = tgt->x - bx, dy = tgt->y - by;
|
||||
float t = 0.28f + 0.42f * ((spawned2 * 23) % 100) / 100.0f;
|
||||
float t = 0.26f + 0.44f * ((spawned2 * 23) % 100) / 100.0f;
|
||||
bullet_spawn(g, bx + dx * t, by + dy * t, tgt->id, -1,
|
||||
2.0f, bl->faction, (spawned2 & 1) ? 1 : 2);
|
||||
spawned2++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue