From 493425c55ef17b8c584bc1434d6b0a94eef23950 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Fri, 20 Nov 2009 23:54:46 -0800 Subject: tiles monster lookup: dancing weapons tiles Handle faked dancing weapons tiles in MonsterMenuEntry::get_tiles() --- crawl-ref/source/command.cc | 20 ++++++++------------ crawl-ref/source/menu.cc | 35 +++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 20 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 21fb52becd..0d98b27b46 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -1726,7 +1726,10 @@ static bool _find_description(bool &again, std::string& error_inout) monsters fake_mon; monster_type m_type = get_monster_by_name(str, true); + // NOTE: Initializing the demon_ghost part of (very) ugly + // things and player ghosts is taken care of in define_monster(). fake_mon.type = m_type; + fake_mon.props["fake"] = true; define_monster(fake_mon); // FIXME: This doesn't generate proper draconian monsters. @@ -1748,18 +1751,11 @@ static bool _find_description(bool &again, std::string& error_inout) str = prefix + str; #endif - // FIXME: Properly set up a dancing weapon monster to - // show in tiles. There must be a weapon item in mitm[], - // which the dancing weapon has wielded. - if (m_type != MONS_DANCING_WEAPON) - me = new MonsterMenuEntry(str, &(monster_list.back()), - letter); - else - { - me = new MenuEntry(str, MEL_ITEM, 1, letter); - - me->data = (void*) &(monster_list.back()); - } + // NOTE: MonsterMenuEntry::get_tiles() takes care of setting + // up a fake weapon when displaying a fake dancing weapon's + // tile. + me = new MonsterMenuEntry(str, &(monster_list.back()), + letter); } else if (doing_features) me = new FeatureMenuEntry(str, feat_by_desc(str), letter); diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index b641b01ace..a0673d5be1 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -761,18 +761,35 @@ bool MonsterMenuEntry::get_tiles(std::vector& tileset) const if (!m) return (false); - const coord_def c = m->pos(); - int ch = tileidx_feature(grd(c), c.x, c.y); - if (ch == TILE_FLOOR_NORMAL) - ch = env.tile_flv(c).floor; - else if (ch == TILE_WALL_NORMAL) - ch = env.tile_flv(c).wall; + const bool fake = m->props.exists("fake"); + const coord_def c = m->pos(); + int ch = TILE_FLOOR_NORMAL; + + if (!fake) + { + ch = tileidx_feature(grd(c), c.x, c.y); + if (ch == TILE_FLOOR_NORMAL) + ch = env.tile_flv(c).floor; + else if (ch == TILE_WALL_NORMAL) + ch = env.tile_flv(c).wall; + } tileset.push_back(tile_def(ch, TEX_DUNGEON)); if (m->type == MONS_DANCING_WEAPON) { - item_def item = mitm[m->inv[MSLOT_WEAPON]]; + // For fake dancing weapons, just use a generic long sword, since + // fake monsters won't have a real item equipped. + item_def item; + if (fake) + { + item.base_type = OBJ_WEAPONS; + item.sub_type = WPN_LONG_SWORD; + item.quantity = 1; + } + else + item = mitm[m->inv[MSLOT_WEAPON]]; + tileset.push_back(tile_def(tileidx_item(item), TEX_DEFAULT)); tileset.push_back(tile_def(TILE_ANIMATED_WEAPON, TEX_DEFAULT)); } @@ -781,7 +798,9 @@ bool MonsterMenuEntry::get_tiles(std::vector& tileset) const else tileset.push_back(tile_def(tileidx_monster_base(m), TEX_PLAYER)); - if (!mons_flies(m)) + // A fake monster might not have it's ghost member set up properly, + // and mons_flies() looks at ghost. + if (!fake && !mons_flies(m)) { if (ch == TILE_DNGN_LAVA) tileset.push_back(tile_def(TILE_MASK_LAVA, TEX_DEFAULT)); -- cgit v1.2.3-54-g00ecf