summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-16 18:58:08 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-16 18:58:08 +0000
commit67251d8f0ceb7cdd3c73fed911a5d47c279e494c (patch)
treefb70bb7363064ba358f06fc9f613d94b0459d6ce /crawl-ref
parent78a45dd9099c4340a9aec9d634d3ef91bab181ac (diff)
downloadcrawl-ref-67251d8f0ceb7cdd3c73fed911a5d47c279e494c.tar.gz
crawl-ref-67251d8f0ceb7cdd3c73fed911a5d47c279e494c.zip
Fix randart books being much too cheap. (Yes, this was actually a bug.)
A randart book's rarity is now defined as the average of its three rarest spells. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9101 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/effects.cc5
-rw-r--r--crawl-ref/source/shopping.cc28
2 files changed, 25 insertions, 8 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index f704f4243c..f13b2d70d1 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -1431,7 +1431,7 @@ static void _do_book_acquirement(item_def &book, int agent)
60, BOOK_RANDART_THEME,
agent == GOD_SIF_MUNA ? 24 : 34, book.sub_type,
level == -1 ? 0 :
- agent == GOD_SIF_MUNA ? 3 : 1, BOOK_RANDART_LEVEL,
+ agent == GOD_SIF_MUNA ? 4 : 1, BOOK_RANDART_LEVEL,
0);
}
@@ -1481,6 +1481,9 @@ static void _do_book_acquirement(item_def &book, int agent)
int w = (skill < 12) ? skill + 3
: 25 - skill;
+ if (w < 0)
+ w = 0;
+
// If we don't know any magic skills, make non-magic skills
// more likely.
if (!knows_magic && i < SK_SPELLCASTING)
diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc
index 3df185d1b6..61c5a41ca0 100644
--- a/crawl-ref/source/shopping.cc
+++ b/crawl-ref/source/shopping.cc
@@ -1666,26 +1666,40 @@ unsigned int item_value( item_def item, bool ident )
valued = 150;
if (item_type_known(item))
{
- int rarity = 0;
+ double rarity = 0;
if (is_random_artefact(item))
{
- // Consider spellbook as rare as its rarest spell.
- // NOTE: This probably undervalues a book if it contains
- // lots of rare spells.
+ // Consider spellbook as rare as the average of its
+ // three rarest spells.
+ int rarities[SPELLBOOK_SIZE];
+ int count_valid = 0;
for (int i = 0; i < SPELLBOOK_SIZE; i++)
{
spell_type spell = which_spell_in_book(item, i);
if (spell == SPELL_NO_SPELL)
+ {
+ rarities[i] = 0;
continue;
+ }
- if (rarity > spell_rarity(spell))
- rarity = spell_rarity(spell);
+ rarities[i] = spell_rarity(spell);
+ count_valid++;
}
+ ASSERT(count_valid > 0);
+
+ std::sort(rarities, rarities + SPELLBOOK_SIZE);
+ for (int i = SPELLBOOK_SIZE - 1; i >= SPELLBOOK_SIZE - 3; i--)
+ rarity += rarities[i];
+
+ if (count_valid > 3)
+ count_valid = 3;
+
+ rarity /= count_valid;
}
else
rarity = book_rarity(item.sub_type);
- valued += book_rarity(item.sub_type) * 50;
+ valued += rarity * 50;
}
break;