Difference between revisions of "Autopickup exception"

From NetHackWiki
Jump to navigation Jump to search
(todo|Simplify the examples using real regex. NAO now has them.)
(Nethack mangles names in a misguided attempt to make everything singular. It does not strip articles as far as I can tell.)
Line 17: Line 17:
 
This will make the hero always pick up all items that match the string "*dagger".
 
This will make the hero always pick up all items that match the string "*dagger".
  
If the first character inside the quoted string is greater-than sign (<tt>&gt;</tt>), then the matched items will be not be picked up, if it's less-than sign (<tt>&lt;</tt>), the items will be picked up. The rest of the string defines what items will match for that rule. The string matching allows for basic wildcards, where asterisk (<tt>*</tt>) matches any number of characters and question mark (<tt>?</tt>) matches any one character. The object names to match are in the singular form without a leading "a ", "an ", etc. A "never pickup" rule takes precedence over an "always pickup" rule if both match an item. If no rule matches, autopickup defaults to pickup_types.
+
If the first character inside the quoted string is greater-than sign (<tt>&gt;</tt>), then the matched items will be not be picked up, if it's less-than sign (<tt>&lt;</tt>), the items will be picked up. The rest of the string defines what items will match for that rule. The string matching allows for basic wildcards, where asterisk (<tt>*</tt>) matches any number of characters and question mark (<tt>?</tt>) matches any one character. A "never pickup" rule takes precedence over an "always pickup" rule if both match an item. If no rule matches, autopickup defaults to pickup_types.
 +
 
 +
IMPORTANT: Nethack attempts to make the object names singular before matching them against your exceptions. This usually makes writing exceptions easier; HOWEVER, when you use #name to give an object a class name, like "a gem called worthless", Nethack will mangle the class name as well, possibly making it harder to match against. In particular, Nethack will attempt to make the word "worthless" singular by removing an "s", but only if the word comes at the END of the name. Thus, to drop all worthless glass, whether formally or informally IDed you should say ">*worthles*" NOT ">*worthless*".<ref>{{function|pickup.c|is_autopickup_exception}}</ref>
  
 
==How to use it effectively==
 
==How to use it effectively==
Line 292: Line 294:
 
  OPTIONS=pickup_types:0
 
  OPTIONS=pickup_types:0
 
  AUTOPICKUP_EXCEPTION=">*heavy iron ball*"
 
  AUTOPICKUP_EXCEPTION=">*heavy iron ball*"
 +
 +
==References==
 +
<references />
  
 
==External references==
 
==External references==

Revision as of 23:22, 22 August 2012

AUTOPICKUP_EXCEPTION is a configuration option that allows you to define what items are automatically picked up, with more precision than with pickup_types. You also need to have autopickup on and pickup_types match the AUTOPICKUP_EXCEPTION -lines. Highly recommended but not necessary is adapting pickup_burden.

OPTIONS=autopickup
OPTIONS=pickup_types:$?!/(
OPTIONS=pickup_burden:unencumbered

In NetHack 3.4.3 autopickup exceptions are not compiled in by default, and they're marked as experimental, so most builds probably won't have them. NAO does, however.

You can either define the exceptions in the options screen or in your configuration file by putting the following lines in it:

AUTOPICKUP_EXCEPTION=">*chest*"

This will make the hero never pick up all items that match the string "*chest*".

AUTOPICKUP_EXCEPTION="<*dagger"

This will make the hero always pick up all items that match the string "*dagger".

If the first character inside the quoted string is greater-than sign (>), then the matched items will be not be picked up, if it's less-than sign (<), the items will be picked up. The rest of the string defines what items will match for that rule. The string matching allows for basic wildcards, where asterisk (*) matches any number of characters and question mark (?) matches any one character. A "never pickup" rule takes precedence over an "always pickup" rule if both match an item. If no rule matches, autopickup defaults to pickup_types.

IMPORTANT: Nethack attempts to make the object names singular before matching them against your exceptions. This usually makes writing exceptions easier; HOWEVER, when you use #name to give an object a class name, like "a gem called worthless", Nethack will mangle the class name as well, possibly making it harder to match against. In particular, Nethack will attempt to make the word "worthless" singular by removing an "s", but only if the word comes at the END of the name. Thus, to drop all worthless glass, whether formally or informally IDed you should say ">*worthles*" NOT ">*worthless*".[1]

How to use it effectively

Autopickup exceptions can greatly simplify dungeon exploration. However, the very limited nature of its regular expression syntax makes it a bit hard to configure.

You can use them to keep dangerous items out of monsters' hands, to conveniently sort through large piles of loot, to automate things you might forget, to save a turn when fleeing or on speed runs, to remove good morphs from your polypiling line without paying attention etc.

Use pickup_types as an in-game switch to distinguish between early game and late game config. In your nethackrc, simply don't mention items you want to default to pickup_types.

A few items are useful only in the early game (such as gold). You can remove according autopickup exceptions in-game with the O command. They will re-appear when you restore or start a new game. If your needs change much over the course of a long game, the easiest way to update the exceptions is (un)comment lines in your config file, save the game, and restore.

A user has suggested improving this page or section as follows:

"Simplify the examples using real regex. NAO now has them."

Easy ones

Name the real Amulet right away, and you'll never fall for a fake:

AUTOPICKUP_EXCEPTION=">*Amulet of Yendor"
AUTOPICKUP_EXCEPTION="<*Amulet of Yendor named ?*"

Avoid turning your scrolls of scare monster to dust:

AUTOPICKUP_EXCEPTION=">*scroll of scare monster"
AUTOPICKUP_EXCEPTION=">*scroll called scare monster"

Walk in peace over empty wands:

autopickup_exception="*:0)*"
AUTOPICKUP_EXCEPTION=">* named empty"

Good items left after a fight, but requires careful weight watching:

# autopickup_exception="<*full healing"
# autopickup_exception="<*extra healing"
# autopickup_exception="<*potion of healing"
# autopickup_exception="<*gain level"

Pick up formally identified artifacts. Don't blast yourself to death with a cross-aligned one - leave unidentified ones on the floor.

autopickup_exception="<the*"

Some people also want known-blessed items, but this likely picks up too much.

#  autopickup_exception="<blessed *"

Never pick up corpses except lizards

Since you can't define an exception from an exception, you have to enumerate the possibilities. The trailing asterix takes care of named monsters.

Other reasonable double-exceptions could be wraith or even newt and lichen corpses.

# AUTOPICKUP_EXCEPTION="<*lizard corpse"
# "blessed/(un)cursed greased partly-eaten monstertype/unique's corpse"
AUTOPICKUP_EXCEPTION=">*a corpse*"
AUTOPICKUP_EXCEPTION=">*b corpse*"
AUTOPICKUP_EXCEPTION=">*c corpse*"
AUTOPICKUP_EXCEPTION=">*e corpse*"
AUTOPICKUP_EXCEPTION=">*f corpse*"
AUTOPICKUP_EXCEPTION=">*g corpse*"
AUTOPICKUP_EXCEPTION=">*h corpse*"
AUTOPICKUP_EXCEPTION=">*i corpse*"
AUTOPICKUP_EXCEPTION=">*k corpse*"
AUTOPICKUP_EXCEPTION=">*l corpse*"
AUTOPICKUP_EXCEPTION=">*m corpse*"
AUTOPICKUP_EXCEPTION=">*n corpse*"
AUTOPICKUP_EXCEPTION=">*o corpse*"
AUTOPICKUP_EXCEPTION=">*p corpse*"
AUTOPICKUP_EXCEPTION=">*r corpse*"
AUTOPICKUP_EXCEPTION=">*s corpse*"
AUTOPICKUP_EXCEPTION=">*' corpse*"
AUTOPICKUP_EXCEPTION=">*t corpse*"
AUTOPICKUP_EXCEPTION=">*u corpse*"
AUTOPICKUP_EXCEPTION=">*v corpse*"
AUTOPICKUP_EXCEPTION=">*x corpse*"
AUTOPICKUP_EXCEPTION=">*y corpse*"
AUTOPICKUP_EXCEPTION=">*ld corpse*"
AUTOPICKUP_EXCEPTION=">*nd corpse*"
AUTOPICKUP_EXCEPTION=">*ud corpse*"
AUTOPICKUP_EXCEPTION=">*ord corpse*"
AUTOPICKUP_EXCEPTION=">*uard corpse*"
AUTOPICKUP_EXCEPTION=">*wizard corpse*"

Define pickup / drop in-game

You want to say "pick up all such objects" or "always leave this one on the floor" without editing your config. The challenge is to make the choice for the individual object always override the object class. To preserve that feature, you must not let your other rules end with a wildcard.

This example ruleset has you pick up (<) and drop (>) items according to the last character of their object type name and individual name.

autopickup_exception="<* named *<"
autopickup_exception="<* named *< (?:?)"
autopickup_exception="<* named *< (?:??)"
autopickup_exception="<* called *<"
autopickup_exception="<* called *< named ?*"
# The above rule is ok because if both "called <" and "named >" match, it's dropped.
autopickup_exception=">* named *>"
autopickup_exception=">* called *>"
# Last character only. ">* called *>*" would also match "x called foo>bar named <",
# preventing individual overrides.
autopickup_exception=">* called *> named *a"
autopickup_exception=">* called *> named *b"
autopickup_exception=">* called *> named *c"
autopickup_exception=">* called *> named *d"
autopickup_exception=">* called *> named *e"
autopickup_exception=">* called *> named *f"
autopickup_exception=">* called *> named *g"
autopickup_exception=">* called *> named *h"
autopickup_exception=">* called *> named *i"
autopickup_exception=">* called *> named *j"
autopickup_exception=">* called *> named *k"
autopickup_exception=">* called *> named *l"
autopickup_exception=">* called *> named *m"
autopickup_exception=">* called *> named *n"
autopickup_exception=">* called *> named *o"
autopickup_exception=">* called *> named *p"
autopickup_exception=">* called *> named *q"
autopickup_exception=">* called *> named *r"
autopickup_exception=">* called *> named *s"
autopickup_exception=">* called *> named *t"
autopickup_exception=">* called *> named *u"
autopickup_exception=">* called *> named *v"
autopickup_exception=">* called *> named *w"
autopickup_exception=">* called *> named *x"
autopickup_exception=">* called *> named *y"
autopickup_exception=">* called *> named *z"
autopickup_exception=">* called *> named *A"
autopickup_exception=">* called *> named *B"
autopickup_exception=">* called *> named *C"
autopickup_exception=">* called *> named *D"
autopickup_exception=">* called *> named *E"
autopickup_exception=">* called *> named *F"
autopickup_exception=">* called *> named *G"
autopickup_exception=">* called *> named *H"
autopickup_exception=">* called *> named *I"
autopickup_exception=">* called *> named *J"
autopickup_exception=">* called *> named *K"
autopickup_exception=">* called *> named *L"
autopickup_exception=">* called *> named *M"
autopickup_exception=">* called *> named *N"
autopickup_exception=">* called *> named *O"
autopickup_exception=">* called *> named *P"
autopickup_exception=">* called *> named *Q"
autopickup_exception=">* called *> named *R"
autopickup_exception=">* called *> named *S"
autopickup_exception=">* called *> named *T"
autopickup_exception=">* called *> named *U"
autopickup_exception=">* called *> named *V"
autopickup_exception=">* called *> named *W"
autopickup_exception=">* called *> named *X"
autopickup_exception=">* called *> named *Y"
autopickup_exception=">* called *> named *Z"
autopickup_exception=">* called *> named *^"
autopickup_exception=">* called *> named *!"
autopickup_exception=">* called *> named *$"
autopickup_exception=">* called *> named *%"
autopickup_exception=">* called *> named *&"
autopickup_exception=">* called *> named */"
autopickup_exception=">* called *> named *("
# #items with charges are alway fully ID'd, thus no
# #"wand called nothing> named stash< (0:12)"
autopickup_exception=">* called *> named *)"
autopickup_exception=">* called *> named *="
autopickup_exception=">* called *> named *`"
autopickup_exception=">* called *> named *+"
autopickup_exception=">* called *> named *,"
autopickup_exception=">* called *> named *;"
autopickup_exception=">* called *> named *."
autopickup_exception=">* called *> named *:"
autopickup_exception=">* called *> named *-"
autopickup_exception=">* called *> named *_"
autopickup_exception=">* called *> named *["
autopickup_exception=">* called *> named *]"
autopickup_exception=">* called *> named *{"
autopickup_exception=">* called *> named *}"
autopickup_exception=">* called *> named *|"
autopickup_exception=">* called *> named *\"
autopickup_exception=">* called *> named *0"
autopickup_exception=">* called *> named *1"
autopickup_exception=">* called *> named *2"
autopickup_exception=">* called *> named *3"
autopickup_exception=">* called *> named *4"
autopickup_exception=">* called *> named *5"
autopickup_exception=">* called *> named *6"
autopickup_exception=">* called *> named *7"
autopickup_exception=">* called *> named *8"
autopickup_exception=">* called *> named *9"

One of each kind of magical object

Usually, you need only one of each type of magical armor / ring / amulet / spellbook / magic tool. Wouldn't it be nice if the game managed that for you? It can if you're willing to class-name all objects immediately.

Below are the rules for armor. E. g. call the mine town watchmens' helmets "plain", and a good but cursed one from a bones pile is "#2 bones <" (to pick up a second one). See Tjr's config for other item types.

# AUTOPICKUP_EXCEPTION="<*robe"
# AUTOPICKUP_EXCEPTION="<*faded pall"
# AUTOPICKUP_EXCEPTION="<*apron"
# AUTOPICKUP_EXCEPTION="<*polished silver shield"
# AUTOPICKUP_EXCEPTION="<*smooth shield"
# #              blind       ^^^^^^
AUTOPICKUP_EXCEPTION="<*conical hat"
AUTOPICKUP_EXCEPTION="<*plumed helmet"
AUTOPICKUP_EXCEPTION="<*etched helmet"
AUTOPICKUP_EXCEPTION="<*crested helmet"
AUTOPICKUP_EXCEPTION="<*visored helmet"
AUTOPICKUP_EXCEPTION="<*tattered cape"
AUTOPICKUP_EXCEPTION="<*opera cloak"
AUTOPICKUP_EXCEPTION="<*ornamental cope"
AUTOPICKUP_EXCEPTION="<*piece of cloth"
AUTOPICKUP_EXCEPTION="<*old gloves"
AUTOPICKUP_EXCEPTION="<*padded gloves"
AUTOPICKUP_EXCEPTION="<*riding gloves"
AUTOPICKUP_EXCEPTION="<*fencing gloves"
AUTOPICKUP_EXCEPTION="<*combat boots"
AUTOPICKUP_EXCEPTION="<*jungle boots"
AUTOPICKUP_EXCEPTION="<*hiking boots"
AUTOPICKUP_EXCEPTION="<*mud boots"
AUTOPICKUP_EXCEPTION="<*buckled boots"
AUTOPICKUP_EXCEPTION="<*riding boots"
AUTOPICKUP_EXCEPTION="<*snow boots"

Keeping ammunition out of monsters' hands

Especially in the Mines, you want to collect lightweight but dangerous projectiles and deposit then on an Elbereth square. This prevents monsters from reusing them against you over and over. (Deactivate daggers if you don't fire them yourself - they're heavy.)

AUTOPICKUP_EXCEPTION="<*arrow"
## AUTOPICKUP_EXCEPTION="<*elven arrow"
## AUTOPICKUP_EXCEPTION="<*orcish arrow"
## AUTOPICKUP_EXCEPTION="<*silver arrow"
## AUTOPICKUP_EXCEPTION="<*runed arrow"
## AUTOPICKUP_EXCEPTION="<*crude arrow"
AUTOPICKUP_EXCEPTION="<*ya"
## AUTOPICKUP_EXCEPTION="<*bamboo arrow"
AUTOPICKUP_EXCEPTION="<*crossbow bolt"
AUTOPICKUP_EXCEPTION="<*dart"
AUTOPICKUP_EXCEPTION="<*shuriken"
AUTOPICKUP_EXCEPTION="<*throwing star"
AUTOPICKUP_EXCEPTION="<*dagger"
## AUTOPICKUP_EXCEPTION="<*elven dagger"
## AUTOPICKUP_EXCEPTION="<*orcish dagger"
## AUTOPICKUP_EXCEPTION="<*runed dagger"
## AUTOPICKUP_EXCEPTION="<*crude dagger"
## AUTOPICKUP_EXCEPTION="<*silver dagger"
AUTOPICKUP_EXCEPTION="<*knife"

Things too good to miss

Wands of wishing, magic lamps, magic markers, and wands of permanent Elbereth are useful even in the ascension run or when farming. In those situations, you likely have enough other things on your mind. You don't want monsters zapping create monster or shooting death rays at you.

AUTOPICKUP_EXCEPTION="<*wand of wishing"
AUTOPICKUP_EXCEPTION="<*wand called wish"
AUTOPICKUP_EXCEPTION="<*wand of create monster"
AUTOPICKUP_EXCEPTION="<*wand of teleportation"
AUTOPICKUP_EXCEPTION="<*wand called tele"
# AUTOPICKUP_EXCEPTION="<*wand of polymorph"
# AUTOPICKUP_EXCEPTION="<*wand called poly"
AUTOPICKUP_EXCEPTION="<*wand of fire"
AUTOPICKUP_EXCEPTION="<*wand of lightning"
AUTOPICKUP_EXCEPTION="<*wand of death"
# # Cold is used for Juiblex swamp, etc.
# AUTOPICKUP_EXCEPTION=">*wand of cold"
AUTOPICKUP_EXCEPTION="<*magic marker"
AUTOPICKUP_EXCEPTION="<*magic lamp"
AUTOPICKUP_EXCEPTION="<lamp"
AUTOPICKUP_EXCEPTION="<*d lamp"
AUTOPICKUP_EXCEPTION="<*amulet of life saving"
AUTOPICKUP_EXCEPTION="<*amulet called life"
AUTOPICKUP_EXCEPTION="<*athame"


Avoiding loadstones

This ruleset should never pick up a loadstone, regardless if you are blind or how well you know loadstones. You can still automatically pick up agate stones etc.

AUTOPICKUP_EXCEPTION=">*stone called loa*"
AUTOPICKUP_EXCEPTION=">*loadstone"
AUTOPICKUP_EXCEPTION=">*loadstone named *"
AUTOPICKUP_EXCEPTION=">*gray stone"
# #blind: glass/gems show up as gem, all else as stone.
AUTOPICKUP_EXCEPTION=">stone"
# # blessed, uncursed, cursed, greased
AUTOPICKUP_EXCEPTION=">*sed stone"

Only exceptions pick stuff up

If you want only the exceptions to pick anything up, you would normally set pickup_tyes to "". Unfortunately, that picks up everything. The solution are iron balls:

OPTIONS=pickup_types:0
AUTOPICKUP_EXCEPTION=">*heavy iron ball*"

References

External references