summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/item_use.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-10 03:43:21 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-10 03:43:21 +0000
commit936f2a18fa5079cf5f5dac8277ace09848784843 (patch)
tree2a46bdba2cf6ba4e9b20b7f8805d290a74135d67 /crawl-ref/source/item_use.cc
parent3b3bb038d36521c1eb95b4dfd1b54ca14cef308f (diff)
downloadcrawl-ref-936f2a18fa5079cf5f5dac8277ace09848784843.tar.gz
crawl-ref-936f2a18fa5079cf5f5dac8277ace09848784843.zip
Remember and describe randart properties which have been learned via
wearing the randart. Breaks savefile compatibility for saved games containing any randarts. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2403 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r--crawl-ref/source/item_use.cc58
1 files changed, 40 insertions, 18 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index aeca7119d9..ea900bd501 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -3945,35 +3945,39 @@ void use_randart(unsigned char item_wield_2)
use_randart( you.inv[ item_wield_2 ] );
}
-void use_randart(const item_def &item)
+void use_randart(item_def &item)
{
+#define unknown_proprt(prop) (proprt[(prop)] && !known[(prop)])
+
ASSERT( is_random_artefact( item ) );
const bool alreadyknown = item_type_known(item);
const bool dangerous = player_in_a_dangerous_place();
- const bool ident = fully_identified(item);
- randart_properties_t proprt;
- randart_wpn_properties( item, proprt );
+ randart_properties_t proprt;
+ randart_known_props_t known;
+ randart_wpn_properties( item, proprt, known );
- // Give messages for stat changes, possibly only if !identified
+ // Only give property messages for previously unknown properties.
if (proprt[RAP_AC])
{
you.redraw_armour_class = 1;
- if (!ident)
+ if (!known[RAP_AC])
{
mprf("You feel %s.", proprt[RAP_AC] > 0?
"well-protected" : "more vulnerable");
+ randart_wpn_learn_prop(item, RAP_AC);
}
}
if (proprt[RAP_EVASION])
{
you.redraw_evasion = 1;
- if (!ident)
+ if (!known[RAP_EVASION])
{
mprf("You feel somewhat %s.", proprt[RAP_EVASION] > 0?
"nimbler" : "more awkward");
+ randart_wpn_learn_prop(item, RAP_EVASION);
}
}
@@ -3983,24 +3987,41 @@ void use_randart(const item_def &item)
modify_stat( STAT_INTELLIGENCE, proprt[RAP_INTELLIGENCE], false, item );
modify_stat( STAT_DEXTERITY, proprt[RAP_DEXTERITY], false, item );
+ int stat_props[3] = {RAP_STRENGTH, RAP_INTELLIGENCE, RAP_DEXTERITY};
+ for (int i = 0; i < 3; i++)
+ if (unknown_proprt(stat_props[i]))
+ randart_wpn_learn_prop(item, stat_props[i]);
// For evokable stuff, check whether other equipped items yield
- // the same ability. If not, give a message.
- // Do NOT give all these messages if the randart is identified.
- if (!ident)
+ // the same ability. If not, and if the ability granted hasn't
+ // already been discovered, give a message.
+ if (unknown_proprt(RAP_LEVITATE)
+ && !items_give_ability(item.link, RAP_LEVITATE))
{
- if (proprt[RAP_LEVITATE] && !items_give_ability(item.link, RAP_LEVITATE))
- mpr("You feel buoyant.");
+ mpr("You feel buoyant.");
+ randart_wpn_learn_prop(item, RAP_LEVITATE);
+ }
- if (proprt[RAP_INVISIBLE] && !you.duration[DUR_INVIS])
- mpr("You become transparent for a moment.");
+ if (unknown_proprt(RAP_INVISIBLE) && !you.duration[DUR_INVIS])
+ {
+ mpr("You become transparent for a moment.");
+ randart_wpn_learn_prop(item, RAP_INVISIBLE);
+ }
- if (proprt[RAP_CAN_TELEPORT] && !items_give_ability(item.link, RAP_CAN_TELEPORT))
- mpr("You feel slightly jumpy.");
+ if (unknown_proprt(RAP_CAN_TELEPORT)
+ && !items_give_ability(item.link, RAP_CAN_TELEPORT))
+ {
+ mpr("You feel slightly jumpy.");
+ randart_wpn_learn_prop(item, RAP_CAN_TELEPORT);
+ }
- if (proprt[RAP_BERSERK] && !items_give_ability(item.link, RAP_BERSERK))
- mpr("You feel a brief urge to hack something to bits.");
+ if (unknown_proprt(RAP_BERSERK)
+ && !items_give_ability(item.link, RAP_BERSERK))
+ {
+ mpr("You feel a brief urge to hack something to bits.");
+ randart_wpn_learn_prop(item, RAP_BERSERK);
}
+
if (proprt[RAP_NOISES])
you.special_wield = SPWLD_NOISE;
@@ -4010,6 +4031,7 @@ void use_randart(const item_def &item)
// there is a dangerous monster nearby...
xom_is_stimulated(255);
}
+#undef unknown_proprt
}
bool wearing_slot(int inv_slot)