summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-04 12:43:38 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-04 12:43:38 +0000
commitf51727efb9e6d576724304b659a8b1a12ee8a37b (patch)
treeb635c58004bf3d21e6a723ee68c420f085e1dd3b /crawl-ref
parentca72b70cd5ffb1e3e71512b6c457ad21ec20b71f (diff)
downloadcrawl-ref-f51727efb9e6d576724304b659a8b1a12ee8a37b.tar.gz
crawl-ref-f51727efb9e6d576724304b659a8b1a12ee8a37b.zip
[1730416] Warn player if not switching back to original weapon when butchery is
interrupted. Also tweaked delay handling, since delays (particularly stacked delays) were taking more turns than intended. Changes to delays: - A delay of 1 is assumed to mean *one* turn spent performing the delay action. - Finishing a delay takes no additional turns (because all the work was done in the prior turns). - No turn is lost after finishing a delay and before starting the next delay. finish_delay() immediately calls handle_delay() to start on the next delay. Some delay turn counts: Activity 0.2 0.3 Eat a pear 3 2 Butcher a corpse (no weapon swap) 5 4 Butcher a corpse (swapping weapons) 9 6 Take off robe (when wearing cloak) 8 5 Wear a cloak 3 2 git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1532 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/delay.cc50
-rw-r--r--crawl-ref/source/food.cc21
2 files changed, 46 insertions, 25 deletions
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 9de42ec70d..366ced7327 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -145,6 +145,11 @@ void stop_delay( void )
delay_queue_item delay = you.delay_queue.front();
+ const bool butcher_swap_warn =
+ delay.type == DELAY_BUTCHER
+ && (you.delay_queue.size() >= 2
+ && you.delay_queue[1].type == DELAY_WEAPON_SWAP);
+
// At the very least we can remove any queued delays, right
// now there is no problem with doing this... note that
// any queuing here can only happen from a single command,
@@ -157,7 +162,12 @@ void stop_delay( void )
{
case DELAY_BUTCHER:
// Corpse keeps track of work in plus2 field, see handle_delay() -- bwr
- mpr( "You stop butchering the corpse." );
+ if (butcher_swap_warn)
+ mpr("You stop butchering the corpse; not switching back to "
+ "primary weapon.",
+ MSGCH_WARN);
+ else
+ mpr( "You stop butchering the corpse." );
pop_delay();
break;
@@ -319,7 +329,8 @@ void handle_delay( void )
{
// special < 100 is the rottenness check
if ( (mitm[delay.parm1].special < 100) &&
- (delay.parm2 >= 100) ) {
+ (delay.parm2 >= 100) )
+ {
mpr("The corpse rots.", MSGCH_ROTTEN_MEAT);
delay.parm2 = 99; // don't give the message twice
}
@@ -329,9 +340,10 @@ void handle_delay( void )
}
else
{
- // corpse is no longer valid!
- stop_delay();
- return;
+ // corpse is no longer valid! End the butchering normally
+ // instead of using stop_delay() so that the player switches
+ // back to their main weapon if necessary.
+ delay.duration = 0;
}
}
if ( delay.type == DELAY_MULTIDROP )
@@ -536,18 +548,28 @@ static void finish_delay(const delay_queue_item &delay)
}
case DELAY_BUTCHER:
- mprf("You finish %s the corpse into pieces.",
- (you.species==SP_TROLL || you.species == SP_GHOUL) ? "ripping"
- : "chopping");
+ {
+ const item_def &item = mitm[delay.parm1];
+ if (is_valid_item(item) && item.base_type == OBJ_CORPSES)
+ {
+ mprf("You finish %s the corpse into pieces.",
+ (you.species==SP_TROLL || you.species == SP_GHOUL) ? "ripping"
+ : "chopping");
- turn_corpse_into_chunks( mitm[ delay.parm1 ] );
+ turn_corpse_into_chunks( mitm[ delay.parm1 ] );
- if (you.berserker && you.berserk_penalty != NO_BERSERK_PENALTY)
+ if (you.berserker && you.berserk_penalty != NO_BERSERK_PENALTY)
+ {
+ mpr("You enjoyed that.");
+ you.berserk_penalty = 0;
+ }
+ }
+ else
{
- mpr("You enjoyed that.");
- you.berserk_penalty = 0;
+ mpr("You stop butchering the corpse.");
}
break;
+ }
case DELAY_DROP_ITEM:
// Note: checking if item is droppable is assumed to
@@ -603,8 +625,10 @@ static void finish_delay(const delay_queue_item &delay)
you.wield_change = true;
print_stats(); // force redraw of the stats
- you.turn_is_over = true;
pop_delay();
+
+ // Chain onto the next delay.
+ handle_delay();
}
static void armour_wear_effects(const int item_slot)
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 0d2bc1e714..14020ec01f 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -162,14 +162,6 @@ static bool find_butchering_implement()
{
mpr("Switching to a butchering implement.");
wield_weapon( true, i, false );
-
- // Account for the weapon switch...we're doing this here
- // since the above switch may reveal information about the
- // weapon (curse status, ego type). So even if the
- // character fails to or decides not to butcher past this
- // point, they have achieved something and there should be
- // a cost.
- start_delay( DELAY_UNINTERRUPTIBLE, 1 );
return true;
}
}
@@ -226,7 +218,8 @@ bool butchery(void)
// 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.berserker ) {
+ if ( !can_butcher && you.berserker )
+ {
mpr ("You are too berserk to search for a butchering knife!");
return (false);
}
@@ -309,7 +302,12 @@ bool butchery(void)
}
else
{
- int work_req = 4 - (++mitm[objl].plus2);
+ // If we didn't switch weapons, we get in one turn of butchery;
+ // otherwise the work has to happen in the delay.
+ if (!wpn_switch)
+ ++mitm[objl].plus2;
+
+ int work_req = 4 - mitm[objl].plus2;
if (work_req < 0)
work_req = 0;
@@ -327,8 +325,7 @@ bool butchery(void)
if (!new_cursed && wpn_switch)
start_delay( DELAY_WEAPON_SWAP, 1, old_weapon );
- you.turn_is_over = true;
-
+ you.turn_is_over = true;
return true;
}