Пример #1
0
int
do_mname(const struct nh_cmd_arg *arg)
{
    coord cc;
    int cx, cy;
    struct monst *mtmp;
    const char *qbuf, *buf;

    if (Hallucination) {
        pline(msgc_cancelled, "You would never recognize it anyway.");
        return 0;
    }
    cc.x = youmonst.mx;
    cc.y = youmonst.my;
    if (getargpos(arg, &cc, FALSE, "the monster you want to name") ==
        NHCR_CLIENT_CANCEL || (cx = cc.x) < 0)
        return 0;
    cy = cc.y;

    if (cx == youmonst.mx && cy == youmonst.my) {
        if (u.usteed && canspotmon(u.usteed))
            mtmp = u.usteed;
        else {
            pline(msgc_cancelled,
                  "This %s creature is called %s and cannot be renamed.",
                  beautiful(), u.uplname);
            return 0;
        }
    } else
        mtmp = vismon_at(level, cx, cy);

    unsigned msense_status = mtmp ? msensem(&youmonst, mtmp) : 0;

    if (!(msense_status & ~MSENSE_ITEMMIMIC)) {
        pline(msgc_mispaste, "I see no monster there.");
        return 0;
    } else if (!(msense_status & (MSENSE_ANYDETECT | MSENSE_ANYVISION))) {
        pline(msgc_cancelled,
              "You can't see it well enough to recognise it in the future.");
        return 0;
    }

    /* special case similar to the one in lookat() */
    qbuf = distant_monnam(mtmp, NULL, ARTICLE_THE);
    qbuf = msgprintf("What do you want to call %s?", qbuf);
    buf = getarglin(arg, qbuf);
    if (!*buf || *buf == '\033')
        return 0;
    /* strip leading and trailing spaces; unnames monster if all spaces */
    buf = msgmungspaces(buf);

    if (mtmp->data->geno & G_UNIQ) {
        qbuf = msgupcasefirst(distant_monnam(mtmp, NULL, ARTICLE_THE));
        pline(msgc_cancelled, "%s doesn't like being called names!", qbuf);
    } else
        christen_monst(mtmp, buf);
    return 0;
}
Пример #2
0
int do_mname(void)
{
	char buf[BUFSZ];
	coord cc;
	int cx,cy;
	struct monst *mtmp;
	char qbuf[QBUFSZ];

	if (Hallucination) {
		pline("You would never recognize it anyway.");
		return 0;
	}
	cc.x = u.ux;
	cc.y = u.uy;
	if (getpos(&cc, FALSE, "the monster you want to name") < 0 ||
			(cx = cc.x) < 0)
		return 0;
	cy = cc.y;

	if (cx == u.ux && cy == u.uy) {
	    if (u.usteed && canspotmon(u.usteed))
		mtmp = u.usteed;
	    else {
		pline("This %s creature is called %s and cannot be renamed.",
		ACURR(A_CHA) > 14 ?
		(flags.female ? "beautiful" : "handsome") :
		"ugly",
		plname);
		return 0;
	    }
	} else
	    mtmp = m_at(level, cx, cy);

	if (!mtmp || (!sensemon(mtmp) &&
			(!(cansee(cx,cy) || see_with_infrared(mtmp)) || mtmp->mundetected
			|| mtmp->m_ap_type == M_AP_FURNITURE
			|| mtmp->m_ap_type == M_AP_OBJECT
			|| (mtmp->minvis && !See_invisible)))) {
		pline("I see no monster there.");
		return 0;
	}
	/* special case similar to the one in lookat() */
	distant_monnam(mtmp, ARTICLE_THE, buf);
	sprintf(qbuf, "What do you want to call %s?", buf);
	getlin(qbuf,buf);
	if (!*buf || *buf == '\033') return 0;
	/* strip leading and trailing spaces; unnames monster if all spaces */
	mungspaces(buf);

	if (mtmp->data->geno & G_UNIQ) {
	    distant_monnam(mtmp, ARTICLE_THE, buf);
	    *buf = highc(*buf);
	    pline("%s doesn't like being called names!", buf);
	} else
	    christen_monst(mtmp, buf);
	return 0;
}
Пример #3
0
static void
describe_mon(int x, int y, int monnum, char *buf)
{
    char race[QBUFSZ];
    const char *name;
    boolean accurate = !Hallucination;
    char steedbuf[BUFSZ];
    struct monst *mtmp;
    char visionbuf[BUFSZ], temp_buf[BUFSZ];

    static const int maximum_output_len = 78;

    if (monnum == -1)
        return;

    if (u.ux == x && u.uy == y && senseself()) {
        /* if not polymorphed, show both the role and the race */
        race[0] = 0;
        if (!Upolyd)
            snprintf(race, SIZE(race), "%s ", urace.adj);

        sprintf(buf, "%s%s%s called %s", Invis ? "invisible " : "", race,
                mons[u.umonnum].mname, u.uplname);

        if (u.usteed) {
            snprintf(steedbuf, SIZE(steedbuf), ", mounted on %s", y_monnam(u.usteed));
            /* assert((sizeof buf >= strlen(buf)+strlen(steedbuf)+1); */
            strcat(buf, steedbuf);
        }
        /* When you see yourself normally, no explanation is appended (even if
           you could also see yourself via other means). Sensing self while
           blind or swallowed is treated as if it were by normal vision (cf
           canseeself()). */
        if ((Invisible || u.uundetected) && !Blind && !Engulfed) {
            unsigned how = 0;

            if (Infravision)
                how |= 1;
            if (Unblind_telepat)
                how |= 2;
            if (Detect_monsters)
                how |= 4;

            if (how)
                sprintf(buf + strlen(buf), " [seen: %s%s%s%s%s]",
                        (how & 1) ? "infravision" : "",
                        /* add comma if telep and infrav */
                        ((how & 3) > 2) ? ", " : "",
                        (how & 2) ? "telepathy" : "",
                        /* add comma if detect and (infrav or telep or both) */
                        ((how & 7) > 4) ? ", " : "",
                        (how & 4) ? "monster detection" : "");
        }

    } else if (monnum >= NUMMONS) {
        monnum -= NUMMONS;
        if (monnum < WARNCOUNT)
            strcat(buf, warnexplain[monnum]);

    } else if ((mtmp = m_at(level, x, y))) {
        bhitpos.x = x;
        bhitpos.y = y;

        if (mtmp->data == &mons[PM_COYOTE] && accurate && !mtmp->mpeaceful)
            name = an(coyotename(mtmp));
        else
            name = distant_monnam(
                mtmp, (mtmp->mtame && accurate) ? "tame" :
                (mtmp->mpeaceful && accurate) ? "peaceful" : NULL,
                ARTICLE_A);

        boolean spotted = canspotmon(mtmp);

        if (!spotted && (mtmp->mx != x || mtmp->my != y))
            name = "an unseen long worm";
        else if (!spotted)
            /* we can't safely impossible/panic from this point in the code;
               well, we /could/, but as it's called on every mouse movement,
               it'd quickly get very confusing and possibly lead to recursive
               panics; just put up an obvious message instead */
            name = "a <BUG: monster both seen and unseen>";

        snprintf(buf, BUFSZ-1, "%s%s",
                (mtmp->mx != x || mtmp->my != y) ? "tail of " : "", name);
        buf[BUFSZ-1] = '\0';
        if (u.ustuck == mtmp)
            strcat(buf,
                   (Upolyd &&
                    sticks(youmonst.data)) ? ", being held" : ", holding you");
        if (mtmp->mleashed)
            strcat(buf, ", leashed to you");

        if (mtmp->mtrapped && cansee(mtmp->mx, mtmp->my)) {
            struct trap *t = t_at(level, mtmp->mx, mtmp->my);
            int tt = t ? t->ttyp : NO_TRAP;

            /* newsym lets you know of the trap, so mention it here */
            if (tt == BEAR_TRAP || tt == PIT || tt == SPIKED_PIT || tt == WEB)
                sprintf(buf + strlen(buf),
                        ", trapped in %s", an(trapexplain[tt - 1]));
        }

#ifdef DEBUG_STRATEGY
        if (wizard) {
            snprintf(temp_buf, SIZE(temp_buf),
                     ", strategy %08lx, muxy %02x%02x",
                     (unsigned long)mtmp->mstrategy,
                     (int)mtmp->mux, (int)mtmp->muy);
            strncat(buf, temp_buf, maximum_output_len - strlen(buf) - 1);
        }
#endif

        /* Don't mention how a long worm tail is seen; msensem() only works on
           monster heads. (Probably, the only unusual way to see a long worm
           tail is see invisible, anyway.) */
        if (mtmp->mx == x && mtmp->my == y) {
            mon_vision_summary(mtmp, visionbuf);
            if (visionbuf[0]) {
                snprintf(temp_buf, SIZE(temp_buf), " [seen: %s]", visionbuf);
                strncat(buf, temp_buf, maximum_output_len - strlen(buf) - 1);
            }
        }
    }
}
Пример #4
0
static void describe_mon(int x, int y, int monnum, char *buf)
{
    char race[QBUFSZ];
    char *name, monnambuf[BUFSZ];
    boolean accurate = !Hallucination;
    char steedbuf[BUFSZ];
    struct monst *mtmp;
    char visionbuf[BUFSZ], temp_buf[BUFSZ];
    
    if (monnum == -1)
	return;
    
    if (u.ux == x && u.uy == y && senseself()) {
	/* if not polymorphed, show both the role and the race */
	race[0] = 0;
	if (!Upolyd)
	    sprintf(race, "%s ", urace.adj);

	sprintf(buf, "%s%s%s called %s",
		Invis ? "invisible " : "",
		race,
		mons[u.umonnum].mname,
		plname);
	
	if (u.usteed) {
	    sprintf(steedbuf, ", mounted on %s", y_monnam(u.usteed));
	    /* assert((sizeof buf >= strlen(buf)+strlen(steedbuf)+1); */
	    strcat(buf, steedbuf);
	}
	/* When you see yourself normally, no explanation is appended
	(even if you could also see yourself via other means).
	Sensing self while blind or swallowed is treated as if it
	were by normal vision (cf canseeself()). */
	if ((Invisible || u.uundetected) && !Blind && !u.uswallow) {
	    unsigned how = 0;

	    if (Infravision)	 how |= 1;
	    if (Unblind_telepat) how |= 2;
	    if (Detect_monsters) how |= 4;

	    if (how)
		sprintf(eos(buf), " [seen: %s%s%s%s%s]",
			(how & 1) ? "infravision" : "",
			/* add comma if telep and infrav */
			((how & 3) > 2) ? ", " : "",
			(how & 2) ? "telepathy" : "",
			/* add comma if detect and (infrav or telep or both) */
			((how & 7) > 4) ? ", " : "",
			(how & 4) ? "monster detection" : "");
	}
	
    } else if (monnum >= NUMMONS) {
	monnum -= NUMMONS;
	if (monnum < WARNCOUNT)
	    strcat(buf, warnexplain[monnum]);
	
    } else if ( (mtmp = m_at(level, x,y)) ) {
	bhitpos.x = x;
	bhitpos.y = y;

	if (mtmp->data == &mons[PM_COYOTE] && accurate)
	    name = coyotename(mtmp, monnambuf);
	else
	    name = distant_monnam(mtmp, ARTICLE_NONE, monnambuf);

	sprintf(buf, "%s%s%s",
		(mtmp->mx != x || mtmp->my != y) ?
		    ((mtmp->isshk && accurate)
			    ? "tail of " : "tail of a ") : "",
		(mtmp->mtame && accurate) ? "tame " :
		(mtmp->mpeaceful && accurate) ? "peaceful " : "",
		name);
	if (u.ustuck == mtmp)
	    strcat(buf, (Upolyd && sticks(youmonst.data)) ?
		    ", being held" : ", holding you");
	if (mtmp->mleashed)
	    strcat(buf, ", leashed to you");

	if (mtmp->mtrapped && cansee(mtmp->mx, mtmp->my)) {
	    struct trap *t = t_at(level, mtmp->mx, mtmp->my);
	    int tt = t ? t->ttyp : NO_TRAP;

	    /* newsym lets you know of the trap, so mention it here */
	    if (tt == BEAR_TRAP || tt == PIT ||
		    tt == SPIKED_PIT || tt == WEB)
		sprintf(eos(buf), ", trapped in %s", an(trapexplain[tt]));
	}

	mon_vision_summary(mtmp, visionbuf);
	if (visionbuf[0]) {
	    sprintf(temp_buf, " [seen: %s]", visionbuf);
	    strncat(buf, temp_buf, BUFSZ-strlen(buf)-1);
	}
    }
}