summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/beam.cc
diff options
context:
space:
mode:
authorgammafunk <gammafunk@gmail.com>2014-07-02 00:24:22 -0500
committergammafunk <gammafunk@gmail.com>2014-07-02 01:14:22 -0500
commitfc78f0c065fcd4d19bddc74daaf1d70cc5c68792 (patch)
treefc5eb588365fc80a17a1c96e3e7012e224182262 /crawl-ref/source/beam.cc
parent679cb175872ec8848394f93d41504ebada0369a8 (diff)
downloadcrawl-ref-fc78f0c065fcd4d19bddc74daaf1d70cc5c68792.tar.gz
crawl-ref-fc78f0c065fcd4d19bddc74daaf1d70cc5c68792.zip
Have monsters check constriction before using knockback abilities
If a monster is constricting a victim, don't allow it to use a spell or ability that would knock the victim back, thus breaking the constriction. I made this commit when I was considering giving op crushers primal wave, an idea that I dropped, but the check should still be there, and this does move otherwise duplicated code to a single method.
Diffstat (limited to 'crawl-ref/source/beam.cc')
-rw-r--r--crawl-ref/source/beam.cc36
1 files changed, 24 insertions, 12 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index d05c952aa7..f19b967563 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -4109,13 +4109,9 @@ void bolt::affect_player()
extra_range_used += range_used_on_hit();
- if (flavour == BEAM_WATER && origin_spell == SPELL_PRIMAL_WAVE
- || origin_spell == SPELL_COLD_BREATH && you.airborne()
- || origin_spell == SPELL_FORCE_LANCE && hurted > 0
- || name == "flood of elemental water")
- {
+ if (can_knockback(&you, hurted))
beam_hits_actor(&you);
- }
+
else if (name == "explosive bolt")
_explosive_bolt_explode(this, you.pos());
else if (name == "flash freeze"
@@ -4625,13 +4621,9 @@ void bolt::monster_post_hit(monster* mon, int dmg)
if (dmg)
beogh_follower_convert(mon, true);
- if ((flavour == BEAM_WATER && origin_spell == SPELL_PRIMAL_WAVE)
- || (name == "freezing breath" && mon->flight_mode())
- || (name == "lance of force" && dmg > 0)
- || name == "flood of elemental water")
- {
+ if (can_knockback(mon, dmg))
beam_hits_actor(mon);
- }
+
else if (name == "explosive bolt")
_explosive_bolt_explode(this, mon->pos());
@@ -6644,6 +6636,26 @@ string bolt::get_source_name() const
return "";
}
+/**
+ * Can this bolt knock back an actor?
+ *
+ * The bolts that knockback flying actors or actors only when damage
+ * is dealt will return when.
+ *
+ * @param act The target actor. If not-NULL, check if the actor is flying for
+ * bolts that knockback flying actors.
+ * @param dam The damage dealt. If non-negative, check that dam > 0 for bolts
+ * like force bolt that only push back upon damage.
+ * @return True if the bolt could knockback the actor, false otherwise.
+*/
+bool bolt::can_knockback(const actor *act, int dam) const
+{
+ return((flavour == BEAM_WATER && origin_spell == SPELL_PRIMAL_WAVE)
+ || (name == "freezing breath" && (!act || act->flight_mode()))
+ || (name == "lance of force" && (dam < 0 || dam > 0))
+ || name == "flood of elemental water");
+}
+
void clear_zap_info_on_exit()
{
for (unsigned int i = 0; i < ARRAYSZ(zap_data); ++i)