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 | |
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')
-rw-r--r-- | crawl-ref/source/chardump.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/effects.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/makeitem.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/skills.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/skills2.cc | 32 | ||||
-rw-r--r-- | crawl-ref/source/skills2.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.cc | 33 |
11 files changed, 67 insertions, 49 deletions
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index 20f0e392e3..0eeacc8e8d 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -804,7 +804,9 @@ static void _sdump_inventory(dump_params &par) text += "\n" " (" + origin_desc(you.inv[j]) + ")"; } - if (is_dumpable_artefact( you.inv[j], false )) + if (is_dumpable_artefact( you.inv[j], false ) + || Options.dump_book_spells + && you.inv[j].base_type == OBJ_BOOKS) { text2 = get_item_description( you.inv[j], false, @@ -822,7 +824,7 @@ static void _sdump_inventory(dump_params &par) } } text += "\n\n"; -} // end dump_inventory() +} //--------------------------------------------------------------- // diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 77dadd1052..ae143cd563 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -204,7 +204,7 @@ static int _debug_prompt_for_skill( const char *prompt ) for (int i = 0; i < NUM_SKILLS; i++) { // Avoid the bad values. - if (i == SK_UNUSED_1 || (i > SK_UNARMED_COMBAT && i < SK_SPELLCASTING)) + if (is_invalid_skill(i)) continue; char sk_name[80]; @@ -3711,11 +3711,8 @@ void wizard_set_all_skills(void) for (i = SK_FIGHTING; i < NUM_SKILLS; i++) { - if (i == SK_UNUSED_1 - || (i > SK_UNARMED_COMBAT && i < SK_SPELLCASTING)) - { + if (is_invalid_skill(i)) continue; - } const int points = (skill_exp_needed( amount ) * species_skills( i, you.species )) / 100; diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 197de44d75..6147b21e21 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -1632,7 +1632,7 @@ void append_spells(std::string &desc, const item_def &item) desc += "$$Spells Type Level$"; - for (int j = 0; j < 8; j++) + for (int j = 0; j < SPELLBOOK_SIZE; j++) { spell_type stype = which_spell_in_book(item, j); if (stype == SPELL_NO_SPELL) @@ -1861,8 +1861,11 @@ std::string get_item_description( const item_def &item, bool verbose, description << "$This book is beyond your current level of " "understanding."; } - else if (!verbose && is_random_artefact( item )) + else if (!verbose + && (Options.dump_book_spells || is_random_artefact(item))) { + mprf("book: %s, option: %s", item.name(DESC_PLAIN).c_str(), + Options.dump_book_spells ? "true" : "false"); append_spells( desc, item ); if (desc.empty()) need_extra_line = false; diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index e71c3658d8..5d07fb3786 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1041,7 +1041,7 @@ static int _acquirement_weapon_subtype() for (int i = SK_SHORT_BLADES; i <= SK_DARTS; i++) { - if (i == SK_UNUSED_1) + if (is_invalid_skill(i)) continue; // Adding a small constant allows for the occasional @@ -1328,9 +1328,10 @@ static int _spell_weight(spell_type spell) } ASSERT(count > 0); - int level = spell_difficulty(spell) - 1; + int leveldiff = 5 - spell_difficulty(spell); + + return std::max(0, 2 * weight/count + leveldiff); - return std::max(0, weight/count - 2*level); } // When randomly picking a book for acquirement, use the sum of the @@ -1401,7 +1402,7 @@ static void _do_book_acquirement(item_def &book, int agent) for (int i = 0; i < NUM_SKILLS; i++) { - if (i > SK_UNARMED_COMBAT && i < SK_SPELLCASTING) + if (is_invalid_skill(i)) continue; int weight = you.skills[i] * 100 / species_skills(i, you.species); @@ -1472,9 +1473,9 @@ static void _do_book_acquirement(item_def &book, int agent) case BOOK_RANDART_LEVEL: { - book.sub_type = BOOK_RANDART_LEVEL; - int num_spells = 5 - (level + 1) / 2 + random_range(1, 3); - make_book_level_randart(book, level, num_spells, owner); + book.sub_type = BOOK_RANDART_LEVEL; + int max_spells = 5 + level/3; + make_book_level_randart(book, level, max_spells, owner); break; } @@ -1489,8 +1490,7 @@ static void _do_book_acquirement(item_def &book, int agent) for (int i = 0; i < NUM_SKILLS; i++) { - if (i == SK_UNUSED_1 - || i > SK_UNARMED_COMBAT && i < SK_SPELLCASTING) + if (is_invalid_skill(i)) { weights[i] = 0; continue; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index a8bbc5973b..ab99a99379 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -2118,6 +2118,7 @@ public: int dump_item_origins; // Show where items came from? int dump_item_origin_price; + bool dump_book_spells; // Order of sections in the character dump. std::vector<std::string> dump_order; diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index a65b50e635..671264c652 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -836,6 +836,7 @@ void game_options::reset_options() dump_message_count = 7; dump_item_origins = IODS_ARTEFACTS | IODS_RODS; dump_item_origin_price = -1; + dump_book_spells = true; drop_mode = DM_MULTI; pickup_mode = -1; @@ -2958,6 +2959,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) if (dump_item_origin_price < -1) dump_item_origin_price = -1; } + else BOOL_OPTION(dump_book_spells); else BOOL_OPTION(level_map_title); else BOOL_OPTION(target_zero_exp); else BOOL_OPTION(target_oos); diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index f5e52e30a6..6461342c0a 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -2530,10 +2530,10 @@ static void _generate_book_item(item_def& item, int allow_uniques, make_book_theme_randart(item, 0, 0, 5 + coinflip(), 20); else if (item.sub_type == BOOK_RANDART_LEVEL) { - int max_level = std::min( 9, std::max(1, item_level / 3) ); - int spell_level = random_range(1, max_level); - int num_spells = 5 - (spell_level + 1) / 2 + random_range(1, 3); - make_book_level_randart(item, spell_level, num_spells); + int max_level = std::min( 9, std::max(1, item_level / 3) ); + int spl_level = random_range(1, max_level); + int max_spells = 5 + spl_level/3; + make_book_level_randart(item, spl_level, max_spells); } } diff --git a/crawl-ref/source/skills.h b/crawl-ref/source/skills.h index a31c9e658d..2ad4abc7ff 100644 --- a/crawl-ref/source/skills.h +++ b/crawl-ref/source/skills.h @@ -20,5 +20,4 @@ void calc_total_skill_points( void ); * *********************************************************************** */ int exercise(int exsk, int deg); - #endif diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index d546e2501f..7ff53d8054 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -1980,12 +1980,8 @@ std::string skill_title( unsigned char best_skill, unsigned char skill_lev, int species, int str, int dex, int god ) { // paranoia - if (best_skill == SK_UNUSED_1 - || best_skill > SK_UNARMED_COMBAT && best_skill < SK_SPELLCASTING - || best_skill >= NUM_SKILLS) - { + if (is_invalid_skill(best_skill)) return ("Adventurer"); - } if (species == -1) species = you.species; @@ -2072,12 +2068,8 @@ skill_type best_skill( int min_skill, int max_skill, int excl_skill ) for (int i = min_skill; i <= max_skill; i++) // careful!!! { - if (i == excl_skill - || i == SK_UNUSED_1 - || i > SK_UNARMED_COMBAT && i < SK_SPELLCASTING) - { + if (i == excl_skill || is_invalid_skill(i)) continue; - } if (you.skills[i] > best_skill_level) { @@ -2118,8 +2110,7 @@ void init_skill_order( void ) { for (int i = SK_FIGHTING; i < NUM_SKILLS; i++) { - if (i == SK_UNUSED_1 - || (i > SK_UNARMED_COMBAT && i < SK_SPELLCASTING)) + if (is_invalid_skill(i)) { you.skill_order[i] = MAX_SKILL_ORDER; continue; @@ -2132,12 +2123,8 @@ void init_skill_order( void ) for (int j = SK_FIGHTING; j < NUM_SKILLS; j++) { - if (i == j - || j == SK_UNUSED_1 - || (j > SK_UNARMED_COMBAT && j < SK_SPELLCASTING)) - { + if (i == j || is_invalid_skill(j)) continue; - } const int j_diff = species_skills( j, you.species ); const unsigned int j_points = (you.skill_points[j] * 100) / j_diff; @@ -2296,3 +2283,14 @@ void wield_warning(bool newWeapon) } } } + +bool is_invalid_skill(int skill) +{ + if (skill < 0 || skill == SK_UNUSED_1 || skill >= NUM_SKILLS) + return (true); + + if (skill > SK_UNARMED_COMBAT && skill < SK_SPELLCASTING) + return (true); + + return (false); +} diff --git a/crawl-ref/source/skills2.h b/crawl-ref/source/skills2.h index de878c083a..97ac2d92a1 100644 --- a/crawl-ref/source/skills2.h +++ b/crawl-ref/source/skills2.h @@ -84,5 +84,6 @@ void show_skills(); * *********************************************************************** */ void wield_warning(bool newWeapon = true); +bool is_invalid_skill(int skill); #endif 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) { |