Attached Files |
0001-Do-not-take-gloves-off-to-butcher.patch [^] (6,154 bytes) 2013-08-07 00:20 [Show Content] [Hide Content]From d21acc9988e60c1574757aa5bf05de85a46cb145 Mon Sep 17 00:00:00 2001
From: cjo <cjo@ulyco.com>
Date: Tue, 6 Aug 2013 11:02:43 -0700
Subject: [PATCH] Do not take gloves off to butcher.
Remove obsolete code concerning removal of gloves for butchering.
Now that all players have a butchering knife, it does not make
sense for unarmed characters to take gloves off to butcher, so
this code can be removed.
---
crawl-ref/source/food.cc | 58 +++++++++---------------------------------------
1 file changed, 11 insertions(+), 47 deletions(-)
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 40f51dc..1b558ea 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -228,30 +228,13 @@ void weapon_switch(int targ)
you.turn_is_over = true;
}
-static bool _prepare_butchery(bool can_butcher, bool removed_gloves,
- bool wpn_switch)
+static bool _prepare_butchery(bool can_butcher, bool wpn_switch)
{
// No preparation necessary.
if (can_butcher)
return true;
- // 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)
- {
- // Actually take off the gloves; this creates a delay. We
- // assume later on that gloves have a 1-turn takeoff delay!
- if (!takeoff_armour(you.equip[EQ_GLOVES]))
- return false;
-
- // Ensure that the gloves are taken off by now by finishing the
- // DELAY_ARMOUR_OFF delay started by takeoff_armour() above.
- // FIXME: get rid of this hack!
- finish_last_delay();
- }
+ ASSERT(wpn_switch);
if (wpn_switch
&& !wield_weapon(true, SLOT_BARE_HANDS, false, true, false, false))
@@ -330,8 +313,7 @@ static bool _corpse_butchery(int corpse_id, int butcher_tool,
return true;
}
-static void _terminate_butchery(bool wpn_switch, bool removed_gloves,
- int old_weapon, int old_gloves)
+static void _terminate_butchery(bool wpn_switch, int old_weapon)
{
// Switch weapon back.
if (wpn_switch && you.equip[EQ_WEAPON] != old_weapon
@@ -339,10 +321,6 @@ static void _terminate_butchery(bool wpn_switch, bool removed_gloves,
{
start_delay(DELAY_WEAPON_SWAP, 1, old_weapon);
}
-
- // Put on the removed gloves.
- if (removed_gloves && you.equip[EQ_GLOVES] != old_gloves)
- start_delay(DELAY_ARMOUR_ON, 1, old_gloves, 1);
}
static int _corpse_badness(corpse_effect_type ce, const item_def &item,
@@ -476,9 +454,6 @@ bool butchery(int which_corpse, bool bottle_blood)
|| you.has_claws())
&& !player_wearing_slot(EQ_GLOVES);
- bool gloved_butcher = (you.has_claws() && player_wearing_slot(EQ_GLOVES)
- && !you.inv[you.equip[EQ_GLOVES]].cursed());
-
bool weapon_butcher = you.weapon() && can_cut_meat(*you.weapon());
bool knife_butcher = !weapon_butcher && form_can_wield();
@@ -551,22 +526,15 @@ bool butchery(int which_corpse, bool bottle_blood)
}
int old_weapon = you.equip[EQ_WEAPON];
- int old_gloves = you.equip[EQ_GLOVES];
bool wpn_switch = false;
- bool removed_gloves = false;
if (!can_butcher)
- {
- if (you.weapon() && you.weapon()->cursed() && gloved_butcher)
- removed_gloves = true;
- else
- wpn_switch = true;
- }
+ wpn_switch = true;
int butcher_tool;
- if (barehand_butcher || removed_gloves)
+ if (barehand_butcher)
butcher_tool = SLOT_CLAWS;
else if (teeth_butcher)
butcher_tool = SLOT_TEETH;
@@ -591,11 +559,11 @@ bool butchery(int which_corpse, bool bottle_blood)
return false;
}
- if (!_prepare_butchery(can_butcher, removed_gloves, wpn_switch))
+ if (!_prepare_butchery(can_butcher, wpn_switch))
return false;
success = _corpse_butchery(corpse_id, butcher_tool, true, bottle_blood);
- _terminate_butchery(wpn_switch, removed_gloves, old_weapon, old_gloves);
+ _terminate_butchery(wpn_switch, old_weapon);
// Remind player of corpses in pack that could be butchered or
// bottled.
@@ -634,7 +602,7 @@ bool butchery(int which_corpse, bool bottle_blood)
corpse_id = selected[i].item->index();
if (!did_weap_swap)
{
- if (_prepare_butchery(can_butcher, removed_gloves, wpn_switch))
+ if (_prepare_butchery(can_butcher, wpn_switch))
did_weap_swap = true;
else
return false;
@@ -693,11 +661,8 @@ bool butchery(int which_corpse, bool bottle_blood)
case 'a':
if (!did_weap_swap)
{
- if (_prepare_butchery(can_butcher, removed_gloves,
- wpn_switch))
- {
+ if (_prepare_butchery(can_butcher, wpn_switch))
did_weap_swap = true;
- }
else
return false;
}
@@ -710,8 +675,7 @@ bool butchery(int which_corpse, bool bottle_blood)
case 'q':
CASE_ESCAPE
canned_msg(MSG_OK);
- _terminate_butchery(wpn_switch, removed_gloves, old_weapon,
- old_gloves);
+ _terminate_butchery(wpn_switch, old_weapon);
return false;
case '?':
@@ -745,7 +709,7 @@ bool butchery(int which_corpse, bool bottle_blood)
Options.confirm_butcher == CONFIRM_NEVER ? "suitable" : "else",
bottle_blood ? "bottle" : "butcher");
}
- _terminate_butchery(wpn_switch, removed_gloves, old_weapon, old_gloves);
+ _terminate_butchery(wpn_switch, old_weapon);
if (success)
{
--
1.8.3-rc3
0001-Remove-obsolete-butchering-code.patch [^] (26,310 bytes) 2013-08-07 23:54 [Show Content] [Hide Content]From a21a631dc18f29919e10a31b973d412127059489 Mon Sep 17 00:00:00 2001
From: cjo <cjo@ulyco.com>
Date: Wed, 7 Aug 2013 14:16:05 -0700
Subject: [PATCH] Remove obsolete butchering code
Remove obsolete butchering code. Players can now butcher with blunt
weapons, but the code to make them swap away from blunt weapons was
never removed. Food.cc used custom functions for wielding and unwielding,
so removing those functions required changing various other files.
This patch also moves the process of choosing the butchering tool to
its own function, and removes the restriction on unarmed butchering
for players with no mutations.
---
crawl-ref/source/delay.cc | 130 +----------------------
crawl-ref/source/delay.h | 2 -
crawl-ref/source/enum.h | 4 +-
crawl-ref/source/files.cc | 5 -
crawl-ref/source/food.cc | 220 +++++++++------------------------------
crawl-ref/source/hints.cc | 43 +-------
crawl-ref/source/itemprop.cc | 2 +
crawl-ref/source/melee_attack.cc | 9 --
crawl-ref/source/spl-transloc.cc | 2 -
crawl-ref/source/transform.cc | 3 -
10 files changed, 58 insertions(+), 362 deletions(-)
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 543a070..57bd4e0 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -161,9 +161,6 @@ void start_delay(delay_type type, int turns, int parm1, int parm2, int parm3)
delay.started = false;
// Paranoia
- if (type == DELAY_WEAPON_SWAP)
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
-
if (delay_is_run(type))
clear_travel_trail();
@@ -179,8 +176,6 @@ void start_delay(delay_type type, int turns, int parm1, int parm2, int parm3)
_push_delay(delay);
}
-static void _maybe_interrupt_swap(bool force_unsafe = false);
-
void stop_delay(bool stop_stair_travel, bool force_unsafe)
{
if (you.delay_queue.empty())
@@ -226,7 +221,6 @@ void stop_delay(bool stop_stair_travel, bool force_unsafe)
_pop_delay();
- _maybe_interrupt_swap(force_unsafe);
break;
}
case DELAY_MEMORISE:
@@ -360,7 +354,6 @@ void stop_delay(bool stop_stair_travel, bool force_unsafe)
}
break;
- case DELAY_WEAPON_SWAP: // one turn... too much trouble
case DELAY_DROP_ITEM: // one turn... only used for easy armour drops
case DELAY_JEWELLERY_ON: // one turn
case DELAY_UNINTERRUPTIBLE: // never stoppable
@@ -391,116 +384,6 @@ void maybe_clear_weapon_swap()
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
-void handle_interrupted_swap(bool swap_if_safe, bool force_unsafe)
-{
- if (!you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
- || !you_tran_can_wear(EQ_WEAPON) || you.cannot_act() || you.berserk())
- {
- return;
- }
-
- // Decrease value by 1. (0 means attribute is false, 1 = a, 2 = b, ...)
- int weap = you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] - 1;
- if (weap == ENDOFPACK)
- weap = -1;
-
- const bool safe = i_feel_safe() && !force_unsafe;
- const bool prompt = Options.prompt_for_swap && !safe;
- const delay_type delay = current_delay_action();
-
- const char* prompt_str = "Switch back to main weapon?";
-
- // If we're going to prompt then update the window so the player can
- // see what the monsters are.
- if (prompt)
- viewwindow();
-
- if (delay == DELAY_WEAPON_SWAP)
- die("handle_interrupted_swap() called while already swapping weapons");
- else if (!you.turn_is_over
- && (delay == DELAY_ASCENDING_STAIRS
- || delay == DELAY_DESCENDING_STAIRS))
- {
- // We just arrived on the level, let rest of function do its stuff.
- ;
- }
- else if (you.turn_is_over && delay == DELAY_NOT_DELAYED)
- {
- // Turn is over, set up a delay to do swapping next turn.
- if (prompt && yesno(prompt_str, true, 'n', true, false)
- || safe && swap_if_safe)
- {
- if (weap == -1 || check_warning_inscriptions(you.inv[weap], OPER_WIELD))
- start_delay(DELAY_WEAPON_SWAP, 1, weap);
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
- }
- return;
- }
- else if (delay != DELAY_NOT_DELAYED)
- {
- // If ATTR_WEAPON_SWAP_INTERRUPTED is set while a corpse is being
- // butchered/bottled/offered, then fake a weapon swap delay.
- if (_is_butcher_delay(delay)
- && (safe || prompt && yesno(prompt_str, true, 'n', true, false)))
- {
- if (weap == -1 || check_warning_inscriptions(you.inv[weap], OPER_WIELD))
- start_delay(DELAY_WEAPON_SWAP, 1, weap);
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
- }
- return;
- }
-
- if (safe)
- {
- if (!swap_if_safe)
- return;
- }
- else if (!prompt || !yesno(prompt_str, true, 'n', true, false))
- return;
-
- if (weap == -1 || check_warning_inscriptions(you.inv[weap], OPER_WIELD))
- {
- weapon_switch(weap);
- print_stats();
- }
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
-}
-
-static void _maybe_interrupt_swap(bool force_unsafe)
-{
- bool butcher_swap_setup = false;
- int butcher_swap_weapon = 0;
-
- for (unsigned int i = 1; i < you.delay_queue.size(); ++i)
- if (you.delay_queue[i].type == DELAY_WEAPON_SWAP)
- {
- butcher_swap_weapon = you.delay_queue[i].parm1;
- butcher_swap_setup = true;
- break;
- }
-
- if (!butcher_swap_setup && delays_cleared[DELAY_WEAPON_SWAP] > 0)
- {
- butcher_swap_setup = true;
- butcher_swap_weapon = cleared_delays_parm1[DELAY_WEAPON_SWAP];
- }
-
- if (butcher_swap_setup)
- {
- // Use weapon slot + 1, so weapon slot 'a' (== 0) doesn't
- // return false when checking if
- // you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED].
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
- = (butcher_swap_weapon == -1 ? ENDOFPACK
- : butcher_swap_weapon) + 1;
-
- // Possibly prompt if user wants to switch back from
- // butchering tool in order to use their normal weapon to
- // fight the interrupting monster.
- handle_interrupted_swap(true, force_unsafe);
- }
-}
-
bool you_are_delayed(void)
{
return !you.delay_queue.empty();
@@ -659,6 +542,7 @@ void handle_delay()
case SLOT_BUTCHERING_KNIFE: tool = "knife"; break;
case SLOT_CLAWS: tool = "claws"; break;
case SLOT_TEETH: tool = "teeth"; break;
+ case SLOT_BARE_HANDS: tool = "bare hands"; break;
case SLOT_BIRDIE: tool = "beak and talons"; break;
default: tool = you.inv[delay.parm3].name(DESC_QUALNAME);
}
@@ -861,7 +745,6 @@ void handle_delay()
break;
case DELAY_JEWELLERY_ON:
- case DELAY_WEAPON_SWAP:
// These are 1-turn delays where the time cost is handled
// in _finish_delay().
// FIXME: get rid of this hack!
@@ -924,11 +807,6 @@ static void _finish_delay(const delay_queue_item &delay)
{
switch (delay.type)
{
- case DELAY_WEAPON_SWAP:
- weapon_switch(delay.parm1);
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
- break;
-
case DELAY_JEWELLERY_ON:
puton_ring(delay.parm1);
break;
@@ -1165,7 +1043,6 @@ static void _finish_delay(const delay_queue_item &delay)
autopickup();
}
- _maybe_interrupt_swap();
}
else
{
@@ -1455,9 +1332,8 @@ void run_macro(const char *macroname)
bool is_delay_interruptible(delay_type delay)
{
- return !(delay == DELAY_EAT || delay == DELAY_WEAPON_SWAP
- || delay == DELAY_DROP_ITEM || delay == DELAY_JEWELLERY_ON
- || delay == DELAY_UNINTERRUPTIBLE);
+ return !(delay == DELAY_EAT || delay == DELAY_DROP_ITEM
+ || delay == DELAY_JEWELLERY_ON || delay == DELAY_UNINTERRUPTIBLE);
}
// Returns TRUE if the delay should be interrupted, MAYBE if the user function
diff --git a/crawl-ref/source/delay.h b/crawl-ref/source/delay.h
index 25dd20a..4692dfa 100644
--- a/crawl-ref/source/delay.h
+++ b/crawl-ref/source/delay.h
@@ -81,8 +81,6 @@ bool player_stair_delay();
bool already_learning_spell(int spell);
void stop_butcher_delay();
void maybe_clear_weapon_swap();
-void handle_interrupted_swap(bool swap_if_safe = false,
- bool force_unsafe = false);
void clear_macro_process_key_delay();
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 95e0ebd..1016810 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1059,7 +1059,9 @@ enum delay_type
DELAY_MEMORISE,
DELAY_BUTCHER,
DELAY_BOTTLE_BLOOD,
- DELAY_WEAPON_SWAP,
+#if TAG_MAJOR_VERSION == 34
+ DELAY_WEAPON_SWAP, // was specific to butchering code
+#endif
DELAY_PASSWALL,
DELAY_DROP_ITEM,
DELAY_MULTIDROP,
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index de5379f..7acc8ac 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1506,11 +1506,6 @@ bool load_level(dungeon_feature_type stair_taken, load_mode_type load_mode,
}
}
- // If butchering was interrupted by switching levels (banishment)
- // then switch back from butchering tool if there's no hostiles
- // nearby.
- handle_interrupted_swap(true);
-
// Forget about interrupted butchering, since we probably aren't going
// to get back to the corpse in time to finish things.
// But do not reset the weapon swap if we swapped weapons
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 1b558ea..1a33867 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -63,7 +63,8 @@ static void _describe_food_change(int hunger_increment);
static bool _vampire_consume_corpse(int slot, bool invent);
static void _heal_from_food(int hp_amt, bool unrot = false,
bool restore_str = false);
-
+int _choose_butcher_tool();
+bool _can_butcher();
/*
* BEGIN PUBLIC FUNCTIONS
*/
@@ -161,91 +162,6 @@ bool you_foodless_normally()
|| you.species == SP_DJINNI;
}
-/**
- * More of a "weapon_switch back from butchering" function, switching
- * to a weapon is done using the wield_weapon() code.
- * Special cases like staves of power or other special weps are taken
- * care of by calling wield_effects(). {gdl}
- */
-void weapon_switch(int targ)
-{
- // Give the player an option to abort.
- if (you.weapon() && !check_old_item_warning(*you.weapon(), OPER_WIELD))
- return;
-
- if (targ == -1) // Unarmed Combat.
- {
- // Already unarmed?
- if (!you.weapon())
- return;
-
- mpr("You switch back to your bare hands.");
- }
- else
- {
- // Possibly not valid anymore (dropped, etc.).
- if (!you.inv[targ].defined())
- return;
-
- // Already wielding this weapon?
- if (you.equip[EQ_WEAPON] == you.inv[targ].link)
- return;
-
- if (!can_wield(&you.inv[targ]))
- {
- mprf("Not switching back to %s.",
- you.inv[targ].name(DESC_INVENTORY).c_str());
- return;
- }
- }
-
- // Unwield the old weapon and wield the new.
- // XXX This is a pretty dangerous hack; I don't like it.--GDL
- //
- // Well yeah, but that's because interacting with the wielding
- // code is a mess... this whole function's purpose was to
- // isolate this hack until there's a proper way to do things. -- bwr
- if (you.weapon())
- unwield_item(false);
-
- if (targ != -1)
- equip_item(EQ_WEAPON, targ, false);
-
- if (Options.chunks_autopickup || you.species == SP_VAMPIRE)
- autopickup();
-
- // Same amount of time as normal wielding.
- // FIXME: this duplicated code is begging for a bug.
- if (you.weapon())
- you.time_taken /= 2;
- else // Swapping to empty hands is faster.
- {
- you.time_taken *= 3;
- you.time_taken /= 10;
- }
-
- you.wield_change = true;
- you.turn_is_over = true;
-}
-
-static bool _prepare_butchery(bool can_butcher, bool wpn_switch)
-{
- // No preparation necessary.
- if (can_butcher)
- return true;
-
- ASSERT(wpn_switch);
-
- if (wpn_switch
- && !wield_weapon(true, SLOT_BARE_HANDS, false, true, false, false))
- {
- return false;
- }
-
- // Switched to a good butchering tool.
- return true;
-}
-
static bool _should_butcher(int corpse_id, bool bottle_blood = false)
{
const item_def &corpse = mitm[corpse_id];
@@ -296,7 +212,8 @@ static bool _corpse_butchery(int corpse_id, int butcher_tool,
if (first_corpse)
mitm[corpse_id].plus2++;
- int work_req = max(0, 4 - mitm[corpse_id].plus2);
+ int work_req = 5; // all butchering will take 5 turns
+ // int work_req = max(0, 4 - mitm[corpse_id].plus2);
delay_type dtype = DELAY_BUTCHER;
// Sanity checks.
@@ -313,16 +230,6 @@ static bool _corpse_butchery(int corpse_id, int butcher_tool,
return true;
}
-static void _terminate_butchery(bool wpn_switch, int old_weapon)
-{
- // Switch weapon back.
- if (wpn_switch && you.equip[EQ_WEAPON] != old_weapon
- && (!you.weapon() || !you.weapon()->cursed()))
- {
- start_delay(DELAY_WEAPON_SWAP, 1, old_weapon);
- }
-}
-
static int _corpse_badness(corpse_effect_type ce, const item_def &item,
bool wants_any)
{
@@ -428,54 +335,64 @@ static string _butcher_menu_title(const Menu *menu, const string &oldt)
}
#endif
-bool butchery(int which_corpse, bool bottle_blood)
+bool _can_butcher()
{
- if (you.visible_igrd(you.pos()) == NON_ITEM)
+ // You are transmuted into a form which can not butcher.
+ // cjo: I removed restrictions on butchering while berserk,
+ // which leaves only one case for this function.
+ if (you.form != TRAN_NONE
+ && !form_can_wield() && ! form_can_butcher_barehanded())
{
- if (!_have_corpses_in_pack(false, bottle_blood))
- mpr("There isn't anything here!");
+ mpr("You can not butcher while in this form!");
return false;
}
+ return true;
+}
- // XXX these restrictions are a huge mess, leading to a lot of
- // complicated code and very little in the way of actual fun.
- // We should rip them out once we figure out how. (SamB)
-
+int _choose_butcher_tool()
+{
// Vampires' fangs are optimised for biting, not for tearing flesh.
// (Not that they really need to.) Other species with this mutation
// might still benefit from it.
- bool teeth_butcher = (you.has_usable_fangs() == 3
- && you.species != SP_VAMPIRE);
-
- bool birdie_butcher = (player_mutation_level(MUT_BEAK)
- && player_mutation_level(MUT_TALONS));
-
- bool barehand_butcher = (form_can_butcher_barehanded(you.form)
- || you.has_claws())
- && !player_wearing_slot(EQ_GLOVES);
-
- bool weapon_butcher = you.weapon() && can_cut_meat(*you.weapon());
-
- bool knife_butcher = !weapon_butcher && form_can_wield();
+ int butcher_tool = 0;
+ if((you.has_usable_fangs() == 3) && you.species != SP_VAMPIRE)
+ butcher_tool = SLOT_TEETH;
+ else if (player_mutation_level(MUT_BEAK) && player_mutation_level(MUT_TALONS))
+ butcher_tool = SLOT_BIRDIE;
+ else if ((form_can_butcher_barehanded(you.form) || you.has_claws())
+ && !player_wearing_slot(EQ_GLOVES))
+ {
+ butcher_tool = SLOT_CLAWS;
+ }
+ else if (you.form != TRAN_NONE && form_can_butcher_barehanded())
+ butcher_tool = SLOT_CLAWS;
+ else if(you.weapon())
+ butcher_tool = you.weapon()->link;
+ else if(!you.berserk() && form_can_wield())
+ butcher_tool = SLOT_BUTCHERING_KNIFE;
+ else if (you.berserk())
+ butcher_tool = SLOT_BARE_HANDS;
+ else
+ butcher_tool = SLOT_BUTCHERING_KNIFE;
- bool can_butcher = (teeth_butcher || barehand_butcher
- || birdie_butcher
- || weapon_butcher
- || knife_butcher);
+ return butcher_tool;
+}
- // It makes more sense that you first find out if there's anything
- // to butcher, *then* decide to actually butcher it.
- // The old code did it the other way.
- if (!can_butcher && you.berserk())
+bool butchery(int which_corpse, bool bottle_blood)
+{
+ // nothing to butcher
+ if (you.visible_igrd(you.pos()) == NON_ITEM)
{
- // NB: Normally can't get here with bottle_blood == true because it's an
- // ability and thus also blocked when berserking. If bottle_blood was
- // somehow true at the point, the following message would be wrong and
- // (even worse) bottling success would depend on can_butcher == true.
- mpr("You are too berserk to search for a butchering tool!");
+ if (!_have_corpses_in_pack(false, bottle_blood))
+ mpr("There isn't anything here!");
return false;
}
+ if(!_can_butcher())
+ return false;
+
+ int butcher_tool = _choose_butcher_tool();
+
bool wants_any = you.has_spell(SPELL_SIMULACRUM)
|| you.has_spell(SPELL_SUBLIMATION_OF_BLOOD);
@@ -525,26 +442,6 @@ bool butchery(int which_corpse, bool bottle_blood)
return false;
}
- int old_weapon = you.equip[EQ_WEAPON];
-
- bool wpn_switch = false;
-
- if (!can_butcher)
- wpn_switch = true;
-
- int butcher_tool;
-
- if (barehand_butcher)
- butcher_tool = SLOT_CLAWS;
- else if (teeth_butcher)
- butcher_tool = SLOT_TEETH;
- else if (birdie_butcher)
- butcher_tool = SLOT_BIRDIE;
- else if (wpn_switch || knife_butcher)
- butcher_tool = SLOT_BUTCHERING_KNIFE;
- else
- butcher_tool = you.weapon()->link;
-
// Butcher pre-chosen corpse, if found, or if there is only one corpse.
bool success = false;
if (prechosen && corpse_id == which_corpse
@@ -559,11 +456,7 @@ bool butchery(int which_corpse, bool bottle_blood)
return false;
}
- if (!_prepare_butchery(can_butcher, wpn_switch))
- return false;
-
success = _corpse_butchery(corpse_id, butcher_tool, true, bottle_blood);
- _terminate_butchery(wpn_switch, old_weapon);
// Remind player of corpses in pack that could be butchered or
// bottled.
@@ -574,7 +467,6 @@ bool butchery(int which_corpse, bool bottle_blood)
// Now pick what you want to butcher. This is only a problem
// if there are several corpses on the square.
bool butcher_all = false;
- bool did_weap_swap = false;
bool first_corpse = true;
#ifdef TOUCH_UI
vector<const item_def*> meat;
@@ -600,13 +492,6 @@ bool butchery(int which_corpse, bool bottle_blood)
for (int i = 0, count = selected.size(); i < count; ++i)
{
corpse_id = selected[i].item->index();
- if (!did_weap_swap)
- {
- if (_prepare_butchery(can_butcher, wpn_switch))
- did_weap_swap = true;
- else
- return false;
- }
if (_corpse_butchery(corpse_id, butcher_tool, first_corpse,
bottle_blood))
{
@@ -659,13 +544,6 @@ bool butchery(int which_corpse, bool bottle_blood)
case 'c':
case 'd':
case 'a':
- if (!did_weap_swap)
- {
- if (_prepare_butchery(can_butcher, wpn_switch))
- did_weap_swap = true;
- else
- return false;
- }
corpse_id = si->index();
if (keyin == 'a')
@@ -675,7 +553,6 @@ bool butchery(int which_corpse, bool bottle_blood)
case 'q':
CASE_ESCAPE
canned_msg(MSG_OK);
- _terminate_butchery(wpn_switch, old_weapon);
return false;
case '?':
@@ -709,7 +586,6 @@ bool butchery(int which_corpse, bool bottle_blood)
Options.confirm_butcher == CONFIRM_NEVER ? "suitable" : "else",
bottle_blood ? "bottle" : "butcher");
}
- _terminate_butchery(wpn_switch, old_weapon);
if (success)
{
diff --git a/crawl-ref/source/hints.cc b/crawl-ref/source/hints.cc
index 084749c..5899cd7 100644
--- a/crawl-ref/source/hints.cc
+++ b/crawl-ref/source/hints.cc
@@ -1020,18 +1020,6 @@ void hints_first_item(const item_def &item)
glyph_to_tagstr(get_item_glyph(&item)));
}
-// If the player is wielding a cursed non-slicing weapon then butchery
-// isn't currently possible.
-static bool _cant_butcher()
-{
- const item_def *wpn = you.weapon();
-
- if (!wpn || wpn->base_type != OBJ_WEAPONS)
- return false;
-
- return (wpn->cursed() && !can_cut_meat(*wpn));
-}
-
static string _describe_portal(const coord_def &gc)
{
const string desc = feature_description_at(gc);
@@ -1410,13 +1398,6 @@ void learned_something_new(hints_event_type seen_what, coord_def gc)
"can <w>%</w>hop it up";
cmd.push_back(CMD_BUTCHER);
- if (_cant_butcher())
- {
- text << " (though unfortunately you can't do that right now, "
- "since the cursed weapon you're wielding can't slice up "
- "meat, and you can't let go of it to wield your pocket "
- "knife)";
- }
text << ". Once hungry you can then <w>%</w>at the resulting chunks "
"(though they may not be healthful).";
cmd.push_back(CMD_EAT);
@@ -2022,24 +2003,10 @@ void learned_something_new(hints_event_type seen_what, coord_def gc)
case HINT_YOU_HUNGRY:
text << "There are two ways to overcome hunger: food you started "
"with or found, and self-made chunks from corpses. To get the "
- "latter, all you need to do is <w>%</w>hop up a corpse. ";
+ "latter, all you need to do is <w>%</w>hop up a corpse. "
+ "Try to dine on chunks in order to save permanent food.";
cmd.push_back(CMD_BUTCHER);
- if (_cant_butcher())
- {
- text << "Unfortunately you can't butcher corpses right now, "
- "since the cursed weapon you're wielding can't slice up "
- "meat, and you can't let go of it to wield your pocket "
- "knife. ";
- }
- else
- {
- text << "Luckily, all adventurers carry a pocket knife with them "
- "which is perfect for butchering. ";
- }
-
- text << "Try to dine on chunks in order to save permanent food.";
-
if (Hints.hints_type == HINT_BERSERK_CHAR)
text << "\nNote that you cannot Berserk while very hungry or worse.";
break;
@@ -2130,12 +2097,6 @@ void learned_something_new(hints_event_type seen_what, coord_def gc)
"<w>%</w>hop up";
cmd.push_back(CMD_BUTCHER);
- if (_cant_butcher())
- {
- text << "(or which you <w>could</w> chop up if it weren't for "
- "the fact that you can't let go of your cursed "
- "non-chopping weapon)";
- }
text << ". One or more chunks will appear that you can then "
"<w>%</w>at. Beware that some chunks may be, sometimes or "
"always, hazardous. You can find out whether that might be the "
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index f21dc08..40fcb0a 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -2138,6 +2138,8 @@ int food_turns(const item_def &item)
return max(1, item_mass(item) / 100); // TRAN_JELLY
}
+// cjo: this no longer relates to butchering, but is still used
+// in several places to check for slicing damage
bool can_cut_meat(const item_def &item)
{
return _does_damage_type(item, DAM_SLICE);
diff --git a/crawl-ref/source/melee_attack.cc b/crawl-ref/source/melee_attack.cc
index 557ee07..da05bd3 100644
--- a/crawl-ref/source/melee_attack.cc
+++ b/crawl-ref/source/melee_attack.cc
@@ -1017,15 +1017,6 @@ bool melee_attack::attack()
do_miscast();
}
- else
- {
- // Invisible monster might have interrupted butchering.
- if (you_are_delayed() && defender->is_player()
- && perceived_attack && !attacker_visible)
- {
- handle_interrupted_swap(false, true);
- }
- }
adjust_noise();
// don't crash on banishment
diff --git a/crawl-ref/source/spl-transloc.cc b/crawl-ref/source/spl-transloc.cc
index b491540..f02213b 100644
--- a/crawl-ref/source/spl-transloc.cc
+++ b/crawl-ref/source/spl-transloc.cc
@@ -447,8 +447,6 @@ static void _handle_teleport_update(bool large_change, const coord_def old_pos)
else if (see_cell)
behaviour_event(*mi, ME_EVAL);
}
-
- handle_interrupted_swap(true);
}
#ifdef USE_TILE
diff --git a/crawl-ref/source/transform.cc b/crawl-ref/source/transform.cc
index e62cf4b..1b1ecbd 100644
--- a/crawl-ref/source/transform.cc
+++ b/crawl-ref/source/transform.cc
@@ -1367,9 +1367,6 @@ void untransform(bool skip_wielding, bool skip_move)
you.stop_being_constricted();
}
- if (!skip_wielding)
- handle_interrupted_swap(true, false);
-
you.turn_is_over = true;
if (you.transform_uncancellable)
you.transform_uncancellable = false;
--
1.8.3-rc3
0001-Allow-unarmed-butchering-remove-hypothetical-knife.patch [^] (9,634 bytes) 2013-08-09 00:49 [Show Content] [Hide Content]From 02998129efad88230cd5d97288e81100c791ebe1 Mon Sep 17 00:00:00 2001
From: cjo <cjo@ulyco.com>
Date: Thu, 8 Aug 2013 15:42:53 -0700
Subject: [PATCH] Allow unarmed butchering, remove hypothetical knife
This patch allows unarmed butchering and removes the
hypothetical butcher knife as no longer necessary.
It removes mention of a weapon from the butchering
message (since that raises awkward questions about
how a whip, etc, can be used to chop things). It
also renames a function (new name: weapon_is_slicing).
---
crawl-ref/source/dat/descript/ability.txt | 3 +--
crawl-ref/source/delay.cc | 27 ++++++++++++++++-----------
crawl-ref/source/food.cc | 21 ++++++---------------
crawl-ref/source/invent.cc | 2 +-
crawl-ref/source/invent.h | 1 -
crawl-ref/source/itemprop.cc | 2 +-
crawl-ref/source/itemprop.h | 2 +-
crawl-ref/source/l_item.cc | 6 +++---
crawl-ref/source/mon-ench.cc | 2 +-
crawl-ref/source/traps.cc | 4 ++--
10 files changed, 32 insertions(+), 38 deletions(-)
diff --git a/crawl-ref/source/dat/descript/ability.txt b/crawl-ref/source/dat/descript/ability.txt
index 209d82b..ba5967e 100644
--- a/crawl-ref/source/dat/descript/ability.txt
+++ b/crawl-ref/source/dat/descript/ability.txt
@@ -60,8 +60,7 @@ weight of your possessions or some disability would normally drag you down.
Bottle Blood
At experience level 6 and higher, Vampires can bottle the blood from non-rotten
-and blood-containing corpses they are standing on. Doing so requires the
-capability of wielding your knife, as is the case for butchering.
+and blood-containing corpses they are standing on.
%%%%
Spit Acid
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 57bd4e0..95b2de8 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -536,19 +536,25 @@ void handle_delay()
}
else
{
- string tool;
+ string act, tool;
switch (delay.parm3)
{
- case SLOT_BUTCHERING_KNIFE: tool = "knife"; break;
- case SLOT_CLAWS: tool = "claws"; break;
- case SLOT_TEETH: tool = "teeth"; break;
- case SLOT_BARE_HANDS: tool = "bare hands"; break;
- case SLOT_BIRDIE: tool = "beak and talons"; break;
- default: tool = you.inv[delay.parm3].name(DESC_QUALNAME);
+ case SLOT_CLAWS:
+ act = "slicing up"; tool = " with your claws";
+ break;
+ case SLOT_TEETH:
+ act = "tearing up"; tool = " with your teeth";
+ break;
+ case SLOT_BIRDIE:
+ act = "tearing up"; tool = " with your beak and talons";
+ break;
+ default:
+ act = "butchering"; tool = "";
+ break;
}
mprf(MSGCH_MULTITURN_ACTION,
- "You start butchering %s with your %s.",
- mitm[delay.parm1].name(DESC_THE).c_str(), tool.c_str());
+ "You start %s the %s%s.",
+ act.c_str(), mitm[delay.parm1].name(DESC_THE).c_str(), tool.c_str());
}
break;
@@ -989,8 +995,7 @@ static void _finish_delay(const delay_queue_item &delay)
}
else
{
- mprf("You finish %s %s into pieces.",
- delay.parm3 <= SLOT_CLAWS ? "ripping" : "chopping",
+ mprf("You finish butchering the %s.",
mitm[delay.parm1].name(DESC_THE).c_str());
if (god_hates_cannibalism(you.religion)
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 1a33867..c39ac38 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -351,29 +351,20 @@ bool _can_butcher()
int _choose_butcher_tool()
{
- // Vampires' fangs are optimised for biting, not for tearing flesh.
- // (Not that they really need to.) Other species with this mutation
- // might still benefit from it.
+ // This relates to special messages for mutations which are used to butcher.
+ // It has no effect other than flavour.
+
int butcher_tool = 0;
+ // Vampires' fangs are optimised for biting, not for tearing flesh.
if((you.has_usable_fangs() == 3) && you.species != SP_VAMPIRE)
butcher_tool = SLOT_TEETH;
else if (player_mutation_level(MUT_BEAK) && player_mutation_level(MUT_TALONS))
butcher_tool = SLOT_BIRDIE;
- else if ((form_can_butcher_barehanded(you.form) || you.has_claws())
- && !player_wearing_slot(EQ_GLOVES))
+ else if (form_can_butcher_barehanded(you.form)
+ || (you.has_claws() && !player_wearing_slot(EQ_GLOVES)))
{
butcher_tool = SLOT_CLAWS;
}
- else if (you.form != TRAN_NONE && form_can_butcher_barehanded())
- butcher_tool = SLOT_CLAWS;
- else if(you.weapon())
- butcher_tool = you.weapon()->link;
- else if(!you.berserk() && form_can_wield())
- butcher_tool = SLOT_BUTCHERING_KNIFE;
- else if (you.berserk())
- butcher_tool = SLOT_BARE_HANDS;
- else
- butcher_tool = SLOT_BUTCHERING_KNIFE;
return butcher_tool;
}
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index b018553..5efb8d2 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -1173,7 +1173,7 @@ static bool _item_class_selected(const item_def &i, int selector)
return item_is_wieldable(i);
case OSEL_BUTCHERY:
- return (itype == OBJ_WEAPONS && can_cut_meat(i));
+ return (itype == OBJ_WEAPONS && weapon_is_slicing(i));
case OBJ_SCROLLS:
return (itype == OBJ_SCROLLS
diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h
index fbe89c4..72ade34 100644
--- a/crawl-ref/source/invent.h
+++ b/crawl-ref/source/invent.h
@@ -36,7 +36,6 @@ enum object_selector
#define SLOT_BARE_HANDS -2
// Only used for butchering messages
-#define SLOT_BUTCHERING_KNIFE -3
#define SLOT_CLAWS -4
#define SLOT_TEETH -5
#define SLOT_BIRDIE -6
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 40fcb0a..2c90c52 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -2140,7 +2140,7 @@ int food_turns(const item_def &item)
// cjo: this no longer relates to butchering, but is still used
// in several places to check for slicing damage
-bool can_cut_meat(const item_def &item)
+bool weapon_is_slicing(const item_def &item)
{
return _does_damage_type(item, DAM_SLICE);
}
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index 165c8f0..022467d 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -153,7 +153,7 @@ bool food_is_veggie(int food_type) PURE;
bool food_is_veggie(const item_def &item) PURE;
int food_value(const item_def &item) PURE;
int food_turns(const item_def &item) PURE;
-bool can_cut_meat(const item_def &item) PURE;
+bool weapon_is_slicing(const item_def &item) PURE;
bool food_is_rotten(const item_def &item) PURE;
bool is_fruit(const item_def &item) PURE;
diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc
index 22df765..802f265 100644
--- a/crawl-ref/source/l_item.cc
+++ b/crawl-ref/source/l_item.cc
@@ -562,12 +562,12 @@ IDEF(is_melded)
return 1;
}
-IDEF(can_cut_meat)
+IDEF(weapon_is_slicing)
{
if (!item || !item->defined())
return 0;
- lua_pushboolean(ls, can_cut_meat(*item));
+ lua_pushboolean(ls, weapon_is_slicing(*item));
return 1;
}
@@ -1074,7 +1074,7 @@ static ItemAccessor item_attrs[] =
{ "is_throwable", l_item_is_throwable },
{ "dropped", l_item_dropped },
{ "is_melded", l_item_is_melded },
- { "can_cut_meat", l_item_can_cut_meat },
+ { "weapon_is_slicing", l_item_weapon_is_slicing },
{ "is_bad_food", l_item_is_bad_food },
{ "is_useless", l_item_is_useless },
{ "pluses", l_item_pluses },
diff --git a/crawl-ref/source/mon-ench.cc b/crawl-ref/source/mon-ench.cc
index eef0344..b0b6084 100644
--- a/crawl-ref/source/mon-ench.cc
+++ b/crawl-ref/source/mon-ench.cc
@@ -1261,7 +1261,7 @@ void monster::apply_enchantment(const mon_enchant &me)
{
damage += one_chance_in(3);
- if (can_cut_meat(mitm[inv[MSLOT_WEAPON]]))
+ if (weapon_is_slicing(mitm[inv[MSLOT_WEAPON]]))
damage++;
}
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index 10c1254..642820d 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -1233,7 +1233,7 @@ static int damage_or_escape_net(int hold)
// your weapon may damage the net, max. bonus of 2
if (you.weapon())
{
- if (can_cut_meat(*you.weapon()))
+ if (weapon_is_slicing(*you.weapon()))
damage++;
int brand = get_weapon_brand(*you.weapon());
@@ -1333,7 +1333,7 @@ void free_self_from_net()
// 8 turns.
bool can_slice =
(you.form == TRAN_BLADE_HANDS)
- || (you.weapon() && can_cut_meat(*you.weapon()));
+ || (you.weapon() && weapon_is_slicing(*you.weapon()));
int damage = -do_what;
--
1.8.3-rc3
combined-butchering-fixes.patch [^] (50,620 bytes) 2013-08-10 06:19 [Show Content] [Hide Content]From efe9cd9e594954b4bb80b92f9783f564a13b3c7e Mon Sep 17 00:00:00 2001
From: cjo <cjo@ulyco.com>
Date: Tue, 6 Aug 2013 11:02:43 -0700
Subject: [PATCH 1/4] Do not take gloves off to butcher.
Remove obsolete code concerning removal of gloves for butchering.
Now that all players have a butchering knife, it does not make
sense for unarmed characters to take gloves off to butcher, so
this code can be removed.
---
crawl-ref/source/food.cc | 58 +++++++++-------------------------------------
1 file changed, 11 insertions(+), 47 deletions(-)
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 60a1c87..f423981 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -227,30 +227,13 @@ void weapon_switch(int targ)
you.turn_is_over = true;
}
-static bool _prepare_butchery(bool can_butcher, bool removed_gloves,
- bool wpn_switch)
+static bool _prepare_butchery(bool can_butcher, bool wpn_switch)
{
// No preparation necessary.
if (can_butcher)
return true;
- // 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)
- {
- // Actually take off the gloves; this creates a delay. We
- // assume later on that gloves have a 1-turn takeoff delay!
- if (!takeoff_armour(you.equip[EQ_GLOVES]))
- return false;
-
- // Ensure that the gloves are taken off by now by finishing the
- // DELAY_ARMOUR_OFF delay started by takeoff_armour() above.
- // FIXME: get rid of this hack!
- finish_last_delay();
- }
+ ASSERT(wpn_switch);
if (wpn_switch
&& !wield_weapon(true, SLOT_BARE_HANDS, false, true, false, false))
@@ -329,8 +312,7 @@ static bool _corpse_butchery(int corpse_id, int butcher_tool,
return true;
}
-static void _terminate_butchery(bool wpn_switch, bool removed_gloves,
- int old_weapon, int old_gloves)
+static void _terminate_butchery(bool wpn_switch, int old_weapon)
{
// Switch weapon back.
if (wpn_switch && you.equip[EQ_WEAPON] != old_weapon
@@ -338,10 +320,6 @@ static void _terminate_butchery(bool wpn_switch, bool removed_gloves,
{
start_delay(DELAY_WEAPON_SWAP, 1, old_weapon);
}
-
- // Put on the removed gloves.
- if (removed_gloves && you.equip[EQ_GLOVES] != old_gloves)
- start_delay(DELAY_ARMOUR_ON, 1, old_gloves, 1);
}
static int _corpse_badness(corpse_effect_type ce, const item_def &item,
@@ -475,9 +453,6 @@ bool butchery(int which_corpse, bool bottle_blood)
|| you.has_claws())
&& !player_wearing_slot(EQ_GLOVES);
- bool gloved_butcher = (you.has_claws() && player_wearing_slot(EQ_GLOVES)
- && !you.inv[you.equip[EQ_GLOVES]].cursed());
-
bool weapon_butcher = you.weapon() && can_cut_meat(*you.weapon());
bool knife_butcher = !weapon_butcher && form_can_wield();
@@ -550,22 +525,15 @@ bool butchery(int which_corpse, bool bottle_blood)
}
int old_weapon = you.equip[EQ_WEAPON];
- int old_gloves = you.equip[EQ_GLOVES];
bool wpn_switch = false;
- bool removed_gloves = false;
if (!can_butcher)
- {
- if (you.weapon() && you.weapon()->cursed() && gloved_butcher)
- removed_gloves = true;
- else
- wpn_switch = true;
- }
+ wpn_switch = true;
int butcher_tool;
- if (barehand_butcher || removed_gloves)
+ if (barehand_butcher)
butcher_tool = SLOT_CLAWS;
else if (teeth_butcher)
butcher_tool = SLOT_TEETH;
@@ -590,11 +558,11 @@ bool butchery(int which_corpse, bool bottle_blood)
return false;
}
- if (!_prepare_butchery(can_butcher, removed_gloves, wpn_switch))
+ if (!_prepare_butchery(can_butcher, wpn_switch))
return false;
success = _corpse_butchery(corpse_id, butcher_tool, true, bottle_blood);
- _terminate_butchery(wpn_switch, removed_gloves, old_weapon, old_gloves);
+ _terminate_butchery(wpn_switch, old_weapon);
// Remind player of corpses in pack that could be butchered or
// bottled.
@@ -633,7 +601,7 @@ bool butchery(int which_corpse, bool bottle_blood)
corpse_id = selected[i].item->index();
if (!did_weap_swap)
{
- if (_prepare_butchery(can_butcher, removed_gloves, wpn_switch))
+ if (_prepare_butchery(can_butcher, wpn_switch))
did_weap_swap = true;
else
return false;
@@ -692,11 +660,8 @@ bool butchery(int which_corpse, bool bottle_blood)
case 'a':
if (!did_weap_swap)
{
- if (_prepare_butchery(can_butcher, removed_gloves,
- wpn_switch))
- {
+ if (_prepare_butchery(can_butcher, wpn_switch))
did_weap_swap = true;
- }
else
return false;
}
@@ -709,8 +674,7 @@ bool butchery(int which_corpse, bool bottle_blood)
case 'q':
CASE_ESCAPE
canned_msg(MSG_OK);
- _terminate_butchery(wpn_switch, removed_gloves, old_weapon,
- old_gloves);
+ _terminate_butchery(wpn_switch, old_weapon);
return false;
case '?':
@@ -744,7 +708,7 @@ bool butchery(int which_corpse, bool bottle_blood)
Options.confirm_butcher == CONFIRM_NEVER ? "suitable" : "else",
bottle_blood ? "bottle" : "butcher");
}
- _terminate_butchery(wpn_switch, removed_gloves, old_weapon, old_gloves);
+ _terminate_butchery(wpn_switch, old_weapon);
if (success)
{
--
1.7.10.4
From 7793960dc70f5337a72ddae6717af1343e3ad7c4 Mon Sep 17 00:00:00 2001
From: cjo <cjo@ulyco.com>
Date: Wed, 7 Aug 2013 14:16:05 -0700
Subject: [PATCH 2/4] Remove obsolete butchering code
Remove obsolete butchering code. Players can now butcher with blunt
weapons, but the code to make them swap away from blunt weapons was
never removed. Food.cc used custom functions for wielding and unwielding,
so removing those functions required changing various other files.
This patch also moves the process of choosing the butchering tool to
its own function, and removes the restriction on unarmed butchering
for players with no mutations.
---
crawl-ref/source/delay.cc | 130 +---------------------
crawl-ref/source/delay.h | 2 -
crawl-ref/source/enum.h | 4 +-
crawl-ref/source/files.cc | 5 -
crawl-ref/source/food.cc | 220 +++++++++-----------------------------
crawl-ref/source/hints.cc | 43 +-------
crawl-ref/source/itemprop.cc | 2 +
crawl-ref/source/melee_attack.cc | 9 --
crawl-ref/source/spl-transloc.cc | 2 -
crawl-ref/source/transform.cc | 3 -
10 files changed, 58 insertions(+), 362 deletions(-)
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 543a070..57bd4e0 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -161,9 +161,6 @@ void start_delay(delay_type type, int turns, int parm1, int parm2, int parm3)
delay.started = false;
// Paranoia
- if (type == DELAY_WEAPON_SWAP)
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
-
if (delay_is_run(type))
clear_travel_trail();
@@ -179,8 +176,6 @@ void start_delay(delay_type type, int turns, int parm1, int parm2, int parm3)
_push_delay(delay);
}
-static void _maybe_interrupt_swap(bool force_unsafe = false);
-
void stop_delay(bool stop_stair_travel, bool force_unsafe)
{
if (you.delay_queue.empty())
@@ -226,7 +221,6 @@ void stop_delay(bool stop_stair_travel, bool force_unsafe)
_pop_delay();
- _maybe_interrupt_swap(force_unsafe);
break;
}
case DELAY_MEMORISE:
@@ -360,7 +354,6 @@ void stop_delay(bool stop_stair_travel, bool force_unsafe)
}
break;
- case DELAY_WEAPON_SWAP: // one turn... too much trouble
case DELAY_DROP_ITEM: // one turn... only used for easy armour drops
case DELAY_JEWELLERY_ON: // one turn
case DELAY_UNINTERRUPTIBLE: // never stoppable
@@ -391,116 +384,6 @@ void maybe_clear_weapon_swap()
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
-void handle_interrupted_swap(bool swap_if_safe, bool force_unsafe)
-{
- if (!you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
- || !you_tran_can_wear(EQ_WEAPON) || you.cannot_act() || you.berserk())
- {
- return;
- }
-
- // Decrease value by 1. (0 means attribute is false, 1 = a, 2 = b, ...)
- int weap = you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] - 1;
- if (weap == ENDOFPACK)
- weap = -1;
-
- const bool safe = i_feel_safe() && !force_unsafe;
- const bool prompt = Options.prompt_for_swap && !safe;
- const delay_type delay = current_delay_action();
-
- const char* prompt_str = "Switch back to main weapon?";
-
- // If we're going to prompt then update the window so the player can
- // see what the monsters are.
- if (prompt)
- viewwindow();
-
- if (delay == DELAY_WEAPON_SWAP)
- die("handle_interrupted_swap() called while already swapping weapons");
- else if (!you.turn_is_over
- && (delay == DELAY_ASCENDING_STAIRS
- || delay == DELAY_DESCENDING_STAIRS))
- {
- // We just arrived on the level, let rest of function do its stuff.
- ;
- }
- else if (you.turn_is_over && delay == DELAY_NOT_DELAYED)
- {
- // Turn is over, set up a delay to do swapping next turn.
- if (prompt && yesno(prompt_str, true, 'n', true, false)
- || safe && swap_if_safe)
- {
- if (weap == -1 || check_warning_inscriptions(you.inv[weap], OPER_WIELD))
- start_delay(DELAY_WEAPON_SWAP, 1, weap);
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
- }
- return;
- }
- else if (delay != DELAY_NOT_DELAYED)
- {
- // If ATTR_WEAPON_SWAP_INTERRUPTED is set while a corpse is being
- // butchered/bottled/offered, then fake a weapon swap delay.
- if (_is_butcher_delay(delay)
- && (safe || prompt && yesno(prompt_str, true, 'n', true, false)))
- {
- if (weap == -1 || check_warning_inscriptions(you.inv[weap], OPER_WIELD))
- start_delay(DELAY_WEAPON_SWAP, 1, weap);
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
- }
- return;
- }
-
- if (safe)
- {
- if (!swap_if_safe)
- return;
- }
- else if (!prompt || !yesno(prompt_str, true, 'n', true, false))
- return;
-
- if (weap == -1 || check_warning_inscriptions(you.inv[weap], OPER_WIELD))
- {
- weapon_switch(weap);
- print_stats();
- }
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
-}
-
-static void _maybe_interrupt_swap(bool force_unsafe)
-{
- bool butcher_swap_setup = false;
- int butcher_swap_weapon = 0;
-
- for (unsigned int i = 1; i < you.delay_queue.size(); ++i)
- if (you.delay_queue[i].type == DELAY_WEAPON_SWAP)
- {
- butcher_swap_weapon = you.delay_queue[i].parm1;
- butcher_swap_setup = true;
- break;
- }
-
- if (!butcher_swap_setup && delays_cleared[DELAY_WEAPON_SWAP] > 0)
- {
- butcher_swap_setup = true;
- butcher_swap_weapon = cleared_delays_parm1[DELAY_WEAPON_SWAP];
- }
-
- if (butcher_swap_setup)
- {
- // Use weapon slot + 1, so weapon slot 'a' (== 0) doesn't
- // return false when checking if
- // you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED].
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
- = (butcher_swap_weapon == -1 ? ENDOFPACK
- : butcher_swap_weapon) + 1;
-
- // Possibly prompt if user wants to switch back from
- // butchering tool in order to use their normal weapon to
- // fight the interrupting monster.
- handle_interrupted_swap(true, force_unsafe);
- }
-}
-
bool you_are_delayed(void)
{
return !you.delay_queue.empty();
@@ -659,6 +542,7 @@ void handle_delay()
case SLOT_BUTCHERING_KNIFE: tool = "knife"; break;
case SLOT_CLAWS: tool = "claws"; break;
case SLOT_TEETH: tool = "teeth"; break;
+ case SLOT_BARE_HANDS: tool = "bare hands"; break;
case SLOT_BIRDIE: tool = "beak and talons"; break;
default: tool = you.inv[delay.parm3].name(DESC_QUALNAME);
}
@@ -861,7 +745,6 @@ void handle_delay()
break;
case DELAY_JEWELLERY_ON:
- case DELAY_WEAPON_SWAP:
// These are 1-turn delays where the time cost is handled
// in _finish_delay().
// FIXME: get rid of this hack!
@@ -924,11 +807,6 @@ static void _finish_delay(const delay_queue_item &delay)
{
switch (delay.type)
{
- case DELAY_WEAPON_SWAP:
- weapon_switch(delay.parm1);
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
- break;
-
case DELAY_JEWELLERY_ON:
puton_ring(delay.parm1);
break;
@@ -1165,7 +1043,6 @@ static void _finish_delay(const delay_queue_item &delay)
autopickup();
}
- _maybe_interrupt_swap();
}
else
{
@@ -1455,9 +1332,8 @@ void run_macro(const char *macroname)
bool is_delay_interruptible(delay_type delay)
{
- return !(delay == DELAY_EAT || delay == DELAY_WEAPON_SWAP
- || delay == DELAY_DROP_ITEM || delay == DELAY_JEWELLERY_ON
- || delay == DELAY_UNINTERRUPTIBLE);
+ return !(delay == DELAY_EAT || delay == DELAY_DROP_ITEM
+ || delay == DELAY_JEWELLERY_ON || delay == DELAY_UNINTERRUPTIBLE);
}
// Returns TRUE if the delay should be interrupted, MAYBE if the user function
diff --git a/crawl-ref/source/delay.h b/crawl-ref/source/delay.h
index 25dd20a..4692dfa 100644
--- a/crawl-ref/source/delay.h
+++ b/crawl-ref/source/delay.h
@@ -81,8 +81,6 @@ bool player_stair_delay();
bool already_learning_spell(int spell);
void stop_butcher_delay();
void maybe_clear_weapon_swap();
-void handle_interrupted_swap(bool swap_if_safe = false,
- bool force_unsafe = false);
void clear_macro_process_key_delay();
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index a2574e3..0b22b16 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1059,7 +1059,9 @@ enum delay_type
DELAY_MEMORISE,
DELAY_BUTCHER,
DELAY_BOTTLE_BLOOD,
- DELAY_WEAPON_SWAP,
+#if TAG_MAJOR_VERSION == 34
+ DELAY_WEAPON_SWAP, // was specific to butchering code
+#endif
DELAY_PASSWALL,
DELAY_DROP_ITEM,
DELAY_MULTIDROP,
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index de5379f..7acc8ac 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1506,11 +1506,6 @@ bool load_level(dungeon_feature_type stair_taken, load_mode_type load_mode,
}
}
- // If butchering was interrupted by switching levels (banishment)
- // then switch back from butchering tool if there's no hostiles
- // nearby.
- handle_interrupted_swap(true);
-
// Forget about interrupted butchering, since we probably aren't going
// to get back to the corpse in time to finish things.
// But do not reset the weapon swap if we swapped weapons
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index f423981..275b945 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -62,7 +62,8 @@ static void _eating(item_def &food);
static void _describe_food_change(int hunger_increment);
static bool _vampire_consume_corpse(int slot, bool invent);
static void _heal_from_food(int hp_amt, bool unrot = false);
-
+int _choose_butcher_tool();
+bool _can_butcher();
/*
* BEGIN PUBLIC FUNCTIONS
*/
@@ -160,91 +161,6 @@ bool you_foodless_normally()
|| you.species == SP_DJINNI;
}
-/**
- * More of a "weapon_switch back from butchering" function, switching
- * to a weapon is done using the wield_weapon() code.
- * Special cases like staves of power or other special weps are taken
- * care of by calling wield_effects(). {gdl}
- */
-void weapon_switch(int targ)
-{
- // Give the player an option to abort.
- if (you.weapon() && !check_old_item_warning(*you.weapon(), OPER_WIELD))
- return;
-
- if (targ == -1) // Unarmed Combat.
- {
- // Already unarmed?
- if (!you.weapon())
- return;
-
- mpr("You switch back to your bare hands.");
- }
- else
- {
- // Possibly not valid anymore (dropped, etc.).
- if (!you.inv[targ].defined())
- return;
-
- // Already wielding this weapon?
- if (you.equip[EQ_WEAPON] == you.inv[targ].link)
- return;
-
- if (!can_wield(&you.inv[targ]))
- {
- mprf("Not switching back to %s.",
- you.inv[targ].name(DESC_INVENTORY).c_str());
- return;
- }
- }
-
- // Unwield the old weapon and wield the new.
- // XXX This is a pretty dangerous hack; I don't like it.--GDL
- //
- // Well yeah, but that's because interacting with the wielding
- // code is a mess... this whole function's purpose was to
- // isolate this hack until there's a proper way to do things. -- bwr
- if (you.weapon())
- unwield_item(false);
-
- if (targ != -1)
- equip_item(EQ_WEAPON, targ, false);
-
- if (Options.chunks_autopickup || you.species == SP_VAMPIRE)
- autopickup();
-
- // Same amount of time as normal wielding.
- // FIXME: this duplicated code is begging for a bug.
- if (you.weapon())
- you.time_taken /= 2;
- else // Swapping to empty hands is faster.
- {
- you.time_taken *= 3;
- you.time_taken /= 10;
- }
-
- you.wield_change = true;
- you.turn_is_over = true;
-}
-
-static bool _prepare_butchery(bool can_butcher, bool wpn_switch)
-{
- // No preparation necessary.
- if (can_butcher)
- return true;
-
- ASSERT(wpn_switch);
-
- if (wpn_switch
- && !wield_weapon(true, SLOT_BARE_HANDS, false, true, false, false))
- {
- return false;
- }
-
- // Switched to a good butchering tool.
- return true;
-}
-
static bool _should_butcher(int corpse_id, bool bottle_blood = false)
{
const item_def &corpse = mitm[corpse_id];
@@ -295,7 +211,8 @@ static bool _corpse_butchery(int corpse_id, int butcher_tool,
if (first_corpse)
mitm[corpse_id].plus2++;
- int work_req = max(0, 4 - mitm[corpse_id].plus2);
+ int work_req = 5; // all butchering will take 5 turns
+ // int work_req = max(0, 4 - mitm[corpse_id].plus2);
delay_type dtype = DELAY_BUTCHER;
// Sanity checks.
@@ -312,16 +229,6 @@ static bool _corpse_butchery(int corpse_id, int butcher_tool,
return true;
}
-static void _terminate_butchery(bool wpn_switch, int old_weapon)
-{
- // Switch weapon back.
- if (wpn_switch && you.equip[EQ_WEAPON] != old_weapon
- && (!you.weapon() || !you.weapon()->cursed()))
- {
- start_delay(DELAY_WEAPON_SWAP, 1, old_weapon);
- }
-}
-
static int _corpse_badness(corpse_effect_type ce, const item_def &item,
bool wants_any)
{
@@ -427,54 +334,64 @@ static string _butcher_menu_title(const Menu *menu, const string &oldt)
}
#endif
-bool butchery(int which_corpse, bool bottle_blood)
+bool _can_butcher()
{
- if (you.visible_igrd(you.pos()) == NON_ITEM)
+ // You are transmuted into a form which can not butcher.
+ // cjo: I removed restrictions on butchering while berserk,
+ // which leaves only one case for this function.
+ if (you.form != TRAN_NONE
+ && !form_can_wield() && ! form_can_butcher_barehanded())
{
- if (!_have_corpses_in_pack(false, bottle_blood))
- mpr("There isn't anything here!");
+ mpr("You can not butcher while in this form!");
return false;
}
+ return true;
+}
- // XXX these restrictions are a huge mess, leading to a lot of
- // complicated code and very little in the way of actual fun.
- // We should rip them out once we figure out how. (SamB)
-
+int _choose_butcher_tool()
+{
// Vampires' fangs are optimised for biting, not for tearing flesh.
// (Not that they really need to.) Other species with this mutation
// might still benefit from it.
- bool teeth_butcher = (you.has_usable_fangs() == 3
- && you.species != SP_VAMPIRE);
-
- bool birdie_butcher = (player_mutation_level(MUT_BEAK)
- && player_mutation_level(MUT_TALONS));
-
- bool barehand_butcher = (form_can_butcher_barehanded(you.form)
- || you.has_claws())
- && !player_wearing_slot(EQ_GLOVES);
-
- bool weapon_butcher = you.weapon() && can_cut_meat(*you.weapon());
-
- bool knife_butcher = !weapon_butcher && form_can_wield();
+ int butcher_tool = 0;
+ if((you.has_usable_fangs() == 3) && you.species != SP_VAMPIRE)
+ butcher_tool = SLOT_TEETH;
+ else if (player_mutation_level(MUT_BEAK) && player_mutation_level(MUT_TALONS))
+ butcher_tool = SLOT_BIRDIE;
+ else if ((form_can_butcher_barehanded(you.form) || you.has_claws())
+ && !player_wearing_slot(EQ_GLOVES))
+ {
+ butcher_tool = SLOT_CLAWS;
+ }
+ else if (you.form != TRAN_NONE && form_can_butcher_barehanded())
+ butcher_tool = SLOT_CLAWS;
+ else if(you.weapon())
+ butcher_tool = you.weapon()->link;
+ else if(!you.berserk() && form_can_wield())
+ butcher_tool = SLOT_BUTCHERING_KNIFE;
+ else if (you.berserk())
+ butcher_tool = SLOT_BARE_HANDS;
+ else
+ butcher_tool = SLOT_BUTCHERING_KNIFE;
- bool can_butcher = (teeth_butcher || barehand_butcher
- || birdie_butcher
- || weapon_butcher
- || knife_butcher);
+ return butcher_tool;
+}
- // It makes more sense that you first find out if there's anything
- // to butcher, *then* decide to actually butcher it.
- // The old code did it the other way.
- if (!can_butcher && you.berserk())
+bool butchery(int which_corpse, bool bottle_blood)
+{
+ // nothing to butcher
+ if (you.visible_igrd(you.pos()) == NON_ITEM)
{
- // NB: Normally can't get here with bottle_blood == true because it's an
- // ability and thus also blocked when berserking. If bottle_blood was
- // somehow true at the point, the following message would be wrong and
- // (even worse) bottling success would depend on can_butcher == true.
- mpr("You are too berserk to search for a butchering tool!");
+ if (!_have_corpses_in_pack(false, bottle_blood))
+ mpr("There isn't anything here!");
return false;
}
+ if(!_can_butcher())
+ return false;
+
+ int butcher_tool = _choose_butcher_tool();
+
bool wants_any = you.has_spell(SPELL_SIMULACRUM)
|| you.has_spell(SPELL_SUBLIMATION_OF_BLOOD);
@@ -524,26 +441,6 @@ bool butchery(int which_corpse, bool bottle_blood)
return false;
}
- int old_weapon = you.equip[EQ_WEAPON];
-
- bool wpn_switch = false;
-
- if (!can_butcher)
- wpn_switch = true;
-
- int butcher_tool;
-
- if (barehand_butcher)
- butcher_tool = SLOT_CLAWS;
- else if (teeth_butcher)
- butcher_tool = SLOT_TEETH;
- else if (birdie_butcher)
- butcher_tool = SLOT_BIRDIE;
- else if (wpn_switch || knife_butcher)
- butcher_tool = SLOT_BUTCHERING_KNIFE;
- else
- butcher_tool = you.weapon()->link;
-
// Butcher pre-chosen corpse, if found, or if there is only one corpse.
bool success = false;
if (prechosen && corpse_id == which_corpse
@@ -558,11 +455,7 @@ bool butchery(int which_corpse, bool bottle_blood)
return false;
}
- if (!_prepare_butchery(can_butcher, wpn_switch))
- return false;
-
success = _corpse_butchery(corpse_id, butcher_tool, true, bottle_blood);
- _terminate_butchery(wpn_switch, old_weapon);
// Remind player of corpses in pack that could be butchered or
// bottled.
@@ -573,7 +466,6 @@ bool butchery(int which_corpse, bool bottle_blood)
// Now pick what you want to butcher. This is only a problem
// if there are several corpses on the square.
bool butcher_all = false;
- bool did_weap_swap = false;
bool first_corpse = true;
#ifdef TOUCH_UI
vector<const item_def*> meat;
@@ -599,13 +491,6 @@ bool butchery(int which_corpse, bool bottle_blood)
for (int i = 0, count = selected.size(); i < count; ++i)
{
corpse_id = selected[i].item->index();
- if (!did_weap_swap)
- {
- if (_prepare_butchery(can_butcher, wpn_switch))
- did_weap_swap = true;
- else
- return false;
- }
if (_corpse_butchery(corpse_id, butcher_tool, first_corpse,
bottle_blood))
{
@@ -658,13 +543,6 @@ bool butchery(int which_corpse, bool bottle_blood)
case 'c':
case 'd':
case 'a':
- if (!did_weap_swap)
- {
- if (_prepare_butchery(can_butcher, wpn_switch))
- did_weap_swap = true;
- else
- return false;
- }
corpse_id = si->index();
if (keyin == 'a')
@@ -674,7 +552,6 @@ bool butchery(int which_corpse, bool bottle_blood)
case 'q':
CASE_ESCAPE
canned_msg(MSG_OK);
- _terminate_butchery(wpn_switch, old_weapon);
return false;
case '?':
@@ -708,7 +585,6 @@ bool butchery(int which_corpse, bool bottle_blood)
Options.confirm_butcher == CONFIRM_NEVER ? "suitable" : "else",
bottle_blood ? "bottle" : "butcher");
}
- _terminate_butchery(wpn_switch, old_weapon);
if (success)
{
diff --git a/crawl-ref/source/hints.cc b/crawl-ref/source/hints.cc
index 084749c..5899cd7 100644
--- a/crawl-ref/source/hints.cc
+++ b/crawl-ref/source/hints.cc
@@ -1020,18 +1020,6 @@ void hints_first_item(const item_def &item)
glyph_to_tagstr(get_item_glyph(&item)));
}
-// If the player is wielding a cursed non-slicing weapon then butchery
-// isn't currently possible.
-static bool _cant_butcher()
-{
- const item_def *wpn = you.weapon();
-
- if (!wpn || wpn->base_type != OBJ_WEAPONS)
- return false;
-
- return (wpn->cursed() && !can_cut_meat(*wpn));
-}
-
static string _describe_portal(const coord_def &gc)
{
const string desc = feature_description_at(gc);
@@ -1410,13 +1398,6 @@ void learned_something_new(hints_event_type seen_what, coord_def gc)
"can <w>%</w>hop it up";
cmd.push_back(CMD_BUTCHER);
- if (_cant_butcher())
- {
- text << " (though unfortunately you can't do that right now, "
- "since the cursed weapon you're wielding can't slice up "
- "meat, and you can't let go of it to wield your pocket "
- "knife)";
- }
text << ". Once hungry you can then <w>%</w>at the resulting chunks "
"(though they may not be healthful).";
cmd.push_back(CMD_EAT);
@@ -2022,24 +2003,10 @@ void learned_something_new(hints_event_type seen_what, coord_def gc)
case HINT_YOU_HUNGRY:
text << "There are two ways to overcome hunger: food you started "
"with or found, and self-made chunks from corpses. To get the "
- "latter, all you need to do is <w>%</w>hop up a corpse. ";
+ "latter, all you need to do is <w>%</w>hop up a corpse. "
+ "Try to dine on chunks in order to save permanent food.";
cmd.push_back(CMD_BUTCHER);
- if (_cant_butcher())
- {
- text << "Unfortunately you can't butcher corpses right now, "
- "since the cursed weapon you're wielding can't slice up "
- "meat, and you can't let go of it to wield your pocket "
- "knife. ";
- }
- else
- {
- text << "Luckily, all adventurers carry a pocket knife with them "
- "which is perfect for butchering. ";
- }
-
- text << "Try to dine on chunks in order to save permanent food.";
-
if (Hints.hints_type == HINT_BERSERK_CHAR)
text << "\nNote that you cannot Berserk while very hungry or worse.";
break;
@@ -2130,12 +2097,6 @@ void learned_something_new(hints_event_type seen_what, coord_def gc)
"<w>%</w>hop up";
cmd.push_back(CMD_BUTCHER);
- if (_cant_butcher())
- {
- text << "(or which you <w>could</w> chop up if it weren't for "
- "the fact that you can't let go of your cursed "
- "non-chopping weapon)";
- }
text << ". One or more chunks will appear that you can then "
"<w>%</w>at. Beware that some chunks may be, sometimes or "
"always, hazardous. You can find out whether that might be the "
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index f21dc08..40fcb0a 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -2138,6 +2138,8 @@ int food_turns(const item_def &item)
return max(1, item_mass(item) / 100); // TRAN_JELLY
}
+// cjo: this no longer relates to butchering, but is still used
+// in several places to check for slicing damage
bool can_cut_meat(const item_def &item)
{
return _does_damage_type(item, DAM_SLICE);
diff --git a/crawl-ref/source/melee_attack.cc b/crawl-ref/source/melee_attack.cc
index 557ee07..da05bd3 100644
--- a/crawl-ref/source/melee_attack.cc
+++ b/crawl-ref/source/melee_attack.cc
@@ -1017,15 +1017,6 @@ bool melee_attack::attack()
do_miscast();
}
- else
- {
- // Invisible monster might have interrupted butchering.
- if (you_are_delayed() && defender->is_player()
- && perceived_attack && !attacker_visible)
- {
- handle_interrupted_swap(false, true);
- }
- }
adjust_noise();
// don't crash on banishment
diff --git a/crawl-ref/source/spl-transloc.cc b/crawl-ref/source/spl-transloc.cc
index b491540..f02213b 100644
--- a/crawl-ref/source/spl-transloc.cc
+++ b/crawl-ref/source/spl-transloc.cc
@@ -447,8 +447,6 @@ static void _handle_teleport_update(bool large_change, const coord_def old_pos)
else if (see_cell)
behaviour_event(*mi, ME_EVAL);
}
-
- handle_interrupted_swap(true);
}
#ifdef USE_TILE
diff --git a/crawl-ref/source/transform.cc b/crawl-ref/source/transform.cc
index e62cf4b..1b1ecbd 100644
--- a/crawl-ref/source/transform.cc
+++ b/crawl-ref/source/transform.cc
@@ -1367,9 +1367,6 @@ void untransform(bool skip_wielding, bool skip_move)
you.stop_being_constricted();
}
- if (!skip_wielding)
- handle_interrupted_swap(true, false);
-
you.turn_is_over = true;
if (you.transform_uncancellable)
you.transform_uncancellable = false;
--
1.7.10.4
From 81c4aacb7e945ef1d1017ac33e76ce64ee74ffb7 Mon Sep 17 00:00:00 2001
From: cjo <cjo@ulyco.com>
Date: Thu, 8 Aug 2013 15:42:53 -0700
Subject: [PATCH 3/4] Allow unarmed butchering, remove hypothetical knife
This patch allows unarmed butchering and removes the
hypothetical butcher knife as no longer necessary.
It removes mention of a weapon from the butchering
message (since that raises awkward questions about
how a whip, etc, can be used to chop things). It
also renames a function (new name: weapon_is_slicing).
---
crawl-ref/source/dat/descript/ability.txt | 3 +--
crawl-ref/source/delay.cc | 27 ++++++++++++++++-----------
crawl-ref/source/food.cc | 21 ++++++---------------
crawl-ref/source/invent.cc | 2 +-
crawl-ref/source/invent.h | 1 -
crawl-ref/source/itemprop.cc | 2 +-
crawl-ref/source/itemprop.h | 2 +-
crawl-ref/source/l_item.cc | 6 +++---
crawl-ref/source/mon-ench.cc | 2 +-
crawl-ref/source/traps.cc | 4 ++--
10 files changed, 32 insertions(+), 38 deletions(-)
diff --git a/crawl-ref/source/dat/descript/ability.txt b/crawl-ref/source/dat/descript/ability.txt
index 209d82b..ba5967e 100644
--- a/crawl-ref/source/dat/descript/ability.txt
+++ b/crawl-ref/source/dat/descript/ability.txt
@@ -60,8 +60,7 @@ weight of your possessions or some disability would normally drag you down.
Bottle Blood
At experience level 6 and higher, Vampires can bottle the blood from non-rotten
-and blood-containing corpses they are standing on. Doing so requires the
-capability of wielding your knife, as is the case for butchering.
+and blood-containing corpses they are standing on.
%%%%
Spit Acid
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 57bd4e0..95b2de8 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -536,19 +536,25 @@ void handle_delay()
}
else
{
- string tool;
+ string act, tool;
switch (delay.parm3)
{
- case SLOT_BUTCHERING_KNIFE: tool = "knife"; break;
- case SLOT_CLAWS: tool = "claws"; break;
- case SLOT_TEETH: tool = "teeth"; break;
- case SLOT_BARE_HANDS: tool = "bare hands"; break;
- case SLOT_BIRDIE: tool = "beak and talons"; break;
- default: tool = you.inv[delay.parm3].name(DESC_QUALNAME);
+ case SLOT_CLAWS:
+ act = "slicing up"; tool = " with your claws";
+ break;
+ case SLOT_TEETH:
+ act = "tearing up"; tool = " with your teeth";
+ break;
+ case SLOT_BIRDIE:
+ act = "tearing up"; tool = " with your beak and talons";
+ break;
+ default:
+ act = "butchering"; tool = "";
+ break;
}
mprf(MSGCH_MULTITURN_ACTION,
- "You start butchering %s with your %s.",
- mitm[delay.parm1].name(DESC_THE).c_str(), tool.c_str());
+ "You start %s the %s%s.",
+ act.c_str(), mitm[delay.parm1].name(DESC_THE).c_str(), tool.c_str());
}
break;
@@ -989,8 +995,7 @@ static void _finish_delay(const delay_queue_item &delay)
}
else
{
- mprf("You finish %s %s into pieces.",
- delay.parm3 <= SLOT_CLAWS ? "ripping" : "chopping",
+ mprf("You finish butchering the %s.",
mitm[delay.parm1].name(DESC_THE).c_str());
if (god_hates_cannibalism(you.religion)
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 275b945..85b1931 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -350,29 +350,20 @@ bool _can_butcher()
int _choose_butcher_tool()
{
- // Vampires' fangs are optimised for biting, not for tearing flesh.
- // (Not that they really need to.) Other species with this mutation
- // might still benefit from it.
+ // This relates to special messages for mutations which are used to butcher.
+ // It has no effect other than flavour.
+
int butcher_tool = 0;
+ // Vampires' fangs are optimised for biting, not for tearing flesh.
if((you.has_usable_fangs() == 3) && you.species != SP_VAMPIRE)
butcher_tool = SLOT_TEETH;
else if (player_mutation_level(MUT_BEAK) && player_mutation_level(MUT_TALONS))
butcher_tool = SLOT_BIRDIE;
- else if ((form_can_butcher_barehanded(you.form) || you.has_claws())
- && !player_wearing_slot(EQ_GLOVES))
+ else if (form_can_butcher_barehanded(you.form)
+ || (you.has_claws() && !player_wearing_slot(EQ_GLOVES)))
{
butcher_tool = SLOT_CLAWS;
}
- else if (you.form != TRAN_NONE && form_can_butcher_barehanded())
- butcher_tool = SLOT_CLAWS;
- else if(you.weapon())
- butcher_tool = you.weapon()->link;
- else if(!you.berserk() && form_can_wield())
- butcher_tool = SLOT_BUTCHERING_KNIFE;
- else if (you.berserk())
- butcher_tool = SLOT_BARE_HANDS;
- else
- butcher_tool = SLOT_BUTCHERING_KNIFE;
return butcher_tool;
}
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index b018553..5efb8d2 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -1173,7 +1173,7 @@ static bool _item_class_selected(const item_def &i, int selector)
return item_is_wieldable(i);
case OSEL_BUTCHERY:
- return (itype == OBJ_WEAPONS && can_cut_meat(i));
+ return (itype == OBJ_WEAPONS && weapon_is_slicing(i));
case OBJ_SCROLLS:
return (itype == OBJ_SCROLLS
diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h
index fbe89c4..72ade34 100644
--- a/crawl-ref/source/invent.h
+++ b/crawl-ref/source/invent.h
@@ -36,7 +36,6 @@ enum object_selector
#define SLOT_BARE_HANDS -2
// Only used for butchering messages
-#define SLOT_BUTCHERING_KNIFE -3
#define SLOT_CLAWS -4
#define SLOT_TEETH -5
#define SLOT_BIRDIE -6
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 40fcb0a..2c90c52 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -2140,7 +2140,7 @@ int food_turns(const item_def &item)
// cjo: this no longer relates to butchering, but is still used
// in several places to check for slicing damage
-bool can_cut_meat(const item_def &item)
+bool weapon_is_slicing(const item_def &item)
{
return _does_damage_type(item, DAM_SLICE);
}
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index 165c8f0..022467d 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -153,7 +153,7 @@ bool food_is_veggie(int food_type) PURE;
bool food_is_veggie(const item_def &item) PURE;
int food_value(const item_def &item) PURE;
int food_turns(const item_def &item) PURE;
-bool can_cut_meat(const item_def &item) PURE;
+bool weapon_is_slicing(const item_def &item) PURE;
bool food_is_rotten(const item_def &item) PURE;
bool is_fruit(const item_def &item) PURE;
diff --git a/crawl-ref/source/l_item.cc b/crawl-ref/source/l_item.cc
index 22df765..802f265 100644
--- a/crawl-ref/source/l_item.cc
+++ b/crawl-ref/source/l_item.cc
@@ -562,12 +562,12 @@ IDEF(is_melded)
return 1;
}
-IDEF(can_cut_meat)
+IDEF(weapon_is_slicing)
{
if (!item || !item->defined())
return 0;
- lua_pushboolean(ls, can_cut_meat(*item));
+ lua_pushboolean(ls, weapon_is_slicing(*item));
return 1;
}
@@ -1074,7 +1074,7 @@ static ItemAccessor item_attrs[] =
{ "is_throwable", l_item_is_throwable },
{ "dropped", l_item_dropped },
{ "is_melded", l_item_is_melded },
- { "can_cut_meat", l_item_can_cut_meat },
+ { "weapon_is_slicing", l_item_weapon_is_slicing },
{ "is_bad_food", l_item_is_bad_food },
{ "is_useless", l_item_is_useless },
{ "pluses", l_item_pluses },
diff --git a/crawl-ref/source/mon-ench.cc b/crawl-ref/source/mon-ench.cc
index eef0344..b0b6084 100644
--- a/crawl-ref/source/mon-ench.cc
+++ b/crawl-ref/source/mon-ench.cc
@@ -1261,7 +1261,7 @@ void monster::apply_enchantment(const mon_enchant &me)
{
damage += one_chance_in(3);
- if (can_cut_meat(mitm[inv[MSLOT_WEAPON]]))
+ if (weapon_is_slicing(mitm[inv[MSLOT_WEAPON]]))
damage++;
}
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index 10c1254..642820d 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -1233,7 +1233,7 @@ static int damage_or_escape_net(int hold)
// your weapon may damage the net, max. bonus of 2
if (you.weapon())
{
- if (can_cut_meat(*you.weapon()))
+ if (weapon_is_slicing(*you.weapon()))
damage++;
int brand = get_weapon_brand(*you.weapon());
@@ -1333,7 +1333,7 @@ void free_self_from_net()
// 8 turns.
bool can_slice =
(you.form == TRAN_BLADE_HANDS)
- || (you.weapon() && can_cut_meat(*you.weapon()));
+ || (you.weapon() && weapon_is_slicing(*you.weapon()));
int damage = -do_what;
--
1.7.10.4
From 69aee0cfe8f54904f7c29f27ad26bfa9186182d2 Mon Sep 17 00:00:00 2001
From: Neil Moore <neil@s-z.org>
Date: Sat, 10 Aug 2013 00:07:59 -0400
Subject: [PATCH 4/4] Remove the last vestiges of weapon swap interruption.
It could still be set when transforming to a no-wield form while
wielding a non-weapon, but the only remaining effects did nothing
when the item was not a weapon.
---
crawl-ref/source/delay.cc | 6 ------
crawl-ref/source/delay.h | 1 -
crawl-ref/source/enum.h | 8 +++++---
crawl-ref/source/fight.cc | 35 +++++------------------------------
crawl-ref/source/files.cc | 6 ------
crawl-ref/source/player-equip.cc | 3 ---
crawl-ref/source/player.cc | 7 ++-----
crawl-ref/source/transform.cc | 2 --
crawl-ref/source/travel.cc | 6 ------
9 files changed, 12 insertions(+), 62 deletions(-)
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 95b2de8..7583ea3 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -378,12 +378,6 @@ void stop_butcher_delay()
stop_delay();
}
-void maybe_clear_weapon_swap()
-{
- if (form_can_wield())
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
-}
-
bool you_are_delayed(void)
{
return !you.delay_queue.empty();
diff --git a/crawl-ref/source/delay.h b/crawl-ref/source/delay.h
index 4692dfa..e731b47 100644
--- a/crawl-ref/source/delay.h
+++ b/crawl-ref/source/delay.h
@@ -80,7 +80,6 @@ bool is_butchering();
bool player_stair_delay();
bool already_learning_spell(int spell);
void stop_butcher_delay();
-void maybe_clear_weapon_swap();
void clear_macro_process_key_delay();
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 0b22b16..aff648f 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -265,18 +265,20 @@ enum attribute_type
ATTR_DIVINE_VIGOUR, // strength of Ely's Divine Vigour
ATTR_DIVINE_STAMINA, // strength of Zin's Divine Stamina
ATTR_DIVINE_SHIELD, // strength of TSO's Divine Shield
- ATTR_WEAPON_SWAP_INTERRUPTED,
+#if TAG_MAJOR_VERSION == 34
+ ATTR_UNUSED1, // was ATTR_WEAPON_SWAP_INTERRUPTED
+#endif
ATTR_GOLD_FOUND,
ATTR_PURCHASES, // Gold amount spent at shops.
ATTR_DONATIONS, // Gold amount donated to Zin.
ATTR_MISC_SPENDING, // Spending for things like ziggurats.
#if TAG_MAJOR_VERSION == 34
- ATTR_UNUSED1, // was ATTR_RND_LVL_BOOKS
+ ATTR_UNUSED2, // was ATTR_RND_LVL_BOOKS
#endif
ATTR_NOISES, // A noisy artefact is equipped.
ATTR_SHADOWS, // Lantern of shadows effect.
#if TAG_MAJOR_VERSION == 34
- ATTR_UNUSED2, // was ATTR_FRUIT_FOUND
+ ATTR_UNUSED3, // was ATTR_FRUIT_FOUND
#endif
ATTR_FLIGHT_UNCANCELLABLE, // Potion of flight is in effect.
ATTR_INVIS_UNCANCELLABLE, // Potion/spell/wand of invis is in effect.
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 0c92d7c..0a86158 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -354,40 +354,15 @@ int resist_adjust_damage(actor *defender, beam_type flavour,
bool wielded_weapon_check(item_def *weapon, bool no_message)
{
- bool weapon_warning = false;
- bool unarmed_warning = false;
-
- if (weapon)
- {
- if (needs_handle_warning(*weapon, OPER_ATTACK)
- || !is_melee_weapon(*weapon))
- {
- weapon_warning = true;
- }
- }
- else if (you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
- && you_tran_can_wear(EQ_WEAPON))
- {
- const int weap = you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] - 1;
- const item_def &wpn = you.inv[weap];
- if (is_melee_weapon(wpn)
- && you.skill(weapon_skill(wpn)) > you.skill(SK_UNARMED_COMBAT))
- {
- unarmed_warning = true;
- }
- }
-
- if (!you.received_weapon_warning && !you.confused()
- && (weapon_warning || unarmed_warning))
+ if (weapon && (needs_handle_warning(*weapon, OPER_ATTACK)
+ || !is_melee_weapon(*weapon))
+ && !you.received_weapon_warning && !you.confused())
{
if (no_message)
return false;
- string prompt = "Really attack while ";
- if (unarmed_warning)
- prompt += "unarmed?";
- else
- prompt += "wielding " + weapon->name(DESC_YOUR) + "? ";
+ string prompt = "Really attack while wielding "
+ + weapon->name(DESC_YOUR) + "? ";
const bool result = yesno(prompt.c_str(), true, 'n');
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 7acc8ac..4667b72 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -1506,12 +1506,6 @@ bool load_level(dungeon_feature_type stair_taken, load_mode_type load_mode,
}
}
- // Forget about interrupted butchering, since we probably aren't going
- // to get back to the corpse in time to finish things.
- // But do not reset the weapon swap if we swapped weapons
- // because of a transformation.
- maybe_clear_weapon_swap();
-
ash_detect_portals(is_map_persistent());
}
// Initialize halos, etc.
diff --git a/crawl-ref/source/player-equip.cc b/crawl-ref/source/player-equip.cc
index 08d90ee..af02c2e 100644
--- a/crawl-ref/source/player-equip.cc
+++ b/crawl-ref/source/player-equip.cc
@@ -732,8 +732,6 @@ static void _equip_weapon_effect(item_def& item, bool showMsgs, bool unmeld)
if (showMsgs)
warn_shield_penalties();
-
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
static void _unequip_weapon_effect(item_def& item, bool showMsgs, bool meld)
@@ -1589,7 +1587,6 @@ bool unwield_item(bool showMsgs)
you.wield_change = true;
you.redraw_quiver = true;
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
return true;
}
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index e03ccbf..7eae3e5 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -906,9 +906,8 @@ bool player_weapon_wielded()
bool berserk_check_wielded_weapon()
{
const item_def * const wpn = you.weapon();
- if (wpn && (wpn->defined() && (!is_melee_weapon(*wpn)
- || needs_handle_warning(*wpn, OPER_ATTACK))
- || you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]))
+ if (wpn && wpn->defined() && (!is_melee_weapon(*wpn)
+ || needs_handle_warning(*wpn, OPER_ATTACK)))
{
string prompt = "Do you really want to go berserk while wielding "
+ wpn->name(DESC_YOUR) + "?";
@@ -918,8 +917,6 @@ bool berserk_check_wielded_weapon()
canned_msg(MSG_OK);
return false;
}
-
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
return true;
diff --git a/crawl-ref/source/transform.cc b/crawl-ref/source/transform.cc
index 1b1ecbd..c7edecf 100644
--- a/crawl-ref/source/transform.cc
+++ b/crawl-ref/source/transform.cc
@@ -273,10 +273,8 @@ static void _remove_equipment(const set<equipment_type>& removed,
{
if (e == EQ_WEAPON)
{
- const int slot = you.equip[EQ_WEAPON];
unwield_item(!you.berserk());
canned_msg(MSG_EMPTY_HANDED_NOW);
- you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = slot + 1;
}
else
unequip_item(e);
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index 1cf3f2f..176096e 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -2533,9 +2533,6 @@ static void _start_translevel_travel()
if (level_target.p.id.depth > 0)
{
- // Forget interrupted butchering.
- maybe_clear_weapon_swap();
-
you.running = RMODE_INTERLEVEL;
you.running.pos.reset();
last_stair.depth = -1;
@@ -3004,9 +3001,6 @@ void start_explore(bool grab_items)
if (!i_feel_safe(true, true))
return;
- // Forget interrupted butchering.
- maybe_clear_weapon_swap();
-
you.running = (grab_items ? RMODE_EXPLORE_GREEDY : RMODE_EXPLORE);
if (you.running == RMODE_EXPLORE_GREEDY && god_likes_items(you.religion, true))
--
1.7.10.4
|