suggestions/observations:
Get rid of option swap_when_safe and its behaviour.
If auto-swap butchery is interrupted by teleportation or chagning levels (banishment) then auto-swap back if there's no monsters nearby.
2b) Do the same if butchery is interrupted and then later a large position change happens.
If auto-swap butchery is interrupted by something like poison damage, if the butchery is resumed and finished then swap back.
If auto-swap butchery is interrupted by a monster, then if the new option prompt_for_swap is set the game will ask if you wish to swap back from your butchering tool.
4b) Do the same if butchery is interrupted and then later a large position change lands you near some hostile monsters.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7717 c06c8d41-db1a-0410-9941-cceddc491573
3PBG6FJ6WGSR4UM3I7UQUYYCSYU3UBCKCIKYKUEEANIK72TUL4XAC
B62LRY6EDGLIYGZCQC6UG76KGGCHQZUP6ZDFBPSWYF352ULQJQOQC
A45CG72LRSPIM3FYRRZQ4CIRMO7VAA6FW2N3YZ55BCFZLFCWEUZAC
EYYWIH7377INOKPRABJUATNQ2YWKLOVHZKQIY55POX2YXVMDDWAAC
4V4YGPXG45JV5ZPAFDEHTLLGAQIFISMHKCZMMJRAD62FVDCL255AC
MINMR3UAVXGVNIGZKS3SRYFCYDMCVEJZN7AGDWJNHQLR36FDXU7QC
QKV56RZTWOX64VLWW52R2DEUM3HGGZNLRAJ2ZV2BHW5K422OPNJQC
JYEEOUYQ7ZPKOGWUV7VCORBVSOLF2UCBFBH3TR75RGOSS6PNKYUAC
SWE3F3BLKHYMJEJLXNFH3MR2E6VDEYXJ6DL7QLPP47BJEKEUCAMAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
CIAIASCBKKV7VMYBL2CIFAYGFQTB6GIME4FSQGZNQGXO7FXQTA5AC
W6EWE6VIRP6OTSSTG3ZZEBN72OIKK6D3AEIP3OWX3HMJBA52SZSAC
EOMCPVNQLX3IMLC46EAO67DPBH5KEG2FQTPBLGU62HIRWA3UQ7XQC
KFULGQQOHWUTXOM3BXCCYPGGVGGY4Z6265XUFRCB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XYPKQIBJXZBDNUCHXQC
7MMBAVNSUSNLVE2G6Z25C3TGHYAYLCOOXQ63KHXPYUMOOSKNGDKAC
K2B4YUKFNQX33VFTVF4WRGMXUG7OG6AKCE67MU562QNBJXGOVQTAC
MDFQRJ6QZNFUBVSFWLXUJ6EBXOU47T3CVDI2XKBGNNRF4DXDKESQC
if (load_mode == LOAD_ENTER_LEVEL)
{
// 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.
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
const int nrounds = atk->has_hydra_multi_attack() ? atk->number : 4;
const coord_def pos = defender->pos();
const int nrounds = atk->has_hydra_multi_attack() ? atk->number : 4;
const coord_def pos = defender->pos();
const bool was_delayed = you_are_delayed();
// Maybe we should do precisely that, but that would entirely
// defeat the purpose of the weapon swap.
// you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
if (Options.swap_when_safe)
{
// 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;
}
// 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;
}
}
void handle_interrupted_swap(bool swap_if_safe, bool force_unsafe)
{
if (!you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
|| !you_tran_can_wear(EQ_WEAPON))
{
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();
// If we're going to prompt then update the window so the player can
// see what the monsters are.
if (prompt)
viewwindow(true, false);
if (delay == DELAY_WEAPON_SWAP)
{
ASSERT(!"handle_interrupted_swap() called while already swapping "
"weapons");
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
return;
}
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("Switch back from butchering tool?", false)
|| safe && swap_if_safe)
{
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 (delay == DELAY_BUTCHER || delay == DELAY_BOTTLE_BLOOD
|| delay == DELAY_OFFER_CORPSE)
{
start_delay(DELAY_WEAPON_SWAP, 1, weap);
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
return;
}
if (safe)
{
if (!swap_if_safe)
return;
// 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
&& you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
&& you_tran_can_wear(EQ_WEAPON))
{
// 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;
weapon_switch(weap);
print_stats();
// To prevent spam in case the weapon can't be switched back to.
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
butchery is interrupted, the auto-switch will be reversed as
soon as you are safe again.
butchery is interrupted by a hostile monster, the game will
ask if you wish to switch back to your weapon. It will also
prompt you if after butchery is interupted you teleport or
change levels and find yourself near hostile monsters.