diff options
author | Johanna Ploog <j-p-e-g@users.sourceforge.net> | 2010-01-15 19:09:37 +0100 |
---|---|---|
committer | Johanna Ploog <j-p-e-g@users.sourceforge.net> | 2010-01-15 19:28:55 +0100 |
commit | d3b316cb62dd1fbd27789ef36076c3ca83290422 (patch) | |
tree | b54ad2dcef3a1e894da4e6a37ae3eb173e6f2e49 /crawl-ref/source/mon-place.cc | |
parent | e9a337536b2a0c74eea3835061fa292f4ede6069 (diff) | |
download | crawl-ref-d3b316cb62dd1fbd27789ef36076c3ca83290422.tar.gz crawl-ref-d3b316cb62dd1fbd27789ef36076c3ca83290422.zip |
Add new props value "tile_num" and use it for randomized monster tiles.
Monsters that have several variant tiles will now get a random value
written into tile_num at creation, so when their tile gets drawn one
of the set is picked, but always the same one.
In practise, this is currently only used for slaves and toadstools.
Other monsters that have variant tiles, such as ugly things, kraken
tentacles, or slimes creatures, are handled specially.
Generally, such differences should be small and flavourful. The greater
the threat of a given monster the more important it is that the player
will recognize it immediately. (Of course, this restriction does not
hold if the tile actually transport information as is the case for
ugly things' colours etc.)
Diffstat (limited to 'crawl-ref/source/mon-place.cc')
-rw-r--r-- | crawl-ref/source/mon-place.cc | 25 |
1 files changed, 18 insertions, 7 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. |