diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-11 13:50:07 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-11 13:50:07 +0000 |
commit | d90612ecda4f3088e903280024b9aaf6a8279b8f (patch) | |
tree | a47f2bf9bf939818f595e4b268e2af095eb19dce /crawl-ref/source | |
parent | 6b7d71f720060c2023960aa7ab716063630d8332 (diff) | |
download | crawl-ref-d90612ecda4f3088e903280024b9aaf6a8279b8f.tar.gz crawl-ref-d90612ecda4f3088e903280024b9aaf6a8279b8f.zip |
Extend on Haran's monster resistance description. Thanks, Haran! :)
Now lists:
* all resistances on one line, sorted by resistance level.
* susceptibility
* magic immunity
* see/sense invisible
* monster speed
* flying/levitating
An example output:
A fire vortex
A swirling cloud of flame.
It is extremely resistant to fire, very resistant to electricity, and
resistant to poison.
It is susceptible to cold.
It is immune to magical enchantments.
It is fast.
It can levitate.
I also removed all those symbol/quote/etc. checks from the database
lookup. Instead describe_monster() is now called directly, so the
descriptions are now identical when (v)iewing a monster and when
searching the database.
In other news, I removed Eringya's Surprising Bouquet since I doubt
we'll ever get it implemented, disagree balance-wise, and it was
shamelessly nicked from Pratchett in the first place.
Breaks saves.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8411 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/acr.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/command.cc | 39 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 209 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 31 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/spl-data.h | 13 |
6 files changed, 233 insertions, 63 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index ca79d35a62..759985b68a 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -4636,7 +4636,7 @@ static void _compile_time_asserts() COMPILE_CHECK(SP_VAMPIRE == 33 , c3); COMPILE_CHECK(SPELL_BOLT_OF_MAGMA == 19 , c4); COMPILE_CHECK(SPELL_POISON_ARROW == 94 , c5); - COMPILE_CHECK(SPELL_SUMMON_MUSHROOMS == 223 , c6); + COMPILE_CHECK(NUM_SPELLS == 229 , c6); //jmf: NEW ASSERTS: we ought to do a *lot* of these COMPILE_CHECK(NUM_JOBS < JOB_UNKNOWN , c7); diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index e44ff784d6..a5c4389f2e 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -1292,12 +1292,11 @@ static bool _do_description(std::string key, std::string type, monster_type mon_num = get_monster_by_name(key, true); if (mon_num != MONS_PROGRAM_BUG) { + monsters mon; + mon.type = mon_num; + if (mons_genus(mon_num) == MONS_DRACONIAN) { - monsters mon; - - mon.type = mon_num; - switch (mon_num) { case MONS_BLACK_DRACONIAN: @@ -1314,29 +1313,13 @@ static bool _do_description(std::string key, std::string type, mon.base_monster = MONS_PROGRAM_BUG; break; } - - const monsters m = mon; - describe_monsters(m); - return (false); } + else + mon.base_monster = MONS_PROGRAM_BUG; - std::string symbol = ""; - symbol += get_monster_data(mon_num)->showchar; - if (isupper(symbol[0])) - symbol = "cap-" + symbol; - - std::string symbol_prefix = "__"; - symbol_prefix += symbol; - symbol_prefix += "_prefix"; - prefix = getLongDescription(symbol_prefix); - quote += getQuoteString(symbol_prefix); - - std::string symbol_suffix = "__"; - symbol_suffix += symbol; - symbol_suffix += "_suffix"; - suffix += getLongDescription(symbol_suffix); - suffix += getLongDescription(symbol_suffix + "_lookup"); - quote += getQuoteString(symbol_suffix); + const monsters m = mon; + describe_monsters(m); + return (false); } else { @@ -1642,11 +1625,7 @@ static bool _find_description(bool &again, std::string& error_inout) footer += regex; footer += "'. To see non-exact matches, press space."; - if (!_do_description(regex, type, footer)) - { - DEBUGSTR("do_description() returned false for exact_match"); - return (false); - } + _do_description(regex, type, footer); if (getch() != ' ') return (false); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index b725f8b10f..10d097170e 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -2590,6 +2590,205 @@ static std::string _describe_draconian(const monsters *mon) return (description); } +static const char* _get_resist_name(mon_resist_flags res_type) +{ + switch (res_type) + { + case MR_RES_ELEC: + return "electricity"; + case MR_RES_POISON: + return "poison"; + case MR_RES_FIRE: + return "fire"; + case MR_RES_STEAM: + return "steam"; + case MR_RES_COLD: + return "cold"; + case MR_RES_ACID: + return "acid"; + default: + return "buggy resistance"; + } +} + +static int _get_resist_level(const mon_resist_def resist, + mon_resist_flags res_type) +{ + switch (res_type) + { + case MR_RES_ELEC: + return resist.elec; + case MR_RES_POISON: + return resist.poison; + case MR_RES_FIRE: + return resist.fire; + case MR_RES_STEAM: + return resist.steam; + case MR_RES_COLD: + return resist.cold; + case MR_RES_ACID: + return resist.acid; + default: + return (0); + } +} + +// Describe a monster's (intrinsic) resistances, speed and a few other +// attributes. +static std::string _monster_stat_description(const monsters& mon) +{ + const char* modifiers[] = { + "susceptible", // -1 + "resistant", // +1 + "very resistant", // +2 + "extremely resistant" // +3 + }; + + const mon_resist_def resist = get_mons_resists(&mon); + std::vector<mon_resist_flags> resists; + resists.push_back(MR_RES_ELEC); + resists.push_back(MR_RES_POISON); + resists.push_back(MR_RES_FIRE); + resists.push_back(MR_RES_STEAM); + resists.push_back(MR_RES_COLD); + resists.push_back(MR_RES_ACID); + + std::vector<std::string> extreme_resists; + std::vector<std::string> high_resists; + std::vector<std::string> base_resists; + std::vector<std::string> suscept; + for (unsigned int i = 0; i < resists.size(); ++i) + { + int level = _get_resist_level(resist, resists[i]); + const char* attackname = _get_resist_name(resists[i]); + if (level != 0) + { + const int offset = (level < 0) ? 0 : std::min(level, 3); + switch (offset) + { + case 0: + suscept.push_back(attackname); + break; + case 1: + base_resists.push_back(attackname); + break; + case 2: + high_resists.push_back(attackname); + break; + case 3: + extreme_resists.push_back(attackname); + break; + } + } + } + + std::string result = ""; + const char* pronoun = mons_pronoun(static_cast<monster_type>(mon.type), + PRONOUN_CAP, true); + + std::vector<std::string> all_resists; + if (!extreme_resists.empty()) + { + result = modifiers[3]; + result += " to "; + result += comma_separated_line(extreme_resists.begin(), + extreme_resists.end(), + " and ", ", "); + all_resists.push_back(result); + } + if (!high_resists.empty()) + { + result = modifiers[2]; + result += " to "; + result += comma_separated_line(high_resists.begin(), + high_resists.end(), + " and ", ", "); + all_resists.push_back(result); + } + if (!base_resists.empty()) + { + result = modifiers[1]; + result += " to "; + result += comma_separated_line(base_resists.begin(), + base_resists.end(), + " and ", ", "); + all_resists.push_back(result); + } + if (!all_resists.empty()) + { + result = pronoun; + result += " is "; + result += comma_separated_line(all_resists.begin(), + all_resists.end(), + ", and ", ", "); + result += ".$"; + } + + // Is monster susceptible to anything? (On a new line.) + if (!suscept.empty()) + { + result += pronoun; + result += " is "; + result += modifiers[0]; + result += " to "; + result += comma_separated_line(suscept.begin(), + suscept.end(), + " and ", ", "); + result += ".$"; + } + + // Magic resistance at MAG_IMMUNE. + if (mons_immune_magic(&mon)) + { + result += pronoun; + result += " is immune to magical enchantments.$"; + } + + // Seeing/sensing invisible. + if (mons_class_flag(mon.type, M_SEE_INVIS)) + { + result += pronoun; + result += " can see invisible.$"; + } + else if (mons_class_flag(mon.type, M_SENSE_INVIS)) + { + result += pronoun; + result += " can sense the presence of invisible creatures.$"; + } + + // Unusual monster speed. + const int speed = mons_speed(mon.type); + if (speed < 10 || speed > 10) + { + result += pronoun; + result += " is "; + if (speed < 7) + result += "very slow"; + else if (speed < 10) + result += "slow"; + else if (speed > 20) + result += "extremely fast"; + else if (speed > 15) + result += "very fast"; + else if (speed > 10) + result += "fast"; + result += ".$"; + } + + // Can the monster fly/levitate? + const flight_type fly = mons_class_flies(mon.type); + if (fly != FL_NONE) + { + result += pronoun; + result += " can "; + result += (fly == FL_FLY ? "fly" : "levitate"); + result += ".$"; + } + + return result; +} + +/* // Return a string of the form "She is resistant to fire." static std::string _resistance_description(const char* pronoun, int level, const char* attackname) @@ -2621,6 +2820,7 @@ 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"); @@ -2631,7 +2831,8 @@ static std::string _monster_resists_string(const monsters& mon) result += _resistance_description(pronoun, resist.acid, "acid"); return result; } - +*/ + //--------------------------------------------------------------- // // describe_monsters @@ -2773,7 +2974,11 @@ void describe_monsters(const monsters& mons) // 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); + { + std::string result = _monster_stat_description(mons); + if (!result.empty()) + body << "$" << result; + } if (!mons_can_use_stairs(&mons)) { diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 7b8325b0ae..59ae2824c9 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2790,50 +2790,49 @@ enum spell_type SPELL_BEND, SPELL_BACKLIGHT, SPELL_INTOXICATE, // confusion but only "smart" creatures - SPELL_EVAPORATE, // turn a potion into a cloud 190 - SPELL_ERINGYAS_SURPRISING_BOUQUET, // turn sticks into herbivore food + SPELL_EVAPORATE, // 190, turn a potion into a cloud SPELL_FRAGMENTATION, // replacement for "orb of frag" SPELL_AIR_WALK, // "dematerialise" (air/transmigration) SPELL_SANDBLAST, // mini-frag; can use stones for material comp SPELL_ROTTING, // evil god power or necromantic transmigration - SPELL_MAXWELLS_SILVER_HAMMER, // vorpal-brand maces etc. + SPELL_MAXWELLS_SILVER_HAMMER, // 195, vorpal-brand maces etc. SPELL_CONDENSATION_SHIELD, // "shield" of icy vapour SPELL_SEMI_CONTROLLED_BLINK, //jmf: to test effect SPELL_STONESKIN, - SPELL_SIMULACRUM, // 200 - SPELL_CONJURE_BALL_LIGHTNING, + SPELL_SIMULACRUM, + SPELL_CONJURE_BALL_LIGHTNING, // 200 SPELL_CHAIN_LIGHTNING, SPELL_EXCRUCIATING_WOUNDS, SPELL_PORTAL_PROJECTILE, - SPELL_SUMMON_UGLY_THING, // 205 - SPELL_PETRIFY, + SPELL_SUMMON_UGLY_THING, + SPELL_PETRIFY, // 205 // Mostly monster-only spells after this point: SPELL_HELLFIRE_BURST, SPELL_VAMPIRE_SUMMON, SPELL_BRAIN_FEED, - SPELL_FAKE_RAKSHASA_SUMMON, // 210 - SPELL_STEAM_BALL, + SPELL_FAKE_RAKSHASA_SUMMON, + SPELL_STEAM_BALL, // 210 SPELL_SUMMON_UFETUBUS, SPELL_SUMMON_BEAST, SPELL_ENERGY_BOLT, - SPELL_POISON_SPLASH, // 215 - SPELL_SUMMON_UNDEAD, + SPELL_POISON_SPLASH, + SPELL_SUMMON_UNDEAD, // 215 SPELL_CANTRIP, SPELL_QUICKSILVER_BOLT, SPELL_METAL_SPLINTERS, - SPELL_MIASMA, // 220 - SPELL_SUMMON_DRAKES, + SPELL_MIASMA, + SPELL_SUMMON_DRAKES, // 220 SPELL_BLINK_OTHER, SPELL_SUMMON_MUSHROOMS, SPELL_ACID_SPLASH, - SPELL_STICKY_FLAME_SPLASH, // 225 - SPELL_FIRE_BREATH, + SPELL_STICKY_FLAME_SPLASH, + SPELL_FIRE_BREATH, // 225 SPELL_COLD_BREATH, SPELL_DRACONIAN_BREATH, SPELL_WATER_ELEMENTALS, - NUM_SPELLS + NUM_SPELLS // 229 }; enum slot_select_mode diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index 09a6df8809..574436b063 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -487,7 +487,7 @@ static spell_type spellbook_template_array[][SPELLBOOK_SIZE] = SPELL_BLINK, SPELL_LEVITATION, SPELL_INTOXICATE, - SPELL_NO_SPELL, //jmf: SPELL_ERINGYAS_SURPRISING_BOUQUET, when finished + SPELL_NO_SPELL, SPELL_NO_SPELL, }, diff --git a/crawl-ref/source/spl-data.h b/crawl-ref/source/spl-data.h index abf5eb8dd0..ae668b289f 100644 --- a/crawl-ref/source/spl-data.h +++ b/crawl-ref/source/spl-data.h @@ -2423,19 +2423,6 @@ }, { - SPELL_ERINGYAS_SURPRISING_BOUQUET, "Eringya's Surprising Bouquet", - SPTYP_TRANSMIGRATION | SPTYP_EARTH, - SPFLAG_NONE, - 4, - 0, - -1, -1, - 0, - NULL, - false, - false -}, - -{ SPELL_FRAGMENTATION, "Lee's Rapid Deconstruction", SPTYP_TRANSMIGRATION | SPTYP_EARTH, SPFLAG_GRID, |