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

Method safeAimProjectile

plugins/siege-engine.cpp:1636–1662  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1634 }
1635
1636 static int safeAimProjectile(lua_State *L)
1637 {
1638 color_ostream &out = *Lua::GetOutput(L);
1639 auto proj = (projectile_hook*)lua_touserdata(L, 1);
1640 auto engine = (EngineInfo*)lua_touserdata(L, 2);
1641 auto unit = (df::unit*)lua_touserdata(L, 3);
1642 int skill = lua_tointeger(L, 4);
1643
1644 if (!Lua::PushModulePublic(out, L, "plugins.siege-engine", "doAimProjectile"))
1645 luaL_error(L, "Projectile aiming AI not available");
1646
1647 Lua::PushDFObject(L, engine->bld);
1648 Lua::Push(L, proj->item);
1649 Lua::Push(L, engine->target.first);
1650 Lua::Push(L, engine->target.second);
1651 Lua::PushDFObject(L, unit);
1652 Lua::Push(L, skill);
1653
1654 lua_call(L, 6, 1);
1655
1656 if (lua_isnil(L, -1))
1657 proj->aimAtArea(engine, skill);
1658 else
1659 proj->aimAtPoint(engine, skill, decode_path(L, -1, engine->center));
1660
1661 return 0;
1662 }
1663
1664 void doCheckMovement()
1665 {

Callers

nothing calls this directly

Calls 8

lua_touserdataFunction · 0.85
PushModulePublicFunction · 0.85
luaL_errorFunction · 0.85
PushDFObjectFunction · 0.85
PushFunction · 0.85
decode_pathFunction · 0.85
aimAtAreaMethod · 0.80
aimAtPointMethod · 0.80

Tested by

no test coverage detected