Skip to content

Commit

Permalink
Add threat level indicators for monsters
Browse files Browse the repository at this point in the history
Webtiles and console both have a monster list at the bottom-right of
the screen which lists all monsters in view color-coded by rough
threat level. Many players have expressed a desire for something
similar in offline tiles, to provide always-visible indicators of the
threat levels of all enemies in view. This commit adds translucent
colored backgrounds -- dark grey, light grey, yellow, and red --
to indicate trivial, easy, tough, and nasty monsters respectively.

Additionally, these indicators are configurable with a new option in
the options file, "tile_show_threat_levels" with valid values being any set of 'trivial', 'easy', 'tough' and 'nasty'. Each type of indicator
can be independently enabled or disabled by including or omitting it
in the option file line. For example, the following...

"tile_show_threat_levels = tough nasty"

...will show only yellow (tough) and red (nasty) threat indicators.

This patch was mostly written by GnarledBeach in PR crawl#1120. I picked it up and added webtiles support, plus squashed some trivial commits.
  • Loading branch information
ByrelMitchell committed Nov 25, 2019
1 parent 9513415 commit 7b30f65
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crawl-ref/source/initfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ const vector<GameOption*> game_options::build_options_list()
new BoolGameOption(SIMPLE_NAME(tile_show_minihealthbar), true),
new BoolGameOption(SIMPLE_NAME(tile_show_minimagicbar), true),
new BoolGameOption(SIMPLE_NAME(tile_show_demon_tier), false),
new StringGameOption(SIMPLE_NAME(tile_show_threat_levels),
"trivial easy tough nasty"),
new StringGameOption(SIMPLE_NAME(tile_show_items), "!?/%=([)x}:|\\"),
// disabled by default due to performance issues
new BoolGameOption(SIMPLE_NAME(tile_water_anim), !USING_WEB_TILES),
Expand Down
22 changes: 22 additions & 0 deletions crawl-ref/source/menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1549,6 +1549,28 @@ bool MonsterMenuEntry::get_tiles(vector<tile_def>& tileset) const
tileset.emplace_back(TILE_HALO_GD_NEUTRAL, TEX_FEAT);
else if (m->neutral())
tileset.emplace_back(TILE_HALO_NEUTRAL, TEX_FEAT);
else
switch (m->threat)
{
case MTHRT_TRIVIAL:
if (Options.tile_show_threat_levels.find("trivial") != string::npos)
tileset.emplace_back(TILE_BORDER_TRIVIAL, TEX_FEAT);
break;
case MTHRT_EASY:
if (Options.tile_show_threat_levels.find("easy") != string::npos)
tileset.emplace_back(TILE_BORDER_EASY, TEX_FEAT);
break;
case MTHRT_TOUGH:
if (Options.tile_show_threat_levels.find("tough") != string::npos)
tileset.emplace_back(TILE_BORDER_TOUGH, TEX_FEAT);
break;
case MTHRT_NASTY:
if (Options.tile_show_threat_levels.find("nasty") != string::npos)
tileset.emplace_back(TILE_BORDER_NASTY, TEX_FEAT);
break;
default:
break;
}

if (m->type == MONS_DANCING_WEAPON)
{
Expand Down
1 change: 1 addition & 0 deletions crawl-ref/source/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ struct game_options
bool tile_show_minihealthbar;
bool tile_show_minimagicbar;
bool tile_show_demon_tier;
string tile_show_threat_levels;
bool tile_water_anim;
bool tile_misc_anim;
vector<string> tile_layout_priority;
Expand Down
4 changes: 4 additions & 0 deletions crawl-ref/source/rltiles/dc-feat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,10 @@ halo_friendly HALO_FRIENDLY
halo_gd_neutral HALO_GD_NEUTRAL
halo_neutral HALO_NEUTRAL
halo_summoner HALO_SUMMONER
monster_threat_trivial BORDER_TRIVIAL
monster_threat_easy BORDER_EASY
monster_threat_tough BORDER_TOUGH
monster_threat_nasty BORDER_NASTY
ray RAY
ray_multi RAY_MULTI
ray_out_of_range RAY_OUT_OF_RANGE
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions crawl-ref/source/tile-flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ enum tile_flags ENUM_INT64
TILE_FLAG_VILE_CLUTCH = 0x400000000000000ULL,
TILE_FLAG_POSSESSABLE = 0x800000000000000ULL,

// 4 mutually exclusive flags for threat level.
TILE_FLAG_THREAT_MASK = 0xE000000000000000ULL,
TILE_FLAG_TRIVIAL = 0x2000000000000000ULL,
TILE_FLAG_EASY = 0x4000000000000000ULL,
TILE_FLAG_TOUGH = 0x6000000000000000ULL,
TILE_FLAG_NASTY = 0x8000000000000000ULL,

// MDAM has 5 possibilities, so uses 3 bits.
TILE_FLAG_MDAM_MASK = 0x1C0000000ULL,
TILE_FLAG_MDAM_LIGHT = 0x040000000ULL,
Expand Down
10 changes: 10 additions & 0 deletions crawl-ref/source/tiledgnbuf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,16 @@ void DungeonCellBuffer::pack_background(int x, int y, const packed_cell &cell)
else if (att_flag == TILE_FLAG_NEUTRAL)
m_buf_feat.add(TILE_HALO_NEUTRAL, x, y);

const tileidx_t threat_flag = cell.fg & TILE_FLAG_THREAT_MASK;
if (threat_flag == TILE_FLAG_TRIVIAL)
m_buf_feat.add(TILE_BORDER_TRIVIAL, x, y);
else if (threat_flag == TILE_FLAG_EASY)
m_buf_feat.add(TILE_BORDER_EASY, x, y);
else if (threat_flag == TILE_FLAG_TOUGH)
m_buf_feat.add(TILE_BORDER_TOUGH, x, y);
else if (threat_flag == TILE_FLAG_NASTY)
m_buf_feat.add(TILE_BORDER_NASTY, x, y);

if (cell.is_highlighted_summoner)
m_buf_feat.add(TILE_HALO_SUMMONER, x, y);
}
Expand Down
23 changes: 23 additions & 0 deletions crawl-ref/source/tilepick.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,29 @@ tileidx_t tileidx_monster(const monster_info& mons)
ch |= TILE_FLAG_GD_NEUTRAL;
else if (mons.neutral())
ch |= TILE_FLAG_NEUTRAL;
else
switch (mons.threat)
{
case MTHRT_TRIVIAL:
if (Options.tile_show_threat_levels.find("trivial") != string::npos)
ch |= TILE_FLAG_TRIVIAL;
break;
case MTHRT_EASY:
if (Options.tile_show_threat_levels.find("easy") != string::npos)
ch |= TILE_FLAG_EASY;
break;
case MTHRT_TOUGH:
if (Options.tile_show_threat_levels.find("tough") != string::npos)
ch |= TILE_FLAG_TOUGH;
break;
case MTHRT_NASTY:
if (Options.tile_show_threat_levels.find("nasty") != string::npos)
ch |= TILE_FLAG_NASTY;
break;
default:
break;
}

if (mons.is(MB_FLEEING))
ch |= TILE_FLAG_FLEEING;
else if (mons.is(MB_STABBABLE) || mons.is(MB_SLEEPING)
Expand Down
10 changes: 10 additions & 0 deletions crawl-ref/source/webserver/game_data/static/cell_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,16 @@ function ($, view_data, main, tileinfo_player, icons, dngn, enums,
else if (fg.NEUTRAL)
this.draw_dngn(dngn.HALO_NEUTRAL, x, y);

// Monster difficulty
if (fg.TRIVIAL)
this.draw_dngn(dngn.BORDER_TRIVIAL, x, y);
else if (fg.EASY)
this.draw_dngn(dngn.BORDER_EASY, x, y);
else if (fg.TOUGH)
this.draw_dngn(dngn.BORDER_TOUGH, x, y);
else if (fg.NASTY)
this.draw_dngn(dngn.BORDER_NASTY, x, y);

if (cell.highlighted_summoner)
this.draw_dngn(dngn.HALO_SUMMONER, x, y);
}
Expand Down
9 changes: 9 additions & 0 deletions crawl-ref/source/webserver/game_data/static/enums.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@ define(function () {
fg_flags.flags.PINNED = [0, 0x2000000];
fg_flags.flags.VILE_CLUTCH = [0, 0x4000000];

// Threat level has 4 possibilities, so uses 3 bits.
fg_flags.exclusive_flags.push({
mask : [0, 0x60000000 | highbit],
TRIVIAL : [0, 0x20000000],
EASY : [0, 0x40000000],
TOUGH : [0, 0x60000000],
NASTY : [0, highbit]
})

// MDAM has 5 possibilities, so uses 3 bits.
fg_flags.exclusive_flags.push({
mask : [0x40000000 | highbit, 0x01],
Expand Down

0 comments on commit 7b30f65

Please sign in to comment.