unicorn horn vs deafness

Implement the suggestion that applying a non-cursed unicorn horn can
cure deafness like other similar troubles.  Also, applying a cursed one
can cause deafness, although I made the chance be half of what it is
for the other troubles since they tend to be more significant.

This is entry #2 on the bugzilla list, but I haven't figured out how to
update that yet.
This commit is contained in:
PatR
2015-08-20 18:31:12 -07:00
parent 791c41e6b4
commit 96f9997164
5 changed files with 113 additions and 71 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1434421365 2015/06/16 02:22:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.504 $ */
/* NetHack 3.6 extern.h $NHDT-Date: 1440120640 2015/08/21 01:30:40 $ $NHDT-Branch: master $:$NHDT-Revision: 1.506 $ */
/* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1795,6 +1795,7 @@ E void FDECL(make_slimed, (long, const char *));
E void FDECL(make_stoned, (long, const char *, int, const char *));
E void FDECL(make_vomiting, (long, BOOLEAN_P));
E boolean FDECL(make_hallucinated, (long, BOOLEAN_P, long));
E void FDECL(make_deaf, (long, BOOLEAN_P));
E int NDECL(dodrink);
E int FDECL(dopotion, (struct obj *));
E int FDECL(peffects, (struct obj *));

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 apply.c $NHDT-Date: 1436753497 2015/07/13 02:11:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.200 $ */
/* NetHack 3.6 apply.c $NHDT-Date: 1440120650 2015/08/21 01:30:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.201 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1709,16 +1709,16 @@ void
use_unicorn_horn(obj)
struct obj *obj;
{
#define PROP_COUNT 6 /* number of properties we're dealing with */
#define PROP_COUNT 7 /* number of properties we're dealing with */
#define ATTR_COUNT (A_MAX * 3) /* number of attribute points we might fix */
int idx, val, val_limit, trouble_count, unfixable_trbl, did_prop,
did_attr;
int trouble_list[PROP_COUNT + ATTR_COUNT];
if (obj && obj->cursed) {
long lcount = (long) rnd(100);
long lcount = (long) rn1(90, 10);
switch (rn2(6)) {
switch (rn2(13) / 2) { /* case 6 is half as likely as the others */
case 0:
make_sick((Sick & TIMEOUT) ? (Sick & TIMEOUT) / 3L + 1L
: (long) rn1(ACURR(A_CON), 20),
@@ -1743,6 +1743,11 @@ struct obj *obj;
(void) make_hallucinated((HHallucination & TIMEOUT) + lcount,
TRUE, 0L);
break;
case 6:
if (Deaf) /* make_deaf() won't give feedback when already deaf */
pline("Nothing seems to happen.");
make_deaf((HDeaf & TIMEOUT) + lcount, TRUE);
break;
}
return;
}
@@ -1754,7 +1759,7 @@ struct obj *obj;
#define attr2trbl(Y) (Y)
#define prop_trouble(X) trouble_list[trouble_count++] = prop2trbl(X)
#define attr_trouble(Y) trouble_list[trouble_count++] = attr2trbl(Y)
#define TimedTrouble(P) (((P) && !((P) & ~TIMEOUT)) ? ((P) &TIMEOUT) : 0L)
#define TimedTrouble(P) (((P) && !((P) & ~TIMEOUT)) ? ((P) & TIMEOUT) : 0L)
trouble_count = unfixable_trbl = did_prop = did_attr = 0;
@@ -1773,6 +1778,8 @@ struct obj *obj;
prop_trouble(CONFUSION);
if (TimedTrouble(HStun))
prop_trouble(STUNNED);
if (TimedTrouble(HDeaf))
prop_trouble(DEAF);
unfixable_trbl = unfixable_trouble_count(TRUE);
@@ -1815,10 +1822,10 @@ struct obj *obj;
}
/*
* Chances for number of troubles to be fixed
* 0 1 2 3 4 5 6 7
* blessed: 22.7% 22.7% 19.5% 15.4% 10.7% 5.7% 2.6% 0.8%
* uncursed: 35.4% 35.4% 22.9% 6.3% 0 0 0 0
* Chances for number of troubles to be fixed
* 0 1 2 3 4 5 6 7
* blessed: 22.7% 22.7% 19.5% 15.4% 10.7% 5.7% 2.6% 0.8%
* uncursed: 35.4% 35.4% 22.9% 6.3% 0 0 0 0
*/
val_limit = rn2(d(2, (obj && obj->blessed) ? 4 : 2));
if (val_limit > trouble_count)
@@ -1853,6 +1860,10 @@ struct obj *obj;
make_stunned(0L, TRUE);
did_prop++;
break;
case prop2trbl(DEAF):
make_deaf(0L, TRUE);
did_prop++;
break;
default:
if (idx >= 0 && idx < A_MAX) {
ABASE(idx) += 1;
@@ -1974,8 +1985,8 @@ long timeout;
}
break;
#if 0
case OBJ_MIGRATING:
break;
case OBJ_MIGRATING:
break;
#endif
default:
@@ -2503,20 +2514,19 @@ struct obj *obj;
} else if (u.utrap && u.utraptype == TT_PIT) {
/*
* Assumptions:
* Assumptions:
*
* if you're in a pit
* - you are attempting to get out of the pit
* - or, if you are applying it towards a small
* monster then it is assumed that you are
* trying to hit it.
* else if the monster is wielding a weapon
* - you are attempting to disarm a monster
* else
* - you are attempting to hit the monster
* if you're in a pit
* - you are attempting to get out of the pit
* or, if you are applying it towards a small monster
* - then it is assumed that you are trying to hit it
* else if the monster is wielding a weapon
* - you are attempting to disarm a monster
* else
* - you are attempting to hit the monster.
*
* if you're confused (and thus off the mark)
* - you only end up hitting.
* if you're confused (and thus off the mark)
* - you only end up hitting.
*
*/
const char *wrapped_what = (char *) 0;
@@ -2599,25 +2609,25 @@ struct obj *obj;
stackobj(otmp);
break;
case 3:
/* right to you */
#if 0
if (!rn2(25)) {
/* proficient with whip, but maybe not
so proficient at catching weapons */
int hitu, hitvalu;
/* right to you */
if (!rn2(25)) {
/* proficient with whip, but maybe not
so proficient at catching weapons */
int hitu, hitvalu;
hitvalu = 8 + otmp->spe;
hitu = thitu(hitvalu,
dmgval(otmp, &youmonst),
otmp, (char *)0);
if (hitu) {
pline_The("%s hits you as you try to snatch it!",
the(onambuf));
}
place_object(otmp, u.ux, u.uy);
stackobj(otmp);
break;
}
hitvalu = 8 + otmp->spe;
hitu = thitu(hitvalu,
dmgval(otmp, &youmonst),
otmp, (char *)0);
if (hitu) {
pline_The("%s hits you as you try to snatch it!",
the(onambuf));
}
place_object(otmp, u.ux, u.uy);
stackobj(otmp);
break;
}
#endif /* 0 */
/* right into your inventory */
You("snatch %s!", yname(otmp));
@@ -2754,20 +2764,20 @@ struct obj *obj;
/* assert(obj == uwep); */
/*
* Calculate allowable range (pole's reach is always 2 steps):
* unskilled and basic: orthogonal direction, 4..4;
* skilled: as basic, plus knight's jump position, 4..5;
* expert: as skilled, plus diagonal, 4..8.
* ...9...
* .85458.
* .52125.
* 9410149
* .52125.
* .85458.
* ...9...
* (Note: no roles in nethack can become expert or better
* for polearm skill; Yeoman in slash'em can become expert.)
*/
* Calculate allowable range (pole's reach is always 2 steps):
* unskilled and basic: orthogonal direction, 4..4;
* skilled: as basic, plus knight's jump position, 4..5;
* expert: as skilled, plus diagonal, 4..8.
* ...9...
* .85458.
* .52125.
* 9410149
* .52125.
* .85458.
* ...9...
* (Note: no roles in nethack can become expert or better
* for polearm skill; Yeoman in slash'em can become expert.)
*/
min_range = 4;
typ = uwep_skill_type();
if (typ == P_NONE || P_SKILL(typ) <= P_BASIC)
@@ -3400,9 +3410,9 @@ doapply()
use_whistle(obj);
break;
case EUCALYPTUS_LEAF:
/* MRKR: Every Australian knows that a gum leaf makes an */
/* excellent whistle, especially if your pet is a */
/* tame kangaroo named Skippy. */
/* MRKR: Every Australian knows that a gum leaf makes an excellent
* whistle, especially if your pet is a tame kangaroo named Skippy.
*/
if (obj->blessed) {
use_magic_whistle(obj);
/* sometimes the blessing will be worn off */
@@ -3535,8 +3545,7 @@ boolean is_horn;
unfixable_trbl++;
if (Slimed)
unfixable_trbl++;
/* lycanthropy is not desirable, but it doesn't actually make you feel
bad */
/* lycanthropy is undesirable, but it doesn't actually make you feel bad */
if (!is_horn || (Confusion & ~TIMEOUT))
unfixable_trbl++;
@@ -3548,6 +3557,8 @@ boolean is_horn;
unfixable_trbl++;
if (!is_horn || (HStun & ~TIMEOUT))
unfixable_trbl++;
if (!is_horn || (HDeaf & ~TIMEOUT))
unfixable_trbl++;
return unfixable_trbl;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 eat.c $NHDT-Date: 1432512769 2015/05/25 00:12:49 $ $NHDT-Branch: master $:$NHDT-Revision: 1.143 $ */
/* NetHack 3.6 eat.c $NHDT-Date: 1440120655 2015/08/21 01:30:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.144 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1460,11 +1460,13 @@ register struct obj *otmp;
return;
}
int Hear_again(VOID_ARGS) /* called when waking up after fainting */
/* called when waking up after fainting */
int
Hear_again(VOID_ARGS)
{
/* Chance of deafness going away while fainted/sleepeing/etc. */
if (!rn2(2))
set_itimeout(&HDeaf, 0L);
make_deaf(0L, FALSE);
return 0;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 potion.c $NHDT-Date: 1433060654 2015/05/31 08:24:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.116 $ */
/* NetHack 3.6 potion.c $NHDT-Date: 1440120657 2015/08/21 01:30:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.117 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -115,7 +115,7 @@ int type;
long old = Sick;
#if 0
if (Unaware) talk = FALSE;
if (Unaware) talk = FALSE;
#endif
if (xtime > 0L) {
@@ -162,7 +162,7 @@ const char *msg;
long old = Slimed;
#if 0
if (Unaware) msg = 0;
if (Unaware) msg = 0;
#endif
if ((!xtime && old) || (xtime && !old)) {
@@ -186,7 +186,7 @@ const char *killername;
long old = Stoned;
#if 0
if (Unaware) msg = 0;
if (Unaware) msg = 0;
#endif
if ((!xtime && old) || (xtime && !old)) {
@@ -390,6 +390,34 @@ long mask; /* nonzero if resistance status should change by mask */
return changed;
}
void
make_deaf(xtime, talk)
long xtime;
boolean talk;
{
long old = HDeaf;
boolean toggled = FALSE;
if (Unaware)
talk = FALSE;
if (!xtime && old) {
if (talk)
You("can hear again.");
toggled = TRUE;
} else if (xtime && !old) {
if (talk)
You("are unable to hear anything.");
toggled = TRUE;
}
/* deafness isn't presently shown on status line, but
request a status update in case that changes someday */
if (toggled)
context.botl = TRUE;
set_itimeout(&HDeaf, xtime);
}
STATIC_OVL void
ghost_from_bottle()
{

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 timeout.c $NHDT-Date: 1432512765 2015/05/25 00:12:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */
/* NetHack 3.6 timeout.c $NHDT-Date: 1440120659 2015/08/21 01:30:59 $ $NHDT-Branch: master $:$NHDT-Revision: 1.60 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -343,10 +343,10 @@ nh_timeout()
stop_occupation();
break;
case DEAF:
if (!Deaf) {
You("can hear again.");
set_itimeout(&HDeaf, 1L);
make_deaf(0L, TRUE);
if (!Deaf)
stop_occupation();
}
break;
case INVIS:
newsym(u.ux, u.uy);