From b08d3b7b1b06fd2e9dd09eef248a10d33b8d1742 Mon Sep 17 00:00:00 2001 From: jacopo grandi Date: Sat, 6 Mar 2021 13:06:09 +0100 Subject: gst interpolations, particle systems, timing and gui fix --- gst/units.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'gst/units.c') diff --git a/gst/units.c b/gst/units.c index aeced1b..8b84d52 100644 --- a/gst/units.c +++ b/gst/units.c @@ -181,6 +181,7 @@ int army_move_step (infos *info, army *ar, map *m, stats_unit *ustats) { int army_move (infos *info, army *ar, map *m, stats_unit *ustats) { for (int i=0; iuslen; i++) { ar->us[i].move_points += ustats[i].frame.speed; + if (ar->us[i].move_points > 1) ar->us[i].move_points = 1; } int iter = 0, finished = army_move_step(info, ar, m, ustats); for (; iter<5 && !finished; iter++) { @@ -197,6 +198,7 @@ int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[], int lw = u->info.levels[LEVEL_CHASSIS]; for (int j=0; jcooldown[j] += 1; + if (u->cooldown[j] > 1) u->cooldown[j] = 1; } } int dmgslen = 0; @@ -209,24 +211,26 @@ int army_fire (infos *info, army *ar, map *m, a_dmg dmgs[], for (int j=0; jcooldown[j] <= 0) continue; float range = ustats[i].weapon[j].range; - unit_search(info, ar, m, u, t, range); - if (t[0]!=NULL) { - dmgs[dmgslen].u = u; - dmgs[dmgslen].t = t[0]; - - int t_i = 0; - for (int k=0; kuslen; k++) { - if (ar->us+k == t[0]) { t_i = k; break; } - } - float dam = stats_compute_damage( - &ustats[i].weapon[j], - &ustats[t_i].frame, u->reduced_armor); - - dmgs[dmgslen].dam = dam; - dmgslen++; - u->cooldown[j] -= ustats[i].weapon[j].cooldown; - u->charge -= ustats[i].weapon[j].charge_per_shot; - if (u->charge < 0) u->charge = 0; + while (u->cooldown[j] > 0) { + unit_search(info, ar, m, u, t, range); + if (t[0]!=NULL) { + dmgs[dmgslen].u = u; + dmgs[dmgslen].t = t[0]; + + int t_i = 0; + for (int k=0; kuslen; k++) { + if (ar->us+k == t[0]) { t_i = k; break; } + } + float dam = stats_compute_damage( + &ustats[i].weapon[j], + &ustats[t_i].frame, u->reduced_armor); + + dmgs[dmgslen].dam = dam; + dmgslen++; + u->cooldown[j] -= ustats[i].weapon[j].cooldown; + u->charge -= ustats[i].weapon[j].charge_per_shot; + if (u->charge < 0) u->charge = 0; + } else break; } } } -- cgit v1.2.3-54-g00ecf