fix github issue #900 - "Elbereth" engravings

Issue reported by vultur-cadens:  Elbereth used to be effective in
inhibiting monster movement when an object was present on the same
spot, but since 3.6.0 it isn't.  It only functions that way when the
hero--or hero's displaced image--is present these days.  So special
levels that have been using engraved Elbereth to try to protect
objects from monsters haven't been providing any useful protection.

This makes Elbereth that's engraved during level creation work like
it used to in 3.4.3 and earlier:  when there's at least one object
on the engraving's spot, monsters who are affected by Elbereth will
be affected.  [I'm fairly sure that that behavior started out
unintentionally, as a side-effect of an optimization to only check
for scroll of scare monster when there was at least one item present
which is a necessary condition for such a scroll.]

Old-style Elbereth includes Elbereth chosen as a random engraving
during level creation in addition to engravings specified in special
level definitions.  Engravings by the player don't have the required
attribute and player-engraved Elbereth behaves in the 3.6 way.

This ought to be replaced by something more general.  Perhaps a new
engraving type not usable by the player?

Fixes #900
This commit is contained in:
PatR
2022-10-15 02:13:39 -07:00
committed by nhmall
parent e135046497
commit 659f16070c
5 changed files with 36 additions and 19 deletions

View File

@@ -20,10 +20,15 @@ struct engr {
#define ENGR_BLOOD 5
#define HEADSTONE 6
#define N_ENGRAVE 6
Bitfield(guardobjects, 1); /* if engr_txt is "Elbereth", it is effective
* against monsters when an object is present
* even when hero isn't (so behaves similarly
* to how Elbereth did in 3.4.3) */
/* 7 free bits */
};
#define newengr(lth) \
(struct engr *) alloc((unsigned)(lth) + sizeof(struct engr))
#define dealloc_engr(engr) free((genericptr_t)(engr))
(struct engr *) alloc((unsigned) (lth) + (unsigned) sizeof (struct engr))
#define dealloc_engr(engr) free((genericptr_t) (engr))
#endif /* ENGRAVE_H */

View File

@@ -809,7 +809,7 @@ extern void cant_reach_floor(coordxy, coordxy, boolean, boolean);
extern const char *surface(coordxy, coordxy);
extern const char *ceiling(coordxy, coordxy);
extern struct engr *engr_at(coordxy, coordxy);
extern boolean sengr_at(const char *, coordxy, coordxy, boolean);
extern struct engr *sengr_at(const char *, coordxy, coordxy, boolean);
extern void u_wipe_engr(int);
extern void wipe_engr_at(coordxy, coordxy, xint16, boolean);
extern void read_engr_at(coordxy, coordxy);