blindness overhaul

I was working on this at the time 3.6.0 was released and set it aside
until later.  Later has finally arrived.  Redo the Blind, Blinded,
Blindfolded,&c macros to make more complete use of intrinsic property
handling.  Blinded was being treated as a number which could be added
to or subtracted from; now that has to be done via TIMEOUT mask
because it has FROMOUTSIDE (OPTIONS:blind) and FROMFORM (poly'd into
!haseyes() form) bits included.  Object definitions for blindfold and
towel now specify the BLINDED property; overriding blindness via the
Eyes of the Overworld is accomplished via props[BLINDED].blocked.

Code generated for the scores of Blind and !Blind tests throughout
the program should be smaller.

One bug that has been fixed is that putting on the Eyes of the
Overworld cured permanent blindness (from OPTIONS:blind).  The
u.uroleplay.blind flag was cleared and stayed so after taking them
off.  Putting the Eyes on still breaks blind-from-birth conduct but
now blindness will resume when they are removed.

This was untested at the time it was set aside and is only lightly
tested now.  A large number of the changes here are just to switch
from Blinded to BlindedTimeout for current timed value and to call
set_itimeout() for setting a new value.
This commit is contained in:
PatR
2023-04-27 14:53:28 -07:00
parent 57ff993352
commit 1c94bdac89
26 changed files with 142 additions and 85 deletions

View File

@@ -54,8 +54,8 @@ itimeout(long val)
{
if (val >= TIMEOUT)
val = TIMEOUT;
else if (val < 1)
val = 0;
else if (val < 1L)
val = 0L;
return val;
}
@@ -257,16 +257,16 @@ static const char eyemsg[] = "%s momentarily %s.";
void
make_blinded(long xtime, boolean talk)
{
long old = Blinded;
long old = BlindedTimeout;
boolean u_could_see, can_see_now;
const char *eyes;
/* we need to probe ahead in case the Eyes of the Overworld
/* we probe ahead in case the Eyes of the Overworld
are or will be overriding blindness */
u_could_see = !Blind;
Blinded = xtime ? 1L : 0L;
set_itimeout(&HBlinded, xtime ? 1L : 0L);
can_see_now = !Blind;
Blinded = old; /* restore */
set_itimeout(&HBlinded, old);
if (Unaware)
talk = FALSE;
@@ -320,7 +320,7 @@ make_blinded(long xtime, boolean talk)
}
}
set_itimeout(&Blinded, xtime);
set_itimeout(&HBlinded, xtime);
if (u_could_see ^ can_see_now) { /* one or the other but not both */
toggle_blindness();
@@ -1048,9 +1048,9 @@ peffect_speed(struct obj *otmp)
static void
peffect_blindness(struct obj *otmp)
{
if (Blind)
if (Blind || ((HBlinded || EBlinded) && BBlinded))
gp.potion_nothing++;
make_blinded(itimeout_incr(Blinded,
make_blinded(itimeout_incr(BlindedTimeout,
rn1(200, 250 - 125 * bcsign(otmp))),
(boolean) !Blind);
}
@@ -2037,7 +2037,7 @@ potionbreathe(struct obj *obj)
kn++;
pline("It suddenly gets dark.");
}
make_blinded(itimeout_incr(Blinded, rnd(5)), FALSE);
make_blinded(itimeout_incr(BlindedTimeout, rnd(5)), FALSE);
if (!Blind && !Unaware)
Your1(vision_clears);
break;