From 0c0e03aa42471d8d791cdd5bbd9503455623b740 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Fri, 20 Nov 2009 20:45:11 -0800 Subject: define_monster(): init ghost_demon for some mons Move setting up of mons.ghost for pandemonium lords to define_monster(), and also have define_monster() do some default initialization for (very) ugly things and player ghosts, so that a simple define_monster() will generate something valid to be displayed in the monster lookup menu (?/M). --- crawl-ref/source/mon-place.cc | 7 ------- crawl-ref/source/mon-util.cc | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/mon-place.cc b/crawl-ref/source/mon-place.cc index 4dbd5957a8..6f77a2619a 100644 --- a/crawl-ref/source/mon-place.cc +++ b/crawl-ref/source/mon-place.cc @@ -1350,13 +1350,6 @@ static int _place_monster_aux(const mgen_data &mg, mon->set_ghost(ghost, false); mon->uglything_init(); } - else if (mon->type == MONS_PANDEMONIUM_DEMON) - { - ghost_demon ghost; - ghost.init_random_demon(); - mon->set_ghost(ghost); - mon->pandemon_init(); - } else if (mon->type == MONS_DANCING_WEAPON) { ghost_demon ghost; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index db8d05c2ac..35a7c8e218 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -1633,6 +1633,44 @@ void define_monster(monsters &mons) // Reset monster enchantments. mons.enchantments.clear(); mons.ench_countdown = 0; + + // NOTE: For player ghosts and (very) ugly things this just ensures that + // the monster instance is valid and won't crash when used, though the + // (very) ugly thing generated should actually work. The player ghost and + // (very) ugly thing code is currently only used for generating a monster + // for MonsterMenuEntry in _find_description() in command.cc + switch (mcls) { + case MONS_PANDEMONIUM_DEMON: + { + ghost_demon ghost; + ghost.init_random_demon(); + mons.set_ghost(ghost); + mons.pandemon_init(); + break; + } + + case MONS_PLAYER_GHOST: + { + ghost_demon ghost; + ghost.init_player_ghost(); + mons.set_ghost(ghost); + mons.ghost_init(); + break; + } + + case MONS_UGLY_THING: + case MONS_VERY_UGLY_THING: + { + ghost_demon ghost; + ghost.init_ugly_thing(mcls == MONS_VERY_UGLY_THING); + mons.set_ghost(ghost, false); + mons.uglything_init(); + break; + } + + default: + break; + } } static const unsigned char ugly_colour_values[] = { -- cgit v1.2.3-54-g00ecf