summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/dat/database/monspeak.txt2
-rw-r--r--crawl-ref/source/mon-abil.cc41
-rw-r--r--crawl-ref/source/monspeak.cc53
-rw-r--r--crawl-ref/source/monspeak.h1
4 files changed, 56 insertions, 41 deletions
diff --git a/crawl-ref/source/dat/database/monspeak.txt b/crawl-ref/source/dat/database/monspeak.txt
index e28a854cc9..a60da963d8 100644
--- a/crawl-ref/source/dat/database/monspeak.txt
+++ b/crawl-ref/source/dat/database/monspeak.txt
@@ -1351,7 +1351,7 @@ VISUAL:@The_monster@ counts something out on his fingers.
%%%%
_crazy_yiuf_speech_
-w:30
+w:300
@The_monster@ @_crazy_yiuf_speech_verbs_@, "@_crazy_yiuf_sentence_@"
VISUAL:@The_monster@ waves his quarterstaff at you. @player_only@
diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc
index 73d0547f6c..7067112d6e 100644
--- a/crawl-ref/source/mon-abil.cc
+++ b/crawl-ref/source/mon-abil.cc
@@ -1306,46 +1306,7 @@ void mon_nearby_ability(monsters *monster)
return;
}
-#define MON_SPEAK_CHANCE 21
-
- if (monster->is_patrolling() || mons_is_wandering(monster)
- || monster->attitude == ATT_NEUTRAL)
- {
- // Very fast wandering/patrolling monsters might, in one monster turn,
- // move into the player's LOS and then back out (or the player
- // might move into their LOS and the monster move back out before
- // the player's view has a chance to update) so prevent them
- // from speaking.
- ;
- }
- else if ((mons_class_flag(monster->type, M_SPEAKS)
- || !monster->mname.empty())
- && one_chance_in(MON_SPEAK_CHANCE))
- {
- mons_speaks(monster);
- }
- else if (get_mon_shape(monster) >= MON_SHAPE_QUADRUPED)
- {
- // Non-humanoid-ish monsters have a low chance of speaking
- // without the M_SPEAKS flag, to give the dungeon some
- // atmosphere/flavour.
- int chance = MON_SPEAK_CHANCE * 4;
-
- // Band members are a lot less likely to speak, since there's
- // a lot of them.
- if (testbits(monster->flags, MF_BAND_MEMBER))
- chance *= 10;
-
- // However, confused and fleeing monsters are more interesting.
- if (mons_is_fleeing(monster))
- chance /= 2;
- if (monster->has_ench(ENCH_CONFUSION))
- chance /= 2;
-
- if (one_chance_in(chance))
- mons_speaks(monster);
- }
- // Okay then, don't speak.
+ maybe_mons_speaks(monster);
if (monster_can_submerge(monster, grd(monster->pos()))
&& !monster->caught() // No submerging while caught.
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc
index 8f66ebb025..1d9650bbca 100644
--- a/crawl-ref/source/monspeak.cc
+++ b/crawl-ref/source/monspeak.cc
@@ -355,6 +355,59 @@ static bool _polyd_can_speak(const monsters* 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)
+{
+#define MON_SPEAK_CHANCE 21
+
+ if (monster->is_patrolling() || mons_is_wandering(monster)
+ || monster->attitude == ATT_NEUTRAL)
+ {
+ // Very fast wandering/patrolling monsters might, in one monster turn,
+ // move into the player's LOS and then back out (or the player
+ // might move into their LOS and the monster move back out before
+ // the player's view has a chance to update) so prevent them
+ // from speaking.
+ ;
+ }
+ else if ((mons_class_flag(monster->type, M_SPEAKS)
+ || !monster->mname.empty())
+ && one_chance_in(MON_SPEAK_CHANCE))
+ {
+ mons_speaks(monster);
+ }
+ else if (monster->type == MONS_CRAZY_YIUF
+ && one_chance_in(MON_SPEAK_CHANCE / 3))
+ {
+ // Yiuf gets an extra chance to speak!
+ mons_speaks(monster);
+ }
+ else if (get_mon_shape(monster) >= MON_SHAPE_QUADRUPED)
+ {
+ // Non-humanoid-ish monsters have a low chance of speaking
+ // without the M_SPEAKS flag, to give the dungeon some
+ // atmosphere/flavour.
+ int chance = MON_SPEAK_CHANCE * 4;
+
+ // Band members are a lot less likely to speak, since there's
+ // a lot of them.
+ if (testbits(monster->flags, MF_BAND_MEMBER))
+ chance *= 10;
+
+ // However, confused and fleeing monsters are more interesting.
+ if (mons_is_fleeing(monster))
+ chance /= 2;
+ if (monster->has_ench(ENCH_CONFUSION))
+ chance /= 2;
+
+ if (one_chance_in(chance))
+ mons_speaks(monster);
+ }
+ // Okay then, don't speak.
+}
+
+
// Returns true if something is said.
bool mons_speaks(monsters *monster)
{
diff --git a/crawl-ref/source/monspeak.h b/crawl-ref/source/monspeak.h
index 674aaa1257..9191cebce2 100644
--- a/crawl-ref/source/monspeak.h
+++ b/crawl-ref/source/monspeak.h
@@ -8,6 +8,7 @@
#include "externs.h"
+void maybe_mons_speaks(monsters *monster);
bool mons_speaks(monsters *monster);
bool mons_speaks_msg(monsters *monster, const std::string &msg,
const msg_channel_type def_chan = MSGCH_TALK,