summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/acr.cc6
-rw-r--r--crawl-ref/source/delay.cc2
-rw-r--r--crawl-ref/source/fight.cc9
-rw-r--r--crawl-ref/source/food.cc194
-rw-r--r--crawl-ref/source/initfile.cc10
-rw-r--r--crawl-ref/source/player.cc2
6 files changed, 121 insertions, 102 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 23aa7cd34f..b6c372cd33 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1396,7 +1396,7 @@ static void _input()
fire_monster_alerts();
- bool player_feels_safe = i_feel_safe();
+ const bool player_feels_safe = i_feel_safe();
if (Options.tutorial_left)
{
@@ -1458,10 +1458,10 @@ static void _input()
// XXX: Is there some smart way to avoid autoswitching back if we're
// just about to continue butchering?
- if (!you.turn_is_over && player_feels_safe
+ if (Options.swap_when_safe && !you.turn_is_over && player_feels_safe
&& you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED])
{
- int weap = you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED];
+ int weap = you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] - 1;
if (weap == ENDOFPACK)
weap = -1;
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 2e20c7406b..4f98fb7e85 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -399,7 +399,7 @@ void stop_delay( bool stop_stair_travel )
// (Necessary because attributes are unsigned chars.)
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
= (butcher_swap_weapon == -1 ? ENDOFPACK
- : butcher_swap_weapon);
+ : butcher_swap_weapon) + 1;
}
}
else
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 18be80e265..0bbfc47f96 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -4076,9 +4076,9 @@ static bool wielded_weapon_check(const item_def *weapon)
{
bool result = true;
if (!you.received_weapon_warning
- && weapon && weapon->base_type != OBJ_STAVES
- && (weapon->base_type != OBJ_WEAPONS || is_range_weapon(*weapon))
- || you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED])
+ && (weapon && weapon->base_type != OBJ_STAVES
+ && (weapon->base_type != OBJ_WEAPONS || is_range_weapon(*weapon))
+ || you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]))
{
if (item_cursed(*weapon))
{
@@ -4097,10 +4097,7 @@ static bool wielded_weapon_check(const item_def *weapon)
// Don't warn again if you decide to continue your attack.
if (result)
- {
you.received_weapon_warning = true;
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
- }
}
return (result);
}
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 55ef08637d..6c92065f09 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -178,15 +178,18 @@ void weapon_switch( int targ )
// Look for a butchering implement. If fallback is true,
// prompt the user if no obvious options exist.
// Returns whether a weapon was switched.
-static bool _find_butchering_implement( bool fallback )
+static int _find_butchering_implement(int &butcher_tool)
{
+ // When berserk, you can't change weapons. Sanity check!
+ if (!can_wield(NULL, true))
+ return (false);
+
// If wielding a distortion weapon, never attempt to switch away
// automatically.
if (const item_def *wpn = you.weapon())
{
- // No switching necessary.
- if (can_cut_meat( *wpn ))
- return (false);
+ // Otherwise we wouldn't be here.
+ ASSERT(!can_cut_meat( *wpn ));
if (wpn->base_type == OBJ_WEAPONS
&& item_type_known(*wpn)
@@ -200,52 +203,92 @@ static bool _find_butchering_implement( bool fallback )
}
}
- int old_weapon = you.equip[EQ_WEAPON];
+ bool potential_candidate = false;
// Look for a butchering implement in your pack.
for (int i = 0; i < ENDOFPACK; ++i)
{
if (is_valid_item( you.inv[i] )
- && can_cut_meat( you.inv[i] )
&& you.inv[i].base_type == OBJ_WEAPONS
- && item_known_uncursed(you.inv[i])
- && item_type_known(you.inv[i])
- && get_weapon_brand(you.inv[i]) != SPWPN_DISTORTION
- // don't even ask
- && !has_warning_inscription(you.inv[i], OPER_WIELD)
+ && can_cut_meat( you.inv[i] )
&& can_wield( &you.inv[i] ))
{
- mpr("Switching to a butchering implement.");
- wield_weapon( true, i, false );
- return (true);
+ if (Options.easy_butcher
+ && item_known_uncursed(you.inv[i])
+ && item_type_known(you.inv[i])
+ && get_weapon_brand(you.inv[i]) != SPWPN_DISTORTION
+ // Don't even ask!
+ && !has_warning_inscription(you.inv[i], OPER_WIELD))
+ {
+ butcher_tool = i;
+ return (true);
+ }
+ else
+ potential_candidate = true;
}
}
- if (!fallback)
+ if (!potential_candidate)
+ {
+ mpr("You don't carry any weapon that could be used for butchering.");
return (false);
+ }
- // If we didn't swap above, then we still can't cut...let's call
- // wield_weapon() in the "prompt the user" way...
+ const int item_slot = prompt_invent_item(
+ "What would you like to use? (- for none)?",
+ MT_INVLIST, OSEL_WIELD,
+ true, true, true, '-', -1, NULL, OPER_WIELD);
- // Prompt for new weapon.
- mpr("What would you like to use?", MSGCH_PROMPT);
- wield_weapon( false );
+ if (prompt_failed(item_slot))
+ {
+ canned_msg(MSG_OK);
+ return (false);
+ }
+ else if (item_slot == PROMPT_GOT_SPECIAL)
+ {
+
+ if (you.has_claws()
+ || transform_can_butcher_barehanded(
+ static_cast<transformation_type>(
+ you.attribute[ATTR_TRANSFORMATION])))
+ {
+ butcher_tool = -1;
+ return (true);
+ }
+ else
+ {
+ mpr("You can't butcher without a weapon!");
+ return (false);
+ }
+ }
+ else if (item_slot == you.equip[EQ_WEAPON])
+ {
+ mpr("You are already wielding that!");
+ return (false);
+ }
- // Let's see if the user did something...
- return (you.equip[EQ_WEAPON] != old_weapon);
+ if (is_valid_item( you.inv[item_slot] )
+ && you.inv[item_slot].base_type == OBJ_WEAPONS
+ && can_cut_meat( you.inv[item_slot] )
+ && can_wield( &you.inv[item_slot] ))
+ {
+ butcher_tool = item_slot;
+ return (true);
+ }
+
+ mpr("That item isn't sharp enough!");
+ return (false);
}
-static bool _prepare_butchery(bool can_butcher, bool barehand_butcher,
- bool wpn_switch, bool removed_gloves,
- bool new_cursed)
+static bool _prepare_butchery(bool can_butcher, bool removed_gloves,
+ bool wpn_switch, int butchering_tool)
{
// No preparation necessary.
if (can_butcher)
return (true);
- // We don't want auto-switching.
- if (!Options.easy_butcher)
- return (false);
+ // At least one of these has to be true, else what are we doing here?
+ ASSERT(removed_gloves || wpn_switch);
// If you can butcher by taking off your gloves, don't prompt.
if (removed_gloves)
@@ -253,36 +296,20 @@ static bool _prepare_butchery(bool can_butcher, bool barehand_butcher,
// Actually take off the gloves; this creates a
// delay. We assume later on that gloves have a 1-turn
// takeoff delay!
- takeoff_armour(you.equip[EQ_GLOVES]);
- barehand_butcher = true;
+ if (!takeoff_armour(you.equip[EQ_GLOVES]))
+ return (false);
}
- // note that if barehanded then the user selected '-' when
- // switching weapons
- if (!barehand_butcher && (!wpn_switch
- || you.weapon() == NULL
- || !can_cut_meat(*you.weapon())))
+ if (wpn_switch)
{
- // still can't butcher. Early out
- if ( you.weapon() == NULL )
- {
- if (you.equip[EQ_GLOVES] == -1)
- mpr("What, with your bare hands?");
- else
- mpr("Your gloves aren't that sharp!");
- }
- else
- mpr("Maybe you should try using a sharper implement.");
-
- // Switch back to old weapon.
- if (!new_cursed && wpn_switch)
- start_delay( DELAY_WEAPON_SWAP, 1, you.equip[EQ_WEAPON] );
+ mprf("Switching to %s.",
+ (butchering_tool == -1) ? "unarmed"
+ : "a butchering implement");
- return (false);
+ if (!wield_weapon( true, butchering_tool, false ))
+ return (false);
}
- you.turn_is_over = true;
-
// Switched to a good butchering tool.
return (true);
}
@@ -328,17 +355,19 @@ static bool _butcher_corpse(int corpse_id, bool force_butcher = false)
}
static void _terminate_butchery(bool wpn_switch, bool removed_gloves,
- bool new_cursed, int old_weapon, int old_gloves)
+ int old_weapon, int old_gloves)
{
- // switch weapon back
- if (!new_cursed && wpn_switch)
+ // Switch weapon back.
+ if (wpn_switch && you.equip[EQ_WEAPON] != old_weapon
+ && (you.equip[EQ_WEAPON] == -1
+ || !item_cursed(you.inv[you.equip[EQ_WEAPON]])))
+ {
start_delay( DELAY_WEAPON_SWAP, 1, old_weapon );
+ }
- // put on the removed gloves
- if (removed_gloves)
+ // Put on the removed gloves.
+ if (removed_gloves && you.equip[EQ_GLOVES] != old_gloves)
start_delay( DELAY_ARMOUR_ON, 1, old_gloves );
-
- you.turn_is_over = true;
}
static bool _have_corpses_in_pack(bool remind)
@@ -403,7 +432,7 @@ static bool _have_corpses_in_pack(bool remind)
else
{
mprf("If you dropped the %s in your pack you could %s %s.",
- verb.c_str(), noun.c_str(), pronoun.c_str());
+ noun.c_str(), verb.c_str(), pronoun.c_str());
}
return (true);
@@ -429,7 +458,8 @@ bool butchery(int which_corpse)
static_cast<transformation_type>(you.attribute[ATTR_TRANSFORMATION]);
// Vampires' fangs are optimised for biting, not for tearing flesh.
- // Other species with this mutation still might benefit from this.
+ // (Not that they really need to.) Other species with this mutation
+ // might still benefit from it.
bool teeth_butcher = (player_mutation_level(MUT_FANGS) == 3
&& you.species != SP_VAMPIRE);
@@ -491,20 +521,19 @@ bool butchery(int which_corpse)
bool wpn_switch = false;
bool removed_gloves = false;
- bool new_cursed = false;
+ int butcher_tool = -1;
if (!can_butcher)
{
// Try to find a butchering implement.
- wpn_switch = _find_butchering_implement(!gloved_butcher);
- removed_gloves = gloved_butcher && !wpn_switch;
+ if (!_find_butchering_implement(butcher_tool))
+ return (false);
- if (wpn_switch)
- {
- new_cursed = ( you.weapon() != NULL
- && you.weapon()->base_type == OBJ_WEAPONS
- && item_cursed(*you.weapon()) );
- }
+ if (butcher_tool == -1 && gloved_butcher)
+ removed_gloves = true;
+
+ if (you.equip[EQ_WEAPON] != butcher_tool)
+ wpn_switch = true;
}
// Butcher pre-chosen corpse, if found, or if there is only one corpse.
@@ -512,19 +541,18 @@ bool butchery(int which_corpse)
if (prechosen && corpse_id == which_corpse
|| num_corpses == 1 && !Options.always_confirm_butcher)
{
- if (!_prepare_butchery(can_butcher, barehand_butcher, wpn_switch,
- removed_gloves, new_cursed))
+ if (!_prepare_butchery(can_butcher, removed_gloves, wpn_switch,
+ butcher_tool))
{
return (false);
}
success = _butcher_corpse(corpse_id);
- _terminate_butchery(wpn_switch, removed_gloves, new_cursed,
- old_weapon, old_gloves);
+ _terminate_butchery(wpn_switch, removed_gloves, old_weapon, old_gloves);
// Remind player of corpses in pack that could be butchered or
// bottled.
_have_corpses_in_pack(true);
- return success;
+ return (success);
}
// Now pick what you want to butcher. This is only a problem
@@ -583,9 +611,8 @@ bool butchery(int which_corpse)
case 'c':
case 'd':
case 'a':
- if (!_prepare_butchery(can_butcher, barehand_butcher,
- wpn_switch, removed_gloves,
- new_cursed))
+ if (!_prepare_butchery(can_butcher, removed_gloves,
+ wpn_switch, butcher_tool))
{
return (false);
}
@@ -607,8 +634,8 @@ bool butchery(int which_corpse)
case 'q':
canned_msg(MSG_OK);
- _terminate_butchery(wpn_switch, removed_gloves, new_cursed,
- old_weapon, old_gloves);
+ _terminate_butchery(wpn_switch, removed_gloves, old_weapon,
+ old_gloves);
return (false);
case '?':
@@ -641,12 +668,7 @@ bool butchery(int which_corpse)
you.species == SP_VAMPIRE && you.experience_level >= 6 ?
"bottle" : "butcher");
}
- else
- {
- _terminate_butchery(wpn_switch, removed_gloves, new_cursed,
- old_weapon, old_gloves);
- }
-
+ _terminate_butchery(wpn_switch, removed_gloves, old_weapon, old_gloves);
if (success)
{
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 9745be3425..098db26920 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -242,14 +242,15 @@ std::string channel_to_str( int channel )
static int _str_to_book( const std::string& str )
{
- if ( str == "fire" || str == "flame" )
+ if (str == "fire" || str == "flame")
return SBT_FIRE;
- if ( str == "cold" || str == "ice" )
+ if (str == "cold" || str == "ice")
return SBT_COLD;
- if ( str == "summ" || str == "summoning" )
+ if (str == "summ" || str == "summoning")
return SBT_SUMM;
- if ( str == "random" )
+ if (str == "random")
return SBT_RANDOM;
+
return SBT_NO_SELECTION;
}
@@ -286,7 +287,6 @@ std::string weapon_to_str( int weapon )
case WPN_HAND_AXE:
return "hand axe";
case WPN_RANDOM:
- return "random";
default:
return "random";
}
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 252bbe152c..15cb592619 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -3960,7 +3960,7 @@ void display_char_status()
if (you.rotting || you.species == SP_GHOUL)
mprf("Your flesh is rotting%s.", _get_rotting_how());
- // prints a contamination message
+ // Prints a contamination message.
contaminate_player( 0, false, true );
if (you.duration[DUR_CONFUSING_TOUCH])