engine-c: live heading tick + muzzle/death FX
This commit is contained in:
parent
7b182166e8
commit
073f38db7a
2 changed files with 36 additions and 15 deletions
|
|
@ -62,12 +62,15 @@ void unit_apply_damage(Game *g, Unit *u, float dmg) {
|
|||
float eff = dmg - u->defense * 0.25f;
|
||||
if (eff < 1) eff = 1;
|
||||
u->hp -= eff;
|
||||
particle_burst(g, u->x, u->y, 3, 2, 255, 200, 80);
|
||||
particle_burst(g, u->x, u->y, 4, 2, 255, 200, 80);
|
||||
if (u->hp <= 0 && !u->dead) {
|
||||
u->dead = 1;
|
||||
u->state = STATE_DEAD;
|
||||
particle_burst(g, u->x, u->y, 14, 1, 255, 140, 40);
|
||||
particle_burst(g, u->x, u->y, 8, 3, 90, 80, 70);
|
||||
/* denser KKND2-like death: fire core + debris ring + smoke */
|
||||
particle_burst(g, u->x, u->y, 18, 1, 255, 140, 40);
|
||||
particle_burst(g, u->x, u->y, 10, 3, 90, 80, 70);
|
||||
particle_burst(g, u->x + 6, u->y - 4, 8, 0, 110, 100, 90);
|
||||
particle_burst(g, u->x - 5, u->y + 5, 6, 2, 255, 220, 90);
|
||||
audio_sfx(2);
|
||||
if (g->cam.shake < 7) g->cam.shake = 7;
|
||||
if (u->faction == g->human)
|
||||
|
|
@ -320,8 +323,13 @@ static void unit_combat_step(Game *g, Unit *u, float dt) {
|
|||
if (u->atk_cd <= 0) {
|
||||
int kind = (u->type == UT_ARTILLERY || u->type == UT_MISSILE || u->type == UT_TANK)
|
||||
? 1 : 0;
|
||||
if (tu) bullet_spawn(g, u->x, u->y, tu->id, -1, u->attack, u->faction, kind);
|
||||
else bullet_spawn(g, u->x, u->y, -1, tb->id, u->attack, u->faction, kind);
|
||||
/* muzzle offset along heading so shot/live FX sit at barrel tip */
|
||||
float mx = u->x + cosf(u->heading) * 14.0f;
|
||||
float my = u->y + sinf(u->heading) * 14.0f;
|
||||
if (tu) bullet_spawn(g, mx, my, tu->id, -1, u->attack, u->faction, kind);
|
||||
else bullet_spawn(g, mx, my, -1, tb->id, u->attack, u->faction, kind);
|
||||
particle_burst(g, mx, my, 5, 2, 255, 230, 120);
|
||||
particle_burst(g, mx, my, 3, 1, 255, 160, 50);
|
||||
u->atk_cd = ((u->type == UT_ARTILLERY) ? 2.2f
|
||||
: (u->type == UT_INFANTRY ? 0.8f : 1.0f)) / u->reload_mul;
|
||||
u->anim = 1.0f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue