summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/godabil.cc
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-06-24 21:12:26 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-06-24 21:41:22 -0700
commitc94875da97cfbca3100955a65f81370df4d2d35a (patch)
tree9a40a9ee568fa188c275a2fb2847509d47080586 /crawl-ref/source/godabil.cc
parent810044142f6bb87906e4ba88363e20704914ac64 (diff)
downloadcrawl-ref-c94875da97cfbca3100955a65f81370df4d2d35a.tar.gz
crawl-ref-c94875da97cfbca3100955a65f81370df4d2d35a.zip
Don't make orc drop melee weapons when gifted launchers
Diffstat (limited to 'crawl-ref/source/godabil.cc')
-rw-r--r--crawl-ref/source/godabil.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/crawl-ref/source/godabil.cc b/crawl-ref/source/godabil.cc
index 123dbc2c7d..ed92491d53 100644
--- a/crawl-ref/source/godabil.cc
+++ b/crawl-ref/source/godabil.cc
@@ -1572,19 +1572,33 @@ bool beogh_gift_item()
const bool shield = is_shield(gift);
const bool body_armour = gift.base_type == OBJ_ARMOUR
&& get_armour_slot(gift) == EQ_BODY_ARMOUR;
+ const bool weapon = gift.base_type == OBJ_WEAPONS;
+ const item_def* mons_weapon = mons->weapon();
- if (!(gift.base_type == OBJ_WEAPONS && mons->could_wield(gift)
+ if (!(weapon && mons->could_wield(gift)
|| body_armour && check_armour_size(gift, mons->body_size())
|| shield
- && (!mons->weapon()
- || mons->hands_reqd(*mons->weapon()) != HANDS_TWO)))
+ && (!mons_weapon
+ || mons->hands_reqd(*mons_weapon) != HANDS_TWO)))
{
mprf("%s can't use that.", monsname);
return false;
}
+
+ // if we're giving a ranged weapon to an orc holding a melee weapon in
+ // their hands, or vice versa, put it in their carried slot instead.
+ // this will of course drop anything that's there.
+ const bool use_alt_slot = weapon && mons_weapon
+ && is_range_weapon(gift) !=
+ is_range_weapon(*mons_weapon);
+
mons->take_item(item_slot, body_armour ? MSLOT_ARMOUR :
shield ? MSLOT_SHIELD :
+ use_alt_slot ? MSLOT_ALT_WEAPON :
MSLOT_WEAPON);
+ if (use_alt_slot)
+ mons->swap_weapons(true);
+
if (shield)
mons->props[BEOGH_SH_GIFT_KEY] = true;
else if (body_armour)