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

Function isProtectedUnit

plugins/autobutcher.cpp:664–677  ·  view source on GitHub ↗

This can be used to identify protected units that should be counted towards fort totals, but not scheduled for butchering. This way they count towards target quota, so if you order that you want 1 female adult cat and have 2 cats, one of them being a pet, the other gets butchered

Source from the content-addressed store, hash-verified

662// for butchering. This way they count towards target quota, so if you order that you want 1 female adult cat
663// and have 2 cats, one of them being a pet, the other gets butchered
664static bool isProtectedUnit(df::unit *unit) {
665 return Units::isWar(unit) // ignore war dogs etc
666 || Units::isHunter(unit) // ignore hunting dogs etc
667 || Units::isMarkedForWarTraining(unit) // ignore units marked for any kind of training
668 || Units::isMarkedForHuntTraining(unit)
669 || unit->flags1.bits.chained // ignore chained animals
670 // ignore creatures in built cages which are members of zones to leave zoos alone
671 // (TODO: better solution would be to allow some kind of slaughter cages which you can place near the butcher)
672 || (isContainedInItem(unit) && isInBuiltCageRoom(unit))
673 || (unit->pregnancy_timer != 0) // do not butcher pregnant animals (which includes brooding female egglayers)
674 || Units::isAvailableForAdoption(unit)
675 || unit->name.has_name
676 || !unit->name.nickname.empty();
677}
678
679static void autobutcher_cycle(color_ostream &out) {
680 // mark that we have recently run

Callers 4

autobutcher_cycleFunction · 0.85
checkRaceStocksProtectedFunction · 0.85
autobutcher_butcherRaceFunction · 0.85

Calls 3

isInBuiltCageRoomFunction · 0.85
isContainedInItemFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected