summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells2.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-04 14:44:13 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-04 14:44:13 +0000
commit4d0b7c461fd459e01cab475eb6b01ab5ea9d4689 (patch)
tree3750b8574e0cba9afe96292cf622c385a30ce62e /crawl-ref/source/spells2.cc
parentda0c3f0c317cfb21e88aecbbb90388cc6d087cfe (diff)
downloadcrawl-ref-4d0b7c461fd459e01cab475eb6b01ab5ea9d4689.tar.gz
crawl-ref-4d0b7c461fd459e01cab475eb6b01ab5ea9d4689.zip
Redid monster death idiom so that monsters::hurt can implicitly
call monster_die(). (This behaviour can be overriden.) Minor code cleanups elsewhere, removal of dead code from bolt. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7123 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells2.cc')
-rw-r--r--crawl-ref/source/spells2.cc33
1 files changed, 15 insertions, 18 deletions
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index f181ab51b5..35f0257eee 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -640,7 +640,7 @@ void cast_refrigeration(int pow)
// Handle the player.
const dice_def dam_dice(3, 5 + pow / 10);
- const int hurted = check_your_resists(roll_dice( dam_dice ), BEAM_COLD);
+ const int hurted = check_your_resists(dam_dice.roll(), BEAM_COLD);
if (hurted > 0)
{
@@ -694,15 +694,16 @@ void cast_refrigeration(int pow)
if (monster->alive() && mons_near(monster))
{
// Calculate damage and apply.
- int hurt = mons_adjust_flavoured(monster,beam,roll_dice(dam_dice));
- if (hurt > 0)
- hurt_monster(monster, hurt);
-
- // Kill monster if necessary; cold-blooded creatures can be slowed.
- if (monster->hit_points < 1)
- monster_die(monster, KILL_YOU, NON_MONSTER);
- else if (mons_class_flag(monster->type, M_COLD_BLOOD) && coinflip())
+ int hurt = mons_adjust_flavoured(monster, beam, dam_dice.roll());
+ monster->hurt(&you, hurt, BEAM_COLD);
+
+ // Cold-blooded creatures can be slowed.
+ if (monster->alive()
+ && mons_class_flag(monster->type, M_COLD_BLOOD)
+ && coinflip())
+ {
monster->add_ench(ENCH_SLOW);
+ }
}
}
}
@@ -743,12 +744,10 @@ void drain_life(int pow)
const int hurted = 3 + random2(7) + random2(pow);
behaviour_event(monster, ME_WHACK, MHITYOU, you.pos());
- hurt_monster(monster, hurted);
hp_gain += hurted;
- if (monster->hit_points < 1)
- monster_die(monster, KILL_YOU, NON_MONSTER);
- else
+ monster->hurt(&you, hurted);
+ if (monster->alive())
print_wounds(monster);
}
}
@@ -805,15 +804,13 @@ bool vampiric_drain(int pow, const dist &vmove)
return (false);
}
- hurt_monster(monster, inflicted);
-
mprf("You feel life coursing from %s into your body!",
monster->name(DESC_NOCAP_THE).c_str());
- print_wounds(monster);
+ monster->hurt(&you, inflicted);
- if (monster->hit_points < 1)
- monster_die(monster, KILL_YOU, NON_MONSTER);
+ if (monster->alive())
+ print_wounds(monster);
inc_hp(inflicted / 2, false);