summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/throw.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-03-02 21:54:09 -0800
committerSteve Melenchuk <smelenchuk@gmail.com>2014-03-05 19:59:19 -0700
commita5274fd6dc5599ce2afdc882a46526b036e8f25f (patch)
tree8f15e6696f4a52033e064314c74b6febfa5e50d3 /crawl-ref/source/throw.cc
parent9259616cc7dcd8d058367b4d8ba84d8f49dcb898 (diff)
downloadcrawl-ref-a5274fd6dc5599ce2afdc882a46526b036e8f25f.tar.gz
crawl-ref-a5274fd6dc5599ce2afdc882a46526b036e8f25f.zip
Refactored random_near_space(); fixed bugs
Cleaned up bugs in random_near_space(). Monsters can no longer blink through walls, or into lava/deep water. Ball lightning can be summoned over lava/deep water. [Committer's note: cleaned up a bit of code formatting and comments.] Signed-off-by: Steve Melenchuk <smelenchuk@gmail.com>
Diffstat (limited to 'crawl-ref/source/throw.cc')
-rw-r--r--crawl-ref/source/throw.cc29
1 files changed, 3 insertions, 26 deletions
diff --git a/crawl-ref/source/throw.cc b/crawl-ref/source/throw.cc
index a555d20b6e..3a79f72755 100644
--- a/crawl-ref/source/throw.cc
+++ b/crawl-ref/source/throw.cc
@@ -681,40 +681,17 @@ static bool _dispersal_hit_victim(bolt& beam, actor* victim, int dmg)
coord_def pos, pos2;
- int tries = 0;
- do
- {
- if (!random_near_space(victim->pos(), pos, false, true, false,
- no_sanct))
- {
- return false;
- }
- }
- while (!victim->is_habitable(pos) && tries++ < 100);
-
- if (!victim->is_habitable(pos))
+ if (!random_near_space(victim->pos(), pos, false, no_sanct))
return false;
- tries = 0;
- do
- if (!random_near_space(victim->pos(), pos2, false, true, false,
- no_sanct))
- {
- return false;
- }
- while (!victim->is_habitable(pos2) && tries++ < 100);
-
- if (!victim->is_habitable(pos2))
+ if (!random_near_space(victim->pos(), pos2, false, no_sanct))
return false;
// Pick the square further away from the agent.
const coord_def from = agent->pos();
- if (in_bounds(pos2) && distance2(pos2, from) > distance2(pos, from))
+ if (distance2(pos2, from) > distance2(pos, from))
pos = pos2;
- if (pos == victim->pos())
- return false;
-
const coord_def oldpos = victim->pos();
victim->clear_clinging();