summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/items.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-01 15:20:32 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-01 15:20:32 +0000
commit5c65cedddfd6f3d893c7eaec03f3c8519e266d45 (patch)
treea329dac4fc6be65f3ef947fc22c5af4f3e1e8284 /crawl-ref/source/items.cc
parent7cc367c09ed4fa3239ef8cb300cc1ef21fe129ce (diff)
downloadcrawl-ref-5c65cedddfd6f3d893c7eaec03f3c8519e266d45.tar.gz
crawl-ref-5c65cedddfd6f3d893c7eaec03f3c8519e266d45.zip
[1597293] Preliminary greedy-explore, parked on Ctrl-I. We can (re)move it if necessary.
Stash-tracking is no longer #ifdef conditionalised. I'm not aware of anybody who compiles without it. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@538 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r--crawl-ref/source/items.cc68
1 files changed, 42 insertions, 26 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index e0313a6ff6..c040288570 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2882,47 +2882,63 @@ static void autoinscribe_items()
autoinscribe_item( mitm[o] );
o = next;
}
-}
+}
-static void autopickup(void)
+bool item_needs_autopickup(const item_def &item)
{
- //David Loewenstern 6/99
- int result, o, next;
- bool did_pickup = false;
-
- if (!Options.autopickup_on || Options.autopickups == 0L)
- return;
+ return (strstr(item.inscription.c_str(), "=g") != 0
+ || ((item.flags & ISFLAG_THROWN) && Options.pickup_thrown)
+ || (((Options.autopickups & (1L << item.base_type))
+#ifdef CLUA_BINDINGS
+ || clua.callbooleanfn(false, "ch_autopickup", "u", &item)
+#endif
+ )
+ && (Options.pickup_dropped || !(item.flags & ISFLAG_DROPPED))
+ && !is_banned(item)));
+}
+
+bool can_autopickup()
+{
+ // [ds] Checking for autopickups == 0 is a bad idea because
+ // autopickup is still possible with inscriptions and
+ // pickup_thrown.
+ if (!Options.autopickup_on)
+ return (false);
if (you.attribute[ATTR_TRANSFORMATION] == TRAN_AIR
- && you.duration[DUR_TRANSFORMATION] > 0)
- {
- return;
- }
+ && you.duration[DUR_TRANSFORMATION] > 0)
+ return (false);
if (player_is_levitating() && !wearing_amulet(AMU_CONTROLLED_FLIGHT))
- return;
+ return (false);
if ( Options.safe_autopickup && !i_feel_safe() )
- return;
+ return (false);
+ return (true);
+}
+
+static void autopickup(void)
+{
+ //David Loewenstern 6/99
+ int result, o, next;
+ bool did_pickup = false;
+
+ if (!can_autopickup())
+ return;
+
o = igrd[you.x_pos][you.y_pos];
+ int unthrown = 0;
while (o != NON_ITEM)
{
next = mitm[o].link;
- if (
- (strstr(mitm[o].inscription.c_str(), "=g") != 0) || (
-
- ((mitm[o].flags & ISFLAG_THROWN) && Options.pickup_thrown) ||
- ( (Options.autopickups & (1L << mitm[o].base_type)
-#ifdef CLUA_BINDINGS
- || clua.callbooleanfn(false, "ch_autopickup", "u", &mitm[o])
-#endif
- )
- && (Options.pickup_dropped || !(mitm[o].flags & ISFLAG_DROPPED))
- && !is_banned(mitm[o]))))
+ if (item_needs_autopickup(mitm[o]))
{
+ if (!(mitm[o].flags & ISFLAG_THROWN))
+ unthrown++;
+
mitm[o].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED);
result = move_item_to_player( o, mitm[o].quantity);
@@ -2950,7 +2966,7 @@ static void autopickup(void)
if (did_pickup)
{
you.turn_is_over = true;
- start_delay( DELAY_AUTOPICKUP, 1 );
+ start_delay( DELAY_AUTOPICKUP, 1, unthrown );
}
}