From 2f62da4f8d850459676d780980dbabb7f25a1488 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sat, 17 Oct 2009 14:50:31 +0200 Subject: Remove chain-lightning specific LOS test from beam.cc. There's now a spell-specific _lightning_los which may require some fine-tuning -- I'm not quite sure of the intention of the original check. --- crawl-ref/source/beam.cc | 23 ----------------------- crawl-ref/source/beam.h | 1 - crawl-ref/source/losparam.h | 1 + crawl-ref/source/spells1.cc | 11 +++++++++-- 4 files changed, 10 insertions(+), 26 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 83736773da..59b839ccf3 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2832,29 +2832,6 @@ void fire_tracer(const monsters *monster, bolt &pbolt, bool explode_only) pbolt.is_tracer = false; } -/** - * Checks whether target is in sight of source. - * - * Only used from cast_chain_lightning currently. - * XXX: Move to los.cc; integrate with other LOS code. - */ -bool check_line_of_sight(const coord_def& source, const coord_def& target) -{ - const int dist = grid_distance(source, target); - - // Can always see one square away. - if (dist <= 1) - return (true); - - // Currently we limit the range to 8. - if (dist > MONSTER_LOS_RANGE) - return (false); - - // Note that we are guaranteed to be within the player LOS range, - // so fallback is unnecessary. - return exists_ray(source, target); -} - // When a mimic is hit by a ranged attack, it teleports away (the slow // way) and changes its appearance - the appearance change is in // monster_teleport() in mstuff2.cc. diff --git a/crawl-ref/source/beam.h b/crawl-ref/source/beam.h index 56908cc023..41f410c8ac 100644 --- a/crawl-ref/source/beam.h +++ b/crawl-ref/source/beam.h @@ -291,7 +291,6 @@ bool napalm_monster(monsters *monster, kill_category who, int levels = 1, bool verbose = true); void fire_tracer( const monsters *monster, struct bolt &pbolt, bool explode_only = false ); -bool check_line_of_sight( const coord_def& source, const coord_def& target ); void mimic_alert( monsters *mimic ); bool zapping(zap_type ztype, int power, bolt &pbolt, bool needs_tracer = false, const char* msg = NULL); diff --git a/crawl-ref/source/losparam.h b/crawl-ref/source/losparam.h index 4d5bc141e1..82dee24519 100644 --- a/crawl-ref/source/losparam.h +++ b/crawl-ref/source/losparam.h @@ -60,6 +60,7 @@ struct bounds_radius_sq : bounds_func : radius_sq(r_sq) {} bool operator()(const coord_def& p) const; }; +static bounds_radius_sq bds_maxlos(LOS_RADIUS); // LOS bounded by current global LOS radius. struct bounds_los_radius : bounds_func diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 0e71583ffb..e49807379a 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -297,6 +297,13 @@ void cast_fire_storm(int pow, bolt &beam) viewwindow(true, false); } +bool _lightning_los(const coord_def& source, const coord_def& target) +{ + // XXX: currently bounded by circular LOS radius; + // XXX: adapt opacity -- allow passing clouds. + return (exists_ray(source, target, opc_solid, bds_maxlos)); +} + void cast_chain_lightning(int pow) { bolt beam; @@ -350,7 +357,7 @@ void cast_chain_lightning(int pow) if (dist > min_dist) continue; - if (!check_line_of_sight(source, monster->pos())) + if (_lightning_los(source, monster->pos())) continue; count++; @@ -387,7 +394,7 @@ void cast_chain_lightning(int pow) if ((target.x == -1 || dist < min_dist || (dist == min_dist && one_chance_in(count + 1))) - && check_line_of_sight(source, you.pos())) + && _lightning_los(source, you.pos())) { target = you.pos(); } -- cgit v1.2.3-54-g00ecf