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

Method aimAtPoint

plugins/siege-engine.cpp:1530–1563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1528 typedef df::proj_itemst interpose_base;
1529
1530 void aimAtPoint(EngineInfo *engine, const ProjectilePath &path)
1531 {
1532 target_pos = path.target;
1533
1534 // Debug
1535 if (debug_mode)
1536 set_arrow_color(path.goal, COLOR_LIGHTMAGENTA);
1537
1538 PathMetrics raytrace(path);
1539
1540 // Materialize map blocks, or the projectile will crash into them
1541 for (int i = 0; i < raytrace.collision_step; i++)
1542 Maps::ensureTileBlock(path[i]);
1543
1544 // Find valid hit point for catapult stones
1545 if (flags.bits.high_flying)
1546 {
1547 if (raytrace.hits())
1548 fall_threshold = raytrace.goal_step;
1549 else
1550 fall_threshold = (raytrace.collision_z_step+raytrace.collision_step-1)/2;
1551
1552 while (fall_threshold < raytrace.collision_step-1)
1553 {
1554 if (isTargetableTile(path[fall_threshold]))
1555 break;
1556
1557 fall_threshold++;
1558 }
1559 }
1560
1561 fall_threshold = std::max(fall_threshold, engine->fire_range.first);
1562 fall_threshold = std::min(fall_threshold, engine->fire_range.second);
1563 }
1564
1565 void aimAtPoint(EngineInfo *engine, int skill, const ProjectilePath &path)
1566 {

Callers 1

safeAimProjectileMethod · 0.80

Calls 9

set_arrow_colorFunction · 0.85
ensureTileBlockFunction · 0.85
isTargetableTileFunction · 0.85
orient_engineFunction · 0.85
ProjectilePathClass · 0.85
point_distanceFunction · 0.85
int_roundFunction · 0.85
random_errorFunction · 0.85
hitsMethod · 0.80

Tested by

no test coverage detected