diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-21 19:52:14 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-02-21 19:52:14 +0000 |
commit | 6fe9d2d6362915f3ab999971c87dd2f4d09e905f (patch) | |
tree | 3815ce19535e80e61c54ab53234616c885688d2a /crawl-ref/source/spl-book.cc | |
parent | 2846de53110f56c1732a3e9b2ab71b396af3c5a0 (diff) | |
download | crawl-ref-6fe9d2d6362915f3ab999971c87dd2f4d09e905f.tar.gz crawl-ref-6fe9d2d6362915f3ab999971c87dd2f4d09e905f.zip |
* Tweak spell number of randart books some more.
* Loosen restrictions on spell levels of unknown spells for normal books,
so there are more matches even for untrained schools.
* Add a new option dump_book_spells that, if set to true (default), will
dump the spells even for non-randart book. Useful if you don't know
the books' contents by heart and want to know spells at your disposal
without checking some spoilers.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9143 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-book.cc')
-rw-r--r-- | crawl-ref/source/spl-book.cc | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index 4f0ee38e99..21e71c5c65 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -1832,7 +1832,8 @@ bool make_book_level_randart(item_def &book, int level, int num_spells, if (level == -1) { int max_level = - completely_random ? 9 : std::min(9, you.get_experience_level()); + (completely_random ? 9 + : std::min(9, you.get_experience_level())); level = random_range(1, max_level); } @@ -1921,6 +1922,7 @@ bool make_book_level_randart(item_def &book, int level, int num_spells, std::vector<bool> spell_used(spell_list.size(), false); std::vector<bool> avoid_memorised(spell_list.size(), !completely_random); + std::vector<bool> avoid_seen(spell_list.size(), !completely_random); spell_type chosen_spells[SPELLBOOK_SIZE]; for (int i = 0; i < SPELLBOOK_SIZE; i++) @@ -1939,9 +1941,16 @@ bool make_book_level_randart(item_def &book, int level, int num_spells, if (avoid_memorised[spell_pos] && is_memorised(spell)) { - // Only once. - avoid_memorised[spell_pos] = false; - continue; + // Only once. + avoid_memorised[spell_pos] = false; + continue; + } + + if (avoid_seen[spell_pos] && you.seen_spell[spell] && coinflip()) + { + // Only once. + avoid_seen[spell_pos] = false; + continue; } spell_used[spell_pos] = true; @@ -2049,6 +2058,7 @@ static bool _get_weighted_discs(bool completely_random, god_type god, // spells are discarded. std::vector<int> ok_discs; std::vector<int> skills; + std::vector<int> spellcount; for (int i = 0; i < SPTYP_LAST_EXPONENT; i++) { int disc = 1 << i; @@ -2058,13 +2068,14 @@ static bool _get_weighted_discs(bool completely_random, god_type god, std::vector<spell_type> spell_list; _get_spell_list(spell_list, disc, disc, god, !completely_random, - junk1, junk2, true); + junk1, junk2, !completely_random); if (spell_list.empty()) continue; ok_discs.push_back(disc); skills.push_back(spell_type2skill(disc)); + spellcount.push_back(spell_list.size()); } int num_discs = ok_discs.size(); @@ -2086,10 +2097,14 @@ static bool _get_weighted_discs(bool completely_random, god_type god, int total_skills = 0; for (int i = 0; i < num_discs; i++) { - int skill = skills[i]; - skill_weights[i] = you.skills[skill] - * 100 / species_skills(skill, you.species); + int skill = skills[i]; + int weight = you.skills[skill] + * 200 / species_skills(skill, you.species) + 1; + + if (spellcount[i] < 5) + weight -= 5 - spellcount[i]; + skill_weights[i] = std::max(0, weight); total_skills += skill_weights[i]; } @@ -2478,7 +2493,7 @@ bool make_book_theme_randart(item_def &book, int disc1, int disc2, else if (god_gift && one_chance_in(3) || one_chance_in(5)) { bool highlevel = (highest_level >= 7 + random2(3) - && lowest_level > 1); + && (lowest_level > 1 || coinflip())); if (disc1 != disc2) { |