segment feedback when probing long worms

When using a stethoscope or wand of probing on a long worm, report
the number of segments it has in the feedback given.

Some of the extra bhitpos and/or notonhead assigments may not be
necessary.  They were added when I was trying to figure out the
question of why probing of a tail segment revealed a long worm's
inventory even though the code explicitly prevents that.  (Answer:
it didn't; I had misinterpreted bz 12 to think that that was what
was being reported.  You need to use wand of probing--or "insigtful"
Magicbane hit--on the head in order to see its inventory or be told
"not carrying anything".)
This commit is contained in:
PatR
2016-02-26 15:16:49 -08:00
parent 0d7e51e88a
commit a00c8068f0
6 changed files with 84 additions and 37 deletions
+1
View File
@@ -228,6 +228,7 @@ allow some extra color name aliases for menucolors and status hilites
add extended command #kick add extended command #kick
when choosing an inventory item and '-' for bare-hands/fingers/no-ammo is a when choosing an inventory item and '-' for bare-hands/fingers/no-ammo is a
choice, include that in the inventory menu if player types '?' or '*' choice, include that in the inventory menu if player types '?' or '*'
feedback from probing of long worm now includes number of segments it has
Platform- and/or Interface-Specific New Features Platform- and/or Interface-Specific New Features
+2 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1455672983 2016/02/17 01:36:23 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.548 $ */ /* NetHack 3.6 extern.h $NHDT-Date: 1456528594 2016/02/26 23:16:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.549 $ */
/* Copyright (c) Steve Creps, 1988. */ /* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2715,6 +2715,7 @@ E void FDECL(place_worm_tail_randomly, (struct monst *, XCHAR_P, XCHAR_P));
E int FDECL(count_wsegs, (struct monst *)); E int FDECL(count_wsegs, (struct monst *));
E boolean FDECL(worm_known, (struct monst *)); E boolean FDECL(worm_known, (struct monst *));
E boolean FDECL(worm_cross, (int, int, int, int)); E boolean FDECL(worm_cross, (int, int, int, int));
E int FDECL(wseg_at, (struct monst *, int, int));
/* ### worn.c ### */ /* ### worn.c ### */
+9 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 apply.c $NHDT-Date: 1456526104 2016/02/26 22:35:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.221 $ */ /* NetHack 3.6 apply.c $NHDT-Date: 1456528594 2016/02/26 23:16:34 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.222 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -323,6 +323,8 @@ register struct obj *obj;
context.stethoscope_move = moves; context.stethoscope_move = moves;
context.stethoscope_movement = youmonst.movement; context.stethoscope_movement = youmonst.movement;
bhitpos.x = u.ux, bhitpos.y = u.uy; /* tentative, reset below */
notonhead = u.uswallow;
if (u.usteed && u.dz > 0) { if (u.usteed && u.dz > 0) {
if (interference) { if (interference) {
pline("%s interferes.", Monnam(u.ustuck)); pline("%s interferes.", Monnam(u.ustuck));
@@ -369,6 +371,10 @@ register struct obj *obj;
const char *mnm = x_monnam(mtmp, ARTICLE_A, (const char *) 0, const char *mnm = x_monnam(mtmp, ARTICLE_A, (const char *) 0,
SUPPRESS_IT | SUPPRESS_INVISIBLE, FALSE); SUPPRESS_IT | SUPPRESS_INVISIBLE, FALSE);
/* bhitpos needed by mstatusline() iff mtmp is a long worm */
bhitpos.x = rx, bhitpos.y = ry;
notonhead = (mtmp->mx != rx || mtmp->my != ry);
if (mtmp->mundetected) { if (mtmp->mundetected) {
if (!canspotmon(mtmp)) if (!canspotmon(mtmp))
There("is %s hidden there.", mnm); There("is %s hidden there.", mnm);
@@ -393,6 +399,7 @@ register struct obj *obj;
} else if (flags.verbose && !canspotmon(mtmp)) { } else if (flags.verbose && !canspotmon(mtmp)) {
There("is %s there.", mnm); There("is %s there.", mnm);
} }
mstatusline(mtmp); mstatusline(mtmp);
if (!canspotmon(mtmp)) if (!canspotmon(mtmp))
map_invisible(rx, ry); map_invisible(rx, ry);
@@ -403,6 +410,7 @@ register struct obj *obj;
newsym(rx, ry); newsym(rx, ry);
pline_The("invisible monster must have moved."); pline_The("invisible monster must have moved.");
} }
lev = &levl[rx][ry]; lev = &levl[rx][ry];
switch (lev->typ) { switch (lev->typ) {
case SDOOR: case SDOOR:
+17 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 pline.c $NHDT-Date: 1455672995 2016/02/17 01:36:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.48 $ */ /* NetHack 3.6 pline.c $NHDT-Date: 1456528597 2016/02/26 23:16:37 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.49 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -397,6 +397,22 @@ register struct monst *mtmp;
} }
} else if (mtmp->mpeaceful) } else if (mtmp->mpeaceful)
Strcat(info, ", peaceful"); Strcat(info, ", peaceful");
if (mtmp->data == &mons[PM_LONG_WORM]) {
int segndx, nsegs = count_wsegs(mtmp);
/* the worm code internals don't consider the head of be one of
the worm's segments, but we count it as such when presenting
worm feedback to the player */
if (!nsegs) {
Strcat(info, ", single segment");
} else {
++nsegs; /* include head in the segment count */
segndx = wseg_at(mtmp, bhitpos.x, bhitpos.y);
Sprintf(eos(info), ", %d%s of %d segments",
segndx, ordin(segndx), nsegs);
}
}
if (mtmp->cham >= LOW_PM && mtmp->data != &mons[mtmp->cham]) if (mtmp->cham >= LOW_PM && mtmp->data != &mons[mtmp->cham])
/* don't reveal the innate form (chameleon, vampire, &c), /* don't reveal the innate form (chameleon, vampire, &c),
just expose the fact that this current form isn't it */ just expose the fact that this current form isn't it */
+35 -18
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 worm.c $NHDT-Date: 1446887540 2015/11/07 09:12:20 $ $NHDT-Branch: master $:$NHDT-Revision: 1.19 $ */ /* NetHack 3.6 worm.c $NHDT-Date: 1456528599 2016/02/26 23:16:39 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.20 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -89,11 +89,9 @@ get_wormno()
while (new_wormno < MAX_NUM_WORMS) { while (new_wormno < MAX_NUM_WORMS) {
if (!wheads[new_wormno]) if (!wheads[new_wormno])
return new_wormno; /* found an empty wtails[] slot at new_wormno return new_wormno; /* found empty wtails[] slot at new_wormno */
*/
new_wormno++; new_wormno++;
} }
return 0; /* level infested with worms */ return 0; /* level infested with worms */
} }
@@ -296,11 +294,9 @@ register struct monst *worm;
/* if (!wnum) return; bullet proofing */ /* if (!wnum) return; bullet proofing */
/* This does not work right now because mattacku() thinks that the head /* This does not work right now because mattacku() thinks that the head
* is * is out of range of the player. We might try to kludge, and bring
* out of range of the player. We might try to kludge, and bring the * the head within range for a tiny moment, but this needs a bit more
* head * looking at before we decide to do this.
* within range for a tiny moment, but this needs a bit more looking at
* before we decide to do this.
*/ */
for (seg = wtails[wnum]; seg; seg = seg->nseg) for (seg = wtails[wnum]; seg; seg = seg->nseg)
if (distu(seg->wx, seg->wy) < 3) if (distu(seg->wx, seg->wy) < 3)
@@ -373,7 +369,6 @@ struct obj *weap;
* it's head at "curr" and its tail at "new_tail". The old worm * it's head at "curr" and its tail at "new_tail". The old worm
* must be at least level 3 in order to produce a new worm. * must be at least level 3 in order to produce a new worm.
*/ */
new_worm = 0; new_worm = 0;
new_wnum = (worm->m_lev >= 3 && !rn2(3)) ? get_wormno() : 0; new_wnum = (worm->m_lev >= 3 && !rn2(3)) ? get_wormno() : 0;
if (new_wnum) { if (new_wnum) {
@@ -683,22 +678,19 @@ register xchar *nx, *ny;
} }
/* count_wsegs() /* count_wsegs()
* returns the number of visible segments that a worm has. * returns the number of segments that a worm has.
*/ */
int int
count_wsegs(mtmp) count_wsegs(mtmp)
struct monst *mtmp; struct monst *mtmp;
{ {
register int i = 0; register int i = 0;
register struct wseg *curr = (wtails[mtmp->wormno])->nseg; register struct wseg *curr;
/* if (!mtmp->wormno) return 0; bullet proofing */ if (mtmp->wormno) {
for (curr = wtails[mtmp->wormno]->nseg; curr; curr = curr->nseg)
while (curr) { i++;
i++;
curr = curr->nseg;
} }
return i; return i;
} }
@@ -802,4 +794,29 @@ int x1, y1, x2, y2;
return FALSE; return FALSE;
} }
/* construct an index number for a worm tail segment */
int
wseg_at(worm, x, y)
struct monst *worm;
int x, y;
{
int res = 0;
if (worm && worm->wormno && m_at(x, y) == worm) {
struct wseg *curr;
int i, n;
xchar wx = (xchar) x, wy = (xchar) y;
for (i = 0, curr = wtails[worm->wormno]; curr; curr = curr->nseg) {
if (curr->wx == wx && curr->wy == wy)
break;
++i;
}
for (n = i; curr; curr = curr->nseg)
++n;
res = n - i;
}
return res;
}
/*worm.c*/ /*worm.c*/
+20 -16
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 zap.c $NHDT-Date: 1449669396 2015/12/09 13:56:36 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.238 $ */ /* NetHack 3.6 zap.c $NHDT-Date: 1456528600 2016/02/26 23:16:40 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.247 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -55,21 +55,21 @@ STATIC_DCL int FDECL(spell_hit_bonus, (int));
STATIC_VAR const char are_blinded_by_the_flash[] = STATIC_VAR const char are_blinded_by_the_flash[] =
"are blinded by the flash!"; "are blinded by the flash!";
const char *const flash_types[] = const char *const flash_types[] = /* also used in buzzmu(mcastu.c) */
{ /* also used in buzzmu(mcastu.c) */ {
"magic missile", /* Wands must be 0-9 */ "magic missile", /* Wands must be 0-9 */
"bolt of fire", "bolt of cold", "sleep ray", "death ray", "bolt of fire", "bolt of cold", "sleep ray", "death ray",
"bolt of lightning", "", "", "", "", "bolt of lightning", "", "", "", "",
"magic missile", /* Spell equivalents must be 10-19 */ "magic missile", /* Spell equivalents must be 10-19 */
"fireball", "cone of cold", "sleep ray", "finger of death", "fireball", "cone of cold", "sleep ray", "finger of death",
"bolt of lightning", /* There is no spell, used for retribution */ "bolt of lightning", /* there is no spell, used for retribution */
"", "", "", "", "", "", "", "",
"blast of missiles", /* Dragon breath equivalents 20-29*/ "blast of missiles", /* Dragon breath equivalents 20-29*/
"blast of fire", "blast of frost", "blast of sleep gas", "blast of fire", "blast of frost", "blast of sleep gas",
"blast of disintegration", "blast of lightning", "blast of poison gas", "blast of disintegration", "blast of lightning",
"blast of acid", "", "" "blast of poison gas", "blast of acid", "", ""
}; };
/* /*
@@ -140,12 +140,13 @@ struct obj *otmp;
int dmg, otyp = otmp->otyp; int dmg, otyp = otmp->otyp;
const char *zap_type_text = "spell"; const char *zap_type_text = "spell";
struct obj *obj; struct obj *obj;
boolean disguised_mimic = boolean disguised_mimic = (mtmp->data->mlet == S_MIMIC
(mtmp->data->mlet == S_MIMIC && mtmp->m_ap_type != M_AP_NOTHING); && mtmp->m_ap_type != M_AP_NOTHING);
if (u.uswallow && mtmp == u.ustuck) if (u.uswallow && mtmp == u.ustuck)
reveal_invis = FALSE; reveal_invis = FALSE;
notonhead = (mtmp->mx != bhitpos.x || mtmp->my != bhitpos.y);
switch (otyp) { switch (otyp) {
case WAN_STRIKING: case WAN_STRIKING:
zap_type_text = "wand"; zap_type_text = "wand";
@@ -2523,6 +2524,8 @@ struct obj *obj; /* wand or spell */
{ {
int steedhit = FALSE; int steedhit = FALSE;
bhitpos.x = u.usteed->mx, bhitpos.y = u.usteed->my;
notonhead = FALSE;
switch (obj->otyp) { switch (obj->otyp) {
/* /*
* Wands that are allowed to hit the steed * Wands that are allowed to hit the steed
@@ -3915,6 +3918,7 @@ register int dx, dy;
if (type >= 0) if (type >= 0)
mon->mstrategy &= ~STRAT_WAITMASK; mon->mstrategy &= ~STRAT_WAITMASK;
buzzmonst: buzzmonst:
notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y);
if (zap_hit(find_mac(mon), spell_type)) { if (zap_hit(find_mac(mon), spell_type)) {
if (mon_reflects(mon, (char *) 0)) { if (mon_reflects(mon, (char *) 0)) {
if (cansee(mon->mx, mon->my)) { if (cansee(mon->mx, mon->my)) {