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

Method aimAtArea

plugins/siege-engine.cpp:1603–1634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1601 }
1602
1603 void aimAtArea(EngineInfo *engine, int skill)
1604 {
1605 df::coord target, last_passable;
1606 df::coord tbase = engine->target.first;
1607 df::coord tsize = engine->getTargetSize();
1608
1609 for (int i = 0; i < 50; i++)
1610 {
1611 target = tbase + df::coord(
1612 rng.random(tsize.x), rng.random(tsize.y), rng.random(tsize.z)
1613 );
1614
1615 if (adjustToTarget(engine, &target))
1616 last_passable = target;
1617 else
1618 continue;
1619
1620 ProjectilePath path(engine->center, target, engine->is_catapult ? 0.5f : 0.0f);
1621 PathMetrics raytrace(path);
1622
1623 if (raytrace.hits() && engine->isInRange(raytrace.goal_step))
1624 {
1625 aimAtPoint(engine, skill, path);
1626 return;
1627 }
1628 }
1629
1630 if (!last_passable.isValid())
1631 last_passable = target;
1632
1633 aimAtPoint(engine, skill, ProjectilePath(engine->center, last_passable));
1634 }
1635
1636 static int safeAimProjectile(lua_State *L)
1637 {

Callers 1

safeAimProjectileMethod · 0.80

Calls 6

adjustToTargetFunction · 0.85
ProjectilePathClass · 0.85
getTargetSizeMethod · 0.80
hitsMethod · 0.80
isInRangeMethod · 0.80
isValidMethod · 0.45

Tested by

no test coverage detected