From 3bea6e2e7aadb7df468b8a00c3a8fb42dde3dfb5 Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Mon, 23 Nov 2009 14:15:41 +0100 Subject: Move _polyd_can_speak() to monsters::can_speak() so others can use it. --- crawl-ref/source/mon-speak.cc | 26 ++++---------------------- crawl-ref/source/monster.cc | 18 ++++++++++++++++++ crawl-ref/source/monster.h | 1 + 3 files changed, 23 insertions(+), 22 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/mon-speak.cc b/crawl-ref/source/mon-speak.cc index 6d17ec3e11..be75705372 100644 --- a/crawl-ref/source/mon-speak.cc +++ b/crawl-ref/source/mon-speak.cc @@ -331,27 +331,6 @@ static std::string _player_ghost_speak_str(const monsters *monster, return msg; } -// If the monster was originally a unique which has been polymorphed into -// a non-unique, is its current monter type capable of using its old -// speech? -static bool _polyd_can_speak(const monsters* monster) -{ - // Priest and wizard monsters can always speak. - if (monster->is_priest() || monster->is_actual_spellcaster()) - return (true); - - // Silent or non-sentient monsters can't use the original speech. - if (mons_intel(monster) < I_NORMAL - || mons_shouts(monster->type) == S_SILENT) - { - return (false); - } - - // Does it have the proper vocal equipment? - const mon_body_shape shape = get_mon_shape(monster); - return (shape >= MON_SHAPE_HUMANOID && shape <= MON_SHAPE_NAGA); -} - // Returns true if the monster did speak, false otherwise. // Maybe monsters will speak! void maybe_mons_speaks (monsters *monster) @@ -579,7 +558,10 @@ bool mons_speaks(monsters *monster) } else { - if (!monster->mname.empty() && _polyd_can_speak(monster)) + // If the monster was originally a unique which has been polymorphed + // into a non-unique, is its current monter type capable of using its + // old speech? + if (!monster->mname.empty() && monster->can_speak()) { msg = _get_speak_string(prefixes, monster->name(DESC_PLAIN), monster, no_player, no_foe, no_foe_name, diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index 15fd301813..c5c018c8f5 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -659,6 +659,24 @@ bool monsters::can_throw_large_rocks() const || ::mons_species(type) == MONS_OGRE); } +bool monsters::can_speak() +{ + // Priest and wizard monsters can always speak. + if (is_priest() || is_actual_spellcaster()) + return (true); + + // Silent or non-sentient monsters can't use the original speech. + if (mons_intel(this) < I_NORMAL + || mons_shouts(type) == S_SILENT) + { + return (false); + } + + // Does it have the proper vocal equipment? + const mon_body_shape shape = get_mon_shape(this); + return (shape >= MON_SHAPE_HUMANOID && shape <= MON_SHAPE_NAGA); +} + bool monsters::has_spell_of_type(unsigned disciplines) const { for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h index 84a291cef8..c5c95f0550 100644 --- a/crawl-ref/source/monster.h +++ b/crawl-ref/source/monster.h @@ -364,6 +364,7 @@ public: bool has_damage_type(int dam_type); bool can_throw_large_rocks() const; + bool can_speak(); int armour_class() const; int melee_evasion(const actor *attacker, ev_ignore_type evit) const; -- cgit v1.2.3-54-g00ecf