From 752b66f301b0bfbc911f3c7f42fcef1d64f7d9ed Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Thu, 22 Jan 2009 18:36:03 +0000 Subject: Commit patch by castamir: * allow placement of fixedarts and damaged/cursed items in vaults git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8699 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/level_design.txt | 11 +++++++--- crawl-ref/source/dungeon.cc | 4 ++++ crawl-ref/source/makeitem.cc | 45 +++++++++++++++++++++++++++++++++++++++-- crawl-ref/source/mapdef.cc | 33 ++++++++++++++++++++++++++++-- crawl-ref/source/mapdef.h | 6 ++++-- crawl-ref/source/randart.cc | 12 +++++++++++ crawl-ref/source/randart.h | 5 +++++ 7 files changed, 107 insertions(+), 9 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/docs/level_design.txt b/crawl-ref/docs/level_design.txt index 2720df6cb3..6a5cf7115f 100644 --- a/crawl-ref/docs/level_design.txt +++ b/crawl-ref/docs/level_design.txt @@ -561,6 +561,8 @@ ITEM: (list of items, separated by comma) "good_item"). If set to -2 then the object's item level will be the same as a "*" symbol item (five plus twice the vault's level number). + * "damaged" sets the item plusses to -1..-4. + * "cursed" gets a curse plus plusses as in "damaged". * "any" by itself gives a random choice; you can combine "any" with "good_item." * "any book", "any misc" etc. gives a random item of that class. @@ -580,6 +582,9 @@ ITEM: (list of items, separated by comma) trying "any weapon ego:vorpal" or "any armour ego:positive_energy" will result in an error. Trying to give an ego to something which can't accept an ego will also result in an error. + * "fixed:item_name" will make a given fixedart by a given name, + like "long sword fixed:singing_sword". If the unique already + exists, the base item will be given instead. WARNING: While checks are done to make sure that an armour ego isn't given to a weapon, a weapon ego to a missile, and so on, and @@ -587,9 +592,9 @@ ITEM: (list of items, separated by comma) missiles, no other checking is done. Thus it is possible to create a demonic weapon of holy wrath or a helmet of running. - Limitations: You can't specify curse status, specificy pluses or - number of charges, force a randart or give fixedarts. You also - can't lay down corpses, skeletons, or chunks. + Limitations: You can't specify specific pluses or number of charges + or force a randart. 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 d462e30f44..bceb9bbda7 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -4381,6 +4381,10 @@ static void _dgn_place_item_explicit(const item_spec &spec, bool adjust_type = true; switch (spec.level) { + case ISPEC_DAMAGED: + case ISPEC_BAD: + level = spec.level; + break; case ISPEC_GOOD: level = 5 + level * 2; break; diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index 29f9e8e6da..361c46b88e 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -1531,7 +1531,22 @@ static void _generate_weapon_item(item_def& item, bool allow_uniques, _weapon_add_racial_modifiers(item); - if ((force_good || is_demonic(item) || forced_ego + if (item_level < 0) + { + // thoroughly damaged, could had been good once + if (!no_brand && (forced_ego || one_chance_in(4))) + { + // brand is set as for "good" items + set_item_ego_type(item, OBJ_WEAPONS, + _determine_weapon_brand(item, 2+2*you.your_level)); + } + item.plus -= 1+random2(3); + item.plus2 -= 1+random2(3); + + if (item_level == -5) + do_curse_item(item); + } + else if ((force_good || is_demonic(item) || forced_ego || x_chance_in_y(51 + item_level, 200)) // Nobody would bother enchanting a mundane club. && item.sub_type != WPN_CLUB @@ -2076,7 +2091,21 @@ static void _generate_armour_item(item_def& item, bool allow_uniques, if (no_ego) item.special = SPARM_NORMAL; - if (force_good || forced_ego || item.sub_type == ARM_WIZARD_HAT + if (item_level < 0) + { + // thoroughly damaged, could had been good once + if (!no_ego && (forced_ego || one_chance_in(4))) + { + // brand is set as for "good" items + set_item_ego_type(item, OBJ_ARMOUR, + _determine_armour_ego(item, item.sub_type, 2+2*you.your_level)); + } + item.plus -= 1+random2(3); + + if (item_level == -5) + do_curse_item(item); + } + else if (force_good || forced_ego || item.sub_type == ARM_WIZARD_HAT || x_chance_in_y(51 + item_level, 250)) { // Make a good item... @@ -2746,6 +2775,18 @@ int items( int allow_uniques, // not just true-false, item.quantity = 1; // generally the case + if (force_ego >= SPWPN_START_FIXEDARTS && force_ego <= SPWPN_END_FIXEDARTS) + { + if (get_unique_item_status(OBJ_WEAPONS, force_ego) == UNIQ_NOT_EXISTS) + { + make_item_fixed_artefact(mitm[p], false, force_ego); + return p; + } + // the base item otherwise + item.special = SPWPN_NORMAL; + force_ego = 0; + } + // Determine sub_type accordingly. {dlb} switch (item.base_type) { diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 532161e44c..98e41ce51d 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -33,6 +33,7 @@ REVISION("$Rev$"); #include "monplace.h" #include "mon-util.h" #include "place.h" +#include "randart.h" #include "stuff.h" #include "tags.h" @@ -2843,6 +2844,8 @@ item_spec item_list::parse_single_spec(std::string s) return (result); } + std::string fixed_str = strip_tag_prefix(s, "fixed:"); + if (strip_tag(s, "good_item")) result.level = MAKE_GOOD_ITEM; else @@ -2850,7 +2853,8 @@ item_spec item_list::parse_single_spec(std::string s) int number = strip_number_tag(s, "level:"); if (number != TAG_UNFOUND) { - if (number <= 0 && number != ISPEC_GOOD && number != ISPEC_SUPERB) + if (number <= 0 && number != ISPEC_GOOD && number != ISPEC_SUPERB + && number != ISPEC_DAMAGED && number != ISPEC_BAD) { error = make_stringf("Bad item level: %d", number); return (result); @@ -2860,6 +2864,17 @@ item_spec item_list::parse_single_spec(std::string s) } } + if (s.find("damaged ") == 0) + { + result.level = ISPEC_DAMAGED; + s = s.substr(8); + } + if (s.find("cursed ") == 0) + { + result.level = ISPEC_BAD; // damaged + cursed, actually + s = s.substr(7); + } + if (strip_tag(s, "no_uniq")) result.allow_uniques = 0; if (strip_tag(s, "allow_uniq")) @@ -2932,7 +2947,21 @@ item_spec item_list::parse_single_spec(std::string s) error.clear(); parse_raw_name(s, result); - if (!error.empty() || ego_str.empty()) + if (!error.empty()) + return (result); + + if (!fixed_str.empty()) + { + result.ego = get_fixedart_num(fixed_str.c_str()); + if (result.ego == SPWPN_NORMAL) + { + error = make_stringf("Unknown fixed art: %s", fixed_str.c_str()); + return result; + } + return result; + } + + if (ego_str.empty()) return (result); if (result.base_type != OBJ_WEAPONS diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index ecc27cb47f..6909ff4580 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -408,8 +408,10 @@ private: enum item_spec_type { - ISPEC_GOOD = -2, - ISPEC_SUPERB = -3 + ISPEC_GOOD = -2, + ISPEC_SUPERB = -3, + ISPEC_DAMAGED = -4, + ISPEC_BAD = -5 }; struct item_spec diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc index 66f724c739..78b82ab0c7 100644 --- a/crawl-ref/source/randart.cc +++ b/crawl-ref/source/randart.cc @@ -1817,6 +1817,18 @@ static const char* _get_fixedart_name(const item_def &item) return (item_type_known(item) ? "Unnamed Artefact" : "buggy fixedart"); } +int get_fixedart_num( const char *name ) +{ + for (unsigned int i = 0; i < ARRAYSZ(fixedarts); ++i) + { + std::string art = fixedarts[i].name; + lowercase(art); + if (replace_all(art, " ", "_") == name) + return fixedarts[i].which; + } + return SPWPN_NORMAL; +} + // which == 0 (default) gives random fixed artefact. // Returns true if successful. bool make_item_fixed_artefact( item_def &item, bool in_abyss, int which ) diff --git a/crawl-ref/source/randart.h b/crawl-ref/source/randart.h index 0cacf2b3bf..cdc65e57c6 100644 --- a/crawl-ref/source/randart.h +++ b/crawl-ref/source/randart.h @@ -124,4 +124,9 @@ void randart_set_properties( item_def &item, void randart_set_property( item_def &item, randart_prop_type prop, int val ); + +/* *********************************************************************** + * called from: mapdef + * *********************************************************************** */ +int get_fixedart_num( const char *name ); #endif -- cgit v1.2.3-54-g00ecf