diff options
-rw-r--r-- | crawl-ref/source/mon-place.cc | 25 | ||||
-rw-r--r-- | crawl-ref/source/tilepick.cc | 16 |
2 files changed, 31 insertions, 10 deletions
diff --git a/crawl-ref/source/mon-place.cc b/crawl-ref/source/mon-place.cc index 331071bfcc..36be19cdeb 100644 --- a/crawl-ref/source/mon-place.cc +++ b/crawl-ref/source/mon-place.cc @@ -1059,6 +1059,22 @@ monsters* get_free_monster() return (NULL); } +#ifdef USE_TILE +// For some tiles, always use the fixed same variant out of a set +// of tiles. (Where this is not handled by number or colour already.) +static void _maybe_init_tilenum_props(monsters *mon) +{ + // Not necessary. + if (mon->props.exists("monster_tile") || mon->props.exists("tile_num")) + return; + + // Only add the property for tiles that have several variants. + const int base_tile = tileidx_monster_base(mon); + if (tile_player_count(base_tile) > 1) + mon->props["tile_num"] = short(random2(256)); +} +#endif + static int _place_monster_aux(const mgen_data &mg, bool first_band_member, bool force_pos) { @@ -1132,13 +1148,8 @@ static int _place_monster_aux(const mgen_data &mg, else if (mon->type == MONS_MERGED_SLIME_CREATURE) // shouldn't ever happen mon->type = MONS_SLIME_CREATURE; #ifdef USE_TILE - else if (mon->type == MONS_SLAVE && !mon->props.exists("monster_tile") - && coinflip()) - { - // When placing the slave monster, there's a 50% chance the - // default tile is replaced with an alternative one. - mon->props["monster_tile"] = short(TILEP_MONS_SLAVE_SMALL); - } + else + _maybe_init_tilenum_props(mon); #endif // Generate a brand shiny new monster, or zombie. diff --git a/crawl-ref/source/tilepick.cc b/crawl-ref/source/tilepick.cc index d516e20b73..d0ea280cf6 100644 --- a/crawl-ref/source/tilepick.cc +++ b/crawl-ref/source/tilepick.cc @@ -115,6 +115,16 @@ static int _bow_offset(const monsters *mon) } } +static int _get_random_monster_tile(const monsters *mon, const int base_tile) +{ + if (!mon->props.exists("tile_num")) + return (base_tile); + + const int variants = tile_player_count(base_tile); + return base_tile + (mon->props["tile_num"].get_short() % variants); +} + + int tileidx_monster_base(const monsters *mon, bool detected) { bool in_water = feat_is_water(grd(mon->pos())); @@ -202,7 +212,7 @@ int tileidx_monster_base(const monsters *mon, bool detected) return TILEP_MONS_BALLISTOMYCETE_ACTIVE; return TILEP_MONS_BALLISTOMYCETE_INACTIVE; case MONS_TOADSTOOL: - return TILEP_MONS_TOADSTOOL; + return _get_random_monster_tile(mon, TILEP_MONS_TOADSTOOL); case MONS_FUNGUS: return TILEP_MONS_FUNGUS; case MONS_WANDERING_MUSHROOM: @@ -788,7 +798,7 @@ int tileidx_monster_base(const monsters *mon, bool detected) case MONS_KILLER_KLOWN: return TILEP_MONS_KILLER_KLOWN; case MONS_SLAVE: - return TILEP_MONS_SLAVE; + return _get_random_monster_tile(mon, TILEP_MONS_SLAVE); // mimics case MONS_GOLD_MIMIC: @@ -1116,7 +1126,7 @@ int tileidx_monster_base(const monsters *mon, bool detected) case MONS_KIRKE: return TILEP_MONS_KIRKE; case MONS_NIKOLA: - return TILEP_MONS_NIKOLA; // TODO + return TILEP_MONS_NIKOLA; case MONS_MAURICE: return TILEP_MONS_MAURICE; |