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

Function setTargetArea

plugins/siege-engine.cpp:544–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542}
543
544static bool setTargetArea(df::building_siegeenginest *bld, df::coord target_min, df::coord target_max)
545{
546 CHECK_NULL_POINTER(bld);
547 CHECK_INVALID_ARGUMENT(target_min.isValid() && target_max.isValid());
548 CHECK_INVALID_ARGUMENT(is_build_complete(bld));
549
550 if (!enable_plugin())
551 return false;
552
553 auto key = stl_sprintf("siege-engine/target/%d", bld->id);
554 auto entry = World::GetPersistentData(key, NULL);
555 if (!entry.isValid())
556 return false;
557
558 auto engine = find_engine(bld, true);
559
560 set_range(&engine->target, target_min, target_max);
561
562 entry.ival(0) = bld->id;
563 entry.ival(1) = engine->target.first.x;
564 entry.ival(2) = engine->target.first.y;
565 entry.ival(3) = engine->target.first.z;
566 entry.ival(4) = engine->target.second.x;
567 entry.ival(5) = engine->target.second.y;
568 entry.ival(6) = engine->target.second.z;
569
570 df::coord sum = target_min + target_max;
571 orient_engine(bld, df::coord(sum.x/2, sum.y/2, sum.z/2));
572
573 return true;
574}
575
576static int getAmmoItem(lua_State *L)
577{

Callers

nothing calls this directly

Calls 8

is_build_completeFunction · 0.85
stl_sprintfFunction · 0.85
find_engineFunction · 0.85
set_rangeFunction · 0.85
orient_engineFunction · 0.85
ivalMethod · 0.80
enable_pluginFunction · 0.70
isValidMethod · 0.45

Tested by

no test coverage detected