diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-06 19:08:38 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-06 19:08:38 +0000 |
commit | 590e197da874d89defd085e799f8171c2880e8e3 (patch) | |
tree | 31b0b0ba425f6ce98d996dfcc450920c218c2362 | |
parent | 942fcc618e384eed001f538abe28912fd0d468d3 (diff) | |
download | crawl-ref-590e197da874d89defd085e799f8171c2880e8e3.tar.gz crawl-ref-590e197da874d89defd085e799f8171c2880e8e3.zip |
Monsters that have destructive spells do not pick up missile weapons.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1777 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/externs.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 777d91c33f..d0d9e70ce9 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1168,7 +1168,8 @@ private: void lose_pickup_energy(); bool check_set_valid_home(const coord_def &place, coord_def &chosen, - int &nvalid) const; + int &nvalid) const; + bool has_spell_of_type(unsigned) const; }; struct cloud_struct diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 8653c1cfd5..d26bacc2e6 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -2339,11 +2339,29 @@ bool monsters::can_throw_rocks() const type == MONS_POLYPHEMUS); } +bool monsters::has_spell_of_type(unsigned disciplines) const +{ + for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) + { + if (spells[i] == SPELL_NO_SPELL) + continue; + + if (spell_typematch(spells[i], disciplines)) + return (true); + } + return (false); +} + bool monsters::can_use_missile(const item_def &item) const { // Pretty simplistic at the moment. We allow monsters to pick up // missiles without the corresponding launcher, assuming that sufficient // wandering may get them to stumble upon the launcher. + + // Prevent monsters that have conjurations / summonings from + // grabbing missiles. + if (has_spell_of_type(SPTYP_CONJURATION | SPTYP_SUMMONING)) + return (false); if (item.base_type == OBJ_WEAPONS) return (is_throwable(item)); |