From: PatR Date: Fri, 26 Feb 2016 23:16:49 +0000 (-0800) Subject: segment feedback when probing long worms X-Git-Tag: NetHack-3.6.1_RC01~898 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a00c8068f03d583fe60f6b96532c54e4b4d7d023;p=nethack 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".) --- diff --git a/doc/fixes36.1 b/doc/fixes36.1 index 4a9403068..7003206ed 100644 --- a/doc/fixes36.1 +++ b/doc/fixes36.1 @@ -228,6 +228,7 @@ allow some extra color name aliases for menucolors and status hilites add extended command #kick 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 '*' +feedback from probing of long worm now includes number of segments it has Platform- and/or Interface-Specific New Features diff --git a/include/extern.h b/include/extern.h index 81a0f3dcc..34d200bba 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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. */ /* 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 boolean FDECL(worm_known, (struct monst *)); E boolean FDECL(worm_cross, (int, int, int, int)); +E int FDECL(wseg_at, (struct monst *, int, int)); /* ### worn.c ### */ diff --git a/src/apply.c b/src/apply.c index 2af9d245d..28bb61fc4 100644 --- a/src/apply.c +++ b/src/apply.c @@ -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. */ /* NetHack may be freely redistributed. See license for details. */ @@ -323,6 +323,8 @@ register struct obj *obj; context.stethoscope_move = moves; 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 (interference) { 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, 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 (!canspotmon(mtmp)) There("is %s hidden there.", mnm); @@ -393,6 +399,7 @@ register struct obj *obj; } else if (flags.verbose && !canspotmon(mtmp)) { There("is %s there.", mnm); } + mstatusline(mtmp); if (!canspotmon(mtmp)) map_invisible(rx, ry); @@ -403,6 +410,7 @@ register struct obj *obj; newsym(rx, ry); pline_The("invisible monster must have moved."); } + lev = &levl[rx][ry]; switch (lev->typ) { case SDOOR: diff --git a/src/pline.c b/src/pline.c index 0c9a400e3..3775a7c14 100644 --- a/src/pline.c +++ b/src/pline.c @@ -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. */ /* NetHack may be freely redistributed. See license for details. */ @@ -397,6 +397,22 @@ register struct monst *mtmp; } } else if (mtmp->mpeaceful) 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]) /* don't reveal the innate form (chameleon, vampire, &c), just expose the fact that this current form isn't it */ diff --git a/src/worm.c b/src/worm.c index 5d41c59f4..839b0193e 100644 --- a/src/worm.c +++ b/src/worm.c @@ -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. */ /* NetHack may be freely redistributed. See license for details. */ @@ -89,11 +89,9 @@ get_wormno() while (new_wormno < MAX_NUM_WORMS) { 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++; } - return 0; /* level infested with worms */ } @@ -296,11 +294,9 @@ register struct monst *worm; /* if (!wnum) return; bullet proofing */ /* This does not work right now because mattacku() thinks that the head - * is - * out of range of the player. We might try to kludge, and bring the - * head - * within range for a tiny moment, but this needs a bit more looking at - * before we decide to do this. + * is out of range of the player. We might try to kludge, and bring + * the head 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) 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 * must be at least level 3 in order to produce a new worm. */ - new_worm = 0; new_wnum = (worm->m_lev >= 3 && !rn2(3)) ? get_wormno() : 0; if (new_wnum) { @@ -683,22 +678,19 @@ register xchar *nx, *ny; } /* count_wsegs() - * returns the number of visible segments that a worm has. + * returns the number of segments that a worm has. */ int count_wsegs(mtmp) struct monst *mtmp; { register int i = 0; - register struct wseg *curr = (wtails[mtmp->wormno])->nseg; + register struct wseg *curr; - /* if (!mtmp->wormno) return 0; bullet proofing */ - - while (curr) { - i++; - curr = curr->nseg; + if (mtmp->wormno) { + for (curr = wtails[mtmp->wormno]->nseg; curr; curr = curr->nseg) + i++; } - return i; } @@ -802,4 +794,29 @@ int x1, y1, x2, y2; 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*/ diff --git a/src/zap.c b/src/zap.c index 38d797e5a..d8784d12b 100644 --- a/src/zap.c +++ b/src/zap.c @@ -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. */ /* 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[] = "are blinded by the flash!"; -const char *const flash_types[] = - { /* also used in buzzmu(mcastu.c) */ - "magic missile", /* Wands must be 0-9 */ - "bolt of fire", "bolt of cold", "sleep ray", "death ray", - "bolt of lightning", "", "", "", "", - - "magic missile", /* Spell equivalents must be 10-19 */ - "fireball", "cone of cold", "sleep ray", "finger of death", - "bolt of lightning", /* There is no spell, used for retribution */ - "", "", "", "", - - "blast of missiles", /* Dragon breath equivalents 20-29*/ - "blast of fire", "blast of frost", "blast of sleep gas", - "blast of disintegration", "blast of lightning", "blast of poison gas", - "blast of acid", "", "" +const char *const flash_types[] = /* also used in buzzmu(mcastu.c) */ + { + "magic missile", /* Wands must be 0-9 */ + "bolt of fire", "bolt of cold", "sleep ray", "death ray", + "bolt of lightning", "", "", "", "", + + "magic missile", /* Spell equivalents must be 10-19 */ + "fireball", "cone of cold", "sleep ray", "finger of death", + "bolt of lightning", /* there is no spell, used for retribution */ + "", "", "", "", + + "blast of missiles", /* Dragon breath equivalents 20-29*/ + "blast of fire", "blast of frost", "blast of sleep gas", + "blast of disintegration", "blast of lightning", + "blast of poison gas", "blast of acid", "", "" }; /* @@ -140,12 +140,13 @@ struct obj *otmp; int dmg, otyp = otmp->otyp; const char *zap_type_text = "spell"; struct obj *obj; - boolean disguised_mimic = - (mtmp->data->mlet == S_MIMIC && mtmp->m_ap_type != M_AP_NOTHING); + boolean disguised_mimic = (mtmp->data->mlet == S_MIMIC + && mtmp->m_ap_type != M_AP_NOTHING); if (u.uswallow && mtmp == u.ustuck) reveal_invis = FALSE; + notonhead = (mtmp->mx != bhitpos.x || mtmp->my != bhitpos.y); switch (otyp) { case WAN_STRIKING: zap_type_text = "wand"; @@ -2523,6 +2524,8 @@ struct obj *obj; /* wand or spell */ { int steedhit = FALSE; + bhitpos.x = u.usteed->mx, bhitpos.y = u.usteed->my; + notonhead = FALSE; switch (obj->otyp) { /* * Wands that are allowed to hit the steed @@ -3915,6 +3918,7 @@ register int dx, dy; if (type >= 0) mon->mstrategy &= ~STRAT_WAITMASK; buzzmonst: + notonhead = (mon->mx != bhitpos.x || mon->my != bhitpos.y); if (zap_hit(find_mac(mon), spell_type)) { if (mon_reflects(mon, (char *) 0)) { if (cansee(mon->mx, mon->my)) {