summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-08 04:29:50 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-08 04:29:50 +0000
commit835386081ecfabc9e442ce6cc1139fae06564651 (patch)
treeec56759ac399d0ea30d268cec8d2b0eb51fbd8f8 /crawl-ref/source
parentf9b3fccde9594e3ba99a93a8652416f32e662f8d (diff)
downloadcrawl-ref-835386081ecfabc9e442ce6cc1139fae06564651.tar.gz
crawl-ref-835386081ecfabc9e442ce6cc1139fae06564651.zip
Clean up handling of angered monsters.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5579 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/beam.cc6
-rw-r--r--crawl-ref/source/decks.cc2
-rw-r--r--crawl-ref/source/monplace.cc40
-rw-r--r--crawl-ref/source/monplace.h8
-rw-r--r--crawl-ref/source/spells2.cc12
-rw-r--r--crawl-ref/source/spells4.cc2
6 files changed, 46 insertions, 24 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index 870fc2bc59..4be9722605 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2603,7 +2603,7 @@ int mons_ench_f2(monsters *monster, bolt &pbolt)
return (MON_AFFECTED);
}
case BEAM_CHARM: /* 9 = charm */
- if (player_angers_monster(monster, false))
+ if (player_will_anger_monster(monster))
{
simple_monster_message(monster, " is repulsed!");
return (MON_OTHER);
@@ -4805,7 +4805,7 @@ static int _affect_monster_enchantment(bolt &beam, monsters *mon)
return mons_immune_magic(mon) ? MON_UNAFFECTED : MON_RESIST;
beam.obvious_effect = true;
- if (player_angers_monster(mon, false))
+ if (player_will_anger_monster(mon))
{
simple_monster_message(mon, " is repulsed!");
return (MON_OTHER);
@@ -4837,7 +4837,7 @@ static int _affect_monster_enchantment(bolt &beam, monsters *mon)
return (MON_UNAFFECTED);
beam.obvious_effect = true;
- if (player_angers_monster(mon, false))
+ if (player_will_anger_monster(mon))
{
simple_monster_message(mon, " is repulsed!");
return (MON_OTHER);
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 1f525a83e9..6a9a4c5783 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -2426,7 +2426,7 @@ static void _crusade_card(int power, deck_rarity_type rarity)
|| mons_holiness(monster) != MH_NATURAL
|| mons_is_unique(monster->type)
|| mons_immune_magic(monster)
- || player_angers_monster(monster, false))
+ || player_will_anger_monster(monster))
{
continue;
}
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index badbb816a1..fabb21e883 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -2006,20 +2006,40 @@ coord_def find_newmons_square(int mons_class, const coord_def &p)
return (pos);
}
-bool player_angers_monster(monsters *mon, bool actual)
+bool player_will_anger_monster(monster_type type, bool *holy,
+ bool *unholy, bool *antimagical)
{
- const bool holy =
- (is_good_god(you.religion) && mons_is_evil_or_unholy(mon));
- const bool unholy =
- (is_evil_god(you.religion) && mons_is_holy(mon));
- const bool antimagical =
- (you.religion == GOD_TROG && mons_is_magic_user(mon));
+ monsters dummy;
+ dummy.type = type;
+
+ return (player_will_anger_monster(&dummy, holy, unholy, antimagical));
+}
+
+bool player_will_anger_monster(monsters *mon, bool *holy,
+ bool *unholy, bool *antimagical)
+{
+ if (holy)
+ *holy = (is_good_god(you.religion) && mons_is_evil_or_unholy(mon));
+
+ if (unholy)
+ *unholy = (is_evil_god(you.religion) && mons_is_holy(mon));
+
+ if (antimagical)
+ *antimagical = (you.religion == GOD_TROG && mons_is_magic_user(mon));
+
+ return (holy || unholy || antimagical);
+}
+
+bool player_angers_monster(monsters *mon)
+{
+ bool holy;
+ bool unholy;
+ bool antimagical;
// Get the drawbacks, not the benefits... (to prevent e.g. demon-scumming).
- if (holy || unholy || antimagical)
+ if (player_will_anger_monster(mon, &holy, &unholy, &antimagical))
{
- if (actual
- && (mon->attitude != ATT_HOSTILE || mon->has_ench(ENCH_CHARM)))
+ if (mon->attitude != ATT_HOSTILE || mon->has_ench(ENCH_CHARM))
{
mon->attitude = ATT_HOSTILE;
mon->del_ench(ENCH_CHARM);
diff --git a/crawl-ref/source/monplace.h b/crawl-ref/source/monplace.h
index b5456dc491..1b3ad0c6e7 100644
--- a/crawl-ref/source/monplace.h
+++ b/crawl-ref/source/monplace.h
@@ -258,7 +258,13 @@ monster_type pick_random_monster(const level_id &place,
int power,
int &lev_mons);
-bool player_angers_monster(monsters *mon, bool actual = true);
+bool player_will_anger_monster(monster_type type, bool *holy = NULL,
+ bool *unholy = NULL, bool *antimagical = NULL);
+
+bool player_will_anger_monster(monsters *mon, bool *holy = NULL,
+ bool *unholy = NULL, bool *antimagical = NULL);
+
+bool player_angers_monster(monsters *mon);
// last updated 12may2000 {dlb}
/* ***********************************************************************
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 520c1e3feb..2371d051f8 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -1627,15 +1627,11 @@ bool cast_summon_small_mammals(int pow, bool god_gift)
switch (pow_spent)
{
case 75: case 74: case 38:
+ mon = MONS_ORANGE_RAT;
// If you worship a good god, don't summon an evil small
// mammal.
- // XXX: There should be a better way to do this, using
- // player_angers_monster().
- if (!is_good_god(you.religion))
- {
- mon = MONS_ORANGE_RAT;
+ if (!player_will_anger_monster(mon))
break;
- }
case 65: case 64: case 63: case 27: case 26: case 25:
mon = MONS_GREEN_RAT;
@@ -1643,11 +1639,11 @@ bool cast_summon_small_mammals(int pow, bool god_gift)
case 57: case 56: case 55: case 54: case 53: case 52:
case 20: case 18: case 16: case 14: case 12: case 10:
- mon = coinflip() ? MONS_QUOKKA : MONS_GREY_RAT;
+ mon = (coinflip()) ? MONS_QUOKKA : MONS_GREY_RAT;
break;
default:
- mon = coinflip() ? MONS_GIANT_BAT : MONS_RAT;
+ mon = (coinflip()) ? MONS_GIANT_BAT : MONS_RAT;
break;
}
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index 3e8b87b4f0..4bec36ec47 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -648,7 +648,7 @@ static int tame_beast_monsters(int x, int y, int pow, int garbage)
monsters *monster = &menv[which_mons];
if (!is_domesticated_animal(monster->type) || mons_friendly(monster)
- || player_angers_monster(monster, false))
+ || player_will_anger_monster(monster))
{
return 0;
}