summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monplace.cc
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/monplace.cc
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/monplace.cc')
-rw-r--r--crawl-ref/source/monplace.cc40
1 files changed, 30 insertions, 10 deletions
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);