From fe2bf66390e67cdb54c0a8e455689258e6fa4ef2 Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Sun, 20 Dec 2009 17:27:24 +0100 Subject: Make clarity prevent berserk. Only Trog may override this, and even then, there's a penalty to success rate. --- crawl-ref/source/abl-show.cc | 9 ++++++--- crawl-ref/source/misc.cc | 4 ++-- crawl-ref/source/misc.h | 2 +- crawl-ref/source/player.cc | 21 ++++++++++++++++++++- crawl-ref/source/player.h | 2 +- 5 files changed, 30 insertions(+), 8 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index bb69c1b8d8..e0e46db98d 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -702,6 +702,8 @@ static talent _get_talent(ability_type ability, bool check_confused) case ABIL_TROG_BERSERK: // piety >= 30 invoc = true; failure = 30 - you.piety; // starts at 0% + if (player_mental_clarity(true)) + failure += 80; break; case ABIL_TROG_REGEN_MR: // piety >= 50 @@ -1102,7 +1104,8 @@ static bool _check_ability_possible(const ability_def& abil, mpr("You're too hungry to berserk."); return (false); } - return (you.can_go_berserk(true) && berserk_check_wielded_weapon()); + return (you.can_go_berserk(true, abil.ability == ABIL_TROG_BERSERK) + && berserk_check_wielded_weapon()); case ABIL_FLY_II: if (you.duration[DUR_EXHAUSTED]) @@ -1161,7 +1164,7 @@ static bool _activate_talent(const talent& tal) } if ((tal.which == ABIL_EVOKE_BERSERK || tal.which == ABIL_TROG_BERSERK) - && !you.can_go_berserk(true)) + && !you.can_go_berserk(true, tal.which == ABIL_TROG_BERSERK)) { crawl_state.zero_turns_taken(); return (false); @@ -1745,7 +1748,7 @@ static bool _do_ability(const ability_def& abil) case ABIL_TROG_BERSERK: // Trog abilities don't use or train invocations. - go_berserk(true); + go_berserk(true, true); break; case ABIL_TROG_REGEN_MR: diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index b528df7766..79bb102b1c 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2701,11 +2701,11 @@ bool scramble(void) return (true); } -bool go_berserk(bool intentional) +bool go_berserk(bool intentional, bool no_clarity) { ASSERT(!crawl_state.arena); - if (!you.can_go_berserk(intentional)) + if (!you.can_go_berserk(intentional, no_clarity)) return (false); if (Tutorial.tutorial_left) diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index 9f75955885..3c5cee6cbf 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -13,7 +13,7 @@ struct bolt; struct dist; struct activity_interrupt_data; -bool go_berserk(bool intentional); +bool go_berserk(bool intentional, bool no_clarity = false); void search_around(bool only_adjacent = false); void down_stairs(int old_level, dungeon_feature_type force_stair = DNGN_UNSEEN, diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 126a7539b1..a4b7f566b0 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5977,7 +5977,7 @@ bool player::can_go_berserk() const return (can_go_berserk(false)); } -bool player::can_go_berserk(bool verbose) const +bool player::can_go_berserk(bool verbose, bool no_clarity) const { if (berserk()) { @@ -6013,6 +6013,25 @@ bool player::can_go_berserk(bool verbose) const return (false); } + if (!no_clarity && player_mental_clarity(true)) + { + if (verbose) + { + mpr("You're too calm and focused to rage."); + item_def *amu; + if (!player_mental_clarity(false) && wearing_amulet(AMU_CLARITY) + && (amu = &you.inv[you.equip[EQ_AMULET]]) && !item_type_known(*amu)) + { + set_ident_type(amu->base_type, amu->sub_type, ID_KNOWN_TYPE); + set_ident_flags(*amu, ISFLAG_KNOW_PROPERTIES); + mprf("You are wearing: %s", + amu->name(DESC_INVENTORY_EQUIP).c_str()); + } + } + + return (false); + } + return (true); } diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index aebace1a3e..285d438c0c 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -412,7 +412,7 @@ public: void attacking(actor *other); bool can_go_berserk() const; - bool can_go_berserk(bool verbose) const; + bool can_go_berserk(bool verbose, bool no_clarity = false) const; void go_berserk(bool intentional); bool berserk() const; bool can_mutate() const; -- cgit v1.2.3-54-g00ecf