summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monspeak.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-05 06:59:32 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-05 06:59:32 +0000
commitcfc5e8cefc516db7e842518eb5afeff1b5aa46b5 (patch)
treee4364dcb162bc3c7bea69eacdb495d5f77bdb300 /crawl-ref/source/monspeak.cc
parentdc942d2989c077985d1ba2ca9c87801ef58da35f (diff)
downloadcrawl-ref-cfc5e8cefc516db7e842518eb5afeff1b5aa46b5.tar.gz
crawl-ref-cfc5e8cefc516db7e842518eb5afeff1b5aa46b5.zip
Generalize the mechanism for Boris' death message, so that any monster can
potentially have a death message (or a message for when the monster is banished or a summon runs out of time). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8235 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monspeak.cc')
-rw-r--r--crawl-ref/source/monspeak.cc81
1 files changed, 50 insertions, 31 deletions
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc
index 1d9a7c77b6..51496f4b49 100644
--- a/crawl-ref/source/monspeak.cc
+++ b/crawl-ref/source/monspeak.cc
@@ -267,11 +267,19 @@ static std::string __get_speak_string(const std::vector<std::string> &prefixes,
}
static std::string _get_speak_string(const std::vector<std::string> &prefixes,
- const std::string &key,
+ std::string key,
const monsters *monster,
bool no_player, bool no_foe,
bool no_foe_name, bool no_god)
{
+ int duration = 1;
+ if (monster->hit_points <= 0)
+ key += " killed";
+ else if (monster->flags & MF_BANISHED)
+ key += " banished";
+ else if (monster->is_summoned(&duration) && duration <= 0)
+ key += " unsummoned";
+
std::string msg;
for (int tries = 0; tries < 10; tries++)
{
@@ -354,44 +362,55 @@ static bool _polyd_can_speak(const monsters* monster)
// Returns true if something is said.
bool mons_speaks(const monsters *monster)
{
- // Invisible monster tries to remain unnoticed. Unless they're
- // confused, since then they're too confused to realize they
- // should stay silent, but only if the player can see them, so as
- // to not have to deal with cases of speaking monsters which the
- // player can't see.
- if (monster->invisible() && !(player_monster_visible(monster)
- && monster->has_ench(ENCH_CONFUSION)))
- {
- return (false);
- }
+ ASSERT(!invalid_monster_class(monster->type));
+
+ // Monsters always talk on death, even if invisible/silenced/etc
+ int duration = -1;
+ const bool force_speak = !monster->alive()
+ || !(monster->flags & MF_BANISHED)
+ || (monster->is_summoned(&duration) && duration <= 0);
+
+ if (!force_speak)
+ {
+ // Invisible monster tries to remain unnoticed. Unless they're
+ // confused, since then they're too confused to realize they
+ // should stay silent, but only if the player can see them, so as
+ // to not have to deal with cases of speaking monsters which the
+ // player can't see.
+ if (monster->invisible() && !(player_monster_visible(monster)
+ && monster->has_ench(ENCH_CONFUSION)))
+ {
+ return (false);
+ }
+
+ // Silenced monsters only "speak" 1/3 as often as non-silenced,
+ // unless they're normally silent (S_SILENT). Use
+ // get_monster_data(monster->type) to bypass mon_shouts()
+ // replacing S_RANDOM with a random value.
+ if (silenced(monster->pos())
+ && get_monster_data(monster->type)->shouts != S_SILENT)
+ {
+ if (!one_chance_in(3))
+ return (false);
+ }
- // Silenced monsters only "speak" 1/3 as often as non-silenced,
- // unless they're normally silent (S_SILENT). Use
- // get_monster_data(monster->type) to bypass mon_shouts()
- // replacing S_RANDOM with a random value.
- if (silenced(monster->pos())
- && get_monster_data(monster->type)->shouts != S_SILENT)
- {
- if (!one_chance_in(3))
+ // Berserk monsters just want your hide.
+ if (monster->has_ench(ENCH_BERSERK))
return (false);
- }
-
- // Berserk monsters just want your hide.
- if (monster->has_ench(ENCH_BERSERK))
- return (false);
- // Monsters in a battle frenzy are likewise occupied.
- if (monster->has_ench(ENCH_BATTLE_FRENZY) && !one_chance_in(3))
- return (false);
+ // Monsters in a battle frenzy are likewise occupied.
+ if (monster->has_ench(ENCH_BATTLE_FRENZY) && !one_chance_in(3))
+ return (false);
- // Charmed monsters aren't too expressive.
- if (monster->has_ench(ENCH_CHARM) && !one_chance_in(3))
- return (false);
+ // Charmed monsters aren't too expressive.
+ if (monster->has_ench(ENCH_CHARM) && !one_chance_in(3))
+ return (false);
+ }
std::vector<std::string> prefixes;
if (mons_neutral(monster))
{
- if (coinflip()) // Neutrals speak half as often.
+ if (!force_speak && coinflip()) // Neutrals speak half as often.
return (false);
prefixes.push_back("neutral");