diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-26 09:43:41 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-26 09:43:41 +0000 |
commit | 728d47739090f3b3e739858af065168fdea4eeb4 (patch) | |
tree | ed832410bc66d2fea047ab17b61f0d9ce37c830e | |
parent | ea3b797045e2c9f99f6f2814b623ca4d341f92c6 (diff) | |
download | crawl-ref-728d47739090f3b3e739858af065168fdea4eeb4.tar.gz crawl-ref-728d47739090f3b3e739858af065168fdea4eeb4.zip |
Smarter monster pickup:
* Hostile monsters that are occupied by fighting, seeking etc. won't
pick up anything dropped or thrown by you. Since they cannot know when
or why you dropped or threw an item, they just have to assume that it
was done to distract them. Our monsters are smart, and won't fall for
such cheap ploys. :P
* Occupied monsters won't pick up throwable weapons if they would just
stack with existing missiles.
* Monsters won't pick up empty wands, and they may drop an empty wand
if they come across a charged one (however unlikely that combination
may be).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4661 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/mon-util.cc | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 4c98d801f6..f5e8a8b66f 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -3340,8 +3340,14 @@ static int _q_adj_damage(int damage, int qty) bool monsters::pickup_throwable_weapon(item_def &item, int near) { - if (mslot_item(MSLOT_MISSILE) && pickup(item, MSLOT_MISSILE, near, true)) + // If occupied, don't pick up a throwable weapons if it would just + // stack with an existing one. (Upgrading is possible.) + if (mslot_item(MSLOT_MISSILE) + && behaviour == BEH_WANDER + && pickup(item, MSLOT_MISSILE, near, true)) + { return (true); + } item_def *launch = NULL; const int exist_missile = mons_pick_best_missile(this, &launch, true); @@ -3563,8 +3569,26 @@ bool monsters::pickup_missile(item_def &item, int near, bool force) bool monsters::pickup_wand(item_def &item, int near) { + // Don't pick up empty wands. + if (item.plus == 0) + return (false); + // Only low-HD monsters bother with wands. - return (hit_dice < 14 && pickup(item, MSLOT_WAND, near)); + if (hit_dice >= 14) + return (false); + + // If you already have a charged wand, don't bother. + // Otherwise, replace with a charged one. + if (item_def *wand = mslot_item(MSLOT_WAND)) + { + if (wand->plus > 0) + return (false); + + if (!drop_item(MSLOT_WAND, near)) + return (false); + } + + return (pickup(item, MSLOT_WAND, near)); } bool monsters::pickup_scroll(item_def &item, int near) @@ -3654,7 +3678,10 @@ bool monsters::pickup_item(item_def &item, int near, bool force) if (attitude == ATT_NEUTRAL) return (false); - bool wandering = (behaviour == BEH_WANDER); + // If a monster isn't otherwise occupied (has a foe, is fleeing, etc.) + // it is considered wandering. + bool wandering = (behaviour == BEH_WANDER + || mons_friendly(this) && foe == MHITYOU); // Weak(ened) monsters won't stop to pick up things as long as they // feel unsafe. @@ -3673,18 +3700,30 @@ bool monsters::pickup_item(item_def &item, int near, bool force) // These are not important enough for pickup when seeking, fleeing etc. const int itype = item.base_type; - if (!wandering && (!mons_friendly(this) || foe != MHITYOU) - && (itype == OBJ_ARMOUR || itype == OBJ_CORPSES - || itype == OBJ_MISCELLANY || itype == OBJ_GOLD)) + if (!wandering) { - return false; - } + if (itype == OBJ_ARMOUR || itype == OBJ_CORPSES + || itype == OBJ_MISCELLANY || itype == OBJ_GOLD) + { + return false; + } - // Fleeing monster only pick up emergency equipment. - if (behaviour == BEH_FLEE - && (itype == OBJ_WEAPONS || itype == OBJ_MISSILES)) - { - return (false); + if (itype == OBJ_WEAPONS || itype == OBJ_MISSILES) + { + // Fleeing monster only pick up emergency equipment. + if (behaviour == BEH_FLEE) + return false; + + // While occupied, hostile monsters won't pick up items + // dropped or thrown by you. (You might have done that to + // distract them.) + if (!mons_friendly(this) + && (testbits(item.flags, ISFLAG_DROPPED) + || testbits(item.flags, ISFLAG_THROWN))) + { + return false; + } + } } } @@ -3700,6 +3739,7 @@ bool monsters::pickup_item(item_def &item, int near, bool force) case OBJ_GOLD: return pickup_gold(item, near); // Fleeing monsters won't pick up these. + // Hostiles won't pick them up if they were ever dropped/thrown by you. case OBJ_WEAPONS: return pickup_weapon(item, near, force); case OBJ_MISSILES: |