void opit() { int i; if (rnd(101)>81) return; if (rnd(70) > 9*c[DEXTERITY]-packweight() || rnd(101)<5) { for (i=0;i<IVENSIZE;i++) if (iven[i]==OWWAND) { lprcat("\nYou float right over the pit."); return; } if (level==DBOTTOM || level == VBOTTOM) obottomless(); else { if (rnd(101)<20) { i=0; lprcat("\nYou fell ino a pit! " "A poor monster cushions your fall!\n"); } else { i = rnd(level*3+3); if (i > c[HP]) i = c[HP]; lprintf("\nYou fell into a pit! " "You suffer %d hit point%s damage.",(long)i, (i==1)?"":"s"); lastnum=261; /* if he dies scoreboard will say so */ } losehp(i); lflush(); nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY); } } }
/* ********* OTELEPORT ********* subroutine to handle a teleport trap +/- 1 level maximum */ void oteleport(int err) { int tmp; if (err) if (rnd(151)<3) died(264); /* stuck in a rock */ /*show ?? on bottomline if been teleported */ if (!wizard) c[TELEFLAG]=1; if (level==0) tmp=0; else if (level <= DBOTTOM) { /* in dungeon */ tmp=rnd(5)+level-3; if (tmp>DBOTTOM) tmp=DBOTTOM; if (tmp<0) tmp=0; } else { /* in volcano */ tmp=rnd(4)+level-2; if (tmp>=VBOTTOM) tmp=VBOTTOM; if (tmp<DBOTTOM+1) tmp=0; /* back to surface */ } playerx = rnd(MAXX-2); playery = rnd(MAXY-2); if (level != tmp) newcavelevel(tmp); positionplayer(); draws(0,MAXX,0,MAXY); bot_linex(); }
void oelevator(int dir) { if (dir==1) { if (level == 0) { lprcat(",\nunfortunately, it is out of order."); return; } playerx = rnd(MAXX-2); playery = rnd(MAXY-2); nap(2000); newcavelevel(rund(level)); } else { if (level==DBOTTOM || level==VBOTTOM) { nap(2000); lprcat("\nand it leads straight to HELL!"); beep(); lflush(); nap(3000); died(287); } playerx = rnd(MAXX-2); playery = rnd(MAXY-2); nap(2000); newcavelevel(level + rnd(DBOTTOM - level)); } positionplayer(); draws(0,MAXX,0,MAXY); bot_linex(); }
int main() { setup(); draws(); info(); while (1) { if (timer_expired(tim)){ check_input(); update_state(); draws(); info(); reset_timer(tim); } } }
/* * subroutine to restore normal display screen depending on t_setup() */ static void t_endup(int count) { if (count < 18) /* how did we clear the screen? */ draws(0, MAXX, 0, (count > MAXY) ? MAXY : count); else { drawscreen(); setscroll(); } }
/* assumes that cursors() has been called and that a check has been made that the user is actually standing at a set of up stairs. */ void act_up_stairs(void) { if (level >= 2 && level != 11) { newcavelevel( level - 1 ) ; draws( 0, MAXX, 0, MAXY ); bot_linex() ; } else { lprcat("\nThe stairs lead to a dead end!"); } }
TDenseMatrix SBVAR_symmetric_linear::Simulate_serial_correlation(int n, int burn_in, int thin) { if ((n <= 0) || (burn_in < 0) || (thin <= 0)) throw dw_exception("Simulate(): invalid arguments"); TDenseMatrix draws(n,NumberParameters(),false); for (int i=0; i < burn_in; i++) SimulateA0(); for (int i=0; i < n; i++) { for (int j=0; j < thin; j++) SimulateA0(); SimulateAplus(); draws.InsertRowMatrix(i,0,parameters); } return draws; }
/* assumes that cursors() has been called and that a check has been made that the user is actually standing at a set of down stairs. */ void act_down_stairs(void) { if (level != 0 && level != 10 && level != 13) { newcavelevel( level + 1 ) ; draws( 0, MAXX, 0, MAXY ); bot_linex() ; } else { lprcat("\nThe stairs lead to a dead end!"); } }
/* Perform the action of placing the player near the volcanic shaft after it has been climbed. Takes one parameter: the volcanic shaft object to be found. If have climbed up, search for OVOLDOWN, otherwise search for OVOLUP. */ static void volshaft_climbed(int object) { int i,j ; /* place player near the volcanic shaft */ for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) if (item[j][i] == object) { playerx=j; playery=i; positionplayer(); i=MAXY; break; } draws(0,MAXX,0,MAXY); bot_linex(); return ; }
/* Perform the act of climbing down the volcanic shaft. Assumes cursors() has been called and that a check has been made that are actually at a down shaft. */ void act_down_shaft(void) { if (level!=0) { lprcat("\nThe shaft only extends 5 feet downward!"); return; } if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); lastnum=275; losehp(30+rnd(20)); bottomhp(); } newcavelevel(MAXLEVEL); draws(0,MAXX,0,MAXY); bot_linex(); return; }
/* *************** LOOK_FOR_OBJECT *************** subroutine to look for an object and give the player his options if an object was found. */ lookforobject() { register int i,j; if (c[TIMESTOP]) return; /* can't find objects is time is stopped */ i=item[playerx][playery]; if (i==0) return; showcell(playerx,playery); cursors(); yrepcount=0; switch(i) { case OGOLDPILE: case OMAXGOLD: case OKGOLD: case ODGOLD: lprcat("\n\nYou have found some gold!"); ogold(i); break; case OPOTION: lprcat("\n\nYou have found a magic potion"); i = iarg[playerx][playery]; if (potionname[i][0]) lprintf(" of %s",&potionname[i][1]); opotion(i); break; case OSCROLL: lprcat("\n\nYou have found a magic scroll"); i = iarg[playerx][playery]; if (scrollname[i][0]) lprintf(" of %s",&scrollname[i][1]); oscroll(i); break; case OALTAR: if (nearbymonst()) return; lprcat("\n\nThere is a Holy Altar here!"); oaltar(); break; case OBOOK: lprcat("\n\nYou have found a book."); obook(); break; case OCOOKIE: lprcat("\n\nYou have found a fortune cookie."); ocookie(); break; case OTHRONE: if (nearbymonst()) return; lprintf("\n\nThere is %s here!",objectname[i]); othrone(0); break; case OTHRONE2: if (nearbymonst()) return; lprintf("\n\nThere is %s here!",objectname[i]); othrone(1); break; case ODEADTHRONE: lprintf("\n\nThere is %s here!",objectname[i]); odeadthrone(); break; case OORB: lprcat("\n\nYou have found the Orb!!!!!"); oorb(); break; case OPIT: lprcat("\n\nYou're standing at the top of a pit."); opit(); break; case OSTAIRSUP: lprcat("\n\nThere is a circular staircase here"); ostairs(1); /* up */ break; case OELEVATORUP: lprcat("\n\nYou feel heavy for a moment, but the feeling disappears"); oelevator(1); /* up */ break; case OFOUNTAIN: if (nearbymonst()) return; lprcat("\n\nThere is a fountain here"); ofountain(); break; case OSTATUE: if (nearbymonst()) return; lprcat("\n\nYou are standing in front of a statue"); ostatue(); break; case OCHEST: lprcat("\n\nThere is a chest here"); ochest(); break; case OIVTELETRAP: if (rnd(11)<6) return; item[playerx][playery] = OTELEPORTER; know[playerx][playery] = 1; case OTELEPORTER: lprcat("\nZaaaappp! You've been teleported!\n"); beep(); nap(3000); oteleport(0); break; case OSCHOOL: if (nearbymonst()) return; lprcat("\n\nYou have found the College of Larn."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); if (i == 'g') { oschool(); /* the college of larn */ } else lprcat(" stay here"); break; case OMIRROR: if (nearbymonst()) return; lprcat("\n\nThere is a mirror here"); omirror(); break; case OBANK2: case OBANK: if (nearbymonst()) return; if (i==OBANK) lprcat("\n\nYou have found the bank of Larn."); else lprcat("\n\nYou have found a branch office of the bank of Larn."); lprcat("\nDo you (g) go inside, or (i) stay here? "); j=0; while ((j!='g') && (j!='i') && (j!='\33')) j=getchar(); if (j == 'g') { if (i==OBANK) obank(); else obank2(); /* the bank of larn */ } else lprcat(" stay here"); break; case ODEADFOUNTAIN: if (nearbymonst()) return; lprcat("\n\nThere is a dead fountain here"); break; case ODNDSTORE: if (nearbymonst()) return; lprcat("\n\nThere is a DND store here."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); if (i == 'g') dndstore(); /* the dnd adventurers store */ else lprcat(" stay here"); break; case OSTAIRSDOWN: lprcat("\n\nThere is a circular staircase here"); ostairs(-1); /* down */ break; case OELEVATORDOWN: lprcat("\n\nYou feel light for a moment, but the feeling disappears"); oelevator(-1); /* down */ break; case OOPENDOOR: lprintf("\n\nYou have found %s",objectname[i]); lprcat("\nDo you (c) close it"); iopts(); i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar(); if ((i=='\33') || (i=='i')) { ignore(); break; } lprcat("close"); forget(); item[playerx][playery]=OCLOSEDDOOR; iarg[playerx][playery]=0; playerx = lastpx; playery = lastpy; break; case OCLOSEDDOOR: lprintf("\n\nYou have found %s",objectname[i]); lprcat("\nDo you (o) try to open it"); iopts(); i=0; while ((i!='o') && (i!='i') && (i!='\33')) i=getchar(); if ((i=='\33') || (i=='i')) { ignore(); playerx = lastpx; playery = lastpy; break; } else { lprcat("open"); if (rnd(11)<7) { switch(iarg[playerx][playery]) { case 6: c[AGGRAVATE] += rnd(400); break; case 7: lprcat("\nYou are jolted by an electric shock "); lastnum=274; losehp(rnd(20)); bottomline(); break; case 8: loselevel(); break; case 9: lprcat("\nYou suddenly feel weaker "); if (c[STRENGTH]>3) c[STRENGTH]--; bottomline(); break; default: break; } playerx = lastpx; playery = lastpy; } else { forget(); item[playerx][playery]=OOPENDOOR; } } break; case OENTRANCE: lprcat("\nYou have found "); lprcat(objectname[OENTRANCE]); lprcat("\nDo you (g) go inside"); iopts(); i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); if (i == 'g') { newcavelevel(1); playerx=33; playery=MAXY-2; item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1]=0; draws(0,MAXX,0,MAXY); bot_linex(); return; } else ignore(); break; case OVOLDOWN: lprcat("\nYou have found "); lprcat(objectname[OVOLDOWN]); lprcat("\nDo you (c) climb down"); iopts(); i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar(); if ((i=='\33') || (i=='i')) { ignore(); break; } if (level!=0) { lprcat("\nThe shaft only extends 5 feet downward!"); return; } if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep(); lastnum=275; losehp(30+rnd(20)); bottomhp(); } else lprcat("climb down"); nap(3000); newcavelevel(MAXLEVEL); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) /* put player near volcano shaft */ if (item[j][i]==OVOLUP) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); } draws(0,MAXX,0,MAXY); bot_linex(); return; case OVOLUP: lprcat("\nYou have found "); lprcat(objectname[OVOLUP]); lprcat("\nDo you (c) climb up"); iopts(); i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar(); if ((i=='\33') || (i=='i')) { ignore(); break; } if (level!=11) { lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!"); return; } if (packweight() > 45+5*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep(); lastnum=275; losehp(15+rnd(20)); bottomhp(); return; } lprcat("climb up"); lflush(); nap(3000); newcavelevel(0); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) /* put player near volcano shaft */ if (item[j][i]==OVOLDOWN) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); } draws(0,MAXX,0,MAXY); bot_linex(); return; case OTRAPARROWIV: if (rnd(17)<13) return; /* for an arrow trap */ item[playerx][playery] = OTRAPARROW; know[playerx][playery] = 0; case OTRAPARROW: lprcat("\nYou are hit by an arrow"); beep(); /* for an arrow trap */ lastnum=259; losehp(rnd(10)+level); bottomhp(); return; case OIVDARTRAP: if (rnd(17)<13) return; /* for a dart trap */ item[playerx][playery] = ODARTRAP; know[playerx][playery] = 0; case ODARTRAP: lprcat("\nYou are hit by a dart"); beep(); /* for a dart trap */ lastnum=260; losehp(rnd(5)); if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3; bottomline(); return; case OIVTRAPDOOR: if (rnd(17)<13) return; /* for a trap door */ item[playerx][playery] = OTRAPDOOR; know[playerx][playery] = 1; case OTRAPDOOR: lastnum = 272; /* a trap door */ if ((level==MAXLEVEL-1) || (level==MAXLEVEL+MAXVLEVEL-1)) { lprcat("\nYou fell through a bottomless trap door!"); beep(); nap(3000); died(271); } lprcat("\nYou fall through a trap door!"); beep(); /* for a trap door */ losehp(rnd(5+level)); nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY); bot_linex(); return; case OTRADEPOST: if (nearbymonst()) return; lprcat("\nYou have found the Larn trading Post."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); if (i == 'g') otradepost(); else lprcat("stay here"); return; case OHOME: if (nearbymonst()) return; lprcat("\nYou have found your way home."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); if (i == 'g') ohome(); else lprcat("stay here"); return; case OWALL: break; case OANNIHILATION: died(283); return; /* annihilated by sphere of annihilation */ case OLRS: if (nearbymonst()) return; lprcat("\n\nThere is an LRS office here."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); if (i == 'g') olrs(); /* the larn revenue service */ else lprcat(" stay here"); break; default: finditem(i); break; }; }
/* *************** LOOK_FOR_OBJECT *************** subroutine to look for an object and give the player his options if an object was found. */ lookforobject() { int i,j; /* can't find objects is time is stopped*/ if (c[TIMESTOP]) return; i=item[playerx][playery]; if (i==0) return; showcell(playerx,playery); cursors(); yrepcount=0; switch(i) { case OGOLDPILE: case OMAXGOLD: case OKGOLD: case ODGOLD: ogold(i); break; case OPOTION: lprcat("\n\nYou find a magic potion"); i = iarg[playerx][playery]; if (potionknown[i]) lprintf(" of %s",&potionname[i][1]); lprcat("."); opotion(i); break; case OSCROLL: lprcat("\n\nYou find a magic scroll"); i = iarg[playerx][playery]; if (scrollknown[i]) lprintf(" of %s",&scrollname[i][1]); lprcat("."); oscroll(i); break; case OALTAR: if (nearbymonst()) return; lprcat("\n\nThere is a holy altar here."); oaltar(); break; case OBOOK: lprcat("\n\nYou find a book."); obook(); break; case OCOOKIE: lprcat("\n\nYou find a fortune cookie."); ocookie(); break; case OTHRONE: if (nearbymonst()) return; lprintf("\n\nThere is %s here.",objectname[i]); othrone(0); break; case OTHRONE2: if (nearbymonst()) return; lprintf("\n\nThere is %s here.",objectname[i]); othrone(1); break; case ODEADTHRONE: lprintf("\n\nThere is %s here.",objectname[i]); odeadthrone(); break; case OORB: if (nearbymonst()) return; finditem(i); break; case OBRASSLAMP: lprcat("\nYou find a brass lamp."); lprcat("\nDo you want to (r) rub it, (t) take it, or (i) ignore it? "); i=0; while ((i!='r') && (i!='i') && (i!='t') && (i!=ESC)) i=getcharacter(); if (i=='r') { i=rnd(100); if (i>90) { lprcat("\nThe magic genie was very upset at being disturbed!"); lastnum = 286; losehp((int)c[HP]/2+1); beep(); } /* higher level, better chance of spell */ else if ( (rnd(100)+c[LEVEL]/2) > 80) { int a,b,d; lprcat("\nA magic genie appears!"); cursors(); lprcat("\n What spell would you like? : "); while ((a=getcharacter())=='D') { seemagic(99); cursors(); lprcat("\n What spell would you like? : "); } /* to escape casting a spell */ if (a==ESC) goto over; if ((b=getcharacter())==ESC) goto over; if ((d=getcharacter())==ESC) { over: lprcat("aborted"); return; } lprc('\n'); for (i=0; i<SPNUM; i++) if ((spelcode[i][0]==a) && (spelcode[i][1]==b) && (spelcode[i][2]==d)) { spelknow[i]=1; lprintf("\nSpell \"%s\": %s\n%s",spelcode[i], spelname[i],speldescript[i]); lprcat("\nThe genie prefers not to be disturbed " "again."); forget(); bottomline(); return; } lprcat("\nThe genie has never heard of such a spell!"); lprcat("\nThe genie prefers not to be disturbed again."); forget(); bottomline(); return; } else lprcat("\nnothing happened."); if (rnd(100) < 15) { lprcat("\nThe genie prefers not to be disturbed again!"); forget(); c[LAMP]=0; /* chance of finding lamp again */ } bottomline(); } else if (i=='t') { lprcat("take."); if (take(OBRASSLAMP,0)==0) forget(); } else lprcat("ignore."); return; case OWWAND: if (nearbymonst()) return; finditem(i); break; case OHANDofFEAR: if (nearbymonst()) return; finditem(i); break; case OPIT: lprcat("\n\nYou're standing at the top of a pit."); opit(); break; case OSTAIRSUP: lprcat("\n\nThere is a circular staircase here."); ostairs(1); /* up */ break; case OELEVATORUP: lprcat("\n\nYou have found an express elevator going up."); oelevator(1); /* up */ break; case OELEVATORDOWN: lprcat("\n\nYou have found an express elevator going down."); oelevator(-1); /* down */ break; case OFOUNTAIN: if (nearbymonst()) return; lprcat("\n\nThere is a fountain here."); ofountain(); break; case OSTATUE: if (nearbymonst()) return; lprcat("\n\nYou stand before a statue."); ostatue(); break; case OCHEST: lprcat("\n\nThere is a chest here."); ochest(); break; case OIVTELETRAP: if (rnd(11)<6) return; item[playerx][playery] = OTELEPORTER; know[playerx][playery] = 1; case OTELEPORTER: lprcat("\nZaaaappp! You've been teleported!\n"); beep(); nap(3000); oteleport(0); break; case OSCHOOL: if (nearbymonst()) return; lprcat("\n\nYou have found the College of Ularn."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter(); if (i == 'g') { oschool(); /* the college of larn */ } else lprcat(" stay here."); break; case OMIRROR: if (nearbymonst()) return; lprcat("\n\nThere is a mirror here."); omirror(); break; case OBANK2: case OBANK: if (nearbymonst()) return; if (i==OBANK) lprcat("\n\nYou have found the bank of Ularn."); else lprcat("\n\nYou have found a branch office of the bank of Ularn."); lprcat("\nDo you (g) go inside, or (i) stay here? "); j=0; while ((j!='g') && (j!='i') && (j!=ESC)) j=getcharacter(); if (j == 'g') { if (i==OBANK) obank(); else obank2(); /* the bank of larn */ } else lprcat(" stay here."); break; case ODEADFOUNTAIN: if (nearbymonst()) return; lprcat("\n\nThere is a dead fountain here."); break; case ODNDSTORE: if (nearbymonst()) return; lprcat("\n\nThere is a DND store here."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter(); if (i == 'g') dndstore(); /* the dnd adventurers store */ else lprcat(" stay here."); break; case OSTAIRSDOWN: lprcat("\n\nThere is a circular staircase here."); ostairs(-1); /* down */ break; case OOPENDOOR: lprcat("\nThere is an open door here."); break; case OCLOSEDDOOR: if (dropflag) return; lprintf("\n\nYou find %s",objectname[i]); lprcat("\nDo you (o) try to open it"); iopts(); i=0; while ((i!='o') && (i!='i') && (i!=ESC)) i=getcharacter(); if ((i==ESC) || (i=='i')) { ignore(); playerx = lastpx; playery = lastpy; break; } else { lprcat("open."); if (rnd(11)<7) { switch(iarg[playerx][playery]) { case 6: c[AGGRAVATE] += rnd(400); break; case 7: case 8: lprcat("\nYou are jolted by an electric shock!"); lastnum=274; losehp(rnd(20)); bottomline(); break; /* Losing a level is just too harsh... */ /* case 8: loselevel(); break; */ case 9: lprcat("\nYou suddenly feel weaker!"); if (c[STRENGTH]>3) c[STRENGTH]--; bottomline(); break; default: break; } playerx = lastpx; playery = lastpy; } else { forget(); item[playerx][playery]=OOPENDOOR; } } break; case OENTRANCE: lprcat("\nYou have found "); lprcat(objectname[OENTRANCE]); lprcat("\nDo you (g) go inside"); iopts(); i=0; while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter(); if (i == 'g') { newcavelevel(1); playerx=33; playery=MAXY-2; item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1].mon=0; draws(0,MAXX,0,MAXY); bot_linex(); return; } else ignore(); break; case OVOLDOWN: lprcat("\nYou have found "); lprcat(objectname[OVOLDOWN]); lprcat("\nDo you (c) climb down"); iopts(); i=0; while ((i!='c') && (i!='i') && (i!=ESC)) i=getcharacter(); if ((i==ESC) || (i=='i')) { ignore(); break; } if (level!=0) { lprcat("\nThe shaft only extends 5 feet downward!"); return; } if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft."); beep(); lastnum=275; losehp(30+rnd(20)); bottomhp(); } else lprcat("climb down."); nap(3000); newcavelevel(DBOTTOM+1); /* down to V1 */ playerx = rnd(MAXX-2); playery = rnd(MAXY-2); positionplayer(); draws(0,MAXX,0,MAXY); bot_linex(); return; case OVOLUP: lprcat("\nYou have found "); lprcat(objectname[OVOLUP]); lprcat("\nDo you (c) climb up"); iopts(); i=0; while ((i!='c') && (i!='i') && (i!=ESC)) i=getcharacter(); if ((i==ESC) || (i=='i')) { ignore(); break; } if (packweight() > 40+5*(c[DEXTERITY]+c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft."); beep(); lastnum=275; losehp(15+rnd(20)); bottomhp(); return; } lprcat("climb up."); lflush(); nap(3000); newcavelevel(0); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) /* put player near volcano shaft */ if (item[j][i]==OVOLDOWN) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); } draws(0,MAXX,0,MAXY); bot_linex(); return; case OTRAPARROWIV: if (rnd(17)<13) return; /* for an arrow trap */ item[playerx][playery] = OTRAPARROW; know[playerx][playery] = 0; case OTRAPARROW: lprcat("\nYou are hit by an arrow!"); beep(); /* for an arrow trap */ lastnum=259; losehp(rnd(10)+level); bottomhp(); return; case OIVDARTRAP: if (rnd(17)<13) return; /* for a dart trap */ item[playerx][playery] = ODARTRAP; know[playerx][playery] = 0; case ODARTRAP: lprcat("\nYou are hit by a dart!"); beep(); /* for a dart trap */ lastnum=260; losehp(rnd(5)); if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3; bottomline(); return; case OIVTRAPDOOR: if (rnd(17)<13) return; /* for a trap door */ item[playerx][playery] = OTRAPDOOR; know[playerx][playery] = 1; case OTRAPDOOR: lastnum = 272; /* a trap door */ for (i=0;i<IVENSIZE;i++) if (iven[i]==OWWAND) { lprcat("\nYou escape a trap door."); return; } if ((level==DBOTTOM)||(level==VBOTTOM)) { lprcat("\nYou fall through a trap door leading straight to HELL!"); beep(); lflush(); nap(3000); died(271); } lprcat("\nYou fall through a trap door!"); beep(); lflush(); losehp(rnd(5+level)); nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY); bot_linex(); return; case OTRADEPOST: if (nearbymonst()) return; lprcat("\nYou have found the Ularn trading Post."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter(); if (i == 'g') otradepost(); else lprcat("stay here."); return; case OHOME: if (nearbymonst()) return; lprcat("\nYou have found your way home."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter(); if (i == 'g') ohome(); else lprcat("stay here."); return; case OPAD: if (nearbymonst()) return; lprcat("\nYou have found Dealer McDope's Hideout!"); lprcat("\nDo you (c) check it out, or (i) ignore it? "); i=0; while ((i!='c') && (i!='i') && (i!=ESC)) i=getcharacter(); if (i == 'c') opad(); else lprcat("forget it."); return; case OSPEED: lprcat("\nYou find some speed."); lprcat("\nDo you (s) snort it, (t) take it, or (i) ignore it? "); i=0; while ((i!='s') && (i!='i') && (i!='t') && (i!=ESC)) i=getcharacter(); if (i=='s') { lprcat("snort!"); lprcat("\nOhwowmanlikethingstotallyseemtoslowdown!"); c[HASTESELF] += 200 + c[LEVEL]; c[HALFDAM] += 300 + rnd(200); if ((c[INTELLIGENCE]-=2) < 3) c[INTELLIGENCE]=3; if ((c[WISDOM]-=2) < 3) c[WISDOM]=3; if ((c[CONSTITUTION]-=2) <3) c[CONSTITUTION]=3; if ((c[DEXTERITY]-=2) <3) c[DEXTERITY]=3; if ((c[STRENGTH]-=2) <3) c[STRENGTH]=3; forget(); bottomline(); } else if (i=='t') { lprcat("take."); if (take(OSPEED,0)==0) forget(); } else lprcat("ignore."); break; case OSHROOMS: lprcat("\nYou find some magic mushrooms."); lprcat("\nDo you (e) eat them, (t) take them, or (i) ignore them? "); i=0; while ((i!='e') && (i!='i') && (i!='t') && (i!=ESC)) i=getcharacter(); if (i=='e') { lprcat("eat!"); lprcat("\nThings start to get real spacey..."); c[HASTEMONST] += rnd(75) + 25; c[CONFUSE] += 30+rnd(10); c[WISDOM]+=2; c[CHARISMA]+=2; forget(); bottomline(); } else if (i=='t') { lprcat("take."); if (take(OSHROOMS,0)==0) forget(); } else lprcat("ignore."); break; case OACID: lprcat("\nYou find some LSD."); lprcat("\nDo you (e) eat it, (t) take it, or (i) ignore it? "); i=0; while ((i!='e') && (i!='i') && (i!='t') && (i!=ESC)) i=getcharacter(); if (i=='e') { lprcat("eat!"); lprcat("\nYou are now frying your ass off!"); c[CONFUSE]+=30+rnd(10); c[WISDOM]+=2; c[INTELLIGENCE]+=2; c[AWARENESS]+=1500; c[AGGRAVATE]+=1500; { int j,k; /* heal monsters */ for(j=0;j<MAXY;j++) for(k=0;k<MAXX;k++) if (mitem[k][j].mon) hitp[k][j]=monster[mitem[k][j].mon].hitpoints; } forget(); bottomline(); } else if (i=='t') { lprcat("take."); if (take(OACID,0)==0) forget(); } else lprcat("ignore."); break; case OHASH: lprcat("\nYou find some hashish."); lprcat("\nDo you (s) smoke it, (t) take it, or (i) ignore it? "); i=0; while ((i!='s') && (i!='i') && (i!='t') && (i!=ESC)) i=getcharacter(); if (i=='s') { lprcat("smoke!"); lprcat("\nWOW! You feel stooooooned..."); c[HASTEMONST]+=rnd(75)+25; c[INTELLIGENCE]+=2; c[WISDOM]+=2; if( (c[CONSTITUTION]-=2) < 3) c[CONSTITUTION]=3; if( (c[DEXTERITY]-=2) < 3) c[DEXTERITY]=3; c[HALFDAM]+=300+rnd(200); c[CLUMSINESS]+=rnd(1800)+200; forget(); bottomline(); } else if (i=='t') { lprcat("take."); if (take(OHASH,0)==0) forget(); } else lprcat("ignore."); break; case OCOKE: lprcat("\nYou find some cocaine."); lprcat("\nDo you want to (s) snort it, (t) take it, or (i) ignore it? "); i=0; while ((i!='s') && (i!='i') && (i!='t') && (i!=ESC)) i=getcharacter(); if (i=='s') { lprcat("snort!"); lprcat("\nYour nose begins to bleed!"); if ((c[DEXTERITY]-=2) <3) c[DEXTERITY]=3; if ((c[CONSTITUTION]-=2) <3) c[CONSTITUTION]=3; c[CHARISMA]+=3; for(i=0;i<6;i++) c[i]+=33; c[COKED]+=10; forget(); bottomline(); } else if (i=='t') { lprcat("take."); if (take(OCOKE,0)==0) forget(); } else lprcat("ignore."); break; case OWALL: break; case OANNIHILATION: for (i=0;i<IVENSIZE;i++) if (iven[i]==OSPHTALISMAN) { lprcat("\nThe Talisman of the Sphere protects you from " "annihilation!"); return; } /* annihilated by sphere of annihilation */ died(283); return; case OLRS: if (nearbymonst()) return; lprcat("\n\nThere is an LRS office here."); lprcat("\nDo you (g) go inside, or (i) stay here? "); i=0; while ((i!='g') && (i!='i') && (i!=ESC)) i=getcharacter(); if (i == 'g') olrs(); /* the larn revenue service */ else lprcat(" stay here."); break; default: finditem(i); break; }; }
void act_on_object(int ans) { int i, j; int dx, dy; /* can't find objects is time is stopped */ if (c[TIMESTOP]) return; i=item[playerx][playery]; if (i == ONOTHING) return; showcell(playerx,playery); yrepcount=0; switch (i) { case OPOTION: i = iarg[playerx][playery]; opotion(i, ans); break; case OSCROLL: i = iarg[playerx][playery]; oscroll(i, ans); break; case OALTAR: oaltar(ans); move_world(0); break; case OBOOK: obook(ans); break; case OCOOKIE: ocookie(ans); break; case OTHRONE: othrone(0, ans); break; case OTHRONE2: othrone(1, ans); break; case ODEADTHRONE: odeadthrone(ans); break; case OORB: take_item(ans); break; case OBRASSLAMP: if (ans=='r') { i=rnd(100); if (i>90) { Print("The magic genie was very upset at being disturbed!"); losehp(DIED_ANNOYED_GENIE, (int)c[HP]/2+1); UlarnBeep(); } /* higher level, better chance of spell */ else if ( (rnd(100)+c[LEVEL]/2) > 80) { j = 0; for (i = 0; i < SPELL_COUNT; i++) { if (!spelknow[i]) { add_option(i, spelname[i], ""); j++; } } if (j > 0) { print_header("A magic genie appears! What spell would you like?"); set_callback("obrasslamp"); break; } else Print("A magic genie appears! The genie has no new spells to teach you."); } else { Print("Nothing happened."); } if (rnd(100) < 15) { Print("The genie prefers not to be disturbed again!"); forget(); c[LAMP]=0; /* chance of finding lamp again */ } UpdateStatus(); } else if (ans=='t') { if (take(OBRASSLAMP,0)==0) forget(); } return; case OWWAND: take_item(ans); break; case OHANDofFEAR: take_item(ans); break; case OSTAIRSUP: ostairs(1, ans); /* up */ break; case OFOUNTAIN: ofountain(ans); break; case OCHEST: ochest(ans); break; case OSCHOOL: if (ans == 'g') { oschool(); } break; case OBANK2: case OBANK: if (ans == 'g') { if (i==OBANK) obank(); else obank2(); } break; case ODNDSTORE: if (ans == 'g') dndstore(); break; case OSTAIRSDOWN: ostairs(-1, ans); /* down */ break; case OCLOSEDDOOR: /* can't move objects if time is stopped */ if (c[TIMESTOP]) return; dx = playerx; dy = playery; if (dropflag) return; if ((ans==ESC) || (ans=='i')) { playerx = lastpx; playery = lastpy; lastpx = (char) dx; lastpy = (char) dy; break; } else { /* Try and open the door that is here */ oopendoor(playerx, playery); if (item[playerx][playery] == OCLOSEDDOOR) { /* * Door didn't open. * Move the player back where they came from. */ playerx = lastpx; playery = lastpy; lastpx = (char) dx; lastpy = (char) dy; } move_world(0); } break; case OENTRANCE: if (ans == 'g') { newcavelevel(1); playerx = 33; playery = MAXY - 2; /* Make sure the entrance to the dungeon is clear */ item[33][MAXY-1] = ONOTHING; mitem[33][MAXY-1].mon = MONST_NONE; draws(0,MAXX,0,MAXY); UpdateStatusAndEffects(); return; } break; case OVOLDOWN: if ((ans==ESC) || (ans=='i')) { break; } if (level!=0) { Print("The shaft only extends 5 feet downward!"); return; } if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { Print("You slip and fall down the shaft."); UlarnBeep(); losehp(DIED_SLIPPED_VOLCANO_SHAFT, 30+rnd(20)); UpdateStatus(); } nap(3000); newcavelevel(DBOTTOM+1); /* down to V1 */ playerx = (char) rnd(MAXX-2); playery = (char) rnd(MAXY-2); positionplayer(); draws(0,MAXX,0,MAXY); UpdateStatusAndEffects(); return; case OVOLUP: if ((ans==ESC) || (ans=='i')) { break; } if (packweight() > 40+5*(c[DEXTERITY]+c[STRENGTH]+c[STREXTRA])) { Print("You slip and fall down the shaft."); UlarnBeep(); losehp(DIED_SLIPPED_VOLCANO_SHAFT, 15+rnd(20)); UpdateStatus(); return; } nap(3000); newcavelevel(0); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) { /* put player near volcano shaft */ if (item[j][i]==OVOLDOWN) { playerx = (char) j; playery = (char) i; j=MAXX; i=MAXY; positionplayer(); } } draws(0,MAXX,0,MAXY); UpdateStatusAndEffects(); return; case OTRADEPOST: if (ans == 'g') { otradepost(); } return; case OHOME: if (ans == 'g') { ohome(); } return; case OPAD: if (ans == 'c') { opad(); } return; case OSPEED: if (ans=='s') { Print("Ohwowmanlikethingstotallyseemtoslowdown!"); c[HASTESELF] += 200 + c[LEVEL]; c[HALFDAM] += 300 + rnd(200); adjust_ability(INTELLIGENCE, -2); adjust_ability(WISDOM, -2); adjust_ability(CONSTITUTION, -2); adjust_ability(DEXTERITY, -2); adjust_ability(STRENGTH, -2); forget(); UpdateStatus(); } else if (ans=='t') { if (take(OSPEED,0)==0) forget(); } break; case OSHROOMS: if (ans=='e') { Print("Things start to get real spacey..."); c[HASTEMONST] += rnd(75) + 25; c[CONFUSE] += 30+rnd(10); adjust_ability(WISDOM, 2); adjust_ability(CHARISMA, 2); forget(); UpdateStatus(); } else if (ans=='t') { if (take(OSHROOMS,0)==0) forget(); } break; case OACID: if (ans=='e') { Print("You are now frying your ass off!"); c[CONFUSE] += 30 + rnd(10); adjust_ability(WISDOM, 2); adjust_ability(INTELLIGENCE, 2); c[AWARENESS] += 1500; c[AGGRAVATE] += 1500; { int j, k; /* heal monsters */ for(j = 0 ; j < MAXY ; j++) { for(k = 0 ; k < MAXX ; k++) { if (mitem[k][j].mon) { hitp[k][j] = monster[(int) mitem[k][j].mon].hitpoints; } } } } forget(); UpdateStatus(); } else if (ans=='t') { if (take(OACID,0)==0) forget(); } break; case OHASH: if (ans=='s') { Print("WOW! You feel stooooooned..."); c[HASTEMONST] += rnd(75)+25; adjust_ability(INTELLIGENCE, 2); adjust_ability(WISDOM, 2); adjust_ability(CONSTITUTION, -2); adjust_ability(DEXTERITY, -2); c[HALFDAM] += 300+rnd(200); c[CLUMSINESS] += rnd(1800)+200; forget(); UpdateStatus(); } else if (ans=='t') { if (take(OHASH,0)==0) forget(); } break; case OCOKE: if (ans=='s') { Print("Your nose begins to bleed!"); adjust_ability(DEXTERITY, -2); adjust_ability(CONSTITUTION, -2); adjust_ability(CHARISMA, 3); for(i = ABILITY_FIRST ; i <= ABILITY_LAST ; i++) { adjust_ability(i, 33); } c[COKED] += 10; forget(); UpdateStatus(); } else if (ans=='t') { if (take(OCOKE, 0) == 0) forget(); } break; case OWALL: break; case OANNIHILATION: if (player_has_item(OSPHTALISMAN)) { Print("The Talisman of the Sphere protects you from annihilation!"); return; } /* annihilated by sphere of annihilation */ died(DIED_SPHERE_ANNIHILATION, 0); return; case OLRS: if (nearbymonst()) return; if (ans == 'g') { olrs(); } break; default: if (ans == 't') { if (take(i, iarg[playerx][playery]) == 0) forget(); } break; } }
/* function to drink a potion */ void quaffpotion(int pot) { int i,j; int k; if (pot<0 || pot>=MAXPOTION) return; /* check for within bounds */ /* first character of potion name starts off as \0. */ /* drinking a certain type of potion changes that to a space */ /* ...and from then on it is printable. */ /* if (potionname[pot][0] == '\0') */ /* potionname[pot][0] = ' '; */ if (potionknown[pot] == 0) potionknown[pot] = 1; lprintf("\nYou drink a potion of %s.", &potionname[pot][1]); switch(pot) { case PSLEEP: lprcat(" You fall asleep..."); lflush(); i=rnd(11)-(c[CONSTITUTION]>>2)+2; while(--i>0) { parse2(); nap(1000); } cursors(); lprcat("\n.. you wake up."); return; case PHEALING: lprcat(" You feel better."); if (c[HP] == c[HPMAX]) raisemhp(1); else if ((c[HP] += rnd(20)+20+c[LEVEL]) > c[HPMAX]) c[HP]=c[HPMAX]; break; case PRAISELEVEL: lprcat(" You feel much more skillful!"); raiselevel(); raisemhp(1); return; case PINCABILITY: lprcat(" You feel strange for a moment."); c[rund(6)]++; break; case PWISDOM: lprcat(" You feel more self-confident!"); c[WISDOM] += rnd(2); break; case PSTRENGTH: lprcat(" Wow! You feel great!"); if (c[STRENGTH]<12) c[STRENGTH]=12; else c[STRENGTH]++; break; case PCHARISMA: lprcat(" You feel charismatic!"); c[CHARISMA]++; break; case PDIZZINESS: lprcat(" You become dizzy!"); if (--c[STRENGTH] < 3) c[STRENGTH]=3; break; case PLEARNING: lprcat(" You feel clever!"); c[INTELLIGENCE]++; break; case PGOLDDET: lprcat(" You feel greedy..."); lflush(); nap(2000); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) if ((item[j][i]==OGOLDPILE) || (item[j][i]==OMAXGOLD)) { know[j][i]=1; show1cell(j,i); } showplayer(); return; case PMONSTDET: for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) if (mitem[j][i].mon) { know[j][i]=1; show1cell(j,i); } return; case PFORGETFUL: lprcat(" You stagger for a moment..."); lflush(); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) know[j][i]=0; nap(2000); draws(0,MAXX,0,MAXY); return; case PWATER: return; case PBLINDNESS: lprcat(" You can't see anything!"); c[BLINDCOUNT]+=500; /* dang, that's a long time. */ /* erase the character, too! */ cursor(playerx+1,playery+1); lprc(' '); cursor(playerx+1,playery+1); return; case PCONFUSION: lprcat(" You feel confused."); c[CONFUSE]+= 20+rnd(9); return; case PHEROISM: lprcat(" WOW! You feel fantastic!"); if (c[HERO]==0) for (i=0; i<6; i++) c[i] += 11; c[HERO] += 250; break; case PSTURDINESS: lprcat(" You feel healthier!"); c[CONSTITUTION]++; break; case PGIANTSTR: lprcat(" You now have incredible bulging muscles!"); if (c[GIANTSTR]==0) c[STREXTRA] += 21; c[GIANTSTR] += 700; break; case PFIRERESIST: lprcat(" You feel a chill run up your spine!"); c[FIRERESISTANCE] += 1000; break; case PTREASURE: lprcat(" You feel greedy..."); lflush(); nap(2000); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) { k=item[j][i]; if ((k==ODIAMOND) || (k==ORUBY) || (k==OEMERALD) || (k==OMAXGOLD) || (k==OSAPPHIRE) || (k==OLARNEYE) || (k==OGOLDPILE)) { know[j][i]=1; show1cell(j,i); } } showplayer(); return; case PINSTHEAL: c[HP] = c[HPMAX]; removecurse(); break; case PCUREDIANTH: lprcat(" You don't seem to be affected."); return; case PPOISON: lprcat(" You feel a sickness engulf you!"); c[HALFDAM] += 200 + rnd(200); return; case PSEEINVIS: lprcat(" You feel your vision sharpen."); c[SEEINVISIBLE] += rnd(1000)+400; monstnamelist[INVISIBLESTALKER] = 'I'; return; }; /* show new stats */ bottomline(); return; }
/* ******* OSTAIRS ******* subroutine to process the stair cases if dir > 0 then up else down */ void ostairs(int dir) { int x, y; lprcat("\nDo you (s) stay here or "); if (dir > 0) lprcat("(u) go up? "); else lprcat("(d) go down? "); while (1) switch(getcharacter()) { case ESC: case 's': case 'i': lprcat("stay here."); return; case 'u': lprcat("go up."); if (dir < 0) lprcat("\nThe stairs don't go up!"); else /* not on V1 */ if (level>=2 && level!=DBOTTOM+1) { newcavelevel(level-1); for (x=0;x<MAXX;x++) for (y=0;y<MAXY;y++) if (item[x][y] == OSTAIRSDOWN){ playerx=x; playery=y; x=MAXX; y=MAXY; } draws(0,MAXX,0,MAXY); bot_linex(); } else lprcat("\nThe stairs lead to a dead end!"); return; case 'd': lprcat("go down."); if (dir > 0) lprcat("\nThe stairs don't go down!"); else /* not on dungeon botto or V5 */ if ((level!=0) && (level!=DBOTTOM) && (level!=VBOTTOM)) { newcavelevel(level+1); for (x=0;x<MAXX;x++) for (y=0;y<MAXY;y++) if (item[x][y] == OSTAIRSUP){ playerx=x; playery=y; x=MAXX; y=MAXY; } draws(0,MAXX,0,MAXY); bot_linex(); } else lprcat("\nThe stairs lead to a dead end!"); return; }; }
// simulate genotypes given observed marker data // [[Rcpp::export(".sim_geno")]] IntegerVector sim_geno(const String& crosstype, const IntegerMatrix& genotypes, // columns are individuals, rows are markers const IntegerMatrix& founder_geno, // columns are markers, rows are founder lines const bool is_X_chr, const LogicalVector& is_female, // length n_ind const IntegerMatrix& cross_info, // columns are individuals const NumericVector& rec_frac, // length nrow(genotypes)-1 const IntegerVector& marker_index, // length nrow(genotypes) const double error_prob, const int n_draws) // number of imputations { const int n_ind = genotypes.cols(); const int n_pos = marker_index.size(); const int n_mar = genotypes.rows(); QTLCross* cross = QTLCross::Create(crosstype); // check inputs if(is_female.size() != n_ind) throw std::range_error("length(is_female) != ncol(genotypes)"); if(cross_info.cols() != n_ind) throw std::range_error("ncols(cross_info) != ncol(genotypes)"); if(rec_frac.size() != n_pos-1) throw std::range_error("length(rec_frac) != length(marker_index)-1"); if(error_prob < 0.0 || error_prob > 1.0) throw std::range_error("error_prob out of range"); for(int i=0; i<rec_frac.size(); i++) { if(rec_frac[i] < 0 || rec_frac[i] > 0.5) throw std::range_error("rec_frac must be >= 0 and <= 0.5"); } if(!cross->check_founder_geno_size(founder_geno, n_mar)) throw std::range_error("founder_geno is not the right size"); // end of checks const int mat_size = n_pos*n_draws; IntegerVector draws(mat_size*n_ind); // output object for(int ind=0; ind<n_ind; ind++) { Rcpp::checkUserInterrupt(); // check for ^C from user // possible genotypes for this individual IntegerVector poss_gen = cross->possible_gen(is_X_chr, is_female[ind], cross_info(_,ind)); const int n_poss_gen = poss_gen.size(); NumericVector probs(n_poss_gen); // backward equations NumericMatrix beta = backwardEquations(cross, genotypes(_,ind), founder_geno, is_X_chr, is_female[ind], cross_info(_,ind), rec_frac, marker_index, error_prob, poss_gen); // simulate genotypes for(int draw=0; draw<n_draws; draw++) { // first draw // calculate first prob (on log scale) probs[0] = cross->init(poss_gen[0], is_X_chr, is_female[ind], cross_info(_,ind)) + beta(0,0); if(marker_index[0] >= 0) probs[0] += cross->emit(genotypes(marker_index[0],ind), poss_gen[0], error_prob, founder_geno(_, marker_index[0]), is_X_chr, is_female[ind], cross_info(_,ind)); double sumprobs = probs[0]; // to contain log(sum(probs)) // calculate rest of probs for(int g=1; g<n_poss_gen; g++) { probs[g] = cross->init(poss_gen[g], is_X_chr, is_female[ind], cross_info(_,ind)) + beta(g,0); if(marker_index[0] >= 0) probs[g] += cross->emit(genotypes(marker_index[0],ind), poss_gen[g], error_prob, founder_geno(_, marker_index[0]), is_X_chr, is_female[ind], cross_info(_,ind)); sumprobs = addlog(sumprobs, probs[g]); } // re-scale probs for(int g=0; g<n_poss_gen; g++) probs[g] = exp(probs[g] - sumprobs); // make draw, returns a value from 1, 2, ..., n_poss_gen int curgeno = random_int(probs); draws[draw*n_pos + ind*mat_size] = poss_gen[curgeno]; // move along chromosome for(int pos=1; pos<n_pos; pos++) { // calculate probs for(int g=0; g<n_poss_gen; g++) { probs[g] = cross->step(poss_gen[curgeno], poss_gen[g], rec_frac[pos-1], is_X_chr, is_female[ind], cross_info(_,ind)) + beta(g,pos) - beta(curgeno, pos-1); if(marker_index[pos] >= 0) probs[g] += cross->emit(genotypes(marker_index[pos],ind), poss_gen[g], error_prob, founder_geno(_, marker_index[pos]), is_X_chr, is_female[ind], cross_info(_,ind)); probs[g] = exp(probs[g]); } // make draw curgeno = random_int(probs); draws[pos + draw*n_pos + ind*mat_size] = poss_gen[curgeno]; } // loop over positions } // loop over draws } // loop over individuals draws.attr("dim") = Dimension(n_pos, n_draws, n_ind); delete cross; return draws; }
/* ============================================================================= * FUNCTION: lookforobject */ void lookforobject(void) { int i; int dx, dy; /* can't find objects is time is stopped */ if (c[TIMESTOP]) return; i=item[playerx][playery]; if (i == ONOTHING) return; showcell(playerx,playery); yrepcount=0; switch (i) { case OGOLDPILE: case OMAXGOLD: case OKGOLD: case ODGOLD: ogold(i); break; case OPOTION: Print("You find a magic potion"); i = iarg[playerx][playery]; if (potionknown[i]) Printf(" of %s",&potionname[i][1]); Print("."); add_option('d', "Drink", ""); add_option('t', "Take", ""); break; case OSCROLL: Print("You find a magic scroll"); i = iarg[playerx][playery]; if (scrollknown[i]) Printf(" of %s",&scrollname[i][1]); Print("."); if (c[BLINDCOUNT] == 0) add_option('r', "Read", ""); add_option('t', "Take", ""); break; case OALTAR: if (nearbymonst()) return; Print("There is a holy altar here."); set_callback("act_on_object"); add_option('p', "Pray", ""); add_option('d', "Desecrate", ""); add_option('i', "Ignore", ""); break; case OBOOK: Print("You find a book."); if (c[BLINDCOUNT] == 0) add_option('r', "Read", ""); add_option('t', "Take", ""); break; case OCOOKIE: Print("You find a fortune cookie."); add_option('e', "Eat", ""); add_option('t', "Take", ""); break; case OTHRONE: case OTHRONE2: if (nearbymonst()) return; Printf("There is %s here.", objectname[i]); add_option('p', "Pry Jewels", ""); add_option('s', "Sit", ""); break; case ODEADTHRONE: Printf("There is %s here.", objectname[i]); add_option('s', "Sit", ""); break; case OORB: if (nearbymonst()) return; finditem(i); break; case OBRASSLAMP: Print("You find a brass lamp."); add_option('r', "Rub", ""); add_option('t', "Take", ""); return; case OWWAND: if (nearbymonst()) return; finditem(i); break; case OHANDofFEAR: if (nearbymonst()) return; finditem(i); break; case OPIT: Print("You're standing at the top of a pit."); opit(); break; case OSTAIRSUP: Print("There is a circular staircase here."); add_option('u', "Up", ""); break; case OELEVATORUP: Print("You have found an express elevator going up."); oelevator(1); /* up */ break; case OELEVATORDOWN: Print("You have found an express elevator going down."); oelevator(-1); /* down */ break; case OFOUNTAIN: if (nearbymonst()) return; Print("There is a fountain here."); add_option('d', "Drink", ""); add_option('w', "Wash Yourself", ""); break; case OSTATUE: if (nearbymonst()) return; Print("You stand before a statue."); ostatue(); break; case OCHEST: Print("There is a chest here."); add_option('t', "Take", ""); add_option('o', "Open", ""); break; case OIVTELETRAP: if (rnd(11)<6) return; item[playerx][playery] = OTELEPORTER; case OTELEPORTER: /* * The player is being teleported, so obviously the player gets * to know that a teleport trap is here. * oteleport forces a screen redraw, so don't bother display anything * here. */ know[playerx][playery] = item[playerx][playery]; Print("Zaaaappp! You've been teleported!"); UlarnBeep(); nap(3000); oteleport(0); break; case OSCHOOL: if (nearbymonst()) return; Print("You have found the College of Ularn."); add_option('g', "Go in", ""); break; case OMIRROR: if (nearbymonst()) return; Print("There is a mirror here."); omirror(); break; case OBANK2: case OBANK: if (nearbymonst()) return; if (i==OBANK) { Print("You have found the bank of Ularn."); } else { Print("You have found a branch office of the bank of Ularn."); } add_option('g', "Go in", ""); break; case ODEADFOUNTAIN: if (nearbymonst()) return; Print("There is a dead fountain here."); break; case ODNDSTORE: if (nearbymonst()) return; Print("There is a DND store here."); add_option('g', "Go in", ""); break; case OSTAIRSDOWN: Print("There is a circular staircase here."); add_option('d', "Down", ""); break; case OOPENDOOR: Print("There is an open door here."); break; case OCLOSEDDOOR: /* can't move objects if time is stopped */ if (c[TIMESTOP]) return; dx = playerx; dy = playery; if (dropflag) return; Printf("You find %s",objectname[i]); set_callback("act_on_object"); add_option('o', "Open", ""); add_option('i', "Ignore", ""); break; case OENTRANCE: Print("You have found "); Print(objectname[OENTRANCE]); add_option('g', "Go in", ""); break; case OVOLDOWN: Print("You have found "); Print(objectname[OVOLDOWN]); add_option('c', "Climb down", ""); return; case OVOLUP: Print("You have found "); Print(objectname[OVOLUP]); add_option('c', "Climb up", ""); return; case OTRAPARROWIV: if (rnd(17)<13) return; /* for an arrow trap */ item[playerx][playery] = OTRAPARROW; case OTRAPARROW: Print("You are hit by an arrow!"); UlarnBeep(); /* for an arrow trap */ losehp(DIED_SHOT_BY_ARROW, rnd(10)+level); UpdateStatus(); return; case OIVDARTRAP: if (rnd(17)<13) return; /* for a dart trap */ item[playerx][playery] = ODARTRAP; case ODARTRAP: Print("You are hit by a dart!"); UlarnBeep(); /* for a dart trap */ losehp(DIED_HIT_BY_DART, rnd(5)); if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3; UpdateStatus(); return; case OIVTRAPDOOR: if (rnd(17)<13) return; /* for a trap door */ item[playerx][playery] = OTRAPDOOR; case OTRAPDOOR: for (i=0;i<IVENSIZE;i++) { if (iven[i]==OWWAND) { Print("You escape a trap door."); return; } } if ((level==DBOTTOM)||(level==VBOTTOM)) { Print("You fall through a trap door leading straight to HELL!"); UlarnBeep(); nap(3000); died(DIED_FELL_THROUGH_BOTTOMLESS_TRAPDOOR, 0); } Print("You fall through a trap door!"); UlarnBeep(); losehp(DIED_FELL_THROUGH_TRAPDOOR, rnd(5+level)); nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY); UpdateStatusAndEffects(); return; case OTRADEPOST: if (nearbymonst()) return; Print("You have found the Ularn trading Post."); add_option('g', "Go in", ""); return; case OHOME: if (nearbymonst()) return; Print("You have found your way home."); add_option('g', "Go in", ""); return; case OPAD: if (nearbymonst()) return; Print("You have found Dealer McDope's Hideout!"); add_option('g', "Go in", ""); return; case OSPEED: Print("You find some speed."); add_option('s', "Snort", ""); add_option('t', "Take", ""); break; case OSHROOMS: Print("You find some magic mushrooms."); add_option('e', "Eat", ""); add_option('t', "Take", ""); break; case OACID: Print("You find some LSD."); add_option('e', "Eat", ""); add_option('t', "Take", ""); break; case OHASH: Print("You find some hashish."); add_option('s', "Smoke", ""); add_option('t', "Take", ""); break; case OCOKE: Print("You find some cocaine."); add_option('s', "Snort", ""); add_option('t', "Take", ""); break; case OWALL: break; case OANNIHILATION: if (player_has_item(OSPHTALISMAN)) { Print("The Talisman of the Sphere protects you from annihilation!"); return; } /* annihilated by sphere of annihilation */ died(DIED_SPHERE_ANNIHILATION, 0); return; case OLRS: if (nearbymonst()) return; Print("There is an LRS office here."); add_option('g', "Go in", ""); break; default: finditem(i); break; } }
/*JUEGO*/ void game(){ u8 atkObj = 0; initVariables(1); initPlayer(map); initNivel(); initEnemies(map); cpct_clearScreen(0); drawMap(map); while (1){ if(finish == 1) return; //Esperar el retrazado cpct_waitVSYNC(); //Desdibujar personajes erases(); //Dibujar pickups if(temp == 10) drawPickUps(n.corazon,n.bullet); //Dibujar personajes draws(); //Dibujar fatiga if(temp == 10){ if(player.atk < 20) drawFatiga(player.atk,2); else if(player.atk > 20) drawFatiga(player.atk,1); else drawFatiga(player.atk,0); } //guardar datos anteriores if(temp%2 == 0){ player.lx = player.x; player.ly = player.y; } if(enemy.life > 0){ if(temp%2 == 1){ enemy.lx = enemy.x; enemy.ly = enemy.y; } move(); switch(checkCollisions(player.x, player.y, enemy.x, enemy.y, player.atk)){ case 1: erase(enemy.lx,enemy.ly,0); enemy.x = enemy.ox; enemy.y = enemy.oy; enemy.lx = enemy.x; enemy.ly = enemy.y; enemy.ox = originse[map-1][4]; enemy.oy = originse[map-1][5]; enemy.life -= 1; player.atk = 20; enemy.pursue = 0; break; case 2: erase(player.lx,player.ly,0); player.x =originsp[map-1][0]; player.y = originsp[map-1][1]; player.lx =originsp[map-1][0]; player.ly = originsp[map-1][1]; player.life -= 1; player.atk = 20; enemy.pursue = 0; break; } } if(temp > 10) temp = 0; temp += 1; player.latk = player.atk; //Comprobar teclado cpct_scanKeyboard_f(); player.sprite = checkKeyboard(); checkBoundsCollisions(&n.corazon,&n.bullet); if(arrow == 1){ moveObject(); bound = checkArrowCollisions(); if(object.dir == 2 || object.dir == 8) atkObj = 21; else atkObj = 22; if(enemy.life > 0 && checkCollisions(object.x, object.y, enemy.x, enemy.y, atkObj) == 1 && bound == 0){ enemy.life -= 1; erase(enemy.lx,enemy.ly,0); enemy.x = enemy.ox; enemy.y = enemy.oy; enemy.lx = enemy.x; enemy.ly = enemy.y; enemy.pursue = 0; object.vivo = 0; bound = 1; } } if(player.life == 0){ gameOver(); finish = 1; } } }
/* function to read a scroll */ void read_scroll(int typ) { int i,j; if (typ<0 || typ>=MAXSCROLL) return; /* be sure we are within bounds */ if (scrollknown[typ] == 0) scrollknown[typ] = 1; lprintf("\nYou read a scroll of %s.", &(scrollname[typ][1])); switch(typ) { case SENCHANTARM: enchantarmor(ENCH_SCROLL); return; case SENCHANTWEAP: enchweapon(ENCH_SCROLL); return; case SENLIGHTEN: lflush(); yh = min(playery+7,MAXY); xh = min(playerx+25,MAXX); yl = max(playery-7,0); xl = max(playerx-25,0); for (i=yl; i<yh; i++) for (j=xl; j<xh; j++) know[j][i]=1; nap(2000); draws(xl,xh,yl,yh); return; case SBLANK: return; case SCREATEMONST: createmonster(makemonst(level+1)); return; case SCREATEITEM: something(playerx, playery, level); return; case SAGGMONST: c[AGGRAVATE]+=800; return; case STIMEWARP: /* * This code is slightly wrong in that, if gtime is small and * we can't go back by the required number of mobuls, it's * still reported that we did. I don't think this is * critical -- dmr */ i = (rnd(1000) - 850)/100; if (i==0) i=1; gtime += 100*i; if (gtime < 0) gtime = 0; lprintf("\nYou go %sward in time by %d mobul%s", (i<0)?"back":"for", (i<0)?-i:i, i==1?"":"s"); adjusttime((long)(i*100));/* adjust time for time warping */ return; case STELEPORT: oteleport(0); return; case SAWARENESS: c[AWARENESS] += 1800; return; case SHASTEMONST: c[HASTEMONST] += rnd(55)+12; lprintf(" You feel nervous."); return; case SMONSTHEAL: for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) if (mitem[j][i].mon) hitp[j][i] = monster[mitem[j][i].mon].hitpoints; lprintf(" You feel uneasy."); return; case SSPIRITPROT: c[SPIRITPRO] += 300 + rnd(200); bottomline(); return; case SUNDEADPROT: c[UNDEADPRO] += 300 + rnd(200); bottomline(); return; case SSTEALTH: c[STEALTH] += 250 + rnd(250); bottomline(); return; case SMAGICMAP: lflush(); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) know[j][i]=1; nap(2000); draws(0,MAXX,0,MAXY); return; case SHOLDMONST: c[HOLDMONST] += 30; bottomline(); return; case SGEMPERFECT: for (i=0; i<IVENSIZE; i++) switch(iven[i]) { case ODIAMOND: case ORUBY: case OEMERALD: case OSAPPHIRE: j = ivenarg[i]; j *= 2; if (j <= 0 && ivenarg[i]) j=2550; ivenarg[i] = j; break; } break; case SSPELLEXT: for (i=0; i<11; i++) c[exten[i]] <<= 1; break; case SIDENTIFY: for (i=0; i<IVENSIZE; i++) { if (iven[i]==OPOTION) potionknown[ivenarg[i]] = 1; if (iven[i]==OSCROLL) scrollknown[ivenarg[i]] = 1; } break; case SREMCURSE: removecurse(); break; case SANNIHILATE: annihilate(); break; case SPULVERIZE: godirect(22,150,"The ray hits the %s.",0,' '); break; case SLIFEPROT: c[LIFEPROT]++; break; }; }