diff options
-rw-r--r-- | crawl-ref/docs/options_guide.txt | 9 | ||||
-rw-r--r-- | crawl-ref/settings/init.txt | 1 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/externs.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 27 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 31 | ||||
-rw-r--r-- | crawl-ref/source/misc.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/mutation.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/output.cc | 107 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 85 | ||||
-rw-r--r-- | crawl-ref/source/transfor.cc | 28 | ||||
-rw-r--r-- | crawl-ref/source/transfor.h | 5 |
12 files changed, 207 insertions, 96 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index 2896881009..30ee80e321 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -61,7 +61,7 @@ The contents of this text are: prompt_for_swap, easy_quit_item_prompts, easy_exit_menu, sort_menus 4-j Message and Display Improvements. - hp_warning, mp_warning, hp_colour, mp_colour, + hp_warning, mp_warning, hp_colour, mp_colour, stat_colour, status_caption_colour, delay_message_clear, message_colour, show_inventory_weights, show_gold_turns, show_beam, item_stack_summary_minimum, list_rotten, @@ -1152,6 +1152,13 @@ hp_colour = 50:yellow, 25:red mp_colour = 50:yellow, 25:red mp_colour does to Magic what hp_colour does to Health. +stat_colour = 1:lightred, 3:red + stat_colour colours your stats if they drop below a given value, + in the order of their definition. This check takes place before + the ones for e.g. Might or degeneration. + For normal grey colouring, set it to + stat_colour = 7 + status_caption_colour = brown Sets the colour that is used to display the captions in the status area (for instance the "Health:" in "Health: 10/10"). diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index 668ecdf6b3..debc523c6c 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -232,6 +232,7 @@ sort_menus = inv: true : equipped # mp_warning = 0 # hp_colour = 50:yellow, 25:red # mp_colour = 50:yellow, 25:red +# stat_colour = 1:lightred, 3:red # status_caption_colour = yellow # classic_hud = true diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 3750b72eb4..c6bb78faaf 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -2265,7 +2265,7 @@ void describe_floor() msg_channel_type channel = MSGCH_EXAMINE; - // Water is not terribly important if you don't mind it- + // Water is not terribly important if you don't mind it. if ((grd(you.pos()) == DNGN_DEEP_WATER || grd(you.pos()) == DNGN_SHALLOW_WATER) && player_likes_water()) diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 301b663592..520d7f08b1 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1996,6 +1996,7 @@ public: std::vector<std::pair<int, int> > hp_colour; std::vector<std::pair<int, int> > mp_colour; + std::vector<std::pair<int, int> > stat_colour; std::string map_file_name; // name of mapping file to use std::vector<std::pair<text_pattern, bool> > force_autopickup; diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 856b35d5c5..14e9e69f57 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -895,6 +895,9 @@ void game_options::reset_options() mp_colour.clear(); mp_colour.push_back(std::pair<int, int>(50, YELLOW)); mp_colour.push_back(std::pair<int, int>(25, RED)); + stat_colour.clear(); + stat_colour.push_back(std::pair<int, int>(1, LIGHTRED)); + stat_colour.push_back(std::pair<int, int>(3, RED)); force_autopickup.clear(); note_monsters.clear(); @@ -2486,6 +2489,30 @@ void game_options::read_option_line(const std::string &str, bool runscript) mp_colour.push_back(std::pair<int, int>(mp_percent, scolour)); } } + else if (key == "stat_colour" || key == "stat_color") + { + stat_colour.clear(); + std::vector<std::string> thesplit = split_string(",", field); + for (unsigned i = 0; i < thesplit.size(); ++i) + { + std::vector<std::string> insplit = split_string(":", thesplit[i]); + + if (insplit.size() == 0 || insplit.size() > 2 + || insplit.size() == 1 && i != 0) + { + crawl_state.add_startup_error( + make_stringf("Bad stat_colour string: %s\n", field.c_str())); + break; + } + + int stat_limit = 1; + if (insplit.size() == 2 ) + stat_limit = atoi(insplit[0].c_str()); + + int scolour = str_to_colour(insplit[(insplit.size() == 1) ? 0 : 1]); + stat_colour.push_back(std::pair<int, int>(stat_limit, scolour)); + } + } else if (key == "note_skill_levels") { std::vector<std::string> thesplit = split_string(",", field); diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 0c3ae915f3..b28934a945 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1242,11 +1242,9 @@ void search_around( bool only_adjacent ) // Traps and doors stepdown skill: // skill/(2x-1) for squares at distance x int max_dist = (you.skills[SK_TRAPS_DOORS] + 1) / 2; - if ( max_dist > 5 ) + if (max_dist > 5) max_dist = 5; - if ( max_dist > 1 && only_adjacent ) - max_dist = 1; - if ( max_dist < 1 ) + if (only_adjacent && max_dist > 1 || max_dist < 1) max_dist = 1; for (radius_iterator ri(you.pos(), max_dist); ri; ++ri ) @@ -1297,21 +1295,36 @@ void search_around( bool only_adjacent ) } } -void merfolk_start_swimming(void) +bool merfolk_change_is_safe(bool quiet) +{ + // If already transformed, no subsequent transformation necessary. + if (!player_is_airborne() && grid_is_water(grd(you.pos()))) + return (true); + + std::set<equipment_type> r; + r.insert(EQ_BOOTS); + if (!player_light_armour()) + r.insert(EQ_BODY_ARMOUR); + + if (check_transformation_stat_loss(r, quiet)) + return (false); + + return (true); +} + +void merfolk_start_swimming() { if (you.attribute[ATTR_TRANSFORMATION] != TRAN_NONE) untransform(); - std::set<equipment_type> removed; - removed.insert(EQ_BOOTS); + remove_one_equip(EQ_BOOTS); // Perhaps a bit to easy for the player, but we allow merfolk // to slide out of heavy body armour freely when entering water, // rather than handling emcumbered swimming. -- bwr if (!player_light_armour()) - removed.insert(EQ_BODY_ARMOUR); + remove_one_equip(EQ_BODY_ARMOUR, false); - remove_equipment(removed); you.redraw_evasion = true; } diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index 5394cea642..762f548c06 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -20,6 +20,7 @@ void search_around( bool only_adjacent = false ); void down_stairs(int old_level, dungeon_feature_type force_stair = DNGN_UNSEEN, entry_cause_type entry_cause = EC_UNKNOWN); +bool merfolk_change_is_safe(bool quiet = false); void merfolk_start_swimming(); void new_level(); void trackers_init_new_level(bool transit); diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index 97ecc63231..ddd5d3e57c 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -2182,7 +2182,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, // Hooves and talons force boots off. if (you_tran_can_wear(EQ_BOOTS)) - remove_one_equip(EQ_BOOTS); + remove_one_equip(EQ_BOOTS, false); break; case MUT_CLAWS: @@ -2194,7 +2194,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, // mutation yet, so we have to check for level 2 or higher claws // here. if (you.mutation[mutat] >= 2 && you_tran_can_wear(EQ_GLOVES)) - remove_one_equip(EQ_GLOVES); + remove_one_equip(EQ_GLOVES, false); break; case MUT_HORNS: @@ -2206,7 +2206,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, && is_hard_helmet(you.inv[you.equip[EQ_HELMET]]) && you_tran_can_wear(EQ_HELMET)) { - remove_one_equip(EQ_HELMET); + remove_one_equip(EQ_HELMET, false); } break; diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index ec6343346b..22a9e1a186 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -53,8 +53,8 @@ // Color for captions like 'Health:', 'Str:', etc. #define HUD_CAPTION_COLOR Options.status_caption_colour -// Color for values, which come after captions. -static const short HUD_VALUE_COLOR = LIGHTGREY; +// Colour for values, which come after captions. +static const short HUD_VALUE_COLOUR = LIGHTGREY; // ---------------------------------------------------------------------- // colour_bar @@ -227,7 +227,7 @@ void update_turn_count() cgotoxy(19+6, 8, GOTO_STAT); // Show the turn count starting from 1. You can still quit on turn 0. - textcolor(HUD_VALUE_COLOR); + textcolor(HUD_VALUE_COLOUR); cprintf("%ld", you.num_turns); textcolor(LIGHTGREY); } @@ -280,20 +280,21 @@ static const char* _describe_hunger(int& color) static void _print_stats_mp(int x, int y) { // Calculate colour - short mp_colour = HUD_VALUE_COLOR; + short mp_colour = HUD_VALUE_COLOUR; { int mp_percent = (you.max_magic_points == 0 ? 100 : (you.magic_points * 100) / you.max_magic_points); - for ( unsigned int i = 0; i < Options.mp_colour.size(); ++i ) - if ( mp_percent <= Options.mp_colour[i].first ) + + for (unsigned int i = 0; i < Options.mp_colour.size(); ++i) + if (mp_percent <= Options.mp_colour[i].first) mp_colour = Options.mp_colour[i].second; } cgotoxy(x+8, y, GOTO_STAT); textcolor(mp_colour); cprintf("%d", you.magic_points); - textcolor(HUD_VALUE_COLOR); + textcolor(HUD_VALUE_COLOUR); cprintf("/%d", you.max_magic_points ); int col = _count_digits(you.magic_points) @@ -310,7 +311,7 @@ static void _print_stats_hp(int x, int y) const int max_max_hp = get_real_hp(true, true); // Calculate colour - short hp_colour = HUD_VALUE_COLOR; + short hp_colour = HUD_VALUE_COLOUR; { const int hp_percent = (you.hp * 100) / (max_max_hp ? max_max_hp : you.hp); @@ -327,7 +328,7 @@ static void _print_stats_hp(int x, int y) cprintf(max_max_hp != you.hp_max ? "HP: " : "Health: "); textcolor(hp_colour); cprintf( "%d", you.hp ); - textcolor(HUD_VALUE_COLOR); + textcolor(HUD_VALUE_COLOUR); cprintf( "/%d", you.hp_max ); if (max_max_hp != you.hp_max) cprintf( " (%d)", max_max_hp ); @@ -336,10 +337,50 @@ static void _print_stats_hp(int x, int y) for (int i = 18-col; i > 0; i--) cprintf(" "); - if (! Options.classic_hud) + if (!Options.classic_hud) HP_Bar.draw(19, y, you.hp, you.hp_max); } +short _get_stat_colour(stat_type stat) +{ + int val = 0, max_val = 0; + switch (stat) + { + case STAT_STRENGTH: + val = you.strength; + max_val = you.max_strength; + break; + case STAT_INTELLIGENCE: + val = you.intel; + max_val = you.max_intel; + break; + case STAT_DEXTERITY: + val = you.dex; + max_val = you.max_dex; + break; + default: + ASSERT(false); + } + + // Check the stat_colour option for warning thresholds. + for (unsigned int i = 0; i < Options.stat_colour.size(); ++i) + if (val <= Options.stat_colour[i].first) + return (Options.stat_colour[i].second); + + // Stat is magically increased. + if (you.duration[DUR_DIVINE_STAMINA] + || stat == STAT_STRENGTH && you.duration[DUR_MIGHT]) + { + return (LIGHTBLUE); // no end of effect warning + } + + // Stat is degenerated. + if (val < max_val) + return (YELLOW); + + return (HUD_VALUE_COLOUR); +} + // XXX: alters state! Does more than just print! static void _print_stats_str(int x, int y) { @@ -353,13 +394,7 @@ static void _print_stats_str(int x, int y) cgotoxy(x+5, y, GOTO_STAT); - if (you.duration[DUR_MIGHT] || you.duration[DUR_DIVINE_STAMINA]) - textcolor(LIGHTBLUE); // no end of effect warning - else if (you.strength < you.max_strength) - textcolor(YELLOW); - else - textcolor(HUD_VALUE_COLOR); - + textcolor(_get_stat_colour(STAT_STRENGTH)); cprintf( "%d", you.strength ); if (you.strength != you.max_strength) @@ -382,13 +417,7 @@ static void _print_stats_int(int x, int y) cgotoxy(x+5, y, GOTO_STAT); - if (you.duration[DUR_DIVINE_STAMINA]) - textcolor(LIGHTBLUE); // no end of effect warning - else if (you.intel < you.max_intel) - textcolor(YELLOW); - else - textcolor(HUD_VALUE_COLOR); - + textcolor(_get_stat_colour(STAT_INTELLIGENCE)); cprintf( "%d", you.intel ); if (you.intel != you.max_intel) @@ -409,13 +438,7 @@ static void _print_stats_dex(int x, int y) cgotoxy(x+5, y, GOTO_STAT); - if (you.duration[DUR_DIVINE_STAMINA]) - textcolor(LIGHTBLUE); // no end of effect warning - else if (you.dex < you.max_dex) - textcolor(YELLOW); - else - textcolor(HUD_VALUE_COLOR); - + textcolor(_get_stat_colour(STAT_DEXTERITY)); cprintf( "%d", you.dex ); if (you.dex != you.max_dex) @@ -433,7 +456,7 @@ static void _print_stats_ac(int x, int y) else if (you.duration[DUR_ICY_ARMOUR] || you.duration[DUR_STONESKIN]) textcolor( LIGHTBLUE ); else - textcolor( HUD_VALUE_COLOR ); + textcolor( HUD_VALUE_COLOUR ); cprintf( "%2d ", player_AC() ); // SH: (two lines lower) @@ -441,14 +464,14 @@ static void _print_stats_ac(int x, int y) if (you.duration[DUR_CONDENSATION_SHIELD] || you.duration[DUR_DIVINE_SHIELD]) textcolor( LIGHTBLUE ); else - textcolor( HUD_VALUE_COLOR ); + textcolor( HUD_VALUE_COLOUR ); cprintf( "%2d ", player_shield_class() ); } static void _print_stats_ev(int x, int y) { cgotoxy(x+4, y, GOTO_STAT); - textcolor(you.duration[DUR_FORESCRY] ? LIGHTBLUE : HUD_VALUE_COLOR); + textcolor(you.duration[DUR_FORESCRY] ? LIGHTBLUE : HUD_VALUE_COLOUR); cprintf( "%2d ", player_evasion() ); } @@ -834,7 +857,7 @@ void print_stats(void) // Increase y-value for all following lines. yhack = 1; cgotoxy(1+6, 8, GOTO_STAT); - textcolor(HUD_VALUE_COLOR); + textcolor(HUD_VALUE_COLOUR); cprintf("%d", you.gold); } @@ -843,7 +866,7 @@ void print_stats(void) cgotoxy(1,8 + yhack, GOTO_STAT); textcolor(Options.status_caption_colour); cprintf("Exp Pool: "); - textcolor(HUD_VALUE_COLOR); + textcolor(HUD_VALUE_COLOUR); #if DEBUG_DIAGNOSTICS cprintf("%d/%d (%d) ", you.skill_cost_level, you.exp_available, you.experience); @@ -935,7 +958,7 @@ void print_stats_level() textcolor(HUD_CAPTION_COLOR); cprintf("Place: "); - textcolor(HUD_VALUE_COLOR); + textcolor(HUD_VALUE_COLOUR); #if DEBUG_DIAGNOSTICS cprintf( "(%d) ", you.your_level + 1 ); #endif @@ -1658,14 +1681,20 @@ static void _print_overview_screen_equip(column_composer& cols, { const int item_idx = you.equip[e_order[i]]; const item_def& item = you.inv[item_idx]; - const char* colname = colour_to_str(item.colour).c_str(); + + // Colour melded equipment dark grey. + const char* colname = + player_wearing_slot(e_order[i]) ? + colour_to_str(item.colour).c_str() : "darkgrey"; + const char equip_char = index_to_letter(item_idx); snprintf(buf, sizeof buf, - "%s<w>%c</w> - <%s>%s</%s>", + "%s<w>%c</w> - <%s>%s%s</%s>", slot, equip_char, colname, + !player_wearing_slot(e_order[i]) ? "melded " : "", item.name(DESC_PLAIN, true).substr(0,42).c_str(), colname); equip_chars.push_back(equip_char); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index ae98021ff6..526e6358eb 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -223,48 +223,64 @@ bool move_player_to_grid( const coord_def& p, bool stepped, bool allow_shift, // Only consider terrain if player is not levitating. if (!player_is_airborne()) { - // XXX: at some point we're going to need to fix the swimming - // code to handle burden states. - if (is_grid_dangerous(new_grid)) + bool merfolk_check = false; + if (you.species == SP_MERFOLK) { - // lava and dangerous deep water (ie not merfolk) - const coord_def entry = (stepped) ? you.pos() : p; + if (grid_is_water(new_grid)) + merfolk_check = true; - if (stepped && !force && !you.confused()) + // Safer water effects. + if (grid_is_water(new_grid) && !grid_is_water(old_grid)) { - canned_msg(MSG_UNTHINKING_ACT); - return (false); - } - - // Have to move now so fall_into_a_pool will work. - you.moveto(p); + // Check for fatal stat loss due to transforming. + // Also handles the warning message. + if (!merfolk_change_is_safe()) + { + stop_running(); + you.turn_is_over = false; + return (false); + } - viewwindow( true, false ); + if (stepped) + mpr("Your legs become a tail as you enter the water."); + else + mpr("Your legs become a tail as you dive into the water."); - // If true, we were shifted and so we're done. - if (fall_into_a_pool( entry, allow_shift, new_grid )) - return (true); + merfolk_start_swimming(); + } + else if (!grid_is_water(new_grid) && grid_is_water(old_grid)) + { + unmeld_one_equip(EQ_BOOTS); + you.redraw_evasion = true; + } } - else if (new_grid == DNGN_SHALLOW_WATER || new_grid == DNGN_DEEP_WATER) + + if (!merfolk_check) { - // Safer water effects. - if (you.species == SP_MERFOLK) + // XXX: at some point we're going to need to fix the swimming + // code to handle burden states. + if (is_grid_dangerous(new_grid)) { - if (old_grid != DNGN_SHALLOW_WATER - && old_grid != DNGN_DEEP_WATER) - { - if (stepped) - mpr("Your legs become a tail as you enter the water."); - else - mpr("Your legs become a tail as you dive into the water."); + // Lava and dangerous deep water (ie not merfolk). + const coord_def entry = (stepped) ? you.pos() : p; - merfolk_start_swimming(); + if (stepped && !force && !you.confused()) + { + canned_msg(MSG_UNTHINKING_ACT); + return (false); } + + // Have to move now so fall_into_a_pool will work. + you.moveto(p); + + viewwindow( true, false ); + + // If true, we were shifted and so we're done. + if (fall_into_a_pool( entry, allow_shift, new_grid )) + return (true); } - else if (!player_likes_water()) + else if (new_grid == DNGN_SHALLOW_WATER && !player_likes_water()) { - ASSERT( new_grid != DNGN_DEEP_WATER ); - if (!stepped) noisy(SL_SPLASH, you.pos(), "Splash!"); @@ -283,11 +299,6 @@ bool move_player_to_grid( const coord_def& p, bool stepped, bool allow_shift, } } } - else if (!grid_is_water(new_grid) && grid_is_water(old_grid) - && you.species == SP_MERFOLK) - { - you.redraw_evasion = true; - } } // Move the player to new location. @@ -5886,7 +5897,9 @@ bool player::in_water() const bool player::can_swim() const { - return (species == SP_MERFOLK); + // Transforming could be fatal if it would cause unequipment of + // stat-boosting boots or heavy armour. + return (species == SP_MERFOLK && merfolk_change_is_safe(true)); } bool player::swimming() const diff --git a/crawl-ref/source/transfor.cc b/crawl-ref/source/transfor.cc index f891c90804..43fea5e51e 100644 --- a/crawl-ref/source/transfor.cc +++ b/crawl-ref/source/transfor.cc @@ -90,7 +90,7 @@ static void _init_equipment_removal(std::set<equipment_type> &rem_stuff, } } -bool remove_equipment(std::set<equipment_type> removed) +bool remove_equipment(std::set<equipment_type> removed, bool meld) { if (removed.find(EQ_WEAPON) != removed.end() && you.equip[EQ_WEAPON] != -1) @@ -109,8 +109,11 @@ bool remove_equipment(std::set<equipment_type> removed) if (e == EQ_WEAPON || you.equip[e] == -1) continue; - mprf("%s melds into your body.", - you.inv[you.equip[e]].name(DESC_CAP_YOUR).c_str()); + if (meld) + { + mprf("%s melds into your body.", + you.inv[you.equip[e]].name(DESC_CAP_YOUR).c_str()); + } if (e == EQ_LEFT_RING || e == EQ_RIGHT_RING || e == EQ_AMULET) { @@ -121,6 +124,14 @@ bool remove_equipment(std::set<equipment_type> removed) { unwear_armour( you.equip[e] ); } + + if (!meld) + { + mprf("%s falls away!", + you.inv[you.equip[e]].name(DESC_CAP_YOUR).c_str()); + + you.equip[e] = -1; + } } return (true); @@ -197,11 +208,18 @@ static bool _unmeld_equipment(std::set<equipment_type> melded) return (true); } -bool remove_one_equip(equipment_type eq) +bool unmeld_one_equip(equipment_type eq) +{ + std::set<equipment_type> e; + e.insert(eq); + return _unmeld_equipment(e); +} + +bool remove_one_equip(equipment_type eq, bool meld) { std::set<equipment_type> r; r.insert(eq); - return remove_equipment(r); + return remove_equipment(r, meld); } static bool _tran_may_meld_cursed(int transformation) diff --git a/crawl-ref/source/transfor.h b/crawl-ref/source/transfor.h index f7d8361e02..86a7d9c5ce 100644 --- a/crawl-ref/source/transfor.h +++ b/crawl-ref/source/transfor.h @@ -60,8 +60,9 @@ bool transform(int pow, transformation_type which_trans, bool quiet = false); /* *********************************************************************** * called from: mutation - transfor * *********************************************************************** */ -bool remove_equipment( std::set<equipment_type> remove_stuff ); -bool remove_one_equip(equipment_type eq); +bool remove_equipment(std::set<equipment_type> remove_stuff, bool meld = true); +bool remove_one_equip(equipment_type eq, bool meld = true); +bool unmeld_one_equip(equipment_type eq); bool transform_changed_physiology( bool phys_scales = false ); |