summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-20 17:57:17 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-20 17:57:17 +0000
commite55e12b955d739545cf587d04fcb840ef6470f13 (patch)
tree977f8f44391d29381aab0276d4d67ab526358722 /crawl-ref/source/monstuff.cc
parent0b103119bb91d60929ddd2a016395698778151d7 (diff)
downloadcrawl-ref-e55e12b955d739545cf587d04fcb840ef6470f13.tar.gz
crawl-ref-e55e12b955d739545cf587d04fcb840ef6470f13.zip
Improve the previous sanity fixes. Add a function
invalid_monster_index(), and use that where applicable. Also, put the "god gift" flag back on orcish followers, since the Crusade card now handles orc conversion properly for Beoghites, and so that the index check doesn't have to be done twice for collateral kills. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3755 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc21
1 files changed, 7 insertions, 14 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index b0bf368639..b6c787ff09 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -466,7 +466,7 @@ static bool ely_heals_monster(monsters *monster, killer_type killer, int i)
{
god_type god = GOD_ELYVILON;
ASSERT(you.religion != god);
-
+
const int ely_penance = you.penance[god];
ASSERT(ely_penance > 0);
@@ -477,9 +477,7 @@ static bool ely_heals_monster(monsters *monster, killer_type killer, int i)
return (false);
}
- if (MON_KILL(killer)
- && i != ANON_FRIENDLY_MONSTER
- && i >= 0 && i < MAX_MONSTERS)
+ if (MON_KILL(killer) && !invalid_monster_index(i))
{
monsters *mon = &menv[i];
if (!mons_friendly(mon) || !one_chance_in(3))
@@ -530,7 +528,7 @@ static bool monster_avoided_death(monsters *monster, killer_type killer, int i)
{
return (true);
}
-
+
bool convert = false;
if (you.religion == GOD_BEOGH
@@ -540,9 +538,7 @@ static bool monster_avoided_death(monsters *monster, killer_type killer, int i)
{
if (YOU_KILL(killer))
convert = true;
- else if (MON_KILL(killer)
- && i != ANON_FRIENDLY_MONSTER
- && i >= 0 && i < MAX_MONSTERS)
+ else if (MON_KILL(killer) && !invalid_monster_index(i))
{
monsters *mon = &menv[i];
if (is_orcish_follower(mon) && !one_chance_in(3))
@@ -728,7 +724,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
case KILL_YOU_MISSILE: /* You kill by missile or beam. */
case KILL_YOU_CONF: /* You kill by confusion */
{
- const bool created_friendly =
+ const bool created_friendly =
testbits(monster->flags, MF_CREATED_FRIENDLY);
const bool was_neutral =
testbits(monster->flags, MF_WAS_NEUTRAL);
@@ -868,14 +864,12 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
if (attacker_holy == MH_UNDEAD)
{
if (targ_holy == MH_NATURAL)
- notice |=
+ notice |=
did_god_conduct(DID_LIVING_KILLED_BY_UNDEAD_SLAVE,
monster->hit_dice);
}
else if (you.religion == GOD_VEHUMET
|| you.religion == GOD_MAKHLEB
- || (you.religion == GOD_BEOGH
- && is_orcish_follower(&menv[i]))
|| (!anon && testbits(menv[i].flags, MF_GOD_GIFT)))
{
// Yes, we are splitting undead pets from the others
@@ -938,8 +932,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
&& mons_is_evil_or_unholy(monster)
&& (!player_under_penance()
&& random2(you.piety) >= piety_breakpoint(0))
- && i != ANON_FRIENDLY_MONSTER
- && i >= 0 && i < MAX_MONSTERS)
+ && !invalid_monster_index(i))
{
monsters *mon = &menv[i];
if (mon->alive() && mon->hit_points < mon->max_hit_points)