summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-20 20:45:11 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-20 20:45:11 -0800
commit0c0e03aa42471d8d791cdd5bbd9503455623b740 (patch)
tree80c6c958fccceb37c619ff6561b40e68d2601af4 /crawl-ref
parentcd26a67dc74141c030ac48ec29993fbb893a2005 (diff)
downloadcrawl-ref-0c0e03aa42471d8d791cdd5bbd9503455623b740.tar.gz
crawl-ref-0c0e03aa42471d8d791cdd5bbd9503455623b740.zip
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).
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/mon-place.cc7
-rw-r--r--crawl-ref/source/mon-util.cc38
2 files changed, 38 insertions, 7 deletions
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[] = {