summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-02 17:02:47 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-02 17:02:47 +0000
commit748d46d89bf76acd85c117b95579ea9c477fce9d (patch)
tree68331a9c1568b0b9627fbc11c50a117fc95acae7 /crawl-ref/source
parent39b970fbeb8fe4f25c7a077be347a2374b9037ae (diff)
downloadcrawl-ref-748d46d89bf76acd85c117b95579ea9c477fce9d.tar.gz
crawl-ref-748d46d89bf76acd85c117b95579ea9c477fce9d.zip
Generalize monsters::can_drink_potion(). First, monsters that don't
have at least MONUSE_STARTING_EQUIPMENT can't drink them, as they can't use them anyway (which covers wraiths; the same check is also done in monsters::should_drink_potion()). Second, skeletal monsters in general can't use them, since they require digestion of some type (which covers skeletal warriors). Third, insubstantial monsters can't use them, for the same reason (since all insubstantial monsters use, at most, MONUSE_OPEN_DOORS). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8122 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/mon-util.cc48
1 files changed, 20 insertions, 28 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 273546b24d..4a48963344 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -7455,40 +7455,32 @@ static inline monster_type _royal_jelly_ejectable_monster()
bool monsters::can_drink_potion(potion_type ptype) const
{
- bool rc = true;
-
- switch (mons_species())
+ if (mons_itemuse(this) >= MONUSE_STARTING_EQUIPMENT)
{
- case MONS_LICH:
- case MONS_MUMMY:
- case MONS_SKELETAL_WARRIOR:
- case MONS_WRAITH:
- rc = false;
- break;
- default:
- break;
- }
+ if (mons_is_skeletal(type) || mons_is_insubstantial(type)
+ || mons_species() == MONS_LICH || mons_species() == MONS_MUMMY)
+ {
+ return (false);
+ }
- switch (ptype)
- {
- case POT_HEALING:
- case POT_HEAL_WOUNDS:
- if (holiness() == MH_UNDEAD
- || holiness() == MH_NONLIVING
- || holiness() == MH_PLANT)
+ switch (ptype)
{
- rc = false;
+ case POT_HEALING:
+ case POT_HEAL_WOUNDS:
+ return (holiness() != MH_UNDEAD
+ && holiness() != MH_NONLIVING
+ && holiness() != MH_PLANT);
+ case POT_BLOOD:
+ case POT_BLOOD_COAGULATED:
+ return (mons_species() != MONS_VAMPIRE);
+ default:
+ break;
}
- break;
- case POT_BLOOD:
- case POT_BLOOD_COAGULATED:
- rc = (mons_species() == MONS_VAMPIRE);
- break;
- default:
- break;
+
+ return (true);
}
- return rc;
+ return (false);
}
bool monsters::should_drink_potion(potion_type ptype) const