summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-04 09:00:04 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-04 09:00:04 +0000
commit6e8d91afe0a93353fac5c3120c6c6bc2601c2e8f (patch)
tree91a42ea41ad2d378101e27795dec37ee5b15914a
parent7b960a89ece3e8d66abeee2ef8b49a5bc9e90b0a (diff)
downloadcrawl-ref-6e8d91afe0a93353fac5c3120c6c6bc2601c2e8f.tar.gz
crawl-ref-6e8d91afe0a93353fac5c3120c6c6bc2601c2e8f.zip
Allow maps to specify item quantities with the q:N syntax in item specs.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1745 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/docs/level-design.txt13
-rw-r--r--crawl-ref/source/dungeon.cc3
-rw-r--r--crawl-ref/source/mapdef.cc4
-rw-r--r--crawl-ref/source/mapdef.h3
4 files changed, 17 insertions, 6 deletions
diff --git a/crawl-ref/docs/level-design.txt b/crawl-ref/docs/level-design.txt
index a2ab8655ca..f73700e49b 100644
--- a/crawl-ref/docs/level-design.txt
+++ b/crawl-ref/docs/level-design.txt
@@ -394,11 +394,15 @@ ITEM: (list of items, separated by comma)
can abbreviate "weight:30" by "w:30". The chance to pick a
possibility is
[possibility's weight: / sum of all weight:s in that array position]
+
For example, the following line makes letter 'd' into a bread ration
with 50% chance, or apple or orange with 25% chance each:
+
ITEM: bread ration / w:5 apple / w:5 orange
- Modifiers:
+ Modifiers:
+ * "q:N" sets the item quantity to N (if N > 0). Does nothing
+ if the item is not stackable.
* "good_item" makes the builder try to make the item a good one.
* "any" by itself gives random choice; you can combine "any" with
"good_item."
@@ -408,10 +412,9 @@ ITEM: (list of items, separated by comma)
misc, carrion. All of these are usable in map definitions,
apart from "orb" and "carrion".
- Limitations: You can't affect stack quantity for stackable items,
- nor can you affect curse status nor item race, nor can you give
- specific egos, nor can give fixedarts. You also can't lay down
- corpses, skeletons, or chunks.
+ Limitations: You can't specify curse status nor item race,
+ nor can you give specific egos, nor can give fixedarts. You
+ also can't lay down corpses, skeletons, or chunks.
MONS: (list of monsters)
These are used to help place specific monsters at specific places
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index a63d6bb145..1b314bf98d 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -3194,6 +3194,9 @@ static void dngn_place_item_explicit(const item_spec &spec,
{
mitm[item_made].x = x;
mitm[item_made].y = y;
+
+ if (is_stackable_item(mitm[item_made]) && spec.qty > 0)
+ mitm[item_made].quantity = spec.qty;
}
}
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 5e46f86774..65592df4b5 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -2078,6 +2078,10 @@ item_spec item_list::parse_single_spec(std::string s)
}
}
+ const int qty = strip_number_tag(s, "q:");
+ if (qty != TAG_UNFOUND)
+ result.qty = qty;
+
if (strip_tag(s, "good_item"))
result.level = MAKE_GOOD_ITEM;
else
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index 7cb4252197..4774684560 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -350,9 +350,10 @@ struct item_spec
int allow_uniques;
int level;
int race;
+ int qty;
item_spec() : genweight(10), base_type(OBJ_RANDOM), sub_type(OBJ_RANDOM),
- allow_uniques(1), level(-1), race(MAKE_ITEM_RANDOM_RACE)
+ allow_uniques(1), level(-1), race(MAKE_ITEM_RANDOM_RACE), qty(0)
{
}
};