summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-11-06 13:37:03 -0600
committerDavid Lawrence Ramsey <dolorous@users.sourceforge.net>2009-11-06 13:37:52 -0600
commitf858cfc60235a5cfb86dd2a2c510dde5e130a4bf (patch)
treed961eaf5b7122e52a9250e3381d93b1e9c80c88b /crawl-ref
parent79d8c3044d2bb75d7f1e8ebad5cf6e3692fb7605 (diff)
downloadcrawl-ref-f858cfc60235a5cfb86dd2a2c510dde5e130a4bf.tar.gz
crawl-ref-f858cfc60235a5cfb86dd2a2c510dde5e130a4bf.zip
Move checks for the berserk state into actor::berserk().
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/abl-show.cc2
-rw-r--r--crawl-ref/source/acr.cc10
-rw-r--r--crawl-ref/source/actor.h1
-rw-r--r--crawl-ref/source/beam.cc3
-rw-r--r--crawl-ref/source/delay.cc5
-rw-r--r--crawl-ref/source/directn.cc4
-rw-r--r--crawl-ref/source/effects.cc19
-rw-r--r--crawl-ref/source/fight.cc3
-rw-r--r--crawl-ref/source/food.cc2
-rw-r--r--crawl-ref/source/it_use2.cc2
-rw-r--r--crawl-ref/source/it_use3.cc4
-rw-r--r--crawl-ref/source/item_use.cc20
-rw-r--r--crawl-ref/source/mon-abil.cc4
-rw-r--r--crawl-ref/source/mon-act.cc10
-rw-r--r--crawl-ref/source/mon-behv.cc10
-rw-r--r--crawl-ref/source/mon-info.cc4
-rw-r--r--crawl-ref/source/monspeak.cc2
-rw-r--r--crawl-ref/source/monster.cc21
-rw-r--r--crawl-ref/source/monster.h1
-rw-r--r--crawl-ref/source/monstuff.cc2
-rw-r--r--crawl-ref/source/output.cc6
-rw-r--r--crawl-ref/source/player.cc25
-rw-r--r--crawl-ref/source/player.h1
-rw-r--r--crawl-ref/source/religion.cc2
-rw-r--r--crawl-ref/source/showsymb.cc2
-rw-r--r--crawl-ref/source/spl-book.cc2
-rw-r--r--crawl-ref/source/spl-cast.cc2
-rw-r--r--crawl-ref/source/tilereg.cc2
-rw-r--r--crawl-ref/source/transfor.cc2
-rw-r--r--crawl-ref/source/traps.cc6
-rw-r--r--crawl-ref/source/tutorial.cc10
-rw-r--r--crawl-ref/source/view.cc4
-rw-r--r--crawl-ref/source/xom.cc2
33 files changed, 102 insertions, 93 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 867fa8b626..b968d3d6c7 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -878,7 +878,7 @@ static void _print_talent_description(talent tal)
bool activate_ability()
{
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return (false);
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index cafcc35029..e31464f555 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1223,7 +1223,7 @@ static void _go_upstairs()
if (ygrd == DNGN_ENTER_SHOP)
{
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
canned_msg(MSG_TOO_BERSERK);
else
shop();
@@ -1280,7 +1280,7 @@ static void _go_downstairs()
// Up and down both work for shops.
if (ygrd == DNGN_ENTER_SHOP)
{
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
canned_msg(MSG_TOO_BERSERK);
else
shop();
@@ -3283,7 +3283,7 @@ static void _open_door(coord_def move, bool check_confused)
}
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
// XXX: Better flavour for larger doors?
if (silenced(you.pos()))
@@ -3443,7 +3443,7 @@ static void _close_door(coord_def move)
int skill = you.dex
+ (you.skills[SK_TRAPS_DOORS] + you.skills[SK_STEALTH]) / 2;
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
if (silenced(you.pos()))
{
@@ -3773,7 +3773,7 @@ static void _do_berserk_no_combat_penalty(void)
if (you.berserk_penalty == NO_BERSERK_PENALTY)
return;
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
you.berserk_penalty++;
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 69ae5ebf79..6149207816 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -99,6 +99,7 @@ public:
virtual bool cannot_fight() const = 0;
virtual void attacking(actor *other) = 0;
virtual bool can_go_berserk() const = 0;
+ virtual bool berserk() const = 0;
virtual bool can_see_invisible() const = 0;
virtual bool invisible() const = 0;
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 41736c6b16..7d20454b35 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -5214,7 +5214,8 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon)
return (MON_AFFECTED);
case BEAM_BERSERK:
- if (!mon->has_ench(ENCH_BERSERK)) {
+ if (!mon->berserk())
+ {
// currently from potion, hence voluntary
mon->go_berserk(true);
// can't return this from go_berserk, unfortunately
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 8297f964b8..b7b47f195a 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -562,8 +562,7 @@ void handle_interrupted_swap(bool swap_if_safe, bool force_unsafe,
bool transform)
{
if (!you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
- || !you_tran_can_wear(EQ_WEAPON) || you.cannot_act()
- || you.duration[DUR_BERSERKER])
+ || !you_tran_can_wear(EQ_WEAPON) || you.cannot_act() || you.berserk())
{
return;
}
@@ -1284,7 +1283,7 @@ static void _finish_delay(const delay_queue_item &delay)
else
turn_corpse_into_chunks(item);
- if (you.duration[DUR_BERSERKER]
+ if (you.berserk()
&& you.berserk_penalty != NO_BERSERK_PENALTY)
{
mpr("You enjoyed that.");
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index a40966326e..abd2fc1b13 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -2989,8 +2989,8 @@ static std::string _describe_mons_enchantment(const monsters &mons,
}
if ((ench.ench == ENCH_HASTE || ench.ench == ENCH_BATTLE_FRENZY
- || ench.ench == ENCH_MIGHT)
- && mons.has_ench(ENCH_BERSERK))
+ || ench.ench == ENCH_MIGHT)
+ && mons.berserk())
{
return "";
}
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index fb50a9b7ad..ca1839fd75 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -2461,7 +2461,7 @@ static void _set_friendly_foes(bool allow_patrol = false)
}
// Berserking monsters cannot be ordered around.
- if (mon->has_ench(ENCH_BERSERK))
+ if (mon->berserk())
continue;
mon->foe = (allow_patrol && mon->is_patrolling() ? MHITNOT
@@ -2478,7 +2478,7 @@ static void _set_allies_patrol_point(bool clear = false)
continue;
// Berserking monsters cannot be ordered around.
- if (mon->has_ench(ENCH_BERSERK))
+ if (mon->berserk())
continue;
mon->patrol_point = (clear ? coord_def(0, 0) : mon->pos());
@@ -2553,7 +2553,7 @@ void yell(bool force)
mpr("What do you say?", MSGCH_PROMPT);
mprf(" t - %s!", cap_shout.c_str());
- if (!you.duration[DUR_BERSERKER])
+ if (!you.berserk())
{
std::string previous;
if (!(you.prev_targ == MHITNOT || you.prev_targ == MHITYOU))
@@ -2569,7 +2569,7 @@ void yell(bool force)
mprf("Orders for allies: a - Attack new target.%s", previous.c_str());
mpr( " s - Stop attacking.");
mpr( " w - Wait here. f - Follow me.");
- }
+ }
mprf(" Anything else - Stay silent%s.",
one_chance_in(20) ? " (and be thought a fool)" : "");
@@ -2605,7 +2605,7 @@ void yell(bool force)
break;
case 'p':
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return;
@@ -2619,7 +2619,7 @@ void yell(bool force)
// fall through
case 'a':
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return;
@@ -3730,11 +3730,8 @@ void handle_time(long time_delta)
if (you.duration[DUR_INVIS] && x_chance_in_y(6, 10))
added_contamination++;
- if (you.duration[DUR_HASTE] && !you.duration[DUR_BERSERKER]
- && x_chance_in_y(6, 10))
- {
+ if (you.duration[DUR_HASTE] && !you.berserk() && x_chance_in_y(6, 10))
added_contamination++;
- }
bool mutagenic_randart = false;
if (const int artefact_glow = scan_artefacts(ARTP_MUTAGENIC))
@@ -3911,7 +3908,7 @@ void handle_time(long time_delta)
}
// Exercise stealth skill:
else if (you.burden_state == BS_UNENCUMBERED
- && !you.duration[DUR_BERSERKER]
+ && !you.berserk()
&& !you.attribute[ATTR_SHADOWS])
{
// Diminishing returns for stealth training by waiting.
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 6f44616de8..29715af093 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -4099,8 +4099,7 @@ bool melee_attack::mons_attack_mons()
mpr("Zin prevents your ally from violating sanctuary "
"in its confusion.", MSGCH_GOD);
}
- else if (attacker_as_monster()->has_ench(ENCH_BERSERK)
- && you.can_see(attacker))
+ else if (attacker->berserk() && you.can_see(attacker))
{
mpr("Zin prevents your ally from violating sanctuary "
"in its berserker rage.", MSGCH_GOD);
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index b723b17da1..45cabbb224 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -523,7 +523,7 @@ bool butchery(int which_corpse)
// It makes more sense that you first find out if there's anything
// to butcher, *then* decide to actually butcher it.
// The old code did it the other way.
- if (!can_butcher && you.duration[DUR_BERSERKER])
+ if (!can_butcher && you.berserk())
{
mpr("You are too berserk to search for a butchering tool!");
return (false);
diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc
index 96350a9bc6..ce7d4292ea 100644
--- a/crawl-ref/source/it_use2.cc
+++ b/crawl-ref/source/it_use2.cc
@@ -468,7 +468,7 @@ bool unwield_item(bool showMsgs)
if (!you.weapon())
return (false);
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
if (showMsgs)
canned_msg(MSG_TOO_BERSERK);
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index d87aa7df09..54a8acba67 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -712,9 +712,9 @@ static bool _ball_of_fixation(void)
bool evoke_item(int slot)
{
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
- canned_msg( MSG_TOO_BERSERK );
+ canned_msg(MSG_TOO_BERSERK);
return (false);
}
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 8e7c500f98..19378c4da6 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -90,7 +90,7 @@ bool can_wield(item_def *weapon, bool say_reason,
{
#define SAY(x) if (say_reason) { x; } else
- if (!ignore_temporary_disability && you.duration[DUR_BERSERKER])
+ if (!ignore_temporary_disability && you.berserk())
{
SAY(canned_msg(MSG_TOO_BERSERK));
return (false);
@@ -712,7 +712,7 @@ bool armour_prompt(const std::string & mesg, int *index, operation_types oper)
if (inv_count() < 1)
canned_msg(MSG_NOTHING_CARRIED);
- else if (you.duration[DUR_BERSERKER])
+ else if (you.berserk())
canned_msg(MSG_TOO_BERSERK);
else
{
@@ -1067,7 +1067,7 @@ bool takeoff_armour(int item)
return (false);
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return (false);
@@ -1442,7 +1442,7 @@ static bool _fire_warn_if_impossible()
}
// Else shooting is possible.
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return (true);
@@ -3693,7 +3693,7 @@ bool puton_ring(int slot)
return (false);
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return (false);
@@ -3813,7 +3813,7 @@ bool remove_ring(int slot, bool announce)
return (false);
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return (false);
@@ -3982,7 +3982,7 @@ void zap_wand(int slot)
return;
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return;
@@ -4244,7 +4244,7 @@ void drink(int slot)
return;
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return;
@@ -4346,7 +4346,7 @@ bool _drink_fountain()
return (false);
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return (true);
@@ -4940,7 +4940,7 @@ static void _vulnerability_scroll()
void read_scroll(int slot)
{
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return;
diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc
index 0cd0b4e801..0c62f719e0 100644
--- a/crawl-ref/source/mon-abil.cc
+++ b/crawl-ref/source/mon-abil.cc
@@ -598,7 +598,7 @@ static bool _orc_battle_cry(monsters *chief)
&& mons_species(mon->type) == MONS_ORC
&& mons_aligned(boss_index, i)
&& mon->hit_dice < chief->hit_dice
- && !mon->has_ench(ENCH_BERSERK)
+ && !mon->berserk()
&& !mon->has_ench(ENCH_MIGHT)
&& !mon->cannot_move()
&& !mon->confused()
@@ -1188,7 +1188,7 @@ bool mon_special_ability(monsters *monster, bolt & beem)
}
// Don't even try on berserkers. Mermaids know their limits.
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
break;
// Reduce probability because of spamminess.
diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc
index ca998d22a3..03b8c1eed9 100644
--- a/crawl-ref/source/mon-act.cc
+++ b/crawl-ref/source/mon-act.cc
@@ -352,7 +352,7 @@ static void _handle_movement(monsters *monster)
// since they're only being forced out rather than actually
// scared.
if (monster->holiness() == MH_NONLIVING
- || monster->has_ench(ENCH_BERSERK)
+ || monster->berserk()
|| x_chance_in_y(2, 5))
{
mons_stop_fleeing_from_sanctuary(monster);
@@ -538,7 +538,7 @@ static void _handle_movement(monsters *monster)
&& mons_intel(monster) >= I_ANIMAL
&& coinflip()
&& !mons_is_confused(monster) && !monster->caught()
- && !monster->has_ench(ENCH_BERSERK))
+ && !monster->berserk())
{
// If the monster is moving parallel to the x or y axis, check
// whether
@@ -1909,7 +1909,7 @@ static void _handle_monster_move(monsters *monster)
if (!monster->asleep() && !mons_is_wandering(monster)
// Berserking monsters are limited to running up and
// hitting their foes.
- && !monster->has_ench(ENCH_BERSERK)
+ && !monster->berserk()
// Slime creatures can split while wandering or resting.
|| monster->type == MONS_SLIME_CREATURE)
{
@@ -3122,7 +3122,7 @@ static bool _monster_move(monsters *monster)
if (monster_can_submerge(monster, grd(monster->pos()))
&& !can_see && !mons_is_confused(monster)
&& !monster->caught()
- && !monster->has_ench(ENCH_BERSERK))
+ && !monster->berserk())
{
monster->add_ench(ENCH_SUBMERGED);
monster->behaviour = BEH_LURK;
@@ -3131,7 +3131,7 @@ static bool _monster_move(monsters *monster)
}
// Berserking monsters make a lot of racket.
- if (monster->has_ench(ENCH_BERSERK))
+ if (monster->berserk())
{
int noise_level = get_shout_noise_level(mons_shouts(monster->type));
if (noise_level > 0)
diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc
index 0d67baf782..62b3a68a82 100644
--- a/crawl-ref/source/mon-behv.cc
+++ b/crawl-ref/source/mon-behv.cc
@@ -1192,14 +1192,14 @@ void handle_behaviour(monsters *mon)
if (isFriendly
&& you.pet_target != MHITNOT
&& (mon->foe == MHITNOT || mon->foe == MHITYOU)
- && !mon->has_ench(ENCH_BERSERK)
- && mon->mons_species() != MONS_GIANT_SPORE )
+ && !mon->berserk()
+ && mon->mons_species() != MONS_GIANT_SPORE)
{
mon->foe = you.pet_target;
}
// Instead, berserkers attack nearest monsters.
- if ((mon->has_ench(ENCH_BERSERK) || mon->mons_species() == MONS_GIANT_SPORE)
+ if ((mon->berserk() || mon->mons_species() == MONS_GIANT_SPORE)
&& (mon->foe == MHITNOT || isFriendly && mon->foe == MHITYOU))
{
// Intelligent monsters prefer to attack the player,
@@ -1238,7 +1238,7 @@ void handle_behaviour(monsters *mon)
// target the player, if they're healthy.
if (!isFriendly && !isNeutral
&& mon->foe != MHITYOU && mon->foe != MHITNOT
- && proxPlayer && !(mon->has_ench(ENCH_BERSERK)) && isHealthy
+ && proxPlayer && !mon->berserk() && isHealthy
&& !one_chance_in(3))
{
mon->foe = MHITYOU;
@@ -1802,7 +1802,7 @@ void behaviour_event(monsters *mon, mon_event_type event, int src,
case ME_SCARE:
// Stationary monsters can't flee, and berserking monsters
// are too enraged.
- if (mons_is_stationary(mon) || mon->has_ench(ENCH_BERSERK))
+ if (mons_is_stationary(mon) || mon->berserk())
{
mon->del_ench(ENCH_FEAR, true, true);
break;
diff --git a/crawl-ref/source/mon-info.cc b/crawl-ref/source/mon-info.cc
index 47a2f8564c..141584a003 100644
--- a/crawl-ref/source/mon-info.cc
+++ b/crawl-ref/source/mon-info.cc
@@ -46,7 +46,7 @@ monster_info::monster_info(const monsters *m)
if (mons_looks_stabbable(m)) m_brands |= (1 << MB_STABBABLE);
if (mons_looks_distracted(m)) m_brands |= (1 << MB_DISTRACTED);
- if (m->has_ench(ENCH_BERSERK)) m_brands |= (1 << MB_BERSERK);
+ if (m->berserk()) m_brands |= (1 << MB_BERSERK);
get_mons_glyph(m_mon, &m_glyph, &m_glyph_colour);
@@ -255,7 +255,7 @@ void monster_info::to_string(int count, std::string& desc,
if (count == 1)
{
- if (m_mon->has_ench(ENCH_BERSERK))
+ if (m_mon->berserk())
out << " (berserk)";
else if (Options.verbose_monster_pane)
out << _verbose_info(m_mon);
diff --git a/crawl-ref/source/monspeak.cc b/crawl-ref/source/monspeak.cc
index f40a148903..393440f36c 100644
--- a/crawl-ref/source/monspeak.cc
+++ b/crawl-ref/source/monspeak.cc
@@ -392,7 +392,7 @@ bool mons_speaks(monsters *monster)
}
// Berserk monsters just want your hide.
- if (monster->has_ench(ENCH_BERSERK))
+ if (monster->berserk())
return (false);
// Monsters in a battle frenzy are likewise occupied.
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 67de4d5e4d..1cd5129676 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -2669,7 +2669,7 @@ void monsters::attacking(actor * /* other */)
void monsters::go_berserk(bool /* intentional */)
{
- if (!this->can_go_berserk())
+ if (!can_go_berserk())
return;
if (has_ench(ENCH_SLOW))
@@ -3816,7 +3816,7 @@ bool monsters::add_ench(const mon_enchant &ench)
return (false);
if (ench.ench == ENCH_FEAR
- && (holiness() == MH_NONLIVING || has_ench(ENCH_BERSERK)))
+ && (holiness() == MH_NONLIVING || berserk()))
{
return (false);
}
@@ -4135,7 +4135,7 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet)
break;
case ENCH_FEAR:
- if (holiness() == MH_NONLIVING || has_ench(ENCH_BERSERK))
+ if (holiness() == MH_NONLIVING || berserk())
{
// This should only happen because of fleeing sanctuary
snprintf(info, INFO_SIZE, " stops retreating.");
@@ -4246,7 +4246,7 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet)
// abjured.
add_ench(mon_enchant(ENCH_ABJ, 0, KC_OTHER, -1));
- if (this->has_ench(ENCH_BERSERK))
+ if (berserk())
simple_monster_message(this, " is no longer berserk.");
monster_die(this, quiet ? KILL_DISMISSED : KILL_RESET, NON_MONSTER);
@@ -4601,7 +4601,7 @@ void monsters::apply_enchantment(const mon_enchant &me)
// Smaller monsters can escape more quickly.
if (mon_size < random2(SIZE_BIG) // BIG = 5
- && !has_ench(ENCH_BERSERK) && type != MONS_DANCING_WEAPON)
+ && !berserk() && type != MONS_DANCING_WEAPON)
{
if (mons_near(this) && !visible_to(&you))
mpr("Something wriggles in the net.");
@@ -4665,7 +4665,7 @@ void monsters::apply_enchantment(const mon_enchant &me)
damage++;
// Berserking doubles damage dealt.
- if (has_ench(ENCH_BERSERK))
+ if (berserk())
damage *= 2;
// Faster monsters can damage the net more often per
@@ -5081,7 +5081,7 @@ bool monsters::can_go_berserk() const
if (holiness() != MH_NATURAL || type == MONS_KRAKEN_TENTACLE)
return (false);
- if (has_ench(ENCH_FATIGUE) || has_ench(ENCH_BERSERK))
+ if (berserk() || has_ench(ENCH_FATIGUE))
return (false);
// If we have no melee attack, going berserk is pointless.
@@ -5092,6 +5092,11 @@ bool monsters::can_go_berserk() const
return (true);
}
+bool monsters::berserk() const
+{
+ return (has_ench(ENCH_BERSERK));
+}
+
bool monsters::needs_berserk(bool check_spells) const
{
if (!can_go_berserk())
@@ -5508,7 +5513,7 @@ bool monsters::should_drink_potion(potion_type ptype) const
case POT_MIGHT:
return (!has_ench(ENCH_MIGHT) && foe_distance() <= 2);
case POT_BERSERK_RAGE:
- // this implies !has_ench(ENCH_BERSERK_RAGE)
+ // this implies !berserk()
return (!has_ench(ENCH_MIGHT) && !has_ench(ENCH_HASTE)
&& needs_berserk());
case POT_INVISIBILITY:
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index d07b4bd0ed..8e50ad0b6f 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -283,6 +283,7 @@ public:
void attacking(actor *other);
bool can_go_berserk() const;
void go_berserk(bool intentional);
+ bool berserk() const;
bool can_mutate() const;
bool can_safely_mutate() const;
bool can_bleed() const;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 79c535e69c..c5722b2121 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1377,7 +1377,7 @@ int monster_die(monsters *monster, killer_type killer,
}
// From time to time Trog gives you a little bonus.
- if (killer == KILL_YOU && you.duration[DUR_BERSERKER])
+ if (killer == KILL_YOU && you.berserk())
{
if (you.religion == GOD_TROG
&& !player_under_penance() && you.piety > random2(1000))
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 8b0d4e9adb..c1c22bc802 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -327,7 +327,7 @@ static void _print_stats_hp(int x, int y)
short hp_colour = HUD_VALUE_COLOUR;
const bool boosted = you.duration[DUR_DIVINE_VIGOUR]
- || you.duration[DUR_BERSERKER];
+ || you.berserk();
if (boosted)
hp_colour = LIGHTBLUE;
@@ -1636,7 +1636,7 @@ static std::vector<formatted_string> _get_overview_stats()
column_composer cols1(4, 18, 28, 40);
const bool boosted_hp = you.duration[DUR_DIVINE_VIGOUR]
- || you.duration[DUR_BERSERKER];
+ || you.berserk();
const bool boosted_mp = you.duration[DUR_DIVINE_VIGOUR];
const bool boosted_str = you.duration[DUR_DIVINE_STAMINA]
|| you.duration[DUR_MIGHT];
@@ -2157,7 +2157,7 @@ std::string _status_mut_abilities()
if (you.duration[DUR_DIVINE_STAMINA])
status.push_back("divinely fortified");
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
status.push_back("berserking");
if (you.airborne())
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index a7dda1eb12..e5e9333d51 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1170,7 +1170,7 @@ int player_hunger_rate(void)
hunger += 5;
// Berserk has its own food penalty -- excluding berserk haste.
- if (you.duration[DUR_HASTE] > 0 && !you.duration[DUR_BERSERKER])
+ if (you.duration[DUR_HASTE] > 0 && !you.berserk())
hunger += 5;
}
@@ -3319,7 +3319,7 @@ int check_stealth(void)
return (1000);
#endif
- if (you.attribute[ATTR_SHADOWS] || you.duration[DUR_BERSERKER])
+ if (you.attribute[ATTR_SHADOWS] || you.berserk())
return (0);
int stealth = you.dex * 3;
@@ -3862,7 +3862,7 @@ void display_char_status()
if (you.duration[DUR_DIVINE_STAMINA])
mpr("You are divinely fortified.");
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
mpr("You are possessed by a berserker rage.");
if (you.airborne())
@@ -4722,7 +4722,7 @@ int get_real_hp(bool trans, bool rotted)
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])
+ if (trans && you.berserk())
hitp *= 2;
if (trans)
@@ -6182,12 +6182,12 @@ void player::go_berserk(bool intentional)
bool player::can_go_berserk() const
{
- return can_go_berserk(false);
+ return (can_go_berserk(false));
}
bool player::can_go_berserk(bool verbose) const
{
- if (this->duration[DUR_BERSERKER])
+ if (berserk())
{
if (verbose)
mpr("You're already berserk!");
@@ -6195,7 +6195,7 @@ bool player::can_go_berserk(bool verbose) const
return (false);
}
- if (this->duration[DUR_EXHAUSTED])
+ if (duration[DUR_EXHAUSTED])
{
if (verbose)
mpr("You're too exhausted to go berserk.");
@@ -6211,8 +6211,8 @@ bool player::can_go_berserk(bool verbose) const
return (false);
}
- if (this->is_undead
- && (this->is_undead != US_SEMI_UNDEAD || this->hunger_state <= HS_SATIATED))
+ if (is_undead
+ && (is_undead != US_SEMI_UNDEAD || hunger_state <= HS_SATIATED))
{
if (verbose)
mpr("You cannot raise a blood rage in your lifeless body.");
@@ -6224,6 +6224,11 @@ bool player::can_go_berserk(bool verbose) const
return (true);
}
+bool player::berserk() const
+{
+ return (duration[DUR_BERSERKER]);
+}
+
void player::god_conduct(conduct_type thing_done, int level)
{
::did_god_conduct(thing_done, level);
@@ -7057,7 +7062,7 @@ void player::put_to_sleep(int)
{
ASSERT(!crawl_state.arena);
- if (duration[DUR_BERSERKER] || asleep()) // No cumulative sleeps.
+ if (berserk() || asleep()) // No cumulative sleeps.
return;
// Not all species can be put to sleep. Check holiness.
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 0d113ff5b2..1456fd5fa4 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -395,6 +395,7 @@ public:
bool can_go_berserk() const;
bool can_go_berserk(bool verbose) const;
void go_berserk(bool intentional);
+ bool berserk() const;
bool can_mutate() const;
bool can_safely_mutate() const;
bool can_bleed() const;
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 64ff727b1c..797cf347ef 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -6840,7 +6840,7 @@ int get_tension(god_type god, bool count_travelling)
exper /= 4;
}
- if (mons->has_ench(ENCH_BERSERK))
+ if (mons->berserk())
{
// in addition to haste and might bonuses above
exper *= 3;
diff --git a/crawl-ref/source/showsymb.cc b/crawl-ref/source/showsymb.cc
index 711c53e974..eef0dc7636 100644
--- a/crawl-ref/source/showsymb.cc
+++ b/crawl-ref/source/showsymb.cc
@@ -195,7 +195,7 @@ int get_mons_colour(const monsters *mons)
{
int col = mons->colour;
- if (mons->has_ench(ENCH_BERSERK))
+ if (mons->berserk())
col = RED;
if (mons->friendly())
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index baa38eb5e5..c04554d56a 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1668,7 +1668,7 @@ bool can_learn_spell(bool silent)
return (false);
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
if (!silent)
canned_msg(MSG_TOO_BERSERK);
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 35e26beef7..262026415e 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -679,7 +679,7 @@ bool cast_a_spell(bool check_range, spell_type spell)
return (false);
}
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return (false);
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index 745ca0fca9..c4c0801739 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -1022,7 +1022,7 @@ void DungeonRegion::render()
m_buf_doll.draw();
m_buf_main.draw();
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
ShapeBuffer buff;
VColour red_film(130, 0, 0, 100);
diff --git a/crawl-ref/source/transfor.cc b/crawl-ref/source/transfor.cc
index 3127308325..603a2547ba 100644
--- a/crawl-ref/source/transfor.cc
+++ b/crawl-ref/source/transfor.cc
@@ -144,7 +144,7 @@ static void _unwear_equipment_slot(equipment_type eqslot)
if (eqslot == EQ_WEAPON)
{
- unwield_item(!you.duration[DUR_BERSERKER]);
+ unwield_item(!you.berserk());
canned_msg(MSG_EMPTY_HANDED);
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = slot + 1;
}
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index 97c5a0834f..25a56cfa3e 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -757,7 +757,7 @@ trap_type get_trap_type(const coord_def& pos)
// where *must* point to a valid, discovered trap.
void disarm_trap(const coord_def& where)
{
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
{
canned_msg(MSG_TOO_BERSERK);
return;
@@ -915,7 +915,7 @@ static int damage_or_escape_net(int hold)
}
// Berserkers get a fighting bonus.
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
damage += 2;
// Check stats.
@@ -993,7 +993,7 @@ void free_self_from_net()
if (damage < 1)
damage = 1;
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
damage *= 2;
// Medium sized characters are at a disadvantage and sometimes
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index 978ba69c17..c8d46ca4c3 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -1052,7 +1052,7 @@ void tutorial_healing_reminder()
#endif
".";
- if (you.religion == GOD_TROG && !you.duration[DUR_BERSERKER]
+ if (you.religion == GOD_TROG && !you.berserk()
&& !you.duration[DUR_EXHAUSTED]
&& you.hunger_state >= HS_SATIATED)
{
@@ -1276,7 +1276,7 @@ void tutorial_first_monster(const monsters &mon)
if (mon.friendly())
learned_something_new(TUT_MONSTER_FRIENDLY, mon.pos());
- if (you.religion == GOD_TROG && !you.duration[DUR_BERSERKER]
+ if (you.religion == GOD_TROG && !you.berserk()
&& !you.duration[DUR_EXHAUSTED] && you.hunger_state >= HS_SATIATED
&& one_chance_in(4))
{
@@ -2849,7 +2849,7 @@ void learned_something_new(tutorial_event_type seen_what, coord_def gc)
"you come back, so you might want to use a different set of "
"stairs when you return.";
- if (you.religion == GOD_TROG && !you.duration[DUR_BERSERKER]
+ if (you.religion == GOD_TROG && !you.berserk()
&& !you.duration[DUR_EXHAUSTED]
&& you.hunger_state >= HS_SATIATED)
{
@@ -4524,7 +4524,7 @@ void tutorial_describe_monster(const monsters *mons)
}
}
- if (mons->has_ench(ENCH_BERSERK))
+ if (mons->berserk())
{
ostr << "A berserking monster is bloodthirsty and fighting madly. "
"Such a blood rage makes it particularly dangerous!\n\n";
@@ -4566,7 +4566,7 @@ void tutorial_describe_monster(const monsters *mons)
{
ostr << "This might be a good time to run away";
- if (you.religion == GOD_TROG && !you.duration[DUR_BERSERKER]
+ if (you.religion == GOD_TROG && !you.berserk()
&& !you.duration[DUR_EXHAUSTED]
&& you.hunger_state >= HS_SATIATED)
{
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 3db47e723a..3fcf4a2a90 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -491,7 +491,7 @@ bool check_awaken(monsters* monster)
return (false);
// Berserkers aren't really concerned about stealth.
- if (you.duration[DUR_BERSERKER])
+ if (you.berserk())
return (true);
// I assume that creatures who can sense invisible are very perceptive.
@@ -1118,7 +1118,7 @@ static int _viewmap_flash_colour()
{
if (you.attribute[ATTR_SHADOWS])
return (DARKGREY);
- else if (you.duration[DUR_BERSERKER])
+ else if (you.berserk())
return (RED);
return (BLACK);
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index d596e28203..3298631d85 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -1532,7 +1532,7 @@ static int _xom_swap_weapons(bool debug = false)
if (!wpn)
return (XOM_DID_NOTHING);
- if (you.duration[DUR_BERSERKER]
+ if (you.berserk()
|| wpn->base_type != OBJ_WEAPONS
|| get_weapon_brand(*wpn) == SPWPN_DISTORTION
|| !safe_to_remove_or_wear(*wpn, true, true))