diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-29 22:20:54 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-29 22:20:54 +0000 |
commit | 10676923ec3e6a636e021089ef8e0e39c097e983 (patch) | |
tree | 8d808505b259b446cea3f6fd15afbcd144aa8492 /crawl-ref/source | |
parent | eeaba130f2a67321b64889c935fe443af70e3e97 (diff) | |
download | crawl-ref-10676923ec3e6a636e021089ef8e0e39c097e983.tar.gz crawl-ref-10676923ec3e6a636e021089ef8e0e39c097e983.zip |
FR 2532818: Allow randart books to be named after uniques and legendary mages.
Also, randart books created by acquirement (not gifts) have a chance to
be named after the player.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8848 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/dat/database/randbook.txt | 179 | ||||
-rw-r--r-- | crawl-ref/source/effects.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/mon-data.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.cc | 103 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.h | 2 |
5 files changed, 274 insertions, 23 deletions
diff --git a/crawl-ref/source/dat/database/randbook.txt b/crawl-ref/source/dat/database/randbook.txt index 3d4637a00c..bf3b9c40ed 100644 --- a/crawl-ref/source/dat/database/randbook.txt +++ b/crawl-ref/source/dat/database/randbook.txt @@ -129,8 +129,12 @@ Theurgy Thaumaturgy +w:5 Casting +w:5 +Spellcasting + Wizardry Sorcery @@ -141,6 +145,8 @@ Witchery Spellcraft +Spell Weaving + w:5 Secret Knowledge @@ -433,6 +439,12 @@ Displacement Dislocation Orientation + +the Traveller + +the Compass + +the Voyage %%%% Poison @@ -646,3 +658,170 @@ Cloudy Gliding %%%% +# potential previous owners of books +# __NONE is parsed to the empty string +Conjuration owner + +Lee + +Lehudib + +Iskenderun + +Erolcha + +Louise + +Boris + +Nergalle + +Josephine + +Frederick +%%%% +high-level Conjuration owner + +Asmodeus + +Ereshkigal + +Dispater + +Cerebov + +Lom Lobon + +w:30 +@Conjuration owner@ +%%%% +Enchantment owner + +Ilsuiw + +Rupert + +Norris + +__NONE +%%%% +Summoning owner + +__NONE +%%%% +high-level Summoning owner + +Asmodeus + +Dispater + +Mnoleg + +@Summoning owner@ +%%%% +Fire owner + +Azrael + +Margery + +__NONE +%%%% +high-level Fire owner + +Asmodeus + +Cerebov + +w:20 +@Fire owner@ +%%%% +Ice owner + +w:5 +Ozocubu + +__NONE +%%%% +Transmutation owner + +Cigotuvi + +Roxanne + +__NONE +%%%% +Necromancy owner + +Borgnjor + +Cigotuvi + +Boris + +Francis + +Frances + +Murray + +Nergalle +%%%% +high-level Necromancy owner + +Ereshkigal + +Gloorx Vloq + +w:40 +@Necromancy owner@ +%%%% +Divination owner + +__NONE +%%%% +Translocation owner + +__NONE +%%%% +high-level Translocation owner + +Lom Lobon + +@Translocation owner@ +%%%% +Poison owner + +Olgreb + +Alistair + +__NONE +%%%% +high-level Poison owner + +Gloorx Vloq + +@Poison owner@ +%%%% +Earth owner + +Lehudib + +Lee + +Roxanne + +__NONE +%%%% +high-level Earth owner + +Dispater + +w:30 +@Earth owner@ +%%%% +Air owner + +__NONE +%%%% diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 92da990d38..8acf483ce6 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1566,16 +1566,24 @@ static void _do_book_acquirement(item_def &book, int agent) book.sub_type = choice; + // Acquired randart books have a chance of being named after the player. + std::string owner = ""; + if (agent == AQ_SCROLL && one_chance_in(10) + || agent == AQ_CARD_GENIE && one_chance_in(5)) + { + owner = you.your_name; + } + switch (choice) { case BOOK_RANDART_THEME: - make_book_theme_randart(book, 0, 0, 7, 22); + make_book_theme_randart(book, 0, 0, 7, 22, SPELL_NO_SPELL, owner); break; case BOOK_RANDART_LEVEL: { int num_spells = 7 - (level + 1) / 2 + random_range(1, 2); - make_book_level_randart(book, level, num_spells); + make_book_level_randart(book, level, num_spells, owner); break; } diff --git a/crawl-ref/source/mon-data.h b/crawl-ref/source/mon-data.h index ca9c8f5513..c99ea94573 100644 --- a/crawl-ref/source/mon-data.h +++ b/crawl-ref/source/mon-data.h @@ -4078,6 +4078,7 @@ static monsterentry mondata[] = { }, { + // Gets a random spellbook between MST_WIZARD_I and MST_WIZARD_V. MONS_EROLCHA, 'O', LIGHTBLUE, "Erolcha", M_UNIQUE | M_SPELLCASTER | M_ACTUAL_SPELLS | M_SEE_INVIS | M_WARM_BLOOD | M_EVIL | M_SPEAKS, diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index 711592b957..3627b15051 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -1803,7 +1803,8 @@ static void _get_spell_list(std::vector<spell_type> &spell_list, int level, } -bool make_book_level_randart(item_def &book, int level, int num_spells) +bool make_book_level_randart(item_def &book, int level, int num_spells, + std::string owner) { ASSERT(book.base_type == OBJ_BOOKS); @@ -1815,6 +1816,9 @@ bool make_book_level_randart(item_def &book, int level, int num_spells) if (!is_random_artefact(book)) { + if (!owner.empty()) + book.props["owner"].get_string() = owner; + // Stuff parameters into book.plus and book.plus2, then call // make_item_randart(), which will call us back. if (level == -1) @@ -1838,10 +1842,13 @@ bool make_book_level_randart(item_def &book, int level, int num_spells) } // Being called from make_item_randart() - ASSERT(book.sub_type == BOOK_RANDART_LEVEL); ASSERT(level == -1 && num_spells == -1); + // Re-read owner, if applicable. + if (owner.empty() && book.props.exists("owner")) + owner = book.props["owner"].get_string(); + level = book.plus; ASSERT(level > 0 && level <= 9); @@ -1948,13 +1955,18 @@ bool make_book_level_randart(item_def &book, int level, int num_spells) bool has_owner = true; std::string name = ""; - if (god != GOD_NO_GOD) - name += apostrophise(god_name(god, false)) + " "; + if (!owner.empty()) + name = owner; + else if (god != GOD_NO_GOD) + name = god_name(god, false); else if (one_chance_in(3)) - name += apostrophise(make_name(random_int(), false)) + " "; + name = make_name(random_int(), false); else has_owner = false; + if (has_owner) + name = apostrophise(name) + " "; + // None of these books need a definite article prepended. book.props["is_named"].get_bool() = true; @@ -2387,9 +2399,15 @@ bool make_book_theme_randart(item_def &book, int disc1, int disc2, _remove_nondiscipline_spells(chosen_spells, 1 << max1, 1 << max2, incl_spell); + int highest_level = 0; // Finally fill the spell vector. for (int i = 0; i < SPELLBOOK_SIZE; i++) + { spell_vec[i] = (long) chosen_spells[i]; + if (spell_difficulty(chosen_spells[i]) > highest_level) + highest_level = spell_difficulty(chosen_spells[i]); + } + // ... and change disc1 and disc2 accordingly. disc1 = 1 << max1; @@ -2398,24 +2416,69 @@ bool make_book_theme_randart(item_def &book, int disc1, int disc2, else disc2 = 1 << max2; - std::string name; + // If the owner hasn't been set already use + // a) the god's name for god gifts (only applies to Sif Muna and Xom), + // b) a name depending on the spell disciplines, for pure books + // c) a random name (all god gifts not named earlier) + // d) an applicable god's name + // ... else leave it unnamed (around 56% chance for non-god gifts) + if (owner.empty()) + { + const bool god_gift = (god != GOD_NO_GOD); + if (god_gift && !one_chance_in(4)) + owner = god_name(god, false); + else if (disc1 == disc2 + && (god_gift && one_chance_in(3) || one_chance_in(5))) + { + std::string lookup = spelltype_long_name(disc1); + if (highest_level >= 6) + owner = getRandNameString("high-level " + lookup + " owner"); - const bool god_gift = (god != GOD_NO_GOD); - bool has_owner = true; - if (!owner.empty()) - name = owner; - else if (god_gift && !one_chance_in(4)) - name = god_name(god, false); - else if (god_gift || one_chance_in(5)) // Occasionally, use a random name. - name = make_name(random_int(), false); - else - has_owner = false; + if (owner.empty() || owner == "__NONE") + owner = getRandNameString(lookup + " owner"); - if (has_owner) + if (owner == "__NONE") + owner = ""; + } + + if (owner.empty()) + { + if (god_gift || one_chance_in(5)) // Use a random name. + owner = make_name(random_int(), false); + else if (!god_gift && one_chance_in(8)) + { + god = GOD_SIF_MUNA; + switch (disc1) + { + case SPTYP_NECROMANCY: + if (disc1 == disc2 && !one_chance_in(6)) + god = GOD_KIKUBAAQUDGHA; + break; + case SPTYP_SUMMONING: + case SPTYP_CONJURATION: + if ((disc2 == SPTYP_SUMMONING || disc2 == SPTYP_CONJURATION) + && !one_chance_in(4)) + { + god = GOD_VEHUMET; + } + break; + default: + break; + } + owner = god_name(god, false); + } + } + } + + std::string name = ""; + + if (!owner.empty()) { + name = apostrophise(owner) + " "; book.props["is_named"].get_bool() = true; - name = apostrophise(name) + " "; } + else + book.props["is_named"].get_bool() = false; name += getRandNameString("book_name") + " "; @@ -2425,8 +2488,8 @@ bool make_book_theme_randart(item_def &book, int disc1, int disc2, std::string type_name; if (disc1 != disc2 && coinflip()) { - std::string search = spelltype_long_name(disc2); - type_name = getRandNameString(search + " adj"); + std::string lookup = spelltype_long_name(disc2); + type_name = getRandNameString(lookup + " adj"); } if (type_name.empty()) diff --git a/crawl-ref/source/spl-book.h b/crawl-ref/source/spl-book.h index e48ea6fe09..53aaef2f49 100644 --- a/crawl-ref/source/spl-book.h +++ b/crawl-ref/source/spl-book.h @@ -70,7 +70,7 @@ int count_staff_spells(const item_def &item, bool need_id); int rod_shield_leakage(); bool make_book_level_randart(item_def &book, int level = -1, - int num_spells = -1); + int num_spells = -1, std::string owner = ""); bool make_book_theme_randart(item_def &book, int disc1 = 0, int disc2 = 0, int num_spells = -1, int max_levels = -1, |