summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-04 19:46:18 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-04 19:46:18 +0000
commitd5c46b944d92e3b36aaccb50135d8132e26a2228 (patch)
tree5d12d8846c29cc88e8b43d43986256e23c3a18cd /crawl-ref/source
parented6970cf64309f5b1741304aa1c828cc0319b00d (diff)
downloadcrawl-ref-d5c46b944d92e3b36aaccb50135d8132e26a2228.tar.gz
crawl-ref-d5c46b944d92e3b36aaccb50135d8132e26a2228.zip
Spellbook memorisation stuff:
* Simplify the message given when none of the available spells can be memorised. * The descriptions of the three dangerous spellbooks now mention that the books will lash out at the player if a memorisation fails. Also, the "some of the more powerful grimoires are not to be toyed with" warning has been removed from all of the normal spellbooks, since the dangerous spellbooks are adequetly warned. * If a spell to be memorised is only available from a dangerous spell book then colour that spell light red and warn the player if they select it for memorisation. (Not yet handled is any logic for choosing between multiple dangerous spell books if the same spell is in more than one of them) * is_dangerous_item() now returns true for the three dangerous spellbooks, so they'll be colored differently in the inventory. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9891 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dat/descript/items.txt138
-rw-r--r--crawl-ref/source/itemname.cc3
-rw-r--r--crawl-ref/source/spl-book.cc177
-rw-r--r--crawl-ref/source/spl-book.h3
4 files changed, 164 insertions, 157 deletions
diff --git a/crawl-ref/source/dat/descript/items.txt b/crawl-ref/source/dat/descript/items.txt
index 5762378451..ada4fbf477 100644
--- a/crawl-ref/source/dat/descript/items.txt
+++ b/crawl-ref/source/dat/descript/items.txt
@@ -160,8 +160,7 @@ A crossbow bolt.
%%%%
book of air
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of annihilations
@@ -171,51 +170,45 @@ book. It is sought after by sorcerers, for it allows the gifted and
resourceful to command destruction with the ease of a twinkle. Feeble
wizards, however, may well meet their doom when trying to read this
opus.
+
+WARNING: If you fail in an attempt to memorize a spell from this book,
+the book will lash out at you.
%%%%
book of callings
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of cantrips
-A book of magic spells. Unlike most of the other grimoires,
-this one can be toyed with.
+A book of magic spells.
%%%%
book of changes
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of card effects
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of charms
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of clouds
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of conjurations
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of control
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of death
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of demonology
@@ -225,161 +218,133 @@ to unleash them unto this unsuspecting world. Many wizards have proven
too weak to stand the power of this tome. You are not sure whether you
hear the screams of the countless victims, which have been eaten,
maimed and raped by the demons. Or do you scream yet?
+
+WARNING: If you fail in an attempt to memorize a spell from this book,
+the book will lash out at you.
%%%%
book of divinations
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of enchantments
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of envenomations
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of fixed level
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of fixed theme
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of fire
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of flames
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of frost
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of geomancy
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of healing
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of hinderance
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of ice
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of minor magic
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of morphology
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of necromancy
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of party tricks
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of power
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of practical magic
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of spatial translocations
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of stalking
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of summonings
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of surveyances
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of the earth
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of the sky
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of the tempests
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of the warp
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of transfigurations
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of tukima
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of unlife
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of war chants
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
book of wizardry
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
bottled efreet
@@ -800,8 +765,7 @@ A filling ration of dried and preserved meats.
%%%%
monster manual
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
morningstar
@@ -830,6 +794,9 @@ An extremely rare book, powerful and sinister. Its binding is made from
delicate skin of unknown provenance. Many foolhardy magicians have tried
to study this tome, only to find themselves entangled within necromantic
forces they could not hope to control.
+
+WARNING: If you fail in an attempt to memorize a spell from this book,
+the book will lash out at you.
%%%%
needle
@@ -1639,6 +1606,5 @@ A conical cloth hat.
%%%%
young poisoner's handbook
-A book of magic spells. Beware, for some of the more powerful
-grimoires are not to be toyed with.
+A book of magic spells.
%%%%
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 4165023a5e..88186883c4 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -2452,7 +2452,8 @@ bool is_dangerous_item(const item_def &item, bool temp)
case OBJ_BOOKS:
// The Tome of Destruction is certainly risky.
- return (item.sub_type == BOOK_DESTRUCTION);
+ return (item.sub_type == BOOK_DESTRUCTION
+ || is_dangerous_spellbook(item));
default:
return (false);
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index 8f44dad1f7..1a630f259f 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1290,11 +1290,12 @@ bool player_can_memorise(const item_def &book)
return (false);
}
-static std::vector<spell_type> _get_mem_list()
-{
- std::set<spell_type> all_spells;
- std::vector<spell_type> mem_spells;
+typedef std::vector<spell_type> spell_list;
+typedef std::map<spell_type, int> spells_to_books;
+static bool _get_mem_list(spell_list &mem_spells,
+ spells_to_books &book_hash)
+{
bool book_errors = false;
int num_books = 0;
int num_unreadable = 0;
@@ -1328,8 +1329,15 @@ static std::vector<spell_type> _get_mem_list()
if (!is_valid_spell_in_book(book, j))
continue;
- all_spells.insert(which_spell_in_book(book, j));
+ const spell_type spell = which_spell_in_book(book, j);
+
spells_in_book++;
+
+ // XXX: If same spell is in two different dangerous spellbooks,
+ // how to decide which one to use?
+ spells_to_books::iterator it = book_hash.find(spell);
+ if (it == book_hash.end() || is_dangerous_spellbook(it->second))
+ book_hash[spell] = book.sub_type;
}
if (spells_in_book == 0)
@@ -1346,19 +1354,19 @@ static std::vector<spell_type> _get_mem_list()
if (num_books == 0)
{
mpr("You aren't carrying any spellbooks.", MSGCH_PROMPT);
- return (mem_spells);
+ return (false);
}
else if (num_unreadable == num_books)
{
mpr("All of the spellbooks you're carrying are beyond your "
"current level of comprehension.", MSGCH_PROMPT);
- return (mem_spells);
+ return (false);
}
- else if (all_spells.size() == 0)
+ else if (book_hash.size() == 0)
{
mpr("None of the spellbooks you are carrying contain any spells.",
MSGCH_PROMPT);
- return (mem_spells);
+ return (false);
}
unsigned int num_known = 0;
@@ -1369,10 +1377,10 @@ static std::vector<spell_type> _get_mem_list()
bool amnesia = false;
- for (std::set<spell_type>::iterator i = all_spells.begin();
- i != all_spells.end(); ++i)
+ for (spells_to_books::iterator i = book_hash.begin();
+ i != book_hash.end(); ++i)
{
- const spell_type spell = *i;
+ const spell_type spell = i->first;
if (player_knows_spell(spell))
num_known++;
@@ -1398,62 +1406,40 @@ static std::vector<spell_type> _get_mem_list()
// You can always memorise selective amnesia.
if (num_memable > 0 && you.spell_no >= 21)
{
- mem_spells.clear();
-
if (amnesia)
{
+ mem_spells.clear();
mem_spells.push_back(SPELL_SELECTIVE_AMNESIA);
- return (mem_spells);
+ return (true);
}
mpr("Your head is already too full of spells!");
- return (mem_spells);
+ return (false);
}
if (num_memable)
- return (mem_spells);
-
- // No spells to be memorised is indicated by an empty list.
- mem_spells.clear();
-
- // None of the spells can be memorised; tell the player why.
- std::string prefix =
- make_stringf("You cannot memorise any new spells. Out of %u "
- "available spells, ", all_spells.size());
-
- std::vector<std::string> causes;
- if (num_known)
- {
- causes.push_back(make_stringf("you already know %u of them",
- num_known));
- }
- if (num_race)
- {
- causes.push_back(make_stringf("%u cannot be memorised because of "
- "your race", num_race));
- }
- if (num_low_xl)
- {
- causes.push_back(make_stringf("%u cannot be memorised because of "
- "your low experience level",
- num_low_xl));
- }
- if (num_low_levels)
- {
- causes.push_back(make_stringf("%u cannot be memorised because you "
- "don't have enough free spell levels",
- num_low_levels));
- }
+ return (true);
unsigned int total = num_known + num_race + num_low_xl + num_low_levels;
- if (total < all_spells.size())
- {
- causes.push_back(make_stringf("%u cannot be accounted for (please "
- "file a bug report)",
- all_spells.size() - total));
- }
- mpr_comma_separated_list(prefix, causes, " and ", ", ", MSGCH_PROMPT);
+ if (num_known == total)
+ mpr("You already know all available spells.", MSGCH_PROMPT);
+ else if (num_race == total || (num_known + num_race) == total)
+ {
+ std::string species = species_name(you.species, 0);
+ mprf(MSGCH_PROMPT,
+ "You cannot memorize any of the available spells because you "
+ "are a %s.", lowercase_string(species).c_str());
+ }
+ else if (num_low_levels > 0)
+ mpr("You do not have enough free spell levels to memorize any of the "
+ "available spells.", MSGCH_PROMPT);
+ else if (num_low_xl > 0)
+ mpr("You aren't experienced enough yet to memorize any of the "
+ "available spells.", MSGCH_PROMPT);
+ else
+ mpr("You can't memorize any new spells for an unknown reason; "
+ "please file a bug report.", MSGCH_PROMPT);
if (num_unreadable)
{
@@ -1462,7 +1448,7 @@ static std::vector<spell_type> _get_mem_list()
"spells in them are available to you.", num_unreadable);
}
- return (mem_spells);
+ return (false);
}
static bool _sort_mem_spells(spell_type a, spell_type b)
@@ -1475,7 +1461,8 @@ static bool _sort_mem_spells(spell_type a, spell_type b)
return (stricmp(spell_title(a), spell_title(b)) < 0);
}
-static spell_type _choose_mem_spell(std::vector<spell_type> &spells)
+static spell_type _choose_mem_spell(spell_list &spells,
+ spells_to_books &book_hash)
{
std::sort(spells.begin(), spells.end(), _sort_mem_spells);
@@ -1509,15 +1496,21 @@ static spell_type _choose_mem_spell(std::vector<spell_type> &spells)
const bool grey = spell_difficulty(spell) > you.experience_level
|| player_spell_levels() < spell_levels_required(spell);
+ spells_to_books::iterator it = book_hash.find(spell);
+ const bool red = is_dangerous_spellbook(it->second);
+
std::ostringstream desc;
if (grey)
desc << "<darkgrey>";
+ else if (red)
+ desc << "<lightred>";
+
desc << std::left;
desc << std::setw(30) << spell_title(spell);
desc << spell_schools_string(spell);
- int so_far = desc.str().length() - (grey ? 10 : 0);
+ int so_far = desc.str().length() - ( (grey || red) ? 10 : 0);
if (so_far < 60)
desc << std::string(60 - so_far, ' ');
@@ -1525,6 +1518,8 @@ static spell_type _choose_mem_spell(std::vector<spell_type> &spells)
<< spell_difficulty(spell);
if (grey)
desc << "</darkgrey>";
+ else if (red)
+ desc << "</lightred>";
MenuEntry* me = new MenuEntry(desc.str(), MEL_ITEM, 1,
index_to_letter(i % 52));
@@ -1559,8 +1554,6 @@ bool learn_spell()
return (false);
}
- int chance = 0;
-
int i;
int j = 0;
@@ -1586,12 +1579,13 @@ bool learn_spell()
return (false);
}
- std::vector<spell_type> spell_list = _get_mem_list();
+ spell_list mem_spells;
+ spells_to_books book_hash;
- if (spell_list.empty())
+ if (!_get_mem_list(mem_spells, book_hash))
return (false);
- spell_type specspell = _choose_mem_spell(spell_list);
+ spell_type specspell = _choose_mem_spell(mem_spells, book_hash);
// MATT
if (specspell == SPELL_NO_SPELL)
@@ -1612,7 +1606,32 @@ bool learn_spell()
return (false);
}
- chance = spell_fail(specspell);
+ int chance = spell_fail(specspell);
+
+ spells_to_books::iterator it = book_hash.find(specspell);
+
+ if (chance > 0 && is_dangerous_spellbook(it->second))
+ {
+ item_def book;
+ book.base_type = OBJ_BOOKS;
+ book.sub_type = it->second;
+ book.quantity = 1;
+ book.flags |= ISFLAG_IDENT_MASK;
+
+ char buf[180];
+
+ sprintf(buf, "The only spellbook you have which contains that spell "
+ "is %s, a dangerous spellbook which will strike back at you "
+ "if you memorisation attempt fails. Attempt to memorise "
+ "anyways?",
+ book.name(DESC_NOCAP_THE).c_str());
+ if (!yesno(buf, false, 'n'))
+ {
+ canned_msg( MSG_OK );
+ return (false);
+ }
+ }
+
const int temp_rand1 = random2(3);
const int temp_rand2 = random2(4);
@@ -1650,29 +1669,27 @@ bool learn_spell()
mpr("You fail to memorise the spell.");
you.turn_is_over = true;
-#if 0
- if (you.inv[ book ].sub_type == BOOK_NECRONOMICON)
+ if (it->second == BOOK_NECRONOMICON)
{
mpr("The pages of the Necronomicon glow with a dark malevolence...");
MiscastEffect( &you, MISC_KNOWN_MISCAST, SPTYP_NECROMANCY,
8, random2avg(88, 3),
"reading the Necronomicon" );
}
- else if (you.inv[ book ].sub_type == BOOK_DEMONOLOGY)
+ else if (it->second == BOOK_DEMONOLOGY)
{
mpr("This book does not appreciate being disturbed by one of your ineptitude!");
MiscastEffect( &you, MISC_KNOWN_MISCAST, SPTYP_SUMMONING,
7, random2avg(88, 3),
"reading the book of Demonology" );
}
- else if (you.inv[ book ].sub_type == BOOK_ANNIHILATIONS)
+ else if (it->second == BOOK_ANNIHILATIONS)
{
mpr("This book does not appreciate being disturbed by one of your ineptitude!");
MiscastEffect( &you, MISC_KNOWN_MISCAST, SPTYP_CONJURATION,
8, random2avg(88, 3),
"reading the book of Annihilations" );
}
-#endif
#ifdef WIZARD
if (!you.wizard)
@@ -2909,3 +2926,23 @@ bool book_has_title(const item_def &book)
return (book.props.exists("is_named")
&& book.props["is_named"].get_bool() == true);
}
+
+bool is_dangerous_spellbook(const int book_type)
+{
+ switch(book_type)
+ {
+ case BOOK_NECRONOMICON:
+ case BOOK_DEMONOLOGY:
+ case BOOK_ANNIHILATIONS:
+ return (true);
+ default:
+ break;
+ }
+ return (false);
+}
+
+bool is_dangerous_spellbook(const item_def &book)
+{
+ ASSERT(book.base_type == OBJ_BOOKS);
+ return is_dangerous_spellbook(book.sub_type);
+}
diff --git a/crawl-ref/source/spl-book.h b/crawl-ref/source/spl-book.h
index 3a05756785..ae57a4ebe1 100644
--- a/crawl-ref/source/spl-book.h
+++ b/crawl-ref/source/spl-book.h
@@ -78,4 +78,7 @@ bool make_book_theme_randart(item_def &book,
void make_book_Roxanne_special(item_def *book);
bool book_has_title(const item_def &book);
+
+bool is_dangerous_spellbook(const item_def &book);
+bool is_dangerous_spellbook(const int book_type);
#endif