summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source')
-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
6 files changed, 59 insertions, 156 deletions
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));
}