Now it is possible to remove attacks with WML:

The new remove_attacks key in [effect] will remove all the matching
attacks.

Note: since 0-attacks units aren't supported, it won't remove the last
remaining attack.
This commit is contained in:
Benoît Timbert 2007-02-06 20:46:06 +00:00
parent ffa1dd5ec3
commit cd0441b9d0
2 changed files with 14 additions and 0 deletions

View file

@ -221,6 +221,7 @@ Version 1.3-svn:
this means the user has to rediscover all available terrains.
* fixed a bug which returned wrong values if a random number was negative
* max level advancements now raise the advance and post_advance events
* [effect] can now remove attacks with the remove_attacks key
* sound
* new or revised sounds: morning star, holy magic.
* add advanced sound tab to pref allowing you to play with sample_rate and

View file

@ -2362,6 +2362,19 @@ void unit::add_modification(const std::string& type, const config& mod,
advance_to(&var->second.get_variation(variation_));
} else if(apply_to == "new_attack") {
attacks_.push_back(attack_type(**i.first,id(),image_fighting((**i.first)["range"]=="ranged" ? attack_type::LONG_RANGE : attack_type::SHORT_RANGE)));
} else if(apply_to == "remove_attacks") {
int num_attacks= attacks_.size();
for(std::vector<attack_type>::iterator a = attacks_.begin(); a != attacks_.end(); ++a) {
if (a->matches_filter(**i.first,false)) {
if (num_attacks > 1) {
attacks_.erase(a--);
num_attacks--;
} else {
// Don't remove the last attack
LOG_STREAM(err, config) << "[effect] tried to remove the last attack : ignored.\n";
}
}
}
} else if(apply_to == "attack") {
bool first_attack = true;