diff options
author | blackcustard <peterwicksstringfield@gmail.com> | 2013-02-03 12:09:26 -0600 |
---|---|---|
committer | Pekka Lampila <pekka.lampila@iki.fi> | 2014-01-30 08:51:23 +0200 |
commit | c2bc827ef229d04c54483e9692726732df28cbcd (patch) | |
tree | 69631a2c074ede76f898bc791d51075996e3ced7 /crawl-ref/source/throw.cc | |
parent | 8aec01e85e2030a5aa8dc04c53e2927e2f58d8ec (diff) | |
download | crawl-ref-c2bc827ef229d04c54483e9692726732df28cbcd.tar.gz crawl-ref-c2bc827ef229d04c54483e9692726732df28cbcd.zip |
Confirm Portal Projectile attacks against allies etc.
Diffstat (limited to 'crawl-ref/source/throw.cc')
-rw-r--r-- | crawl-ref/source/throw.cc | 69 |
1 files changed, 45 insertions, 24 deletions
diff --git a/crawl-ref/source/throw.cc b/crawl-ref/source/throw.cc index f8d2a19ecd..8990900a1b 100644 --- a/crawl-ref/source/throw.cc +++ b/crawl-ref/source/throw.cc @@ -1526,35 +1526,56 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, if (!pbolt.effect_known) pbolt.special_explosion = NULL; - // Don't do the tracing when using Portaled Projectile, or when confused. - if (!teleport && !you.confused()) - { - // Set values absurdly high to make sure the tracer will - // complain if we're attempting to fire through allies. - pbolt.hit = 100; - pbolt.damage = dice_def(1, 100); + // Don't trace at all when confused. + // Give the player a chance to be warned about helpless targets when using + // Portaled Projectile, but obviously don't trace a path. + bool cancelled = false; + if (!you.confused()) + { + // Kludgy. Ideally this would handled by the same code. + // Perhaps some notion of a zero length bolt, with the source and + // target both set to the target? + if (teleport) + { + // This block is roughly equivalent to bolt::affect_cell for + // normal projectiles. + monster *m = monster_at(target->target); + if (m) + cancelled = stop_attack_prompt(m, false, target->target, false); + } + else + { + // Set values absurdly high to make sure the tracer will + // complain if we're attempting to fire through allies. + pbolt.hit = 100; + pbolt.damage = dice_def(1, 100); - // Init tracer variables. - pbolt.foe_info.reset(); - pbolt.friend_info.reset(); - pbolt.foe_ratio = 100; - pbolt.is_tracer = true; + // Init tracer variables. + pbolt.foe_info.reset(); + pbolt.friend_info.reset(); + pbolt.foe_ratio = 100; + pbolt.is_tracer = true; - pbolt.fire(); + pbolt.fire(); - // Should only happen if the player answered 'n' to one of those - // "Fire through friendly?" prompts. - if (pbolt.beam_cancelled) - { - canned_msg(MSG_OK); - you.turn_is_over = false; - if (pbolt.special_explosion != NULL) - delete pbolt.special_explosion; - return false; + cancelled = pbolt.beam_cancelled; + + pbolt.hit = 0; + pbolt.damage = dice_def(); } - pbolt.hit = 0; - pbolt.damage = dice_def(); } + + // Should only happen if the player answered 'n' to one of those + // "Fire through friendly?" prompts. + if (cancelled) + { + canned_msg(MSG_OK); + you.turn_is_over = false; + if (pbolt.special_explosion != NULL) + delete pbolt.special_explosion; + return false; + } + pbolt.is_tracer = false; // Reset values. |