diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-06 20:14:35 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-06 20:14:35 +0000 |
commit | 44d7fbb36c55859117824fe25a298afbe437221b (patch) | |
tree | 8854c7d492879cb8ddda79ca91f44d964c5828a9 /crawl-ref | |
parent | b847d4bad842066f8721cf68650d5087528e8486 (diff) | |
download | crawl-ref-44d7fbb36c55859117824fe25a298afbe437221b.tar.gz crawl-ref-44d7fbb36c55859117824fe25a298afbe437221b.zip |
Fix 1870427: Max hp misreported if frail and rotted.
Fix 2002931: feature_item_brand not working
No, it's not the important bugs, but at least these are bugs I can
reproduce. :P
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6433 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/defines.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/initfile.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/libunix.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/output.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 49 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/skills2.cc | 38 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 18 |
8 files changed, 81 insertions, 63 deletions
diff --git a/crawl-ref/source/defines.h b/crawl-ref/source/defines.h index 267e81ffce..4ee5296b04 100644 --- a/crawl-ref/source/defines.h +++ b/crawl-ref/source/defines.h @@ -8,7 +8,7 @@ * because there are in numerical order. But I'm too lazy to * do it myself. * - * Copyright © 1999 Brian Robinson. // Me? How come? + * Copyright � 1999 Brian Robinson. // Me? How come? * * Modified for Crawl Reference by $Author$ on $Date$ * @@ -262,7 +262,7 @@ const int LABYRINTH_BORDER = 4; #define COLFLAG_WILLSTAB 0x0400 #define COLFLAG_MAYSTAB 0x0800 #define COLFLAG_ITEM_HEAP 0x1000 - #define COLFLAG_STAIR_ITEM 0x2000 + #define COLFLAG_FEATURE_ITEM 0x2000 #define COLFLAG_TRAP_ITEM 0x4000 #define COLFLAG_REVERSE 0x8000 #define COLFLAG_MASK 0xFF00 diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index ed89744d20..9745be3425 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -420,14 +420,18 @@ static unsigned curses_attribute(const std::string &field) int col = field.find(":"); int colour = str_to_colour(field.substr(col + 1)); if (colour == -1) + { crawl_state.add_startup_error( make_stringf("Bad highlight string -- %s\n", field.c_str())); + } else return CHATTR_HILITE | (colour << 8); } else if (field != "none") + { crawl_state.add_startup_error( make_stringf( "Bad colour -- %s\n", field.c_str() ) ); + } return CHATTR_NORMAL; } @@ -2034,7 +2038,7 @@ void game_options::read_option_line(const std::string &str, bool runscript) else CURSES_OPTION(neutral_brand); else CURSES_OPTION(stab_brand); else CURSES_OPTION(may_stab_brand); - else CURSES_OPTION_NAMED("stair_item_brand", feature_item_brand); + else CURSES_OPTION(feature_item_brand); else CURSES_OPTION(trap_item_brand); // This is useful for terms where dark grey does // not have standout modes (since it's black on black). diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc index eb66fb36ab..0859bc18f6 100644 --- a/crawl-ref/source/libunix.cc +++ b/crawl-ref/source/libunix.cc @@ -744,15 +744,15 @@ bool is_cursor_enabled() inline unsigned get_brand(int col) { - return (col & COLFLAG_FRIENDLY_MONSTER)? Options.friend_brand : - (col & COLFLAG_NEUTRAL_MONSTER)? Options.neutral_brand : - (col & COLFLAG_ITEM_HEAP)? Options.heap_brand : - (col & COLFLAG_WILLSTAB)? Options.stab_brand : - (col & COLFLAG_MAYSTAB)? Options.may_stab_brand : - (col & COLFLAG_STAIR_ITEM)? Options.feature_item_brand : - (col & COLFLAG_TRAP_ITEM)? Options.trap_item_brand : - (col & COLFLAG_REVERSE)? CHATTR_REVERSE : - CHATTR_NORMAL; + return (col & COLFLAG_FRIENDLY_MONSTER) ? Options.friend_brand : + (col & COLFLAG_NEUTRAL_MONSTER) ? Options.neutral_brand : + (col & COLFLAG_ITEM_HEAP) ? Options.heap_brand : + (col & COLFLAG_WILLSTAB) ? Options.stab_brand : + (col & COLFLAG_MAYSTAB) ? Options.may_stab_brand : + (col & COLFLAG_FEATURE_ITEM) ? Options.feature_item_brand : + (col & COLFLAG_TRAP_ITEM) ? Options.trap_item_brand : + (col & COLFLAG_REVERSE) ? CHATTR_REVERSE + : CHATTR_NORMAL; } void textattr(int col) diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index aaa206bd50..c5ff49069e 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -307,7 +307,7 @@ static void _print_stats_mp(int x, int y) static void _print_stats_hp(int x, int y) { - const int max_max_hp = you.hp_max + player_rotted(); + const int max_max_hp = get_real_hp(true, true); // Calculate colour short hp_colour = HUD_VALUE_COLOR; @@ -315,8 +315,8 @@ static void _print_stats_hp(int x, int y) const int hp_percent = (you.hp * 100) / (max_max_hp ? max_max_hp : you.hp); - for ( unsigned int i = 0; i < Options.hp_colour.size(); ++i ) - if ( hp_percent <= Options.hp_colour[i].first ) + for (unsigned int i = 0; i < Options.hp_colour.size(); ++i) + if (hp_percent <= Options.hp_colour[i].first) hp_colour = Options.hp_colour[i].second; } @@ -1751,11 +1751,11 @@ static std::vector<formatted_string> _get_overview_stats() column_composer cols1(4, 18, 28, 40); if (!player_rotted()) - snprintf(buf, sizeof buf, "HP %3d/%d",you.hp,you.hp_max); + snprintf(buf, sizeof buf, "HP %3d/%d", you.hp, you.hp_max); else { snprintf(buf, sizeof buf, "HP %3d/%d (%d)", - you.hp, you.hp_max, you.hp_max + player_rotted() ); + you.hp, you.hp_max, get_real_hp(true, true) ); } cols1.add_formatted(0, buf, false); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 4ded8c08f8..252bbe152c 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -4876,6 +4876,55 @@ void set_mp(int new_amount, bool max_too) you.redraw_magic_points = true; } +// If trans is true, being berserk and/or transformed is taken into account +// here. Else, the base hp is calculated. If rotted is true, calculate the +// real max hp you'd have if the rotting was cured. +int get_real_hp(bool trans, bool rotted) +{ + int hitp; + + hitp = (you.base_hp - 5000) + (you.base_hp2 - 5000); + hitp += (you.experience_level * you.skills[SK_FIGHTING]) / 5; + + // Being berserk makes you resistant to damage. I don't know why. + if (trans && you.duration[DUR_BERSERKER]) + { + hitp *= 15; + hitp /= 10; + } + + if (trans) + { + // Some transformations give you extra hp. + switch (you.attribute[ATTR_TRANSFORMATION]) + { + case TRAN_STATUE: + hitp *= 15; + hitp /= 10; + break; + case TRAN_ICE_BEAST: + hitp *= 12; + hitp /= 10; + break; + case TRAN_DRAGON: + hitp *= 16; + hitp /= 10; + break; + } + } + + if (rotted) + hitp += player_rotted(); + + // Frail and robust mutations, and divine robustness. + hitp *= (10 + player_mutation_level(MUT_ROBUST) + + you.attribute[ATTR_DIVINE_ROBUSTNESS] + - player_mutation_level(MUT_FRAIL)); + hitp /= 10; + + return (hitp); +} + static int _get_contamination_level() { const int glow = you.magic_contamination; diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index a00dd66937..a1bd79ac52 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -398,6 +398,7 @@ void deflate_hp(int new_level, bool floor); * *********************************************************************** */ void set_hp(int new_amount, bool max_too); +int get_real_hp(bool trans, bool rotted = false); /* *********************************************************************** * called from: it_use3 - newgame diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index 3b7e045ecf..9653007a8b 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -2188,43 +2188,7 @@ void init_skill_order( void ) int calc_hp(bool real_hp) { - int hitp; - - hitp = (you.base_hp - 5000) + (you.base_hp2 - 5000); - hitp += (you.experience_level * you.skills[SK_FIGHTING]) / 5; - - // being berserk makes you resistant to damage. I don't know why. - if (you.duration[DUR_BERSERKER] && !real_hp) - { - hitp *= 15; - hitp /= 10; - } - - if (!real_hp) - { - // some transformations give you extra hp - switch (you.attribute[ATTR_TRANSFORMATION]) - { - case TRAN_STATUE: - hitp *= 15; - hitp /= 10; - break; - case TRAN_ICE_BEAST: - hitp *= 12; - hitp /= 10; - break; - case TRAN_DRAGON: - hitp *= 16; - hitp /= 10; - break; - } - } - - // frail and robust mutations, and divine robustness - hitp *= (10 + player_mutation_level(MUT_ROBUST) - + you.attribute[ATTR_DIVINE_ROBUSTNESS] - - player_mutation_level(MUT_FRAIL)); - hitp /= 10; + int hitp = get_real_hp(!real_hp, false); you.hp_max = hitp; diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index a8a070e17d..89cc37c67c 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -319,7 +319,7 @@ static unsigned _colflag2brand(int colflag) return (Options.stab_brand); case COLFLAG_MAYSTAB: return (Options.may_stab_brand); - case COLFLAG_STAIR_ITEM: + case COLFLAG_FEATURE_ITEM: return (Options.feature_item_brand); case COLFLAG_TRAP_ITEM: return (Options.trap_item_brand); @@ -398,7 +398,7 @@ static bool _show_bloodcovered(int x, int y) dungeon_feature_type grid = grd[x][y]; - // altars, stairs (of any kind) and traps should not be coloured red + // Altars, stairs (of any kind) and traps should not be coloured red. return (!is_critical_feature(grid) && !grid_is_trap(grid)); } @@ -653,11 +653,10 @@ screen_buffer_t colour_code_map( int x, int y, bool item_colour, tc = feature_colour; if (Options.feature_item_brand - && (is_stair(grid_value) || grid_altar_god(grid_value) != GOD_NO_GOD - || grid_value == DNGN_ENTER_SHOP || grid_is_portal(grid_value)) + && is_critical_feature(grid_value) && igrd[x][y] != NON_ITEM) { - tc |= COLFLAG_STAIR_ITEM; + tc |= COLFLAG_FEATURE_ITEM; } else if (Options.trap_item_brand && grid_is_trap(grid_value) && igrd[x][y] != NON_ITEM) @@ -758,9 +757,10 @@ int get_mons_colour(const monsters *mons) else if (mons_is_stationary(mons)) { if (Options.feature_item_brand != CHATTR_NORMAL + && is_critical_feature(grd(mons->pos())) && grid_stair_direction(grd(mons->pos())) != CMD_NO_CMD) { - col |= COLFLAG_STAIR_ITEM; + col |= COLFLAG_FEATURE_ITEM; } else if (Options.heap_brand != CHATTR_NORMAL && igrd(mons->pos()) != NON_ITEM) @@ -1343,13 +1343,13 @@ inline static void _update_item_grid(const coord_def &gp, const coord_def &ep) unsigned short &ecol = env.show_col(ep); const dungeon_feature_type grid = grd(gp); - if (Options.feature_item_brand && is_stair(grid)) - ecol |= COLFLAG_STAIR_ITEM; + if (Options.feature_item_brand && is_critical_feature(grid)) + ecol |= COLFLAG_FEATURE_ITEM; else if (Options.trap_item_brand && grid_is_trap(grid)) ecol |= COLFLAG_TRAP_ITEM; else { - ecol = (grid == DNGN_SHALLOW_WATER)? CYAN : eitem.colour; + ecol = (grid == DNGN_SHALLOW_WATER) ? CYAN : eitem.colour; if (eitem.link != NON_ITEM) ecol |= COLFLAG_ITEM_HEAP; env.show(ep) = _get_item_dngn_code( eitem ); |