'moves' is actually turns and there hasn't been any straightforward
way to track actual hero moves.  Add hero_seq for that.  It isn't a
counter but is distinct each time the hero makes a move.  I wanted
it for curses ^P support but so far use it for checking stethoscope
usage and for shopkeeper behavior when items in a shop are broken by
the hero.

Increment EDITLEVEL due to change in save file contents.
This commit is contained in:
PatR
2021-12-26 00:16:55 -08:00
parent c4724fd271
commit 5fbe1de2a7
8 changed files with 41 additions and 33 deletions

View File

@@ -2111,10 +2111,11 @@ release_camera_demon(struct obj *obj, xchar x, xchar y)
* and break messages have been delivered prior to getting here.
*/
void
breakobj(struct obj *obj,
xchar x, xchar y, /* object location (ox, oy may not be right) */
boolean hero_caused, /* is this the hero's fault? */
boolean from_invent)
breakobj(
struct obj *obj,
xchar x, xchar y, /* object location (ox, oy may not be right) */
boolean hero_caused, /* is this the hero's fault? */
boolean from_invent)
{
boolean fracture = FALSE;
@@ -2175,19 +2176,20 @@ breakobj(struct obj *obj,
struct monst *shkp = shop_keeper(*o_shop);
if (shkp) { /* (implies *o_shop != '\0') */
static NEARDATA long lastmovetime = 0L;
static NEARDATA boolean peaceful_shk = FALSE;
/* We want to base shk actions on her peacefulness
at start of this turn, so that "simultaneous"
multiple breakage isn't drastically worse than
single breakage. (ought to be done via ESHK) */
if (g.moves != lastmovetime)
peaceful_shk = shkp->mpeaceful;
if (stolen_value(obj, x, y, peaceful_shk, FALSE) > 0L
struct eshk *eshkp = ESHK(shkp);
/* base shk actions on her peacefulness at start of
this turn, so that "simultaneous" multiple breakage
isn't drastically worse than single breakage */
if (g.hero_seq != eshkp->break_seq)
eshkp->seq_peaceful = shkp->mpeaceful;
if ((stolen_value(obj, x, y, eshkp->seq_peaceful, FALSE) > 0L)
&& (*o_shop != u.ushops[0] || !inside_shop(u.ux, u.uy))
&& g.moves != lastmovetime)
&& g.hero_seq != eshkp->break_seq)
make_angry_shk(shkp, x, y);
lastmovetime = g.moves;
/* make_angry_shk() is only called on the first instance
of breakage during any particular hero move */
eshkp->break_seq = g.hero_seq;
}
}
}