Пример #1
0
int
getdir(boolean s)
{
	char dirsym;

	if(s) pline("In what direction?");
	dirsym = readchar();
	if(!movecmd(dirsym) && !u.dz) {
		if(!strchr(quitchars, dirsym))
			pline("What a strange direction!");
		return(0);
	}
	if(Confusion && !u.dz)
		confdir();
	return(1);
}
Пример #2
0
void
rhack(const char *cmd)
{
	const struct func_tab *tlist = cmdlist;
	boolean         firsttime = FALSE;
	int res;

	if (!cmd) {
		firsttime = TRUE;
		flags.nopick = 0;
		cmd = parse();
	}
	if (!*cmd || (*cmd & 0377) == 0377 ||
	    (flags.no_rest_on_space && *cmd == ' ')) {
		sound_bell();
		flags.move = 0;
		return;		/* probably we just had an interrupt */
	}
	if (movecmd(*cmd)) {
walk:
		if (multi)
			flags.mv = 1;
		domove();
		return;
	}
	if (movecmd(lowc(*cmd))) {
		flags.run = 1;
rush:
		if (firsttime) {
			if (!multi)
				multi = COLNO;
			u.last_str_turn = 0;
		}
		flags.mv = 1;
#ifdef QUEST
		if (flags.run >= 4)
			finddir();
		if (firsttime) {
			u.ux0 = u.ux + u.dx;
			u.uy0 = u.uy + u.dy;
		}
#endif	/* QUEST */
		domove();
		return;
	}
	if ((*cmd == 'f' && movecmd(cmd[1])) || movecmd(unctrl(*cmd))) {
		flags.run = 2;
		goto rush;
	}
	if (*cmd == 'F' && movecmd(lowc(cmd[1]))) {
		flags.run = 3;
		goto rush;
	}
	if (*cmd == 'm' && movecmd(cmd[1])) {
		flags.run = 0;
		flags.nopick = 1;
		goto walk;
	}
	if (*cmd == 'M' && movecmd(lowc(cmd[1]))) {
		flags.run = 1;
		flags.nopick = 1;
		goto rush;
	}
#ifdef QUEST
	if (*cmd == cmd[1] && (*cmd == 'f' || *cmd == 'F')) {
		flags.run = 4;
		if (*cmd == 'F')
			flags.run += 2;
		if (cmd[2] == '-')
			flags.run += 1;
		goto rush;
	}
#endif	/* QUEST */
	while (tlist->f_char) {
		if (*cmd == tlist->f_char) {
			res = (*(tlist->f_funct)) ();
			if (!res) {
				flags.move = 0;
				multi = 0;
			}
			return;
		}
		tlist++;
	}
	{
		char            expcmd[10];
		char  *cp = expcmd;
		while (*cmd && cp - expcmd < (int)sizeof(expcmd) - 2) {
			if (*cmd >= 040 && *cmd < 0177)
				*cp++ = *cmd++;
			else {
				*cp++ = '^';
				*cp++ = *cmd++ ^ 0100;
			}
		}
		*cp++ = 0;
		pline("Unknown command '%s'.", expcmd);
	}
	multi = flags.move = 0;
}
Пример #3
0
static int
use_pick_axe(struct obj *obj)
{
	char dirsyms[12];
	extern char sdir[];
	char *dsp = dirsyms, *sdp = sdir;
	struct monst *mtmp;
	struct rm *lev;
	int rx, ry, res = 0;

	if(obj != uwep) {
		if(uwep && uwep->cursed) {
			/* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */
			pline("Since your weapon is welded to your hand,");
			pline("you cannot use that pick-axe.");
			return(0);
		}
		pline("You now wield %s.", doname(obj));
		setuwep(obj);
		res = 1;
	}
	while(*sdp) {
		(void) movecmd(*sdp);	/* sets u.dx and u.dy and u.dz */
		rx = u.ux + u.dx;
		ry = u.uy + u.dy;
		if(u.dz > 0 || (u.dz == 0 && isok(rx, ry) &&
		    (IS_ROCK(levl[rx][ry].typ)
		    || sobj_at(ENORMOUS_ROCK, rx, ry))))
			*dsp++ = *sdp;
		sdp++;
	}
	*dsp = 0;
	pline("In what direction do you want to dig? [%s] ", dirsyms);
	if(!getdir(0))		/* no txt */
		return(res);
	if(u.uswallow && attack(u.ustuck)) /* return(1) */;
	else
	if(u.dz < 0)
		pline("You cannot reach the ceiling.");
	else
	if(u.dz == 0) {
		if(Confusion)
			confdir();
		rx = u.ux + u.dx;
		ry = u.uy + u.dy;
		if((mtmp = m_at(rx, ry)) && attack(mtmp))
			return(1);
		if(!isok(rx, ry)) {
			pline("Clash!");
			return(1);
		}
		lev = &levl[rx][ry];
		if(lev->typ == DOOR)
			pline("Your %s against the door.",
				aobjnam(obj, "clang"));
		else if(!IS_ROCK(lev->typ)
		     && !sobj_at(ENORMOUS_ROCK, rx, ry)) {
			/* ACCESSIBLE or POOL */
			pline("You swing your %s through thin air.",
				aobjnam(obj, (char *) 0));
		} else {
			if(dig_pos.x != rx || dig_pos.y != ry
			    || dig_level != dlevel || dig_down) {
				dig_down = FALSE;
				dig_pos.x = rx;
				dig_pos.y = ry;
				dig_level = dlevel;
				dig_effort = 0;
				pline("You start digging.");
			} else
				pline("You continue digging.");
			occupation = dig;
			occtxt = "digging";
		}
	} else if(Levitation) {
		pline("You cannot reach the floor.");
	} else {
		if(dig_pos.x != u.ux || dig_pos.y != u.uy
		    || dig_level != dlevel || !dig_down) {
			dig_down = TRUE;
			dig_pos.x = u.ux;
			dig_pos.y = u.uy;
			dig_level = dlevel;
			dig_effort = 0;
			pline("You start digging in the floor.");
			if(inshop())
				shopdig(0);
		} else
			pline("You continue digging in the floor.");
		occupation = dig;
		occtxt = "digging";
	}
	return(1);
}