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WFKC6RXQIRRTSSTF3Z2QPVCAC
4G2K5BAIB5SDKIQKA4CJUPAJDGKINIRCM5AZST5POL2YCNDTF7AQC
IHOKNI4O7EEW4UBMKHP6XOZNEIQSW4AYOT4O3JXUIXNNR553IQAQC
X33DHOW2PFC4YDGNF5UH5NOX7QXT6BTE634NDT4RNYGCWW6TT5DAC
6PNVX6Q45HH733TZDXYBA6BYPJKDMND5BA4N2MP6HA3QVNCEPN2QC
TRCCLE5RJ4VJULBOWOI2WC3RJU7WTEGS7RRQTDQL6W5UU246LKTQC
3VWSZUGYL36SO5AOZRASGK3VHFCFZUGGCGRT3R7BZB36IZPN7OSQC
FACD4S74A4PYPEYDEIDP56BPE5NJGRK2RWVOKROXLMT7FJUPTYQAC
56JVX6R2B54KWATOPKE5RIED4M2AW7FPTPUSUU57RXY7OKJVOI2QC
EOMCPVNQLX3IMLC46EAO67DPBH5KEG2FQTPBLGU62HIRWA3UQ7XQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
NQIXUYGUIQTKZUB2IQDII7BBDMZ4VN4NUUTGT2ARQBZTDJUMPKRQC
GQ3RKP6CX6TT37NNKSLCW3S3WPICG2HO7GIKGKO7UOKX4UQFD7RAC
3YBQGKQ22WFXA5RXDSKLFWMABLJ6KHBVWEIA3WIDHWM25OECNTYAC
CZCG4FOXPQXXUCGKK4W2IHUJK2PXUZJ22IAA6UIZ2EU7WX7VLOBQC
22RFWMSJGG26Z2MQEEXGKVTFSTLREHQIG46WYOTMDRKI5YVMRNVAC
NO2HRD7RZS42S55UG4FQ5EFQDY6WYWKGIXHUKYLWF36HHE3VZ7WAC
4UQBOVCMAMNCCF6PPX222H6JJO7MPYOKKC2NBKMVYIT5R5FOACNAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
// ----------------------------------------------------------------------
// colour_bar
// ----------------------------------------------------------------------
class colour_bar
{
typedef unsigned short color_t;
public:
colour_bar(color_t default_colour,
color_t change_pos,
color_t change_neg,
color_t empty)
: m_default(default_colour), m_change_pos(change_pos),
m_change_neg(change_neg), m_empty(empty),
m_old_disp(-1),
m_request_redraw_after(0)
{
// m_old_disp < 0 means it's invalid and needs to be initialized
}
bool wants_redraw() const
{
return (m_request_redraw_after && you.num_turns >= m_request_redraw_after);
}
void draw(int ox, int oy, int val, int max_val)
{
ASSERT(val <= max_val);
if (max_val <= 0)
{
m_old_disp = -1;
return;
}
#ifdef USE_TILE
// Don't redraw colour bars while resting
// *unless* we'll stop doing so right after that
if (you.running >= 2 && is_resting() && val != max_val)
{
m_old_disp = -1;
return;
}
#endif
const int width = crawl_view.hudsz.x - (ox-1);
const int disp = width * val / max_val;
const int old_disp = (m_old_disp < 0) ? disp : m_old_disp;
m_old_disp = disp;
cgotoxy(ox, oy, GOTO_STAT);
textcolor(BLACK);
for (int cx = 0; cx < width; cx++)
{
#ifdef USE_TILE
// maybe this should use textbackground too?
textcolor(BLACK + m_empty * 16);
if (cx < disp)
textcolor(BLACK + m_default * 16);
else if (old_val > val && old_disp > disp && cx < old_disp)
textcolor(BLACK + m_change_neg * 16);
putch(' ');
#else
if (cx < disp && cx < old_disp)
{
textcolor(m_default);
putch('=');
}
else if (/* old_disp <= cx && */ cx < disp)
{
textcolor(m_change_pos);
putch('=');
}
else if (/* disp <= cx && */ cx < old_disp)
{
textcolor(m_change_neg);
putch('-');
}
else
{
textcolor(m_empty);
putch('-');
}
// If some change colour was rendered, redraw in a few
// turns to clear it out.
if (old_disp != disp)
m_request_redraw_after = you.num_turns + 4;
else
m_request_redraw_after = 0;
#endif
}
textcolor(LIGHTGREY);
textbackground(BLACK);
}
private:
const color_t m_default;
const color_t m_change_pos;
const color_t m_change_neg;
const color_t m_empty;
int m_old_disp;
int m_request_redraw_after; // force a redraw at this turn count
};
colour_bar HP_Bar(GREEN, LIGHTGREEN, RED, DARKGRAY);
#ifdef USE_TILE
colour_bar MP_Bar(BLUE, BLUE, LIGHTBLUE, DARKGRAY);
#else
colour_bar MP_Bar(BLUE, LIGHTBLUE, MAGENTA, DARKGRAY);
#endif
// ----------------------------------------------------------------------
// Status display
// ----------------------------------------------------------------------
case GREEN: textcolor( LIGHTGREEN ); break;
case BLUE: textcolor( LIGHTBLUE ); break;
case MAGENTA: textcolor( LIGHTMAGENTA ); break;
case LIGHTGREY: textcolor( WHITE ); break;
case GREEN: return ( LIGHTGREEN );
case BLUE: return ( LIGHTBLUE );
case MAGENTA: return ( LIGHTMAGENTA );
case LIGHTGREY: return ( WHITE );
default: return running_out_color;
}
static int _draw_colour_bar(int val, int max_val, int old_val, int old_disp,
int ox, int oy, unsigned short default_colour,
unsigned short change_colour,
unsigned short empty_colour)
{
ASSERT(val <= max_val);
if (max_val <= 0)
return -1;
// Don't redraw colour bars while resting
// *unless* we'll stop doing so right after that
if (you.running >= 2 && is_resting() && val != max_val)
return -1;
const int width = crawl_view.hudsz.x - (ox-1);
int disp = width * val / max_val;
cgotoxy(ox, oy, GOTO_STAT);
textcolor(BLACK);
for (int cx = 0; cx < width; cx++)
{
#ifdef USE_TILE
// maybe this should use textbackground too?
textcolor(BLACK + empty_colour * 16);
if (cx < disp)
textcolor(BLACK + default_colour * 16);
else if (old_val > val && old_disp > disp && cx < old_disp)
textcolor(BLACK + change_colour * 16);
putch(' ');
#else
if (cx < disp)
{
textcolor(default_colour);
putch('=');
}
else if (old_val > val && old_disp > disp && cx < old_disp)
{
textcolor(change_colour);
putch('-');
}
else
{
textcolor(empty_colour);
putch('-');
}
#endif
}
textcolor(LIGHTGREY);
textbackground(BLACK);
return disp;
}
void draw_mp_bar(int ox, int oy, int val, int max_val)
{
const unsigned short default_colour = BLUE;
const unsigned short change = LIGHTBLUE;
const unsigned short empty = DARKGRAY;
static int old_val = 0;
static int old_disp = 0;
old_disp = _draw_colour_bar(val, max_val, old_val, old_disp, ox, oy,
default_colour, change, empty);
old_val = val;
}
void draw_hp_bar(int ox, int oy, int val, int max_val)
{
const unsigned short default_colour = GREEN;
const unsigned short change = RED;
const unsigned short empty = DARKGRAY;
static int old_val = 0;
static int old_disp = 0;
old_disp = _draw_colour_bar(val, max_val, old_val, old_disp, ox, oy,
default_colour, change, empty);
old_val = val;
// Prints burden, hunger
// Max length: "Encumbered Near Starving (NNN:NNN)" = 34
static void _print_stats_line1(int y)
// Prints burden, hunger,
// pray, holy, teleport, regen, insulation, fly/lev, invis, silence,
// conf. touch, bargain, sage
// confused, beheld, fire, poison, disease, rot, held, glow,
// swift, fast, slow, breath
//
// Note the usage of bad_ench_colour() correspond to levels that
// can be found in player.cc, ie those that the player can tell by
// using the '@' command. Things like confusion and sticky flame
// hide their amounts and are thus always the same colour (so
// we're not really exposing any new information). --bwr
static void _get_status_lights(std::vector<status_light>& out)
cgotoxy(1, y, GOTO_STAT);
clear_to_end_of_line();
cgotoxy(1, y, GOTO_STAT);
#if DEBUG_DIAGNOSTICS
{
static char static_pos_buf[80];
snprintf(static_pos_buf, sizeof(static_pos_buf),
"%2d,%2d", you.x_pos, you.y_pos );
out.push_back(status_light(LIGHTGREY, static_pos_buf));
case HS_ENGORGED:
textcolor( LIGHTGREEN );
break;
case HS_VERY_FULL:
case HS_FULL:
case HS_SATIATED:
textcolor( GREEN );
break;
case HS_HUNGRY:
case HS_VERY_HUNGRY:
case HS_NEAR_STARVING:
textcolor( YELLOW );
break;
case HS_STARVING:
textcolor( RED );
break;
int hunger_color;
const char* hunger_text = _describe_hunger(hunger_color);
if (hunger_text)
out.push_back(status_light(hunger_color, hunger_text));
textcolor( LIGHTGREY );
#if DEBUG_DIAGNOSTICS
// debug mode hunger-o-meter
cprintf( " (%d:%d)", you.hunger - you.old_hunger, you.hunger );
#endif
}
// For colors, see comment at _print_stats_line1
// Prints: pray, holy, teleport, regen, insulation, fly/lev, invis, silence,
// conf. touch, bargain, sage
static void _print_stats_line2(int y)
{
cgotoxy(1, y, GOTO_STAT);
clear_to_end_of_line();
cgotoxy(1, y, GOTO_STAT);
// Max length of this line = 8 * 5 - 1 = 39
_dur_colour( LIGHTGREY, (you.duration[DUR_REPEL_UNDEAD] <= 4) );
cprintf( "Holy " );
int color = _dur_colour( LIGHTGREY, (you.duration[DUR_REPEL_UNDEAD] <= 4) );
out.push_back(status_light(color, "Holy"));
_dur_colour( MAGENTA, (you.duration[DUR_DEFLECT_MISSILES] <= 6) );
cprintf( "DMsl " );
int color = _dur_colour( MAGENTA, (you.duration[DUR_DEFLECT_MISSILES] <= 6) );
out.push_back(status_light(color, "DMsl"));
_dur_colour( BLUE, (you.duration[DUR_REPEL_MISSILES] <= 6) );
cprintf( "RMsl " );
int color = _dur_colour( BLUE, (you.duration[DUR_REPEL_MISSILES] <= 6) );
out.push_back(status_light(color, "RMsl"));
_dur_colour( BLUE, (you.duration[DUR_REGENERATION] <= 6) );
cprintf( "Regen " );
int color = _dur_colour( BLUE, (you.duration[DUR_REGENERATION] <= 6) );
out.push_back(status_light(color, "Regen"));
_dur_colour( BLUE, (you.duration[DUR_INSULATION] <= 6) );
cprintf( "Ins " );
int color = _dur_colour( BLUE, (you.duration[DUR_INSULATION] <= 6) );
out.push_back(status_light(color, "Ins"));
_dur_colour(BLUE, (you.duration[DUR_LEVITATION] <= 10 && !perm));
cprintf( "Lev " );
int color = _dur_colour(BLUE, (you.duration[DUR_LEVITATION] <= 10 && !perm));
out.push_back(status_light(color, "Lev"));
_dur_colour( BLUE, (you.duration[DUR_BARGAIN] <= 15) );
cprintf( "Brgn " );
int color = _dur_colour( BLUE, (you.duration[DUR_BARGAIN] <= 15) );
out.push_back(status_light(color, "Brgn"));
textcolor( LIGHTGREY );
}
// For colors, see comment at _print_stats_line1
// Prints confused, beheld, fire, poison, disease, rot, held, glow,
// swift, fast, slow, breath
static void _print_stats_line3(int y)
{
cgotoxy(1, y, GOTO_STAT);
clear_to_end_of_line();
cgotoxy(1, y, GOTO_STAT);
// Max length of this line = 7 * 5 + 3 - 1 = 37
// Note the usage of bad_ench_colour() correspond to levels that
// can be found in player.cc, ie those that the player can tell by
// using the '@' command. Things like confusion and sticky flame
// hide their amounts and are thus always the same colour (so
// we're not really exposing any new information). --bwr
// We skip marking "quite" poisoned and instead mark the
// levels where the rules for dealing poison damage change
// significantly. See acr.cc for that code. -- bwr
textcolor( _bad_ench_colour( you.duration[DUR_POISONING], 5, 10 ) );
cprintf( "Pois " );
int color = _bad_ench_colour( you.duration[DUR_POISONING], 5, 10 );
out.push_back(status_light(color, "Pois"));
textcolor(you.magic_contamination > 5 ?
_bad_ench_colour( you.magic_contamination, 15, 25 )
: LIGHTBLUE );
cprintf( "Glow " );
int color = you.magic_contamination > 5
? _bad_ench_colour( you.magic_contamination, 15, 25 )
: LIGHTBLUE;
out.push_back(status_light(color, "Glow"));
_dur_colour( BLUE, (you.duration[DUR_SWIFTNESS] <= 6) );
cprintf( "Swift " );
int color = _dur_colour( BLUE, (you.duration[DUR_SWIFTNESS] <= 6) );
out.push_back(status_light(color, "Swift"));
// Perhaps this should be reversed to show when it can be used?
// In that case, it should be probably be GREEN, and we'd have
// to check to see if the player does have a breath weapon. -- bwr
if (you.duration[DUR_BREATH_WEAPON] && wherex() < get_number_of_cols() - 5)
if (you.duration[DUR_BREATH_WEAPON])
textcolor( LIGHTGREY );
}
static void _print_status_lights(int y)
{
you.redraw_status_flags = 0;
std::vector<status_light> lights;
size_t line_cur = y;
const size_t line_end = crawl_view.hudsz.y+1;
size_t i_light = 0;
_get_status_lights(lights);
cgotoxy(1, line_cur, GOTO_STAT);
ASSERT(wherex()-crawl_view.hudp.x == 0);
while (true)
{
const int end_x = (wherex() - crawl_view.hudp.x) +
(i_light < lights.size() ? strlen(lights[i_light].text) : 10000);
#if DEBUG_DIAGNOSTICS
cprintf( "%2d,%2d", you.x_pos, you.y_pos );
#endif
if (end_x <= crawl_view.hudsz.x)
{
textcolor(lights[i_light].color);
cprintf("%s", lights[i_light].text);
if (end_x < crawl_view.hudsz.x)
cprintf(" ");
++ i_light;
}
else
{
clear_to_end_of_line();
++ line_cur;
// Careful not to trip the )#(*$ cgotoxy ASSERT
if (line_cur == line_end) break;
cgotoxy(1, line_cur, GOTO_STAT);
}
}
// Health: 910/932 (999)
// Magic: 7/7
// Str: 13 AC: 3
// Int: 15 Sh: -
// Dex: 14 Ev: 12
// Level 1 of the Dungeon
if (you.redraw_status_flags & REDRAW_LINE_1_MASK)
_print_stats_line1(12);
if (you.redraw_status_flags & REDRAW_LINE_2_MASK)
_print_stats_line2(13);
if (you.redraw_status_flags & REDRAW_LINE_3_MASK)
_print_stats_line3(14);
you.redraw_status_flags = 0;
if (you.redraw_status_flags)
{
you.redraw_status_flags = 0;
_print_status_lights(12);
}
void get_playervisible_monsters(std::vector<monsters*> &mons, bool want_move,
bool just_check, bool dangerous, int range)
//
// want_move (??) Somehow affects what monsters are considered dangerous
// just_check Return zero or one monsters only
// dangerous_only Return only "dangerous" monsters
// range search radius (defaults: LOS)
//
void get_playervisible_monsters(std::vector<monsters*> &mons,
bool want_move,
bool just_check,
bool dangerous_only,
int range)
#define INT_OPTION_NAMED(_opt_str, _opt_var, _min_val, _max_val) \
if (key == _opt_str) do { \
const int min_val = (_min_val); \
const int max_val = (_max_val); \
int val = atoi(field.c_str()); \
if (val < min_val) { \
crawl_state.add_startup_error( \
make_stringf("Bad %s: %d < %d", _opt_str, val, min_val)); \
val = min_val; \
} else if (val > max_val) { \
crawl_state.add_startup_error( \
make_stringf("Bad %s: %d > %d", _opt_str, val, max_val)); \
val = max_val; \
} \
this->_opt_var = val; \
} while (false)
#define INT_OPTION(_opt, _min_val, _max_val) \
INT_OPTION_NAMED(#_opt, _opt, _min_val, _max_val)