diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-09-16 16:44:48 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-09-16 16:44:48 +0000 |
commit | 9d74ad5fb0661a0fc2ac424adcbed85761954d25 (patch) | |
tree | 368af85251f5cfc610f25d3e3fa7e1088e5bd4aa /crawl-ref/source/monspeak.cc | |
parent | 9505de56091b195cb5d33ef88dcf9cfcc724cc89 (diff) | |
download | crawl-ref-9d74ad5fb0661a0fc2ac424adcbed85761954d25.tar.gz crawl-ref-9d74ad5fb0661a0fc2ac424adcbed85761954d25.zip |
Yet another change to monster speech and silencing...
I found my previous change to block all messages passed
through MSGCH_TALK when silenced was too restrictive, so
I've added another channel MSGCH_TALK_VISUAL and adapted the
monster speech files accordingly. For example, imps can now
also "talk" when silenced, but only the visual stuff will
actually be output. (This automatically takes care of
lowering the output likelihood.) And no, this doesn't hurt
any, as visual talk also won't interrupt travel or resting.
And I added a how-to file on monster speech, which was the
main reason for my silence during the last couple of hours.
It's not that the database system is that complicated but it
surely can't hurt to give players who want to add something
an idea of what is possible and how to go about it.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2108 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monspeak.cc')
-rw-r--r-- | crawl-ref/source/monspeak.cc | 79 |
1 files changed, 54 insertions, 25 deletions
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc index 04da8f22fe..f1230a6fbd 100644 --- a/crawl-ref/source/monspeak.cc +++ b/crawl-ref/source/monspeak.cc @@ -42,21 +42,30 @@ static std::string get_speak_string(const std::vector<std::string> prefixes, const std::string key, - const monsters *monster) + const monsters *monster, + bool ignore_silenced = false) { std::string prefix = ""; + bool silenced = false; const int size = prefixes.size(); for (int i = 0; i < size; i++) { + if (prefixes[i] == "silenced") + { + if (ignore_silenced) + continue; + silenced = true; + } prefix += prefixes[i]; prefix += " "; } std::string msg = ""; + // try string of all prefixes msg = getSpeakString(prefix + key); if (msg != "") return msg; - + // Combinations of prefixes by threes if (size >= 3) { @@ -105,6 +114,10 @@ static std::string get_speak_string(const std::vector<std::string> prefixes, // No prefixes msg = getSpeakString("default " + key); + // try the same ignoring silence + if (msg == "" && silenced) + return get_speak_string(prefixes, key, monster, true); + return msg; } @@ -150,18 +163,23 @@ bool mons_speaks(const monsters *monster) // *is* silenced, and is hence able to see the monsters' gestures // and such but not hear any sounds it makes, would be a big // headache to deal with, so skip it. + + // [jpeg] Why? Only print visible stuff! :p +/* if (!silenced(monster->x, monster->y) && silenced(you.x_pos, you.y_pos)) 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->x, monster->y) && get_monster_data(monster->type)->shouts != S_SILENT) + { if (!one_chance_in(3)) return false; + } // charmed monsters aren't too expressive if (monster->has_ench(ENCH_CHARM)) @@ -178,8 +196,12 @@ bool mons_speaks(const monsters *monster) if (monster->behaviour == BEH_FLEE) prefixes.push_back("fleeing"); + bool silence = silenced(you.x_pos, you.y_pos); if (silenced(monster->x, monster->y)) + { + silence = true; prefixes.push_back("silenced"); + } if (monster->has_ench(ENCH_CONFUSION)) prefixes.push_back("confused"); @@ -327,47 +349,37 @@ bool mons_speaks(const monsters *monster) for (int i = 0, size = lines.size(); i < size; i++) { std::string line = lines[i]; - - if (line == "__YOU_RESIST") - { - canned_msg( MSG_YOU_RESIST ); - continue; - } - else if (line == "__NOTHING_HAPPENS") - { - canned_msg( MSG_NOTHING_HAPPENS ); - continue; - } - else if (line == "__MORE") - { - more(); - continue; - } - + // This function is a little bit of a problem for the message // channels since some of the messages it generates are "fake" // warning to scare the player. In order to accomidate this // intent, we're falsely categorizing various things in the // function as spells and danger warning... everything else // just goes into the talk channel -- bwr + // [jpeg] Added MSGCH_TALK_VISUAL for silent "chatter" msg_channel_type msg_type = MSGCH_TALK; + std::string param = ""; std::string::size_type pos = line.find(":"); if (pos != std::string::npos) + param = line.substr(0, pos); + + if (!param.empty()) { - std::string param = line.substr(0, pos); - bool match = true; + bool match = true; if (param == "DANGER") msg_type = MSGCH_DANGER; - else if (param == "WARN") + else if (param == "WARN" && !silence || param == "VISUAL WARN") msg_type = MSGCH_WARN; else if (param == "SOUND") msg_type = MSGCH_SOUND; - else if (param == "SPELL") + else if (param == "VISUAL") + msg_type = MSGCH_TALK_VISUAL; + else if (param == "SPELL" && !silence || param == "VISUAL SPELL") msg_type = MSGCH_MONSTER_SPELL; - else if (param == "ENCHANT") + else if (param == "ENCHANT" && !silence || param == "VISUAL ENCHANT") msg_type = MSGCH_MONSTER_ENCHANT; else if (param == "PLAIN") msg_type = MSGCH_PLAIN; @@ -378,6 +390,23 @@ bool mons_speaks(const monsters *monster) line = line.substr(pos + 1); } + // except for VISUAL none of the above influence these + if (line == "__YOU_RESIST" && (!silence || param == "VISUAL")) + { + canned_msg( MSG_YOU_RESIST ); + continue; + } + else if (line == "__NOTHING_HAPPENS" && (!silence || param == "VISUAL")) + { + canned_msg( MSG_NOTHING_HAPPENS ); + continue; + } + else if (line == "__MORE" && (!silence || param == "VISUAL")) + { + more(); + continue; + } + mpr(line.c_str(), msg_type); } |