diff options
-rw-r--r-- | crawl-ref/source/debug.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/effects.cc | 32 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/religion.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.cc | 71 | ||||
-rw-r--r-- | crawl-ref/source/spl-util.cc | 4 |
7 files changed, 95 insertions, 30 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 7948367098..e43ec587e1 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -5453,20 +5453,24 @@ void wizard_give_monster_item(monsters *mon) dec_inv_item_quantity(player_slot, item.quantity); if ((mon->flags & MF_HARD_RESET) && !(item.flags & ISFLAG_SUMMONED)) + { mprf(MSGCH_WARN, "WARNING: Monster has MF_HARD_RESET and all its " "items will disappear when it does."); + } else if ((item.flags & ISFLAG_SUMMONED) && !mon->is_summoned()) + { mprf(MSGCH_WARN, "WARNING: Item is summoned and will disappear when " "the monster does."); - + } // Monster's old item moves to player's inventory. if (old_eq != NON_ITEM) { mpr("Fetching monster's old item."); if (mitm[old_eq].flags & ISFLAG_SUMMONED) + { mprf(MSGCH_WARN, "WARNING: Item is summoned and shouldn't really " "be anywhere but in the inventory of a summoned monster."); - + } mitm[old_eq].pos.reset(); mitm[old_eq].link = NON_ITEM; move_item_to_player(old_eq, mitm[old_eq].quantity); diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index c57ab6d823..16aaf8e3fe 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -1474,6 +1474,7 @@ void direction(dist& moves, targeting_type restricts, break; } + flush_prev_message(); if (loop_done == true) { // Confirm that the loop is really done. If it is, diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 599f956785..b74bdc5d11 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1341,9 +1341,6 @@ static int _book_weight(int book) { ASSERT(book >= 0 && book <= MAX_NORMAL_BOOK); - if (book_rarity(book) == 100) - return 0; - int total_weight = 0; for (int i = 0; i < SPELLBOOK_SIZE; i++) { @@ -1361,7 +1358,7 @@ static int _book_weight(int book) return (total_weight); } -static void _do_book_acquirement(item_def &book, int agent) +static bool _do_book_acquirement(item_def &book, int agent) { // items() shouldn't make book a randart for acquirement items. ASSERT(!is_random_artefact(book)); @@ -1469,15 +1466,19 @@ static void _do_book_acquirement(item_def &book, int agent) } case BOOK_RANDART_THEME: book.sub_type = BOOK_RANDART_THEME; - make_book_theme_randart(book, 0, 0, 5 + coinflip(), 20, SPELL_NO_SPELL, - owner); + if (!make_book_theme_randart(book, 0, 0, 5 + coinflip(), 20, + SPELL_NO_SPELL, owner)) + { + return (false); + } break; case BOOK_RANDART_LEVEL: { book.sub_type = BOOK_RANDART_LEVEL; int max_spells = 5 + level/3; - make_book_level_randart(book, level, max_spells, owner); + if (!make_book_level_randart(book, level, max_spells, owner)) + return (false); break; } @@ -1485,7 +1486,7 @@ static void _do_book_acquirement(item_def &book, int agent) { // The Tome of Destruction is rare enough we won't change this. if (book.sub_type == BOOK_DESTRUCTION) - return; + return (true); int weights[NUM_SKILLS]; int total_weights = 0; @@ -1513,10 +1514,7 @@ static void _do_book_acquirement(item_def &book, int agent) // Are we too skilled to get any manuals? if (total_weights == 0) - { - _do_book_acquirement(book, agent); - return; - } + return _do_book_acquirement(book, agent); book.sub_type = BOOK_MANUAL; book.plus = choose_random_weighted(weights, weights + NUM_SKILLS); @@ -1525,6 +1523,7 @@ static void _do_book_acquirement(item_def &book, int agent) break; } } + return (true); } bool acquirement(object_class_type class_wanted, int agent, @@ -1711,7 +1710,14 @@ bool acquirement(object_class_type class_wanted, int agent, if (thing.base_type == OBJ_BOOKS) { - _do_book_acquirement(thing, agent); + if (!_do_book_acquirement(thing, agent)) + { + if (!quiet) + mpr("The demon of the infinite void smiles upon you."); + *item_index = NON_ITEM; + destroy_item(thing, true); + return (false); + } mark_had_book(thing); } else if (thing.base_type == OBJ_JEWELLERY) diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 47cccee2a7..50fca9f162 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1637,9 +1637,10 @@ int move_item_to_player( int obj, int quant_got, bool quiet, // If moving an item directly from a monster to the player without the // item having been on the grid, then it really isn't a position event. if (in_bounds(p)) + { dungeon_events.fire_position_event( dgn_event(DET_ITEM_PICKUP, p, 0, obj, -1), p); - + } item_def &item = you.inv[freeslot]; // Copy item. item = mitm[obj]; diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index b58590e3e8..4502e19793 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -2005,7 +2005,11 @@ static void _do_god_gift(bool prayed_for) && !grid_destroys_items(grd(you.pos()))) { if (gift == OBJ_RANDOM) - success = acquirement(OBJ_BOOKS, you.religion); + { + // Sif Muna special: Keep quiet if acquirement fails + // because the player already has seen all spells. + success = acquirement(OBJ_BOOKS, you.religion, true); + } else { int thing_created = items(1, OBJ_BOOKS, gift, true, 1, diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index 4c7ac86e17..18faa0868f 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -977,11 +977,8 @@ void init_spell_rarities() for (int i = 0; i < NUM_FIXED_BOOKS; ++i) { - const int rarity = book_rarity(i); - - // Manuals, books of destruction, books only created as gifts - // from specific gods, and the unused Book of Healing. - if (rarity >= 20) + // Manuals and books of destruction are not even part of this loop. + if (i >= MIN_GOD_ONLY_BOOK && i <= MAX_GOD_ONLY_BOOK) continue; for (int j = 0; j < SPELLBOOK_SIZE; ++j) @@ -1006,6 +1003,7 @@ void init_spell_rarities() } #endif + const int rarity = book_rarity(i); if (rarity < _lowest_rarity[spell]) _lowest_rarity[spell] = rarity; } @@ -1720,7 +1718,32 @@ static void _get_spell_list(std::vector<spell_type> &spell_list, int level, int &god_discard, int &uncastable_discard, bool avoid_known = false) { - for (int i = 0; i < NUM_SPELLS; i++) + // For randarts handed out by Sif Muna, spells contained in the + // Vehumet/Kiku specials are fair game. + // We store them in an extra vector that (once sorted) can later + // be checked for each spell with a rarity -1 (i.e. not normally + // appearing randomly). + std::vector<spell_type> special_spells; + if (god == GOD_SIF_MUNA) + { + for (int i = MIN_GOD_ONLY_BOOK; i <= MAX_GOD_ONLY_BOOK; ++i) + for (int j = 0; j < SPELLBOOK_SIZE; ++j) + { + spell_type spell = which_spell_in_book(i, j); + if (spell == SPELL_NO_SPELL) + continue; + + if (spell_rarity(spell) != -1) + continue; + + special_spells.push_back(spell); + } + + std::sort(special_spells.begin(), special_spells.end()); + } + + int specnum = 0; + for (int i = 0; i < NUM_SPELLS; ++i) { const spell_type spell = (spell_type) i; @@ -1730,22 +1753,38 @@ static void _get_spell_list(std::vector<spell_type> &spell_list, int level, // Only use spells available in books you might find lying about // the dungeon. if (spell_rarity(spell) == -1) - continue; + { + bool skip_spell = true; + while ((unsigned int) specnum < special_spells.size() + && spell == special_spells[specnum]) + { + specnum++; + skip_spell = false; + } + + if (skip_spell) + continue; + } if (avoid_known && you.seen_spell[spell]) continue; - const unsigned int disciplines = get_spell_disciplines(spell); if (level != -1) { + // fixed level randart: only include spells of the given level if (spell_difficulty(spell) != level) continue; } - else if (!((disciplines & disc1) || (disciplines & disc2)) + else + { + // themed randart: only include spells of the given disciplines + const unsigned int disciplines = get_spell_disciplines(spell); + if ((!(disciplines & disc1) && !(disciplines & disc2)) || disciplines_conflict(disc1, disciplines) || disciplines_conflict(disc2, disciplines)) - { - continue; + { + continue; + } } // Only wizard mode gets spells still under development. @@ -1772,6 +1811,9 @@ static void _get_spell_list(std::vector<spell_type> &spell_list, int level, continue; } +// if (spell_rarity(spell) == -1) +// mprf("chosen spell: %s (%d)", spell_title(spell), spell); + // Passed all tests. spell_list.push_back(spell); } @@ -2068,11 +2110,16 @@ static bool _get_weighted_discs(bool completely_random, god_type god, int num_discs = ok_discs.size(); - ASSERT( num_discs > 0 ); if (num_discs == 0) { +#ifdef DEBUG mpr("No valid disciplines with which to make a themed ranadart " "spellbook.", MSGCH_ERROR); +#endif + // Only happens if !completely_random and the player already knows + // all available spells. We could simply re-allow all disciplines + // but the player isn't going to get any new spells, anyway, so just + // consider this acquirement failed. (jpeg) return (false); } diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index 5d16fa60ab..c8bfdd0d94 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -118,8 +118,10 @@ void init_spell_descs(void) if (data.flags & SPFLAG_TARGETING_MASK) { if (data.min_range <= -1 || data.max_range <= 0) + { end(1, false, "targeted/directed spell '%s' has invalid range", data.title); + } } #endif @@ -980,7 +982,7 @@ static int _sandblast_range(int pow, bool real_cast) int res = 1; if (wielding_rocks() && (!real_cast || coinflip())) - res = 2; + res = 2; return (res); } |