summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/actor.h1
-rw-r--r--crawl-ref/source/beam.cc2
-rw-r--r--crawl-ref/source/mon-project.cc4
-rw-r--r--crawl-ref/source/monster.cc8
-rw-r--r--crawl-ref/source/monster.h1
-rw-r--r--crawl-ref/source/player.cc13
-rw-r--r--crawl-ref/source/player.h1
7 files changed, 27 insertions, 3 deletions
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 6c3dda5bf6..f2c1b42aae 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -253,6 +253,7 @@ public:
int stab_bypass = 0) const;
virtual int melee_evasion(const actor *attacker,
ev_ignore_type ign = EV_IGNORE_NONE) const = 0;
+ virtual bool shielded() const = 0;
virtual int shield_bonus() const = 0;
virtual int shield_block_penalty() const = 0;
virtual int shield_bypass_ability(int tohit) const = 0;
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index a0f2d4c020..3226f756bd 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -3363,7 +3363,7 @@ bool bolt::misses_player()
bool train_shields_more = false;
if (is_blockable()
- && (you.shield() || player_mutation_level(MUT_LARGE_BONE_PLATES) > 0)
+ && you.shielded()
&& !aimed_at_feet
&& player_shield_class() > 0)
{
diff --git a/crawl-ref/source/mon-project.cc b/crawl-ref/source/mon-project.cc
index 6d4e4bb3a4..fad0a806df 100644
--- a/crawl-ref/source/mon-project.cc
+++ b/crawl-ref/source/mon-project.cc
@@ -199,7 +199,7 @@ static void _fuzz_direction(const actor *caster, monster& mon, int pow)
// Alas, too much differs to reuse beam shield blocks :(
static bool _iood_shielded(monster& mon, actor &victim)
{
- if (!victim.shield() || victim.incapacitated())
+ if (!victim.shielded() || victim.incapacitated())
return false;
const int to_hit = 15 + (mons_is_projectile(mon.type) ?
@@ -507,7 +507,7 @@ move_again:
if (victim && _iood_shielded(mon, *victim))
{
item_def *shield = victim->shield();
- if (!shield_reflects(*shield))
+ if (!shield || !shield_reflects(*shield))
{
if (victim->is_player())
mprf("You block %s.", mon.name(DESC_THE, true).c_str());
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 7d022add29..8bcc42e6e2 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -3279,6 +3279,14 @@ bool monster::pacified() const
return attitude == ATT_NEUTRAL && testbits(flags, MF_GOT_HALF_XP);
}
+/**
+ * Returns whether the monster currently has any kind of shield.
+ */
+bool monster::shielded() const
+{
+ return shield();
+}
+
int monster::shield_bonus() const
{
const item_def *shld = const_cast<monster* >(this)->shield();
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index 786fd1b8c8..d0d2087267 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -460,6 +460,7 @@ public:
int stat_maxhp() const { return max_hit_points; }
int stealth() const;
+ bool shielded() const;
int shield_bonus() const;
int shield_block_penalty() const;
void shield_block_succeeded(actor *foe);
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 71443e47fa..d545c27e51 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -6198,6 +6198,19 @@ bool player::liquefied_ground() const
&& ground_level() && !is_insubstantial();
}
+/**
+ * Returns whether the player currently has any kind of shield.
+ */
+bool player::shielded() const
+{
+ return shield()
+ || duration[DUR_CONDENSATION_SHIELD]
+ || duration[DUR_MAGIC_SHIELD]
+ || duration[DUR_DIVINE_SHIELD]
+ || player_mutation_level(MUT_LARGE_BONE_PLATES) > 0
+ || qazlal_sh_boost() > 0;
+}
+
int player::shield_block_penalty() const
{
return 5 * shield_blocks * shield_blocks;
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 3d174c30c1..dfba7e43a3 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -689,6 +689,7 @@ public:
int stat_maxhp() const { return hp_max; }
int stealth() const { return check_stealth(); }
+ bool shielded() const;
int shield_bonus() const;
int shield_block_penalty() const;
int shield_bypass_ability(int tohit) const;