summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/dungeon.cc15
-rw-r--r--crawl-ref/source/items.cc21
-rw-r--r--crawl-ref/source/mapdef.cc11
-rw-r--r--crawl-ref/source/mapdef.h5
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)
{
}
};