/* read a scroll, book, tome, etc. */ void peruse() { int index; struct object *obj; clearmsg(); if (Player.status[BLINDED] > 0) print3("You're blind -- you can't read!!!"); else if (Player.status[AFRAID] > 0) print3("You are too afraid to stop to read a scroll!"); else { print1("Read -- "); index = getitem(SCROLL); if (index == ABORT) setgamestatus(SKIP_MONSTERS); else { obj = Player.possessions[index]; if (obj->objchar != SCROLL) { print3("There's nothing written on "); nprint3(itemid(obj)); } else { nprint1("You carefully unfurl the scroll...."); morewait(); item_use(obj); dispose_lost_objects(1,obj); } } } }
short dump_condo( FILE *dumpfile ) { pol ol; if ( Condoitems ) { /* reset "checksum" */ dumpcheck = 0; if ( !dump( dumpfile, "-- Possessions (In Condo) --\n\n", FALSE ) ) return FALSE; for( ol = Condoitems; ol; ol = ol->next ) { sprintf( dump_buf, "%s\n", itemid( ol->thing ) ); if ( !dump( dumpfile, dump_buf, TRUE ) ) return FALSE; } sprintf( dump_buf, "\n[Verification: %8.8lx]\n\n", dumpcheck ); if ( !dump( dumpfile, dump_buf, FALSE ) ) return FALSE; } return TRUE; }
void eat() { int index; struct object *obj; clearmsg(); print1("Eat --"); index = getitem(FOOD); if (index == ABORT) setgamestatus(SKIP_MONSTERS); else { obj = Player.possessions[index]; if ((obj->objchar != FOOD)&&(obj->objchar != CORPSE)) { print3("You can't eat "); nprint3(itemid(obj)); } else { if (obj->usef == I_FOOD) Player.food = max(0,Player.food+obj->aux); item_use(obj); dispose_lost_objects(1,obj); if (Current_Dungeon == E_COUNTRYSIDE) { Time += 100; hourly_check(); } } } foodcheck(); }
short dump_pack( FILE *dumpfile ) { int i; if ( Player.packptr > 0 ) { /* reset "checksum" */ dumpcheck = 0; if ( !dump( dumpfile, "-- Possessions (In Pack) --\n\n", FALSE ) ) return FALSE; for( i = 0; i < Player.packptr; i++ ) { sprintf( dump_buf, "%c) %s\n", i + 'A', itemid( Player.pack[ i ] ) ); if ( !dump( dumpfile, dump_buf, TRUE ) ) return FALSE; } sprintf( dump_buf, "\n[Verification: %8.8lx]\n\n", dumpcheck ); if ( !dump( dumpfile, dump_buf, FALSE ) ) return FALSE; } return TRUE; }
void strcat_carry_item( char *buf, int slot ) { if ( Player.possessions[ slot ] == NULL ) strcat( buf, "(nothing)\n" ); else { strcat( buf, itemid( Player.possessions[ slot ] )); strcat( buf, "\n" ); } }
/* try to break a weapon (from fumbling) */ void break_weapon(void) { if (Player.possessions[O_WEAPON_HAND] != NULL) { strcpy(Str1,"Your "); strcat(Str1,itemid(Player.possessions[O_WEAPON_HAND])); strcat(Str1," vibrates in your hand...."); mprint(Str1); (void) damage_item(Player.possessions[O_WEAPON_HAND]); morewait(); } }
void identify(int blessing) { int index; clearmsg(); if (blessing == 0) { index = getitem_prompt("Identify: ", NULL_ITEM); if (index == CASHVALUE) print3("Your money is really money."); else if (index == ABORT) State.setSkipMonsters(); else { if (Player.possessions[index]->objchar == FOOD) Player.possessions[index]->known = 1; else { Player.possessions[index]->known = 2; Objects[Player.possessions[index]->id].known = 1; } print1("Identified: "); mprint(itemid(Player.possessions[index])); } } else if (blessing < 0) { print2("You feel forgetful."); for (index=0; index<MAXITEMS; index++) if (Player.possessions[index] != NULL) { Player.possessions[index]->known = 0; Objects[Player.possessions[index]->id].known = 0; } } else { print2("You feel encyclopaedic."); for (index=0; index<MAXITEMS; index++) if (Player.possessions[index] != NULL) { if (Player.possessions[index]->objchar == FOOD) Player.possessions[index]->known = 1; else { Player.possessions[index]->known = 2; Objects[Player.possessions[index]->id].known = 1; } } for (index=0; index<Player.packptr; index++) if (Player.pack[index] != NULL) { if (Player.pack[index]->objchar == FOOD) Player.pack[index]->known = 1; else { Player.pack[index]->known = 2; Objects[Player.pack[index]->id].known = 1; } } } calc_melee(); }
void display_pack(void) { int i; if (Player.packptr < 1) print3("Pack is empty."); else { menuclear(); menuprint("Items in Pack:\n"); for(i=0;i<Player.packptr;i++) { sprintf(Str1, " %c: %s\n", i + 'A', itemid(Player.pack[i])); menuprint(Str1); } showmenu(); } }
void quaff() { int index; struct object *obj; clearmsg(); print1("Quaff --"); index = getitem(POTION); if (index == ABORT) setgamestatus(SKIP_MONSTERS); else { obj = Player.possessions[index]; if (obj->objchar != POTION) { print3("You can't drink "); nprint3(itemid(obj)); } else { print1("You drink it down.... "); item_use(obj); morewait(); dispose_lost_objects(1,obj); } } }
/* bless */ void bless(int blessing) { int index,used; if (blessing < 0) { index = random_item(); if (index == ABORT) { print1("You feel fortunate."); morewait(); } else { print1("A foul odor arises from "); if (Player.possessions[index]->uniqueness == COMMON) nprint1("your "); nprint1(itemid(Player.possessions[index])); morewait(); used = (Player.possessions[index]->used); if (used) { State.setSuppressPrinting( true ); Player.possessions[index]->used = false; item_use(Player.possessions[index]); State.setSuppressPrinting( false ); } Player.possessions[index]->blessing -= 2; if (Player.possessions[index]->blessing < 0) Player.possessions[index]->plus = abs(Player.possessions[index]->plus) - 1; if (used) { State.setSuppressPrinting( true ); Player.possessions[index]->used = true; item_use(Player.possessions[index]); State.setSuppressPrinting( false ); } } } else { index = getitem(NULL_ITEM); if (index == CASHVALUE) { print1("Blessing your money has no effect."); morewait(); } else if (index != ABORT) { used = Player.possessions[index]->isUsed(); if (used) { State.setSuppressPrinting( true ); Player.possessions[index]->used = false; item_use(Player.possessions[index]); State.setSuppressPrinting( false ); } print1("A pure white light surrounds the item... "); if (Player.possessions[index]->blessing < 0-(blessing+1)) { print2("which is evil enough to resist the effect of the blessing!"); morewait(); } else if (Player.possessions[index]->blessing < -1) { print2("which disintegrates under the influence of the holy aura!"); morewait(); Player.itemweight -= Player.possessions[index]->weight; dispose_lost_objects(1,Player.possessions[index]); } else if (Player.possessions[index]->blessing < blessing+1) { print2("which now seems affected by afflatus!"); morewait(); Player.possessions[index]->blessing++; Player.possessions[index]->plus = abs(Player.possessions[index]->plus)+1; } else { print2("The hierolux fades without any appreciable effect...."); morewait(); } if (used && (Player.possessions[index] != NULL)) { State.setSuppressPrinting( true ); Player.possessions[index]->used = true; item_use(Player.possessions[index]); State.setSuppressPrinting( false ); } } } calc_melee(); }
/* Attempt to break an object o */ int damage_item(Object* o) { /* special case -- break star gem */ if (o->id == OB_STARGEM) { print1("The Star Gem shatters into a million glistening shards...."); if (Current_Environment == E_STARPEAK) { if (!State.getKilledLawbringer()) print2("You hear an agonizing scream of anguish and despair."); morewait(); print1("A raging torrent of energy escapes in an explosion of magic!"); print2("The energy flows to the apex of Star Peak where there is"); morewait(); clearmsg(); print1("an enormous explosion!"); morewait(); annihilate(1); print3("You seem to gain strength in the chaotic glare of magic!"); Player.str = max(Player.str, Player.maxstr + 5); /* FIXED! 12/25/98 */ Player.pow = max(Player.pow, Player.maxpow + 5); /* ditto */ Player.alignment -= 200; dispose_lost_objects(1,o); } else { morewait(); print1("The shards coalesce back together again, and vanish"); print2("with a muted giggle."); dispose_lost_objects(1,o); Objects[o->id].uniqueness = UNIQUE_UNMADE; /* FIXED! 12/30/98 */ } return 1; } else { if (o->fragility < random_range(30)) { if (o->objchar == STICK && o->charge > 0) { strcpy(Str1,"Your "); strcat(Str1,(o->blessing >= 0 ? o->truename : o->cursestr)); strcat(Str1," explodes!"); print1(Str1); morewait(); nprint1(" Ka-Blamm!!!"); /* general case. Some sticks will eventually do special things */ morewait(); manastorm(Player.x, Player.y, o->charge*o->level*10); dispose_lost_objects(1,o); return 1; } else if ((o->blessing > 0) && (o->level > random_range(10))) { strcpy(Str1,"Your "); strcat(Str1,itemid(o)); strcat(Str1," glows strongly."); print1(Str1); return 0; } else if ((o->blessing < -1) && (o->level > random_range(10))) { strcpy(Str1,"You hear an evil giggle from your "); strcat(Str1,itemid(o)); print1(Str1); return 0; } else if (o->plus > 0) { strcpy(Str1,"Your "); strcat(Str1,itemid(o)); strcat(Str1," glows and then fades."); print1(Str1); o->plus--; return 0; } else { if (o->blessing > 0) print1("You hear a faint despairing cry!"); else if (o->blessing < 0) print1("You hear an agonized scream!"); strcpy(Str1,"Your "); strcat(Str1,itemid(o)); strcat(Str1," shatters in a thousand lost fragments!"); print2(Str1); morewait(); dispose_lost_objects(1,o); return 1; } } return 0; } }
/* gain for an item */ void acquire(int blessing) { char otype; int index,id = ABORT; pob newthing; if (blessing < 0) { index = random_item(); if (index == ABORT) mprint("You feel fortunate."); else { print1("Smoke drifts out of your pack.... "); print2("Destroyed: "); nprint2(itemid(Player.possessions[index])); morewait(); dispose_lost_objects(1,Player.possessions[index]); } } else { newthing = ((pob) checkmalloc(sizeof(objtype))); /* DAG this assignment looks unneccessary */ newthing->id = -1; if (gamestatusp(CHEATED)) print1("Acquire which kind of item: !?][}{)/=%%\\& "); else print1("Acquire which kind of item: !?][}{)/=%%\\ "); otype = mgetc(); switch (otype) { case (POTION&0xff): if (blessing > 0) id = itemlist(POTIONID,NUMPOTIONS); else id = random_range(NUMPOTIONS); if (id < 0) print2("You feel stupid."); else make_potion(newthing,id); break; case (SCROLL&0xff): if (blessing > 0) id = itemlist(SCROLLID,NUMSCROLLS); else id = random_range(NUMSCROLLS); if (id < 0) print2("You feel stupid."); else make_scroll(newthing,id); break; case (RING&0xff): if (blessing > 0) id = itemlist(RINGID,NUMRINGS); else id = random_range(NUMRINGS); if (id < 0) print2("You feel stupid."); else make_ring(newthing,id); break; case (STICK&0xff): if (blessing > 0) id = itemlist(STICKID,NUMSTICKS); else id = random_range(NUMSTICKS); if (id < 0) print2("You feel stupid."); else make_stick(newthing,id); break; case (ARMOR&0xff): if (blessing > 0) id = itemlist(ARMORID,NUMARMOR); else id = random_range(NUMARMOR); if (id < 0) print2("You feel stupid."); else make_armor(newthing,id); break; case (SHIELD&0xff): if (blessing > 0) id = itemlist(SHIELDID,NUMSHIELDS); else id = random_range(NUMSHIELDS); if (id < 0) print2("You feel stupid."); else make_shield(newthing,id); break; case (WEAPON&0xff): if (blessing > 0) id = itemlist(WEAPONID,NUMWEAPONS); else id = random_range(NUMWEAPONS); if (id < 0) print2("You feel stupid."); else make_weapon(newthing,id); break; case (BOOTS&0xff): if (blessing > 0) id = itemlist(BOOTID,NUMBOOTS); else id = random_range(NUMBOOTS); if (id < 0) print2("You feel stupid."); else make_boots(newthing,id); break; case (CLOAK&0xff): if (blessing > 0) id = itemlist(CLOAKID,NUMCLOAKS); else id = random_range(NUMCLOAKS); if (id < 0) print2("You feel stupid."); else make_cloak(newthing,id); break; case (FOOD&0xff): if (blessing > 0) id = itemlist(FOODID,NUMFOODS); else id = random_range(NUMFOODS); if (id < 0) print2("You feel stupid."); else make_food(newthing,id); break; case (THING&0xff): if (blessing > 0) id = itemlist(THINGID,NUMTHINGS); else id = random_range(NUMTHINGS); if (id < 0) print2("You feel stupid."); else make_thing(newthing,id); break; case (ARTIFACT&0xff): if (gamestatusp(CHEATED)) id = itemlist(ARTIFACTID,NUMARTIFACTS); else id = -1; if (id < 0) print2("You feel stupid."); else make_artifact(newthing,id); break; default: print2("You feel stupid."); } xredraw(); if (id != ABORT) { if (blessing > 0) { newthing->known = 2; Objects[id].known = 1; } newthing->used = FALSE; gain_item(newthing); } else { /* DAG newthing allocated but was not freed... was YA memory leak */ /* use free() rather than free_obj() since newthing not initialized */ free( (char *) newthing ); } } }
void l_thieves_guild(void) { int fee,count,i,number,done=FALSE,dues=1000; char c,action; pob lockpick; print1("You have penetrated to the Lair of the Thieves' Guild."); if (! nighttime()) print2("There aren't any thieves around in the daytime."); else { if ((Player.rank[THIEVES]==TMASTER) && (Player.level > Shadowlordlevel) && find_and_remove_item(OB_JUSTICIAR_BADGE,-1)) { print2("You nicked the Justiciar's Badge!"); morewait(); print1("The Badge is put in a place of honor in the Guild Hall."); print2("You are now the Shadowlord of the Thieves' Guild!"); morewait(); print1("Who says there's no honor among thieves?"); strcpy(Shadowlord,Player.name); Shadowlordlevel = Player.level; morewait(); Shadowlordbehavior = fixnpc(4); save_hiscore_npc(7); clearmsg(); print1("You learn the Spell of Shadowform."); Spells[S_SHADOWFORM].known = TRUE; morewait(); clearmsg(); Player.rank[THIEVES]=SHADOWLORD; Player.maxagi += 2; Player.maxdex += 2; Player.agi += 2; Player.dex += 2; } while (! done) { menuclear(); if (Player.rank[THIEVES] == 0) menuprint("a: Join the Thieves' Guild.\n"); else menuprint("b: Raise your Guild rank.\n"); menuprint("c: Get an item identified.\n"); if (Player.rank[THIEVES] > 0) menuprint("d: Fence an item.\n"); menuprint("ESCAPE: Leave this Den of Iniquity."); showmenu(); action = mgetc(); if (action == ESCAPE) done = TRUE; else if (action == 'a') { done = TRUE; if (Player.rank[THIEVES]> 0) print2("You are already a member!"); else if (Player.alignment > 10) print2("You are too lawful to be a thief!"); else { dues += dues*(12-Player.dex)/9; dues += Player.alignment*5; dues = max(100,dues); clearmsg(); mprint("Dues are"); mnumprint(dues); mprint(" Au. Pay it? [yn] "); if (ynq1() =='y') { if (Player.cash < dues) { print1("You can't cheat the Thieves' Guild!"); print2("... but the Thieves' Guild can cheat you...."); Player.cash = 0; } else { print1("Shadowlord "); nprint1(Shadowlord); print2("enters your name into the roll of the Guild."); morewait(); clearmsg(); print1("As a special bonus, you get a free lockpick."); print2("You are taught the spell of Object Detection."); morewait(); Spells[S_OBJ_DET].known = TRUE; lockpick = ((pob) checkmalloc(sizeof(objtype))); *lockpick = Objects[OB_LOCK_PICK]; /* lock pick */ gain_item(lockpick); Player.cash -= dues; dataprint(); Player.guildxp[THIEVES]=1; Player.rank[THIEVES]=TMEMBER; Player.maxdex++;Player.dex++;Player.agi++;Player.maxagi++; } } } } else if (action == 'b') { if (Player.rank[THIEVES]==0) print2("You are not even a member!"); else if (Player.rank[THIEVES]==SHADOWLORD) print2("You can't get any higher than this!"); else if (Player.rank[THIEVES]==TMASTER) { if (Player.level <= Shadowlordlevel) print2("You are not experienced enough to advance."); else print2("You must bring back the Justiciar's Badge!"); } else if (Player.rank[THIEVES]==THIEF) { if (Player.guildxp[THIEVES] < 4000) print2("You are not experienced enough to advance."); else { print1("You are now a Master Thief of the Guild!"); print2("You are taught the Spell of Apportation."); morewait(); print1("To advance to the next level you must return with"); print2("the badge of the Justiciar (cursed be his name)."); morewait(); clearmsg(); print1("The Justiciar's office is just south of the gaol."); Spells[S_APPORT].known = TRUE; Player.rank[THIEVES]=TMASTER; Player.maxagi++; Player.maxdex++; Player.agi++; Player.dex++; } } else if (Player.rank[THIEVES]==ATHIEF) { if (Player.guildxp[THIEVES] < 1500) print2("You are not experienced enough to advance."); else { print1("You are now a ranking Thief of the Guild!"); print2("You learn the Spell of Invisibility."); Spells[S_INVISIBLE].known = TRUE; Player.rank[THIEVES]=THIEF; Player.agi++; Player.maxagi++; } } else if (Player.rank[THIEVES]==TMEMBER) { if (Player.guildxp[THIEVES] < 400) print2("You are not experienced enough to advance."); else { print1("You are now an Apprentice Thief!"); print2("You are taught the Spell of Levitation."); Spells[S_LEVITATE].known = TRUE; Player.rank[THIEVES]=ATHIEF; Player.dex++; Player.maxdex++; } } } else if (action == 'c') { if (Player.rank[THIEVES]==0) { print1("RTG, Inc, Appraisers. Identification Fee: 50Au/item."); fee = 50; } else { fee = 5; print1("The fee is 5Au per item."); } print2("Identify one item, or all possessions? [ip] "); if ((char) mcigetc()=='i') { if (Player.cash < fee) print2("Try again when you have the cash."); else { Player.cash -= fee; dataprint(); identify(0); } } else { count = 0; for(i=1;i<MAXITEMS;i++) if (Player.possessions[i] != NULL) if (Player.possessions[i]->known < 2) count++; for(i=0;i<Player.packptr;i++) if (Player.pack[i] != NULL) if (Player.pack[i]->known < 2) count++; clearmsg(); print1("The fee will be: "); mnumprint(max(count*fee,fee)); nprint1("Au. Pay it? [yn] "); if (ynq1()=='y') { if (Player.cash < max(count*fee,fee)) print2("Try again when you have the cash."); else { Player.cash -= max(count*fee,fee); dataprint(); identify(1); } } } } else if (action == 'd') { if (Player.rank[THIEVES]==0) print2("Fence? Who said anything about a fence?"); else { print1("Fence one item or go through pack? [ip] "); if ((char) mcigetc()=='i') { i = getitem(NULL_ITEM); if ((i==ABORT) || (Player.possessions[i] == NULL)) print2("Huh, Is this some kind of set-up?"); else if (Player.possessions[i]->blessing < 0) print2("I don't want to buy a cursed item!"); else { clearmsg(); print1("I'll give you "); mlongprint(2 * item_value(Player.possessions[i]) / 3); nprint1("Au each. OK? [yn] "); if (ynq1() == 'y') { number = getnumber(Player.possessions[i]->number); if ((number >= Player.possessions[i]->number) && Player.possessions[i]->used) { Player.possessions[i]->used = FALSE; item_use(Player.possessions[i]); } Player.cash += number*2*item_value(Player.possessions[i])/3; /* Fenced artifacts could turn up anywhere, really... */ if (Objects[Player.possessions[i]->id].uniqueness > UNIQUE_UNMADE) Objects[Player.possessions[i]->id].uniqueness = UNIQUE_UNMADE; dispose_lost_objects(number,Player.possessions[i]); dataprint(); } else print2("Hey, gimme a break, it was a fair price!"); } } else { for(i=0;i<Player.packptr;i++) { if (Player.pack[i]->blessing > -1) { clearmsg(); print1("Sell "); nprint1(itemid(Player.pack[i])); nprint1(" for "); mlongprint(2*item_value(Player.pack[i])/3); nprint1("Au each? [ynq] "); if ((c=ynq1())=='y') { number = getnumber(Player.pack[i]->number); Player.cash += 2*number * item_value(Player.pack[i]) / 3; Player.pack[i]->number -= number; if (Player.pack[i]->number < 1) { /* Fenced an artifact? You just might see it again. */ if (Objects[Player.pack[i]->id].uniqueness > UNIQUE_UNMADE) Objects[Player.pack[i]->id].uniqueness = UNIQUE_UNMADE; free((char *)Player.pack[i]); Player.pack[i] = NULL; } dataprint(); } else if (c=='q') break; } } fixpack(); } } } } } xredraw(); }
void display_inventory_slot(int slotnum, int topline) { WINDOW *W; char usechar = ')', idchar = '-'; if (Player.possessions[slotnum] != NULL) if (Player.possessions[slotnum]->used) usechar = '>'; if (topline) W = Msg3w; else { W = Showline[slotnum]; hide_line(slotnum); } idchar = index_to_key(slotnum); touchwin(W); wclear(W); switch(slotnum) { case O_UP_IN_AIR: wprintw(W,"-- Object 'up in air':",usechar); break; case O_READY_HAND: wprintw(W,"-- %c%c ready hand: ",idchar,usechar); break; case O_WEAPON_HAND: wprintw(W,"-- %c%c weapon hand: ",idchar,usechar); break; case O_LEFT_SHOULDER: wprintw(W,"-- %c%c left shoulder: ",idchar,usechar); break; case O_RIGHT_SHOULDER: wprintw(W,"-- %c%c right shoulder: ",idchar,usechar); break; case O_BELT1: wprintw(W,"-- %c%c belt: ",idchar,usechar); break; case O_BELT2: wprintw(W,"-- %c%c belt: ",idchar,usechar); break; case O_BELT3: wprintw(W,"-- %c%c belt: ",idchar,usechar); break; case O_SHIELD: wprintw(W,"-- %c%c shield: ",idchar,usechar); break; case O_ARMOR: wprintw(W,"-- %c%c armor: ",idchar,usechar); break; case O_BOOTS: wprintw(W,"-- %c%c boots: ",idchar,usechar); break; case O_CLOAK: wprintw(W,"-- %c%c cloak: ",idchar,usechar); break; case O_RING1: wprintw(W,"-- %c%c finger: ",idchar,usechar); break; case O_RING2: wprintw(W,"-- %c%c finger: ",idchar,usechar); break; case O_RING3: wprintw(W,"-- %c%c finger: ",idchar,usechar); break; case O_RING4: wprintw(W,"-- %c%c finger: ",idchar,usechar); break; } if (Player.possessions[slotnum]== NULL) wprintw(W,"(slot vacant)"); else wprintw(W,itemid(Player.possessions[slotnum])); wrefresh(W); }
void l_condo(void) { pol ol,prev=NULL; int i,done=FALSE,over=FALSE,weeksleep=FALSE; char response; if (! gamestatusp(SOLD_CONDO)) { response = cinema_interact ("rp","Rampart Arms. Weekly Condo Rentals and Purchases", "Which are you interested in [r,p, or ESCAPE] ", NULL); if (response == 'p') { print2("Only 50,000Au. Buy it? [yn] "); if (ynq2()=='y') { if (Player.cash < 50000) print3("No mortgages, buddy."); else { setgamestatus(SOLD_CONDO); Player.cash-=50000; dataprint(); print2("You are the proud owner of a luxurious condo penthouse."); Condoitems = NULL; } } } else if (response == 'r') { print2("Weekly Rental, 1000Au. Pay for it? [yn] "); if (ynq2()=='y') { if (Player.cash < 1000) print2("Hey, pay the rent or out you go...."); else { weeksleep = TRUE; Player.cash -=1000; dataprint(); } } } else print2("Please keep us in mind for your housing needs."); } else { while (! done) { menuclear(); menuprint("Home Sweet Home\n"); menuprint("a: Leave items in your safe.\n"); menuprint("b: Retrieve items.\n"); menuprint("c: Take a week off to rest.\n"); menuprint("d: Retire permanently.\n"); menuprint("ESCAPE: Leave this place.\n"); showmenu(); response = (char) mcigetc(); if (response == 'a') { i = getitem(NULL_ITEM); if (i != ABORT) { if (Player.possessions[i]->blessing < 0) print2("The item just doesn't want to be stored away..."); else { ol = ((pol) checkmalloc(sizeof(oltype))); ol->thing = Player.possessions[i]; ol->next = Condoitems; Condoitems = ol; conform_unused_object(Player.possessions[i]); Player.possessions[i] = NULL; } } } else if (response == 'b') { ol = Condoitems; while ((ol != NULL) && (! over)) { print1("Retrieve "); nprint1(itemid(ol->thing)); nprint1(" [ynq] "); response = (char) mcigetc(); /* DAG -- fix memory leak where object list nodes weren't deleted */ if (response == 'y') { gain_item(ol->thing); if (ol == Condoitems) { ol = ol->next; free( Condoitems ); Condoitems = ol; } else { ol=ol->next; free( prev->next ); prev->next = ol; } } else if (response == 'q') over = TRUE; else { prev = ol; ol = ol->next; } } } else if (response == 'c') { weeksleep = TRUE; print1("You take a week off to rest..."); morewait(); } else if (response == 'd') { clearmsg(); if (cinema_confirm("You ponder settling down here for good.") == 'y') { p_win(); } } else if (response == ESCAPE) done = TRUE; } xredraw(); } if (weeksleep) { clearmsg(); print1("Taking a week off to rest..."); morewait(); toggle_item_use(TRUE); Player.hp = Player.maxhp; Player.str = Player.maxstr; Player.agi = Player.maxagi; Player.con = Player.maxcon; Player.dex = Player.maxdex; Player.iq = Player.maxiq; Player.pow = Player.maxpow; for (i=0; i<NUMSTATI; i++) if (Player.status[i]<1000) Player.status[i]=0; toggle_item_use(FALSE); Player.food = 36; print2("You're once again fit and ready to continue your adventure."); Time += 60*24*7; Date += 7; moon_check(); timeprint(); } }
void l_safe(void) { char response; pob newitem; int attempt = 0; response = cinema_interact("pfqi", "You have discovered a safe!", "Pick the lock [p], Force the door [f], or ignore [ESCAPE]", NULL); if (response == 'p') attempt = (2*Player.dex + Player.rank[THIEVES]*10 - random_range(100))/10; else if (response == 'f') attempt = (Player.dmg - random_range(100))/10; if (attempt > 0) { Player.alignment -= 4; gain_experience(50); print2("The door springs open!"); Level->site[Player.x][Player.y].locchar = FLOOR; Level->site[Player.x][Player.y].p_locf = L_NO_OP; lset(Player.x, Player.y, CHANGED); if (random_range(2) == 1) { print1("You find:"); do { newitem = create_object(difficulty()); print2(itemid(newitem)); morewait(); gain_item(newitem); } while (random_range(3) == 1); } else print2("The safe was empty (awwwww....)"); } else { print3("Your attempt at burglary failed!"); if (attempt == -1) { print1("A siren goes off! You see flashing red lights everywhere!"); morewait(); if (Last_Environment == E_CITY) { print2("The city guard shows up! They collar you in no time flat!"); change_environment(E_CITY); morewait(); send_to_jail(); } } else if (attempt == -2) { print1("There is a sudden flash!"); p_damage(random_range(25),FLAME,"a safe"); print2("The safe has self-destructed."); Level->site[Player.x][Player.y].locchar = RUBBLE; Level->site[Player.x][Player.y].p_locf = L_RUBBLE; lset(Player.x, Player.y, CHANGED); } else if (attempt == -3) { print1("The safe jolts you with electricity!"); lball(Player.x,Player.y,Player.x,Player.y,30); } else if (attempt < -3) { print1("You are hit by an acid spray!"); if (Player.possessions[O_CLOAK] != NULL) { print2("Your cloak is destroyed!"); conform_lost_object(Player.possessions[O_CLOAK]); p_damage(10,ACID,"a safe"); } else if (Player.possessions[O_ARMOR] != NULL) { print2("Your armor corrodes!"); Player.possessions[O_ARMOR]->dmg-=3; Player.possessions[O_ARMOR]->hit-=3; Player.possessions[O_ARMOR]->aux-=3; p_damage(10,ACID,"a safe"); } else { print2("The acid hits your bare flesh!"); p_damage(random_range(100),ACID,"a safe"); } } } }
/* enchant */ void enchant(int delta) { int i,used = false; long change_cash; if (delta < 0) { i = random_item(); if (i == ABORT || Player.possessions[i]->usef == I_NOTHING || Player.possessions[i]->usef == I_NO_OP || Player.possessions[i]->usef == I_NORMAL_ARMOR || Player.possessions[i]->usef == I_NORMAL_WEAPON || Player.possessions[i]->usef == I_NORMAL_SHIELD || Player.possessions[i]->objchar == FOOD || Player.possessions[i]->objchar == MISSILEWEAPON) { print1("You feel fortunate."); morewait(); } else if (Player.possessions[i]->blessing < 0 || (Player.possessions[i]->objchar == ARTIFACT && random_range(3))) { if (Player.possessions[i]->uniqueness == COMMON) print1("Your "); nprint1(itemid(Player.possessions[i])); nprint1(" glows, but the glow flickers out..."); morewait(); } else { used = (Player.possessions[i]->used); if (used) { Player.possessions[i]->used = false; item_use(Player.possessions[i]); } if (Player.possessions[i]->uniqueness == COMMON) print1("Your "); nprint1(itemid(Player.possessions[i])); nprint1(" radiates an aura of mundanity!"); morewait(); Player.possessions[i]->plus = 0; Player.possessions[i]->charge = -1; Player.possessions[i]->usef = I_NOTHING; if (used) { Player.possessions[i]->used = true; item_use(Player.possessions[i]); } } } else { i = getitem(CASH); if (i == ABORT) { print1("You feel unlucky."); morewait(); } else if (i == CASHVALUE) { print1("You enchant your money.... What a concept!"); change_cash = Player.cash*(random_range(7) - 3)/6; if (change_cash > 0) print2("Seems to have been a good idea!"); else print2("Maybe it wasn't such a good idea...."); Player.cash += change_cash; morewait(); } else if (Player.possessions[i]->objchar == ARTIFACT) { if (Player.possessions[i]->usef != Objects[Player.possessions[i]->id].usef) { print1("It re-acquires its magical aura!"); Player.possessions[i]->usef = Objects[Player.possessions[i]->id].usef; } else { print1("The enchantment spell enfolds the "); nprint1(itemid(Player.possessions[i])); print2("and the potent enchantment of the Artifact causes a backlash!"); morewait(); clearmsg(); manastorm(Player.x,Player.y,Player.possessions[i]->level*5); } } else { if (Player.possessions[i]->plus > random_range(20)+1) { print1("Uh-oh, the force of the enchantment was too much!"); print2("There is a loud explosion!"); morewait(); manastorm(Player.x,Player.y,Player.possessions[i]->plus*5); dispose_lost_objects(1,Player.possessions[i]); } else { used = (Player.possessions[i]->used); if (used) { State.setSuppressPrinting( true ); Player.possessions[i]->used = false; item_use(Player.possessions[i]); State.setSuppressPrinting( false ); } print1("The item shines!"); morewait(); Player.possessions[i]->plus += delta+1; if (Player.possessions[i]->charge > -1) Player.possessions[i]->charge += ((delta+1) * (random_range(10) + 1)); if (used) { State.setSuppressPrinting( true ); Player.possessions[i]->used = true; item_use(Player.possessions[i]); State.setSuppressPrinting( false ); } } } calc_melee(); } }
void item_use(Object* o) { clearmsg(); switch(o->usef) { case -1: i_no_op(o); break; case 0: i_nothing(o); break; /* scrolls */ case I_SPELLS: i_spells(o); break; case I_BLESS: i_bless(o); break; case I_ACQUIRE: i_acquire(o); break; case I_ENCHANT: i_enchant(o); break; case I_TELEPORT: i_teleport(o); break; case I_WISH: i_wish(o); break; case I_CLAIRVOYANCE: i_clairvoyance(o); break; case I_DISPLACE: i_displace(o); break; case I_ID: i_id(o); break; case I_JANE_T: i_jane_t(o); break; case I_FLUX: i_flux(o); break; case I_WARP: i_warp(o); break; case I_ALERT: i_alert(o); break; case I_CHARGE: i_charge(o); break; case I_KNOWLEDGE: i_knowledge(o); break; case I_LAW: i_law(o); break; case I_HINT: hint(); break; case I_HERO: i_hero(o); break; case I_TRUESIGHT: i_truesight(o); break; case I_ILLUMINATE: i_illuminate(o); break; case I_DEFLECT: i_deflect(o); break; /* potion functions */ case I_HEAL: i_heal(o); break; case I_OBJDET: i_objdet(o); break; case I_MONDET: i_mondet(o); break; case I_SLEEP_SELF: i_sleep_self(o); break; case I_NEUTRALIZE_POISON: i_neutralize_poison(o); break; case I_RESTORE: i_restore(o); break; case I_SPEED: i_speed(o); break; case I_AZOTH: i_azoth(o); break; case I_AUGMENT: i_augment(o); break; case I_REGENERATE: i_regenerate(o); break; case I_INVISIBLE: i_invisible(o); break; case I_BREATHING: i_breathing(o); break; case I_FEAR_RESIST: i_fear_resist(o); break; case I_CHAOS: i_chaos(o); break; case I_ACCURACY: i_accuracy(o); break; case I_LEVITATION: i_levitate(o); break; case I_CURE: i_cure(o); break; /* stick functions */ case I_FIREBOLT: i_firebolt(o); break; case I_LBOLT: i_lbolt(o); break; case I_MISSILE: i_missile(o); break; case I_SLEEP_OTHER: i_sleep_other(o); break; case I_FIREBALL: i_fireball(o); break; case I_LBALL: i_lball(o); break; case I_SNOWBALL: i_snowball(o); break; case I_SUMMON: i_summon(o); break; case I_HIDE: i_hide(o); break; case I_DISRUPT: i_disrupt(o); break; case I_DISINTEGRATE: i_disintegrate(o); break; case I_APPORT: i_apport(o); break; case I_DISPEL: i_dispel(o); break; case I_POLYMORPH: i_polymorph(o); break; case I_FEAR: i_fear(o); break; /* food functions */ case I_FOOD: o->use(); break; case I_LEMBAS: i_lembas(o); break; case I_STIM: i_stim(o); break; case I_POW: i_pow(o); break; case I_IMMUNE: i_immune(o); break; case I_POISON_FOOD: i_poison_food(o); break; case I_CORPSE: i_corpse(o); break; case I_PEPPER_FOOD: i_pepper_food(o); break; /* boots functions */ case I_PERM_SPEED: i_perm_speed(o); break; case I_PERM_HERO: i_perm_hero(o); break; case I_PERM_LEVITATE: i_perm_levitate(o); break; case I_PERM_AGILITY: i_perm_agility(o); break; /* artifact functions */ case I_SCEPTRE: i_sceptre(o); break; case I_PLANES: i_planes(o); break; case I_SERENITY: i_serenity(o); break; case I_STARGEM: i_stargem(o); break; case I_SYMBOL: i_symbol(o); break; case I_ORBMASTERY: i_orbmastery(o); break; case I_ORBFIRE: i_orbfire(o); break; case I_ORBWATER: i_orbwater(o); break; case I_ORBEARTH: i_orbearth(o); break; case I_ORBAIR: i_orbair(o); break; case I_ORBDEAD: i_orbdead(o); break; case I_CRYSTAL: i_crystal(o); break; case I_LIFE: i_life(o); break; case I_DEATH: i_death(o); break; case I_ANTIOCH: i_antioch(o); break; case I_HELM: i_helm(o); break; case I_KOLWYNIA: i_kolwynia(o); break; case I_ENCHANTMENT: i_enchantment(o); break; case I_JUGGERNAUT: i_juggernaut(o); break; case I_HOLDING: i_holding(o); break; /* cloak functions */ case I_PERM_DISPLACE: i_perm_displace(o); break; case I_PERM_NEGIMMUNE: i_perm_negimmune(o); break; case I_PERM_INVISIBLE: i_perm_invisible(o); break; case I_PERM_PROTECTION: i_perm_protection(o); break; case I_PERM_ACCURACY: i_perm_accuracy(o); break; case I_PERM_TRUESIGHT: i_perm_truesight(o); break; /* ring functions */ case I_PERM_BURDEN: i_perm_burden(o); break; case I_PERM_STRENGTH: i_perm_strength(o); break; case I_PERM_GAZE_IMMUNE: i_perm_gaze_immune(o); break; case I_PERM_FIRE_RESIST: i_perm_fire_resist(o); break; case I_PERM_POISON_RESIST: i_perm_poison_resist(o); break; case I_PERM_REGENERATE: i_perm_regenerate(o); break; case I_PERM_KNOWLEDGE: i_perm_knowledge(o); break; /* armor functions */ case I_NORMAL_ARMOR: i_normal_armor(o); break; case I_PERM_FEAR_RESIST: i_perm_fear_resist(o); break; case I_PERM_ENERGY_RESIST: i_perm_energy_resist(o); break; case I_PERM_BREATHING: i_perm_breathing(o); break; /* weapons functions */ case I_NORMAL_WEAPON: i_normal_weapon(o); break; case I_LIGHTSABRE: i_lightsabre(o); break; case I_DEMONBLADE: i_demonblade(o); break; case I_DESECRATE: i_desecrate(o); break; case I_MACE_DISRUPT: i_mace_disrupt(o); break; case I_DEFEND: i_defend(o); break; case I_VICTRIX: i_victrix(o); break; /* thing functions */ case I_PICK: i_pick(o); break; case I_KEY: i_key(o); break; case I_PERM_ILLUMINATE: i_perm_illuminate(o); break; case I_TRAP: i_trap(o); break; case I_RAISE_PORTCULLIS: i_raise_portcullis(o); break; /* shield functions */ case I_NORMAL_SHIELD: i_normal_shield(o); break; case I_PERM_DEFLECT: i_perm_deflect(o); break; #ifdef DEBUG /* WDT: good idea, DG. I'll be using this often, I predict! */ /* looking for objects without, or with unimplemented, functions */ default: fprintf(DG_debug_log, "tried to use a %s with o->usef %d\n", itemid(o), o->usef); break; #endif } }