本文整理汇总了C++中rn1函数的典型用法代码示例。如果您正苦于以下问题:C++ rn1函数的具体用法?C++ rn1怎么用?C++ rn1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rn1函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rndmonnum
int
rndmonnum(void) /* select a random, common monster type */
{
register struct permonst *ptr;
register int i;
/* Plan A: get a level-appropriate common monster */
ptr = rndmonst();
if (ptr) return(monsndx(ptr));
/* Plan B: get any common proper monster */
int count = 0;
do {
i = rn1(SPECIAL_PM - LOW_PM, LOW_PM);
ptr = &mons[i];
count++;
} while (((ptr->geno & G_NOGEN) || prohibited_by_generation_flags(ptr)) && count < 10000);
/* Plan C: get any common monster */
do {
i = rn1(SPECIAL_PM - LOW_PM, LOW_PM);
ptr = &mons[i];
count++;
} while(ptr->geno & G_NOGEN);
return(i);
}
开发者ID:chasonr,项目名称:unnethack-i18n,代码行数:27,代码来源:mkobj.c
示例2: chat_with_guardian
static void
chat_with_guardian(void)
{
/* These guys/gals really don't have much to say... */
if (Uhave_questart && Qstat(killed_nemesis))
qt_pager(rn1(5, QT_GUARDTALK2));
else
qt_pager(rn1(5, QT_GUARDTALK));
}
开发者ID:FredrIQ,项目名称:nhfourk,代码行数:9,代码来源:quest.c
示例3: losexp
void
losexp(const char *drainer) /* e.g., hit by drain life attack */
/* cause of death, if drain should be fatal */
{
register int num;
#ifdef WIZARD
/* override life-drain resistance when handling an explicit
wizard mode request to reduce level; never fatal though */
if (drainer && !strcmp(drainer, "#levelchange"))
drainer = 0;
else
#endif
if (resists_drli(&youmonst)) return;
if (u.ulevel > 1) {
pline("%s level %d.", Goodbye(), u.ulevel--);
/* remove intrinsic abilities */
adjabil(u.ulevel + 1, u.ulevel);
reset_rndmonst(NON_PM); /* new monster selection */
} else {
if (drainer) {
killer_format = KILLED_BY;
killer = drainer;
done(DIED);
}
/* no drainer or lifesaved */
u.uexp = 0;
}
num = newhp();
u.uhpmax -= num;
check_uhpmax();
if (u.uhpmax < 1) u.uhpmax = 1;
u.uhp -= num;
if (u.uhp < 1) u.uhp = 1;
else if (u.uhp > u.uhpmax) u.uhp = u.uhpmax;
if (u.ulevel < urole.xlev)
num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.lornd + urace.enadv.lornd,
urole.enadv.lofix + urace.enadv.lofix);
else
num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.hirnd + urace.enadv.hirnd,
urole.enadv.hifix + urace.enadv.hifix);
num = enermod(num); /* M. Stephenson */
u.uenmax -= num;
if (u.uenmax < 0) u.uenmax = 0;
u.uen -= num;
if (u.uen < 0) u.uen = 0;
else if (u.uen > u.uenmax) u.uen = u.uenmax;
if (u.uexp > 0)
u.uexp = newuexp(u.ulevel) - 1;
flags.botl = 1;
}
开发者ID:chasonr,项目名称:unnethack-i18n,代码行数:54,代码来源:exper.c
示例4: rloc
void
rloc(struct monst *mtmp)
{
int tx, ty;
char ch = mtmp->data->mlet;
#ifndef NOWORM
if (ch == 'w' && mtmp->mx) /* do not relocate worms */
return;
#endif /* NOWORM */
do {
tx = rn1(COLNO - 3, 2);
ty = rn2(ROWNO);
} while (!goodpos(tx, ty));
mtmp->mx = tx;
mtmp->my = ty;
if (u.ustuck == mtmp) {
if (u.uswallow) {
u.ux = tx;
u.uy = ty;
docrt();
} else
u.ustuck = 0;
}
pmon(mtmp);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:26,代码来源:hack.makemon.c
示例5: rloco_pos
void
rloco_pos(struct level *lev, struct obj *obj, int *nx, int *ny)
{
xchar tx, ty, otx;
boolean restricted_fall;
int try_limit = 4000;
otx = obj->ox;
restricted_fall = (otx == 0 && lev->dndest.lx);
do {
tx = rn1(COLNO - 3, 2);
ty = rn2(ROWNO);
if (!--try_limit)
break;
} while (!goodpos(lev, tx, ty, NULL, 0) ||
/* bug: this lacks provision for handling the Wizard's tower */
(restricted_fall &&
(!within_bounded_area
(tx, ty, lev->dndest.lx, lev->dndest.ly, lev->dndest.hx,
lev->dndest.hy) ||
(level->dndest.nlx &&
within_bounded_area(tx, ty,
lev->dndest.nlx, lev->dndest.nly,
lev->dndest.nhx, lev->dndest.nhy)))));
*nx = tx;
*ny = ty;
}
开发者ID:eatnumber1,项目名称:bingehack4,代码行数:28,代码来源:teleport.c
示例6: create_gas_cloud
struct region *
create_gas_cloud(struct level *lev, xchar x, xchar y, int radius, int damage)
{
struct region *cloud;
int i, nrect;
struct nhrect tmprect;
cloud = create_region(NULL, 0);
nrect = radius;
tmprect.lx = x;
tmprect.hx = x;
tmprect.ly = y - (radius - 1);
tmprect.hy = y + (radius - 1);
for (i = 0; i < nrect; i++) {
add_rect_to_reg(cloud, &tmprect);
tmprect.lx--;
tmprect.hx++;
tmprect.ly++;
tmprect.hy--;
}
cloud->ttl = rn1(3, 4);
if (!in_mklev && !flags.mon_moving)
set_heros_fault(cloud); /* assume player has created it */
cloud->inside_f = INSIDE_GAS_CLOUD;
cloud->expire_f = EXPIRE_GAS_CLOUD;
cloud->arg = damage;
cloud->visible = TRUE;
cloud->effect_id = dbuf_effect(E_MISC, E_gascloud);
add_region(lev, cloud);
return cloud;
}
开发者ID:ComputerScienceHouse,项目名称:bingehack4,代码行数:31,代码来源:region.c
示例7: ballfall
void
ballfall(void)
{
boolean gets_hit;
gets_hit = (((uball->ox != u.ux) || (uball->oy != u.uy)) &&
((uwep == uball) ? FALSE : (boolean) rn2(5)));
if (carried(uball)) {
pline("Startled, you drop the iron ball.");
unwield_silently(uball);
if (uwep != uball)
freeinv(uball);
}
if (gets_hit) {
int dmg = rn1(7, 25);
pline("The iron ball falls on your %s.", body_part(HEAD));
if (uarmh) {
if (is_metallic(uarmh)) {
pline("Fortunately, you are wearing a hard helmet.");
dmg = 3;
} else if (flags.verbose)
pline("Your %s does not protect you.", xname(uarmh));
}
losehp(dmg, "crunched in the head by an iron ball");
}
}
开发者ID:ComputerScienceHouse,项目名称:bingehack4,代码行数:27,代码来源:ball.c
示例8: ballfall
void
ballfall()
{
boolean gets_hit;
gets_hit = (((uball->ox != u.ux) || (uball->oy != u.uy)) &&
((uwep == uball)? FALSE : (boolean)rn2(5)));
if (carried(uball)) {
pline("Startled, you drop the iron ball.");
if (uwep == uball)
setuwep((struct obj *)0);
if (uswapwep == uball)
setuswapwep((struct obj *)0);
if (uquiver == uball)
setuqwep((struct obj *)0);;
if (uwep != uball)
freeinv(uball);
}
if(gets_hit){
int dmg = rn1(7,25);
pline_The("iron ball falls on your %s.",
body_part(HEAD));
if (uarmh) {
if(is_metallic(uarmh)) {
pline("Fortunately, you are wearing a hard helmet.");
dmg = 3;
} else if (flags.verbose)
Your("%s does not protect you.", xname(uarmh));
}
losehp(dmg, "crunched in the head by an iron ball",
NO_KILLER_PREFIX);
}
}
开发者ID:Arc0re,项目名称:acehack,代码行数:33,代码来源:ball.c
示例9: chat_with_nemesis
static void
chat_with_nemesis(void)
{
/* The nemesis will do most of the talking, but... */
qt_pager(rn1(10, QT_DISCOURAGE));
if (!Qstat(met_nemesis))
Qstat(met_nemesis++);
}
开发者ID:FredrIQ,项目名称:nhfourk,代码行数:8,代码来源:quest.c
示例10: makerogueghost
void makerogueghost(struct level *lev)
{
struct monst *ghost;
struct obj *ghostobj;
struct mkroom *croom;
int x,y;
if (!lev->nroom)
return; /* Should never happen */
croom = &lev->rooms[rn2(lev->nroom)];
x = somex(croom);
y = somey(croom);
if (!(ghost = makemon(&mons[PM_GHOST], lev, x, y, NO_MM_FLAGS)))
return;
ghost->msleeping = 1;
christen_monst(ghost, roguename());
if (rn2(4)) {
ghostobj = mksobj_at(FOOD_RATION, lev, x, y, FALSE, FALSE);
ghostobj->quan = (long) rnd(7);
ghostobj->owt = weight(ghostobj);
}
if (rn2(2)) {
ghostobj = mksobj_at(MACE, lev, x, y, FALSE, FALSE);
ghostobj->spe = rnd(3);
if (rn2(4)) curse(ghostobj);
} else {
ghostobj = mksobj_at(TWO_HANDED_SWORD, lev, x, y, FALSE, FALSE);
ghostobj->spe = rnd(5) - 2;
if (rn2(4)) curse(ghostobj);
}
ghostobj = mksobj_at(BOW, lev, x, y, FALSE, FALSE);
ghostobj->spe = 1;
if (rn2(4)) curse(ghostobj);
ghostobj = mksobj_at(ARROW, lev, x, y, FALSE, FALSE);
ghostobj->spe = 0;
ghostobj->quan = (long) rn1(10,25);
ghostobj->owt = weight(ghostobj);
if (rn2(4)) curse(ghostobj);
if (rn2(2)) {
ghostobj = mksobj_at(RING_MAIL, lev, x, y, FALSE, FALSE);
ghostobj->spe = rn2(3);
if (!rn2(3)) ghostobj->oerodeproof = TRUE;
if (rn2(4)) curse(ghostobj);
} else {
ghostobj = mksobj_at(PLATE_MAIL, lev, x, y, FALSE, FALSE);
ghostobj->spe = rnd(5) - 2;
if (!rn2(3)) ghostobj->oerodeproof = TRUE;
if (rn2(4)) curse(ghostobj);
}
if (rn2(2)) {
ghostobj = mksobj_at(FAKE_AMULET_OF_YENDOR, lev, x, y, TRUE, FALSE);
ghostobj->known = TRUE;
}
}
开发者ID:mbi,项目名称:NitroHack,代码行数:58,代码来源:extralev.c
示例11: exerchk
void exerchk (void) {
int i, mod_val;
/* Check out the periodic accumulations */
exerper();
/* Are we ready for a test? */
if(moves >= next_check && !multi) {
/*
* Law of diminishing returns (Part II):
*
* The effects of "exercise" and "abuse" wear
* off over time. Even if you *don't* get an
* increase/decrease, you lose some of the
* accumulated effects.
*/
for(i = 0; i < A_MAX; AEXE(i++) /= 2) {
if(ABASE(i) >= 18 || !AEXE(i)) continue;
if(i == A_INT || i == A_CHA) continue;/* can't exercise these */
/*
* Law of diminishing returns (Part III):
*
* You don't *always* gain by exercising.
* [MRS 92/10/28 - Treat Wisdom specially for balance.]
*/
if(rn2(AVAL) > ((i != A_WIS) ? abs(AEXE(i)*2/3) : abs(AEXE(i))))
continue;
mod_val = sgn(AEXE(i));
if(adjattrib(i, mod_val, -1)) {
/* if you actually changed an attrib - zero accumulation */
AEXE(i) = 0;
/* then print an explanation */
switch(i) {
case A_STR: You((mod_val >0) ?
"must have been exercising." :
"must have been abusing your body.");
break;
case A_WIS: You((mod_val >0) ?
"must have been very observant." :
"haven't been paying attention.");
break;
case A_DEX: You((mod_val >0) ?
"must have been working on your reflexes." :
"haven't been working on reflexes lately.");
break;
case A_CON: You((mod_val >0) ?
"must be leading a healthy life-style." :
"haven't been watching your health.");
break;
}
}
}
next_check += rn1(200,800);
}
}
开发者ID:thejoshwolfe,项目名称:nethack,代码行数:58,代码来源:attrib.c
示例12: demon_talk
/* returns 1 if it won't attack. */
int
demon_talk(struct monst *mtmp)
{
long cash, demand, offer;
if (uwep && uwep->oartifact == ART_EXCALIBUR) {
pline("%s looks very angry.", Amonnam(mtmp));
msethostility(mtmp, TRUE, TRUE);
return 0;
}
/* Slight advantage given. */
if (is_dprince(mtmp->data) && mtmp->minvis) {
mtmp->minvis = mtmp->perminvis = 0;
if (!Blind)
pline("%s appears before you.", Amonnam(mtmp));
newsym(mtmp->mx, mtmp->my);
}
if (youmonst.data->mlet == S_DEMON) { /* Won't blackmail their own. */
pline("%s says, \"Good hunting, %s.\"", Amonnam(mtmp),
u.ufemale ? "Sister" : "Brother");
if (!tele_restrict(mtmp))
rloc(mtmp, TRUE);
return 1;
}
cash = money_cnt(invent);
/* don't bother with a custom RNG here, too much unpredictability is
involved */
demand = (cash * (rnd(80) + 20 * Athome)) /
(100 * (1 + (sgn(u.ualign.type) == sgn(mtmp->data->maligntyp))));
if (!demand) { /* you have no gold */
msethostility(mtmp, TRUE, TRUE);
return 0;
} else {
/* make sure that the demand is unmeetable if the monster has the
Amulet, preventing monster from being satisified and removed from
the game (along with said Amulet...) */
if (mon_has_amulet(mtmp))
demand = cash + (long)rn1(1000, 40);
pline("%s demands %ld %s for safe passage.", Amonnam(mtmp), demand,
currency(demand));
if ((offer = bribe(mtmp)) >= demand) {
pline("%s vanishes, laughing about cowardly %s.", Amonnam(mtmp),
makeplural(mortal_or_creature(youmonst.data, FALSE)));
} else if (offer > 0L && (long)rnd(40) > (demand - offer)) {
pline("%s scowls at you menacingly, then vanishes.", Amonnam(mtmp));
} else {
pline("%s gets angry...", Amonnam(mtmp));
msethostility(mtmp, TRUE, TRUE);
return 0;
}
}
mongone(mtmp);
return 1;
}
开发者ID:ComputerScienceHouse,项目名称:bingehack4,代码行数:59,代码来源:minion.c
示例13: pluslvl
void
pluslvl(boolean incr)
/* true iff via incremental experience growth */
{
/* (false for potion of gain level) */
register int num;
if (!incr) You_feel("more experienced.");
num = newhp();
u.uhpmax += num;
u.uhp += num;
if (Upolyd) {
num = rnd(8);
u.mhmax += num;
u.mh += num;
}
if (u.ulevel < urole.xlev)
num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.lornd + urace.enadv.lornd,
urole.enadv.lofix + urace.enadv.lofix);
else
num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.hirnd + urace.enadv.hirnd,
urole.enadv.hifix + urace.enadv.hifix);
num = enermod(num); /* M. Stephenson */
if (!Role_if(PM_TOURIST)) { /* Tourists have no innate magic abilities */
u.uenmax += num;
u.uen += num;
}
if (u.ulevel < MAXULEV) {
if (incr) {
long tmp = newuexp(u.ulevel + 1);
if (u.uexp >= tmp) u.uexp = tmp - 1;
} else {
u.uexp = newuexp(u.ulevel);
}
++u.ulevel;
if (u.ulevelmax < u.ulevel) u.ulevelmax = u.ulevel;
pline("Welcome to experience level %d.", u.ulevel);
adjabil(u.ulevel - 1, u.ulevel); /* give new intrinsics */
reset_rndmonst(NON_PM); /* new monster selection */
}
flags.botl = 1;
}
开发者ID:chasonr,项目名称:unnethack-i18n,代码行数:42,代码来源:exper.c
示例14: nemesis_speaks
void
nemesis_speaks(void)
{
if (!Qstat(in_battle)) {
if (Uhave_questart)
qt_pager(QT_NEMWANTSIT);
else if (Qstat(made_goal) == 1 || !Qstat(met_nemesis))
qt_pager(QT_FIRSTNEMESIS);
else if (Qstat(made_goal) < 4)
qt_pager(QT_NEXTNEMESIS);
else if (Qstat(made_goal) < 7)
qt_pager(QT_OTHERNEMESIS);
else if (!rn2(5))
qt_pager(rn1(10, QT_DISCOURAGE));
if (Qstat(made_goal) < 7)
Qstat(made_goal)++;
Qstat(met_nemesis) = TRUE;
} else /* he will spit out random maledictions */ if (!rn2(5))
qt_pager(rn1(10, QT_DISCOURAGE));
}
开发者ID:FredrIQ,项目名称:nhfourk,代码行数:20,代码来源:quest.c
示例15: rloc
void rloc(struct monst *mtmp)
{
int tx, ty;
do {
tx = rn1(COLNO - 3, 2);
ty = rn2(ROWNO);
} while (!goodpos(tx, ty));
mtmp->mx = tx;
mtmp->my = ty;
pmon(mtmp);
}
开发者ID:msharov,项目名称:bsd-games,代码行数:11,代码来源:makemon.c
示例16: pri_move
/*
* pri_move: return 1: moved 0: didn't -1: let m_move do it -2: died
*/
int
pri_move(struct monst *priest)
{
xchar gx, gy, omx, omy;
schar temple;
boolean avoid = TRUE;
omx = priest->mx;
omy = priest->my;
if (!histemple_at(priest, omx, omy))
return -1;
temple = CONST_EPRI(priest)->shroom;
gx = CONST_EPRI(priest)->shrpos.x;
gy = CONST_EPRI(priest)->shrpos.y;
gx += rn1(3, -1); /* mill around the altar */
gy += rn1(3, -1);
if (!priest->mpeaceful || (Conflict && !resist(priest, RING_CLASS, 0, 0))) {
if (monnear(priest, u.ux, u.uy)) {
if (Displaced)
pline("Your displaced image doesn't fool %s!", mon_nam(priest));
mattacku(priest);
return 0;
} else if (strchr(u.urooms, temple)) {
/* chase player if inside temple & can sense him */
if (m_cansenseu(priest)) {
gx = u.ux;
gy = u.uy;
}
avoid = FALSE;
}
} else if (Invis)
avoid = FALSE;
return move_special(priest, FALSE, TRUE, FALSE, avoid, omx, omy, gx, gy);
}
开发者ID:FredrIQ,项目名称:nhfourk,代码行数:43,代码来源:priest.c
示例17: dlord
int
dlord(aligntyp atyp)
{
int tryct, pm;
for (tryct = 0; tryct < 20; tryct++) {
pm = rn1(PM_YEENOGHU + 1 - PM_JUIBLEX, PM_JUIBLEX);
if (!(mvitals[pm].mvflags & G_GONE) &&
(atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
return pm;
}
return ndemon(&u.uz, atyp); /* approximate */
}
开发者ID:clockfort,项目名称:bingehack4,代码行数:13,代码来源:minion.c
示例18: dprince
int
dprince(aligntyp atyp)
{
int tryct, pm;
for (tryct = 0; tryct < 20; tryct++) {
pm = rn1(PM_DEMOGORGON + 1 - PM_ORCUS, PM_ORCUS);
if (!(mvitals[pm].mvflags & G_GONE) &&
(atyp == A_NONE || sgn(mons[pm].maligntyp) == sgn(atyp)))
return pm;
}
return dlord(atyp); /* approximate */
}
开发者ID:clockfort,项目名称:bingehack4,代码行数:13,代码来源:minion.c
示例19: rloc
void rloc(struct monst *mtmp)
{
int tx;
int ty;
char ch = mtmp->data->mlet;
#ifndef NOWORM
if((ch == 'w') && (mtmp->mx)) {
/* Do not relocate worms */
return;
}
#endif
tx = rn1(COLNO - 3, 2);
ty = rn2(ROWNO);
while(goodpos(tx, ty) == 0) {
tx = rn1(COLNO - 3, 2);
ty = rn2(ROWNO);
}
mtmp->mx = tx;
mtmp->my = ty;
if(u.ustuck == mtmp) {
if(u.uswallow != 0) {
u.ux = tx;
u.uy = ty;
docrt();
}
else {
u.ustuck = 0;
}
}
pmon(mtmp);
}
开发者ID:tcadigan,项目名称:hack_1.0,代码行数:37,代码来源:hack.mon.c
示例20: poisoned
void poisoned(char *string, char *pname)
{
if(Blind != 0) {
pline("It was poisoned.");
}
else {
pline("The %s was poisoned!", string);
}
if(Poison_resistance != 0) {
pline("The poison doesn't seem to affect you.");
return;
}
switch(rnd(6)) {
case 1:
u.uhp = -1;
break;
case 2:
case 3:
case 4:
losestr(rn1(3, 3));
break;
case 5:
case 6:
losehp(rn1(10, 6), pname);
return;
}
if(u.uhp < 1) {
killer = pname;
}
}
开发者ID:tcadigan,项目名称:hack_1.0,代码行数:37,代码来源:hack.mon.c
注:本文中的rn1函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论