MCPcopy Create free account
hub / github.com/DFHack/dfhack / findHits

Method findHits

plugins/siege-engine.cpp:1259–1281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1257 }
1258
1259 bool findHits(EngineInfo *engine, std::vector<Hit> *hit_points, float bias)
1260 {
1261 df::coord origin = engine->center;
1262
1263 Hit info;
1264 info.path = this;
1265
1266 for (auto it = path.begin(); it != path.end(); ++it)
1267 {
1268 info.pos = it->second;
1269 info.dist = point_distance(origin - info.pos);
1270 info.time = float(info.dist)*(engine->proj_speed+1) + engine->hit_delay + bias;
1271 get_margin(it, info.time, &info.lmargin, &info.rmargin);
1272
1273 if (info.lmargin > 0 && info.rmargin > 0)
1274 {
1275 if (engine->onTarget(info.pos) && engine->isInRange(info.dist))
1276 hit_points->push_back(info);
1277 }
1278 }
1279
1280 return !hit_points->empty();
1281 }
1282};
1283
1284std::map<df::unit*, UnitPath*> UnitPath::cache;

Callers 1

proposeUnitHitsFunction · 0.80

Calls 6

point_distanceFunction · 0.85
onTargetMethod · 0.80
isInRangeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected