struct obj *mkobj(struct level *lev, char oclass, boolean artif) { int tprob, i, prob = rnd(1000); if (oclass == RANDOM_CLASS) { const struct icp *iprobs = (Is_rogue_level(&lev->z)) ? (const struct icp *)rogueprobs : In_hell(&lev->z) ? (const struct icp *)hellprobs : (const struct icp *)mkobjprobs; for (tprob = rnd(100); (tprob -= iprobs->iprob) > 0; iprobs++); oclass = iprobs->iclass; } i = bases[(int)oclass]; while ((prob -= objects[i].oc_prob) > 0) i++; if (objects[i].oc_class != oclass || !OBJ_NAME(objects[i])) panic("probtype error, oclass=%d i=%d", (int) oclass, i); return mksobj(lev, i, TRUE, artif); }
/* provide the name of the current level */ int describe_level(char *buf) { int ret = 1; if (Is_knox(&u.uz)) sprintf(buf, "%s", find_dungeon(&u.uz).dname); else if (In_quest(&u.uz)) sprintf(buf, "Home:%d", dunlev(&u.uz)); else if (In_endgame(&u.uz)) sprintf(buf, Is_astralevel(&u.uz) ? "Astral Plane" : "End Game"); else if (In_mines(&u.uz)) sprintf(buf, "Mines:%d", depth(&u.uz)); else if (In_sokoban(&u.uz)) sprintf(buf, "Sokoban:%d", depth(&u.uz)); else if (Is_valley(&u.uz)) sprintf(buf, "Valley:%d", depth(&u.uz)); else if (In_hell(&u.uz)) sprintf(buf, "Gehennom:%d", depth(&u.uz)); else if (In_V_tower(&u.uz)) sprintf(buf, "Tower:%d", depth(&u.uz)); else sprintf(buf, "Dungeons:%d", depth(&u.uz)), (ret = 0); return ret; }
static const struct permonst * morguemon(const d_level * dlev) { int i = rn2(100), hd = rn2(level_difficulty(dlev)); if (hd > 10 && i < 10) return (In_hell(dlev) || In_endgame(dlev)) ? mkclass(dlev, S_DEMON, 0) : &mons[ndemon(dlev, A_NONE)]; if (hd > 8 && i > 85) return mkclass(dlev, S_VAMPIRE, 0); return (i < 20) ? &mons[PM_GHOST] : (i < 40) ? &mons[PM_WRAITH] : mkclass(dlev, S_ZOMBIE, 0); }
/* select a random, common monster type */ int rndmonnum(const d_level *dlev) { const struct permonst *ptr; int i; /* Plan A: get a level-appropriate common monster */ ptr = rndmonst(dlev); if (ptr) return monsndx(ptr); /* Plan B: get any common monster */ do { i = rn1(SPECIAL_PM - LOW_PM, LOW_PM); ptr = &mons[i]; } while ((ptr->geno & G_NOGEN) || (!In_hell(dlev) && (ptr->geno & G_HELL))); return i; }
static const struct permonst * morguemon(const d_level *dlev, enum rng rng) { int i = rn2_on_rng(100, rng); int hd = rn2_on_rng(level_difficulty(dlev), rng); if (hd > 10 && i < 10) { if (In_hell(dlev) || In_endgame(dlev)) return mkclass(dlev, S_DEMON, 0, rng); else { int mnum = ndemon(dlev, A_NONE); if (mnum != NON_PM) return &mons[mnum]; /* otherwise fall through */ } } else if (hd > 8 && i > 85) return mkclass(dlev, S_VAMPIRE, 0, rng); return (i < 20) ? &mons[PM_GHOST] : (i < 40) ? &mons[PM_WRAITH] : mkclass(dlev, S_ZOMBIE, 0, rng); }