summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-22 18:36:03 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-22 18:36:03 +0000
commit752b66f301b0bfbc911f3c7f42fcef1d64f7d9ed (patch)
tree0941572143127178147551f551d751e442f2b295 /crawl-ref/source
parent461b3e21bdc62c92c0237ac61960489771579fbb (diff)
downloadcrawl-ref-752b66f301b0bfbc911f3c7f42fcef1d64f7d9ed.tar.gz
crawl-ref-752b66f301b0bfbc911f3c7f42fcef1d64f7d9ed.zip
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
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/dungeon.cc4
-rw-r--r--crawl-ref/source/makeitem.cc45
-rw-r--r--crawl-ref/source/mapdef.cc33
-rw-r--r--crawl-ref/source/mapdef.h6
-rw-r--r--crawl-ref/source/randart.cc12
-rw-r--r--crawl-ref/source/randart.h5
6 files changed, 99 insertions, 6 deletions
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