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-24 07:29:40 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-24 07:29:40 +0000
commit7b6e06e7dfb876a56c99e2216a6071e0a652caf9 (patch)
tree6126035ebe8c10f89ec930992bfa2e0e99c7dc17 /crawl-ref/source/beam.cc
parenta9c18d8a40084b269f6173ba68283c3a2feaff48 (diff)
downloadcrawl-ref-7b6e06e7dfb876a56c99e2216a6071e0a652caf9.tar.gz
crawl-ref-7b6e06e7dfb876a56c99e2216a6071e0a652caf9.zip
Apply r6627, r6635, r6638 and r6645 (among others) to 0.4.
Fixes Selective Amnesia crash, claws/ankus in the weapon option, randart bardings pretending to be boots and smaller stuff. Includes indication of monsters seeing/sensing invisible. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@6665 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/beam.cc')
-rw-r--r--crawl-ref/source/beam.cc145
1 files changed, 97 insertions, 48 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index ccff519f00..69614f6cc0 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -3623,6 +3623,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 )
{
@@ -3637,10 +3730,11 @@ 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'))
+ if (yesno("That beam is likely to hit you. Continue anyway?",
+ false, 'n'))
{
beam.fr_count += 1;
beam.fr_power += you.experience_level;
@@ -4253,51 +4347,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)
{