summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-09 18:18:52 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-09 18:18:52 +0000
commit2ee0afe954a7c72856fd5f0f7d3080012638bb98 (patch)
treee74d1ada80812f82ebcd67c8928b9c9a3f2a0a81 /crawl-ref
parent2ef8bb80a61c7b8aec6264babac49b04de264e96 (diff)
downloadcrawl-ref-2ee0afe954a7c72856fd5f0f7d3080012638bb98.tar.gz
crawl-ref-2ee0afe954a7c72856fd5f0f7d3080012638bb98.zip
Remove pickup.lua.
Make menu_colour_item_prefix also apply for autopickup_exceptions, so you can exclude, for example, all evil_eating at once. Fix Vampires "continuing draining" after having "stopped". git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5666 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/docs/options_guide.txt28
-rw-r--r--crawl-ref/settings/autopickup_exceptions.txt15
-rw-r--r--crawl-ref/settings/init.txt27
-rw-r--r--crawl-ref/settings/messages.txt2
-rw-r--r--crawl-ref/source/dat/lua/pickup.lua125
-rw-r--r--crawl-ref/source/delay.cc3
-rw-r--r--crawl-ref/source/food.cc6
-rw-r--r--crawl-ref/source/itemname.cc65
-rw-r--r--crawl-ref/source/itemname.h5
-rw-r--r--crawl-ref/source/items.cc11
10 files changed, 87 insertions, 200 deletions
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt
index ea12dd225f..3025d07e66 100644
--- a/crawl-ref/docs/options_guide.txt
+++ b/crawl-ref/docs/options_guide.txt
@@ -1251,8 +1251,11 @@ menu_colour = <match>:<colour>:<regex>
identified, evil_item wand of draining (4)
unidentified, equipped, artefact sparkling ring
+ The same prefixes can also be used for highlighting prompts pertaining
+ to items matching the description, or to define autopickup_exceptions.
+
If you want to colour all items that contain a certain prefix, use
- menu_colour = lightgreen:.*poisonous.*
+ menu_colour = lightgreen:poisonous
To colour worn stuff and highlight cursed items, take
menu_colour = inventory:lightred:equipped.* cursed
@@ -1261,12 +1264,12 @@ menu_colour = <match>:<colour>:<regex>
To colour identified artefacts, try
menu_colour = inventory:white:( [-+] the)
- or, if menu_colour_prefix_id is true,
+ or
menu_colour = inventory:white:identified.*artefact
If you frequently die because you forget to use emergency items,
try
- menu_colour = inventory:cyan:(potions? of heal wounds|blinking)
+ menu_colour = inventory:cyan:emergency_item
menu_colour = inventory:lightcyan:wand of (fire|cold|draining)
To quickly check what potions were trashed by a mummy curse, use
@@ -1280,27 +1283,10 @@ menu_colour = <match>:<colour>:<regex>
white:
menu_colour = notes:white:Reached XP level
-menu_colour_prefix_id = false
- Setting this option to true will prefix the string against which
- menu_colour regexes are matched (not the string
- displayed) with the item's identification state: "unidentified"
- for unidentified, "known" for wands for which you know the type
- but don't know the number of charges, and for rings with plusses
- for which you know the type but don't know the plus value, and
- "identified" for other identified items.
-
- Note that the prefix is put before the the *entire* string which
- is displayed, so if you're wielding an uncursed dagger which has
- the 'a' slot, the string the regexes will match against is
- "identified a - an uncursed dagger (weapon)".
-
menu_colour_prefix_class = false
Setting this option to true will prefix the string against which
menu_colour regexes are matched (not the string displayed) with
- the item's object type: armour, weapon, wand, etc. If both this
- option and menu_colour_prefix_id are set to true, then the
- identification string comes before the object type string (i.e.,
- "identified weapon", "known wand", etc).
+ the item's object type: armour, weapon, wand, etc.
Note that the prefix is put before the the *entire* string which
is displayed, so if you're wielding a uncursed dagger which has
diff --git a/crawl-ref/settings/autopickup_exceptions.txt b/crawl-ref/settings/autopickup_exceptions.txt
index bff660c3c6..a9ffc2405e 100644
--- a/crawl-ref/settings/autopickup_exceptions.txt
+++ b/crawl-ref/settings/autopickup_exceptions.txt
@@ -5,7 +5,6 @@ ae := autopickup_exceptions
# curare is always dangerous on the floor
ae = <curare-tipped
-
### exclusions ###
# Don't autopickup in the Abyss
@@ -16,17 +15,15 @@ function ch_autopickup(it)
end
end >
-# Excluding amulets as you only need one of each. Also for some rings.
-# There is some (intended) overlap with pickup.lua, which also excludes
-# the ring of hunger, for example.
+# Exclude potentially useful items of high risk, like ?torment.
+ae = dangerous_item
+
+# Excluding amulets as you only need one of each. (If you know the
+# subtype that means you already have one of it.) Also for some rings.
+# Some items may already be excluded as bad_item, e.g. inaccuracy.
ae = amulet of (inaccuracy|gourmand|controlled flight|warding)
ae = amulet of (resist mutation|resist slow|clarity|rage)
ae = ring of (see invisible|levitation|poison resistance|hunger)
ae = ring of (fire|ice|sustenance|invisibility)
ae = ring of (magical power|regeneration)
-: if you.god() == "Trog" then
-ae = wizardry
-ae = staff
-: end
-
diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt
index 5dc1d569cc..d489f53e32 100644
--- a/crawl-ref/settings/init.txt
+++ b/crawl-ref/settings/init.txt
@@ -80,7 +80,6 @@ lua_file = lua/runrest.lua
lua_file = lua/gearset.lua
lua_file = lua/eat.lua
lua_file = lua/trapwalk.lua
-lua_file = lua/pickup.lua
# kills.lua yields more information at the cost of huge dumps.
# lua_file = lua/kills.lua
@@ -215,28 +214,30 @@ include = travel_stoppers.txt
# sort_menus = pickup: true : basename, qualname, curse, qty
# msg_condense_repeats = false
+
##### 4-j Messages and Display Enhancements #####
#
# hp_warning = 10
# mp_warning = 0
-
# hp_colour = 50:yellow, 25:red
# mp_colour = 50:yellow, 25:red
-# status_caption_colour = yellow
-# delay_message_clear = true
-# show_inventory_weights = true
-# show_gold_turns = true
-# show_beam = false
-# item_stack_summary_minimum = 5
-# list_rotten = false
-# mlist_min_height = 5
-# msg_max_height = 10
+
+# status_caption_colour = yellow
+# classic_hud = true
+# mlist_min_height = 5
+# msg_max_height = 10
# mlist_allow_alternate_layout = true
-# classic_hud = true
+# show_gold_turns = true
+
+# delay_message_clear = true
+# show_inventory_weights = true
+# item_stack_summary_minimum = 5
+# list_rotten = false
+
+# show_beam = false
##### Colours (messages and menus) #####
#
-# menu_colour_prefix_id = true
menu_colour_prefix_class = true
# Food is colour coded in standard_colours.txt as follows:
diff --git a/crawl-ref/settings/messages.txt b/crawl-ref/settings/messages.txt
index 91220a39cd..67856347fa 100644
--- a/crawl-ref/settings/messages.txt
+++ b/crawl-ref/settings/messages.txt
@@ -10,7 +10,7 @@ msc = lightred:strangely unstable
msc = lightred:curare-tipped.*hits you
msc = lightred:Space warps.* around you
msc = lightred:Space bends around you
-msc = lightred:is eaten away
+msc = lightred:acid corrodes
msc = lightred:you are carrying w.* destroyed
msc = lightred:you are carrying catche?s? fire
msc = lightred:you are carrying freezes? and shatters?
diff --git a/crawl-ref/source/dat/lua/pickup.lua b/crawl-ref/source/dat/lua/pickup.lua
deleted file mode 100644
index 254d17994b..0000000000
--- a/crawl-ref/source/dat/lua/pickup.lua
+++ /dev/null
@@ -1,125 +0,0 @@
-------------------------------------------------------------
--- pickup.lua:
--- Smarter autopickup handling that takes into account the
--- item type in combination with your character's race,
--- religion, knowledge, and eating habits.
---
--- To use this, add this line to your init.txt:
--- lua_file = lua/pickup.lua
---
--- Notes:
--- * This script only handles items of classes with
--- autopickup on.
--- * Any result can still be overridden using
--- autopickup_exceptions.
-------------------------------------------------------------
-
-function make_hash(ls)
- local h = { }
- for _, i in ipairs(ls) do
- h[i] = true
- end
- return h
-end
-
--- don't count Vampires here because of all those exceptions
-function you_real_undead()
- return you.race() == "Mummy" or you.race() == "Ghoul"
-end
-
--- not identified
-function unknown_potion(type)
- return type == 0
-end
-
-function good_potion(type)
- return type == 1
-end
-
-function bad_potion(type)
- return type == 2
-end
-
--- special cases
-function spec_potion(type)
- return type == 3
-end
-
-function ch_autopickup(it)
- local spells = make_hash( you.spells() )
-
- if item.class(it) == "Potions" then
-
- local type = item.potion_type(it)
-
- -- "bad" potions only for Evaporate
- if spells["Evaporate"] and bad_potion(type) then
- return true
- end
-
- -- no potions for Mummies
- -- also: no bad potions for anyone else
- if you.race() == "Mummy" or bad_potion(type) then
- return false
- end
-
- -- pickup "good" and unID'd potions
- if good_potion(type) or unknown_potion(type) then
- return true
- end
-
- -- special handling
- if spec_potion(type) then
-
- -- real undead cannot use berserk
- -- or anything involving mutations
- if item.subtype(it) == "berserk"
- or item.subtype(it) == "gain ability"
- or item.subtype(it) == "cure mutation"
- or item.subtype(it) == "mutation" then
- if you_real_undead() then
- return false
- else
- return true
- end
- end
-
- -- special cases for blood, water, and porridge
- if item.subtype(it) == "blood"
- or item.subtype(it) == "water"
- or item.subtype(it) == "porridge" then
- return food.can_eat(it, false)
- end
- end
-
- -- anything not handled until here can be picked up
- return true
- end
-
- if item.class(it) == "Carrion"
- or item.class(it) == "Comestibles" then
- return food.can_eat(it, false)
- end
-
- if item.class(it) == "Books" and item.subtype(it) == "spellbook"
- and you.god() == "Trog" then
- return false
- end
-
- if item.class(it) == "Jewellery" then
- if item.subtype(it) == "hunger"
- or item.subtype(it) == "inaccuracy" then
- return false
- end
- if you_real_undead() and
- (item.subtype(it) == "regeneration"
- or item.subtype(it) == "rage"
- or item.subtype(it) == "sustenance"
- and you.race() == "Mummy") then
- return false
- end
- end
-
- -- we only get here if class autopickup ON
- return true
-end
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index c78e73dce3..13bba97f25 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -492,6 +492,7 @@ void stop_delay( bool stop_stair_travel )
turn_corpse_into_skeleton(corpse, 90);
}
did_god_conduct(DID_DRINK_BLOOD, 8);
+ delay.duration = 0;
pop_delay();
break;
}
@@ -746,7 +747,7 @@ void handle_delay( void )
{
mpr("The corpse rots away into a skeleton!");
if (delay.type == DELAY_BUTCHER
- || delay.type == DELAY_BOTTLE_BLOOD)
+ || delay.type == DELAY_BOTTLE_BLOOD) // Shouldn't happen.
{
if (player_mutation_level(MUT_SAPROVOROUS) == 3)
xom_check_corpse_waste();
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index aceb6acc94..621abf33bd 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -282,7 +282,8 @@ static bool _prepare_butchery(bool can_butcher, bool barehand_butcher,
}
you.turn_is_over = true;
- // switched to a good butchering tool
+
+ // Switched to a good butchering tool.
return (true);
}
@@ -1947,6 +1948,9 @@ bool is_preferred_food(const item_def &food)
if (you.species == SP_VAMPIRE)
return (is_blood_potion(food));
+ if (food.base_type == OBJ_POTIONS && food.sub_type == POT_PORRIDGE)
+ return (!player_mutation_level(MUT_CARNIVOROUS));
+
if (food.base_type != OBJ_FOOD)
return (false);
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 0a9a885d8e..919db49454 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -2255,15 +2255,20 @@ bool is_bad_item(const item_def &item)
return (false);
}
case OBJ_POTIONS:
+ // Can't be bad if you can't use them.
+ if (you.species == SP_MUMMY)
+ return (false);
+
switch (item.sub_type)
{
case POT_CONFUSION:
case POT_SLOWING:
case POT_DEGENERATION:
case POT_DECAY:
+ case POT_PARALYSIS:
+ // Well, strictly poison is not that bad if you're poison resistant...
case POT_POISON:
case POT_STRONG_POISON:
- case POT_PARALYSIS:
return (true);
case POT_MUTATION:
return (you.is_undead
@@ -2334,7 +2339,7 @@ bool is_dangerous_item(const item_def &item)
}
}
-bool is_useless_item(const item_def &item)
+bool is_useless_item(const item_def &item, bool temp)
{
if (!item_type_known(item))
return (false);
@@ -2345,6 +2350,7 @@ bool is_useless_item(const item_def &item)
return (!can_wear_armour(item, false, true));
case OBJ_SCROLLS:
+ // A bad item is always useless.
if (is_bad_item(item))
return (true);
@@ -2362,31 +2368,39 @@ bool is_useless_item(const item_def &item)
case OBJ_POTIONS:
{
- // Certainly not useless if it can be used for attacking.
- if (is_bad_item(item))
+ switch (item.sub_type)
+ {
+ case POT_CONFUSION:
+ case POT_SLOWING:
+ case POT_DEGENERATION:
+ case POT_DECAY:
+ case POT_PARALYSIS:
+ case POT_POISON:
+ case POT_STRONG_POISON:
+ case POT_MUTATION:
+ // Certainly not useless if it can be used for attacking.
return (!player_knows_spell(SPELL_EVAPORATE));
-
+ }
if (you.species == SP_MUMMY)
return (true);
- if (you.species == SP_GHOUL
- || you.species == SP_VAMPIRE && you.hunger_state >= HS_SATIATED)
- {
- switch (item.sub_type)
- {
- case POT_BERSERK_RAGE:
- case POT_CURE_MUTATION:
- case POT_GAIN_STRENGTH:
- case POT_GAIN_INTELLIGENCE:
- case POT_GAIN_DEXTERITY:
- return (true);
- }
- }
+ // Do a second switch for the other potions.
switch (item.sub_type)
{
+ case POT_BERSERK_RAGE:
+ case POT_CURE_MUTATION:
+ case POT_GAIN_STRENGTH:
+ case POT_GAIN_INTELLIGENCE:
+ case POT_GAIN_DEXTERITY:
+ return (you.species == SP_GHOUL
+ || temp && you.species == SP_VAMPIRE
+ && you.hunger_state >= HS_SATIATED);
+
case POT_LEVITATION:
return (you.permanent_levitation() || you.permanent_flight());
+
case POT_PORRIDGE:
+ case POT_WATER:
case POT_BLOOD:
case POT_BLOOD_COAGULATED:
return (!can_ingest(item.base_type, item.sub_type, true, true,
@@ -2429,12 +2443,16 @@ bool is_useless_item(const item_def &item)
return (item.sub_type == RING_WIZARDRY
|| item.sub_type == AMU_RAGE);
}
+ return (false);
+ case OBJ_STAVES:
+ if (you.religion == GOD_TROG && !item_is_rod(item))
+ return (true);
default:
return (false);
}
}
-const std::string menu_colour_item_prefix(const item_def &item)
+const std::string menu_colour_item_prefix(const item_def &item, bool temp)
{
std::vector<std::string> prefixes;
@@ -2480,7 +2498,7 @@ const std::string menu_colour_item_prefix(const item_def &item)
prefixes.push_back("dangerous_item");
if (is_bad_item(item))
prefixes.push_back("bad_item");
- if (is_useless_item(item))
+ if (is_useless_item(item, temp))
prefixes.push_back("useless_item");
switch (item.base_type)
@@ -2517,6 +2535,13 @@ const std::string menu_colour_item_prefix(const item_def &item)
prefixes.push_back("rot-inducing");
break;
+ case OBJ_POTIONS:
+ if (is_good_god(you.religion) && is_blood_potion(item))
+ prefixes.push_back("evil_eating");
+ if (is_preferred_food(item))
+ prefixes.push_back("preferred");
+ break;
+
case OBJ_WEAPONS:
case OBJ_ARMOUR:
case OBJ_JEWELLERY:
diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h
index 18f4709d5a..2bafdf2e59 100644
--- a/crawl-ref/source/itemname.h
+++ b/crawl-ref/source/itemname.h
@@ -113,7 +113,7 @@ bool is_emergency_item( const item_def& item );
bool is_good_item(const item_def &item);
bool is_bad_item(const item_def &item);
bool is_dangerous_item( const item_def& item );
-bool is_useless_item(const item_def &item);
+bool is_useless_item(const item_def &item, bool temp = false);
std::string make_name( unsigned long seed, bool all_caps );
@@ -135,7 +135,8 @@ void set_ident_type( object_class_type basetype, int subtype,
/* ***********************************************************************
* called from: command - itemname - invent.h
* *********************************************************************** */
-const std::string menu_colour_item_prefix(const item_def &item);
+const std::string menu_colour_item_prefix(const item_def &item,
+ bool temp = true);
const std::string get_menu_colour_prefix_tags(item_def &item,
description_level_type desc);
const std::string get_message_colour_tags(item_def &item,
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index e03d56722e..e40aa46e59 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2190,7 +2190,8 @@ void autoinscribe()
static inline std::string _autopickup_item_name(const item_def &item)
{
return userdef_annotate_item(STASH_LUA_SEARCH_ANNOTATE, &item, true)
- + item.name(DESC_PLAIN);
+ + menu_colour_item_prefix(item, false)
+ + item.name(DESC_PLAIN);
}
static bool _is_denied_autopickup(const item_def &item, std::string &iname)
@@ -2230,12 +2231,8 @@ bool item_needs_autopickup(const item_def &item)
std::string itemname;
return ((Options.autopickups & (1L << item.base_type)
- && !is_useless_item(item) && !is_inedible(item)
- && !is_dangerous_item(item)
-#ifdef CLUA_BINDINGS
- && clua.callbooleanfn(true, "ch_autopickup", "u", &item)
-#endif
- || _is_forced_autopickup(item, itemname))
+ && !is_useless_item(item) && !is_inedible(item)
+ || _is_forced_autopickup(item, itemname))
&& (Options.pickup_dropped || !(item.flags & ISFLAG_DROPPED))
&& !_is_denied_autopickup(item, itemname));
}