From c5f945ee7a4616a77a568245ebb0fcd7c8b859b1 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Thu, 25 Dec 2008 10:13:49 +0000 Subject: FR #2083661: when polymorphed, unique (and named) monsters now retain their name (but not spells, yet), and use their old speech text if it makes sense for them to be able to do so. Polymorphed monsters now retain some of their old flags, like MF_CREATED_FRIENDLY and MF_GOT_HALF_XP. If the Royal Jelly is polymorphed into something else then the Slime:6 vaults will unlock when that monster is killed. If the Royal Jelly is banished the player will be given a hint that it's gone and that the vaults will remain locked. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7970 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/monspeak.cc | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/monspeak.cc') diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc index 059ad562cc..2619563f2b 100644 --- a/crawl-ref/source/monspeak.cc +++ b/crawl-ref/source/monspeak.cc @@ -200,6 +200,27 @@ 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 it's old +// speech? +static bool _polyd_can_speak(const monsters* monster) +{ + // Wizard and priest monsters can always speak. + if (mons_class_flag(monster->type, M_ACTUAL_SPELLS | M_PRIEST)) + 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 something is said. bool mons_speaks(const monsters *monster) { @@ -316,7 +337,15 @@ bool mons_speaks(const monsters *monster) msg = _get_speak_string(prefixes, "pandemonium lord", monster); } else - msg = _get_speak_string(prefixes, monster->name(DESC_PLAIN), monster); + { + if (!monster->mname.empty() && _polyd_can_speak(monster)) + msg = _get_speak_string(prefixes, monster->name(DESC_PLAIN), + monster); + + if (msg.empty()) + msg = _get_speak_string(prefixes, monster->base_name(DESC_PLAIN), + monster); + } // The exact name brought no results, try monster genus. if ((msg.empty() || msg == "__NEXT") -- cgit v1.2.3-54-g00ecf