summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/describe.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-10 22:10:44 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-10 22:10:44 +0000
commit537160d9714e4783ed07c2edbbd85a88d3e51f69 (patch)
tree6dae3f276bb407e647657a1d34fb0d408fc1e879 /crawl-ref/source/describe.cc
parent6e22dc58cfb63a6618d7c92d36a1a7e034e89f44 (diff)
downloadcrawl-ref-537160d9714e4783ed07c2edbbd85a88d3e51f69.tar.gz
crawl-ref-537160d9714e4783ed07c2edbbd85a88d3e51f69.zip
Display basic resistance information. I'm putting this in so that
there'll be a base to work on; of course the format can (and should) be improved. Currently it's one line per resistance. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8396 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/describe.cc')
-rw-r--r--crawl-ref/source/describe.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index fbb6e7c39f..b725f8b10f 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -2590,6 +2590,48 @@ static std::string _describe_draconian(const monsters *mon)
return (description);
}
+// Return a string of the form "She is resistant to fire."
+static std::string _resistance_description(const char* pronoun,
+ int level, const char* attackname)
+{
+ const char* modifiers[] = {
+ "susceptible", // -1
+ "resistant", // +1
+ "very resistant", // +2
+ "extremely resistant" // +3
+ };
+ std::string result;
+
+ if (level != 0)
+ {
+ const int offset = (level < 0) ? 0 : std::min(level, 3);
+
+ result = pronoun;
+ result += " is ";
+ result += modifiers[offset];
+ result += " to ";
+ result += attackname;
+ result += ".$";
+ }
+ return result;
+}
+
+static std::string _monster_resists_string(const monsters& mon)
+{
+ const mon_resist_def resist = get_mons_resists(&mon);
+ const char* pronoun = mons_pronoun(static_cast<monster_type>(mon.type),
+ PRONOUN_CAP, true);
+ std::string result;
+ // Not shown: hellfire, asphyxiation, sticky flames.
+ result += _resistance_description(pronoun, resist.elec, "electricity");
+ result += _resistance_description(pronoun, resist.poison, "poison");
+ result += _resistance_description(pronoun, resist.fire, "fire");
+ result += _resistance_description(pronoun, resist.steam, "steam");
+ result += _resistance_description(pronoun, resist.cold, "cold");
+ result += _resistance_description(pronoun, resist.acid, "acid");
+ return result;
+}
+
//---------------------------------------------------------------
//
// describe_monsters
@@ -2729,6 +2771,10 @@ void describe_monsters(const monsters& mons)
break;
}
+ // Don't leak or duplicate resistance information for ghosts/demons.
+ if (mons.type != MONS_PANDEMONIUM_DEMON && mons.type != MONS_PLAYER_GHOST)
+ body << _monster_resists_string(mons);
+
if (!mons_can_use_stairs(&mons))
{
body << "$" << mons_pronoun(static_cast<monster_type>(mons.type),