diff options
| author | Robert Heinrich | 2012-04-15 17:40:39 +0200 |
|---|---|---|
| committer | Robert Heinrich | 2012-04-15 17:40:39 +0200 |
| commit | 8bbd43f2c955ac812000f75443997bcf3d65e36f (patch) | |
| tree | 24f4e06fcfb85b3c566409c4a73c248d3b16c897 /plugins/zone.cpp | |
| parent | be580592ceae7a4c1adf07aa6d5d87cc23d5adbb (diff) | |
| download | dfhack-8bbd43f2c955ac812000f75443997bcf3d65e36f.tar.gz dfhack-8bbd43f2c955ac812000f75443997bcf3d65e36f.tar.bz2 dfhack-8bbd43f2c955ac812000f75443997bcf3d65e36f.tar.xz | |
zone: added filters to search for creatures who can be trained for war/hunting
Diffstat (limited to 'plugins/zone.cpp')
| -rw-r--r-- | plugins/zone.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/zone.cpp b/plugins/zone.cpp index 7694ad00..55a15069 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -116,6 +116,8 @@ const string zone_help_filters = " (could have weird effects during trading, be careful)\n" " trained - obvious\n" " untrained - obvious\n" + " trainablewar - can be trained for war (and is not already trained)\n" + " trainablehunt- can be trained for hunting (and is not already trained)\n" " male - obvious\n" " female - obvious\n" " egglayer - race lays eggs (use together with 'female')\n" @@ -563,6 +565,32 @@ bool isMilkable(df::unit* unit) return false; } +bool isTrainableWar(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::TRAINABLE_WAR)) + return true; + } + return false; +} + +bool isTrainableHunting(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::TRAINABLE_HUNTING)) + return true; + } + return false; +} + bool isMale(df::unit* unit) { return unit->sex == 1; @@ -1459,6 +1487,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters) bool find_uncaged = false; bool find_foreign = false; bool find_untrained = false; + bool find_trainable_war = false; + bool find_trainable_hunting = false; //bool find_trained = false; bool find_war = false; bool find_own = false; @@ -1593,6 +1623,16 @@ command_result df_zone (color_ostream &out, vector <string> & parameters) out << "Filter by 'untrained'." << endl; find_untrained = true; } + else if(p == "trainablewar") + { + out << "Filter by 'trainable for war'." << endl; + find_trainable_war = true; + } + else if(p == "trainablehunt") + { + out << "Filter by 'trainable for hunting'." << endl; + find_trainable_hunting = true; + } else if(p == "war") { out << "Filter by 'trained war creature'." << endl; @@ -1896,6 +1936,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters) || (find_male && !isMale(unit)) || (find_female && !isFemale(unit)) || (find_named && !unit->name.has_name) + || (find_trainable_war && (isWar(unit) || isHunter(unit) || !isTrainableWar(unit))) + || (find_trainable_hunting && (isWar(unit) || isHunter(unit) || !isTrainableHunting(unit))) ) continue; |
