diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index abf4d4c7f..3e2661984 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1535,6 +1535,7 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = { WRAPM(Units, isHunter), WRAPM(Units, isAvailableForAdoption), WRAPM(Units, isOwnCiv), + WRAPM(Units, isOwnGroup), WRAPM(Units, isOwnRace), WRAPM(Units, getRaceName), WRAPM(Units, getRaceNamePlural), diff --git a/library/include/modules/Units.h b/library/include/modules/Units.h index e5210013b..0c7be6f80 100644 --- a/library/include/modules/Units.h +++ b/library/include/modules/Units.h @@ -240,6 +240,7 @@ DFHACK_EXPORT bool isWar(df::unit* unit); DFHACK_EXPORT bool isHunter(df::unit* unit); DFHACK_EXPORT bool isAvailableForAdoption(df::unit* unit); DFHACK_EXPORT bool isOwnCiv(df::unit* unit); +DFHACK_EXPORT bool isOwnGroup(df::unit* unit); DFHACK_EXPORT bool isOwnRace(df::unit* unit); DFHACK_EXPORT std::string getRaceNameById(int32_t race_id); diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 08c2191ec..341a90b22 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -888,6 +888,22 @@ bool Units::isOwnCiv(df::unit* unit) return unit->civ_id == ui->civ_id; } +// check if creature belongs to the player's group +bool Units::isOwnGroup(df::unit* unit) +{ + CHECK_NULL_POINTER(unit); + auto histfig = df::historical_figure::find(unit->hist_figure_id); + if (!histfig) + return false; + for (size_t i = 0; i < histfig->entity_links.size(); i++) + { + auto link = histfig->entity_links[i]; + if (link->entity_id == ui->group_id && (*link).getType() == df::histfig_entity_link_type::MEMBER) + return true; + } + return false; +} + // check if creature belongs to the player's race // (in combination with check for civ helps to filter out own dwarves) bool Units::isOwnRace(df::unit* unit) diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index 070744de0..b8c89215e 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -365,7 +365,15 @@ static const dwarf_state dwarf_states[] = { BUSY /* PushTrackVehicle */, BUSY /* PlaceTrackVehicle */, BUSY /* StoreItemInVehicle */, - BUSY /* GeldAnimal */ + BUSY /* GeldAnimal */, + BUSY /* MakeFigurine */, + BUSY /* MakeAmulet */, + BUSY /* MakeScepter */, + BUSY /* MakeCrown */, + BUSY /* MakeRing */, + BUSY /* MakeEarring */, + BUSY /* MakeBracelet */, + BUSY /* MakeGem */ }; struct labor_info diff --git a/plugins/devel/autolabor2.cpp b/plugins/devel/autolabor2.cpp index 62bcc98d0..4897832d4 100644 --- a/plugins/devel/autolabor2.cpp +++ b/plugins/devel/autolabor2.cpp @@ -360,7 +360,16 @@ static const dwarf_state dwarf_states[] = { BUSY /* CarveTrack */, BUSY /* PushTrackVehicle */, BUSY /* PlaceTrackVehicle */, - BUSY /* StoreItemInVehicle */ + BUSY /* StoreItemInVehicle */, + BUSY /* GeldAnimal */, + BUSY /* MakeFigurine */, + BUSY /* MakeAmulet */, + BUSY /* MakeScepter */, + BUSY /* MakeCrown */, + BUSY /* MakeRing */, + BUSY /* MakeEarring */, + BUSY /* MakeBracelet */, + BUSY /* MakeGem */ }; struct labor_info @@ -1328,6 +1337,15 @@ public: job_to_labor_table[df::job_type::PushTrackVehicle] = jlf_const(df::unit_labor::PUSH_HAUL_VEHICLE); job_to_labor_table[df::job_type::PlaceTrackVehicle] = jlf_const(df::unit_labor::PUSH_HAUL_VEHICLE); job_to_labor_table[df::job_type::StoreItemInVehicle] = jlf_const(df::unit_labor::PUSH_HAUL_VEHICLE); + job_to_labor_table[df::job_type::GeldAnimal] = jlf_const(df::unit_labor::GELD); + job_to_labor_table[df::job_type::MakeFigurine] = jlf_make_object; + job_to_labor_table[df::job_type::MakeAmulet] = jlf_make_object; + job_to_labor_table[df::job_type::MakeScepter] = jlf_make_object; + job_to_labor_table[df::job_type::MakeCrown] = jlf_make_object; + job_to_labor_table[df::job_type::MakeRing] = jlf_make_object; + job_to_labor_table[df::job_type::MakeEarring] = jlf_make_object; + job_to_labor_table[df::job_type::MakeBracelet] = jlf_make_object; + job_to_labor_table[df::job_type::MakeGem] = jlf_make_object; }; df::unit_labor find_job_labor(df::job* j) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index e2a4e54a0..7c86b6f7d 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -256,10 +256,26 @@ const SkillColumn columns[] = { {19, 6, profession::NONE, unit_labor::NONE, job_skill::POETRY, "Po"}, {19, 6, profession::NONE, unit_labor::NONE, job_skill::READING, "Rd"}, {19, 6, profession::NONE, unit_labor::NONE, job_skill::SPEAKING, "Sp"}, - - {20, 5, profession::NONE, unit_labor::NONE, job_skill::MILITARY_TACTICS, "MT"}, - {20, 5, profession::NONE, unit_labor::NONE, job_skill::TRACKING, "Tr"}, - {20, 5, profession::NONE, unit_labor::NONE, job_skill::MAGIC_NATURE, "Dr"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::DANCE, "Dn"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::MAKE_MUSIC, "MM"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::SING_MUSIC, "SM"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::PLAY_KEYBOARD_INSTRUMENT, "PK"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::PLAY_STRINGED_INSTRUMENT, "PS"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::PLAY_WIND_INSTRUMENT, "PW"}, + {19, 6, profession::NONE, unit_labor::NONE, job_skill::PLAY_PERCUSSION_INSTRUMENT, "PP"}, + + {20, 4, profession::NONE, unit_labor::NONE, job_skill::CRITICAL_THINKING, "CT"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::LOGIC, "Lo"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::MATHEMATICS, "Ma"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::ASTRONOMY, "As"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::CHEMISTRY, "Ch"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::GEOGRAPHY, "Ge"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::OPTICS_ENGINEER, "OE"}, + {20, 4, profession::NONE, unit_labor::NONE, job_skill::FLUID_ENGINEER, "FE"}, + + {21, 5, profession::NONE, unit_labor::NONE, job_skill::MILITARY_TACTICS, "MT"}, + {21, 5, profession::NONE, unit_labor::NONE, job_skill::TRACKING, "Tr"}, + {21, 5, profession::NONE, unit_labor::NONE, job_skill::MAGIC_NATURE, "Dr"}, }; struct UnitInfo @@ -1127,15 +1143,21 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur cur->selected = false; cur->active_index = active_idx[unit]; - if (!Units::isOwnRace(unit)) + if (!Units::isOwnCiv(unit)) cur->allowEdit = false; - if (!Units::isOwnCiv(unit)) + if (!Units::isOwnGroup(unit)) cur->allowEdit = false; if (unit->flags1.bits.dead) cur->allowEdit = false; + if (unit->flags2.bits.visitor) + cur->allowEdit = false; + + if (unit->flags3.bits.ghostly) + cur->allowEdit = false; + if (!ENUM_ATTR(profession, can_assign_labor, unit->profession)) cur->allowEdit = false;