conflicting countdowns again

Use the make_foo() intrinsic set/reset routines instead of trying
to manipulate the intrinsics directly.  Previous patch left Dex
down by 1 if stoning caused wounded legs to be fixed, and left
delayed killer allocated if stoning cured sliming or vice versa.
This commit is contained in:
PatR
2018-11-12 11:02:40 -08:00
parent 53a6ce2c2a
commit 1295e7ee28
8 changed files with 40 additions and 33 deletions
+1 -1
View File
@@ -390,7 +390,7 @@ E void FDECL(revive_mon, (ANY_P *, long));
E int NDECL(donull); E int NDECL(donull);
E int NDECL(dowipe); E int NDECL(dowipe);
E void FDECL(set_wounded_legs, (long, int)); E void FDECL(set_wounded_legs, (long, int));
E void NDECL(heal_legs); E void FDECL(heal_legs, (int));
/* ### do_name.c ### */ /* ### do_name.c ### */
+9 -4
View File
@@ -1882,7 +1882,8 @@ register int timex;
} }
void void
heal_legs() heal_legs(how)
int how; /* 0: ordinary, 1: dismounting steed, 2: limbs turn to stone */
{ {
if (Wounded_legs) { if (Wounded_legs) {
if (ATEMP(A_DEX) < 0) { if (ATEMP(A_DEX) < 0) {
@@ -1890,7 +1891,11 @@ heal_legs()
context.botl = 1; context.botl = 1;
} }
if (!u.usteed) { /* when mounted, wounded legs applies to the steed;
during petrification countdown, "your limbs turn to stone"
before the final stages and that calls us (how==2) to cure
wounded legs, but we want to suppress the feel better message */
if (!u.usteed && how != 2) {
const char *legs = body_part(LEG); const char *legs = body_part(LEG);
if ((EWounded_legs & BOTH_SIDES) == BOTH_SIDES) if ((EWounded_legs & BOTH_SIDES) == BOTH_SIDES)
@@ -1900,7 +1905,7 @@ heal_legs()
Your("%s %s better.", legs, vtense(legs, "feel")); Your("%s %s better.", legs, vtense(legs, "feel"));
} }
HWounded_legs = EWounded_legs = 0; HWounded_legs = EWounded_legs = 0L;
/* Wounded_legs reduces carrying capacity, so we want /* Wounded_legs reduces carrying capacity, so we want
an encumbrance check when they're healed. However, an encumbrance check when they're healed. However,
@@ -1912,7 +1917,7 @@ heal_legs()
it might be immediately contradicted [able to carry it might be immediately contradicted [able to carry
more when steed becomes healthy, then possible floor more when steed becomes healthy, then possible floor
feedback, then able to carry less when back on foot]. */ feedback, then able to carry less when back on foot]. */
if (!in_steed_dismounting) if (how == 0)
(void) encumber_msg(); (void) encumber_msg();
} }
} }
+1 -1
View File
@@ -2217,7 +2217,7 @@ struct obj *otmp;
} }
} }
if (!otmp->cursed) if (!otmp->cursed)
heal_legs(); heal_legs(0);
break; break;
case EGG: case EGG:
if (flesh_petrifies(&mons[otmp->corpsenm])) { if (flesh_petrifies(&mons[otmp->corpsenm])) {
+14 -8
View File
@@ -106,6 +106,9 @@ boolean talk;
set_itimeout(&HStun, xtime); set_itimeout(&HStun, xtime);
} }
/* Sick is overloaded with both fatal illness and food poisoning (via
u.usick_type bit mask), but delayed killer can only support one or
the other at a time. They should become separate intrinsics.... */
void void
make_sick(xtime, cause, talk, type) make_sick(xtime, cause, talk, type)
long xtime; long xtime;
@@ -116,7 +119,7 @@ int type;
struct kinfo *kptr; struct kinfo *kptr;
long old = Sick; long old = Sick;
#if 0 #if 0 /* tell player even if hero is unconscious */
if (Unaware) if (Unaware)
talk = FALSE; talk = FALSE;
#endif #endif
@@ -152,7 +155,10 @@ int type;
kptr = find_delayed_killer(SICK); kptr = find_delayed_killer(SICK);
if (Sick) { if (Sick) {
exercise(A_CON, FALSE); exercise(A_CON, FALSE);
if (!old || !kptr) { /* setting delayed_killer used to be unconditional, but that's
not right when make_sick(0) is called to cure food poisoning
if hero was also fatally ill; this is only approximate */
if (xtime || !old || !kptr) {
int kpfx = ((cause && !strcmp(cause, "#wizintrinsic")) int kpfx = ((cause && !strcmp(cause, "#wizintrinsic"))
? KILLED_BY : KILLED_BY_AN); ? KILLED_BY : KILLED_BY_AN);
@@ -169,7 +175,7 @@ const char *msg;
{ {
long old = Slimed; long old = Slimed;
#if 0 #if 0 /* tell player even if hero is unconscious */
if (Unaware) if (Unaware)
msg = 0; msg = 0;
#endif #endif
@@ -177,7 +183,7 @@ const char *msg;
if ((xtime != 0L) ^ (old != 0L)) { if ((xtime != 0L) ^ (old != 0L)) {
context.botl = TRUE; context.botl = TRUE;
if (msg) if (msg)
pline1(msg); pline("%s", msg);
} }
if (!Slimed) if (!Slimed)
dealloc_killer(find_delayed_killer(SLIMED)); dealloc_killer(find_delayed_killer(SLIMED));
@@ -193,7 +199,7 @@ const char *killername;
{ {
long old = Stoned; long old = Stoned;
#if 0 #if 0 /* tell player even if hero is unconscious */
if (Unaware) if (Unaware)
msg = 0; msg = 0;
#endif #endif
@@ -201,7 +207,7 @@ const char *killername;
if ((xtime != 0L) ^ (old != 0L)) { if ((xtime != 0L) ^ (old != 0L)) {
context.botl = TRUE; context.botl = TRUE;
if (msg) if (msg)
pline1(msg); pline("%s", msg);
} }
if (!Stoned) if (!Stoned)
dealloc_killer(find_delayed_killer(STONED)); dealloc_killer(find_delayed_killer(STONED));
@@ -899,9 +905,9 @@ register struct obj *otmp;
} }
break; break;
case POT_SPEED: case POT_SPEED:
/* skip when mounted; heal_legs() would heal steeds legs */
if (Wounded_legs && !otmp->cursed && !u.usteed) { if (Wounded_legs && !otmp->cursed && !u.usteed) {
/* heal_legs() would heal steeds legs */ heal_legs(0);
heal_legs();
unkn++; unkn++;
break; break;
} }
+1 -1
View File
@@ -524,7 +524,7 @@ int trouble;
break; break;
} }
case TROUBLE_WOUNDED_LEGS: case TROUBLE_WOUNDED_LEGS:
heal_legs(); heal_legs(0);
break; break;
case TROUBLE_STUNNED: case TROUBLE_STUNNED:
make_stunned(0L, TRUE); make_stunned(0L, TRUE);
+1 -1
View File
@@ -188,7 +188,7 @@ dosit()
u.ucreamed = 0; u.ucreamed = 0;
make_blinded(0L, TRUE); make_blinded(0L, TRUE);
make_sick(0L, (char *) 0, FALSE, SICK_ALL); make_sick(0L, (char *) 0, FALSE, SICK_ALL);
heal_legs(); heal_legs(0);
context.botl = 1; context.botl = 1;
break; break;
case 5: case 5:
+3 -7
View File
@@ -221,7 +221,7 @@ boolean force; /* Quietly force this animal */
if (Wounded_legs) { if (Wounded_legs) {
Your("%s are in no shape for riding.", makeplural(body_part(LEG))); Your("%s are in no shape for riding.", makeplural(body_part(LEG)));
if (force && wizard && yn("Heal your legs?") == 'y') if (force && wizard && yn("Heal your legs?") == 'y')
HWounded_legs = EWounded_legs = 0; HWounded_legs = EWounded_legs = 0L;
else else
return (FALSE); return (FALSE);
} }
@@ -542,12 +542,8 @@ int reason; /* Player was thrown off etc. */
} }
/* While riding, Wounded_legs refers to the steed's legs; /* While riding, Wounded_legs refers to the steed's legs;
after dismounting, it reverts to the hero's legs. */ after dismounting, it reverts to the hero's legs. */
if (repair_leg_damage) { if (repair_leg_damage)
/* [TODO: make heal_legs() take a parameter to handle this] */ heal_legs(1);
in_steed_dismounting = TRUE;
heal_legs();
in_steed_dismounting = FALSE;
}
/* Release the steed and saddle */ /* Release the steed and saddle */
u.usteed = 0; u.usteed = 0;
+10 -10
View File
@@ -137,17 +137,17 @@ stoned_dialogue()
multi_reason = "getting stoned"; multi_reason = "getting stoned";
nomovemsg = You_can_move_again; /* not unconscious */ nomovemsg = You_can_move_again; /* not unconscious */
/* "your limbs have turned to stone" so terminate wounded legs */ /* "your limbs have turned to stone" so terminate wounded legs */
if ((HWounded_legs & TIMEOUT) != 0L && !u.usteed) if (Wounded_legs && !u.usteed)
set_itimeout(&HWounded_legs, 0L); heal_legs(2);
break; break;
case 2: /* turned to stone */ case 2: /* turned to stone */
if ((HDeaf & TIMEOUT) > 0L && (HDeaf & TIMEOUT) < 5L) if ((HDeaf & TIMEOUT) > 0L && (HDeaf & TIMEOUT) < 5L)
set_itimeout(&HDeaf, 5L); /* avoid Hear_again at tail end */ set_itimeout(&HDeaf, 5L); /* avoid Hear_again at tail end */
/* if also vomiting or turning into slime, stop those */ /* if also vomiting or turning into slime, stop those (no messages) */
if ((Vomiting & TIMEOUT) != 0L) if (Vomiting)
set_itimeout(&Vomiting, 0L), context.botl = 1; make_vomiting(0L, FALSE);
if ((Slimed & TIMEOUT) != 0L) if (Slimed)
set_itimeout(&Slimed, 0L), context.botl = 1; make_slimed(0L, (char *) 0);
break; break;
default: default:
break; break;
@@ -342,8 +342,8 @@ slime_dialogue()
break; break;
case 1L: /* turning into slime */ case 1L: /* turning into slime */
/* if also turning to stone, stop doing that (no message) */ /* if also turning to stone, stop doing that (no message) */
if ((Stoned & TIMEOUT) != 0L) if (Stoned)
set_itimeout(&Stoned, 0L), context.botl = 1; make_stoned(0L, (char *) 0, KILLED_BY_AN, (char *) 0);
break; break;
} }
exercise(A_DEX, FALSE); exercise(A_DEX, FALSE);
@@ -553,7 +553,7 @@ nh_timeout()
stop_occupation(); stop_occupation();
break; break;
case WOUNDED_LEGS: case WOUNDED_LEGS:
heal_legs(); heal_legs(0);
stop_occupation(); stop_occupation();
break; break;
case HALLUC: case HALLUC: