diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-28 03:32:17 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-28 03:32:17 +0000 |
commit | d04224e3fc2b5271620775742cf316da09513f77 (patch) | |
tree | e953c0e48aad75a3e3b8be16e5ceea3e26b5bd3e | |
parent | 56cb1b52027f736f1d3ec32b08efb52552befaf3 (diff) | |
download | crawl-ref-d04224e3fc2b5271620775742cf316da09513f77.tar.gz crawl-ref-d04224e3fc2b5271620775742cf316da09513f77.zip |
Oops, don't automatically set aimed_at_feet, since the caller might be doing
weird stuff with source and target. Make setup_mons_cast() deal with it
for monster spells which the monster aims at itself.
Force range to 0 when source == target.
In mons_cast() assert that targeted spells have an in-bounds target and that
harmful spells are only aimed at the caster when the caster is confused.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8000 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/beam.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/mstuff2.cc | 16 |
2 files changed, 20 insertions, 1 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 2f8fec57ba..05bac81884 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -1463,6 +1463,9 @@ void bolt::initialize_fire() source = ray.pos(); } + if (target == source) + range = 0; + if (range == -1) { #if DEBUG @@ -1494,6 +1497,7 @@ void bolt::initialize_fire() ASSERT(flavour > BEAM_NONE && flavour < BEAM_FIRST_PSEUDO); ASSERT(!drop_item || item && is_valid_item(*item)); ASSERT(range >= 0); + ASSERT(!aimed_at_feet || source == target); real_flavour = flavour; @@ -1909,7 +1913,6 @@ void bolt::do_fire() { auto_hit = true; aimed_at_spot = true; - aimed_at_feet = true; use_target_as_pos = true; } else diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 0fd515055d..ca82b57e37 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -158,6 +158,19 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast, return; } +#ifdef DEBUG + const unsigned int flags = get_spell_flags(spell_cast); + + ASSERT(!(flags & (SPFLAG_TESTING | SPFLAG_MAPPING))); + + // Targeted spells need a valid target. + ASSERT(!(flags & SPFLAG_TARGETING_MASK) || in_bounds(pbolt.target)); + + // Don't target harmful spells at self unless confused. + ASSERT(monster->pos() != pbolt.target || monster->confused() + || (flags & (SPFLAG_HELPFUL | SPFLAG_ESCAPE | SPFLAG_RECOVERY))); +#endif + if (do_noise) mons_cast_noise(monster, pbolt, spell_cast); @@ -817,6 +830,9 @@ void setup_mons_cast(monsters *monster, bolt &pbolt, { pbolt.target = monster->pos(); } + + if (pbolt.target == pbolt.source) + pbolt.aimed_at_feet = true; } bool monster_random_space(const monsters *monster, coord_def& target, |