summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-stuff.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2010-01-03 16:26:23 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2010-01-03 16:26:23 +0530
commit3afcc226b588e53f707d61341d4a1b4d764278c5 (patch)
tree313e6771482742aa1b57e7797da361d444cedd3c /crawl-ref/source/mon-stuff.cc
parent804b380b9b5600b08c000ac995da1e8529a83ebf (diff)
downloadcrawl-ref-3afcc226b588e53f707d61341d4a1b4d764278c5.tar.gz
crawl-ref-3afcc226b588e53f707d61341d4a1b4d764278c5.zip
Repair monster ability to use throwing weapons.
Monsters were unable to use throwing weapons in inventory, and would reject throwing weapons at generation time, fixed.
Diffstat (limited to 'crawl-ref/source/mon-stuff.cc')
-rw-r--r--crawl-ref/source/mon-stuff.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/crawl-ref/source/mon-stuff.cc b/crawl-ref/source/mon-stuff.cc
index 12f8c137ad..1395161b51 100644
--- a/crawl-ref/source/mon-stuff.cc
+++ b/crawl-ref/source/mon-stuff.cc
@@ -3277,10 +3277,14 @@ bool mons_avoids_cloud(const monsters *monster, int cloud_num,
}
// Returns a rough estimate of damage from throwing the wielded weapon.
-int mons_thrown_weapon_damage(const item_def *weap)
+int mons_thrown_weapon_damage(const item_def *weap,
+ bool only_returning_weapons)
{
- if (!weap || get_weapon_brand(*weap) != SPWPN_RETURNING)
+ if (!weap ||
+ (only_returning_weapons && get_weapon_brand(*weap) != SPWPN_RETURNING))
+ {
return (0);
+ }
return std::max(0, (property(*weap, PWPN_DAMAGE) + weap->plus2 / 2));
}
@@ -3314,6 +3318,7 @@ int mons_pick_best_missile(monsters *mons, item_def **launcher,
{
*launcher = NULL;
item_def *melee = NULL, *launch = NULL;
+ int melee_weapon_count = 0;
for (int i = MSLOT_WEAPON; i <= MSLOT_ALT_WEAPON; ++i)
{
if (item_def *item = mons->mslot_item(static_cast<mon_inv_type>(i)))
@@ -3321,7 +3326,10 @@ int mons_pick_best_missile(monsters *mons, item_def **launcher,
if (is_range_weapon(*item))
launch = item;
else if (!ignore_melee)
+ {
melee = item;
+ ++melee_weapon_count;
+ }
}
}
@@ -3329,7 +3337,10 @@ int mons_pick_best_missile(monsters *mons, item_def **launcher,
if (launch && missiles && !missiles->launched_by(*launch))
launch = NULL;
- const int tdam = mons_thrown_weapon_damage(melee);
+ const int tdam =
+ mons_thrown_weapon_damage(
+ melee,
+ melee_weapon_count == 1 && melee->quantity == 1);
const int fdam = mons_missile_damage(mons, launch, missiles);
if (!tdam && !fdam)