From 0b338bbd007048551526ab4fa4130d53b414e650 Mon Sep 17 00:00:00 2001 From: jacopo grandi Date: Wed, 24 Feb 2021 16:38:42 +0100 Subject: fire and movement animations --- gst/units.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gst/units.c') diff --git a/gst/units.c b/gst/units.c index 89c9489..b699e26 100644 --- a/gst/units.c +++ b/gst/units.c @@ -184,7 +184,7 @@ int army_move (infos *info, army *ar, map *m) { return iter; } -int army_fire (infos *info, army *ar, map *m) { +int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[]) { for (int i=0; iuslen; i++) { unit *u = ar->us+i; int lw = u->info.levels[LEVEL_CHASSIS]; @@ -192,7 +192,7 @@ int army_fire (infos *info, army *ar, map *m) { u->cooldown[j] += 1; } } - struct dmg { unit *u; float dam; } dmgs[1024*8]; int dmgslen = 0; + int dmgslen = 0; unit *t[32]; for (int i=0; iuslen; i++) { unit *u = ar->us+i; @@ -205,7 +205,8 @@ int army_fire (infos *info, army *ar, map *m) { float range = info_unit_get_range(info, &u->info, j); unit_search(info, ar, m, u, t, range); if (t[0]!=NULL) { - dmgs[dmgslen].u = t[0]; + dmgs[dmgslen].u = u; + dmgs[dmgslen].t = t[0]; dmgs[dmgslen].dam = info_unit_get_damage_target( info, &u->info, j, &t[0]->info); dmgslen++; @@ -216,9 +217,9 @@ int army_fire (infos *info, army *ar, map *m) { } } for (int i=0; ihp -= dmgs[i].dam; - if (dmgs[i].u->hp <= 0) { - unit_dead(ar, m, dmgs[i].u); + dmgs[i].t->hp -= dmgs[i].dam; + if (dmgs[i].t->hp <= 0) { + unit_dead(ar, m, dmgs[i].t); } } return dmgslen; -- cgit v1.2.3-54-g00ecf