New standard unit filter keys:

- defense: chance to be hit on current terrain by normal weapons (like
  in movement_type's [defense])

- movement_cost: movement cost on current terrain
This commit is contained in:
Benoît Timbert 2007-11-19 22:42:44 +00:00
parent 94f5008f8f
commit 3b21c5e5c4
2 changed files with 16 additions and 0 deletions

View file

@ -1,4 +1,8 @@
Version 1.3.11+svn:
* WML engine:
* New standard unit filter keys :
- defense: chance to be hit on current terrain by normal weapons
- movement_cost: movement cost on current terrain
* miscellaneous and bug fixes:
* fix a compilation bug on Windows (usleep not defined)
* language and i18n:

View file

@ -847,6 +847,8 @@ bool unit::internal_matches_filter(const vconfig& cfg, const gamemap::location&
const t_string& t_gender = cfg["gender"];
const t_string& t_canrecruit = cfg["canrecruit"];
const t_string& t_level = cfg["level"];
const t_string& t_defense = cfg["defense"];
const t_string& t_movement_cost = cfg["movement_cost"];
const std::string& description = t_description;
const std::string& speaker = t_speaker;
@ -860,6 +862,8 @@ bool unit::internal_matches_filter(const vconfig& cfg, const gamemap::location&
const std::string& gender = t_gender;
const std::string& canrecruit = t_canrecruit;
const std::string& level = t_level;
const std::string& defense = t_defense;
const std::string& mvt_cost = t_movement_cost;
if(description.empty() == false && description != this->underlying_description()) {
return false;
@ -987,6 +991,14 @@ bool unit::internal_matches_filter(const vconfig& cfg, const gamemap::location&
return false;
}
if(defense.empty() == false && defense_modifier(map_->get_terrain(loc)) != lexical_cast_default<int>(defense,-1)) {
return false;
}
if(mvt_cost.empty() == false && movement_cost(map_->get_terrain(loc)) != lexical_cast_default<int>(mvt_cost,-1)) {
return false;
}
// Now start with the new WML based comparison.
// If a key is in the unit and in the filter, they should match
// filter only => not for us