summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-22 07:16:50 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-22 07:16:50 +0000
commit96a447410eabfc50aadc628f4ce27c6cbc4b2353 (patch)
tree5e6359d364498b76683a5ce500846c8685b5d263
parent60d6f32de9c98c67fc5735eede1e08dcf4d3deda (diff)
downloadcrawl-ref-96a447410eabfc50aadc628f4ce27c6cbc4b2353.tar.gz
crawl-ref-96a447410eabfc50aadc628f4ce27c6cbc4b2353.zip
Condensed monster descriptions.
This has two effecs: 1. Monster name and equipment are combined in one line, and enchantments are condensed as well. 2. It's now "The monster wielding a foo comes into view." git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2024 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/beam.cc5
-rw-r--r--crawl-ref/source/delay.cc7
-rw-r--r--crawl-ref/source/direct.cc251
-rw-r--r--crawl-ref/source/direct.h1
-rw-r--r--crawl-ref/source/externs.h2
-rw-r--r--crawl-ref/source/fight.cc3
-rw-r--r--crawl-ref/source/mon-util.cc2
-rw-r--r--crawl-ref/source/monstuff.cc2
-rw-r--r--crawl-ref/source/monstuff.h2
-rw-r--r--crawl-ref/source/spells1.cc5
-rw-r--r--crawl-ref/source/spells2.cc3
-rw-r--r--crawl-ref/source/spells3.cc5
-rw-r--r--crawl-ref/source/spells4.cc5
13 files changed, 179 insertions, 114 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index fac5d51e27..2176e67b6b 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -3731,7 +3731,10 @@ static int affect_monster(bolt &beam, monsters *mon)
else
{
if (thrower == KILL_YOU_MISSILE && mons_near(mon))
- print_wounds(mon);
+ {
+ const monsters *mons = static_cast<const monsters*>(mon);
+ print_wounds(mons);
+ }
// sticky flame
if (beam.name == "sticky flame")
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index abbeadd299..d83e93118b 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -994,8 +994,11 @@ inline static void monster_warning(activity_interrupt_type ai,
return;
#ifndef DEBUG_DIAGNOSTICS
if (at.context != "uncharm")
- mprf(MSGCH_WARN, "%s comes into view.",
- mon->name(DESC_CAP_A).c_str());
+ {
+ std::string text = get_monster_desc(mon, false);
+ text += " comes into view.";
+ print_formatted_paragraph(text, get_number_of_cols(), MSGCH_WARN);
+ }
if (Options.tutorial_left)
{
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 7d7598cf0e..c436f44323 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -1512,72 +1512,55 @@ std::string feature_description(int mx, int my, description_level_type dtype,
}
}
-static void describe_mons_enchantment(const monsters &mons,
- const mon_enchant &ench,
- bool paralysed)
+static std::string describe_mons_enchantment(const monsters &mons,
+ const mon_enchant &ench,
+ bool paralysed)
{
// Suppress silly-looking combinations, even if they're
// internally valid.
if (paralysed && (ench.ench == ENCH_SLOW || ench.ench == ENCH_HASTE))
- return;
+ return "";
if (ench.ench == ENCH_HASTE && mons.has_ench(ENCH_BERSERK))
- return;
-
- std::string msg = mons_pronoun(mons.type, PRONOUN_CAP);
+ return "";
switch (ench.ench)
{
case ENCH_POISON:
- msg += " is poisoned.";
- break;
+ return "poisoned";
case ENCH_SICK:
- msg += " is sick.";
- break;
+ return "sick";
case ENCH_ROT:
- msg += " is rotting away."; //jmf: "covered in sores"?
- break;
+ return "rotting away"; //jmf: "covered in sores"?
case ENCH_BACKLIGHT:
- msg += " is softly glowing.";
- break;
+ return "softly glowing";
case ENCH_SLOW:
- msg += " is moving slowly.";
- break;
+ return "moving slowly";
case ENCH_BERSERK:
- msg += " is berserk!";
- break;
+ return "berserk";
case ENCH_HASTE:
- msg += " is moving very quickly.";
- break;
+ return "moving very quickly";
case ENCH_CONFUSION:
- msg += " appears to be bewildered and confused.";
- break;
+ return "bewildered and confused";
case ENCH_INVIS:
- msg += " is slightly transparent.";
- break;
+ return "slightly transparent";
case ENCH_CHARM:
- msg += " is in your thrall.";
- break;
+ return "in your thrall";
case ENCH_STICKY_FLAME:
- msg += " is covered in liquid flames.";
- break;
+ return "covered in liquid flames";
case ENCH_CAUGHT:
- msg += " is entangled in a net.";
- break;
+ return "entangled in a net";
default:
- msg.clear();
- break;
+ return "";
} // end switch
-
- if (!msg.empty())
- mpr(msg.c_str());
}
-static void describe_monster_weapon(monsters *mons)
+static std::string describe_monster_weapon(const monsters *mons)
{
+ std::string desc = "";
std::string name1, name2;
- const item_def *weap = mons->mslot_item(MSLOT_WEAPON),
- *alt = mons->mslot_item(MSLOT_ALT_WEAPON);
+ const item_def *weap = mons->mslot_item(MSLOT_WEAPON);
+ const item_def *alt = mons->mslot_item(MSLOT_ALT_WEAPON);
if (weap)
name1 = weap->name(DESC_NOCAP_A);
@@ -1596,20 +1579,22 @@ static void describe_monster_weapon(monsters *mons)
}
if (name1.empty())
- return;
+ return (desc);
- std::ostringstream msg;
- msg << mons_pronoun( mons->type, PRONOUN_CAP )
- << " is wielding " << name1;
+ desc += " wielding ";
+ desc += name1;
if (!name2.empty())
- msg << " and " << name2;
-
- msg << ".";
+ {
+ desc += " and ";
+ desc += name2;
+ }
- mpr(msg.str().c_str());
+ return (desc);
}
+
+
#ifdef DEBUG_DIAGNOSTICS
static std::string stair_destination_description(const coord_def &pos)
{
@@ -1625,6 +1610,121 @@ static std::string stair_destination_description(const coord_def &pos)
}
#endif
+static void describe_monster(const monsters *mon)
+{
+
+ // first print type and equipment
+ std::string text = get_monster_desc(mon);
+ text += ".";
+ print_formatted_paragraph(text, get_number_of_cols());
+
+ if (mon->type == MONS_HYDRA)
+ {
+ mprf("It has %d head%s.", mon->number,
+ (mon->number > 1? "s" : ""));
+ }
+
+ print_wounds(mon);
+
+ if (!mons_is_mimic(mon->type) && mons_behaviour_perceptible(mon))
+ {
+ if (mon->behaviour == BEH_SLEEP)
+ {
+ mprf("%s appears to be resting.",
+ mons_pronoun(mon->type, PRONOUN_CAP));
+ }
+ // Applies to both friendlies and hostiles
+ else if (mon->behaviour == BEH_FLEE)
+ {
+ mprf("%s is retreating.",
+ mons_pronoun(mon->type, PRONOUN_CAP));
+ }
+ // hostile with target != you
+ else if (!mons_friendly(mon) && mon->foe != MHITYOU)
+ {
+ // special case: batty monsters get set to BEH_WANDER as
+ // part of their special behaviour.
+ if (!testbits(mon->flags, MF_BATTY))
+ {
+ mprf("%s doesn't appear to have noticed you.",
+ mons_pronoun(mon->type, PRONOUN_CAP));
+ }
+ }
+ }
+
+ if (mon->attitude == ATT_FRIENDLY)
+ mprf("%s is friendly.", mons_pronoun(mon->type, PRONOUN_CAP));
+ else if (mon->attitude == ATT_NEUTRAL)
+ mprf("%s is indifferent to you.",
+ mons_pronoun(mon->type, PRONOUN_CAP));
+
+ std::string desc = "";
+ std::string last_desc = "";
+ std::string tmp = "";
+
+ const bool paralysed = mons_is_paralysed(mon);
+ if (paralysed)
+ last_desc += "paralysed";
+
+ for (mon_enchant_list::const_iterator e = mon->enchantments.begin();
+ e != mon->enchantments.end(); ++e)
+ {
+ tmp = describe_mons_enchantment(*mon, e->second, paralysed);
+ if (!tmp.empty())
+ {
+ if (!desc.empty())
+ desc += ", ";
+ desc += last_desc;
+ last_desc = tmp;
+ }
+ }
+
+ if (!last_desc.empty())
+ {
+ if (!desc.empty())
+ desc += ", and ";
+ desc += last_desc;
+ }
+
+ if (!desc.empty())
+ {
+ text = mons_pronoun(mon->type, PRONOUN_CAP);
+ text += " is ";
+ text += desc;
+ text += ".";
+ print_formatted_paragraph(text, get_number_of_cols());
+ }
+}
+
+std::string get_monster_desc(const monsters *mon, bool full_desc)
+{
+ std::string desc = mon->name(DESC_CAP_A);
+
+ const int mon_arm = mon->inv[MSLOT_ARMOUR];
+ std::string weap = "";
+
+ if (mon->type != MONS_DANCING_WEAPON)
+ weap = describe_monster_weapon(mon);
+
+ if (!weap.empty())
+ {
+ if (full_desc)
+ desc += ",";
+ desc += weap;
+ }
+
+ if (full_desc && mon_arm != NON_ITEM)
+ {
+ desc += ", ";
+ if (!weap.empty())
+ desc += "and ";
+ desc += "wearing ";
+ desc += mitm[mon_arm].name(DESC_NOCAP_A);
+ }
+
+ return desc;
+}
+
static void describe_cell(int mx, int my)
{
bool mimic_item = false;
@@ -1652,64 +1752,11 @@ static void describe_cell(int mx, int my)
goto look_clouds;
#endif
- const int mon_arm = menv[i].inv[MSLOT_ARMOUR];
- mprf("%s.", menv[i].name(DESC_CAP_A).c_str());
-
- if (menv[i].type != MONS_DANCING_WEAPON)
- describe_monster_weapon(&menv[i]);
-
- if (mon_arm != NON_ITEM)
- mprf("%s is wearing %s.",
- mons_pronoun(menv[i].type, PRONOUN_CAP),
- mitm[mon_arm].name(DESC_NOCAP_A).c_str());
-
- if (menv[i].type == MONS_HYDRA)
- mprf("It has %d head%s.", menv[i].number,
- (menv[i].number > 1? "s" : ""));;
-
- print_wounds(&menv[i]);
-
+ describe_monster(&menv[i]);
+
if (mons_is_mimic( menv[i].type ))
mimic_item = true;
- else if (mons_behaviour_perceptible(&menv[i]))
- {
- if (menv[i].behaviour == BEH_SLEEP)
- {
- mprf("%s appears to be resting.",
- mons_pronoun(menv[i].type, PRONOUN_CAP));
- }
- // Applies to both friendlies and hostiles
- else if (menv[i].behaviour == BEH_FLEE)
- {
- mprf("%s is retreating.",
- mons_pronoun(menv[i].type, PRONOUN_CAP));
- }
- // hostile with target != you
- else if (!mons_friendly(&menv[i]) && menv[i].foe != MHITYOU)
- {
- // special case: batty monsters get set to BEH_WANDER as
- // part of their special behaviour.
- if (!testbits(menv[i].flags, MF_BATTY))
- mprf("%s doesn't appear to have noticed you.",
- mons_pronoun(menv[i].type, PRONOUN_CAP));
- }
- }
- if (menv[i].attitude == ATT_FRIENDLY)
- mprf("%s is friendly.", mons_pronoun(menv[i].type, PRONOUN_CAP));
- else if (menv[i].attitude == ATT_NEUTRAL)
- mprf("%s is indifferent to you.",
- mons_pronoun(menv[i].type, PRONOUN_CAP));
-
- const bool paralysed = mons_is_paralysed(&menv[i]);
- if (paralysed)
- mprf("%s is paralysed.", mons_pronoun(menv[i].type, PRONOUN_CAP));
-
- for (mon_enchant_list::const_iterator e = menv[i].enchantments.begin();
- e != menv[i].enchantments.end(); ++e)
- {
- describe_mons_enchantment(menv[i], e->second, paralysed);
- }
#if DEBUG_DIAGNOSTICS
stethoscope(i);
#endif
diff --git a/crawl-ref/source/direct.h b/crawl-ref/source/direct.h
index 4ffd1b5109..183a7582eb 100644
--- a/crawl-ref/source/direct.h
+++ b/crawl-ref/source/direct.h
@@ -53,6 +53,7 @@ bool in_vlos(const coord_def &pos);
void terse_describe_square(const coord_def &c);
void full_describe_square(const coord_def &c);
void describe_floor();
+std::string get_monster_desc(const monsters *mon, bool full_desc = true);
int dos_direction_unmunge(int doskey);
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 5ddcd3fd6f..2106671372 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1087,7 +1087,7 @@ public:
int damage_brand(int attk = -1);
item_def *slot_item(equipment_type eq);
- item_def *mslot_item(mon_inv_type sl);
+ item_def *mslot_item(mon_inv_type sl) const;
item_def *weapon(int which_attack = -1);
item_def *launcher();
item_def *missiles();
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 41ffd6ba92..11db0d7d15 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -552,7 +552,8 @@ bool melee_attack::player_attack()
if ((did_primary_hit || did_hit) && def->alive()
&& where == defender->pos())
{
- print_wounds(def);
+ const monsters *mons = static_cast<const monsters*>(def);
+ print_wounds(mons);
}
return (did_primary_hit || did_hit);
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 89d51e7719..ae41883f15 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -2917,7 +2917,7 @@ item_def *monsters::slot_item(equipment_type eq)
return mslot_item(equip_slot_to_mslot(eq));
}
-item_def *monsters::mslot_item(mon_inv_type mslot)
+item_def *monsters::mslot_item(mon_inv_type mslot) const
{
const int mindex = mslot == NUM_MONSTER_SLOTS? NON_ITEM : inv[mslot];
return (mindex == NON_ITEM? NULL: &mitm[mindex]);
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 442a63333b..ba7a4cd0a8 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1353,7 +1353,7 @@ bool swap_places(monsters *monster)
return (swap);
} // end swap_places()
-void print_wounds(monsters *monster)
+void print_wounds(const monsters *monster)
{
// prevents segfault -- cannot use info[] here {dlb}
char str_wound[INFO_SIZE];
diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h
index 2aa3bb1527..152c44787f 100644
--- a/crawl-ref/source/monstuff.h
+++ b/crawl-ref/source/monstuff.h
@@ -106,7 +106,7 @@ bool swap_places(struct monsters *monster);
/* ***********************************************************************
* called from: bang - beam - direct - fight - spells1 - spells2 - spells3
* *********************************************************************** */
-void print_wounds(struct monsters *monster);
+void print_wounds(const struct monsters *monster);
/* ***********************************************************************
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index e44ca7b58c..8a003323f0 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -572,7 +572,10 @@ static int healing_spell( int healed )
if (monster->hit_points == monster->max_hit_points)
simple_monster_message( monster, " is completely healed." );
else
- print_wounds(monster);
+ {
+ const monsters *mons = static_cast<const monsters*>(monster);
+ print_wounds(mons);
+ }
}
else
{
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 648fda400c..3fd9f1598a 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -900,7 +900,8 @@ void cast_refrigeration(int pow)
monster_die(monster, KILL_YOU, 0);
else
{
- print_wounds(monster);
+ const monsters *mons = static_cast<const monsters*>(monster);
+ print_wounds(mons);
//jmf: "slow snakes" finally available
if (mons_class_flag( monster->type, M_COLD_BLOOD ) && coinflip())
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index bd5687d5f1..a274f6375f 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -212,7 +212,10 @@ int cast_smiting(int power, dist &beam)
if (monster->hit_points < 1)
monster_die(monster, KILL_YOU, 0);
else
- print_wounds(monster);
+ {
+ const monsters *mons = static_cast<const monsters*>(monster);
+ print_wounds(mons);
+ }
success = true;
}
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index b5878d5094..9309cbdb5e 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -164,7 +164,10 @@ inline bool player_hurt_monster(int monster, int damage)
hurt_monster( &menv[monster], damage );
if (menv[monster].hit_points > 0)
- print_wounds( &menv[monster] );
+ {
+ const monsters *mons = static_cast<const monsters*>(&menv[monster]);
+ print_wounds(mons);
+ }
else
{
monster_die( &menv[monster], KILL_YOU, 0 );