summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-01 10:44:11 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-01 10:44:11 +0000
commitd22abf31c5f56320e1ee6c5ff25a75b8bd09b6c0 (patch)
tree224891df1b503798e8826385261c3f825b4a7fd2 /crawl-ref/source
parent2b9197efde1c28e983c988def8f7d673f8699ebe (diff)
downloadcrawl-ref-d22abf31c5f56320e1ee6c5ff25a75b8bd09b6c0.tar.gz
crawl-ref-d22abf31c5f56320e1ee6c5ff25a75b8bd09b6c0.zip
Fixed vampiric healing on death using raw damage instead of actual damage, which produced super-healing for stabbing (jarpiain).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2283 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/fight.cc21
-rw-r--r--crawl-ref/source/monstuff.cc16
-rw-r--r--crawl-ref/source/monstuff.h2
3 files changed, 17 insertions, 22 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 9bfc3ead91..4b033bb609 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -869,11 +869,7 @@ bool melee_attack::player_apply_aux_unarmed()
stab_bonus = 0;
aux_damage = player_apply_monster_ac(aux_damage);
- if (aux_damage < 1)
- aux_damage = 0;
- else
- hurt_monster(def, aux_damage);
-
+ aux_damage = hurt_monster(def, aux_damage);
damage_done = aux_damage;
if (damage_done > 0)
@@ -1437,7 +1433,7 @@ int melee_attack::player_weapon_type_modify(int damage)
bool melee_attack::player_hurt_monster()
{
- return damage_done && hurt_monster(def, damage_done);
+ return damage_done && (damage_done = hurt_monster(def, damage_done));
}
void melee_attack::player_exercise_combat_skills()
@@ -1480,14 +1476,20 @@ bool melee_attack::player_monattk_hit_effects(bool mondied)
if (mondied && damage_brand == SPWPN_VAMPIRICISM)
{
if (defender->holiness() == MH_NATURAL
- && damage_done > 0 && you.hp < you.hp_max
+ && damage_done > 0
+ && you.hp < you.hp_max
&& !one_chance_in(5))
{
mpr("You feel better.");
// more than if not killed
- int heal = 1 + random2(damage_done);
+ const int heal = 1 + random2(damage_done);
+#ifdef DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS,
+ "Vampiric healing: damage %d, healed %d",
+ damage_done, heal);
+#endif
inc_hp(heal, false);
if (you.hunger_state != HS_ENGORGED)
@@ -1525,8 +1527,7 @@ bool melee_attack::player_monattk_hit_effects(bool mondied)
if (needs_message && !special_damage_message.empty())
mprf("%s", special_damage_message.c_str());
-
- hurt_monster(def, special_damage);
+ special_damage = hurt_monster(def, special_damage);
if (def->hit_points < 1)
{
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index c06233b88a..2f71c94086 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -5462,18 +5462,12 @@ unsigned int monster_index(const monsters *monster)
return (monster - menv.buffer());
} // end monster_index()
-bool hurt_monster(monsters * victim, int damage_dealt)
+int hurt_monster(monsters * victim, int damage_dealt)
{
- bool just_a_scratch = true;
-
- if (damage_dealt > 0)
- {
- just_a_scratch = false;
- victim->hit_points -= damage_dealt;
- }
-
- return (!just_a_scratch);
-} // end hurt_monster()
+ damage_dealt = std::max(std::min(damage_dealt, victim->hit_points), 0);
+ victim->hit_points -= damage_dealt;
+ return (damage_dealt);
+}
bool heal_monster(monsters * patient, int health_boost,
bool permit_growth)
diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h
index dc62fc9715..80b9f7d5c3 100644
--- a/crawl-ref/source/monstuff.h
+++ b/crawl-ref/source/monstuff.h
@@ -173,7 +173,7 @@ unsigned int monster_index(const monsters *monster);
* called from: bang - beam - effects - fight - monstuff - mstuff2 -
* spells2 - spells3 - spells4
* *********************************************************************** */
-bool hurt_monster(struct monsters *victim, int damage_dealt);
+int hurt_monster(monsters *victim, int damage_dealt);
/* ***********************************************************************