diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-23 13:07:05 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-23 13:07:05 +0000 |
commit | 76c82d66daed178db22ec0fe9bd91cfb23cfb28c (patch) | |
tree | 05d1029ebd67e95c404d05ad9ef5e4e46b83701e /crawl-ref | |
parent | f3b465a2e3fa4d16eaf9ff89065fa3a67c2775ea (diff) | |
download | crawl-ref-76c82d66daed178db22ec0fe9bd91cfb23cfb28c.tar.gz crawl-ref-76c82d66daed178db22ec0fe9bd91cfb23cfb28c.zip |
Allow .des files to place manuals with names as "manual of Fighting" or "random manual" (dpeg).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7549 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/dungeon.cc | 15 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 21 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.h | 5 |
4 files changed, 45 insertions, 7 deletions
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 1a31f4fb67..a57c96010d 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -4712,7 +4712,8 @@ static bool _build_vaults(int level_number, int force_vault, int rune_subst, } // end build_vaults() static void _dgn_place_item_explicit(const item_spec &spec, - const coord_def& where, int level) + const coord_def& where, + int level) { // Dummy object? if (spec.base_type == OBJ_UNASSIGNED) @@ -4739,10 +4740,16 @@ static void _dgn_place_item_explicit(const item_spec &spec, if (item_made != NON_ITEM && item_made != -1) { - mitm[item_made].pos = where; + item_def &item(mitm[item_made]); + item.pos = where; + if (is_stackable_item(item) && spec.qty > 0) + item.quantity = spec.qty; - if (is_stackable_item(mitm[item_made]) && spec.qty > 0) - mitm[item_made].quantity = spec.qty; + if (spec.plus >= 0 && item.base_type == OBJ_BOOKS + && item.sub_type == BOOK_MANUAL) + { + item.plus = spec.plus; + } } // Modify dungeon to ensure that the item is not on an invalid feature. diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 7e8a54503e..fc10c34971 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -55,6 +55,7 @@ #include "randart.h" #include "religion.h" #include "shopping.h" +#include "skills2.h" #include "spl-book.h" #include "spl-util.h" #include "stuff.h" @@ -2437,7 +2438,25 @@ static bool _find_subtype_by_name(item_def &item, for (int i = 0; i < ntypes; i++) { item.sub_type = i; - if (name == lowercase_string(item.name(DESC_PLAIN))) + + if (base_type == OBJ_BOOKS && i == BOOK_MANUAL) + { + for (int j = 0; j < NUM_SKILLS; ++j) + { + if (!skill_name(j)) + continue; + + item.plus = j; + + if (name == lowercase_string(item.name(DESC_PLAIN))) + { + type_wanted = i; + i = ntypes; + break; + } + } + } + else if (name == lowercase_string(item.name(DESC_PLAIN))) { type_wanted = i; break; diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index fbb2dc5880..1c6a82c4cc 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -2660,6 +2660,15 @@ void item_list::parse_random_by_class(std::string c, item_spec &spec) } } + // Random manual? + if (c == "manual") + { + spec.base_type = OBJ_BOOKS; + spec.sub_type = BOOK_MANUAL; + spec.plus = -1; + return; + } + error = make_stringf("Bad item class: '%s'", c.c_str()); } @@ -2677,6 +2686,8 @@ void item_list::parse_raw_name(std::string name, item_spec &spec) { spec.base_type = parsed.base_type; spec.sub_type = parsed.sub_type; + spec.plus = parsed.plus; + spec.plus2 = parsed.plus2; return; } diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index ca9da9c113..52bb196070 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -355,6 +355,7 @@ struct item_spec object_class_type base_type; int sub_type; + int plus, plus2; int ego; int allow_uniques; int level; @@ -362,8 +363,8 @@ struct item_spec int qty; item_spec() : genweight(10), base_type(OBJ_RANDOM), sub_type(OBJ_RANDOM), - ego(0), allow_uniques(1), level(-1), race(MAKE_ITEM_RANDOM_RACE), - qty(0) + plus(0), plus2(0), ego(0), allow_uniques(1), level(-1), + race(MAKE_ITEM_RANDOM_RACE), qty(0) { } }; |