summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/beam.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-21 18:22:37 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-21 18:22:37 +0000
commit17652535bdeaf8d56ee88ed9296708ff6efd8a31 (patch)
treeceaf2d57b6f390119ad858e2a60cfad5f76f3f08 /crawl-ref/source/beam.cc
parent70c9cdbfc3009b64f58482a1506848ed6437e1f3 (diff)
downloadcrawl-ref-17652535bdeaf8d56ee88ed9296708ff6efd8a31.tar.gz
crawl-ref-17652535bdeaf8d56ee88ed9296708ff6efd8a31.zip
Add immunity checks for prompts about beams potentially hitting yourself
(not counting self-targetting since what we're trying to avoid in that case is loss of magic as well as self-damage) and add some special cases for Evaporate, so the potions use appropriate resistances without leaking information on the random choices. Let Enhancers start with Short Blades skill 1. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6627 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/beam.cc')
-rw-r--r--crawl-ref/source/beam.cc141
1 files changed, 95 insertions, 46 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 681971bd5f..4513b0b511 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -3629,6 +3629,99 @@ static std::string _beam_zapper(const bolt &beam)
return menv[beam_src].name(DESC_PLAIN);
}
+static bool _beam_is_harmless(bolt &beam, monsters *mon)
+{
+ // For enchantments, this is already handled in _nasty_beam().
+ if (beam.name[0] == '0')
+ return (!_nasty_beam(mon, beam));
+
+ // The others are handled here.
+ switch (beam.flavour)
+ {
+ case BEAM_DIGGING:
+ return (true);
+
+ // Cleansing flame doesn't affect player's followers.
+ case BEAM_HOLY:
+ return (mons_is_holy(mon)
+ || is_good_god(you.religion)
+ && ( is_follower(mon) || mons_neutral(mon) ));
+
+ case BEAM_STEAM:
+ return (mons_res_steam(mon) >= 3);
+
+ case BEAM_FIRE:
+ return (mons_res_fire(mon) >= 3);
+
+ case BEAM_COLD:
+ return (mons_res_cold(mon) >= 3);
+
+ case BEAM_MIASMA:
+ case BEAM_NEG:
+ return (mons_res_negative_energy(mon) == 3);
+
+ case BEAM_ELECTRICITY:
+ return (mons_res_elec(mon) >= 3);
+
+ case BEAM_POISON:
+ return (mons_res_poison(mon) >= 3);
+
+ case BEAM_ACID:
+ return (mons_res_acid(mon) >= 3);
+
+ default:
+ return (false);
+ }
+}
+
+static bool _beam_is_harmless_player(bolt &beam)
+{
+#ifdef DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS, "beam flavour: %d", beam.flavour);
+#endif
+
+ // Shouldn't happen anyway since enchantments are either aimed at self
+ // (not prompted) or cast at monsters and don't explode or bounce.
+ if (beam.name[0] == '0')
+ return (false);
+
+ // The others are handled here.
+ switch (beam.flavour)
+ {
+ case BEAM_DIGGING:
+ return (true);
+
+ // Cleansing flame doesn't affect player's followers.
+ case BEAM_HOLY:
+ return (is_good_god(you.religion));
+
+ case BEAM_STEAM:
+ return (player_res_steam(false) >= 3);
+
+ case BEAM_MIASMA:
+ case BEAM_NEG:
+ return (player_prot_life(false) >= 3);
+
+ case BEAM_POISON:
+ return (player_res_poison(false));
+
+ case BEAM_POTION_STINKING_CLOUD:
+ return (player_res_poison(false) || player_mental_clarity(false));
+
+ case BEAM_ELECTRICITY:
+ return (player_res_electricity(false));
+
+ case BEAM_FIRE:
+ case BEAM_COLD:
+ case BEAM_ACID:
+ // Fire and ice can destroy inventory items, acid damage equipment.
+ return (false);
+
+ default:
+ return (false);
+ }
+}
+
// Returns amount of extra range used up by affectation of the player.
static int _affect_player( bolt &beam, item_def *item )
{
@@ -3643,7 +3736,8 @@ static int _affect_player( bolt &beam, item_def *item )
if (YOU_KILL(beam.thrower))
{
// Don't ask if we're aiming at ourselves.
- if (!beam.aimed_at_feet && !beam.dont_stop_player)
+ if (!beam.aimed_at_feet && !beam.dont_stop_player
+ && !_beam_is_harmless_player(beam))
{
if (yesno("That beam is likely to hit yourself. Continue "
"anyway?", false, 'n'))
@@ -4259,51 +4353,6 @@ static void _update_hurt_or_helped(bolt &beam, monsters *mon)
}
}
-static bool _beam_is_harmless(bolt &beam, monsters *mon)
-{
- // For enchantments, this is already handled in _nasty_beam().
- if (beam.name[0] == '0')
- return (!_nasty_beam(mon, beam));
-
- // The others are handled here.
- switch (beam.flavour)
- {
- case BEAM_DIGGING:
- return (true);
-
- // Cleansing flame doesn't affect player's followers.
- case BEAM_HOLY:
- return (mons_is_holy(mon)
- || is_good_god(you.religion)
- && ( is_follower(mon) || mons_neutral(mon) ));
-
- case BEAM_STEAM:
- return (mons_res_steam(mon) >= 3);
-
- case BEAM_FIRE:
- return (mons_res_fire(mon) >= 3);
-
- case BEAM_COLD:
- return (mons_res_cold(mon) >= 3);
-
- case BEAM_MIASMA:
- case BEAM_NEG:
- return (mons_res_negative_energy(mon) == 3);
-
- case BEAM_ELECTRICITY:
- return (mons_res_elec(mon) >= 3);
-
- case BEAM_POISON:
- return (mons_res_poison(mon) >= 3);
-
- case BEAM_ACID:
- return (mons_res_acid(mon) >= 3);
-
- default:
- return (false);
- }
-}
-
// Returns amount of range used up by affectation of this monster.
static int _affect_monster(bolt &beam, monsters *mon, item_def *item)
{