diff options
author | jacopograndi <jak.sk8@hotmail.it> | 2021-09-05 22:36:13 +0200 |
---|---|---|
committer | jacopograndi <jak.sk8@hotmail.it> | 2021-09-05 22:36:13 +0200 |
commit | 728abda9dc6fc8e65c7c0e0240a2e7d61a43a583 (patch) | |
tree | 545187ed3d634792af1082ce021665d3ef4934fc /game/ground.cpp | |
parent | c298eb988874bc2cf3adb39c2532419ec76a24bc (diff) |
tech tostring, all sprites, heal and convert
Diffstat (limited to 'game/ground.cpp')
-rw-r--r-- | game/ground.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/game/ground.cpp b/game/ground.cpp index 4308047..1cadd9b 100644 --- a/game/ground.cpp +++ b/game/ground.cpp @@ -98,9 +98,37 @@ std::vector<int> Ground::attack_targets (Gst &gst, Entity &ent) { for (Entity &e : gst.entities) { if (!units && e.info->unit == 1) continue; if (!builds && e.info->unit == 0) continue; - if (e.owner != ent.owner && abs(e.x-ent.x)+abs(e.y-ent.y) <= range) { + int dist = abs(e.x-ent.x)+abs(e.y-ent.y); + if (dist > 0 && e.owner != ent.owner && dist <= range) { attacks.push_back(at(e.x, e.y)); } } return attacks; +} + +std::vector<int> Ground::heal_targets (Gst &gst, Entity &ent) { + std::vector<int> heals; + int range = gst.get_range(ent); + for (Entity &e : gst.entities) { + if (e.info->unit == 0) continue; + if (e.info->ent_class == EntityInfo::Class::sie) continue; + int dist = abs(e.x-ent.x)+abs(e.y-ent.y); + if (dist > 0 && e.owner == ent.owner && dist <= range) { + heals.push_back(at(e.x, e.y)); + } + } + return heals; +} + +std::vector<int> Ground::convert_targets (Gst &gst, Entity &ent) { + std::vector<int> converts; + int range = gst.get_range(ent); + for (Entity &e : gst.entities) { + if (e.info->unit == 0) continue; + int dist = abs(e.x-ent.x)+abs(e.y-ent.y); + if (dist > 0 && e.owner != ent.owner && dist <= range) { + converts.push_back(at(e.x, e.y)); + } + } + return converts; }
\ No newline at end of file |