From b794d555277836316ec842421c5287ff50641ff9 Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 22 Dec 2006 13:42:49 +0000 Subject: Added option 'autopickup_no_burden' which, if set, will prevent autopickup from picking up items beyond the burden limit. (Partial pickup will take place if you can take some of the items for a stack, e.g., 3 of the 5 potions of healing.) Defaults to false. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@692 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/items.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/items.cc') diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 24df6761d9..1832f36a90 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2962,12 +2962,30 @@ static void autopickup(void) if (item_needs_autopickup(mitm[o])) { + + int num_to_take = mitm[o].quantity; + if ( Options.autopickup_no_burden ) + { + int num_can_take = + (carrying_capacity(you.burden_state) - you.burden) / + item_mass(mitm[o]); + + if ( num_can_take == 0 ) + { + o = next; + continue; + } + + if ( num_can_take < num_to_take ) + num_to_take = num_can_take; + } + if (!(mitm[o].flags & ISFLAG_THROWN)) unthrown++; mitm[o].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED); - result = move_item_to_player( o, mitm[o].quantity); + result = move_item_to_player(o, num_to_take); if (result == 0) { -- cgit v1.2.3-54-g00ecf