| 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 | { |
nothing calls this directly
no test coverage detected