/* Perform the actions associated with Altar desecration. */ void act_desecrate_altar(void) { if (rnd(100)<60) { createmonster(makemonst(level+2)+8); c[AGGRAVATE] += 2500; } else if (rnd(101)<30) { lprcat("\nThe altar crumbles into a pile of dust before your eyes"); forget(); /* remember to destroy the altar */ } else lprcat("\nnothing happens"); return ; }
/* act_sit_throne Sit on a throne. arg is zero if there is a gnome king associated with the throne Assumes that cursors() has been called previously. */ void act_sit_throne(int arg) { int k; k = rnd(101); if (k < 30 && arg == 0) { createmonster(GNOMEKING); item[playerx][playery]=OTHRONE2; know[playerx][playery]=0; } else if (k < 35) { lprcat("\nZaaaappp! You've been teleported!\n"); oteleport(0); } else { lprcat("\nNothing happens"); } }
/* Performs the actions associated with 'just praying' at the altar. Called when the user responds 'just pray' when in prompt mode, or enters 0 to the money prompt when praying. Assumes cursors(), and that any leading \n have been printed */ void act_just_pray(void) { if (rnd(100)<75) lprcat("nothing happens"); else if (rnd(43) == 10) { if (c[WEAR]) lprcat("You feel your armor vibrate for a moment"); enchantarmor(); return; } else if (rnd(43) == 10) { if (c[WIELD]) lprcat("You feel your weapon vibrate for a moment"); enchweapon(); return; } else createmonster(makemonst(level+1)); return; }
void domonsters(void) { Sint4 i; if (nextmontime>0) nextmontime--; else { if (nextmonster<totalmonsters && nmononscr()<maxmononscr && isalive() && !bonusmode) createmonster(); if (unbonusflag && nextmonster==totalmonsters && nextmontime==0) if (isalive()) { unbonusflag=false; createbonus(); } } for (i=0;i<MONSTERS;i++) if (mondat[i].flag) { if (mondat[i].hnt>10-levof10()) { if (mondat[i].nob) { mondat[i].nob=false; mondat[i].hnt=0; } } if (mondat[i].alive) if (mondat[i].t==0) { monai(i); if (randno(15-levof10())==0) /* Need to split for determinism */ if (mondat[i].nob && mondat[i].alive) monai(i); } else mondat[i].t--; else mondie(i); } }
int main(void) { bool GameOver = false; ALLEGRO_DISPLAY *screen = NULL; ALLEGRO_BITMAP *imagem = NULL; ALLEGRO_EVENT_QUEUE *fila_eventos = NULL; if (!al_init()) { fprintf(stderr, "Falha ao inicializar a Allegro.\n"); return -1; } if (!al_init_image_addon()) { fprintf(stderr, "Falha ao inicializar add-on allegro_image.\n"); return -1; } screen = al_create_display(LARGURA_TELA, ALTURA_TELA); if (!screen) { fprintf(stderr, "Falha ao criar janela.\n"); return -1; } imagem = al_load_bitmap("poring.png"); if (!imagem) { fprintf(stderr, "Falha ao carregar o arquivo de imagem.\n"); al_destroy_display(screen); return -1; } fila_eventos = al_create_event_queue(); if (!fila_eventos) { fprintf(stderr, "Falha ao criar fila de eventos.\n"); al_destroy_display(screen); return -1; } al_init_primitives_addon(); al_draw_line(640,480, 0, 0, al_map_rgb(255, 255, 255), 1000); al_register_event_source(fila_eventos, al_get_display_event_source(screen)); al_flip_display(); while (!GameOver) { ALLEGRO_EVENT evento; ALLEGRO_TIMEOUT timeout; al_init_timeout(&timeout, 0.05); int tem_eventos = al_wait_for_event_until(fila_eventos, &evento, &timeout); if (tem_eventos && evento.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { break; } //This is the main game loop //Create the Monstro for(int x = 1; x < 11; x++) { createmonster(x); } //Internal game loop to handle monster movement, shooting, etc. for(int walkcount = 0; walkcount < 1500; walkcount ++) { //Did the player click on 'Build a tower'? //Move the Monstro for (int x = 0; x < 11; x++) { if (Monstro[x].stillalive == true) { erasemonster(x); movemonster(x); drawmonster(x); al_flip_display(); printf("\nMonstro %d em execução\n", x); if (Monstro[x].xlocation > 529) { erasemonster(x); Monstro[x].stillalive = false; Monstro[x].xlocation = 0; Monstro[x].ylocation = 0; } } } } al_flip_display(); } al_destroy_display(screen); al_destroy_event_queue(fila_eventos); return 0; }
/* Perform the actions associated with praying at an altar and giving a donation. */ void act_donation_pray(void) { unsigned long k,temp ; while (1) { lprcat("\n\n"); cursor(1,24); cltoeoln(); cursor(1,23); cltoeoln(); lprcat("how much do you donate? "); k = readnum((long)c[GOLD]); lprcat("\n"); /* make giving zero gold equivalent to 'just pray'ing. Allows player to 'just pray' in command mode, without having to add yet another command. */ if (k == 0) { act_just_pray(); return; } if (c[GOLD] >= k) { temp = c[GOLD] / 10 ; c[GOLD] -= k; bottomline(); /* if player gave less than 10% of _original_ gold, make a monster */ if (k < temp || k < rnd(50)) { createmonster(makemonst(level+1)); c[AGGRAVATE] += 200; return; } if (rnd(101) > 50) { act_prayer_heard(); return; } if (rnd(43) == 5) { if (c[WEAR]) lprcat("You feel your armor vibrate for a moment"); enchantarmor(); return; } if (rnd(43) == 8) { if (c[WIELD]) lprcat("You feel your weapon vibrate for a moment"); enchweapon(); return; } lprcat("Thank You."); return ; } /* Player donates more gold than they have. Loop back around so player can't escape the altar for free. */ lprcat("You don't have that much!"); } }
/* * ********* * OFOUNTAIN * ********* */ void ofountain() { int x; cursors(); lprcat("\nDo you (d) drink, (w) wash yourself"); iopts(); while (1) switch(getcharacter()) { case 'd': lprcat("drink"); if (rnd(1501)<4) { lprcat("\nOH MY GOD!! You have caught the *dreadful sleep*!"); beep(); lflush(); sleep(3); died(280); return; } x = rnd(100); if (x==1) raiselevel(); else if (x < 11) { x=rnd((level<<2)+2); lprintf("\nBleah! The water tasted like stale gatorade! " "You lose %d hit point%s!", (long)x, x==1?"":"s"); lastnum=273; losehp(x); bottomline(); cursors(); } else if (x<14) { c[HALFDAM] += 200+rnd(200); lprcat("\nThe water makes you vomit."); } else if (x<17) quaffpotion(17); /* giant strength */ else if (x < 45) lprcat("\nNothing seems to have happened."); else if (rnd(3) != 2) fntchange(1); /*change char levels upward*/ else fntchange(-1); /*change char levels downward*/ if (rnd(12)<3) { lprcat("\nThe fountains bubbling slowly quietens."); /* dead fountain */ item[playerx][playery]=ODEADFOUNTAIN; know[playerx][playery]=0; } return; case 'i': case ESC: ignore(); return; case 'w': lprcat("wash yourself."); if (rnd(100) < 11) { x=rnd((level<<2)+2); lprintf("\nThe water burns like acid! You lose %d hit point%s!", (long)x, x==1?"":"s"); lastnum=273; losehp(x); bottomline(); cursors(); } else if (rnd(100) < 29) lprcat("\nYou are now clean."); else if (rnd(100) < 31) lprcat("\nThis water needs soap -- the dirt didn't come off."); else if (rnd(100) < 34) createmonster(WATERLORD); else lprcat("\nNothing seems to have happened."); return; } }
/* * ****** * OALTAR * ****** * */ void oaltar() { long k; int p; start: lprcat("\nDo you (p) pray (d) desecrate"); iopts(); while (1) { while (1) switch(getcharacter()) { case 'p': lprcat(" pray.\nDo you (m) give money or (j) just pray? "); while (1) switch(getcharacter()) { case 'j': p = rund(100); if (p < 12) createmonster(makemonst(level+2)); else if (p < 17) enchweapon(ENCH_ALTAR); else if (p < 22) enchantarmor(ENCH_ALTAR); else if (p < 27) ohear(); else lprcat("\nNothing happens."); return; case 'm': cursor(1,24); cltoeoln(); cursor(1,23); cltoeoln(); lprcat("how much do you donate? "); if ((k = readnum(c[GOLD])) < 0) goto start; if (c[GOLD] < k) { lprcat("You don't have that much!"); nap(1001); goto start; } if (k < (c[GOLD]/10) && rnd(60)<30 && !wizard) { lprcat("Cheapskate! The Gods are insulted by such a " "tiny offering!"); forget(); createmonster(DEMONPRINCE); c[AGGRAVATE] += 1500; return; } c[GOLD] -= k; if (k < (c[GOLD]+k)/10 || k < rnd(50) && !wizard) { createmonster(makemonst(level+2)); c[AGGRAVATE] += 500; bottomline(); return; } p = rund(16); if (p < 4) lprcat("Thank you."); else if (p < 6) { enchantarmor(ENCH_ALTAR); enchantarmor(ENCH_ALTAR); } else if (p < 8) { enchweapon(ENCH_ALTAR); enchweapon(ENCH_ALTAR); } else ohear(); bottomline(); return; } /* end while switch : case j or m */ case 'd': lprcat(" desecrate"); if (rnd(100)<60) { createmonster(makemonst(level+3)+8); c[AGGRAVATE] += 2500; } else if(rnd(100)<5) raiselevel(); else if (rnd(101)<30) { lprcat("\nThe altar crumbles into a pile of dust before your eyes."); forget(); /*remember to destroy the altar*/ } else lprcat("\nNothing happens."); return; case 'i': case ESC: ignore(); if (rnd(100)<30) { createmonster(makemonst(level+2)); c[AGGRAVATE] += rnd(450); } else lprcat("\nNothing happens."); return; } /* end while switch: pray, des, ignore */ } /* NOTREACHED */ } /* end oaltar */
/* 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; }; }