diff options
-rw-r--r-- | crawl-ref/source/beam.cc | 49 | ||||
-rw-r--r-- | crawl-ref/source/godabil.cc | 31 | ||||
-rw-r--r-- | crawl-ref/source/godabil.h | 3 |
3 files changed, 48 insertions, 35 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index f8aa4e2ded..36c47d85b8 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -33,6 +33,7 @@ #include "effects.h" #include "env.h" #include "enum.h" +#include "godabil.h" #include "map_knowledge.h" #include "fprop.h" #include "fight.h" @@ -4485,41 +4486,6 @@ void bolt::tracer_enchantment_affect_monster(monsters* mon) bool bolt::determine_damage(monsters* mon, int& preac, int& postac, int& final, std::vector<std::string>& messages) { - // Fedhas worshippers can fire through monsters of the same - // alignment. This means Fedhas-worshipping players can fire through - // allied plants, and also means that Fedhas-worshipping oklob plants - // can fire through plants with the same attitude. - bool originator_worships_fedhas = false; - - // Checking beam_source to decide whether the player or a monster - // fired the beam (so we can check their religion). This is - // complicated by the fact that this beam may in fact be an - // explosion caused by a miscast effect. In that case, the value of - // beam_source may be negative (god-induced miscast) or greater than - // NON_MONSTER (various other miscast sources). So we check whether - // or not this is an explosion, and also the range of beam_source - // before attempting to reference env.mons with it. -cao - if (!is_explosion && beam_source == NON_MONSTER) - originator_worships_fedhas = (you.religion == GOD_FEDHAS); - else if (!is_explosion && beam_source >= 0 && beam_source < MAX_MONSTERS) - originator_worships_fedhas = (env.mons[beam_source].god == GOD_FEDHAS); - - if (!is_enchantment() - && attitude == mon->attitude - && originator_worships_fedhas - && fedhas_protects(mon)) - { - if (!is_tracer) - { - // FIXME: Could use a better message, something about - // dodging that doesn't sound excessively weird would be - // nice. - mprf(MSGCH_GOD, "Fedhas protects %s plant from harm.", - attitude == ATT_FRIENDLY ? "your" : "a"); - } - return (false); - } - // preac: damage before AC modifier // postac: damage after AC modifier // final: damage after AC and resists @@ -4901,6 +4867,19 @@ void bolt::affect_monster(monsters* mon) apply_hit_funcs(mon, 0); return; } + if (fedhas_shoot_through(*this, mon)) + { + apply_hit_funcs(mon, 0); + if (!is_tracer) + { + // FIXME: Could use a better message, something about + // dodging that doesn't sound excessively weird would be + // nice. + mprf(MSGCH_GOD, "Fedhas protects %s plant from harm.", + attitude == ATT_FRIENDLY ? "your" : "a"); + } + return; + } // Fire storm creates these, so we'll avoid affecting them if (name == "great blast of fire" && mon->type == MONS_FIRE_VORTEX) diff --git a/crawl-ref/source/godabil.cc b/crawl-ref/source/godabil.cc index f5b0d609de..f6a1d82c1d 100644 --- a/crawl-ref/source/godabil.cc +++ b/crawl-ref/source/godabil.cc @@ -326,6 +326,37 @@ bool fedhas_passthrough(const monsters * target) || target->attitude != ATT_HOSTILE)); } +// Fedhas worshipers can shoot through non-hostile plants, can a +// particular beam go through a particular monster? +bool fedhas_shoot_through(const bolt & beam, const monsters * victim) +{ + actor * originator = beam.agent(); + if (!victim || !originator) + return (false); + + bool origin_worships_fedhas; + mon_attitude_type origin_attitude; + if (originator->atype() == ACT_PLAYER) + { + origin_worships_fedhas = you.religion == GOD_FEDHAS; + origin_attitude = ATT_FRIENDLY; + } + else + { + monsters * temp = dynamic_cast<monsters *> (originator); + if (!temp) + return false; + origin_worships_fedhas = temp->god == GOD_FEDHAS; + origin_attitude = temp->attitude; + } + + return (origin_worships_fedhas + && fedhas_protects(victim) + && !beam.is_enchantment() + && !(beam.is_explosion && beam.in_explosion_phase) + && (mons_atts_aligned(victim->attitude, origin_attitude) + || victim->neutral() )); +} // Turns corpses in LOS into skeletons and grows toadstools on them. // Can also turn zombies into skeletons and destroy ghoul-type monsters. diff --git a/crawl-ref/source/godabil.h b/crawl-ref/source/godabil.h index 02fbd817bb..ed787249bf 100644 --- a/crawl-ref/source/godabil.h +++ b/crawl-ref/source/godabil.h @@ -9,6 +9,8 @@ #include "enum.h" #include "externs.h" +class bolt; + bool ponderousify_armour(); bool zin_sustenance(bool actual = true); bool zin_remove_all_mutations(); @@ -19,6 +21,7 @@ bool beogh_water_walk(); void yred_make_enslaved_soul(monsters *mon, bool force_hostile = false, bool quiet = false, bool unrestricted = false); bool fedhas_passthrough(const monsters * target); +bool fedhas_shoot_through(const bolt & beam, const monsters * victim); int fungal_bloom(); bool sunlight(); bool prioritise_adjacent(const coord_def &target, |