zone tool: some cleanup, added 'slaughter' command

develop
Robert Heinrich 2012-04-05 11:40:27 +02:00
parent 796bc18fb0
commit 33ceee8310
1 changed files with 124 additions and 72 deletions

@ -201,6 +201,22 @@ bool isDead(df::unit* unit)
return false; return false;
} }
// marked for slaughter?
bool isMarkedForSlaughter(df::unit* unit)
{
if(unit->flags2.bits.slaughter)
return true;
else
return false;
}
// mark for slaughter
void doMarkForSlaughter(df::unit* unit)
{
unit->flags2.bits.slaughter = 1;
}
bool isTame(df::unit* creature) bool isTame(df::unit* creature)
{ {
bool tame = false; bool tame = false;
@ -272,6 +288,7 @@ bool isHunter(df::unit* creature)
return false; return false;
} }
// check if creature belongs to the player's civilization // check if creature belongs to the player's civilization
// (don't try to pasture/slaughter random untame animals) // (don't try to pasture/slaughter random untame animals)
bool isOwnCiv(df::unit* creature) bool isOwnCiv(df::unit* creature)
@ -298,6 +315,22 @@ string getRaceName(df::unit* unit)
return raw->creature_id; return raw->creature_id;
} }
bool isBaby(df::unit* unit)
{
if(unit->profession != df::profession::BABY)
return true;
else
return false;
}
bool isChild(df::unit* unit)
{
if(unit->profession != df::profession::CHILD)
return true;
else
return false;
}
bool isEggLayer(df::unit* unit) bool isEggLayer(df::unit* unit)
{ {
df::creature_raw *raw = df::global::world->raws.creatures.all[unit->race]; df::creature_raw *raw = df::global::world->raws.creatures.all[unit->race];
@ -1079,6 +1112,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
bool verbose = false; bool verbose = false;
bool all = false; bool all = false;
bool auto_nestbox = false; bool auto_nestbox = false;
bool unit_slaughter = false;
static int target_zone = -1; static int target_zone = -1;
for (size_t i = 0; i < parameters.size(); i++) for (size_t i = 0; i < parameters.size(); i++)
@ -1202,6 +1236,11 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
out << "Auto-assign female tame owned egg-layers to free nestboxes." << endl; out << "Auto-assign female tame owned egg-layers to free nestboxes." << endl;
auto_nestbox = true; auto_nestbox = true;
} }
else if(p == "slaughter")
{
out << "Assign animals for slaughter." << endl;
unit_slaughter = true;
}
else if(p == "count") else if(p == "count")
{ {
if(i == parameters.size()-1) if(i == parameters.size()-1)
@ -1405,7 +1444,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
} }
// assign to pen or pit // assign to pen or pit
if(zone_assign || unit_info) if(zone_assign || unit_info || unit_slaughter)
{ {
df::building * building; df::building * building;
if(zone_assign) if(zone_assign)
@ -1463,12 +1502,17 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
out << "invalid unit pos" << endl; out << "invalid unit pos" << endl;
unitInfo(out, unit, verbose); unitInfo(out, unit, verbose);
} }
else else if(zone_assign)
{ {
command_result result = assignUnitToBuilding(out, unit, building, verbose); command_result result = assignUnitToBuilding(out, unit, building, verbose);
if(result != CR_OK) if(result != CR_OK)
return result; return result;
} }
else if(unit_slaughter)
{
doMarkForSlaughter(unit);
}
count++; count++;
if(find_count && count >= target_count) if(find_count && count >= target_count)
break; break;
@ -1490,9 +1534,17 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
unitInfo(out, unit, verbose); unitInfo(out, unit, verbose);
return CR_OK; return CR_OK;
} }
else if(zone_assign)
{
return assignUnitToBuilding(out, unit, building, verbose); return assignUnitToBuilding(out, unit, building, verbose);
} }
else if(unit_slaughter)
{
doMarkForSlaughter(unit);
return CR_OK;
}
}
} }
// de-assign from pen or pit // de-assign from pen or pit