summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/randart.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-07 07:53:33 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-07 07:53:33 +0000
commit0f4b659dddc446658c1cb6387dfdd03bcb758db5 (patch)
treecc9b007258e1b62f34cc2caffeca20d865387d7d /crawl-ref/source/randart.cc
parentfea3c8df37716c2bb4c033d463b9a796098e0a83 (diff)
downloadcrawl-ref-0f4b659dddc446658c1cb6387dfdd03bcb758db5.tar.gz
crawl-ref-0f4b659dddc446658c1cb6387dfdd03bcb758db5.zip
Breaks savefile compatibility.
Re-arranged book_type so that books you might find on the floor come first, then books only given out by certain gods, and so on. Added book types BOOK_RANDART_LEVEL, BOOK_RANDART_THEME and BOOK_CARD_EFFECT. Can now get randart books both from acquirement and shops/floor. Acquirement books have a chance of being a manual with a spell discipline skill. Randart books have their own appearances now, and fixed level books their own naming scheme. Needs more entries. Randart books aren't hilited in the menu like other randarts are; don't know why. Added some assertions to choose_random_weighted(). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7761 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/randart.cc')
-rw-r--r--crawl-ref/source/randart.cc66
1 files changed, 63 insertions, 3 deletions
diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc
index 9ef3270d34..5be03b5185 100644
--- a/crawl-ref/source/randart.cc
+++ b/crawl-ref/source/randart.cc
@@ -1119,9 +1119,66 @@ void static _get_randart_properties(const item_def &item,
}
}
+static bool _redo_book(item_def &book)
+{
+ int num_spells = 0;
+ int num_unknown = 0;
+
+ for (int i = 0; i < SPELLBOOK_SIZE; i++)
+ {
+ spell_type spell = which_spell_in_book(book, i);
+
+ if (spell == SPELL_NO_SPELL)
+ continue;
+
+ num_spells++;
+ if (!you.seen_spell[spell])
+ num_unknown++;
+ }
+
+ if (num_spells <= 5 && num_unknown == 0)
+ return (true);
+ else if (num_spells > 5 && num_unknown <= 1)
+ return (true);
+
+ return (false);
+}
+
static bool _init_randart_book(item_def &book)
{
- return make_book_theme_randart(book);
+ ASSERT(book.sub_type == BOOK_RANDART_LEVEL
+ || book.sub_type == BOOK_RANDART_THEME);
+ ASSERT(book.plus != 0);
+
+ god_type god;
+ bool redo = !origin_is_god_gift(book, &god) || god != GOD_XOM;
+
+ // Plus and plus2 contain paramaters to make_book_foo_randart()
+ // which might get changed after the book has been made into a
+ // randart, so reset them on each iteration of the loop.
+ int plus = book.plus;
+ int plus2 = book.plus2;
+ bool book_good;
+ for (int i = 0; i < 4; i++)
+ {
+ book.plus = plus;
+ book.plus2 = plus2;
+
+ if (book.sub_type == BOOK_RANDART_LEVEL)
+ book_good = make_book_level_randart(book);
+ else
+ book_good = make_book_theme_randart(book);
+
+ if (!book_good)
+ continue;
+
+ if (redo && _redo_book(book))
+ continue;
+
+ break;
+ }
+
+ return (book_good);
}
static bool _init_randart_properties(item_def &item)
@@ -2037,8 +2094,11 @@ bool make_item_randart( item_def &item )
if (item.base_type == OBJ_BOOKS)
{
- if (item.sub_type == BOOK_MANUAL || item.sub_type == BOOK_DESTRUCTION)
- return (false);
+ if (item.sub_type != BOOK_RANDART_LEVEL
+ && item.sub_type != BOOK_RANDART_THEME)
+ {
+ return (false);
+ }
}
// already is a randart