diff options
author | gammafunk <gammafunk@gmail.com> | 2013-06-24 14:15:30 -0500 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-10-01 21:27:23 -0400 |
commit | 44f7868c8e57a7b7e92e1c71564cccb328cd94a0 (patch) | |
tree | 247225b1564f0825ab8574c42effbc66168b12ee /crawl-ref/source/target.cc | |
parent | cc16c311df81b95c60ea01a6f81630552e4cc7fc (diff) | |
download | crawl-ref-44f7868c8e57a7b7e92e1c71564cccb328cd94a0.tar.gz crawl-ref-44f7868c8e57a7b7e92e1c71564cccb328cd94a0.zip |
Don't do an erroneus check_moveto() on the monster target, cleanups and documentation for targetter_jump
Diffstat (limited to 'crawl-ref/source/target.cc')
-rw-r--r-- | crawl-ref/source/target.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crawl-ref/source/target.cc b/crawl-ref/source/target.cc index 338a132b3d..abfe3c4a34 100644 --- a/crawl-ref/source/target.cc +++ b/crawl-ref/source/target.cc @@ -1060,12 +1060,17 @@ bool targetter_jump::set_aim(coord_def a) return false; } +// Determine the set of valid landing sites void targetter_jump::set_additional_sites(coord_def a) { get_additional_sites(a); additional_sites = temp_sites; } +// Determine the set of valid landing sites for the target, putting the results +// in the private set variable temp_sites. This uses valid_aim(), so it looks +// for uninhabited squares that are habitable by the player, but doesn't check +// against e.g. harmful clouds void targetter_jump::get_additional_sites(coord_def a) { bool agent_adjacent = a.distance_from(agent->pos()) == 1; @@ -1093,20 +1098,21 @@ void targetter_jump::get_additional_sites(coord_def a) } } -// See if we can find at least one valid landing position for the -// given monster. Possibly we also care to exclude sites harmful to -// the player. +// See if we can find at least one valid landing position for the given monster. +// Base on allow_harmful we might care to exclude sites harmful to the player. bool targetter_jump::has_additional_sites(coord_def a, bool allow_harmful) { set<coord_def>::const_iterator site; + get_additional_sites(a); + if (allow_harmful || !agent->is_player()) + return temp_sites.size(); // Find a valid jump_attack position in the adjacent squares, chosing the // valid position closest to the player. for (site = temp_sites.begin(); site != temp_sites.end(); site++) { - if (allow_harmful || (agent->is_player() - && check_moveto(*site, "jump", "", false))) + if (check_moveto(*site, "jump", "", false)) return true; } return false; |