示例#1
0
void
init_objects()
{
	int i, j, first, last, sum, end;
	char let, *tmp;

	/* init base; if probs given check that they add up to 100, 
	   otherwise compute probs; shuffle descriptions */
	end = nitems(objects);
	first = 0;
	while( first < end ) {
		let = objects[first].oc_olet;
		last = first+1;
		while(last < end && objects[last].oc_olet == let
				&& objects[last].oc_name != NULL)
			last++;
		i = letindex(let);
		if((!i && let != ILLOBJ_SYM) || bases[i] != 0)
			error("initialization error");
		bases[i] = first;

		if(let == GEM_SYM)
			setgemprobs();
	check:
		sum = 0;
		for(j = first; j < last; j++) sum += objects[j].oc_prob;
		if(sum == 0) {
			for(j = first; j < last; j++)
			    objects[j].oc_prob = (100+j-first)/(last-first);
			goto check;
		}
		if(sum != 100)
			error("init-prob error for %c", let);

		if(objects[first].oc_descr != NULL && let != TOOL_SYM){
			/* shuffle, also some additional descriptions */
			while(last < end && objects[last].oc_olet == let)
				last++;
			j = last;
			while(--j > first) {
				i = first + rn2(j+1-first);
				tmp = objects[j].oc_descr;
				objects[j].oc_descr = objects[i].oc_descr;
				objects[i].oc_descr = tmp;
			}
		}
		first = last;
	}
}
示例#2
0
boolean
create_drawbridge(int x, int y, int dir, int flag)
{
    int x2,y2;
    boolean horiz;
    boolean lava = levl[x][y].typ == LAVAPOOL; /* assume initialized map */

    if (flag < 0 || flag > 1) flag = rn2(2);
    x2 = x;
    y2 = y;
    switch(dir) {
    case DB_NORTH:
        horiz = TRUE;
        y2--;
        break;
    case DB_SOUTH:
        horiz = TRUE;
        y2++;
        break;
    case DB_EAST:
        horiz = FALSE;
        x2++;
        break;
    default:
        impossible("bad direction in create_drawbridge");
        /* fall through */
    case DB_WEST:
        horiz = FALSE;
        x2--;
        break;
    }
    if (!IS_WALL(levl[x2][y2].typ))
        return(FALSE);
    if (flag) {             /* We want the bridge open */
        levl[x][y].typ = DRAWBRIDGE_DOWN;
        levl[x2][y2].typ = DOOR;
        levl[x2][y2].doormask = D_NODOOR;
    } else {
        levl[x][y].typ = DRAWBRIDGE_UP;
        levl[x2][y2].typ = DBWALL;
        /* Drawbridges are non-diggable. */
        levl[x2][y2].wall_info = W_NONDIGGABLE;
    }
    levl[x][y].horizontal = !horiz;
    levl[x2][y2].horizontal = horiz;
    levl[x][y].drawbridgemask = dir;
    if(lava) levl[x][y].drawbridgemask |= DB_LAVA;
    return(TRUE);
}
示例#3
0
BOOL WINAPI PlayerSelectProc(HWND hDlg, UINT messg, UINT wParam, LONG lParam)
{
	int i;

	switch (messg) {
		case WM_INITDIALOG:
			CheckRadioButton(hDlg,IDD_ARCH,IDD_RAND,IDD_RAND);
			nCurrentChar = IDD_RAND;
			return TRUE;
		case WM_COMMAND:
			switch (wParam) {
			   case IDOK:
				if (nCurrentChar == IDD_RAND) {
					i = rn2((int)strlen(pl_classes));
					pl_character[0] = pl_classes[i];
				} else	{
					pl_character[0] = 
					   pl_classes[nCurrentChar-IDD_ARCH];
				}
				EndDialog(hDlg,TRUE);
				return TRUE;
				break;
			   case IDCANCEL:
				pl_character[0] = 0;
				EndDialog(hDlg,FALSE);
				return TRUE;
				break;
			   case IDD_ARCH:
			   case IDD_BARB:
			   case IDD_CAVEMAN:
			   case IDD_ELF:
			   case IDD_HEAL:
			   case IDD_KNIGHT:
			   case IDD_PRIEST:
			   case IDD_ROGUE:
			   case IDD_SAM:
			   case IDD_TOUR:
			   case IDD_VAL:
			   case IDD_WIZ:
			   case IDD_RAND:
				nCurrentChar = wParam;
				CheckRadioButton(hDlg,IDD_ARCH,
						 IDD_RAND,wParam);
				return TRUE;
				break;
		}
	}
	return FALSE;
}
示例#4
0
struct monst *
boomhit(int dx, int dy)
{
	int i, ct;
	struct monst *mtmp;
	char sym = ')';

	bhitpos.x = u.ux;
	bhitpos.y = u.uy;

	for (i = 0; i < 8; i++)
		if (xdir[i] == dx && ydir[i] == dy)
			break;
	tmp_at(-1, sym);	/* open call */
	for (ct = 0; ct < 10; ct++) {
		if (i == 8)
			i = 0;
		sym = ')' + '(' - sym;
		tmp_at(-2, sym);	/* change let call */
		dx = xdir[i];
		dy = ydir[i];
		bhitpos.x += dx;
		bhitpos.y += dy;
		if ((mtmp = m_at(bhitpos.x, bhitpos.y)) != NULL) {
			tmp_at(-1, -1);
			return (mtmp);
		}
		if (!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ)) {
			bhitpos.x -= dx;
			bhitpos.y -= dy;
			break;
		}
		if (bhitpos.x == u.ux && bhitpos.y == u.uy) {	/* ct == 9 */
			if (rn2(20) >= 10 + u.ulevel) {	/* we hit ourselves */
				thitu(10, rnd(10), "boomerang");
				break;
			} else {	/* we catch it */
				tmp_at(-1, -1);
				pline("Skillfully, you catch the boomerang.");
				return (&youmonst);
			}
		}
		tmp_at(bhitpos.x, bhitpos.y);
		if (ct % 5 != 0)
			i++;
	}
	tmp_at(-1, -1);		/* do not leave last symbol */
	return (0);
}
示例#5
0
/* drop (perhaps) a cadaver and remove monster */
void
mondied(struct monst *mdef)
{
	struct permonst *pd = mdef->data;

	if (letter(pd->mlet) && rn2(3)) {
		mkobj_at(pd->mlet, mdef->mx, mdef->my);
		if (cansee(mdef->mx, mdef->my)) {
			unpmon(mdef);
			atl(mdef->mx, mdef->my, fobj->olet);
		}
		stackobj(fobj);
	}
	mondead(mdef);
}
示例#6
0
const struct permonst *
courtmon(const d_level * dlev)
{
    int i = rn2(60) + rn2(3 * level_difficulty(dlev));

    if (i > 100)
        return mkclass(dlev, S_DRAGON, 0);
    else if (i > 95)
        return mkclass(dlev, S_GIANT, 0);
    else if (i > 85)
        return mkclass(dlev, S_TROLL, 0);
    else if (i > 75)
        return mkclass(dlev, S_CENTAUR, 0);
    else if (i > 60)
        return mkclass(dlev, S_ORC, 0);
    else if (i > 45)
        return &mons[PM_BUGBEAR];
    else if (i > 30)
        return &mons[PM_HOBGOBLIN];
    else if (i > 15)
        return mkclass(dlev, S_GNOME, 0);
    else
        return mkclass(dlev, S_KOBOLD, 0);
}
示例#7
0
/*
 * Get a random player name and class from the high score list,
 * and attach them to an object (for statues or morgue corpses).
 */
struct obj *
tt_oname(struct obj *otmp)
{
    int rank, fd;
    struct toptenentry *toptenlist, *tt;

    if (!otmp)
        return NULL;

    fd = open_datafile(RECORD, O_RDONLY, SCOREPREFIX);
    toptenlist = read_topten(fd, 100);  /* load the top 100 scores */
    close(fd);

    /* try to find a valid entry, reducing the value range for rank each time */
    rank = rn2(100);
    while (!validentry(toptenlist[rank]) && rank)
        rank = rn2(rank);

    tt = &toptenlist[rank];

    if (!validentry(toptenlist[rank]))
        otmp = NULL;    /* the topten list is empty */
    else {
        /* reset timer in case corpse started out as lizard or troll */
        if (otmp->otyp == CORPSE)
            obj_stop_timers(otmp);
        otmp->corpsenm = classmon(tt->plrole, (tt->plgend[0] == 'F'));
        otmp->owt = weight(otmp);
        otmp = oname(otmp, tt->name);
        if (otmp->otyp == CORPSE)
            start_corpse_timeout(otmp);
    }

    free(toptenlist);
    return otmp;
}
示例#8
0
struct obj *
mkobj(int let)
{
	if (!let)
		let = mkobjstr[rn2(sizeof(mkobjstr) - 1)];
	return (
		mksobj(
		       letter(let) ?
		       CORPSE +
		       ((let > 'Z') ? (let - 'a' + 'Z' - '@' +
				       1) : (let - '@'))
		       :   probtype(let)
		       )
		);
}
示例#9
0
int domindblast(void)
{
	struct monst *mtmp, *nmon;

	if (u.uen < 10) {
	    pline("You concentrate but lack the energy to maintain doing so.");
	    return 0;
	}
	u.uen -= 10;
	iflags.botl = 1;

	pline("You concentrate.");
	pline("A wave of psychic energy pours out.");
	for (mtmp=level->monlist; mtmp; mtmp = nmon) {
		int u_sen;

		nmon = mtmp->nmon;
		if (DEADMONSTER(mtmp))
			continue;
		if (distu(mtmp->mx, mtmp->my) > BOLT_LIM * BOLT_LIM)
			continue;
		if (mtmp->mpeaceful)
			continue;
		u_sen = telepathic(mtmp->data) && !mtmp->mcansee;
		if (u_sen || (telepathic(mtmp->data) && rn2(2)) || !rn2(10)) {
			pline("You lock in on %s %s.", s_suffix(mon_nam(mtmp)),
				u_sen ? "telepathy" :
				telepathic(mtmp->data) ? "latent telepathy" :
				"mind");
			mtmp->mhp -= rnd(15);
			if (mtmp->mhp <= 0)
				killed(mtmp);
		}
	}
	return 1;
}
示例#10
0
static void
mkswamp (void)  /* Michiel Huisjes & Fred de Wilde */
{
        struct mkroom *sroom;
        int sx,sy,i,eelct = 0;

        for(i=0; i<5; i++) {            /* turn up to 5 rooms swampy */
                sroom = &rooms[rn2(nroom)];
                if(sroom->hx < 0 || sroom->rtype != OROOM ||
                   has_upstairs(sroom) || has_dnstairs(sroom))
                        continue;

                /* satisfied; make a swamp */
                sroom->rtype = SWAMP;
                for(sx = sroom->lx; sx <= sroom->hx; sx++)
                for(sy = sroom->ly; sy <= sroom->hy; sy++)
                if(!OBJ_AT(sx, sy) &&
                   !MON_AT(sx, sy) && !t_at(sx,sy) && !nexttodoor(sx,sy)) {
                    if((sx+sy)%2) {
                        levl[sx][sy].typ = POOL;
                        if(!eelct || !rn2(4)) {
                            /* mkclass() won't do, as we might get kraken */
                            (void) makemon(rn2(5) ? &mons[PM_GIANT_EEL]
                                                  : rn2(2) ? &mons[PM_PIRANHA]
                                                  : &mons[PM_ELECTRIC_EEL],
                                                sx, sy, NO_MM_FLAGS);
                            eelct++;
                        }
                    } else
                        if(!rn2(4))     /* swamps tend to be moldy */
                            (void) makemon(mkclass(S_FUNGUS,0),
                                                sx, sy, NO_MM_FLAGS);
                }
                level.flags.has_swamp = 1;
        }
}
示例#11
0
boolean safe_teleds(boolean allow_drag)
{
	int nux, nuy, tcnt = 0;

	do {
		nux = rnd(COLNO-1);
		nuy = rn2(ROWNO);
	} while (!teleok(nux, nuy, (boolean)(tcnt > 200)) && ++tcnt <= 400);

	if (tcnt <= 400) {
		teleds(nux, nuy, allow_drag);
		return TRUE;
	} else
		return FALSE;
}
示例#12
0
/* pick an unused room, preferably with only one door */
static struct mkroom *
pick_room(struct level *lev, boolean strict)
{
    struct mkroom *sroom;
    int i = lev->nroom;

    for (sroom = &lev->rooms[rn2(lev->nroom)]; i--; sroom++) {
        if (sroom == &lev->rooms[lev->nroom])
            sroom = &lev->rooms[0];
        if (sroom->hx < 0)
            return NULL;
        if (sroom->rtype != OROOM)
            continue;
        if (!strict) {
            if (has_upstairs(lev, sroom) ||
                (has_dnstairs(lev, sroom) && rn2(3)))
                continue;
        } else if (has_upstairs(lev, sroom) || has_dnstairs(lev, sroom))
            continue;
        if (sroom->doorct == 1 || !rn2(5) || wizard)
            return sroom;
    }
    return NULL;
}
示例#13
0
文件: steed.c 项目: FredrIQ/nhfourk
/* The player kicks or whips the steed */
void
kick_steed(void)
{
    char He[4];

    if (!u.usteed)
        return;

    /* [ALI] Various effects of kicking sleeping/paralyzed steeds */
    if (u.usteed->msleeping || !u.usteed->mcanmove) {
        /* We assume a message has just been output of the form "You kick
           <steed>." */
        strcpy(He, mhe(u.usteed));
        *He = highc(*He);
        if ((u.usteed->mcanmove || u.usteed->mfrozen) && !rn2(2)) {
            if (u.usteed->mcanmove)
                u.usteed->msleeping = 0;
            else if (u.usteed->mfrozen > 2)
                u.usteed->mfrozen -= 2;
            else {
                u.usteed->mfrozen = 0;
                u.usteed->mcanmove = 1;
            }
            if (u.usteed->msleeping || !u.usteed->mcanmove)
                pline("%s stirs.", He);
            else
                pline("%s rouses %sself!", He, mhim(u.usteed));
        } else
            pline("%s does not respond.", He);
        return;
    }

    /* Make the steed less tame and check if it resists */
    if (u.usteed->mtame)
        u.usteed->mtame--;
    if (!u.usteed->mtame && u.usteed->mleashed)
        m_unleash(u.usteed, TRUE);
    if (!u.usteed->mtame ||
            (u.ulevel + u.usteed->mtame < rnd(MAXULEV / 2 + 5))) {
        newsym(u.usteed->mx, u.usteed->my);
        dismount_steed(DISMOUNT_THROWN);
        return;
    }

    pline("%s gallops!", Monnam(u.usteed));
    u.ugallop += rn1(20, 30);
    return;
}
示例#14
0
/* return TRUE if successful, FALSE if not */
boolean rloc(struct monst *mtmp, /* mx==0 implies migrating monster arrival */
	     boolean suppress_impossible)
{
	int x, y, trycount;

	if (mtmp == u.usteed) {
	    tele();
	    return TRUE;
	}

	if (mtmp->iswiz && mtmp->mx) {	/* Wizard, not just arriving */
	    if (!In_W_tower(u.ux, u.uy, &u.uz))
		x = level->upstair.sx,  y = level->upstair.sy;
	    else if (!level->dnladder.sx)	/* bottom level of tower */
		x = level->upladder.sx,  y = level->upladder.sy;
	    else
		x = level->dnladder.sx,  y = level->dnladder.sy;
	    /* if the wiz teleports away to heal, try the up staircase,
	       to block the player's escaping before he's healed
	       (deliberately use `goodpos' rather than `rloc_pos_ok' here) */
	    if (goodpos(level, x, y, mtmp, 0))
		goto found_xy;
	}

	trycount = 0;
	do {
	    x = rn1(COLNO-3,2);
	    y = rn2(ROWNO);
	    if ((trycount < 500) ? rloc_pos_ok(x, y, mtmp)
				 : goodpos(level, x, y, mtmp, 0))
		goto found_xy;
	} while (++trycount < 1000);

	/* last ditch attempt to find a good place */
	for (x = 2; x < COLNO - 1; x++)
	    for (y = 0; y < ROWNO; y++)
		if (goodpos(level, x, y, mtmp, 0))
		    goto found_xy;

	/* level either full of monsters or somehow faulty */
	if (!suppress_impossible)
		impossible("rloc(): couldn't relocate monster");
	return FALSE;

 found_xy:
	rloc_to(mtmp, x, y);
	return TRUE;
}
示例#15
0
void redist_attr (void) {
    int i, tmp;

    for(i = 0; i < A_MAX; i++) {
        if (i==A_INT || i==A_WIS) continue;
        /* Polymorphing doesn't change your mind */
        tmp = AMAX(i);
        AMAX(i) += (rn2(5)-2);
        if (AMAX(i) > ATTRMAX(i)) AMAX(i) = ATTRMAX(i);
        if (AMAX(i) < ATTRMIN(i)) AMAX(i) = ATTRMIN(i);
        ABASE(i) = ABASE(i) * AMAX(i) / tmp;
        /* ABASE(i) > ATTRMAX(i) is impossible */
        if (ABASE(i) < ATTRMIN(i)) ABASE(i) = ATTRMIN(i);
    }
    (void)encumber_msg();
}
示例#16
0
文件: hack.zap.c 项目: blakeney/slack
static void
rloco(struct obj *obj)
{
	int tx,ty,otx,oty;

	otx = obj->ox;
	oty = obj->oy;
	do {
		tx = rn1(COLNO-3,2);
		ty = rn2(ROWNO);
	} while(!goodpos(tx,ty));
	obj->ox = tx;
	obj->oy = ty;
	if(cansee(otx,oty))
		newsym(otx,oty);
}
示例#17
0
void
tele(void)
{
    coord cc;

    /* Disable teleportation in stronghold && Vlad's Tower */
    if (level->flags.noteleport) {
        if (!wizard) {
            pline("A mysterious force prevents you from teleporting!");
            return;
        }
    }

    /* don't show trap if "Sorry..." */
    if (!Blinded)
        make_blinded(0L, FALSE);

    if ((u.uhave.amulet || On_W_tower_level(&u.uz)) && !rn2(3)) {
        pline("You feel disoriented for a moment.");
        return;
    }
    if ((Teleport_control && !Stunned) || wizard) {
        if (unconscious()) {
            pline("Being unconscious, you cannot control your teleport.");
        } else {
            char buf[BUFSZ];

            if (u.usteed)
                sprintf(buf, " and %s", mon_nam(u.usteed));
            pline("To what position do you%s want to be teleported?",
                  u.usteed ? buf : "");
            cc.x = u.ux;
            cc.y = u.uy;
            if (getpos(&cc, TRUE, "the desired position") < 0)
                return; /* abort */
            /* possible extensions: introduce a small error if magic power is
               low; allow transfer to solid rock */
            if (teleok(cc.x, cc.y, FALSE)) {
                teleds(cc.x, cc.y, FALSE);
                return;
            }
            pline("Sorry...");
        }
    }

    safe_teleds(FALSE);
}
示例#18
0
文件: hack.zap.c 项目: blakeney/slack
/* bhitm: monster mtmp was hit by the effect of wand otmp */
static void
bhitm(struct monst *mtmp, struct obj *otmp)
{
	wakeup(mtmp);
	switch(otmp->otyp) {
	case WAN_STRIKING:
		if(u.uswallow || rnd(20) < 10+mtmp->data->ac) {
			int tmp = d(2,12);
			hit("wand", mtmp, exclam(tmp));
			mtmp->mhp -= tmp;
			if(mtmp->mhp < 1) killed(mtmp);
		} else miss("wand", mtmp);
		break;
	case WAN_SLOW_MONSTER:
		mtmp->mspeed = MSLOW;
		break;
	case WAN_SPEED_MONSTER:
		mtmp->mspeed = MFAST;
		break;
	case WAN_UNDEAD_TURNING:
		if(index(UNDEAD,mtmp->data->mlet)) {
			mtmp->mhp -= rnd(8);
			if(mtmp->mhp < 1) killed(mtmp);
			else mtmp->mflee = 1;
		}
		break;
	case WAN_POLYMORPH:
		newcham(mtmp,&mons[rn2(CMNUM)]);
		break;
	case WAN_CANCELLATION:
		mtmp->mcan = 1;
		break;
	case WAN_TELEPORTATION:
		rloc(mtmp);
		break;
	case WAN_MAKE_INVISIBLE:
		mtmp->minvis = 1;
		break;
#ifdef WAN_PROBING
	case WAN_PROBING:
		mstatusline(mtmp);
		break;
#endif /* WAN_PROBING */
	default:
		impossible("What an interesting wand (%u)", otmp->otyp);
	}
}
示例#19
0
void
mkmap(lev_init *init_lev)
{
    schar	bg_typ = init_lev->bg,
            fg_typ = init_lev->fg;
    boolean smooth = init_lev->smoothed,
            join = init_lev->joined;
    xchar   lit = init_lev->lit,
            walled = init_lev->walled;
    int i;

    if(lit < 0)
        lit = (rnd(1+abs(depth(&u.uz))) < 11 && rn2(77)) ? 1 : 0;

    new_locations = (char *)alloc((WIDTH+1) * HEIGHT);

    if (bg_typ < MAX_TYPE)
        init_map(bg_typ);
    init_fill(bg_typ, fg_typ);

    for(i = 0; i < N_P1_ITER; i++)
        pass_one(bg_typ, fg_typ);

    for(i = 0; i < N_P2_ITER; i++)
        pass_two(bg_typ, fg_typ);

    if(smooth)
        for(i = 0; i < N_P3_ITER; i++)
            pass_three(bg_typ, fg_typ);

    if(join)
        join_map(bg_typ, fg_typ);

    finish_map(fg_typ, bg_typ, (boolean)lit, (boolean)walled);
    /* a walled, joined level is cavernous, not mazelike -dlc
     *
     * also, caverns have a defined "inside" and "outside"; the outside
     * doesn't _have_ to be stone, say, for hell.  so if the player
     * defined a maze filler originally, go ahead and backfill the
     * background in with that filler - DSR */
    if (walled && join && (init_lev->filling > -1)) {
        level.flags.is_maze_lev = FALSE;
        level.flags.is_cavernous_lev = TRUE;
        backfill(bg_typ,init_lev->filling);
    }
    free(new_locations);
}
示例#20
0
文件: eat.c 项目: msharov/bsd-games
void newuhs (bool incr)
{
    int newhs, h = _u.uhunger;

    newhs = (h > 1000) ? SATIATED : (h > 150) ? NOT_HUNGRY : (h > 50) ? HUNGRY : (h > 0) ? WEAK : FAINTING;

    if (newhs == FAINTING) {
	if (_u.uhs == FAINTED)
	    newhs = FAINTED;
	if (_u.uhs <= WEAK || rn2(20 - _u.uhunger / 10) >= 19) {
	    if (_u.uhs != FAINTED && multi >= 0) {
		pline("You faint from lack of food.");
		nomul(-10 + (_u.uhunger / 10));
		nomovemsg = "You regain consciousness.";
		afternmv = unfaint;
		newhs = FAINTED;
	    }
	} else if (_u.uhunger < -(int) (200 + 25 * _u.ulevel)) {
	    _u.uhs = STARVED;
	    _wflags.botl = 1;
	    bot();
	    pline("You die from starvation.");
	    done("starved");
	}
    }
    if (newhs != _u.uhs) {
	if (newhs >= WEAK && _u.uhs < WEAK)
	    losestr(1);	       // this may kill you -- see below
	else if (newhs < WEAK && _u.uhs >= WEAK && _u.ustr < _u.ustrmax)
	    losestr(-1);
	switch (newhs) {
	    case HUNGRY:
		pline(!incr ? "You only feel hungry now." : (_u.uhunger < 145) ? "You feel hungry." : "You are beginning to feel hungry.");
		break;
	    case WEAK:
		pline(!incr ? "You feel weak now." : (_u.uhunger < 45) ? "You feel weak." : "You are beginning to feel weak.");
		break;
	}
	_u.uhs = newhs;
	_wflags.botl = 1;
	if (_u.uhp < 1) {
	    pline("You die from hunger and exhaustion.");
	    killer = "exhaustion";
	    done("starved");
	}
    }
}
示例#21
0
void mkzoo(int type)
{
    struct mkroom *sroom;
    struct monst *mon;
    int sh, sx, sy, i;
    int goldlim = 500 * dlevel;
    int moct = 0;

    i = nroom;
    for (sroom = &rooms[rn2(nroom)];; sroom++) {
	if (sroom == &rooms[nroom])
	    sroom = &rooms[0];
	if (!i-- || sroom->hx < 0)
	    return;
	if (sroom->rtype)
	    continue;
	if (type == MORGUE && sroom->rlit)
	    continue;
	if (has_upstairs(sroom) || (has_dnstairs(sroom) && rn2(3)))
	    continue;
	if (sroom->doorct == 1 || !rn2(5))
	    break;
    }
    sroom->rtype = type;
    sh = sroom->fdoor;
    for (sx = sroom->lx; sx <= sroom->hx; sx++)
	for (sy = sroom->ly; sy <= sroom->hy; sy++) {
	    if ((sx == sroom->lx && doors[sh].x == sx - 1) || (sx == sroom->hx && doors[sh].x == sx + 1) || (sy == sroom->ly && doors[sh].y == sy - 1) || (sy == sroom->hy && doors[sh].y == sy + 1))
		continue;
	    mon = makemon((type == MORGUE) ? morguemon() : (type == BEEHIVE) ? PM_KILLER_BEE : (struct permonst *) 0, sx, sy);
	    if (mon)
		mon->msleep = 1;
	    switch (type) {
		case ZOO:
		    i = sq(dist2(sx, sy, doors[sh].x, doors[sh].y));
		    if (i >= goldlim)
			i = 5 * dlevel;
		    goldlim -= i;
		    mkgold((long) (10 + rn2(i)), sx, sy);
		    break;
		case MORGUE:
		    // Usually there is one dead body in the morgue
		    if (!moct && rn2(3)) {
			mksobj_at(CORPSE, sx, sy);
			moct++;
		    }
		    break;
		case BEEHIVE:
		    if (!rn2(3))
			mksobj_at(LUMP_OF_ROYAL_JELLY, sx, sy);
		    break;
	    }
	}
}
示例#22
0
void wipe_engr_at(struct level *lev, xchar x, xchar y, xchar cnt)
{
	struct engr *ep = engr_at(lev, x,y);

	/* Headstones are indelible */
	if (ep && ep->engr_type != HEADSTONE){
	    if (ep->engr_type != BURN || is_ice(lev, x, y)) {
		if (ep->engr_type != DUST && ep->engr_type != ENGR_BLOOD) {
			cnt = rn2(1 + 50/(cnt+1)) ? 0 : 1;
		}
		wipeout_text(ep->engr_txt, (int)cnt, 0);
		while (ep->engr_txt[0] == ' ')
			ep->engr_txt++;
		if (!ep->engr_txt[0]) del_engr(ep, lev);
	    }
	}
}
示例#23
0
int
getbones()
{
	int fd, x, y, ok;

	if (rn2(3))
		return (0);	/* only once in three times do we find bones */
	bones[6] = '0' + dlevel / 10;
	bones[7] = '0' + dlevel % 10;
	if ((fd = open(bones, O_RDONLY)) < 0)
		return (0);
	if ((ok = uptodate(fd)) != 0) {
		getlev(fd, 0, dlevel);
		for (x = 0; x < COLNO; x++)
			for (y = 0; y < ROWNO; y++)
				levl[x][y].seen = levl[x][y].new = 0;
	}
示例#24
0
int probtype(char let)
{
    int i = bases[letindex(let)];
    int prob = rn2(100);

    prob -= objects[i].oc_prob;
    while(prob >= 0) {
        ++i;
        prob -= objects[i].oc_prob;
    }

    if((objects[i].oc_olet != let) || (objects[i].oc_name == NULL)) {
        panic("probtype(%c) error, i=%d", let, i);
    }

    return i;
}
示例#25
0
void outrumor()
{
    int rn;
    int i;
    FILE *rumf;

    if(n_rumors <= n_used_rumors) {
        return;
    }
    else {
        rumf = fopen(RUMORFILE, "r");

        if(rumf == NULL) {
            return;
        }
    }

    if(n_used_rumors < 0) {
        init_rumors(rumf);
    }

    if(n_rumors == 0) {
        fclose(rumf);
        
        return;
    }

    rn = rn2(n_rumors - n_used_rumors);
    i = 0;

    while((rn != 0) || (used(i) != 0)) {
        skipline(rumf);
        
        if(used(i) == 0) {
            --rn;
        }

        ++i;
    }

    usedbits[i / CHARSZ] |= (1 << (i % CHARSZ));
    ++n_used_rumors;
    outline(rumf);
    fclose(rumf);
}
示例#26
0
void rloco(struct obj *obj)
{
	xchar tx, ty, otx, oty;
	boolean restricted_fall;
	int try_limit = 4000;

	if (obj->otyp == CORPSE && is_rider(&mons[obj->corpsenm])) {
	    if (revive_corpse(obj)) return;
	}

	obj_extract_self(obj);
	otx = obj->ox;
	oty = obj->oy;
	restricted_fall = (otx == 0 && level->dndest.lx);
	do {
	    tx = rn1(COLNO-3,2);
	    ty = rn2(ROWNO);
	    if (!--try_limit) break;
	} while (!goodpos(level, tx, ty, NULL, 0) ||
		/* bug: this lacks provision for handling the Wizard's tower */
		 (restricted_fall &&
		  (!within_bounded_area(tx, ty, level->dndest.lx, level->dndest.ly,
						level->dndest.hx, level->dndest.hy) ||
		   (level->dndest.nlx &&
		    within_bounded_area(tx, ty, level->dndest.nlx, level->dndest.nly,
						level->dndest.nhx, level->dndest.nhy)))));

	if (flooreffects(obj, tx, ty, "fall")) {
	    return;
	} else if (otx == 0 && oty == 0) {
	    ;	/* fell through a trap door; no update of old loc needed */
	} else {
	    if (costly_spot(otx, oty)
	      && (!costly_spot(tx, ty) ||
		  !strchr(in_rooms(level, tx, ty, 0), *in_rooms(level, otx, oty, 0)))) {
		if (costly_spot(u.ux, u.uy) &&
			    strchr(u.urooms, *in_rooms(level, otx, oty, 0)))
		    addtobill(obj, FALSE, FALSE, FALSE);
		else stolen_value(obj, otx, oty, FALSE, FALSE);
	    }
	    newsym(otx, oty);	/* update old location */
	}
	place_object(obj, level, tx, ty);
	newsym(tx, ty);
}
示例#27
0
/* If he has found the Amulet, make the wizard appear after some time */
void
amulet(){
	register struct monst *mtmp;

	if(!flags.made_amulet || !flags.no_of_wizards)
		return;
	/* find wizard, and wake him if necessary */
	for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
	    if(mtmp->iswiz && mtmp->msleep && !rn2(40))
		    if(u.uhave_amulet) {
			mtmp->msleep = 0;
			if(dist(mtmp->mx,mtmp->my) > 2)
			    You(
    "get the creepy feeling that somebody noticed your taking the Amulet."
			    );
			return;
		    }
}
示例#28
0
char *
whatthefoxsays()
{
    switch(rn2(6)){
    case 0:
        return "goes ring-ding-ding-ding-dingeringeding!";
    case 1:
        return "goes wa-pa-pa-pa-pa-pa-pow!";
    case 2:
        return "goes hatee-hatee-hatee-ho!";
    case 3:
        return "goes jacha-chacha-chacha-chow!";
    case 4:
        return "goes fraka-kaka-kaka-kaka-kow!";
    default:
        return "goes a-hee-ahee ha-hee!";
    }
}
示例#29
0
/* the sounds of a seriously abused pet, including player attacking it */
void growl(struct monst *mtmp)
{
    const char *growl_verb = 0;

    if (mtmp->msleeping || !mtmp->mcanmove || !mtmp->data->msound)
	return;

    /* presumably nearness and soundok checks have already been made */
    if (Hallucination)
	growl_verb = h_sounds[rn2(SIZE(h_sounds))];
    else
	growl_verb = growl_sound(mtmp);
    if (growl_verb) {
	pline("%s %s!", Monnam(mtmp), vtense(NULL, growl_verb));
	if (flags.run) nomul(0, NULL);
	wake_nearto(mtmp->mx, mtmp->my, mtmp->data->mlevel * 18);
    }
}
示例#30
0
static void
makeniche(bool with_trap)
{
	struct mkroom *aroom;
	struct rm *rm;
	int vct = 8;
	coord dd;
	int dy,xx,yy;
	struct trap *ttmp;

	if(doorindex < DOORMAX)
	  while(vct--) {
	    aroom = &rooms[rn2(nroom-1)];
	    if(aroom->rtype != 0) continue;	/* not an ordinary room */
	    if(aroom->doorct == 1 && rn2(5)) continue;
	    if(rn2(2)) {
		dy = 1;
		dd = finddpos(aroom->lx,aroom->hy+1,aroom->hx,aroom->hy+1);
	    } else {
		dy = -1;
		dd = finddpos(aroom->lx,aroom->ly-1,aroom->hx,aroom->ly-1);
	    }
	    xx = dd.x;
	    yy = dd.y;
	    if((rm = &levl[xx][yy+dy])->typ) continue;
	    if(with_trap || !rn2(4)) {
		rm->typ = SCORR;
		rm->scrsym = ' ';
		if(with_trap) {
		    ttmp = maketrap(xx, yy+dy, TELEP_TRAP);
		    ttmp->once = 1;
		    make_engr_at(xx, yy-dy, "ad ae?ar um");
		}
		dosdoor(xx, yy, aroom, SDOOR);
	    } else {
		rm->typ = CORR;
		rm->scrsym = CORR_SYM;
		if(rn2(7))
		    dosdoor(xx, yy, aroom, rn2(5) ? SDOOR : DOOR);
		else {
		    mksobj_at(SCR_TELEPORTATION, xx, yy+dy);
		    if(!rn2(3)) mkobj_at(0, xx, yy+dy);
		}
	    }
	    return;
	}
}