summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-11 22:17:24 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-11 22:17:24 +0000
commit10b6e46cd72b6e18482d91a1144a997bd4658c2d (patch)
treefec46db004298c36654518c1f99ee0608394bf89
parent6f27175d3cc8b754380035036d1dbbb109b5cebe (diff)
downloadcrawl-ref-10b6e46cd72b6e18482d91a1144a997bd4658c2d.tar.gz
crawl-ref-10b6e46cd72b6e18482d91a1144a997bd4658c2d.zip
* Clean up handling of duration values that trigger expiration warnings
and the like. * On '%': add " (expiring)" to durations about to expire. * On '@': Prepend "Expiring: " to durations about to expire. * Add a few messages that were missing to '@'. No changes of duration thresholds. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8416 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/acr.cc65
-rw-r--r--crawl-ref/source/output.cc333
-rw-r--r--crawl-ref/source/player.cc232
-rw-r--r--crawl-ref/source/player.h2
4 files changed, 389 insertions, 243 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 53510a2422..fb73e3728b 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -2640,7 +2640,8 @@ static void _decrement_durations()
if (_decrement_a_duration(DUR_ICY_ARMOUR,
"Your icy armour evaporates.",
- 6, coinflip(),
+ get_expiration_threshold(DUR_ICY_ARMOUR),
+ coinflip(),
"Your icy armour starts to melt."))
{
you.redraw_armour_class = true;
@@ -2651,17 +2652,20 @@ static void _decrement_durations()
_decrement_a_duration(DUR_REPEL_MISSILES,
"You feel less protected from missiles.",
- 6, coinflip(),
+ get_expiration_threshold(DUR_REPEL_MISSILES),
+ coinflip(),
"Your repel missiles spell is about to expire...");
_decrement_a_duration(DUR_DEFLECT_MISSILES,
"You feel less protected from missiles.",
- 6, coinflip(),
+ get_expiration_threshold(DUR_DEFLECT_MISSILES),
+ coinflip(),
"Your deflect missiles spell is about to expire...");
_decrement_a_duration(DUR_REGENERATION,
"Your skin stops crawling.",
- 6, coinflip(),
+ get_expiration_threshold(DUR_REGENERATION),
+ coinflip(),
"Your skin is crawling a little less now.");
if (you.duration[DUR_PRAYER] > 1)
@@ -2740,8 +2744,9 @@ static void _decrement_durations()
|| you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT
|| you.duration[DUR_TRANSFORMATION] <= 5)
{
- if ( _decrement_a_duration(DUR_TRANSFORMATION,
- NULL, 10, random2(3),
+ if ( _decrement_a_duration(DUR_TRANSFORMATION, NULL,
+ get_expiration_threshold(DUR_TRANSFORMATION),
+ random2(3),
"Your transformation is almost over.") )
{
untransform();
@@ -2755,20 +2760,22 @@ static void _decrement_durations()
_decrement_a_duration(DUR_REPEL_UNDEAD,
"Your holy aura fades away.",
- 4, random2(3),
+ get_expiration_threshold(DUR_REPEL_UNDEAD),
+ random2(3),
"Your holy aura is starting to fade.");
_decrement_a_duration(DUR_SWIFTNESS,
"You feel sluggish.",
- 6, coinflip(),
+ get_expiration_threshold(DUR_SWIFTNESS), coinflip(),
"You start to feel a little slower.");
_decrement_a_duration(DUR_INSULATION,
"You feel conductive.",
- 6, coinflip(),
+ get_expiration_threshold(DUR_INSULATION), coinflip(),
"You start to feel a little less insulated.");
if (_decrement_a_duration(DUR_STONEMAIL,
"Your scaly stone armour disappears.",
- 6, coinflip(),
+ get_expiration_threshold(DUR_STONEMAIL),
+ coinflip(),
"Your scaly stone armour is starting "
"to flake away."))
{
@@ -2778,7 +2785,8 @@ static void _decrement_durations()
if (_decrement_a_duration(DUR_FORESCRY,
"You feel firmly rooted in the present.",
- 6, coinflip(),
+ get_expiration_threshold(DUR_FORESCRY),
+ coinflip(),
"Your vision of the future begins to falter."))
{
you.redraw_evasion = true;
@@ -2818,13 +2826,13 @@ static void _decrement_durations()
_decrement_a_duration(DUR_CONTROL_TELEPORT,
"You feel uncertain.",
- 6, coinflip(),
- "You start to feel a little uncertain.");
+ get_expiration_threshold(DUR_CONTROL_TELEPORT),
+ coinflip(), "You start to feel a little uncertain.");
if (_decrement_a_duration(DUR_DEATH_CHANNEL,
"Your unholy channel expires.",
- 6, coinflip(),
- "Your unholy channel is weakening."))
+ get_expiration_threshold(DUR_DEATH_CHANNEL),
+ coinflip(), "Your unholy channel is weakening."))
{
you.attribute[ATTR_DIVINE_DEATH_CHANNEL] = 0;
}
@@ -2837,7 +2845,8 @@ static void _decrement_durations()
_decrement_a_duration(DUR_SLAYING, "You feel less lethal.");
_decrement_a_duration(DUR_INVIS, "You flicker back into view.",
- 6, coinflip(), "You flicker for a moment.");
+ get_expiration_threshold(DUR_INVIS), coinflip(),
+ "You flicker for a moment.");
_decrement_a_duration(DUR_BARGAIN, "You feel less charismatic.");
_decrement_a_duration(DUR_CONF, "You feel less confused.");
@@ -2974,9 +2983,10 @@ static void _decrement_durations()
if (!you.permanent_levitation() && !you.permanent_flight())
{
if (_decrement_a_duration(DUR_LEVITATION,
- "You float gracefully downwards.",
- 10, random2(6),
- "You are starting to lose your buoyancy!"))
+ "You float gracefully downwards.",
+ get_expiration_threshold(DUR_LEVITATION),
+ random2(6),
+ "You are starting to lose your buoyancy!"))
{
burden_change();
// Landing kills controlled flight.
@@ -3042,18 +3052,11 @@ static void _decrement_durations()
you.duration[DUR_DEATHS_DOOR] = 0;
}
else
- you.duration[DUR_DEATHS_DOOR]--;
-
- if (you.duration[DUR_DEATHS_DOOR] == 10)
- {
- mpr("Your time is quickly running out!", MSGCH_DURATION);
- you.duration[DUR_DEATHS_DOOR] -= random2(6);
- }
- if (you.duration[DUR_DEATHS_DOOR] == 1)
- {
- mpr("Your life is in your own hands again!", MSGCH_DURATION);
- more();
- }
+ _decrement_a_duration(DUR_DEATHS_DOOR,
+ "Your life is in your own hands again!",
+ get_expiration_threshold(DUR_DEATHS_DOOR),
+ random2(6),
+ "Your time is quickly running out!");
}
if (_decrement_a_duration(DUR_DIVINE_VIGOUR))
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index bdbb7651c2..3e5426e48e 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -452,7 +452,7 @@ static void _print_stats_ac(int x, int y)
// AC:
cgotoxy(x+4, y, GOTO_STAT);
if (you.duration[DUR_STONEMAIL])
- textcolor(_dur_colour( BLUE, (you.duration[DUR_STONEMAIL] <= 6) ));
+ textcolor(_dur_colour( BLUE, dur_expiring(DUR_STONEMAIL) ));
else if (you.duration[DUR_ICY_ARMOUR] || you.duration[DUR_STONESKIN])
textcolor( LIGHTBLUE );
else
@@ -616,9 +616,7 @@ static void _get_status_lights(std::vector<status_light>& out)
if (you.duration[DUR_REPEL_UNDEAD])
{
- int colour = _dur_colour(LIGHTGREY,
- (you.duration[DUR_REPEL_UNDEAD] <= 4));
-
+ int colour = _dur_colour( LIGHTGREY, dur_expiring(DUR_REPEL_UNDEAD) );
out.push_back(status_light(colour, "Holy"));
}
@@ -627,78 +625,77 @@ static void _get_status_lights(std::vector<status_light>& out)
if (you.duration[DUR_DEFLECT_MISSILES])
{
- int color = _dur_colour( MAGENTA, (you.duration[DUR_DEFLECT_MISSILES] <= 6) );
+ int color = _dur_colour( MAGENTA, dur_expiring(DUR_DEFLECT_MISSILES) );
out.push_back(status_light(color, "DMsl"));
}
else if (you.duration[DUR_REPEL_MISSILES])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_REPEL_MISSILES] <= 6) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_REPEL_MISSILES) );
out.push_back(status_light(color, "RMsl"));
}
if (you.duration[DUR_REGENERATION])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_REGENERATION] <= 6) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_REGENERATION) );
out.push_back(status_light(color, "Regen"));
}
if (you.duration[DUR_INSULATION])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_INSULATION] <= 6) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_INSULATION) );
out.push_back(status_light(color, "Ins"));
}
if (player_is_airborne())
{
- const bool perm = you.permanent_flight();
+ const bool perm = you.permanent_flight();
+ const bool expiring = (!perm && dur_expiring(DUR_LEVITATION));
if (wearing_amulet( AMU_CONTROLLED_FLIGHT ))
{
int color = _dur_colour( you.light_flight()? BLUE : MAGENTA,
- (you.duration[DUR_LEVITATION] <= 10
- && !perm) );
+ expiring);
out.push_back(status_light(color, "Fly"));
}
else
{
- int color = _dur_colour(BLUE, (you.duration[DUR_LEVITATION] <= 10
- && !perm));
+ int color = _dur_colour(BLUE, expiring);
out.push_back(status_light(color, "Lev"));
}
}
if (you.duration[DUR_INVIS])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_INVIS] <= 6) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_INVIS) );
out.push_back(status_light(color, "Invis"));
}
if (you.duration[DUR_SILENCE])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_SILENCE] <= 5) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_SILENCE) );
out.push_back(status_light(color, "Sil"));
}
if (you.duration[DUR_CONFUSING_TOUCH])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_SILENCE] <= 20) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_CONFUSING_TOUCH) );
out.push_back(status_light(color, "Touch"));
}
if (you.duration[DUR_BARGAIN])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_BARGAIN] <= 15) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_BARGAIN) );
out.push_back(status_light(color, "Brgn"));
}
if (you.duration[DUR_SAGE])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_SAGE] <= 15) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_SAGE) );
out.push_back(status_light(color, "Sage"));
}
if (you.duration[DUR_FIRE_SHIELD])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_FIRE_SHIELD] <= 5) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_FIRE_SHIELD) );
out.push_back(status_light(color, "RoF"));
}
@@ -749,7 +746,7 @@ static void _get_status_lights(std::vector<status_light>& out)
if (you.duration[DUR_SWIFTNESS])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_SWIFTNESS] <= 6) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_SWIFTNESS) );
out.push_back(status_light(color, "Swift"));
}
@@ -757,7 +754,7 @@ static void _get_status_lights(std::vector<status_light>& out)
out.push_back(status_light(RED, "Slow"));
else if (you.duration[DUR_HASTE] && !you.duration[DUR_SLOW])
{
- int color = _dur_colour( BLUE, (you.duration[DUR_HASTE] <= 6) );
+ int color = _dur_colour( BLUE, dur_expiring(DUR_HASTE) );
out.push_back(status_light(color, "Fast"));
}
@@ -2140,6 +2137,15 @@ void print_overview_screen()
}
}
+std::string _get_expiration_string(duration_type dur, const char* msg)
+{
+ std::string help = msg;
+ if (dur_expiring(dur))
+ help += " (expiring)";
+
+ return (help);
+}
+
// Creates rows of short descriptions for current
// status, mutations and abilities.
std::string _status_mut_abilities()
@@ -2148,202 +2154,232 @@ std::string _status_mut_abilities()
// print status information
//----------------------------
std::string text = "<w>@:</w> ";
+ std::vector<std::string> status;
+
+ // These are not so unreasonable anymore now that the new overview screen
+ // is dumped. When the player dies while paralysed it's important
+ // information. If so, move them to the front. (jpeg)
+ if (you.paralysed())
+ status.push_back("paralysed");
+
+ if (you.duration[DUR_PETRIFIED])
+ status.push_back("petrified");
+
+ if (you.duration[DUR_SLEEP])
+ status.push_back("sleeping");
if (you.burden_state == BS_ENCUMBERED)
- text += "burdened, ";
+ status.push_back("burdened");
else if (you.burden_state == BS_OVERLOADED)
- text += "overloaded, ";
+ status.push_back("overloaded");
if (you.duration[DUR_BREATH_WEAPON])
- text += "short of breath, ";
+ status.push_back("short of breath");
if (you.duration[DUR_REPEL_UNDEAD])
- text += "repel undead, ";
+ {
+ status.push_back(_get_expiration_string(DUR_REPEL_UNDEAD,
+ "repel undead"));
+ }
if (you.duration[DUR_LIQUID_FLAMES])
- text += "liquid flames, ";
+ status.push_back("liquid flames");
if (you.duration[DUR_ICY_ARMOUR])
- text += "icy shield, ";
+ status.push_back(_get_expiration_string(DUR_ICY_ARMOUR, "icy armour"));
if (you.duration[DUR_DEFLECT_MISSILES])
- text += "deflect missiles, ";
+ {
+ status.push_back(_get_expiration_string(DUR_DEFLECT_MISSILES,
+ "deflect missiles"));
+ }
else if (you.duration[DUR_REPEL_MISSILES])
- text += "repel missiles, ";
+ {
+ status.push_back(_get_expiration_string(DUR_REPEL_MISSILES,
+ "repel missiles"));
+ }
if (you.duration[DUR_PRAYER])
- text += "praying, ";
+ status.push_back("praying");
if (you.disease && !you.duration[DUR_REGENERATION]
|| you.species == SP_VAMPIRE && you.hunger_state == HS_STARVING)
{
- text += "non-regenerating, ";
+ status.push_back("non-regenerating");
}
else if (you.duration[DUR_REGENERATION]
|| you.species == SP_VAMPIRE && you.hunger_state != HS_SATIATED)
{
+ std::string help;
if (you.disease)
- text += "recuperating";
+ help = "recuperating";
else
- text += "regenerating";
+ help = "regenerating";
if (you.species == SP_VAMPIRE && you.hunger_state != HS_SATIATED)
{
if (you.hunger_state < HS_SATIATED)
- text += " slowly";
+ help += " slowly";
else if (you.hunger_state >= HS_FULL)
- text += " quickly";
+ help += " quickly";
else if (you.hunger_state == HS_ENGORGED)
- text += " very quickly";
+ help += " very quickly";
}
- text += ", ";
- }
-// not used as resistance part already says so
-// if (you.duration[DUR_INSULATION])
-// text += "insulated, ";
+ if (dur_expiring(DUR_REGENERATION))
+ help += " (expires)";
+
+ status.push_back(help);
+ }
if (you.duration[DUR_STONEMAIL])
- text += "stone mail, ";
+ {
+ status.push_back(_get_expiration_string(DUR_STONEMAIL,
+ "stone mail"));
+ }
if (you.duration[DUR_STONESKIN])
- text += "stone skin, ";
-
-// resistance part already says so
-// if (you.duration[DUR_CONTROLLED_FLIGHT])
-// text += "control flight, ";
+ status.push_back("stone skin");
if (you.duration[DUR_TELEPORT])
- text += "about to teleport, ";
-
-// resistance part already says so
-// if (you.duration[DUR_CONTROL_TELEPORT])
-// text += "control teleport, ";
-
-// MR output already says so
-// if (you.duration[DUR_LOWERED_MR])
-// text += "vulnerable to magic, ";
+ status.push_back("about to teleport");
if (you.duration[DUR_DEATH_CHANNEL])
- text += "death channel, ";
-
+ {
+ status.push_back(_get_expiration_string(DUR_DEATH_CHANNEL,
+ "death channel"));
+ }
if (you.duration[DUR_FORESCRY])
- text += "forewarned, ";
+ status.push_back(_get_expiration_string(DUR_FORESCRY, "forewarned"));
if (you.duration[DUR_SILENCE])
- text += "radiating silence, ";
+ status.push_back(_get_expiration_string(DUR_SILENCE, "silence"));
if (you.duration[DUR_INVIS])
- text += "invisible, ";
+ status.push_back(_get_expiration_string(DUR_INVIS, "invisible"));
if (you.confused())
- text += "confused, ";
-
- // How exactly did you get to show the status?
- // It's not so unreasonable anymore now that the new overview screen is
- // dumped. When the player dies while paralysed it's important information.
- if (you.paralysed())
- text += "paralysed, ";
-
- if (you.duration[DUR_PETRIFIED])
- text += "petrified, ";
-
- if (you.duration[DUR_SLEEP])
- text += "sleeping, ";
+ status.push_back("confused");
if (you.duration[DUR_EXHAUSTED])
- text += "exhausted, ";
+ status.push_back("exhausted");
if (you.duration[DUR_MIGHT])
- text += "mighty, ";
+ status.push_back("mighty");
if (you.duration[DUR_DIVINE_VIGOUR])
- text += "divinely robust, ";
+ status.push_back("divinely robust");
if (you.duration[DUR_DIVINE_STAMINA])
- text += "divinely fortified, ";
+ status.push_back("divinely fortified");
if (you.duration[DUR_BERSERKER])
- text += "berserking, ";
+ status.push_back("berserking");
if (player_is_airborne())
- text += "levitating, ";
+ {
+ std::string help;
+ if (wearing_amulet( AMU_CONTROLLED_FLIGHT ))
+ help += "flying";
+ else
+ help += "levitating";
+
+ if (dur_expiring(DUR_LEVITATION) && !you.permanent_flight())
+ help += " (expires)";
+
+ status.push_back(help);
+ }
if (you.duration[DUR_BARGAIN])
- text += "charismatic, ";
+ status.push_back(_get_expiration_string(DUR_BARGAIN, "charismatic"));
if (you.duration[DUR_SLAYING])
- text += "deadly, ";
+ status.push_back("deadly");
// DUR_STEALTHY handled in stealth printout
if (you.duration[DUR_SAGE])
{
- text += "studying ";
- text += skill_name(you.sage_bonus_skill);
- text += ", ";
+ std::string help = "studying ";
+ help += skill_name(you.sage_bonus_skill);
+ status.push_back(_get_expiration_string(DUR_SAGE, help.c_str()));
}
if (you.duration[DUR_MAGIC_SHIELD])
- text += "shielded, ";
+ status.push_back("shielded");
if (you.duration[DUR_FIRE_SHIELD])
- text += "immune to fire clouds, ";
+ {
+ status.push_back(_get_expiration_string(DUR_FIRE_SHIELD,
+ "immune to fire clouds"));
+ }
if (you.duration[DUR_POISONING])
{
- text += (you.duration[DUR_POISONING] > 10) ? "extremely" :
- (you.duration[DUR_POISONING] > 5) ? "very" :
- (you.duration[DUR_POISONING] > 3) ? "quite"
- : "mildly";
- text += " poisoned, ";
+ std::string help = (you.duration[DUR_POISONING] > 10) ? "extremely" :
+ (you.duration[DUR_POISONING] > 5) ? "very" :
+ (you.duration[DUR_POISONING] > 3) ? "quite"
+ : "mildly";
+ help += " poisoned";
+
+ status.push_back(help);
}
if (you.disease)
{
- text += (you.disease > 120) ? "badly " :
- (you.disease > 40) ? ""
- : "mildly ";
- text += "diseased, ";
+ std::string help = (you.disease > 120) ? "badly " :
+ (you.disease > 40) ? ""
+ : "mildly ";
+ help += "diseased";
+
+ status.push_back(help);
}
if (you.rotting || you.species == SP_GHOUL)
- text += "rotting, ";
+ status.push_back("rotting");
if (you.duration[DUR_CONFUSING_TOUCH])
- text += "confusing touch, ";
+ {
+ status.push_back(_get_expiration_string(DUR_CONFUSING_TOUCH,
+ "confusing touch"));
+ }
if (you.duration[DUR_SURE_BLADE])
- text += "bonded with blade, ";
+ status.push_back("bonded with blade");
int move_cost = (player_speed() * player_movement_speed()) / 10;
- text += (move_cost < 8) ? "very quick, " :
- (move_cost < 10) ? "quick, " :
- (move_cost == 10) ? "" :
- (move_cost < 13) ? "slow, " : "";
+ if (move_cost != 10)
+ {
+ std::string help = (move_cost < 8) ? "very quick" :
+ (move_cost < 10) ? "quick" :
+ (move_cost < 13) ? "slow"
+ : "";
+ if (!help.empty())
+ status.push_back(help);
+ }
if (you.duration[DUR_SLOW] && !you.duration[DUR_HASTE])
- text += "slowed, ";
+ status.push_back("slowed");
else if (you.duration[DUR_HASTE] && !you.duration[DUR_SLOW])
- text += "hasted, ";
+ status.push_back(_get_expiration_string(DUR_HASTE, "hasted"));
else if (!you.duration[DUR_HASTE] && you.duration[DUR_SWIFTNESS])
- text += "swift, ";
+ status.push_back("swift");
if (you.attribute[ATTR_HELD])
- text += "held, ";
+ status.push_back("held");
const int mr = player_res_magic();
- snprintf(info, INFO_SIZE, "%s resistant to magic, ",
+ snprintf(info, INFO_SIZE, "%s resistant to magic",
(mr < 10) ? "not" :
(mr < 30) ? "slightly" :
(mr < 60) ? "somewhat" :
(mr < 90) ? "quite" :
(mr < 120) ? "very" :
- (mr < 140) ? "extremely" :
- "incredibly");
+ (mr < 140) ? "extremely"
+ : "incredibly");
- text += info;
+ status.push_back(info);
// character evaluates their ability to sneak around:
const int ustealth = check_stealth();
@@ -2361,40 +2397,51 @@ std::string _status_mut_abilities()
(ustealth < 520) ? "incredibly "
: "uncannily ");
- text += info;
+ status.push_back(info);
+
+ text += comma_separated_line(status.begin(), status.end(), ", ", ", ");
- switch (you.attribute[ATTR_TRANSFORMATION])
+ if (you.duration[DUR_TRANSFORMATION])
{
- case TRAN_SPIDER:
- text += "\nYou are in spider-form.";
- break;
- case TRAN_BAT:
- text += "\nYou are in ";
- if (you.species == SP_VAMPIRE)
- text += "vampire ";
- text += "bat-form.";
- break;
- case TRAN_BLADE_HANDS:
- text += "\nYou have blades for hands.";
- break;
- case TRAN_STATUE:
- text += "\nYou are a statue.";
- break;
- case TRAN_ICE_BEAST:
- text += "\nYou are an ice creature.";
- break;
- case TRAN_DRAGON:
- text += "\nYou are in dragon-form.";
- break;
- case TRAN_LICH:
- text += "\nYou are in lich-form.";
- break;
- case TRAN_SERPENT_OF_HELL:
- text += "\nYou are a huge demonic serpent.";
- break;
- case TRAN_AIR:
- text += "\nYou are a cloud of diffuse gas.";
- break;
+ switch (you.attribute[ATTR_TRANSFORMATION])
+ {
+ case TRAN_SPIDER:
+ text += "\nYou are in spider-form.";
+ break;
+ case TRAN_BAT:
+ text += "\nYou are in ";
+ if (you.species == SP_VAMPIRE)
+ text += "vampire ";
+ text += "bat-form.";
+ break;
+ case TRAN_BLADE_HANDS:
+ text += "\nYou have blades for hands.";
+ break;
+ case TRAN_STATUE:
+ text += "\nYou are a statue.";
+ break;
+ case TRAN_ICE_BEAST:
+ text += "\nYou are an ice creature.";
+ break;
+ case TRAN_DRAGON:
+ text += "\nYou are in dragon-form.";
+ break;
+ case TRAN_LICH:
+ text += "\nYou are in lich-form.";
+ break;
+ case TRAN_SERPENT_OF_HELL:
+ text += "\nYou are a huge demonic serpent.";
+ break;
+ case TRAN_AIR:
+ text += "\nYou are a cloud of diffuse gas.";
+ break;
+ }
+ if ((you.species != SP_VAMPIRE
+ || you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT)
+ && dur_expiring(DUR_TRANSFORMATION))
+ {
+ text += " (Expiring.)";
+ }
}
/*
// Commenting out until this information is actually meaningful. (jpeg)
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 8c265ec690..58a6393271 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -3767,26 +3767,97 @@ static const char * _get_rotting_how()
return("");
}
+// Returns the medium duration value which is usually announced by a special
+// message ("XY is about to time out") or a change of colour in the
+// status display.
+// Note that these values cannot be relied on when playing since there are
+// random decrements precisely to avoid this.
+int get_expiration_threshold(duration_type dur)
+{
+ switch (dur)
+ {
+ case DUR_REPEL_UNDEAD:
+ return 4;
+
+ case DUR_FIRE_SHIELD:
+ case DUR_SILENCE: // no message
+ return 5;
+
+ case DUR_DEFLECT_MISSILES:
+ case DUR_REPEL_MISSILES:
+ case DUR_REGENERATION:
+ case DUR_INSULATION:
+ case DUR_STONEMAIL:
+ case DUR_SWIFTNESS:
+ case DUR_INVIS:
+ case DUR_HASTE:
+ // The following are not shown in the status lines.
+ case DUR_ICY_ARMOUR:
+ case DUR_FORESCRY:
+ case DUR_CONTROL_TELEPORT:
+ case DUR_DEATH_CHANNEL:
+ return 6;
+
+ case DUR_LEVITATION:
+ case DUR_TRANSFORMATION: // not on status
+ case DUR_DEATHS_DOOR: // not on status
+ return 10;
+
+ // These get no messages when they "flicker".
+ case DUR_SAGE:
+ case DUR_BARGAIN:
+ return 15;
+
+ case DUR_CONFUSING_TOUCH:
+ return 20;
+
+ default:
+ return 0;
+ }
+}
+
+// Is a given duration about to expire?
+bool dur_expiring(duration_type dur)
+{
+ const int value = you.duration[dur];
+ if (value <= 0)
+ return (false);
+
+ return (value <= get_expiration_threshold(dur));
+}
+
+static void _output_expiring_message(duration_type dur, const char* msg)
+{
+ if (you.duration[dur])
+ {
+ const bool expires = dur_expiring(dur);
+ mprf("%s%s", expires ? "Expiring: " : "", msg);
+ }
+}
+
void display_char_status()
{
if (you.is_undead == US_SEMI_UNDEAD && you.hunger_state == HS_ENGORGED)
- mpr( "You feel almost alive." );
+ mpr("You feel almost alive.");
else if (you.is_undead)
- mpr( "You are undead." );
+ mpr("You are undead.");
else if (you.duration[DUR_DEATHS_DOOR])
- mpr( "You are standing in death's doorway." );
+ {
+ _output_expiring_message(DUR_DEATHS_DOOR,
+ "You are standing in death's doorway.");
+ }
else
- mpr( "You are alive." );
+ mpr("You are alive.");
if (you.haloed())
{
const int halo_size = halo_radius();
if (halo_size > 6)
- mpr( "You are illuminated by a large divine halo." );
+ mpr("You are illuminated by a large divine halo.");
else if (halo_size > 3)
- mpr( "You are illuminated by a divine halo." );
+ mpr("You are illuminated by a divine halo.");
else
- mpr( "You are illuminated by a small divine halo." );
+ mpr("You are illuminated by a small divine halo.");
}
if (you.species == SP_VAMPIRE)
@@ -3846,36 +3917,51 @@ void display_char_status()
}
}
- switch (you.attribute[ATTR_TRANSFORMATION])
+ if (you.duration[DUR_TRANSFORMATION] > 0)
{
- case TRAN_SPIDER:
- mpr( "You are in spider-form." );
- break;
- case TRAN_BAT:
- mprf( "You are in %sbat-form.",
- you.species == SP_VAMPIRE ? "vampire " : "" );
- break;
- case TRAN_BLADE_HANDS:
- mpr( "You have blades for hands." );
- break;
- case TRAN_STATUE:
- mpr( "You are a statue." );
- break;
- case TRAN_ICE_BEAST:
- mpr( "You are an ice creature." );
- break;
- case TRAN_DRAGON:
- mpr( "You are in dragon-form." );
- break;
- case TRAN_LICH:
- mpr( "You are in lich-form." );
- break;
- case TRAN_SERPENT_OF_HELL:
- mpr( "You are a huge demonic serpent." );
- break;
- case TRAN_AIR:
- mpr( "You are a cloud of diffuse gas." );
- break;
+ std::string text = "";
+
+ if ((you.species != SP_VAMPIRE
+ || you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT)
+ && dur_expiring(DUR_TRANSFORMATION))
+ {
+ text = "Expiring: ";
+ }
+
+ switch (you.attribute[ATTR_TRANSFORMATION])
+ {
+ case TRAN_SPIDER:
+ text += "You are in spider-form.";
+ break;
+ case TRAN_BAT:
+ text += "You are in ";
+ if (you.species == SP_VAMPIRE)
+ text += "vampire ";
+ text += "bat-form.";
+ break;
+ case TRAN_BLADE_HANDS:
+ text += "You have blades for hands.";
+ break;
+ case TRAN_STATUE:
+ text += "You are a statue.";
+ break;
+ case TRAN_ICE_BEAST:
+ text += "You are an ice creature.";
+ break;
+ case TRAN_DRAGON:
+ text += "You are in dragon-form.";
+ break;
+ case TRAN_LICH:
+ text += "You are in lich-form.";
+ break;
+ case TRAN_SERPENT_OF_HELL:
+ text += "You are a huge demonic serpent.";
+ break;
+ case TRAN_AIR:
+ text += "You are a cloud of diffuse gas.";
+ break;
+ }
+ mpr(text.c_str());
}
if (you.burden_state == BS_ENCUMBERED)
@@ -3891,31 +3977,39 @@ void display_char_status()
}
if (you.duration[DUR_SAGE])
- mprf("You are studying %s.", skill_name(you.sage_bonus_skill));
+ {
+ std::string msg = "You are studying ";
+ msg += skill_name(you.sage_bonus_skill);
+ msg += ".";
+ _output_expiring_message(DUR_SAGE, msg.c_str());
+ }
+
+ _output_expiring_message(DUR_BARGAIN, "You get a bargain in shops.");
if (you.duration[DUR_BREATH_WEAPON])
mpr("You are short of breath.");
- if (you.duration[DUR_REPEL_UNDEAD])
- mpr("You have a holy aura protecting you from undead.");
+ _output_expiring_message(DUR_REPEL_UNDEAD,
+ "You have a holy aura protecting you from undead.");
if (you.duration[DUR_LIQUID_FLAMES])
mpr("You are covered in liquid flames.");
if (you.duration[DUR_FIRE_SHIELD])
{
- mpr("You are surrounded by a ring of flames.");
- mpr("You are immune to clouds of flame.");
+ _output_expiring_message(DUR_FIRE_SHIELD,
+ "You are surrounded by a ring of flames.");
+ _output_expiring_message(DUR_FIRE_SHIELD,
+ "You are immune to clouds of flame.");
}
- if (you.duration[DUR_ICY_ARMOUR])
- mpr("You are protected by an icy shield.");
+ _output_expiring_message(DUR_ICY_ARMOUR,
+ "You are protected by an icy shield.");
- if (you.duration[DUR_REPEL_MISSILES])
- mpr("You are protected from missiles.");
+ _output_expiring_message(DUR_REPEL_MISSILES,
+ "You are protected from missiles.");
- if (you.duration[DUR_DEFLECT_MISSILES])
- mpr("You deflect missiles.");
+ _output_expiring_message(DUR_DEFLECT_MISSILES, "You deflect missiles.");
if (you.duration[DUR_PRAYER])
mpr("You are praying.");
@@ -3929,20 +4023,17 @@ void display_char_status()
if (you.duration[DUR_REGENERATION]
&& (you.species != SP_VAMPIRE || you.hunger_state != HS_STARVING))
{
- if (you.disease)
- mpr("You are recuperating from your illness.");
- else
- mpr("You are regenerating.");
+ _output_expiring_message(DUR_REGENERATION,
+ you.disease ? "recuperating from your illness"
+ : "regenerating");
}
- if (you.duration[DUR_SWIFTNESS])
- mpr("You can move swiftly.");
+ _output_expiring_message(DUR_SWIFTNESS, "You can move swiftly.");
- if (you.duration[DUR_INSULATION])
- mpr("You are insulated.");
+ _output_expiring_message(DUR_INSULATION, "You are insulated.");
- if (you.duration[DUR_STONEMAIL])
- mpr("You are covered in scales of stone.");
+ _output_expiring_message(DUR_STONEMAIL,
+ "You are covered in scales of stone.");
if (you.duration[DUR_CONTROLLED_FLIGHT])
mpr("You can control your flight.");
@@ -3950,17 +4041,14 @@ void display_char_status()
if (you.duration[DUR_TELEPORT])
mpr("You are about to teleport.");
- if (you.duration[DUR_CONTROL_TELEPORT])
- mpr("You can control teleportation.");
+ _output_expiring_message(DUR_CONTROL_TELEPORT,
+ "You can control teleportation.");
- if (you.duration[DUR_DEATH_CHANNEL])
- mpr("You are channeling the dead.");
+ _output_expiring_message(DUR_DEATH_CHANNEL, "You are channeling the dead.");
- if (you.duration[DUR_FORESCRY]) //jmf: added 19mar2000
- mpr("You are forewarned.");
+ _output_expiring_message(DUR_FORESCRY, "You are forewarned.");
- if (you.duration[DUR_SILENCE]) //jmf: added 27mar2000
- mpr("You radiate silence.");
+ _output_expiring_message(DUR_SILENCE, "You radiate silence.");
if (you.duration[DUR_STONESKIN])
mpr("Your skin is tough as stone.");
@@ -3968,8 +4056,7 @@ void display_char_status()
if (you.duration[DUR_SEE_INVISIBLE])
mpr("You can see invisible.");
- if (you.duration[DUR_INVIS])
- mpr("You are invisible.");
+ _output_expiring_message(DUR_INVIS, "You are invisible.");
if (you.confused())
mpr("You are confused.");
@@ -3994,7 +4081,7 @@ void display_char_status()
else if (you.duration[DUR_SLOW])
mpr("Your actions are slowed.");
else if (you.duration[DUR_HASTE])
- mpr("Your actions are hasted.");
+ _output_expiring_message(DUR_HASTE, "Your actions are hasted.");
if (you.duration[DUR_MIGHT])
mpr("You are mighty.");
@@ -4009,7 +4096,14 @@ void display_char_status()
mpr("You are possessed by a berserker rage.");
if (player_is_airborne())
- mpr("You are hovering above the floor.");
+ {
+ const bool expires = dur_expiring(DUR_LEVITATION)
+ && !you.permanent_flight();
+
+ mprf(expires ? MSGCH_WARN : MSGCH_PLAIN,
+ "%sYou are hovering above the floor.",
+ expires ? "Expiring: " : "");
+ }
if (you.attribute[ATTR_HELD])
mpr("You are held in a net.");
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index d37b00d2f5..bbf4683c66 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -291,6 +291,8 @@ unsigned long exp_needed(int lev);
/* ***********************************************************************
* called from: acr
* *********************************************************************** */
+int get_expiration_threshold(duration_type dur);
+bool dur_expiring(duration_type dur);
void display_char_status(void);