summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-09 16:17:48 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-09 16:17:48 +0000
commit7b7a36d0531a016ba81520bec2a4a4177e2ca8ed (patch)
tree2054ca1b5243de711a38a2751edc06f39d92b001 /crawl-ref/source
parent5443a68f96b0ba24b0de77573ad36a5633b39cd7 (diff)
downloadcrawl-ref-7b7a36d0531a016ba81520bec2a4a4177e2ca8ed.tar.gz
crawl-ref-7b7a36d0531a016ba81520bec2a4a4177e2ca8ed.zip
Yikes, so many files! And all I did was add more item evaluation
functions for menu colouring and pickup... Added: emergency_item, good_item, dangerous_item, bad_item, and useless_item, all taking into account player species and mutations, so e.g. =see invisible is useless for Naga, and !poison is always bad but only useless if you don't know Evaporate. Never autopickup useless, dangerous (e.g. ?immolation) or inedible items, and simplify the item colour/pickup options accordingly. I'll have to see if pickup.lua is still even needed after this. Removed the menu_colour_prefix_id option as I can't see any reason to turn it off. Oh, and fixed a bug where Kenku were unable to stop levitating if they gained level 15 while levitating. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5658 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/acr.cc4
-rw-r--r--crawl-ref/source/clua.cc17
-rw-r--r--crawl-ref/source/debug.cc4
-rw-r--r--crawl-ref/source/describe.cc3
-rw-r--r--crawl-ref/source/effects.cc30
-rw-r--r--crawl-ref/source/externs.h1
-rw-r--r--crawl-ref/source/food.cc23
-rw-r--r--crawl-ref/source/food.h1
-rw-r--r--crawl-ref/source/initfile.cc3
-rw-r--r--crawl-ref/source/item_use.cc6
-rw-r--r--crawl-ref/source/itemname.cc357
-rw-r--r--crawl-ref/source/itemname.h5
-rw-r--r--crawl-ref/source/items.cc17
-rw-r--r--crawl-ref/source/output.cc8
-rw-r--r--crawl-ref/source/player.cc102
-rw-r--r--crawl-ref/source/quiver.cc46
-rw-r--r--crawl-ref/source/religion.cc9
-rw-r--r--crawl-ref/source/religion.h1
-rw-r--r--crawl-ref/source/spells1.cc5
-rw-r--r--crawl-ref/source/travel.cc5
20 files changed, 482 insertions, 165 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 96ee704198..6c10e2c99d 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -2831,7 +2831,7 @@ static void _decrement_durations()
}
- if (!you.permanent_levitation())
+ if (!you.permanent_levitation() && !you.permanent_flight())
{
if ( _decrement_a_duration(DUR_LEVITATION,
"You float gracefully downwards.",
@@ -2841,7 +2841,7 @@ static void _decrement_durations()
burden_change();
// Landing kills controlled flight.
you.duration[DUR_CONTROLLED_FLIGHT] = 0;
- // re-enter the terrain:
+ // Re-enter the terrain.
move_player_to_grid( you.x_pos, you.y_pos, false, true, true );
}
}
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index 237fe16601..87b4dd3028 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -735,7 +735,7 @@ LUARET1(you_exp, number, you.experience_level)
LUARET1(you_exp_points, number, you.experience)
LUARET1(you_skill, number,
lua_isstring(ls, 1) ? you.skills[str_to_skill(lua_tostring(ls, 1))]
- : 0)
+ : 0)
LUARET1(you_res_poison, number, player_res_poison(false))
LUARET1(you_res_fire, number, player_res_fire(false))
LUARET1(you_res_cold, number, player_res_cold(false))
@@ -752,6 +752,7 @@ LUARET1(you_transform, string, transform_name())
LUARET1(you_where, string, level_id::current().describe().c_str())
LUARET1(you_branch, string, level_id::current().describe(false, false).c_str())
LUARET1(you_subdepth, number, level_id::current().depth)
+// Increase by 1 because check happens on old level.
LUARET1(you_absdepth, number, you.your_level + 1)
LUAWRAP(you_stop_activity, interrupt_activity(AI_FORCE_INTERRUPT))
LUARET1(you_turns, number, you.num_turns)
@@ -761,7 +762,6 @@ LUARET1(you_see_grid_no_trans, boolean,
see_grid_no_trans(luaL_checkint(ls, 1), luaL_checkint(ls, 2)))
LUARET1(you_can_smell, boolean, player_can_smell())
-// increase by 1 because check happens on old level
void lua_push_floor_items(lua_State *ls);
static int you_floor_items(lua_State *ls)
@@ -1181,7 +1181,7 @@ static const char *ring_types[] =
"protection from magic",
"fire",
"ice",
- "teleport control",
+ "teleport control"
};
static const char *amulet_types[] =
@@ -1250,6 +1250,11 @@ static int l_item_subtype(lua_State *ls)
return (2);
}
+// Used to divide a given potion into one of four categories:
+// 0 : unknown potion
+// 1 : always beneficial
+// 2 : always bad
+// 3 : depends on species etc.
static int l_item_potion_type(lua_State *ls)
{
LUA_ITEM(item, 1);
@@ -1291,7 +1296,7 @@ static int l_item_potion_type(lua_State *ls)
val = 2;
break;
- // need more refined handling:
+ // Need more refined handling:
// for eating habits
case POT_BLOOD:
case POT_BLOOD_COAGULATED:
@@ -1316,7 +1321,7 @@ static int l_item_cursed(lua_State *ls)
{
LUA_ITEM(item, 1);
bool cursed = item && item_ident(*item, ISFLAG_KNOW_CURSE)
- && item_cursed(*item);
+ && item_cursed(*item);
lua_pushboolean(ls, cursed);
return (1);
}
@@ -2192,8 +2197,6 @@ static option_handler handlers[] =
option_hboolean },
{ "menu_colour_prefix_class", &Options.menu_colour_prefix_class,
option_hboolean },
- { "menu_colour_prefix_id", &Options.menu_colour_prefix_id,
- option_hboolean },
};
static const option_handler *get_handler(const char *optname)
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 7c39b68fba..b5af1de786 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -1220,7 +1220,7 @@ void create_spec_object()
ptr = strstr( strlwr(obj_name), specs );
if (ptr != NULL)
{
- // earliest match is the winner
+ // Earliest match is the winner.
if (ptr - obj_name < best_index)
{
mpr( obj_name );
@@ -1238,7 +1238,7 @@ void create_spec_object()
if (type_wanted == -1)
{
- // ds -- if specs is a valid int, try using that.
+ // ds -- If specs is a valid int, try using that.
// Since zero is atoi's copout, the wizard
// must enter (subtype + 1).
if (!(type_wanted = atoi(specs)))
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 3b6d4969d8..70afc49275 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -1798,8 +1798,7 @@ std::string get_item_description( const item_def &item, bool verbose,
}
}
- if (is_good_god(you.religion) && is_evil_item(item)
- && item_type_known(item))
+ if (god_dislikes_item_handling(item))
{
description << "$$" << god_name(you.religion) << " disapproves of the "
<< "use of such an item.";
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index d394a173bd..f391c4520c 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -1693,28 +1693,24 @@ bool acquirement(object_class_type class_wanted, int agent,
case WPN_GREAT_SWORD:
case WPN_TRIPLE_SWORD:
- thing.sub_type =
- (coinflip() ? WPN_FALCHION : WPN_LONG_SWORD);
+ thing.sub_type = (coinflip() ? WPN_FALCHION : WPN_LONG_SWORD);
break;
case WPN_GREAT_MACE:
case WPN_DIRE_FLAIL:
- thing.sub_type =
- (coinflip() ? WPN_MACE : WPN_FLAIL);
+ thing.sub_type = (coinflip() ? WPN_MACE : WPN_FLAIL);
break;
case WPN_BATTLEAXE:
case WPN_EXECUTIONERS_AXE:
- thing.sub_type =
- (coinflip() ? WPN_HAND_AXE : WPN_WAR_AXE);
+ thing.sub_type = (coinflip() ? WPN_HAND_AXE : WPN_WAR_AXE);
break;
case WPN_HALBERD:
case WPN_GLAIVE:
case WPN_SCYTHE:
case WPN_BARDICHE:
- thing.sub_type =
- (coinflip() ? WPN_SPEAR : WPN_TRIDENT);
+ thing.sub_type = (coinflip() ? WPN_SPEAR : WPN_TRIDENT);
break;
}
break;
@@ -2537,13 +2533,13 @@ void handle_time( long time_delta )
mpr("Your body shudders with the violent release "
"of wild energies!", MSGCH_WARN);
- // for particularly violent releases, make a little boom
+ // For particularly violent releases, make a little boom.
if (you.magic_contamination >= 10 && coinflip())
{
struct bolt boom;
- boom.type = dchar_glyph(DCHAR_FIRED_BURST);
- boom.colour = BLACK;
- boom.flavour = BEAM_RANDOM;
+ boom.type = dchar_glyph(DCHAR_FIRED_BURST);
+ boom.colour = BLACK;
+ boom.flavour = BEAM_RANDOM;
boom.target_x = you.x_pos;
boom.target_y = you.y_pos;
// Undead enjoy extra contamination explosion damage because
@@ -2554,11 +2550,11 @@ void handle_time( long time_delta )
you.magic_contamination
* (you.is_undead? 4 : 2)
/ 4 );
- boom.thrower = KILL_MISC;
- boom.aux_source = "a magical explosion";
- boom.beam_source = NON_MONSTER;
- boom.is_beam = false;
- boom.is_tracer = false;
+ boom.thrower = KILL_MISC;
+ boom.aux_source = "a magical explosion";
+ boom.beam_source = NON_MONSTER;
+ boom.is_beam = false;
+ boom.is_tracer = false;
boom.is_explosion = true;
boom.name = "magical storm";
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 62cdd301cf..0400009eb0 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1769,7 +1769,6 @@ public:
std::vector<message_colour_mapping> message_colour_mappings;
bool menu_colour_prefix_class; // Prefix item class to string
- bool menu_colour_prefix_id; // Prefix id-status to string
std::vector<menu_sort_condition> sort_menus;
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index b1daa6c5e7..aceb6acc94 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -1914,6 +1914,29 @@ static int _player_likes_food_type(int food_type)
return 0;
}
+// Returns true if an item of basetype FOOD or CORPSES cannot currently
+// be eaten (respecting species and mutations set).
+bool is_inedible(const item_def &item)
+{
+ if (food_is_rotten(item)
+ && !player_mutation_level(MUT_SAPROVOROUS))
+ {
+ return (true);
+ }
+
+ if (item.base_type == OBJ_FOOD
+ && !can_ingest(item.base_type, item.sub_type, true, true, false))
+ {
+ return (true);
+ }
+ if (item.base_type == OBJ_CORPSES
+ && (item.sub_type == CORPSE_SKELETON
+ || you.species == SP_VAMPIRE && !mons_has_blood(item.plus)))
+ {
+ return (true);
+ }
+ return (false);
+}
// As we want to avoid autocolouring the entire food selection, this should
// be restricted to the absolute highlights, even though other stuff may
// still be edible or even delicious.
diff --git a/crawl-ref/source/food.h b/crawl-ref/source/food.h
index 32410065ae..b14ff38b85 100644
--- a/crawl-ref/source/food.h
+++ b/crawl-ref/source/food.h
@@ -87,6 +87,7 @@ bool is_poisonous(const item_def &food);
bool is_mutagenic(const item_def &food);
bool is_contaminated(const item_def &food);
bool causes_rot(const item_def &food);
+bool is_inedible(const item_def &item);
bool is_preferred_food(const item_def &food);
bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index cfcc7cd326..969962c757 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -880,7 +880,6 @@ void game_options::reset_options()
sound_mappings.clear();
menu_colour_mappings.clear();
menu_colour_prefix_class = false;
- menu_colour_prefix_id = false;
message_colour_mappings.clear();
drop_filter.clear();
map_file_name.clear();
@@ -2637,8 +2636,6 @@ void game_options::read_option_line(const std::string &str, bool runscript)
}
else BOOL_OPTION(menu_colour_prefix_class);
else BOOL_OPTION_NAMED("menu_color_prefix_class", menu_colour_prefix_class);
- else BOOL_OPTION(menu_colour_prefix_id);
- else BOOL_OPTION_NAMED("menu_color_prefix_id", menu_colour_prefix_id);
else if (key == "message_colour" || key == "message_color")
{
add_message_colour_mappings(field);
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 167049ed32..a704d4c989 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -870,6 +870,7 @@ bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary)
{
if (verbose)
mpr("You can't wear that!");
+
return (false);
}
@@ -932,7 +933,7 @@ bool can_wear_armour(const item_def &item, bool verbose, bool ignore_temporary)
}
else if (slot == EQ_HELMET)
{
- // soft helmets (caps and wizard hats) always fit
+ // Soft helmets (caps and wizard hats) always fit.
if (!is_hard_helmet( item ))
return (true);
@@ -1535,7 +1536,6 @@ static bool _fire_warn_if_impossible()
int get_ammo_to_shoot(int item, dist &target, bool teleport)
{
- mpr("in get_ammo_to_shoot()");
if (_fire_warn_if_impossible())
{
flush_input_buffer( FLUSH_ON_FAILURE );
@@ -1559,10 +1559,8 @@ int get_ammo_to_shoot(int item, dist &target, bool teleport)
// If item passed, it will be put into the quiver.
void fire_thing(int item)
{
- mpr("in fire_thing()");
dist target;
item = get_ammo_to_shoot(item, target);
- mpr("back in fire_thing()");
if (item == -1)
return;
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 47a39c3f9a..0a9a885d8e 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -24,6 +24,7 @@
#ifdef DOS
#include <conio.h>
#endif
+#include "clua.h"
#include "externs.h"
@@ -32,6 +33,7 @@
#include "initfile.h"
#include "invent.h"
#include "it_use2.h"
+#include "item_use.h"
#include "itemprop.h"
#include "macro.h"
#include "makeitem.h"
@@ -2151,54 +2153,335 @@ bool is_interesting_item( const item_def& item )
return (false);
}
-const std::string menu_colour_item_prefix(const item_def &item)
+// Returns true if an item is a potential life saver in an emergency situation.
+bool is_emergency_item(const item_def &item)
{
- std::vector<std::string> prefixes;
+ if (!item_type_known(item))
+ return (false);
- if (Options.menu_colour_prefix_id)
+ switch (item.base_type)
{
- if (item_ident(item, ISFLAG_KNOW_TYPE)
- || item.base_type == OBJ_FOOD
- || item.base_type == OBJ_CORPSES)
+ case OBJ_WANDS:
+ switch (item.sub_type)
{
- prefixes.push_back("identified");
+ case WAND_HASTING:
+ case WAND_HEALING:
+ case WAND_TELEPORTATION:
+ return (true);
+ default:
+ return (false);
}
- else
+ case OBJ_SCROLLS:
+ switch (item.sub_type)
{
- if (get_ident_type(item.base_type,
- item.sub_type) == ID_KNOWN_TYPE)
+ case SCR_TELEPORTATION:
+ case SCR_BLINKING:
+ case SCR_FEAR:
+ return (true);
+ default:
+ return (false);
+ }
+ case OBJ_POTIONS:
+ if (you.species == SP_MUMMY)
+ return (false);
+
+ switch (item.sub_type)
+ {
+ case POT_SPEED:
+ case POT_HEALING:
+ case POT_HEAL_WOUNDS:
+ case POT_RESISTANCE:
+ return (true);
+ default:
+ return (false);
+ }
+ default:
+ return (false);
+ }
+}
+
+// Returns true if an item can be considered particularly good.
+bool is_good_item(const item_def &item)
+{
+ if (!item_type_known(item))
+ return (false);
+
+ if (is_emergency_item(item))
+ return (true);
+
+ if (is_useless_item(item) || is_dangerous_item(item))
+ return (false);
+
+ switch (item.base_type)
+ {
+ case OBJ_SCROLLS:
+ return (item.sub_type == SCR_ACQUIREMENT);
+ case OBJ_POTIONS:
+ switch (item.sub_type)
+ {
+ case POT_CURE_MUTATION:
+ case POT_GAIN_STRENGTH:
+ case POT_GAIN_INTELLIGENCE:
+ case POT_GAIN_DEXTERITY:
+ case POT_EXPERIENCE:
+ case POT_MAGIC:
+ case POT_BERSERK_RAGE:
+ case POT_MIGHT:
+ case POT_RESTORE_ABILITIES:
+ return (true);
+ default:
+ return (false);
+ }
+ default:
+ return (false);
+ }
+}
+
+// Returns true if using an item only has harmful effects.
+bool is_bad_item(const item_def &item)
+{
+ if (!item_type_known(item))
+ return (false);
+
+ switch (item.base_type)
+ {
+ case OBJ_SCROLLS:
+ switch (item.sub_type)
+ {
+ case SCR_CURSE_ARMOUR:
+ case SCR_CURSE_WEAPON:
+ return (true);
+ default:
+ return (false);
+ }
+ case OBJ_POTIONS:
+ switch (item.sub_type)
+ {
+ case POT_CONFUSION:
+ case POT_SLOWING:
+ case POT_DEGENERATION:
+ case POT_DECAY:
+ case POT_POISON:
+ case POT_STRONG_POISON:
+ case POT_PARALYSIS:
+ return (true);
+ case POT_MUTATION:
+ return (you.is_undead
+ && (you.species != SP_VAMPIRE
+ || you.hunger_state < HS_SATIATED));
+ default:
+ return (false);
+ }
+ case OBJ_JEWELLERY:
+ switch (item.sub_type)
+ {
+ case AMU_INACCURACY:
+ return (true);
+ case RING_HUNGER:
+ // Even Vampires can use this ring.
+ return (!you.is_undead);
+ default:
+ return (false);
+ }
+ case OBJ_MISCELLANY:
+ return (item.sub_type == MISC_CRYSTAL_BALL_OF_FIXATION);
+
+ default:
+ return (false);
+ }
+}
+
+// Returns true if using an item is risky but may occasionally be worthwhile.
+bool is_dangerous_item(const item_def &item)
+{
+ if (!item_type_known(item))
+ {
+ // Use-IDing these is extremely dangerous!
+ if (item.base_type == OBJ_MISCELLANY
+ && (item.sub_type == MISC_CRYSTAL_BALL_OF_SEEING
+ || item.sub_type == MISC_CRYSTAL_BALL_OF_ENERGY
+ || item.sub_type == MISC_CRYSTAL_BALL_OF_FIXATION))
+ {
+ return (true);
+ }
+ return (false);
+ }
+
+ switch (item.base_type)
+ {
+ case OBJ_SCROLLS:
+ switch (item.sub_type)
+ {
+ case SCR_IMMOLATION:
+ case SCR_TORMENT:
+ return (true);
+ default:
+ return (false);
+ }
+ case OBJ_POTIONS:
+ switch (item.sub_type)
+ {
+ case POT_MUTATION:
+ // Only living characters can mutate.
+ return (!you.is_undead
+ || you.species == SP_VAMPIRE
+ && you.hunger_state >= HS_SATIATED);
+ default:
+ return (false);
+ }
+ default:
+ return (false);
+ }
+}
+
+bool is_useless_item(const item_def &item)
+{
+ if (!item_type_known(item))
+ return (false);
+
+ switch (item.base_type)
+ {
+ case OBJ_ARMOUR:
+ return (!can_wear_armour(item, false, true));
+
+ case OBJ_SCROLLS:
+ if (is_bad_item(item))
+ return (true);
+
+ switch (item.sub_type)
+ {
+ case SCR_PAPER:
+ case SCR_RANDOM_USELESSNESS:
+ case SCR_NOISE:
+ return (true);
+ default:
+ return (false);
+ }
+ case OBJ_WANDS:
+ return (item.plus2 == ZAPCOUNT_EMPTY);
+
+ case OBJ_POTIONS:
+ {
+ // Certainly not useless if it can be used for attacking.
+ if (is_bad_item(item))
+ 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)
{
- // Wands are only fully identified if we know the
- // number of charges.
- if (item.base_type == OBJ_WANDS)
- prefixes.push_back("known");
+ case POT_BERSERK_RAGE:
+ case POT_CURE_MUTATION:
+ case POT_GAIN_STRENGTH:
+ case POT_GAIN_INTELLIGENCE:
+ case POT_GAIN_DEXTERITY:
+ return (true);
+ }
+ }
+ switch (item.sub_type)
+ {
+ case POT_LEVITATION:
+ return (you.permanent_levitation() || you.permanent_flight());
+ case POT_PORRIDGE:
+ case POT_BLOOD:
+ case POT_BLOOD_COAGULATED:
+ return (!can_ingest(item.base_type, item.sub_type, true, true,
+ false));
+ }
- // Rings are fully identified simply by knowing their
- // type, unless the ring has plusses, like a ring of
- // dexterity.
- else if (item.base_type == OBJ_JEWELLERY
- && !jewellery_is_amulet(item))
- {
- if (item.plus == 0 && item.plus2 == 0)
- prefixes.push_back("identified");
- else
- prefixes.push_back("known");
- }
- // All other types of magical items are fully identified
- // simply by knowing the type
- else
+ return (false);
+ }
+ case OBJ_JEWELLERY:
+ if (is_bad_item(item))
+ return (true);
+
+ if (you.species == SP_MUMMY || you.species == SP_GHOUL)
+ {
+ switch (item.sub_type)
+ {
+ case AMU_RAGE:
+ case RING_REGENERATION:
+ case RING_SUSTENANCE:
+ case RING_HUNGER:
+ case RING_LIFE_PROTECTION:
+ return (true);
+ }
+ }
+
+ if (item.sub_type == RING_SEE_INVISIBLE)
+ return (player_mutation_level(MUT_ACUTE_VISION));
+
+ if (item.sub_type == RING_POISON_RESISTANCE)
+ {
+ return (you.species != SP_VAMPIRE
+ && player_mutation_level(MUT_POISON_RESISTANCE));
+ }
+
+ if (item.sub_type == AMU_CONTROLLED_FLIGHT)
+ return (player_genus(GENPC_DRACONIAN) || you.permanent_flight());
+
+ if (you.religion == GOD_TROG)
+ {
+ return (item.sub_type == RING_WIZARDRY
+ || item.sub_type == AMU_RAGE);
+ }
+ default:
+ return (false);
+ }
+}
+
+const std::string menu_colour_item_prefix(const item_def &item)
+{
+ std::vector<std::string> prefixes;
+
+ if (item_ident(item, ISFLAG_KNOW_TYPE))
+ prefixes.push_back("identified");
+ else
+ {
+ if (get_ident_type(item.base_type, item.sub_type) == ID_KNOWN_TYPE)
+ {
+ // Wands are only fully identified if we know the
+ // number of charges.
+ if (item.base_type == OBJ_WANDS)
+ prefixes.push_back("known");
+
+ // Rings are fully identified simply by knowing their
+ // type, unless the ring has plusses, like a ring of
+ // dexterity.
+ else if (item.base_type == OBJ_JEWELLERY
+ && !jewellery_is_amulet(item))
+ {
+ if (item.plus == 0 && item.plus2 == 0)
prefixes.push_back("identified");
+ else
+ prefixes.push_back("known");
}
+ // All other types of magical items are fully identified
+ // simply by knowing the type
else
- prefixes.push_back("unidentified");
+ prefixes.push_back("identified");
}
+ else
+ prefixes.push_back("unidentified");
}
- if (is_good_god(you.religion) && is_evil_item(item)
- && item_type_known(item))
- {
+ if (god_dislikes_item_handling(item))
prefixes.push_back("evil_item");
- }
+
+ if (is_emergency_item(item))
+ prefixes.push_back("emergency_item");
+ if (is_good_item(item))
+ prefixes.push_back("good_item");
+ if (is_dangerous_item(item))
+ prefixes.push_back("dangerous_item");
+ if (is_bad_item(item))
+ prefixes.push_back("bad_item");
+ if (is_useless_item(item))
+ prefixes.push_back("useless_item");
switch (item.base_type)
{
@@ -2219,14 +2502,8 @@ const std::string menu_colour_item_prefix(const item_def &item)
prefixes.push_back("evil_eating");
}
- if (item.base_type != OBJ_CORPSES
- && !can_ingest(item.base_type, item.sub_type, true, true, false)
- || you.species == SP_VAMPIRE && !mons_has_blood(item.plus)
- || food_is_rotten(item)
- && !player_mutation_level(MUT_SAPROVOROUS))
- {
+ if (is_inedible(item))
prefixes.push_back("inedible");
- }
else if (is_preferred_food(item))
prefixes.push_back("preferred");
diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h
index 48ae1ad239..18f4709d5a 100644
--- a/crawl-ref/source/itemname.h
+++ b/crawl-ref/source/itemname.h
@@ -109,6 +109,11 @@ bool item_type_known( const object_class_type base_type, const int sub_type );
bool item_type_tried( const item_def &item );
bool is_interesting_item( const item_def& item );
+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);
std::string make_name( unsigned long seed, bool all_caps );
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 157571a963..e03d56722e 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1684,7 +1684,7 @@ bool move_item_to_grid( int *const obj, int x, int y )
// Look for similar item to stack:
for (int i = igrd[x][y]; i != NON_ITEM; i = mitm[i].link)
{
- // check if item already linked here -- don't want to unlink it
+ // Check if item already linked here -- don't want to unlink it.
if (*obj == i)
return (false);
@@ -1939,7 +1939,7 @@ bool drop_item( int item_dropped, int quant_drop, bool try_offer )
if (is_blood_potion(you.inv[item_dropped])
&& you.inv[item_dropped].quantity != quant_drop)
{
- // oldest potions have been dropped
+ // Oldest potions have been dropped.
for (int i = 0; i < quant_drop; i++)
remove_oldest_blood_potion(you.inv[item_dropped]);
}
@@ -2202,7 +2202,7 @@ static bool _is_denied_autopickup(const item_def &item, std::string &iname)
if (Options.never_pickup[i].matches(iname))
return (true);
- return false;
+ return (false);
}
static bool _is_forced_autopickup(const item_def &item, std::string &iname)
@@ -2213,7 +2213,8 @@ static bool _is_forced_autopickup(const item_def &item, std::string &iname)
for (unsigned i = 0, size = Options.always_pickup.size(); i < size; ++i)
if (Options.always_pickup[i].matches(iname))
return (true);
- return false;
+
+ return (false);
}
bool item_needs_autopickup(const item_def &item)
@@ -2228,11 +2229,13 @@ bool item_needs_autopickup(const item_def &item)
return (true);
std::string itemname;
- return (((Options.autopickups & (1L << item.base_type))
+ 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)
+ && clua.callbooleanfn(true, "ch_autopickup", "u", &item)
#endif
- || _is_forced_autopickup(item, itemname))
+ || _is_forced_autopickup(item, itemname))
&& (Options.pickup_dropped || !(item.flags & ISFLAG_DROPPED))
&& !_is_denied_autopickup(item, itemname));
}
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index e5a0f367f0..14dc57e16e 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -650,12 +650,14 @@ static void _get_status_lights(std::vector<status_light>& out)
if (wearing_amulet( AMU_CONTROLLED_FLIGHT ))
{
int color = _dur_colour( you.light_flight()? BLUE : MAGENTA,
- (you.duration[DUR_LEVITATION] <= 10 && !perm) );
+ (you.duration[DUR_LEVITATION] <= 10
+ && !perm) );
out.push_back(status_light(color, "Fly"));
}
else
{
- int color = _dur_colour(BLUE, (you.duration[DUR_LEVITATION] <= 10 && !perm));
+ int color = _dur_colour(BLUE, (you.duration[DUR_LEVITATION] <= 10
+ && !perm));
out.push_back(status_light(color, "Lev"));
}
}
@@ -1457,7 +1459,7 @@ void update_monster_pane()
for (unsigned int i=1; i < mons.size(); i++)
if (! monster_pane_info::less_than(mons[i-1], mons[i]))
-- lines_needed;
- }
+ }
#if BOTTOM_JUSTIFY_MONSTER_LIST
const int skip_lines = std::max<int>(0, crawl_view.mlistsz.y-lines_needed);
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 96ebb92304..07cdb20059 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -580,51 +580,51 @@ bool is_player_same_species(const int mon, bool transform)
}
}
-// checks whether the player's current species can
-// use (usually wear) a given piece of equipment
+// Checks whether the player's current species can
+// use (usually wear) a given piece of equipment.
// Note that EQ_BODY_ARMOUR and EQ_HELMET only check
-// the ill-fitting variant (i.e. not caps and robes)
+// the ill-fitting variant (i.e. not caps and robes).
// If special_armour is set to true, special cases
// such as bardings, light armour and caps are
// considered. Otherwise these simply return false.
// -------------------------------------------------
bool you_can_wear(int eq, bool special_armour)
{
- // these can be used by all
- if (eq == EQ_LEFT_RING || eq == EQ_RIGHT_RING || eq == EQ_AMULET
- || eq == EQ_WEAPON || eq == EQ_CLOAK)
- {
- return true;
- }
-
- // anyone can wear caps/hats and robes and at least one of buckler/shield
- if (special_armour
- && (eq == EQ_HELMET || eq == EQ_BODY_ARMOUR || eq == EQ_SHIELD))
- {
- return true;
- }
-
- if (eq == EQ_BOOTS && (you.species == SP_NAGA || you.species == SP_CENTAUR))
- return (special_armour);
-
- // of the remaining items, these races can't wear anything
- if (you.species == SP_TROLL || you.species == SP_SPRIGGAN
- || player_genus(GENPC_OGRE) || player_genus(GENPC_DRACONIAN))
- {
- return false;
- }
+ // These can be used by all.
+ if (eq == EQ_LEFT_RING || eq == EQ_RIGHT_RING || eq == EQ_AMULET
+ || eq == EQ_WEAPON || eq == EQ_CLOAK)
+ {
+ return (true);
+ }
- if (you.species == SP_KENKU && (eq == EQ_HELMET || eq == EQ_BOOTS))
- return false;
+ // Anyone can wear caps/hats and robes and at least one of buckler/shield.
+ if (special_armour
+ && (eq == EQ_HELMET || eq == EQ_BODY_ARMOUR || eq == EQ_SHIELD))
+ {
+ return (true);
+ }
- if (player_mutation_level(MUT_HORNS) && eq == EQ_HELMET)
- return (special_armour);
+ if (eq == EQ_BOOTS && (you.species == SP_NAGA || you.species == SP_CENTAUR))
+ return (special_armour);
- if (you.species == SP_GHOUL && eq == EQ_GLOVES)
- return false;
+ // Of the remaining items, these races can't wear anything.
+ if (you.species == SP_TROLL || you.species == SP_SPRIGGAN
+ || player_genus(GENPC_OGRE) || player_genus(GENPC_DRACONIAN))
+ {
+ return (false);
+ }
- // else no problems
- return true;
+ if (you.species == SP_KENKU && (eq == EQ_HELMET || eq == EQ_BOOTS))
+ return (false);
+
+ if (player_mutation_level(MUT_HORNS) && eq == EQ_HELMET)
+ return (special_armour);
+
+ if (you.species == SP_GHOUL && eq == EQ_GLOVES)
+ return (false);
+
+ // Else, no problems.
+ return (true);
}
bool player_has_feet()
@@ -826,7 +826,7 @@ int player_equip( equipment_type slot, int sub_type, bool calc_unid )
break;
case EQ_ALL_ARMOUR:
- // doesn't make much sense here... be specific. -- bwr
+ // Doesn't make much sense here... be specific. -- bwr
break;
default:
@@ -1003,7 +1003,7 @@ int player_hunger_rate(void)
if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT)
return 1;
- // jmf: hunger isn't fair while you can't eat
+ // jmf: Hunger isn't fair while you can't eat.
// Actually, it is since you can detransform any time you like -- bwr
if (you.attribute[ATTR_TRANSFORMATION] == TRAN_AIR)
return 0;
@@ -1167,22 +1167,22 @@ int player_res_magic(void)
break;
}
- /* randarts */
+ // randarts
rm += scan_randarts(RAP_MAGIC);
- /* armour */
+ // armour
rm += 30 * player_equip_ego_type( EQ_ALL_ARMOUR, SPARM_MAGIC_RESISTANCE );
- /* rings of magic resistance */
+ // rings of magic resistance
rm += 40 * player_equip( EQ_RINGS, RING_PROTECTION_FROM_MAGIC );
- /* Enchantment skill */
+ // Enchantment skill
rm += 2 * you.skills[SK_ENCHANTMENTS];
- /* Mutations */
+ // Mutations
rm += 30 * player_mutation_level(MUT_MAGIC_RESISTANCE);
- /* transformations */
+ // transformations
if (you.attribute[ATTR_TRANSFORMATION] == TRAN_LICH)
rm += 50;
@@ -1289,14 +1289,14 @@ int player_res_cold(bool calc_unid)
rc++;
}
- /* rings of fire resistance/fire */
+ // rings of fire resistance/fire
rc += player_equip( EQ_RINGS, RING_PROTECTION_FROM_COLD, calc_unid );
rc += player_equip( EQ_RINGS, RING_ICE, calc_unid );
- /* rings of ice */
+ // rings of ice
rc -= player_equip( EQ_RINGS, RING_FIRE, calc_unid );
- /* Staves */
+ // Staves
rc += player_equip( EQ_STAFF, STAFF_COLD, calc_unid );
// body armour:
@@ -2760,8 +2760,8 @@ int burden_change(void)
if (is_flying_light != was_flying_light)
{
- mpr(is_flying_light? "You feel quicker in the air."
- : "You feel heavier in the air.");
+ mpr(is_flying_light ? "You feel quicker in the air."
+ : "You feel heavier in the air.");
}
return you.burden;
@@ -6257,15 +6257,13 @@ bool player::permanent_levitation() const
// all times. This is so that you can evoke stop-levitation
// in order to actually cancel levitation (by setting
// DUR_LEVITATION to 1.) Note that antimagic() won't do this.
- return (airborne()
- && (permanent_flight()
- || player_equip_ego_type( EQ_BOOTS, SPARM_LEVITATION )
- && you.duration[DUR_LEVITATION] > 1));
+ return (airborne() && player_equip_ego_type(EQ_BOOTS, SPARM_LEVITATION)
+ && you.duration[DUR_LEVITATION] > 1);
}
bool player::permanent_flight() const
{
- return (airborne()
+ return (airborne() && wearing_amulet( AMU_CONTROLLED_FLIGHT )
&& you.species == SP_KENKU && you.experience_level >= 15);
}
diff --git a/crawl-ref/source/quiver.cc b/crawl-ref/source/quiver.cc
index 5e4744d7c3..8f9bf95d1b 100644
--- a/crawl-ref/source/quiver.cc
+++ b/crawl-ref/source/quiver.cc
@@ -20,9 +20,6 @@
#include <algorithm>
-// checks base_type for OBJ_UNASSIGNED, and quantity
-// bool is_valid_item( const item_def &item )
-
static int _get_pack_slot(const item_def&);
static ammo_t _get_weapon_ammo_type(const item_def*);
static bool _item_matches(const item_def &item, fire_type types, const item_def* launcher);
@@ -55,14 +52,18 @@ void player_quiver::get_desired_item(const item_def** item_out, int* slot_out) c
if (slot == -1)
{
// Not in inv, but caller can at least get the type of the item.
- if (item_out) *item_out = &m_last_used_of_type[m_last_used_type];
+ if (item_out)
+ *item_out = &m_last_used_of_type[m_last_used_type];
}
else
{
// Return the item in inv, since it will have an accurate count
- if (item_out) *item_out = &you.inv[slot];
+ if (item_out)
+ *item_out = &you.inv[slot];
}
- if (slot_out) *slot_out = slot;
+
+ if (slot_out)
+ *slot_out = slot;
}
// Return inv slot of item that should be fired by default.
@@ -76,7 +77,7 @@ int player_quiver::get_fire_item(std::string* no_item_reason) const
get_desired_item(&desired_item, &slot);
- // If not in inv, try the head of the fire order
+ // If not in inv, try the head of the fire order.
if (slot == -1)
{
std::vector<int> order;
@@ -85,7 +86,7 @@ int player_quiver::get_fire_item(std::string* no_item_reason) const
slot = order[0];
}
- // If we can't find anything, tell caller why
+ // If we can't find anything, tell caller why.
if (slot == -1)
{
std::vector<int> full_fire_order;
@@ -119,7 +120,7 @@ int player_quiver::get_fire_item(std::string* no_item_reason) const
return slot;
}
-// Notification that ltem was fired with 'f'
+// Notification that item was fired with 'f'.
void player_quiver::on_item_fired(const item_def& item)
{
// If item matches the launcher, put it in that launcher's last-used item.
@@ -144,10 +145,10 @@ void player_quiver::on_item_fired(const item_def& item)
you.redraw_quiver = true;
}
-// Notification that ltem was fired with 'f' 'i'
+// Notification that item was fired with 'f' 'i'
void player_quiver::on_item_fired_fi(const item_def& item)
{
- // currently no difference
+ // Currently no difference.
on_item_fired(item);
}
@@ -246,7 +247,7 @@ void player_quiver::_get_fire_order(
{
const int inv_start = (ignore_inscription_etc ? 0 : Options.fire_items_start);
- // If in a net, cannot throw anything, and can only launch from blowgun
+ // If in a net, cannot throw anything, and can only launch from blowgun.
if (you.attribute[ATTR_HELD])
{
if (launcher && launcher->sub_type == WPN_BLOWGUN)
@@ -264,7 +265,7 @@ void player_quiver::_get_fire_order(
if (you.equip[EQ_WEAPON] == i_inv)
continue;
- // =f prevents item from being in fire order
+ // =f prevents item from being in fire order.
if (!ignore_inscription_etc &&
strstr(item.inscription.c_str(), "=f"))
{
@@ -358,9 +359,10 @@ preserve_quiver_slots::~preserve_quiver_slots()
// Helpers
// ----------------------------------------------------------------------
-// Helper for _get_fire_order
-// types may actually contain more than one fire_type
-static bool _item_matches(const item_def &item, fire_type types, const item_def* launcher)
+// Helper for _get_fire_order.
+// Types may actually contain more than one fire_type.
+static bool _item_matches(const item_def &item, fire_type types,
+ const item_def* launcher)
{
ASSERT(is_valid_item(item));
@@ -390,9 +392,9 @@ static bool _item_matches(const item_def &item, fire_type types, const item_def*
else if (item.base_type == OBJ_WEAPONS
&& is_throwable(item, you.body_size()))
{
- if ( (types & FIRE_RETURNING)
- && item.special == SPWPN_RETURNING
- && item_ident(item, ISFLAG_KNOW_TYPE))
+ if ((types & FIRE_RETURNING)
+ && item.special == SPWPN_RETURNING
+ && item_ident(item, ISFLAG_KNOW_TYPE))
{
return (true);
}
@@ -408,7 +410,7 @@ static bool _item_matches(const item_def &item, fire_type types, const item_def*
return (false);
}
-// Return inv slot that contains an item that looks like item,
+// Returns inv slot that contains an item that looks like item,
// or -1 if not in inv.
static int _get_pack_slot(const item_def& item)
{
@@ -426,7 +428,7 @@ static int _get_pack_slot(const item_def& item)
}
-// Return the type of ammo used by the player's equipped weapon,
+// Returns the type of ammo used by the player's equipped weapon,
// or AMMO_THROW if it's not a launcher.
static ammo_t _get_weapon_ammo_type(const item_def* weapon)
{
@@ -455,6 +457,6 @@ static ammo_t _get_weapon_ammo_type(const item_def* weapon)
static bool _items_similar(const item_def& a, const item_def& b)
{
- // this is a reasonable implementation for now
+ // This is a reasonable implementation for now.
return items_stack(a, b, true);
}
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index c3b30a0daa..59b7149495 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -2712,6 +2712,15 @@ bool is_evil_item(const item_def& item)
return retval;
}
+bool god_dislikes_item_handling(const item_def &item)
+{
+ return (item_type_known(item)
+ && (is_good_god(you.religion) && is_evil_item(item)
+ || you.religion == GOD_TROG && item.base_type == OBJ_BOOKS
+ && item.sub_type != BOOK_MANUAL
+ && item.sub_type != BOOK_DESTRUCTION));
+}
+
// Is the destroyed weapon valuable enough to gain piety by doing so?
// Evil weapons are handled specially.
static bool _destroyed_valuable_weapon(int value, int type)
diff --git a/crawl-ref/source/religion.h b/crawl-ref/source/religion.h
index b999ae194a..ec3de2a35d 100644
--- a/crawl-ref/source/religion.h
+++ b/crawl-ref/source/religion.h
@@ -97,6 +97,7 @@ void good_god_holy_attitude_change(monsters *holy);
void beogh_convert_orc(monsters *orc, bool emergency,
bool converted_by_follower = false);
bool is_evil_item(const item_def& item);
+bool god_dislikes_item_handling(const item_def &item);
bool ely_destroy_weapons();
bool trog_burn_books();
bool tso_unchivalric_attack_safe_monster(const actor *act);
diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc
index 70e5b71fe2..e151ef26bd 100644
--- a/crawl-ref/source/spells1.cc
+++ b/crawl-ref/source/spells1.cc
@@ -1267,8 +1267,11 @@ void antimagic()
DUR_SLAYING, DUR_STEALTH, DUR_MAGIC_SHIELD, DUR_SAGE
};
- if (!you.permanent_levitation() && you.duration[DUR_LEVITATION] > 2)
+ if (!you.permanent_levitation() && !you.permanent_flight()
+ && you.duration[DUR_LEVITATION] > 2)
+ {
you.duration[DUR_LEVITATION] = 2;
+ }
if (!you.permanent_flight() && you.duration[DUR_CONTROLLED_FLIGHT] > 1)
you.duration[DUR_CONTROLLED_FLIGHT] = 1;
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 894f972fbf..46a07f52c3 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -520,8 +520,9 @@ void init_travel_terrain_check(bool check_race_equip)
_set_pass_feature(DNGN_DEEP_WATER, water);
// Permanently levitating players can cross most hostile terrain.
- const signed char trav = (you.permanent_levitation() ? TRAVERSABLE
- : IMPASSABLE);
+ const signed char trav = (you.permanent_levitation()
+ || you.permanent_flight() ? TRAVERSABLE
+ : IMPASSABLE);
if (water != TRAVERSABLE)
_set_pass_feature(DNGN_DEEP_WATER, trav);