diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-24 16:38:42 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-24 16:38:42 +0100 |
commit | 0b338bbd007048551526ab4fa4130d53b414e650 (patch) | |
tree | 1eabc6fcd6954de07cf1304435b1f70fd58e29f2 /gst/units.c | |
parent | f26a86bcc78c1946f55b6a399039e3bd8fb5dd16 (diff) |
fire and movement animations
Diffstat (limited to 'gst/units.c')
-rw-r--r-- | gst/units.c | 13 |
1 files changed, 7 insertions, 6 deletions
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; i<ar->uslen; 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; i<ar->uslen; 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; i<dmgslen; i++) { - dmgs[i].u->hp -= 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; |