From 537160d9714e4783ed07c2edbbd85a88d3e51f69 Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 10 Jan 2009 22:10:44 +0000 Subject: 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 --- crawl-ref/source/describe.cc | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'crawl-ref/source/describe.cc') 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(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(mons.type), -- cgit v1.2.3-54-g00ecf