summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-02 17:51:08 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-02 17:51:08 +0000
commit77bd894ea2391d0575ff39afac149ee4e54adc2c (patch)
treed89a4935818020cb6931869618753c701bd3d5a6 /crawl-ref/source
parent882095e2a137991f94fb71584a9290bbc333d42b (diff)
downloadcrawl-ref-77bd894ea2391d0575ff39afac149ee4e54adc2c.tar.gz
crawl-ref-77bd894ea2391d0575ff39afac149ee4e54adc2c.zip
Highlight monsters in the path of a beam (with :).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1512 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/command.cc2
-rw-r--r--crawl-ref/source/direct.cc32
-rw-r--r--crawl-ref/source/direct.h10
-rw-r--r--crawl-ref/source/view.cc25
-rw-r--r--crawl-ref/source/view.h3
5 files changed, 48 insertions, 24 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 247230c3cd..5bd5fcfedc 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -562,7 +562,7 @@ static const char *targeting_help =
"<w>.</w> : fire at target (<w>Enter</w>, <w>Del</w>, <w>Space</w>)\n"
"<w>!</w> : fire at target and stop there\n"
"<w>p</w> : fire at Previous target (also <w>t</w>, <w>f</w>)\n"
- "<w>:</w> : hide beam\n"
+ "<w>:</w> : show/hide beam path\n"
"<w>Shift-Dir</w> : shoot straight-line beam\n";
static const char *interlevel_travel_branch_help =
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 0b746910d5..9b6407c8be 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -271,6 +271,25 @@ static const char *target_mode_help_text(int mode)
}
}
+static void draw_ray_glyph(const coord_def &pos, int colour,
+ int glych, int mcol)
+{
+ int mid = mgrd(pos);
+ if (mid != NON_MONSTER)
+ {
+ const monsters *mons = &menv[mid];
+ if (mons->alive() && player_monster_visible(mons))
+ {
+ glych = get_screen_glyph(pos.x, pos.y);
+ colour = mcol;
+ }
+ }
+ const coord_def vp = grid2view(pos);
+ gotoxy(vp.x, vp.y);
+ textcolor( real_colour(colour) );
+ putch(glych);
+}
+
//---------------------------------------------------------------
//
// direction
@@ -731,22 +750,21 @@ void direction(dist& moves, targeting_type restricts,
{
viewwindow(true, false);
if ( show_beam &&
- in_vlos(grid2viewX(moves.tx), grid2viewY(moves.ty)) )
+ in_vlos(grid2viewX(moves.tx), grid2viewY(moves.ty)) &&
+ moves.target() != you.pos() )
{
// Draw the new ray with magenta '*'s, not including
// your square or the target square.
ray_def raycopy = ray; // temporary copy to work with
- textcolor(MAGENTA);
- while ( raycopy.x() != moves.tx || raycopy.y() != moves.ty )
+ while ( raycopy.pos() != moves.target() )
{
- if ( raycopy.x() != you.x_pos || raycopy.y() != you.y_pos )
+ if ( raycopy.pos() != you.pos() )
{
// Sanity: don't loop forever if the ray is problematic
if ( !in_los(raycopy.x(), raycopy.y()) )
break;
- gotoxy( grid2viewX(raycopy.x()),
- grid2viewY(raycopy.y()));
- cprintf("*");
+ draw_ray_glyph(raycopy.pos(), MAGENTA, '*',
+ MAGENTA | COLFLAG_REVERSE);
}
raycopy.advance_through(moves.target());
}
diff --git a/crawl-ref/source/direct.h b/crawl-ref/source/direct.h
index 8522b5d10b..6c7d23c95f 100644
--- a/crawl-ref/source/direct.h
+++ b/crawl-ref/source/direct.h
@@ -49,6 +49,11 @@ inline int view2gridY(int vy)
return (you.y_pos + vy - VIEW_CY);
}
+inline coord_def view2grid(const coord_def &pos)
+{
+ return coord_def( view2gridX(pos.x), view2gridY(pos.y) );
+}
+
inline int grid2viewX(int gx)
{
return (gx - you.x_pos + VIEW_CX);
@@ -59,4 +64,9 @@ inline int grid2viewY(int gy)
return (gy - you.y_pos + VIEW_CY);
}
+inline coord_def grid2view(const coord_def &pos)
+{
+ return coord_def( grid2viewX(pos.x), grid2viewY(pos.y) );
+}
+
#endif
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 3858f89aba..7d91fac9cf 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -90,9 +90,6 @@ void monster_grid(bool do_updates);
static int get_item_dngn_code(const item_def &item);
static void set_show_backup( int ex, int ey );
-
-// Applies EC_ colour substitutions and brands.
-static unsigned fix_colour(unsigned raw_colour);
static int get_viewobj_flags(int viewobj);
int get_message_window_height()
@@ -247,7 +244,7 @@ static unsigned colflag2brand(int colflag)
}
#endif
-static unsigned fix_colour(unsigned raw_colour)
+unsigned real_colour(unsigned raw_colour)
{
// This order is important - is_element_colour() doesn't want to see the
// munged colours returned by dos_brand, so it should always be done
@@ -315,7 +312,7 @@ static void get_symbol( int x, int y,
*ch = mons_char( object - DNGN_START_OF_MONSTERS );
}
- *colour = fix_colour(*colour);
+ *colour = real_colour(*colour);
}
void get_item_symbol(unsigned int object, unsigned short *ch,
@@ -329,7 +326,7 @@ void get_item_symbol(unsigned int object, unsigned short *ch,
if (Feature[object].colour != BLACK)
*colour = Feature[object].colour;
}
- *colour = fix_colour(*colour);
+ *colour = real_colour(*colour);
}
@@ -461,13 +458,13 @@ screen_buffer_t colour_code_map( int x, int y, bool item_colour,
if (map_flags & MAP_DETECTED_MONSTER)
{
tc = Options.detected_monster_colour;
- return fix_colour(tc);
+ return real_colour(tc);
}
// XXX: [ds] If we've an important colour, override other feature
// colouring. Yes, this is hacky. Story of my life.
if (tc == LIGHTGREEN || tc == LIGHTMAGENTA)
- return fix_colour(tc);
+ return real_colour(tc);
if (item_colour && is_envmap_item(x + 1, y + 1))
return get_envmap_col(x + 1, y + 1);
@@ -486,7 +483,7 @@ screen_buffer_t colour_code_map( int x, int y, bool item_colour,
tc |= COLFLAG_STAIR_ITEM;
}
- return fix_colour(tc);
+ return real_colour(tc);
}
void clear_map(bool clear_detected_items, bool clear_detected_monsters)
@@ -1657,7 +1654,6 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
bool allow_fallback, ray_def& ray, int cycle_dir,
bool find_shortest )
{
-
int cellray, inray;
const int signx = ((targetx - sourcex >= 0) ? 1 : -1);
const int signy = ((targety - sourcey >= 0) ? 1 : -1);
@@ -1692,11 +1688,12 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
bool blocked = false;
coord_def c1, c3;
int real_length = 0;
- for ( inray = 0; inray < cellray; ++inray )
+ for ( inray = 0; inray <= cellray; ++inray )
{
const int xi = signx * ray_coord_x[inray + cur_offset];
const int yi = signy * ray_coord_y[inray + cur_offset];
- if (grid_is_solid(grd[sourcex + xi][sourcey + yi]))
+ if (inray < cellray
+ && grid_is_solid(grd[sourcex + xi][sourcey + yi]))
{
blocked = true;
break;
@@ -1727,10 +1724,6 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety,
}
}
- if (find_shortest)
- unaliased_ray.push_back(
- coord_def(signx * absx, signy * absy));
-
int cimbalance = 0;
// If this ray is a candidate for shortest, calculate
// the imbalance. I'm defining 'imbalance' as the
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index 841e33c3ab..c303619497 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -120,6 +120,9 @@ int get_screen_glyph( int x, int y );
void get_item_symbol(unsigned int object, unsigned short *ch,
unsigned short *colour);
+// Applies EC_ colour substitutions and brands.
+unsigned real_colour(unsigned raw_colour);
+
void set_envmap_char( int x, int y, unsigned char chr );
unsigned get_envmap_char(int x, int y);
void set_envmap_detected_item(int x, int y, bool detected = true);