This patch implements dploog's suggestion of hysteresis on piety. gain/lose_piety() adjust you.piety_hysteresis first; you.piety is modified with the leftovers (if any) once the hysteresis reaches its limit.
Players start out at the upper end of the hysteresis region, meaning there is no lag on piety increase, but a lag on piety decrease.
Hysteresis value set by "#define PIETY_HYSTERESIS_LIMIT 1"
Does not break old saves.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3562 c06c8d41-db1a-0410-9941-cceddc491573
FS4MVTH4EEEECLEAO2FTNK5CLF2PHFYO2JZHC2YEOKYLWXRDRU6AC
XDHIIBQZLHLXAHIPJMXWH3FJ2X5PO7IB7HXQMVZDWM5JZFAG3HAQC
LJK4ZQATLSB4MKZG3ARZX5V6RFGTN3NLCN6GTCUGJQKU26SOXMUAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
E42EFZ3RINKLTGOJJZAH2N5QF3P4S5NCO5T52HLXJRMBPP463HTAC
3NFVCXRVGHN2CHLLWFZES5RBS4R2BCDS4EEQNSDCFYIFQWQK7MUQC
BIZDHHK5LIO57S5AKHEPJFLWV5DAFKZIKYBGOUNGICSWTX7DCXKAC
WZNB427K3EUNV3FMVXLQTM4UIHER4FIKQXWLUUXRNQC3OQ33VQYAC
KFULGQQOHWUTXOM3BXCCYPGGVGGY4Z6265XUFRCBPNLTZAEHJZSQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
L6HIZHDQVBJDGBYUHYBUJCTYVYTXP7D5OG5FJSSVCMBKNS3XJ7SAC
6L4EP4ZRWWYLT55PD5KTTJON5J2JB5VV5MWNHF5VPZQZ5BKEYZ4QC
6GT5JAWOIIL4SQ5MWIID6ZVO3KKQFWDQDZNVFHZ6DNK5QCBXJ4UAC
7AMQN7MITMXBNVDAK5VOXTQ4TZIAOD6ZLOFJG7GQMBTY23Y2BKSAC
// Apply hysteresis
{
// piety_hysteresis is the amount of _loss_ stored up, so this
// may look backwards.
const int old_hysteresis = you.piety_hysteresis;
you.piety_hysteresis = (unsigned char)std::max<int>(
0, you.piety_hysteresis - pgn);
const int pgn_borrowed = (old_hysteresis - you.piety_hysteresis);
pgn -= pgn_borrowed;
#if DEBUG_PIETY
mprf(MSGCH_DIAGNOSTICS, "Piety increasing by %d (and %d taken from hysteresis)", pgn, pgn_borrowed);
#endif
}