summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-book.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-15 19:34:39 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-15 19:34:39 +0000
commite4209979f264bb890bd22269e752cbde2ed0d58c (patch)
tree25ba88a058aa13bbbd3fc050abee9cdb875264cc /crawl-ref/source/spl-book.cc
parent1be0369055dab6a8c64b35b083dd4ef58b411b2c (diff)
downloadcrawl-ref-e4209979f264bb890bd22269e752cbde2ed0d58c.tar.gz
crawl-ref-e4209979f264bb890bd22269e752cbde2ed0d58c.zip
Overhaul book acquirement.
1. Do a skill check to decide on manual vs. spellbook (except for Xom and Sif Muna who never gift manuals). 2. If a spellbook, pick randart or normal books with fixed chances. 3. Make randart themes dependant on actual skills, not aptitudes. 4. For normal spellbooks, pick the book randomly with weights favouring books with many unknown spells of schools you're highly skilled in. (Bye-bye, fixed book acquirement order!) Formulas (as suggested by David) may need tweaking, feedback welcome! git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9093 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-book.cc')
-rw-r--r--crawl-ref/source/spl-book.cc57
1 files changed, 28 insertions, 29 deletions
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index 89905a420a..e771b0ce31 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1729,7 +1729,8 @@ bool is_memorised(spell_type spell)
static void _get_spell_list(std::vector<spell_type> &spell_list, int level,
unsigned int disc1, unsigned int disc2,
god_type god, bool avoid_uncastable,
- int &god_discard, int &uncastable_discard)
+ int &god_discard, int &uncastable_discard,
+ bool avoid_known = false)
{
for (int i = 0; i < NUM_SPELLS; i++)
{
@@ -1743,6 +1744,9 @@ static void _get_spell_list(std::vector<spell_type> &spell_list, int level,
if (spell_rarity(spell) == -1)
continue;
+ if (avoid_known && you.seen_spell[spell])
+ continue;
+
const unsigned int disciplines = get_spell_disciplines(spell);
if (level != -1)
{
@@ -1788,18 +1792,22 @@ static void _get_spell_list(std::vector<spell_type> &spell_list, int level,
static void _get_spell_list(std::vector<spell_type> &spell_list,
unsigned int disc1, unsigned int disc2,
god_type god, bool avoid_uncastable,
- int &god_discard, int &uncastable_discard)
+ int &god_discard, int &uncastable_discard,
+ bool avoid_known = false)
{
_get_spell_list(spell_list, -1, disc1, disc2,
- god, avoid_uncastable, god_discard, uncastable_discard);
+ god, avoid_uncastable, god_discard, uncastable_discard,
+ avoid_known);
}
static void _get_spell_list(std::vector<spell_type> &spell_list, int level,
god_type god, bool avoid_uncastable,
- int &god_discard, int &uncastable_discard)
+ int &god_discard, int &uncastable_discard,
+ bool avoid_known = false)
{
_get_spell_list(spell_list, level, SPTYP_NONE, SPTYP_NONE,
- god, avoid_uncastable, god_discard, uncastable_discard);
+ god, avoid_uncastable, god_discard, uncastable_discard,
+ avoid_known);
}
@@ -2050,9 +2058,9 @@ 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);
+ junk1, junk2, true);
- if(spell_list.empty())
+ if (spell_list.empty())
continue;
ok_discs.push_back(disc);
@@ -2070,48 +2078,39 @@ static bool _get_weighted_discs(bool completely_random, god_type god,
}
int skill_weights[SPTYP_LAST_EXPONENT];
- int apt_weights[SPTYP_LAST_EXPONENT];
memset(skill_weights, 0, SPTYP_LAST_EXPONENT * sizeof(int));
- memset(apt_weights, 0, SPTYP_LAST_EXPONENT * sizeof(int));
- if (completely_random)
- {
- for (int i = 0; i < num_discs; i++)
- {
- skill_weights[i] = 1;
- apt_weights[i] = 1;
- }
- }
- else
+ if (!completely_random)
{
int total_skills = 0;
for (int i = 0; i < num_discs; i++)
{
int skill = skills[i];
- skill_weights[i] = you.skills[skill];
-
- int apt = species_skills(skill, you.species);
- apt_weights[i] = (int) ( (1.0 / (double) apt) * 1000000.0);
+ skill_weights[i] = you.skills[skill]
+ * 100 / species_skills(skill, you.species);
total_skills += skill_weights[i];
}
if (total_skills == 0)
- {
- for (int i = 0; i < num_discs; i++)
- skill_weights[i] = apt_weights[i];
- }
+ completely_random = true;
+ }
+
+ if (completely_random)
+ {
+ for (int i = 0; i < num_discs; i++)
+ skill_weights[i] = 1;
}
do
{
disc1 = ok_discs[choose_random_weighted(skill_weights,
skill_weights + num_discs)];
- disc2 = ok_discs[choose_random_weighted(apt_weights,
- apt_weights + num_discs)];
+ disc2 = ok_discs[choose_random_weighted(skill_weights,
+ skill_weights + num_discs)];
}
- while(disciplines_conflict(disc1, disc2));
+ while (disciplines_conflict(disc1, disc2));
return (true);
}