aboutsummaryrefslogtreecommitdiff
path: root/gst/units.c
diff options
context:
space:
mode:
authorjacopo grandi <jak.sk8@hotmail.it>2021-02-22 19:51:09 +0100
committerjacopo grandi <jak.sk8@hotmail.it>2021-02-22 19:51:09 +0100
commit4842b67ab590250d95ad4be5fe61380a09b1e8ea (patch)
treeabb973efe013b3b0970b2f4434119f2c41644f65 /gst/units.c
parentbd372bf19eb79e0bfd3f3d9cb20b4c6a49a8a5ed (diff)
view levels and maxrange strat
Diffstat (limited to 'gst/units.c')
-rw-r--r--gst/units.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gst/units.c b/gst/units.c
index b0ae2b0..409f9b1 100644
--- a/gst/units.c
+++ b/gst/units.c
@@ -116,11 +116,17 @@ int army_move_step (infos *info, army *ar, map *m) {
if (u->move_points <= 0) continue;
if (u->hp <= 0) continue;
if (u->charge <= 0) continue;
- // search target
+ // search target inside max range
unit *t[32];
+ float maxrange = info_unit_get_maxrange(info, &u->info);
+ unit_search(info, ar, m, u, t, maxrange);
+ // stop if found
+ if (t[0] != NULL) { continue; }
+
+ // search target
unit_search(info, ar, m, u, t, 100);
if (t[0] != NULL) {
- // in range to shoot
+ // in range to move
diff[0] = u->gridpos[0] - t[0]->gridpos[0];
diff[1] = u->gridpos[1] - t[0]->gridpos[1];
if (vec2_mag(diff) > /*info->units[u->who].range*/1) {