From e31e50c63a31aa249510d5c23e9a6d7c26e5dfb5 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Thu, 3 Jul 2008 18:21:11 +0000 Subject: Fix 1999363: Vampire eating issues. Tidy up the new lines item descriptions a bit, so you don't get three free lines in some cases (non-randart, non-special description items) and one or two in other cases. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6370 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/changes.stone_soup | 1 + crawl-ref/source/delay.cc | 49 +++++++++++++------- crawl-ref/source/describe.cc | 96 +++++++++++++++++++++++++++------------ crawl-ref/source/food.cc | 36 +++++++-------- crawl-ref/source/output.cc | 16 ++++--- crawl-ref/source/view.cc | 5 +- 6 files changed, 129 insertions(+), 74 deletions(-) diff --git a/crawl-ref/docs/changes.stone_soup b/crawl-ref/docs/changes.stone_soup index 134358ac36..f60ba71a93 100644 --- a/crawl-ref/docs/changes.stone_soup +++ b/crawl-ref/docs/changes.stone_soup @@ -74,6 +74,7 @@ Items ----- * Removed weapons of disruption, improved holy wrath. * New weapon brand: dragon slaying, limited to Polearms. +* Fixed darts of flame/ice to actually work, add similarly branded javelins. * Forbid (un)equipping of items with known potentially fatal stat drain. * Make distortion only take effect on unwielding. * Improved autotargeting for weapons of reaching. diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 65a4dd7b60..7fef1d1f86 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -41,6 +41,7 @@ #include "stash.h" #include "state.h" #include "stuff.h" +#include "transfor.h" #include "travel.h" #include "tutorial.h" #include "view.h" @@ -138,7 +139,7 @@ static int _recite_to_monsters(int x, int y, int pow, int unused) else return (0); // nothing happens - // bad effects stop the recital + // Bad effects stop the recital. stop_delay(); return (1); } @@ -496,19 +497,20 @@ void stop_delay( bool stop_stair_travel ) did_god_conduct(DID_DRINK_BLOOD, 8); delay.duration = 0; _pop_delay(); - break; + handle_delay(); + return; } case DELAY_ARMOUR_ON: case DELAY_ARMOUR_OFF: // These two have the default action of not being interruptible, - // although they will often be chained (remove cloak, remove - // armour, wear new armour, replace cloak), all of which can - // be stopped when complete. This is a fairly reasonable - // behaviour, although perhaps the character should have - // option of reversing the current action if it would take - // less time to get out of the plate mail that's half on - // than it would take to continue. Probably too much trouble, - // and would have to have a prompt... this works just fine. -- bwr + // although they will often consist of chained intermediary steps + // (remove cloak, remove armour, wear new armour, replace cloak), + // all of which can be stopped when complete. This is a fairly + // reasonable behaviour, although perhaps the character should have + // the option of reversing the current action if it would take less + // time to get out of the plate mail that's half on than it would + // take to continue. Probably too much trouble, and we'd have to + // have a prompt... this works just fine. -- bwr break; case DELAY_ASCENDING_STAIRS: // short... and probably what people want @@ -678,7 +680,7 @@ void handle_delay( void ) : "butchering"), mitm[delay.parm1].name(DESC_PLAIN).c_str()); - // also for bottling blood + // Also for bottling blood - just in case. if (you.duration[DUR_PRAYER] && god_hates_butchery(you.religion)) { @@ -728,8 +730,19 @@ void handle_delay( void ) // First check cases where delay may no longer be valid: // XXX: need to handle passwall when monster digs -- bwr - if (delay.type == DELAY_BUTCHER || delay.type == DELAY_BOTTLE_BLOOD - || delay.type == DELAY_OFFER_CORPSE) + if (delay.type == DELAY_FEED_VAMPIRE) + { + if (you.hunger_state == HS_ENGORGED + || you.hunger_state > HS_SATIATED + && you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + { + // Messages handled in _food_change() in food.cc. + stop_delay(); + return; + } + } + else if (delay.type == DELAY_BUTCHER || delay.type == DELAY_BOTTLE_BLOOD + || delay.type == DELAY_OFFER_CORPSE) { if (delay.type == DELAY_BOTTLE_BLOOD && you.experience_level < 6) { @@ -801,7 +814,9 @@ void handle_delay( void ) { mpr("You stop bottling this corpse's foul-smelling " "blood!"); - delay.duration = 0; + _pop_delay(); + handle_delay(); + return; } } @@ -850,10 +865,10 @@ void handle_delay( void ) } else if (delay.type == DELAY_RECITE) { - if (check_recital_audience() < 1 // maybe you've lost your audience + if (check_recital_audience() < 1 // Maybe you've lost your audience... || Options.hp_warning && you.hp*Options.hp_warning <= you.hp_max && delay.parm2*Options.hp_warning > you.hp_max - || you.hp*2 < delay.parm2) // or significant health drop + || you.hp*2 < delay.parm2) // ... or significant health drop. { stop_delay(); return; @@ -1170,6 +1185,8 @@ static void _finish_delay(const delay_queue_item &delay) mprf("You stop %s.", delay.type == DELAY_BUTCHER ? "butchering the corpse" : "bottling this corpse's blood"); + _pop_delay(); + handle_delay(); } StashTrack.update_stash(); // Stash-track the generated item(s). break; diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 43df0b090a..7986ee8663 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -474,9 +474,9 @@ static std::string _randart_descrip( const item_def &item ) { RAP_CURSED, "It may recurse itself.", false} }; - for ( unsigned i = 0; i < ARRAYSZ(propdescs); ++i ) + for (unsigned i = 0; i < ARRAYSZ(propdescs); ++i) { - if ( known_proprt(propdescs[i].property)) + if (known_proprt(propdescs[i].property)) { // Only randarts with RAP_CURSED > 0 may recurse themselves. if (propdescs[i].property == RAP_CURSED @@ -492,13 +492,14 @@ static std::string _randart_descrip( const item_def &item ) snprintf(buf, sizeof buf, "%+d", proprt[propdescs[i].property]); sdesc = replace_all(sdesc, "%d", buf); - if ( propdescs[i].is_graded_resist ) + if (propdescs[i].is_graded_resist) { int idx = proprt[propdescs[i].property] + 3; - if ( idx < 0 ) + if (idx < 0) idx = 0; - if ( idx > 6 ) + if (idx > 6) idx = 6; + const char* prefixes[] = { "It makes you extremely vulnerable to ", "It makes you very vulnerable to ", @@ -1002,9 +1003,14 @@ static std::string _describe_weapon( const item_def &item, bool verbose) if (is_random_artefact( item )) { - description += "$$"; - description += _randart_descrip( item ); + std::string rand_desc = _randart_descrip( item ); + if (!rand_desc.empty()) + { + description += "$$"; + description += rand_desc; + } + // Can't happen, right? (XXX) if (!item_ident(item, ISFLAG_KNOW_PROPERTIES) && item_type_known(item)) { @@ -1287,7 +1293,7 @@ static std::string _describe_armour( const item_def &item, bool verbose ) "of both cold and heat."; break; - // these two are robes only: + // These two are only for robes. case SPARM_POSITIVE_ENERGY: description += "It protects its wearer from " "the effects of negative energy."; @@ -1307,13 +1313,20 @@ static std::string _describe_armour( const item_def &item, bool verbose ) if (is_random_artefact( item )) { - description += "$$"; - description += _randart_descrip( item ); + std::string rand_desc = _randart_descrip( item ); + if (!rand_desc.empty()) + { + description += "$$"; + description += rand_desc; + } + + // Can't happen, right? (XXX) if (!item_ident(item, ISFLAG_KNOW_PROPERTIES) && item_type_known(item)) description += "$This armour may have some hidden properties."; } else if (get_equip_race( item ) != ISFLAG_NO_RACE) { + // Randart armour can't be racial. description += "$"; switch (get_equip_race( item )) { @@ -1344,12 +1357,16 @@ static std::string _describe_armour( const item_def &item, bool verbose ) if (verbose && get_armour_slot(item) == EQ_BODY_ARMOUR) { description += "$$"; - if ( is_light_armour(item) ) + if (is_light_armour(item)) + { description += "This is a light armour. Wearing it will " "exercise Dodging and Stealth."; + } else + { description += "This is a heavy armour. Wearing it will " "exercise Armour."; + } } return description; @@ -1373,7 +1390,7 @@ static std::string _describe_jewellery( const item_def &item, bool verbose) // Note that for randarts we'll print out the pluses even // in the case that its zero, just to avoid confusion. -- bwr if (item.plus != 0 - || (item.sub_type == RING_SLAYING && item.plus2 != 0) + || item.sub_type == RING_SLAYING && item.plus2 != 0 || is_random_artefact( item )) { switch (item.sub_type) @@ -1440,8 +1457,12 @@ static std::string _describe_jewellery( const item_def &item, bool verbose) // Randart properties. if (is_random_artefact( item )) { - description += "$"; - description += _randart_descrip(item); + std::string rand_desc = _randart_descrip( item ); + if (!rand_desc.empty()) + { + description += "$"; + description += rand_desc; + } if (!item_ident(item, ISFLAG_KNOW_PROPERTIES)) { description += "$This "; @@ -1688,18 +1709,37 @@ std::string get_item_description( const item_def &item, bool verbose, } } + bool need_extra_line = true; + std::string desc; switch (item.base_type) { + // Weapons, armour, jewellery might be artefacts. case OBJ_WEAPONS: - description << _describe_weapon( item, verbose ); + desc = _describe_weapon( item, verbose ); + if (desc.empty()) + need_extra_line = false; + else + description << desc; break; - case OBJ_MISSILES: - description << _describe_ammo( item ); + case OBJ_ARMOUR: + desc = _describe_armour( item, verbose ); + if (desc.empty()) + need_extra_line = false; + else + description << desc; break; - case OBJ_ARMOUR: - description << _describe_armour( item, verbose ); + case OBJ_JEWELLERY: + desc = _describe_jewellery( item, verbose ); + if (desc.empty()) + need_extra_line = false; + else + description << desc; + break; + + case OBJ_MISSILES: + description << _describe_ammo( item ); break; case OBJ_WANDS: @@ -1770,14 +1810,9 @@ std::string get_item_description( const item_def &item, bool verbose, "of eating such meat."; } description << "$"; - } break; - case OBJ_JEWELLERY: - description << _describe_jewellery( item, verbose ); - break; - case OBJ_STAVES: if (item_type_known(item)) { @@ -1805,13 +1840,16 @@ std::string get_item_description( const item_def &item, bool verbose, break; case OBJ_BOOKS: - if (! player_can_read_spellbook( item )) - description << "$This book is beyond your current level of understanding."; + if (!player_can_read_spellbook( item )) + { + description << "$This book is beyond your current level of " + "understanding."; + } break; case OBJ_POTIONS: #ifdef DEBUG_BLOOD_POTIONS - // list content of timer vector for blood potions + // List content of timer vector for blood potions. if (is_blood_potion(item)) { item_def stack = static_cast(item); @@ -1846,7 +1884,9 @@ std::string get_item_description( const item_def &item, bool verbose, { if (verbose) { - description << "$$It"; + if (need_extra_line) + description << "$"; + description << "$It"; if (item_known_cursed( item )) description << " has a curse placed upon it, and it"; diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index d222383925..1e71a366e1 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -93,12 +93,12 @@ void make_hungry( int hunger_amount, bool suppress_msg, bool allow_reducing ) if (you.hunger < 0) you.hunger = 0; - // so we don't get two messages, ever. + // So we don't get two messages, ever. bool state_message = _food_change(false); if (!suppress_msg && !state_message) _describe_food_change( -hunger_amount ); -} // end make_hungry() +} void lessen_hunger( int satiated_amount, bool suppress_msg ) { @@ -110,12 +110,12 @@ void lessen_hunger( int satiated_amount, bool suppress_msg ) if (you.hunger > 12000) you.hunger = 12000; - // so we don't get two messages, ever + // So we don't get two messages, ever. bool state_message = _food_change(false); if (!suppress_msg && !state_message) _describe_food_change(satiated_amount); -} // end lessen_hunger() +} void set_hunger( int new_hunger_level, bool suppress_msg ) { @@ -918,6 +918,7 @@ static bool _food_change(bool suppress_message) state_changed = true; if (newstate > you.hunger_state) less_hungry = true; + you.hunger_state = newstate; set_redraw_status( REDRAW_HUNGER ); @@ -946,18 +947,19 @@ static bool _food_change(bool suppress_message) else if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT && you.duration[DUR_TRANSFORMATION] > 5) { + print_stats(); mpr("Your blood-filled body can't sustain your transformation " "much longer.", MSGCH_WARN); - // give more time because suddenly stopping flying can be lethal + + // Give more time because suddenly stopping flying can be fatal. you.duration[DUR_TRANSFORMATION] = 5; - if (is_vampire_feeding()) - stop_delay(); } - if (newstate == HS_ENGORGED && is_vampire_feeding()) // Alive + else if (newstate == HS_ENGORGED && is_vampire_feeding()) // Alive { + print_stats(); mpr("You can't stomach any more blood right now."); - stop_delay(); } + } if (!suppress_message) @@ -970,6 +972,7 @@ static bool _food_change(bool suppress_message) msg += "feel devoid of blood!"; else msg += "are starving!"; + mpr(msg.c_str(), MSGCH_FOOD, less_hungry); // Xom thinks this is funny if you're in a labyrinth @@ -989,15 +992,8 @@ static bool _food_change(bool suppress_message) msg += "feel almost devoid of blood!"; else msg += "are near starving!"; - mpr(msg.c_str(), MSGCH_FOOD, less_hungry); - // Xom thinks this is funny if you're in a labyrinth - // and are low on food. - if (you.level_type == LEVEL_LABYRINTH - && !_player_has_enough_food()) - { - xom_is_stimulated(32); - } + mpr(msg.c_str(), MSGCH_FOOD, less_hungry); learned_something_new(TUT_YOU_HUNGRY); break; @@ -1031,7 +1027,7 @@ static void _describe_food_change(int food_increment) if (magnitude == 0) return; - if ( magnitude <= 100 ) + if (magnitude <= 100) msg = "You feel slightly "; else if (magnitude <= 350) msg = "You feel somewhat "; @@ -1048,7 +1044,7 @@ static void _describe_food_change(int food_increment) msg += _how_hungry().c_str(); msg += "."; mpr(msg.c_str()); -} // end describe_food_change() +} static bool _player_can_eat_rotten_meat(bool need_msg = false) { @@ -1728,7 +1724,7 @@ void vampire_nutrition_per_turn(const item_def &corpse, int feeding) const int chunk_type = _determine_chunk_effect( mons_corpse_effect(mons_type), false); - // This is the exact formula of corpse nutrition for chunk lovers + // This is the exact formula of corpse nutrition for chunk lovers. const int max_chunks = mons_weight(mons_type)/150; int chunk_amount = 1 + max_chunks/2; chunk_amount = stepdown_value( chunk_amount, 4, 4, 12, 12 ); diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 0e88083723..6ab46233b2 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -768,8 +768,9 @@ static void _print_status_lights(int y) size_t i_light = 0; while (true) { - const int end_x = (wherex() - crawl_view.hudp.x) + - (i_light < lights.size() ? strlen(lights[i_light].text) : 10000); + const int end_x = (wherex() - crawl_view.hudp.x) + + (i_light < lights.size() ? strlen(lights[i_light].text) + : 10000); if (end_x <= crawl_view.hudsz.x) { @@ -777,12 +778,12 @@ static void _print_status_lights(int y) cprintf("%s", lights[i_light].text); if (end_x < crawl_view.hudsz.x) cprintf(" "); - ++ i_light; + ++i_light; } else { clear_to_end_of_line(); - ++ line_cur; + ++line_cur; // Careful not to trip the )#(*$ cgotoxy ASSERT if (line_cur == line_end) break; @@ -804,14 +805,15 @@ void print_stats(void) if (you.redraw_dexterity) you.redraw_evasion = true; - if (HP_Bar.wants_redraw()) you.redraw_hit_points = true; - if (MP_Bar.wants_redraw()) you.redraw_magic_points = true; + if (HP_Bar.wants_redraw()) + you.redraw_hit_points = true; + if (MP_Bar.wants_redraw()) + you.redraw_magic_points = true; if (you.redraw_hit_points) { you.redraw_hit_points = false; _print_stats_hp ( 1, 3); } if (you.redraw_magic_points) { you.redraw_magic_points = false; _print_stats_mp ( 1, 4); } if (you.redraw_armour_class) { you.redraw_armour_class = false; _print_stats_ac ( 1, 5); } if (you.redraw_evasion) { you.redraw_evasion = false; _print_stats_ev ( 1, 6); } - // (you.redraw_armour_class) { you.redraw_armour_class = false; _print_stats_sh ( 1, 7); } if (you.redraw_strength) { you.redraw_strength = false; _print_stats_str(19, 5); } if (you.redraw_intelligence) { you.redraw_intelligence = false; _print_stats_int(19, 6); } diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index b5eb5c6362..6f5d247326 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -3015,7 +3015,7 @@ static void _draw_level_map(int start_x, int start_y, bool travel_mode) cursor_control cs(false); int top = 1 + Options.level_map_title; - if ( Options.level_map_title ) + if (Options.level_map_title) { const formatted_string help = formatted_string::parse_string("(Press ? for help)"); @@ -4956,8 +4956,7 @@ void viewwindow(bool draw_it, bool do_updates) // have a monster or cloud on it, and is equal // to the grid before monsters and clouds were // added otherwise. - if (Options.clean_map - && Show_Backup(ep) + if (Options.clean_map && Show_Backup(ep) && is_terrain_seen( gc.x, gc.y )) { _get_symbol( gc.x, gc.y, -- cgit v1.2.3-54-g00ecf