summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/beam.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-02 16:54:20 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-02 16:54:20 +0000
commit882095e2a137991f94fb71584a9290bbc333d42b (patch)
tree3f626430f1b76875efaf35e83ea13394c5aa4afd /crawl-ref/source/beam.cc
parent35f7fe0aa994262518157cae2c4fc22e19939806 (diff)
downloadcrawl-ref-882095e2a137991f94fb71584a9290bbc333d42b.tar.gz
crawl-ref-882095e2a137991f94fb71584a9290bbc333d42b.zip
This is an experimental attempt at selecting more intuitive beams for
targeting (see 1725723): - The default beam selected for targeting is the shortest available beam that is closest to the Bresenham line between src->targ. - Targeting beams convert aliased perpendiculars into diagonals, which look better. This requires an immortal fudge to make sure the diagonal conversion doesn't happen at the wrong places (when the conversion would cause the beam to miss the target square). - Tweaked beam bounce behaviour to look more natural. Comments and suggestions welcome. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1511 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/beam.cc')
-rw-r--r--crawl-ref/source/beam.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index ef80105aab..8305758b35 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -1262,11 +1262,12 @@ static void zappy( zap_type z_type, int power, struct bolt &pbolt )
*/
-void fire_beam( struct bolt &pbolt, item_def *item )
+void fire_beam( bolt &pbolt, item_def *item )
{
bool beamTerminate; // has beam been 'stopped' by something?
int tx = 0, ty = 0; // test(new) x,y - integer
int rangeRemaining;
+ bool did_bounce = false;
cursor_control coff(false);
beam_message_cache.clear();
@@ -1302,11 +1303,12 @@ void fire_beam( struct bolt &pbolt, item_def *item )
{
ray.fullray_idx = -1; // to quiet valgrind
find_ray( pbolt.source_x, pbolt.source_y,
- pbolt.target_x, pbolt.target_y, true, ray);
+ pbolt.target_x, pbolt.target_y, true, ray,
+ 0, true );
}
if ( !pbolt.aimed_at_feet )
- ray.advance();
+ ray.advance_through(pbolt.target());
// give chance for beam to affect one cell even if aimed_at_feet.
beamTerminate = false;
@@ -1351,16 +1353,19 @@ void fire_beam( struct bolt &pbolt, item_def *item )
else
{
// BEGIN bounce case
- if (!isBouncy(pbolt, grd[tx][ty])) {
- ray.regress();
+ if (!isBouncy(pbolt, grd[tx][ty]))
+ {
+ ray.regress(pbolt.target());
tx = ray.x();
ty = ray.y();
break; // breaks from line tracing
}
+ did_bounce = true;
+
// bounce
do {
- ray.regress();
+ ray.regress(pbolt.target());
ray.advance_and_bounce();
--rangeRemaining;
} while ( rangeRemaining > 0 &&
@@ -1458,7 +1463,11 @@ void fire_beam( struct bolt &pbolt, item_def *item )
}
}
- ray.advance();
+
+ if (!did_bounce)
+ ray.advance_through(pbolt.target());
+ else
+ ray.advance(true);
} // end- while !beamTerminate
// the beam has finished, and terminated at tx, ty