Notice when a unit moving to attack should be a support target.

This commit is contained in:
Eric S. Raymond 2008-10-23 07:28:21 +00:00
parent dbfa0f7652
commit cf2cebd541

View File

@ -1208,6 +1208,7 @@ bool ai::do_combat(std::map<map_location,paths>& possible_moves, const move_map&
std::vector<attack_analysis>::iterator choice_it = analysis.end();
double choice_rating = -1000.0;
double vuln = 0.0;
for(std::vector<attack_analysis>::iterator it = analysis.begin();
it != analysis.end(); ++it) {
@ -1231,6 +1232,7 @@ bool ai::do_combat(std::map<map_location,paths>& possible_moves, const move_map&
if(rating > choice_rating) {
choice_it = it;
choice_rating = rating;
vuln = it->vulnerability/it->support;
}
}
@ -1253,6 +1255,9 @@ bool ai::do_combat(std::map<map_location,paths>& possible_moves, const move_map&
return true;
}
if (vuln > 1.5)
add_target(target(to, vuln,target::SUPPORT));
// Recalc appropriate weapons here: AI uses approximations.
game_events::fire("consider attack", to, target_loc);
battle_context bc(map_, teams_, units_, state_,