summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-22 09:21:32 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-22 09:21:32 +0000
commitfaa6d08c428ad8280f84707fa8d4586440b98631 (patch)
tree9efc32b7df06c6ecc579766f5b0a7ab24c4a73d1
parentcce90fadce5dca04e3000cf488e619975bddd8ae (diff)
downloadcrawl-ref-faa6d08c428ad8280f84707fa8d4586440b98631.tar.gz
crawl-ref-faa6d08c428ad8280f84707fa8d4586440b98631.zip
Added additional optional parameter to item_def::name(), ignore_flags,
which will cause the name to be constructed as if those item flags had been unset. Give an auxiliary cause of death for a stat going below 1. (Death by stat loss is already pretty rare, and death by stat loss with confusion as to what caused the stat loss must be *really* rare, but still, if you were confused about what caused the stat loss that lead to death, that'd be pretty frustrating) ouch() is now called from within modify_stat() and lose_stat() right after the stat is lowered, rather than when the stat is updated on the screen. This incidentally fixes the minor annoyance of saying "no" to stat loss death in wizard mode, only to be asked if you want to die every time the screen is updated until you fix having a non-positive stat. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2179 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/acr.cc2
-rw-r--r--crawl-ref/source/decks.cc2
-rw-r--r--crawl-ref/source/delay.cc6
-rw-r--r--crawl-ref/source/effects.cc99
-rw-r--r--crawl-ref/source/effects.h14
-rw-r--r--crawl-ref/source/externs.h10
-rw-r--r--crawl-ref/source/fight.cc6
-rw-r--r--crawl-ref/source/hiscores.cc33
-rw-r--r--crawl-ref/source/it_use2.cc24
-rw-r--r--crawl-ref/source/it_use3.cc4
-rw-r--r--crawl-ref/source/item_use.cc18
-rw-r--r--crawl-ref/source/itemname.cc37
-rw-r--r--crawl-ref/source/items.cc4
-rw-r--r--crawl-ref/source/misc.cc2
-rw-r--r--crawl-ref/source/monstuff.cc11
-rw-r--r--crawl-ref/source/mutation.cc68
-rw-r--r--crawl-ref/source/output.cc9
-rw-r--r--crawl-ref/source/player.cc165
-rw-r--r--crawl-ref/source/player.h12
-rw-r--r--crawl-ref/source/religion.cc6
-rw-r--r--crawl-ref/source/spells2.cc6
-rw-r--r--crawl-ref/source/spells4.cc6
-rw-r--r--crawl-ref/source/spl-cast.cc15
-rw-r--r--crawl-ref/source/transfor.cc54
-rw-r--r--crawl-ref/source/xom.cc3
25 files changed, 442 insertions, 174 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 392cf51b65..348b0a10d1 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -2391,7 +2391,7 @@ static void decrement_durations()
dec_haste_player();
if (decrement_a_duration(DUR_MIGHT, "You feel a little less mighty now."))
- modify_stat(STAT_STRENGTH, -5, true);
+ modify_stat(STAT_STRENGTH, -5, true, "might running out");
if (decrement_a_duration(DUR_BERSERKER, "You are no longer berserk."))
{
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 38ec142228..a842f49be6 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -1354,7 +1354,7 @@ void card_effect(card_type which_card, deck_rarity_type rarity)
case CARD_WILD_MAGIC:
// yes, high power is bad here
miscast_effect( SPTYP_RANDOM, random2(power/15) + 5,
- random2(power), 0 );
+ random2(power), 0, "a card of wild magic" );
break;
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index b84c8107ac..845c0bd7f0 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -746,15 +746,15 @@ static void armour_wear_effects(const int item_slot)
break;
case SPARM_STRENGTH:
- modify_stat(STAT_STRENGTH, 3, false);
+ modify_stat(STAT_STRENGTH, 3, false, arm);
break;
case SPARM_DEXTERITY:
- modify_stat(STAT_DEXTERITY, 3, false);
+ modify_stat(STAT_DEXTERITY, 3, false, arm);
break;
case SPARM_INTELLIGENCE:
- modify_stat(STAT_INTELLIGENCE, 3, false);
+ modify_stat(STAT_INTELLIGENCE, 3, false, arm);
break;
case SPARM_PONDEROUSNESS:
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 604e3f852a..5a0922f7af 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -194,13 +194,16 @@ bool forget_spell(void)
// use player::decrease_stats() instead iff:
// (a) player_sust_abil() should not factor in; and
// (b) there is no floor to the final stat values {dlb}
-bool lose_stat(unsigned char which_stat, unsigned char stat_loss, bool force)
+bool lose_stat(unsigned char which_stat, unsigned char stat_loss, bool force,
+ const char *cause, bool see_source)
{
bool statLowered = false; // must initialize to false {dlb}
char *ptr_stat = NULL;
bool *ptr_redraw = NULL;
char newValue = 0; // holds new value, for comparison to old {dlb}
+ kill_method_type kill_type = NUM_KILLBY;
+
// begin outputing message: {dlb}
std::string msg = "You feel ";
@@ -211,21 +214,24 @@ bool lose_stat(unsigned char which_stat, unsigned char stat_loss, bool force)
switch (which_stat)
{
case STAT_STRENGTH:
- msg += "weakened";
- ptr_stat = &you.strength;
+ msg += "weakened";
+ ptr_stat = &you.strength;
ptr_redraw = &you.redraw_strength;
+ kill_type = KILLED_BY_WEAKNESS;
break;
case STAT_DEXTERITY:
- msg += "clumsy";
- ptr_stat = &you.dex;
+ msg += "clumsy";
+ ptr_stat = &you.dex;
ptr_redraw = &you.redraw_dexterity;
+ kill_type = KILLED_BY_CLUMSINESS;
break;
case STAT_INTELLIGENCE:
- msg += "dopey";
- ptr_stat = &you.intel;
+ msg += "dopey";
+ ptr_stat = &you.intel;
ptr_redraw = &you.redraw_intelligence;
+ kill_type = KILLED_BY_STUPIDITY;
break;
}
@@ -237,10 +243,6 @@ bool lose_stat(unsigned char which_stat, unsigned char stat_loss, bool force)
// newValue is current value less modifier: {dlb}
newValue = *ptr_stat - stat_loss;
- // XXX: Death by stat loss is currently handled in the redraw code. -- bwr
- if (newValue < 0)
- newValue = 0;
-
// conceivable that stat was already *at* three
// or stat_loss zeroed by player_sust_abil(): {dlb}
//
@@ -269,13 +271,85 @@ bool lose_stat(unsigned char which_stat, unsigned char stat_loss, bool force)
msg += ".";
mpr(msg.c_str());
+ if (newValue < 1)
+ {
+ if (cause == NULL)
+ ouch(INSTANT_DEATH, 0, kill_type);
+ else
+ ouch(INSTANT_DEATH, 0, kill_type, cause, see_source);
+ }
+
+
return (statLowered);
} // end lose_stat()
+bool lose_stat(unsigned char which_stat, unsigned char stat_loss, bool force,
+ const std::string cause, bool see_source)
+{
+ return lose_stat(which_stat, stat_loss, force, cause.c_str(), see_source);
+}
+
+bool lose_stat(unsigned char which_stat, unsigned char stat_loss,
+ const monsters* cause, bool force)
+{
+ if (cause == NULL || invalid_monster(cause))
+ return lose_stat(which_stat, stat_loss, force, NULL, true);
+
+ bool vis = mons_near(cause) && player_monster_visible(cause);
+ std::string name = cause->name(DESC_NOCAP_A, true);
+
+ if (cause->has_ench(ENCH_SHAPESHIFTER))
+ name += " (shapeshifter)";
+ else if (cause->has_ench(ENCH_GLOWING_SHAPESHIFTER))
+ name += " (glowing shapeshifter)";
+
+ return lose_stat(which_stat, stat_loss, force, name, vis);
+}
+
+bool lose_stat(unsigned char which_stat, unsigned char stat_loss,
+ const item_def &cause, bool removed, bool force)
+{
+ std::string name = cause.name(DESC_NOCAP_THE, false, true, false, false,
+ ISFLAG_KNOW_CURSE | ISFLAG_KNOW_PLUSES);
+ std::string verb;
+
+ switch(cause.base_type)
+ {
+ case OBJ_ARMOUR:
+ case OBJ_JEWELLERY:
+ if (removed)
+ verb = "removing";
+ else
+ verb = "wearing";
+ break;
+
+ case OBJ_WEAPONS:
+ case OBJ_STAVES:
+ if (removed)
+ verb = "unwielding";
+ else
+ verb = "wielding";
+ break;
+
+ case OBJ_WANDS: verb = "zapping"; break;
+ case OBJ_FOOD: verb = "eating"; break;
+ case OBJ_SCROLLS: verb = "reading"; break;
+ case OBJ_POTIONS: verb = "drinking"; break;
+ default: verb = "using";
+ }
+
+ return lose_stat(which_stat, stat_loss, force, verb + " " + name, true);
+}
+
void direct_effect(struct bolt &pbolt)
{
int damage_taken = 0;
+ monsters* source = NULL;
+
+ if (pbolt.beam_source != NON_MONSTER)
+ source = &menv[pbolt.beam_source];
+
switch (pbolt.type)
{
case DMNBM_HELLFIRE:
@@ -304,7 +378,8 @@ void direct_effect(struct bolt &pbolt)
case DMNBM_BRAIN_FEED:
// lose_stat() must come last {dlb}
- if (one_chance_in(3) && lose_stat(STAT_INTELLIGENCE, 1))
+ if (one_chance_in(3) &&
+ lose_stat(STAT_INTELLIGENCE, 1, source))
{
mpr("Something feeds on your intellect!");
xom_is_stimulated(50);
diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h
index 0ed6b8371e..3c3d741816 100644
--- a/crawl-ref/source/effects.h
+++ b/crawl-ref/source/effects.h
@@ -18,6 +18,10 @@
struct bolt;
+class monsters;
+class item_def;
+
+
// last updated 12may2000 {dlb}
/* ***********************************************************************
* called from: ability - acr - beam - decks - fight - religion - spells
@@ -38,7 +42,15 @@ bool forget_spell(void);
* spells2 - spells4
* *********************************************************************** */
bool lose_stat(unsigned char which_stat, unsigned char stat_loss,
- bool force = false);
+ bool force = false, const std::string cause = "",
+ bool see_source = true);
+bool lose_stat(unsigned char which_stat, unsigned char stat_loss,
+ bool force = false, const char* cause = NULL,
+ bool see_source = true);
+bool lose_stat(unsigned char which_stat, unsigned char stat_loss,
+ const monsters* cause, bool force = false);
+bool lose_stat(unsigned char which_stat, unsigned char stat_loss,
+ const item_def &cause, bool removed, bool force = false);
// last updated 12may2000 {dlb}
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 526bf96b92..09104bd3d2 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -124,7 +124,7 @@ public:
virtual void confuse(int strength) = 0;
virtual void rot(actor *attacker, int rotlevel, int immediate_rot) = 0;
virtual void expose_to_element(beam_type element, int strength = 0) = 0;
- virtual void drain_stat(int stat, int amount) { }
+ virtual void drain_stat(int stat, int amount, actor* attacker) { }
virtual bool wearing_light_armour(bool = false) const { return (true); }
virtual int skill(skill_type sk, bool skill_bump = false) const
@@ -354,7 +354,8 @@ public:
std::string name(description_level_type descrip,
bool terse = false, bool ident = false,
bool with_inscription = true,
- bool quantity_in_words = false) const;
+ bool quantity_in_words = false,
+ unsigned long ignore_flags = 0x0) const;
bool has_spells() const;
bool cursed() const;
int book_number() const;
@@ -371,7 +372,8 @@ public:
}
private:
std::string name_aux( description_level_type desc,
- bool terse, bool ident ) const;
+ bool terse, bool ident,
+ unsigned long ignore_flags ) const;
};
class runrest
@@ -742,7 +744,7 @@ public:
void banish(const std::string &who = "");
void blink();
void teleport(bool right_now = false, bool abyss_shift = false);
- void drain_stat(int stat, int amount);
+ void drain_stat(int stat, int amount, actor* attacker);
void expose_to_element(beam_type element, int strength = 0);
void god_conduct(conduct_type thing_done, int level);
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index ccc022ddb7..6b500c2af4 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -3056,7 +3056,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
{
defender->poison( attacker, roll_dice(1,3) );
if (one_chance_in(4))
- defender->drain_stat( STAT_STRENGTH, 1 );
+ defender->drain_stat( STAT_STRENGTH, 1, attacker );
}
break;
@@ -3148,7 +3148,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
if ((one_chance_in(20) || (damage_done > 0 && one_chance_in(3)))
&& defender->res_negative_energy() < random2(4))
{
- defender->drain_stat(STAT_STRENGTH, 1);
+ defender->drain_stat(STAT_STRENGTH, 1, attacker);
}
break;
@@ -3156,7 +3156,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk)
if ((one_chance_in(20) || (damage_done > 0 && one_chance_in(3)))
&& defender->res_negative_energy() < random2(4))
{
- defender->drain_stat(STAT_DEXTERITY, 1);
+ defender->drain_stat(STAT_DEXTERITY, 1, attacker);
}
break;
diff --git a/crawl-ref/source/hiscores.cc b/crawl-ref/source/hiscores.cc
index ffd64530a1..830fa9f0f4 100644
--- a/crawl-ref/source/hiscores.cc
+++ b/crawl-ref/source/hiscores.cc
@@ -842,6 +842,14 @@ void scorefile_entry::init_death_cause(int dam, int dsrc,
mon_num = 0;
death_source_name[0] = 0;
}
+
+ if (death_type == KILLED_BY_WEAKNESS
+ || death_type == KILLED_BY_STUPIDITY
+ || death_type == KILLED_BY_CLUMSINESS)
+ {
+ if (auxkilldata == "")
+ auxkilldata = "unknown source";
+ }
}
void scorefile_entry::reset()
@@ -1622,6 +1630,31 @@ scorefile_entry::death_description(death_desc_verbosity verbosity) const
break;
} // end switch
+ switch (death_type)
+ {
+ case KILLED_BY_STUPIDITY:
+ case KILLED_BY_WEAKNESS:
+ case KILLED_BY_CLUMSINESS:
+ if (terse)
+ {
+ desc += " (";
+ desc += auxkilldata;
+ desc += ")";
+ }
+ else
+ {
+ desc += "\n";
+ desc += " ";
+ desc += "... caused by ";
+ desc += auxkilldata;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+
if (oneline && desc.length() > 2)
desc[1] = tolower(desc[1]);
diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc
index cd805455fc..d370aae720 100644
--- a/crawl-ref/source/it_use2.cc
+++ b/crawl-ref/source/it_use2.cc
@@ -109,7 +109,7 @@ bool potion_effect( potion_type pot_eff, int pow )
if ( were_mighty )
contaminate_player(1);
else
- modify_stat(STAT_STRENGTH, 5, true);
+ modify_stat(STAT_STRENGTH, 5, true, "");
// conceivable max gain of +184 {dlb}
you.duration[DUR_MIGHT] += 35 + random2(pow);
@@ -215,7 +215,8 @@ bool potion_effect( potion_type pot_eff, int pow )
case POT_DEGENERATION:
mpr("There was something very wrong with that liquid!");
- if (lose_stat(STAT_RANDOM, 1 + random2avg(4, 2)))
+ if (lose_stat(STAT_RANDOM, 1 + random2avg(4, 2), false,
+ "drinking a potion of degeneration"))
xom_is_stimulated(64);
break;
@@ -500,7 +501,9 @@ void unwear_armour(char unw)
you.redraw_armour_class = 1;
you.redraw_evasion = 1;
- switch (get_armour_ego_type( you.inv[unw] ))
+ item_def &item(you.inv[unw]);
+
+ switch (get_armour_ego_type( item ))
{
case SPARM_RUNNING:
mpr("You feel rather sluggish.");
@@ -530,15 +533,15 @@ void unwear_armour(char unw)
break;
case SPARM_STRENGTH:
- modify_stat(STAT_STRENGTH, -3, false);
+ modify_stat(STAT_STRENGTH, -3, false, item, true);
break;
case SPARM_DEXTERITY:
- modify_stat(STAT_DEXTERITY, -3, false);
+ modify_stat(STAT_DEXTERITY, -3, false, item, true);
break;
case SPARM_INTELLIGENCE:
- modify_stat(STAT_INTELLIGENCE, -3, false);
+ modify_stat(STAT_INTELLIGENCE, -3, false, item, true);
break;
case SPARM_PONDEROUSNESS:
@@ -621,9 +624,12 @@ void unuse_randart(const item_def &item)
}
// modify ability scores, always output messages
- modify_stat( STAT_STRENGTH, -proprt[RAP_STRENGTH], false );
- modify_stat( STAT_INTELLIGENCE, -proprt[RAP_INTELLIGENCE], false );
- modify_stat( STAT_DEXTERITY, -proprt[RAP_DEXTERITY], false );
+ modify_stat( STAT_STRENGTH, -proprt[RAP_STRENGTH], false, item,
+ true);
+ modify_stat( STAT_INTELLIGENCE, -proprt[RAP_INTELLIGENCE], false, item,
+ true);
+ modify_stat( STAT_DEXTERITY, -proprt[RAP_DEXTERITY], false, item,
+ true);
if (proprt[RAP_NOISES] != 0)
you.special_wield = SPWLD_NONE;
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index ac3c5f10e5..9ee69e8f87 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -755,7 +755,7 @@ static bool ball_of_seeing(void)
if (use < 2)
{
- lose_stat( STAT_INTELLIGENCE, 1 );
+ lose_stat( STAT_INTELLIGENCE, 1, false, "using a ball of seeing");
}
else if (use < 5 && enough_mp(1, true))
{
@@ -1050,7 +1050,7 @@ static bool ball_of_energy(void)
if (use < 2 || you.max_magic_points == 0)
{
- lose_stat(STAT_INTELLIGENCE, 1);
+ lose_stat(STAT_INTELLIGENCE, 1, false, "using a ball of energy");
}
else if ((use < 4 && enough_mp(1, true))
|| you.magic_points == you.max_magic_points)
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 242358acbe..060b994f5b 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -2335,19 +2335,19 @@ void jewellery_wear_effects(item_def &item)
break;
case RING_STRENGTH:
- modify_stat(STAT_STRENGTH, item.plus, !artefact);
+ modify_stat(STAT_STRENGTH, item.plus, !artefact, item);
if (item.plus != 0 && !artefact)
ident = ID_KNOWN_TYPE;
break;
case RING_DEXTERITY:
- modify_stat(STAT_DEXTERITY, item.plus, !artefact);
+ modify_stat(STAT_DEXTERITY, item.plus, !artefact, item);
if (item.plus != 0 && !artefact)
ident = ID_KNOWN_TYPE;
break;
case RING_INTELLIGENCE:
- modify_stat(STAT_INTELLIGENCE, item.plus, !artefact);
+ modify_stat(STAT_INTELLIGENCE, item.plus, !artefact, item);
if (item.plus != 0 && !artefact)
ident = ID_KNOWN_TYPE;
break;
@@ -2646,15 +2646,15 @@ void jewellery_remove_effects(item_def &item)
break;
case RING_STRENGTH:
- modify_stat(STAT_STRENGTH, -item.plus, true);
+ modify_stat(STAT_STRENGTH, -item.plus, true, item, true);
break;
case RING_DEXTERITY:
- modify_stat(STAT_DEXTERITY, -item.plus, true);
+ modify_stat(STAT_DEXTERITY, -item.plus, true, item, true);
break;
case RING_INTELLIGENCE:
- modify_stat(STAT_INTELLIGENCE, -item.plus, true);
+ modify_stat(STAT_INTELLIGENCE, -item.plus, true, item, true);
break;
case RING_INVISIBILITY:
@@ -3964,9 +3964,9 @@ void use_randart(const item_def &item)
// modify ability scores
// output result even when identified (because of potential fatality)
- modify_stat( STAT_STRENGTH, proprt[RAP_STRENGTH], false );
- modify_stat( STAT_INTELLIGENCE, proprt[RAP_INTELLIGENCE], false );
- modify_stat( STAT_DEXTERITY, proprt[RAP_DEXTERITY], false );
+ modify_stat( STAT_STRENGTH, proprt[RAP_STRENGTH], false, item );
+ modify_stat( STAT_INTELLIGENCE, proprt[RAP_INTELLIGENCE], false, item );
+ modify_stat( STAT_DEXTERITY, proprt[RAP_DEXTERITY], false, item );
// For evokable stuff, check whether other equipped items yield
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 783951d8b9..79f8a34fe4 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -73,11 +73,13 @@ std::string quant_name( const item_def &item, int quant,
std::string item_def::name(description_level_type descrip,
bool terse, bool ident,
bool with_inscription,
- bool quantity_words) const
+ bool quantity_words,
+ unsigned long ignore_flags) const
{
std::ostringstream buff;
- const std::string auxname = this->name_aux(descrip, terse, ident);
+ const std::string auxname = this->name_aux(descrip, terse, ident,
+ ignore_flags);
const bool startvowel = is_vowel(auxname[0]);
if (descrip == DESC_INVENTORY_EQUIP || descrip == DESC_INVENTORY)
@@ -943,7 +945,8 @@ static void output_with_sign(std::ostream& os, int val)
// Note that "terse" is only currently used for the "in hand" listing on
// the game screen.
std::string item_def::name_aux( description_level_type desc,
- bool terse, bool ident ) const
+ bool terse, bool ident,
+ unsigned long ignore_flags) const
{
// Shortcuts
const int item_typ = this->sub_type;
@@ -954,14 +957,20 @@ std::string item_def::name_aux( description_level_type desc,
const bool qualname = desc == DESC_QUALNAME;
const bool know_curse =
- !basename && !qualname
+ !basename && !qualname && !testbits(ignore_flags, ISFLAG_KNOW_CURSE)
&& (ident || item_ident(*this, ISFLAG_KNOW_CURSE));
const bool know_type = ident || item_type_known(*this);
- const bool know_pluses =
+ const bool __know_pluses =
!basename && !qualname
&& (ident || item_ident(*this, ISFLAG_KNOW_PLUSES));
+ const bool know_cosmetic = !__know_pluses && !terse & !basename;
+
+ // So that know_cosmetic won't be affected by ignore_flags
+ const bool know_pluses = __know_pluses
+ && !testbits(ignore_flags, ISFLAG_KNOW_PLUSES);
+
bool need_plural = true;
int brand;
@@ -1012,15 +1021,17 @@ std::string item_def::name_aux( description_level_type desc,
// Now that we can have "glowing elven" weapons, it's
// probably a good idea to cut out the descriptive
// term once it's become obsolete. -- bwr
- if (!know_pluses && !terse && !basename)
+ if (know_cosmetic)
{
switch (get_equip_desc( *this ))
{
case ISFLAG_RUNED:
- buff << "runed ";
+ if (!testbits(ignore_flags, ISFLAG_RUNED))
+ buff << "runed ";
break;
case ISFLAG_GLOWING:
- buff << "glowing ";
+ if (!testbits(ignore_flags, ISFLAG_GLOWING))
+ buff << "glowing ";
break;
}
}
@@ -1117,11 +1128,13 @@ std::string item_def::name_aux( description_level_type desc,
// Now that we can have "glowing elven" armour, it's
// probably a good idea to cut out the descriptive
// term once it's become obsolete. -- bwr
- if (!know_pluses && !terse & !basename)
+ if (know_cosmetic)
{
switch (get_equip_desc( *this ))
{
case ISFLAG_EMBROIDERED_SHINY:
+ if (testbits(ignore_flags, ISFLAG_EMBROIDERED_SHINY))
+ break;
if (item_typ == ARM_ROBE || item_typ == ARM_CLOAK
|| item_typ == ARM_GLOVES || item_typ == ARM_BOOTS)
{
@@ -1135,11 +1148,13 @@ std::string item_def::name_aux( description_level_type desc,
break;
case ISFLAG_RUNED:
- buff << "runed ";
+ if (!testbits(ignore_flags, ISFLAG_RUNED))
+ buff << "runed ";
break;
case ISFLAG_GLOWING:
- buff << "glowing ";
+ if (!testbits(ignore_flags, ISFLAG_GLOWING))
+ buff << "glowing ";
break;
}
}
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index a54882e3d0..94212b9335 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2367,7 +2367,7 @@ void handle_time( long time_delta )
if (one_chance_in(30))
{
mpr("Your disease is taking its toll.", MSGCH_WARN);
- lose_stat(STAT_RANDOM, 1);
+ lose_stat(STAT_RANDOM, 1, false, "disease");
}
}
@@ -2375,7 +2375,7 @@ void handle_time( long time_delta )
if (you.mutation[MUT_DETERIORATION]
&& random2(200) <= you.mutation[MUT_DETERIORATION] * 5 - 2)
{
- lose_stat(STAT_RANDOM, 1);
+ lose_stat(STAT_RANDOM, 1, false, "deterioration mutation");
}
int added_contamination = 0;
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index aa3c39638c..92d886787a 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -1241,7 +1241,7 @@ bool go_berserk(bool intentional)
deflate_hp(you.hp_max, false);
if (!you.duration[DUR_MIGHT])
- modify_stat( STAT_STRENGTH, 5, true );
+ modify_stat( STAT_STRENGTH, 5, true, "going berserk" );
you.duration[DUR_MIGHT] += you.duration[DUR_BERSERKER];
haste_player( you.duration[DUR_BERSERKER] );
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index a84cced78c..69c624511f 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2954,15 +2954,14 @@ static bool handle_wand(monsters *monster, bolt &beem)
beem.is_beam = theBeam.is_beam;
beem.is_explosion = theBeam.is_explosion;
- unsigned long old_flags = wand.flags;
#if HISCORE_WEAPON_DETAIL
- set_ident_flags( wand, ISFLAG_IDENT_MASK );
+ beem.aux_source =
+ wand.name(DESC_QUALNAME, false, true, false, false);
#else
- unset_ident_flags( wand, ISFLAG_IDENT_MASK );
- set_ident_flags( wand, ISFLAG_KNOW_TYPE );
+ beem.aux_source =
+ wand.name(DESC_QUALNAME, false, true, false, false,
+ ISFLAG_KNOW_CURSE | ISFLAG_KNOW_PLUSES);
#endif
- beem.aux_source = wand.name(DESC_PLAIN);
- wand.flags = old_flags;
const int wand_type = wand.sub_type;
switch (wand_type)
diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc
index fe617537f4..fab48702d4 100644
--- a/crawl-ref/source/mutation.cc
+++ b/crawl-ref/source/mutation.cc
@@ -1313,7 +1313,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
mpr( "Your body decomposes!", MSGCH_MUTATION );
if (coinflip())
- lose_stat( STAT_RANDOM, 1 );
+ lose_stat( STAT_RANDOM, 1 , false, "mutating");
else
{
ouch( 3, 0, KILLED_BY_ROTTING );
@@ -1498,7 +1498,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
return true;
}
// replaces earlier, redundant code - 12mar2000 {dlb}
- modify_stat(STAT_STRENGTH, 1, false);
+ modify_stat(STAT_STRENGTH, 1, false, "gaining a mutation");
break;
case MUT_CLEVER:
@@ -1508,7 +1508,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
return true;
}
// replaces earlier, redundant code - 12mar2000 {dlb}
- modify_stat(STAT_INTELLIGENCE, 1, false);
+ modify_stat(STAT_INTELLIGENCE, 1, false, "gaining a mutation");
break;
case MUT_AGILE:
@@ -1518,7 +1518,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
return true;
}
// replaces earlier, redundant code - 12mar2000 {dlb}
- modify_stat(STAT_DEXTERITY, 1, false);
+ modify_stat(STAT_DEXTERITY, 1, false, "gaining a mutation");
break;
case MUT_WEAK:
@@ -1527,7 +1527,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
delete_mutation(MUT_STRONG);
return true;
}
- modify_stat(STAT_STRENGTH, -1, true);
+ modify_stat(STAT_STRENGTH, -1, true, "gaining a mutation");
mpr(gain_mutation[mutat][0], MSGCH_MUTATION);
break;
@@ -1537,7 +1537,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
delete_mutation(MUT_CLEVER);
return true;
}
- modify_stat(STAT_INTELLIGENCE, -1, true);
+ modify_stat(STAT_INTELLIGENCE, -1, true, "gaining a mutation");
mpr(gain_mutation[mutat][0], MSGCH_MUTATION);
break;
@@ -1547,7 +1547,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
delete_mutation(MUT_AGILE);
return true;
}
- modify_stat(STAT_DEXTERITY, -1, true);
+ modify_stat(STAT_DEXTERITY, -1, true, "gaining a mutation");
mpr(gain_mutation[mutat][0], MSGCH_MUTATION);
break;
@@ -1661,8 +1661,8 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
delete_mutation(MUT_FLEXIBLE_WEAK);
return true;
}
- modify_stat(STAT_STRENGTH, 1, true);
- modify_stat(STAT_DEXTERITY, -1, true);
+ modify_stat(STAT_STRENGTH, 1, true, "gaining a mutation");
+ modify_stat(STAT_DEXTERITY, -1, true, "gaining a mutation");
mpr(gain_mutation[mutat][0], MSGCH_MUTATION);
break;
@@ -1672,8 +1672,8 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
delete_mutation(MUT_STRONG_STIFF);
return true;
}
- modify_stat(STAT_STRENGTH, -1, true);
- modify_stat(STAT_DEXTERITY, 1, true);
+ modify_stat(STAT_STRENGTH, -1, true, "gaining a mutation");
+ modify_stat(STAT_DEXTERITY, 1, true, "gaining a mutation");
mpr(gain_mutation[mutat][0], MSGCH_MUTATION);
break;
@@ -1705,7 +1705,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
case MUT_BLACK_SCALES:
case MUT_BONEY_PLATES:
- modify_stat(STAT_DEXTERITY, -1, true);
+ modify_stat(STAT_DEXTERITY, -1, true, "gaining a mutation");
// deliberate fall-through
default:
mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION);
@@ -1713,16 +1713,16 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
case MUT_GREY2_SCALES:
if (you.mutation[mutat] != 1)
- modify_stat(STAT_DEXTERITY, -1, true);
+ modify_stat(STAT_DEXTERITY, -1, true, "gaining a mutation");
mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION);
break;
case MUT_METALLIC_SCALES:
if (you.mutation[mutat] == 0)
- modify_stat(STAT_DEXTERITY, -2, true);
+ modify_stat(STAT_DEXTERITY, -2, true, "gaining a mutation");
else
- modify_stat(STAT_DEXTERITY, -1, true);
+ modify_stat(STAT_DEXTERITY, -1, true, "gaining a mutation");
mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION);
break;
@@ -1730,7 +1730,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
case MUT_RED2_SCALES:
case MUT_YELLOW_SCALES:
if (you.mutation[mutat] != 0)
- modify_stat(STAT_DEXTERITY, -1, true);
+ modify_stat(STAT_DEXTERITY, -1, true, "gaining a mutation");
mpr(gain_mutation[mutat][you.mutation[mutat]], MSGCH_MUTATION);
break;
@@ -1814,31 +1814,31 @@ bool delete_mutation(mutation_type which_mutation, bool force)
switch (mutat)
{
case MUT_STRONG:
- modify_stat(STAT_STRENGTH, -1, true);
+ modify_stat(STAT_STRENGTH, -1, true, "losing a mutation");
mpr(lose_mutation[mutat][0], MSGCH_MUTATION);
break;
case MUT_CLEVER:
- modify_stat(STAT_INTELLIGENCE, -1, true);
+ modify_stat(STAT_INTELLIGENCE, -1, true, "losing a mutation");
mpr(lose_mutation[mutat][0], MSGCH_MUTATION);
break;
case MUT_AGILE:
- modify_stat(STAT_DEXTERITY, -1, true);
+ modify_stat(STAT_DEXTERITY, -1, true, "losing a mutation");
mpr(lose_mutation[mutat][0], MSGCH_MUTATION);
break;
case MUT_WEAK:
- modify_stat(STAT_STRENGTH, 1, false);
+ modify_stat(STAT_STRENGTH, 1, false, "losing a mutation");
break;
case MUT_DOPEY:
- modify_stat(STAT_INTELLIGENCE, 1, false);
+ modify_stat(STAT_INTELLIGENCE, 1, false, "losing a mutation");
break;
case MUT_CLUMSY:
// replaces earlier, redundant code - 12mar2000 {dlb}
- modify_stat(STAT_DEXTERITY, 1, false);
+ modify_stat(STAT_DEXTERITY, 1, false, "losing a mutation");
break;
case MUT_SHOCK_RESISTANCE:
@@ -1858,14 +1858,14 @@ bool delete_mutation(mutation_type which_mutation, bool force)
break;
case MUT_STRONG_STIFF:
- modify_stat(STAT_STRENGTH, -1, true);
- modify_stat(STAT_DEXTERITY, 1, true);
+ modify_stat(STAT_STRENGTH, -1, true, "losing a mutation");
+ modify_stat(STAT_DEXTERITY, 1, true, "losing a mutation");
mpr(lose_mutation[mutat][0], MSGCH_MUTATION);
break;
case MUT_FLEXIBLE_WEAK:
- modify_stat(STAT_STRENGTH, 1, true);
- modify_stat(STAT_DEXTERITY, -1, true);
+ modify_stat(STAT_STRENGTH, 1, true, "losing a mutation");
+ modify_stat(STAT_DEXTERITY, -1, true, "losing a mutation");
mpr(lose_mutation[mutat][0], MSGCH_MUTATION);
break;
@@ -1889,7 +1889,7 @@ bool delete_mutation(mutation_type which_mutation, bool force)
case MUT_BLACK_SCALES:
case MUT_BONEY_PLATES:
- modify_stat(STAT_DEXTERITY, 1, true);
+ modify_stat(STAT_DEXTERITY, 1, true, "losing a mutation");
case MUT_CLAWS:
mpr((you.species == SP_TROLL ? troll_claw_lose
@@ -1903,15 +1903,15 @@ bool delete_mutation(mutation_type which_mutation, bool force)
case MUT_GREY2_SCALES:
if (you.mutation[mutat] != 2)
- modify_stat(STAT_DEXTERITY, 1, true);
+ modify_stat(STAT_DEXTERITY, 1, true, "losing a mutation");
mpr(lose_mutation[mutat][you.mutation[mutat] - 1], MSGCH_MUTATION);
break;
case MUT_METALLIC_SCALES:
if (you.mutation[mutat] == 1)
- modify_stat(STAT_DEXTERITY, 2, true);
+ modify_stat(STAT_DEXTERITY, 2, true, "losing a mutation");
else
- modify_stat(STAT_DEXTERITY, 1, true);
+ modify_stat(STAT_DEXTERITY, 1, true, "losing a mutation");
mpr(lose_mutation[mutat][you.mutation[mutat] - 1], MSGCH_MUTATION);
break;
@@ -1919,7 +1919,7 @@ bool delete_mutation(mutation_type which_mutation, bool force)
case MUT_RED2_SCALES:
case MUT_YELLOW_SCALES:
if (you.mutation[mutat] != 1)
- modify_stat(STAT_DEXTERITY, 1, true);
+ modify_stat(STAT_DEXTERITY, 1, true, "losing a mutation");
mpr(lose_mutation[mutat][you.mutation[mutat] - 1], MSGCH_MUTATION);
break;
@@ -2331,9 +2331,9 @@ void demonspawn(void)
{
/* unlikely but remotely possible */
/* I know this is a cop-out */
- modify_stat(STAT_STRENGTH, 1, true);
- modify_stat(STAT_INTELLIGENCE, 1, true);
- modify_stat(STAT_DEXTERITY, 1, true);
+ modify_stat(STAT_STRENGTH, 1, true, "demonspawn mutation");
+ modify_stat(STAT_INTELLIGENCE, 1, true, "demonspawn mutation");
+ modify_stat(STAT_DEXTERITY, 1, true, "demonspawn mutation");
mpr("You feel much better now.", MSGCH_INTRINSIC_GAIN);
}
} // end demonspawn()
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 7910a27c87..8ec664b0b7 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -198,9 +198,6 @@ void print_stats(void)
you.redraw_strength = 0;
- if (you.strength < 1)
- ouch(INSTANT_DEATH, 0, KILLED_BY_WEAKNESS);
-
burden_change();
}
@@ -228,9 +225,6 @@ void print_stats(void)
cprintf( " " );
you.redraw_intelligence = 0;
-
- if (you.intel < 1)
- ouch(INSTANT_DEATH, 0, KILLED_BY_STUPIDITY);
}
if (you.redraw_dexterity)
@@ -257,9 +251,6 @@ void print_stats(void)
cprintf( " " );
you.redraw_dexterity = 0;
-
- if (you.dex < 1)
- ouch(INSTANT_DEATH, 0, KILLED_BY_CLUMSINESS);
}
if (you.redraw_armour_class)
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 5f33f10c4d..54bafb69a9 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -2546,7 +2546,7 @@ void level_change(bool skip_ability_increase)
{
case SP_HUMAN:
if (!(you.experience_level % 5))
- modify_stat(STAT_RANDOM, 1, false);
+ modify_stat(STAT_RANDOM, 1, false, "level gain");
break;
case SP_HIGH_ELF:
@@ -2565,7 +2565,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 3))
{
modify_stat( (coinflip() ? STAT_INTELLIGENCE
- : STAT_DEXTERITY), 1, false );
+ : STAT_DEXTERITY), 1, false,
+ "level gain");
}
break;
@@ -2586,7 +2587,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 4))
{
modify_stat( (coinflip() ? STAT_INTELLIGENCE
- : STAT_DEXTERITY), 1, false );
+ : STAT_DEXTERITY), 1, false,
+ "level gain");
}
break;
@@ -2600,7 +2602,7 @@ void level_change(bool skip_ability_increase)
mp_adjust++;
if (!(you.experience_level % 4))
- modify_stat(STAT_INTELLIGENCE, 1, false);
+ modify_stat(STAT_INTELLIGENCE, 1, false, "level gain");
break;
case SP_SLUDGE_ELF:
@@ -2612,7 +2614,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 4))
{
modify_stat( (coinflip() ? STAT_INTELLIGENCE
- : STAT_DEXTERITY), 1, false );
+ : STAT_DEXTERITY), 1, false,
+ "level gain");
}
break;
@@ -2628,12 +2631,12 @@ void level_change(bool skip_ability_increase)
mp_adjust--;
if (!(you.experience_level % 4))
- modify_stat(STAT_STRENGTH, 1, false);
+ modify_stat(STAT_STRENGTH, 1, false, "level gain");
break;
case SP_HALFLING:
if (!(you.experience_level % 5))
- modify_stat(STAT_DEXTERITY, 1, false);
+ modify_stat(STAT_DEXTERITY, 1, false, "level gain");
if (you.experience_level < 17)
hp_adjust--;
@@ -2646,7 +2649,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 5))
{
modify_stat( (coinflip() ? STAT_STRENGTH
- : STAT_DEXTERITY), 1, false );
+ : STAT_DEXTERITY), 1, false,
+ "level gain");
}
if (you.experience_level < 17)
@@ -2668,7 +2672,7 @@ void level_change(bool skip_ability_increase)
mp_adjust--;
if (!(you.experience_level % 5))
- modify_stat(STAT_STRENGTH, 1, false);
+ modify_stat(STAT_STRENGTH, 1, false, "level gain");
break;
case SP_MUMMY:
@@ -2704,7 +2708,7 @@ void level_change(bool skip_ability_increase)
hp_adjust++;
if (!(you.experience_level % 4))
- modify_stat(STAT_RANDOM, 1, false);
+ modify_stat(STAT_RANDOM, 1, false, "level gain");
if (!(you.experience_level % 3))
{
@@ -2723,7 +2727,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 4))
{
modify_stat( (coinflip() ? STAT_INTELLIGENCE
- : STAT_DEXTERITY), 1, false );
+ : STAT_DEXTERITY), 1, false,
+ "level gain");
}
break;
@@ -2742,7 +2747,7 @@ void level_change(bool skip_ability_increase)
mp_adjust--;
if (!(you.experience_level % 3))
- modify_stat(STAT_STRENGTH, 1, false);
+ modify_stat(STAT_STRENGTH, 1, false, "level gain");
break;
case SP_OGRE_MAGE:
@@ -2755,7 +2760,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 5))
{
modify_stat( (coinflip() ? STAT_INTELLIGENCE
- : STAT_STRENGTH), 1, false );
+ : STAT_STRENGTH), 1, false,
+ "level gain");
}
break;
@@ -2843,7 +2849,7 @@ void level_change(bool skip_ability_increase)
{
mpr("Your scales feel tougher.", MSGCH_INTRINSIC_GAIN);
you.redraw_armour_class = 1;
- modify_stat(STAT_RANDOM, 1, false);
+ modify_stat(STAT_RANDOM, 1, false, "level gain");
}
break;
@@ -2871,7 +2877,7 @@ void level_change(bool skip_ability_increase)
if ((you.experience_level > 7 && !(you.experience_level % 3))
|| you.experience_level == 4 || you.experience_level == 7)
{
- modify_stat(STAT_RANDOM, 1, false);
+ modify_stat(STAT_RANDOM, 1, false, "level gain");
}
break;
@@ -2879,7 +2885,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 4))
{
modify_stat( (coinflip() ? STAT_DEXTERITY
- : STAT_STRENGTH), 1, false );
+ : STAT_STRENGTH), 1, false,
+ "level gain");
}
// lowered because of HD raise -- bwr
@@ -2895,7 +2902,7 @@ void level_change(bool skip_ability_increase)
case SP_DEMIGOD:
if (!(you.experience_level % 3))
- modify_stat(STAT_RANDOM, 1, false);
+ modify_stat(STAT_RANDOM, 1, false, "level gain");
// lowered because of HD raise -- bwr
// if (you.experience_level < 17)
@@ -2920,7 +2927,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 5))
{
modify_stat( (coinflip() ? STAT_INTELLIGENCE
- : STAT_DEXTERITY), 1, false );
+ : STAT_DEXTERITY), 1, false,
+ "level gain");
}
break;
@@ -2938,7 +2946,8 @@ void level_change(bool skip_ability_increase)
if (!(you.experience_level % 4))
{
modify_stat( (coinflip() ? STAT_DEXTERITY
- : STAT_STRENGTH), 1, false );
+ : STAT_STRENGTH), 1, false,
+ "level gain");
}
break;
@@ -2989,7 +2998,7 @@ void level_change(bool skip_ability_increase)
}
if (!(you.experience_level % 4))
- modify_stat(STAT_RANDOM, 1, false);
+ modify_stat(STAT_RANDOM, 1, false, "level gain");
break;
case SP_GHOUL:
@@ -3004,7 +3013,7 @@ void level_change(bool skip_ability_increase)
mp_adjust--;
if (!(you.experience_level % 5))
- modify_stat(STAT_STRENGTH, 1, false);
+ modify_stat(STAT_STRENGTH, 1, false, "level gain");
break;
case SP_KENKU:
@@ -3015,7 +3024,7 @@ void level_change(bool skip_ability_increase)
hp_adjust--;
if (!(you.experience_level % 4))
- modify_stat(STAT_RANDOM, 1, false);
+ modify_stat(STAT_RANDOM, 1, false, "level gain");
if (you.experience_level == 5)
mpr("You have gained the ability to fly.", MSGCH_INTRINSIC_GAIN);
@@ -3035,7 +3044,7 @@ void level_change(bool skip_ability_increase)
hp_adjust++;
if (!(you.experience_level % 5))
- modify_stat(STAT_RANDOM, 1, false);
+ modify_stat(STAT_RANDOM, 1, false, "level gain");
break;
default:
@@ -3210,17 +3219,17 @@ void ability_increase(void)
{
case 's':
case 'S':
- modify_stat(STAT_STRENGTH, 1, false);
+ modify_stat(STAT_STRENGTH, 1, false, "level gain");
return;
case 'i':
case 'I':
- modify_stat(STAT_INTELLIGENCE, 1, false);
+ modify_stat(STAT_INTELLIGENCE, 1, false, "level gain");
return;
case 'd':
case 'D':
- modify_stat(STAT_DEXTERITY, 1, false);
+ modify_stat(STAT_DEXTERITY, 1, false, "level gain");
return;
}
}
@@ -4058,12 +4067,14 @@ int scan_randarts(char which_property, bool calc_unid)
return (retval);
} // end scan_randarts()
-void modify_stat(stat_type which_stat, char amount, bool suppress_msg)
+void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
+ const char *cause, bool see_source)
{
char *ptr_stat = NULL;
char *ptr_stat_max = NULL;
bool *ptr_redraw = NULL;
+ kill_method_type kill_type = NUM_KILLBY;
// sanity - is non-zero amount?
if (amount == 0)
@@ -4081,23 +4092,26 @@ void modify_stat(stat_type which_stat, char amount, bool suppress_msg)
switch (which_stat)
{
case STAT_STRENGTH:
- ptr_stat = &you.strength;
+ ptr_stat = &you.strength;
ptr_stat_max = &you.max_strength;
- ptr_redraw = &you.redraw_strength;
+ ptr_redraw = &you.redraw_strength;
+ kill_type = KILLED_BY_WEAKNESS;
msg += ((amount > 0) ? "stronger." : "weaker.");
break;
case STAT_DEXTERITY:
- ptr_stat = &you.dex;
+ ptr_stat = &you.dex;
ptr_stat_max = &you.max_dex;
- ptr_redraw = &you.redraw_dexterity;
+ ptr_redraw = &you.redraw_dexterity;
+ kill_type = KILLED_BY_CLUMSINESS;
msg += ((amount > 0) ? "agile." : "clumsy.");
break;
case STAT_INTELLIGENCE:
- ptr_stat = &you.intel;
+ ptr_stat = &you.intel;
ptr_stat_max = &you.max_intel;
- ptr_redraw = &you.redraw_intelligence;
+ ptr_redraw = &you.redraw_intelligence;
+ kill_type = KILLED_BY_STUPIDITY;
msg += ((amount > 0) ? "clever." : "stupid.");
break;
@@ -4108,9 +4122,17 @@ void modify_stat(stat_type which_stat, char amount, bool suppress_msg)
if (!suppress_msg && amount != 0)
mpr( msg.c_str(), (amount > 0) ? MSGCH_INTRINSIC_GAIN : MSGCH_WARN );
- *ptr_stat += amount;
+ *ptr_stat += amount;
*ptr_stat_max += amount;
- *ptr_redraw = 1;
+ *ptr_redraw = 1;
+
+ if (amount < 0 && *ptr_stat < 1)
+ {
+ if (cause == NULL)
+ ouch(INSTANT_DEATH, 0, kill_type);
+ else
+ ouch(INSTANT_DEATH, 0, kill_type, cause, see_source);
+ }
if (ptr_stat == &you.strength)
burden_change();
@@ -4118,6 +4140,68 @@ void modify_stat(stat_type which_stat, char amount, bool suppress_msg)
return;
} // end modify_stat()
+void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
+ const std::string cause, bool see_source)
+{
+ modify_stat(which_stat, amount, suppress_msg, cause.c_str(), see_source);
+}
+
+void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
+ const monsters* cause)
+{
+ if (cause == NULL || invalid_monster(cause))
+ {
+ modify_stat(which_stat, amount, suppress_msg, NULL, true);
+ return;
+ }
+
+ bool vis = mons_near(cause) && player_monster_visible(cause);
+ std::string name = cause->name(DESC_NOCAP_A, true);
+
+ if (cause->has_ench(ENCH_SHAPESHIFTER))
+ name += " (shapeshifter)";
+ else if (cause->has_ench(ENCH_GLOWING_SHAPESHIFTER))
+ name += " (glowing shapeshifter)";
+
+ modify_stat(which_stat, amount, suppress_msg, name, vis);
+}
+
+void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
+ const item_def &cause, bool removed)
+{
+ std::string name = cause.name(DESC_NOCAP_THE, false, true, false, false,
+ ISFLAG_KNOW_CURSE | ISFLAG_KNOW_PLUSES);
+ std::string verb;
+
+ switch(cause.base_type)
+ {
+ case OBJ_ARMOUR:
+ case OBJ_JEWELLERY:
+ if (removed)
+ verb = "removing";
+ else
+ verb = "wearing";
+ break;
+
+ case OBJ_WEAPONS:
+ case OBJ_STAVES:
+ if (removed)
+ verb = "unwielding";
+ else
+ verb = "wielding";
+ break;
+
+ case OBJ_WANDS: verb = "zapping"; break;
+ case OBJ_FOOD: verb = "eating"; break;
+ case OBJ_SCROLLS: verb = "reading"; break;
+ case OBJ_POTIONS: verb = "drinking"; break;
+ default: verb = "using";
+ }
+
+ modify_stat(which_stat, amount, suppress_msg,
+ verb + " " + name, true);
+}
+
void dec_hp(int hp_loss, bool fatal, const char *aux)
{
if (!fatal && you.hp < 1)
@@ -5719,9 +5803,16 @@ void player::hurt(const actor *agent, int amount)
}
}
-void player::drain_stat(int stat, int amount)
+void player::drain_stat(int stat, int amount, actor* attacker)
{
- lose_stat(stat, amount);
+ if (attacker == NULL)
+ lose_stat(stat, amount, false, "");
+ else if (attacker->atype() == ACT_MONSTER)
+ lose_stat(stat, amount, dynamic_cast<monsters*>(attacker), false);
+ else if (attacker->atype() == ACT_PLAYER)
+ lose_stat(stat, amount, false, "suicide");
+ else
+ lose_stat(stat, amount, false, "");
}
void player::rot(actor *who, int rotlevel, int immed_rot)
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index d70fd80048..c9e9ba6d99 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -16,6 +16,9 @@
#include "externs.h"
+class monsters;
+class item_def;
+
enum genus_type
{
GENPC_DRACONIAN, // 0
@@ -290,7 +293,14 @@ void gain_exp(unsigned int exp_gained, unsigned int* actual_gain = NULL,
* called from: acr - it_use2 - item_use - mutation - transfor - player -
* misc - stuff
* *********************************************************************** */
-void modify_stat(stat_type which_stat, char amount, bool suppress_msg);
+void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
+ const std::string cause, bool see_source = true);
+void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
+ const char* cause, bool see_source = true);
+void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
+ const monsters* cause);
+void modify_stat(stat_type which_stat, char amount, bool suppress_msg,
+ const item_def &cause, bool removed = false);
// last updated 19may2000 {dlb}
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index cfc721e263..1dd3cb87a3 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -2055,7 +2055,8 @@ static bool trog_retribution()
case 1:
case 2:
- lose_stat(STAT_STRENGTH, 1 + random2(you.strength / 5), true);
+ lose_stat(STAT_STRENGTH, 1 + random2(you.strength / 5), true,
+ "divine retribution from Trog");
break;
case 3:
@@ -2262,7 +2263,8 @@ static bool sif_muna_retribution()
{
case 0:
case 1:
- lose_stat(STAT_INTELLIGENCE, 1 + random2( you.intel / 5 ), true);
+ lose_stat(STAT_INTELLIGENCE, 1 + random2( you.intel / 5 ), true,
+ "divine retribution from Sif Muna");
break;
case 2:
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index e9b9cbd960..36b463a2bb 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -1647,8 +1647,12 @@ void summon_things( int pow )
int numsc = 2 + (random2(pow) / 10) + (random2(pow) / 10);
- if (one_chance_in(3) && !lose_stat( STAT_INTELLIGENCE, 1, true ))
+ if (one_chance_in(3)
+ && !lose_stat( STAT_INTELLIGENCE, 1, true,
+ "summoning horrible things" ))
+ {
mpr("Your call goes unanswered.");
+ }
else
{
numsc = stepdown_value( numsc, 2, 2, 6, -1 );
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 852ca6cb68..4fddf1ddf0 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -1725,8 +1725,12 @@ void cast_intoxicate(int pow)
{
potion_effect( POT_CONFUSION, 10 + (100 - pow) / 10);
- if (one_chance_in(20) && lose_stat( STAT_INTELLIGENCE, 1 + random2(3) ))
+ if (one_chance_in(20)
+ && lose_stat( STAT_INTELLIGENCE, 1 + random2(3), false,
+ "casting intoxication"))
+ {
mpr("Your head spins!");
+ }
apply_area_visible(intoxicate_monsters, pow);
} // end cast_intoxicate()
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 1fa829b87b..31377824bc 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -2550,7 +2550,8 @@ static void miscast_divination(int severity, const char* cause)
case 0:
if (you.is_undead)
mpr("You suddenly recall your previous life!");
- else if (lose_stat(STAT_INTELLIGENCE, 1 + random2(3)))
+ else if (lose_stat(STAT_INTELLIGENCE, 1 + random2(3),
+ false, cause))
mpr("You have damaged your brain!");
else
mpr("You have a terrible headache.");
@@ -2578,7 +2579,8 @@ static void miscast_divination(int severity, const char* cause)
case 2:
if (you.is_undead)
mpr("You suddenly recall your previous life.");
- else if (lose_stat(STAT_INTELLIGENCE, 3 + random2(3)))
+ else if (lose_stat(STAT_INTELLIGENCE, 3 + random2(3),
+ false, cause))
mpr("You have damaged your brain!");
else
mpr("You have a terrible headache.");
@@ -2733,7 +2735,7 @@ static void miscast_necromancy(int severity, const char* cause)
} // otherwise it just flows through...
case 2:
- lose_stat(STAT_RANDOM, 1 + random2avg(7, 2));
+ lose_stat(STAT_RANDOM, 1 + random2avg(7, 2), false, cause);
break;
case 3:
@@ -3428,7 +3430,7 @@ static void miscast_poison(int severity, const char* cause)
if (player_res_poison())
canned_msg(MSG_NOTHING_HAPPENS);
else
- lose_stat(STAT_RANDOM, 1);
+ lose_stat(STAT_RANDOM, 1, false, cause);
break;
}
break;
@@ -3455,7 +3457,7 @@ static void miscast_poison(int severity, const char* cause)
if (player_res_poison())
canned_msg(MSG_NOTHING_HAPPENS);
else
- lose_stat(STAT_RANDOM, 1 + random2avg(5, 2));
+ lose_stat(STAT_RANDOM, 1 + random2avg(5, 2), false, cause);
break;
}
break;
@@ -3482,6 +3484,9 @@ void miscast_effect( unsigned int sp_type, int mag_pow, int mag_fail,
return;
}
+ if (cause == NULL || strlen(cause) == 0)
+ cause = "spell miscasting";
+
sever /= 100;
#if DEBUG_DIAGNOSTICS
diff --git a/crawl-ref/source/transfor.cc b/crawl-ref/source/transfor.cc
index bed7d87ef8..54cf96f70d 100644
--- a/crawl-ref/source/transfor.cc
+++ b/crawl-ref/source/transfor.cc
@@ -205,7 +205,8 @@ bool transform(int pow, transformation_type which_trans)
if (you.duration[DUR_TRANSFORMATION] > 60)
you.duration[DUR_TRANSFORMATION] = 60;
- modify_stat( STAT_DEXTERITY, 5, true );
+ modify_stat( STAT_DEXTERITY, 5, true,
+ "gaining the spider transformation");
you.symbol = 's';
you.colour = BROWN;
@@ -227,8 +228,10 @@ bool transform(int pow, transformation_type which_trans)
if (you.duration[DUR_TRANSFORMATION] > 100)
you.duration[DUR_TRANSFORMATION] = 100;
- modify_stat( STAT_DEXTERITY, 5, true );
- modify_stat( STAT_STRENGTH, -5, true );
+ modify_stat( STAT_DEXTERITY, 5, true,
+ "gaining the bat transformation");
+ modify_stat( STAT_STRENGTH, -5, true,
+ "gaining the bat transformation" );
you.symbol = 'b';
you.colour = DARKGREY;
@@ -303,8 +306,10 @@ bool transform(int pow, transformation_type which_trans)
if (you.duration[ DUR_TRANSFORMATION ] > 100)
you.duration[ DUR_TRANSFORMATION ] = 100;
- modify_stat( STAT_DEXTERITY, -2, true );
- modify_stat( STAT_STRENGTH, 2, true );
+ modify_stat( STAT_DEXTERITY, -2, true,
+ "gaining the statue transformation" );
+ modify_stat( STAT_STRENGTH, 2, true,
+ "gaining the statue transformation");
extra_hp(15); // must occur after attribute set
if (you.duration[DUR_STONEMAIL] || you.duration[DUR_STONESKIN])
@@ -332,7 +337,8 @@ bool transform(int pow, transformation_type which_trans)
if (you.duration[ DUR_TRANSFORMATION ] > 100)
you.duration[ DUR_TRANSFORMATION ] = 100;
- modify_stat( STAT_STRENGTH, 10, true );
+ modify_stat( STAT_STRENGTH, 10, true,
+ "gaining the dragon transformation" );
extra_hp(16); // must occur after attribute set
you.symbol = 'D';
@@ -378,7 +384,8 @@ bool transform(int pow, transformation_type which_trans)
if (you.duration[ DUR_TRANSFORMATION ] > 100)
you.duration[ DUR_TRANSFORMATION ] = 100;
- modify_stat( STAT_STRENGTH, 3, true );
+ modify_stat( STAT_STRENGTH, 3, true,
+ "gaining the lich transformation" );
you.symbol = 'L';
you.colour = LIGHTGREY;
you.is_undead = US_UNDEAD;
@@ -408,7 +415,8 @@ bool transform(int pow, transformation_type which_trans)
if (you.duration[ DUR_TRANSFORMATION ] > 150)
you.duration[ DUR_TRANSFORMATION ] = 150;
- modify_stat( STAT_DEXTERITY, 8, true );
+ modify_stat( STAT_DEXTERITY, 8, true,
+ "gaining the air transformation" );
you.symbol = '#';
you.colour = DARKGREY;
@@ -437,7 +445,8 @@ bool transform(int pow, transformation_type which_trans)
if (you.duration[ DUR_TRANSFORMATION ] > 120)
you.duration[ DUR_TRANSFORMATION ] = 120;
- modify_stat( STAT_STRENGTH, 13, true );
+ modify_stat( STAT_STRENGTH, 13, true,
+ "gaining the Serpent of Hell transformation");
extra_hp(17); // must occur after attribute set
you.symbol = 'S';
@@ -479,13 +488,16 @@ void untransform(void)
{
case TRAN_SPIDER:
mpr("Your transformation has ended.", MSGCH_DURATION);
- modify_stat( STAT_DEXTERITY, -5, true );
+ modify_stat( STAT_DEXTERITY, -5, true,
+ "losing the spider transformation" );
break;
case TRAN_BAT:
mpr("Your transformation has ended.", MSGCH_DURATION);
- modify_stat( STAT_DEXTERITY, -5, true );
- modify_stat( STAT_STRENGTH, 5, true );
+ modify_stat( STAT_DEXTERITY, -5, true,
+ "losing the bat transformation" );
+ modify_stat( STAT_STRENGTH, 5, true,
+ "losing the bat transformation" );
break;
case TRAN_BLADE_HANDS:
@@ -495,8 +507,10 @@ void untransform(void)
case TRAN_STATUE:
mpr( "You revert to your normal fleshy form.", MSGCH_DURATION );
- modify_stat( STAT_DEXTERITY, 2, true );
- modify_stat( STAT_STRENGTH, -2, true );
+ modify_stat( STAT_DEXTERITY, 2, true,
+ "losing the statue transformation" );
+ modify_stat( STAT_STRENGTH, -2, true,
+ "losing the statue transformation");
// Note: if the core goes down, the combined effect soon disappears,
// but the reverse isn't true. -- bwr
@@ -524,7 +538,8 @@ void untransform(void)
case TRAN_DRAGON:
mpr( "Your transformation has ended.", MSGCH_DURATION );
- modify_stat(STAT_STRENGTH, -10, true);
+ modify_stat(STAT_STRENGTH, -10, true,
+ "losing the dragon transformation" );
// re-check terrain now that be may no longer be flying.
move_player_to_grid( you.x_pos, you.y_pos, false, true, true );
@@ -535,18 +550,21 @@ void untransform(void)
case TRAN_LICH:
mpr( "You feel yourself come back to life.", MSGCH_DURATION );
- modify_stat(STAT_STRENGTH, -3, true);
+ modify_stat(STAT_STRENGTH, -3, true,
+ "losing the lich transformation" );
you.is_undead = US_ALIVE;
break;
case TRAN_AIR:
mpr( "Your body solidifies.", MSGCH_DURATION );
- modify_stat(STAT_DEXTERITY, -8, true);
+ modify_stat(STAT_DEXTERITY, -8, true,
+ "losing the air transformation");
break;
case TRAN_SERPENT_OF_HELL:
mpr( "Your transformation has ended.", MSGCH_DURATION );
- modify_stat(STAT_STRENGTH, -13, true);
+ modify_stat(STAT_STRENGTH, -13, true,
+ "losing the Serpent of Hell transformation");
hp_downscale = 17;
break;
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 096dc27117..7a51f3eda0 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -633,7 +633,8 @@ static bool xom_is_bad(int sever)
(temp_rand == 2) ? "Xom's power touches on you for a moment."
: "You hear Xom's maniacal laughter.");
- lose_stat(STAT_RANDOM, 1 + random2(3), true);
+ lose_stat(STAT_RANDOM, 1 + random2(3), true,
+ "the capriciousness of Xom" );
done = true;
}