From a515e3fef2cb3582e90959c15f89d4d25043cb67 Mon Sep 17 00:00:00 2001 From: Johanna Ploog Date: Fri, 18 Dec 2009 16:48:40 +0100 Subject: Skills unusable with your current god are less likely in manual acquirement. --- crawl-ref/source/effects.cc | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'crawl-ref/source/effects.cc') diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 4cf1a5860b..1c98e6e611 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1762,6 +1762,30 @@ static int _book_weight(book_type book) return (total_weight); } +static bool _is_magic_skill(int skill) +{ + return (skill >= SK_SPELLCASTING && skill < SK_INVOCATIONS); +} + +static bool _skill_useless_with_god(int skill) +{ + switch (you.religion) + { + case GOD_TROG: + return (_is_magic_skill(skill) || skill == SK_INVOCATIONS); + case GOD_ZIN: + case GOD_SHINING_ONE: + case GOD_ELYVILON: + case GOD_FEDHAS: + return (skill == SK_NECROMANCY); + case GOD_XOM: + case GOD_NEMELEX_XOBEH: + return (skill == SK_INVOCATIONS); + default: + return (false); + } +} + static bool _do_book_acquirement(item_def &book, int agent) { // items() shouldn't make book a randart for acquirement items. @@ -1813,7 +1837,7 @@ static bool _do_book_acquirement(item_def &book, int agent) if (i == SK_SPELLCASTING && weight >= 1) weight--; - if (i >= SK_SPELLCASTING && i <= SK_POISON_MAGIC) + if (_is_magic_skill(i)) magic_weights += weight; else other_weights += weight; @@ -1928,9 +1952,14 @@ static bool _do_book_acquirement(item_def &book, int agent) w += 5; } + // Greatly reduce the chances of getting a manual for a skill + // you couldn't use unless you switched your religion. + if (_skill_useless_with_god(i)) + w /= 2; + // If we don't have any magic skills, make non-magic skills // more likely. - if (!knows_magic && (i < SK_SPELLCASTING || i > SK_POISON_MAGIC)) + if (!knows_magic && !_is_magic_skill(i)) w *= 2; weights[i] = w; @@ -1946,8 +1975,8 @@ static bool _do_book_acquirement(item_def &book, int agent) // Set number of reads possible before it "crumbles to dust". book.plus2 = 3 + random2(15); break; - } - } + } // manuals + } // switch book choice return (true); } -- cgit v1.2.3-54-g00ecf