Add "tamable" for animals that can be tamed (PET or PET_EXOTIC in raws)

develop
Kelly Martin 2012-04-20 14:38:50 -05:00
parent e0bb5bf53b
commit ad73b8c737
1 changed files with 28 additions and 0 deletions

@ -367,6 +367,7 @@ void chainInfo(color_ostream & out, df::building* building, bool verbose);
bool isBuiltCageAtPos(df::coord pos); bool isBuiltCageAtPos(df::coord pos);
bool isInBuiltCageRoom(df::unit*); bool isInBuiltCageRoom(df::unit*);
bool isNaked(df::unit *); bool isNaked(df::unit *);
bool isTamable(df::unit *);
int32_t getUnitAge(df::unit* unit) int32_t getUnitAge(df::unit* unit)
{ {
@ -621,6 +622,20 @@ bool isTrainableHunting(df::unit* unit)
return false; return false;
} }
bool isTamable(df::unit* unit)
{
df::creature_raw *raw = df::global::world->raws.creatures.all[unit->race];
size_t sizecas = raw->caste.size();
for (size_t j = 0; j < sizecas;j++)
{
df::caste_raw *caste = raw->caste[j];
if(caste->flags.is_set(caste_raw_flags::PET) ||
caste->flags.is_set(caste_raw_flags::PET_EXOTIC))
return true;
}
return false;
}
bool isMale(df::unit* unit) bool isMale(df::unit* unit)
{ {
return unit->sex == 1; return unit->sex == 1;
@ -1757,6 +1772,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
bool find_not_named = false; bool find_not_named = false;
bool find_naked = false; bool find_naked = false;
bool find_not_naked = false; bool find_not_naked = false;
bool find_tamable = false;
bool find_not_tamable = false;
bool find_agemin = false; bool find_agemin = false;
bool find_agemax = false; bool find_agemax = false;
@ -2144,6 +2161,15 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
find_not_naked = true; find_not_naked = true;
invert_filter=false; invert_filter=false;
} }
else if(p == "tamable" && !invert_filter)
{
find_tamable = true;
}
else if(p == "tamable" && invert_filter)
{
find_not_tamable = true;
invert_filter=false;
}
else if(p == "grazer" && !invert_filter) else if(p == "grazer" && !invert_filter)
{ {
find_grazer = true; find_grazer = true;
@ -2413,6 +2439,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
|| (find_not_named && unit->name.has_name) || (find_not_named && unit->name.has_name)
|| (find_naked && !isNaked(unit)) || (find_naked && !isNaked(unit))
|| (find_not_naked && isNaked(unit)) || (find_not_naked && isNaked(unit))
|| (find_tamable && !isTamable(unit))
|| (find_not_tamable && isTamable(unit))
|| (find_trainable_war && (isWar(unit) || isHunter(unit) || !isTrainableWar(unit))) || (find_trainable_war && (isWar(unit) || isHunter(unit) || !isTrainableWar(unit)))
|| (find_not_trainable_war && isTrainableWar(unit)) // hm, is this check enough? || (find_not_trainable_war && isTrainableWar(unit)) // hm, is this check enough?
|| (find_trainable_hunting && (isWar(unit) || isHunter(unit) || !isTrainableHunting(unit))) || (find_trainable_hunting && (isWar(unit) || isHunter(unit) || !isTrainableHunting(unit)))