summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/describe.cc124
-rw-r--r--crawl-ref/source/randart.cc125
-rw-r--r--crawl-ref/source/randart.h3
3 files changed, 242 insertions, 10 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 25f9928145..f045567659 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -161,11 +161,11 @@ struct property_descriptors
int spell_out; // 0: "+3", 1: "+++", 2: value doesn't matter
};
-static std::string randart_auto_inscription( const item_def& item )
+static std::vector<std::string> randart_propnames( const item_def& item )
{
randart_properties_t proprt;
randart_known_props_t known;
- randart_desc_properties( item, proprt, known );
+ randart_desc_properties( item, proprt, known, true );
std::vector<std::string> propnames;
@@ -182,7 +182,7 @@ static std::string randart_auto_inscription( const item_def& item )
{ "RE", RAP_ELECTRICITY, 1 },
{ "RP", RAP_POISON, 1 },
{ "RN", RAP_NEGATIVE_ENERGY, 1 },
- { "MP", RAP_MAGICAL_POWER, 1 },
+ { "MP", RAP_MAGICAL_POWER, 0 },
{ "MR", RAP_MAGIC, 2 },
{ "SInv", RAP_EYESIGHT, 2 },
{ "Stl", RAP_STEALTH, 2 },
@@ -202,6 +202,80 @@ static std::string randart_auto_inscription( const item_def& item )
{ "Map", RAP_MAPPING, 2 },
};
+ // For randart jewellry, note the base jewelery type if it's not
+ // covered by randart_desc_properties()
+ if (item.base_type == OBJ_JEWELLERY
+ && item_ident( item, ISFLAG_KNOW_PROPERTIES ))
+ {
+ std::string type = "";
+
+ switch(item.sub_type)
+ {
+ case RING_REGENERATION:
+ type = "Regen";
+ break;
+
+ case RING_SUSTAIN_ABILITIES:
+ type = "SustAbil";
+ break;
+
+ case RING_SUSTENANCE:
+ type = "Susten";
+ break;
+
+ case RING_WIZARDRY:
+ type = "Wiz";
+ break;
+
+ case RING_FIRE:
+ type = "F-Mag";
+ break;
+
+ case RING_ICE:
+ type = "I-Mag";
+ break;
+
+ case RING_TELEPORT_CONTROL:
+ type = "T-Cont";
+ break;
+
+ case AMU_RESIST_SLOW:
+ type = "RSlow";
+ break;
+
+ case AMU_CLARITY:
+ type = "Clar";
+ break;
+
+ case AMU_WARDING:
+ type = "Ward";
+ break;
+
+ case AMU_RESIST_CORROSION:
+ type = "RAcid";
+ break;
+
+ case AMU_THE_GOURMAND:
+ type = "Gourm";
+ break;
+
+ case AMU_CONSERVATION:
+ type = "Conserv";
+ break;
+
+ case AMU_CONTROLLED_FLIGHT:
+ type = "C-Fly";
+ break;
+
+ case AMU_RESIST_MUTATION:
+ type = "RMut";
+ break;
+ }
+ if (type != "")
+ propnames.push_back(type);
+ }
+
+
for ( unsigned i = 0; i < ARRAYSIZE(propdescs); ++i )
{
if (known_proprt(propdescs[i].prop))
@@ -211,7 +285,7 @@ static std::string randart_auto_inscription( const item_def& item )
switch ( propdescs[i].spell_out )
{
case 0:
- work << std::ios::showpos << val << ' ' << propdescs[i].name;
+ work << val << ' ' << propdescs[i].name;
break;
case 1:
{
@@ -227,11 +301,39 @@ static std::string randart_auto_inscription( const item_def& item )
propnames.push_back(work.str());
}
}
+
+ return propnames;
+}
+
+static std::string randart_auto_inscription( const item_def& item )
+{
+ std::vector<std::string> propnames = randart_propnames(item);
+
return comma_separated_line(propnames.begin(), propnames.end(),
", ", ", ");
-
}
+// Remove randart auto-inscription. Do it once for each property
+// string, rather than the return value of randart_auto_inscription(),
+// in case more information about the randart has been learned since
+// the last auto-inscription.
+static void trim_randart_inscrip( item_def& item )
+{
+ std::vector<std::string> propnames = randart_propnames(item);
+
+ for (unsigned int i = 0, size = propnames.size(); i < size; i++)
+ {
+ std::string prop = propnames[i] + ",";
+ item.inscription = replace_all(item.inscription, prop, "");
+
+ prop = propnames[i];
+ item.inscription = replace_all(item.inscription, prop, "");
+ }
+
+ trim_string(item.inscription);
+}
+
+
static std::string randart_descrip( const item_def &item )
{
std::string description;
@@ -3602,8 +3704,9 @@ void describe_item( item_def &item, bool allow_inscribe )
// when we don't need to.
const bool allow_autoinscribe =
is_random_artefact(item) &&
- item_ident(item, ISFLAG_KNOW_PROPERTIES) &&
- (item.inscription != randart_auto_inscription(item));
+ (randart_auto_inscription(item) != "") &&
+ (item.inscription.find(randart_auto_inscription(item))
+ == std::string::npos);
if ( allow_autoinscribe )
{
@@ -3627,7 +3730,14 @@ void describe_item( item_def &item, bool allow_inscribe )
item.inscription = buf;
}
else if (toupper(keyin) == 'A' && allow_autoinscribe)
+ {
+ // Remove previous randart inscription
+ trim_randart_inscrip(item);
+
+ if (item.inscription != "")
+ item.inscription += " ";
item.inscription += randart_auto_inscription(item);
+ }
}
else if (getch() == 0)
getch();
diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc
index 20d2de175b..933495d422 100644
--- a/crawl-ref/source/randart.cc
+++ b/crawl-ref/source/randart.cc
@@ -883,11 +883,12 @@ static long calc_seed( const item_def &item )
void randart_desc_properties( const item_def &item,
randart_properties_t &proprt,
- randart_known_props_t &known )
+ randart_known_props_t &known,
+ bool force_fake_props)
{
randart_wpn_properties( item, proprt, known);
- if ( item_ident( item, ISFLAG_KNOW_PROPERTIES ) )
+ if ( !force_fake_props && item_ident( item, ISFLAG_KNOW_PROPERTIES ) )
return;
if (item.base_type != OBJ_JEWELLERY)
@@ -896,6 +897,11 @@ void randart_desc_properties( const item_def &item,
randart_prop_type fake_rap = RAP_NUM_PROPERTIES;
int fake_plus = 1;
+ // The base jewelery type is one whose property is revealed by
+ // wearing it, but whose property isn't revealed by having
+ // ISFLAG_KNOW_PLUSES set. For a randart with a base type of, for
+ // example, a ring of strength, wearing it sets
+ // ISFLAG_KNOW_PLUSES, which reveals the ring's strength plus.
switch (item.sub_type)
{
case RING_INVISIBILITY:
@@ -921,7 +927,122 @@ void randart_desc_properties( const item_def &item,
}
if (fake_rap != RAP_NUM_PROPERTIES)
+ {
proprt[fake_rap] += fake_plus;
+
+ if (item_ident( item, ISFLAG_KNOW_PROPERTIES )
+ || item_ident( item, ISFLAG_KNOW_TYPE ))
+ {
+ known[fake_rap] = true;
+ }
+
+ return;
+ }
+
+ if (!force_fake_props)
+ return;
+
+ // For auto-inscribing randart jewellry, force_fake_props folds as
+ // much info about the base type as possible into the randarts
+ // property struct.
+
+ randart_prop_type fake_rap2 = RAP_NUM_PROPERTIES;
+ int fake_plus2 = 1;
+
+ switch (item.sub_type)
+ {
+ case RING_PROTECTION:
+ fake_rap = RAP_AC;
+ fake_plus = item.plus;
+ break;
+
+ case RING_PROTECTION_FROM_FIRE:
+ fake_rap = RAP_FIRE;
+ break;
+
+ case RING_POISON_RESISTANCE:
+ fake_rap = RAP_POISON;
+ break;
+
+ case RING_PROTECTION_FROM_COLD:
+ fake_rap = RAP_COLD;
+ break;
+
+ case RING_STRENGTH:
+ fake_rap = RAP_STRENGTH;
+ break;
+
+ case RING_SLAYING:
+ fake_rap = RAP_ACCURACY;
+ fake_plus = item.plus;
+ fake_rap2 = RAP_DAMAGE;
+ fake_plus2 = item.plus2;
+ break;
+
+ case RING_SEE_INVISIBLE:
+ fake_rap = RAP_EYESIGHT;
+ break;
+
+ case RING_HUNGER:
+ fake_rap = RAP_METABOLISM;
+ break;
+
+ case RING_EVASION:
+ fake_rap = RAP_EVASION;
+ fake_plus = item.plus;
+ break;
+
+ case RING_DEXTERITY:
+ fake_rap = RAP_DEXTERITY;
+ fake_plus = item.plus;
+ break;
+
+ case RING_INTELLIGENCE:
+ fake_rap = RAP_INTELLIGENCE;
+ fake_plus = item.plus;
+ break;
+
+ case RING_LIFE_PROTECTION:
+ fake_rap = RAP_NEGATIVE_ENERGY;
+ break;
+
+ case RING_PROTECTION_FROM_MAGIC:
+ fake_rap = RAP_MAGIC;
+ break;
+
+ case RING_FIRE:
+ fake_rap = RAP_FIRE;
+ fake_rap2 = RAP_COLD;
+ fake_plus2 = -1;
+ break;
+
+ case RING_ICE:
+ fake_rap = RAP_COLD;
+ fake_rap2 = RAP_FIRE;
+ fake_plus2 = -1;
+ break;
+
+ case AMU_INACCURACY:
+ fake_rap = RAP_ACCURACY;
+ fake_plus = -5;
+ break;
+ }
+
+ if (fake_rap != RAP_NUM_PROPERTIES)
+ proprt[fake_rap] += fake_plus;
+
+ if (fake_rap2 != RAP_NUM_PROPERTIES)
+ proprt[fake_rap2] += fake_plus2;
+
+ if (item_ident( item, ISFLAG_KNOW_PROPERTIES )
+ || item_ident( item, ISFLAG_KNOW_TYPE ))
+ {
+ if (fake_rap != RAP_NUM_PROPERTIES && proprt[fake_rap] != 0)
+ known[fake_rap] = true;
+
+ if (fake_rap2 != RAP_NUM_PROPERTIES && proprt[fake_rap2] != 0)
+ known[fake_rap2] = true;
+ }
}
static int randart_add_one_property( const item_def &item,
diff --git a/crawl-ref/source/randart.h b/crawl-ref/source/randart.h
index 74d7905aed..dc07310a03 100644
--- a/crawl-ref/source/randart.h
+++ b/crawl-ref/source/randart.h
@@ -67,7 +67,8 @@ typedef FixedVector< bool, RA_PROPERTIES > randart_known_props_t;
* *********************************************************************** */
void randart_desc_properties( const item_def &item,
randart_properties_t &proprt,
- randart_known_props_t &known );
+ randart_known_props_t &known,
+ bool force_fake_props = false);
void randart_wpn_properties( const item_def &item,
randart_properties_t &proprt,