summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-08 18:29:52 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-08 18:29:52 +0000
commit9a20cf0a34b9caec2ff9a5c3708a88fb84c80496 (patch)
tree8c52366fe290b5821c8d49b21353cd69845e39bd /crawl-ref
parent459e277ada7ab661190d4a3497a374d76e30c5a4 (diff)
downloadcrawl-ref-9a20cf0a34b9caec2ff9a5c3708a88fb84c80496.tar.gz
crawl-ref-9a20cf0a34b9caec2ff9a5c3708a88fb84c80496.zip
Fix debugging ray zaps (e.g. unknown wands) always setting obvious_effect by
making ZAP_DEBUGGING_RAY no longer an obvious_effect. It might be more correct to restore obvious_effect on a tracer, or at least a player_tracer, but bug 2515082 [and r8500] makes me cautious. Fix healing being too generously identified. Fix wand of healing not working on enemies if you happen to worship Ely. Fixes [2580106]. Also some dead code elimination. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8982 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/abl-show.cc4
-rw-r--r--crawl-ref/source/beam.cc4
-rw-r--r--crawl-ref/source/spells1.cc63
-rw-r--r--crawl-ref/source/spells1.h12
-rw-r--r--crawl-ref/source/spl-cast.cc4
5 files changed, 33 insertions, 54 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index f64fa21dee..9924f8b957 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1715,7 +1715,7 @@ static bool _do_ability(const ability_def& abil)
break;
case ABIL_ELYVILON_LESSER_HEALING:
- if (!cast_healing(3 + (you.skills[SK_INVOCATIONS] / 6)))
+ if (cast_healing(3 + (you.skills[SK_INVOCATIONS] / 6), true) < 0)
return (false);
exercise(SK_INVOCATIONS, 1);
@@ -1727,7 +1727,7 @@ static bool _do_ability(const ability_def& abil)
break;
case ABIL_ELYVILON_GREATER_HEALING:
- if (!cast_healing(10 + (you.skills[SK_INVOCATIONS] / 3)))
+ if (cast_healing(10 + (you.skills[SK_INVOCATIONS] / 3), true) < 0)
return (false);
exercise(SK_INVOCATIONS, 3 + random2(5));
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index efbcc91de7..34b544aa24 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -915,7 +915,7 @@ const zap_info zap_data[] = {
false,
BEAM_MMISSILE,
DCHAR_FIRED_DEBUG,
- true,
+ false,
false,
false
},
@@ -4843,7 +4843,7 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon)
case BEAM_HEALING:
if (YOU_KILL(thrower))
{
- if (cast_healing(5 + damage.roll(), mon->pos()) > 0)
+ if (cast_healing(5 + damage.roll(), false, mon->pos()) > 0)
obvious_effect = true;
msg_generated = true; // to avoid duplicate "nothing happens"
}
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 871187cd3e..3358d99e6f 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -700,7 +700,9 @@ static bool _can_pacify_monster(const monsters *mon, const int healed)
return (false);
}
-static int _healing_spell(int healed, const coord_def where = coord_def())
+// Returns: 1 -- success, 0 -- failure, -1 -- cancel
+static int _healing_spell(int healed, bool divine_ability,
+ const coord_def& where)
{
ASSERT(healed >= 1);
@@ -722,7 +724,7 @@ static int _healing_spell(int healed, const coord_def where = coord_def())
}
if (!spd.isValid)
- return (0);
+ return (-1);
if (spd.target == you.pos())
{
@@ -731,26 +733,28 @@ static int _healing_spell(int healed, const coord_def where = coord_def())
return (1);
}
- const int mgr = mgrd(spd.target);
-
- if (mgr == NON_MONSTER)
+ monsters* monster = monster_at(spd.target);
+ if (!monster)
{
mpr("There isn't anything there!");
- return (-1);
+ // This isn't a cancel, to avoid leaking invisible monster
+ // locations.
+ return (0);
}
- monsters *monster = &menv[mgr];
-
- // Don't heal a monster you can't pacify.
- if (you.religion == GOD_ELYVILON && !_can_pacify_monster(monster, healed))
+ // Don't divinely heal a monster you can't pacify.
+ if (divine_ability
+ && you.religion == GOD_ELYVILON
+ && !_can_pacify_monster(monster, healed))
{
canned_msg(MSG_NOTHING_HAPPENS);
- return (-1);
+ return (0);
}
- bool nothing_happens = true;
+ bool did_something = false;
if (heal_monster(monster, healed, false))
{
+ did_something = true;
mprf("You heal %s.", monster->name(DESC_NOCAP_THE).c_str());
if (monster->hit_points == monster->max_hit_points)
@@ -760,17 +764,16 @@ static int _healing_spell(int healed, const coord_def where = coord_def())
if (you.religion == GOD_ELYVILON && !_mons_hostile(monster))
{
- simple_god_message(" appreciates the healing of a fellow creature.");
+ simple_god_message(" appreciates the healing "
+ "of a fellow creature.");
if (one_chance_in(8))
gain_piety(1);
- return (1);
}
-
- nothing_happens = false;
}
if (you.religion == GOD_ELYVILON && _mons_hostile(monster))
{
+ did_something = true;
simple_god_message(" supports your offer of peace.");
if (mons_is_holy(monster))
@@ -786,34 +789,18 @@ static int _healing_spell(int healed, const coord_def where = coord_def())
gain_piety(1 + random2(healed/15));
}
}
- else if (nothing_happens)
- canned_msg(MSG_NOTHING_HAPPENS);
-
- return (1);
-}
-
-#if 0
-char cast_lesser_healing( int pow )
-{
- return _healing_spell(5 + random2avg(7, 2));
-}
-char cast_greater_healing( int pow )
-{
- return _healing_spell(15 + random2avg(29, 2));
-}
+ if (!did_something)
+ canned_msg(MSG_NOTHING_HAPPENS);
-char cast_greatest_healing( int pow )
-{
- return _healing_spell(50 + random2avg(49, 2));
+ return (did_something ? 1 : 0);
}
-#endif
-int cast_healing(int pow, const coord_def& where)
+// Returns: 1 -- success, 0 -- failure, -1 -- cancel
+int cast_healing(int pow, bool divine_ability, const coord_def& where)
{
pow = std::min(50, pow);
-
- return (_healing_spell(pow + roll_dice(2, pow) - 2, where));
+ return (_healing_spell(pow + roll_dice(2, pow) - 2, divine_ability, where));
}
void remove_divine_vigour()
diff --git a/crawl-ref/source/spells1.h b/crawl-ref/source/spells1.h
index 8b32ca2264..f34ea6cf9f 100644
--- a/crawl-ref/source/spells1.h
+++ b/crawl-ref/source/spells1.h
@@ -16,17 +16,9 @@
struct bolt;
-// last updated 24may2000 {dlb}
-/* ***********************************************************************
- * called from: spell
- * *********************************************************************** */
bool cast_sure_blade(int power);
-
-// last updated 24may2000 {dlb}
-/* ***********************************************************************
- * called from: ability - spell
- * *********************************************************************** */
-int cast_healing(int pow, const coord_def& where = coord_def(0,0));
+int cast_healing(int pow, bool divine_ability = false,
+ const coord_def& where = coord_def(0,0));
void remove_divine_vigour();
bool cast_divine_vigour();
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 016c168260..9978a36f5e 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -1750,12 +1750,12 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
break;
case SPELL_LESSER_HEALING:
- if (!cast_healing(5))
+ if (cast_healing(5) < 0)
return (SPRET_ABORT);
break;
case SPELL_GREATER_HEALING:
- if (!cast_healing(25))
+ if (cast_healing(25) < 0)
return (SPRET_ABORT);
break;