From d90a2c7adcc5b54144b0a4136c7bcc6939d18900 Mon Sep 17 00:00:00 2001 From: dolorous Date: Wed, 16 Apr 2008 18:15:47 +0000 Subject: Fix TSO's artefact weapon blessing. A blessed weapon will now be marked as a gift from him, gifts from him will always be of holy wrath and never poisoned, and make_item_randart() will now check for appropriateness of god gifts. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4262 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/randart.cc | 46 ++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'crawl-ref/source/randart.cc') diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc index 57927f6863..8d9ceb8f42 100644 --- a/crawl-ref/source/randart.cc +++ b/crawl-ref/source/randart.cc @@ -59,7 +59,7 @@ static bool god_fits_artefact(const god_type which_god, const item_def &item) { case GOD_BEOGH: if (brand == SPWPN_ORC_SLAYING) - return (false); + return (false); // goes against orcish theme break; case GOD_ELYVILON: // peaceful healer god, no weapons, no berserking @@ -89,6 +89,14 @@ static bool god_fits_artefact(const god_type which_god, const item_def &item) return (false); // goes against anti-mutagenic theme break; + case GOD_SHINING_ONE: + if (brand == SPWPN_VENOM) + return (false); // goes against anti-poison theme + + if (brand != SPWPN_HOLY_WRATH) + return (false); // goes against holiness theme + break; + case GOD_SIF_MUNA: case GOD_KIKUBAAQUDGHA: case GOD_VEHUMET: @@ -116,13 +124,11 @@ static bool god_fits_artefact(const god_type which_god, const item_def &item) return (true); } -static std::string replace_name_parts(const std::string name_in, - const item_def item) +static god_type gift_from_god(const item_def item) { - std::string name = name_in; - // maybe god gift? god_type god_gift = GOD_NO_GOD; + if (item.orig_monnum < 0) { int help = -item.orig_monnum - 2; @@ -130,6 +136,16 @@ static std::string replace_name_parts(const std::string name_in, god_gift = static_cast(help); } + return god_gift; +} + +static std::string replace_name_parts(const std::string name_in, + const item_def item) +{ + std::string name = name_in; + + god_type god_gift = gift_from_god(item); + // Don't allow "player's Death" type names for god gifts (except Xom!) if (god_gift != GOD_NO_GOD && god_gift != GOD_XOM && name.find("@player_name@'s", 0) != std::string::npos @@ -1238,13 +1254,7 @@ std::string randart_name( const item_def &item ) { result += item_base_name(item) + " "; - std::string name; - - // special case for blessed artefact weapons, since they're unique - if (is_blessed(item)) - name = "of @player_name@"; - else - name = getRandNameString(lookup); + std::string name = getRandNameString(lookup); if (name.empty() && god_gift) // if nothing found, try god name alone { @@ -1277,6 +1287,13 @@ std::string randart_name( const item_def &item ) } } + if (is_blessed(item) && god_gift) + { + result = item_base_name(item) + " "; + std::string name = "of @player_name@"; + result += replace_name_parts(name, item); + } + return result; } @@ -1676,11 +1693,14 @@ bool make_item_randart( item_def &item ) item.flags |= ISFLAG_RANDART; + god_type god_gift = gift_from_god(item); + do { item.special = (random_int() & RANDART_SEED_MASK); } - while (randart_is_bad( item )); + while (randart_is_bad(item) + || (god_gift != GOD_NO_GOD && !god_fits_artefact(god_gift, item))); return (true); } -- cgit v1.2.3-54-g00ecf