-+-+-+-+-+-+-+-+ START OF PART 7 -+-+-+-+-+-+-+-+ X`09 if ( dropall == 'y') `7B`20 X`09 map`5Bppos.y`5D`5Bppos.x`5D.number = BACKPACK`5Bdchar`5D.quantity; X`09 amount = BACKPACK`5Bdchar`5D.quantity; X `09 sprintf(drop_msg,"Dropped %d %ss.",amount,BACKPACK`5Bdchar`5D.name V); X `09 BACKPACK`5Bdchar`5D.quantity = 0; X`09 BACKPACK`5Bdchar`5D.invenchar = SPACE; X`09 `7D X`09 else `7B X`09 BACKPACK`5Bdchar`5D.quantity--; X `09 sprintf(drop_msg,"Dropped %s.",BACKPACK`5Bdchar`5D.name); X `09 amount = 1; X`09 map`5Bppos.y`5D`5Bppos.x`5D.number = 1; `20 X`09 `7D X`09 `7D X`09 else `7B X`09 BACKPACK`5Bdchar`5D.quantity = 0;`09 X BACKPACK`5Bdchar`5D.invenchar = SPACE; X `09 sprintf(drop_msg,"Dropped %s.",BACKPACK`5Bdchar`5D.name); X `09 amount = 1; X map`5Bppos.y`5D`5Bppos.x`5D.number = 1; `20 X `7D X `7D X X PREWEIGHT = CURWEIGHT; X CURWEIGHT -= ITEM_PROPS`5Bidentify( underchar)`5D`5BWEIGHT`5D * amount V; X if ( (PREWEIGHT >= MAXWEIGHT) && (CURWEIGHT < MAXWEIGHT)) `7B X change_speed( 2.0); X prt_msg("The burden of the pack is lifted."); X prt_speed(); X `7D X`09prt_msg(drop_msg); X`09prt_wgt(); X `09compress_inven(); X`7D Xelse prt_msg("You have no such object."); X`7D X X Xdrink_potion()`09`09`09`09/* pretty self-explanitory */ X`7B Xint bp_num, item_num, change = TRUE; Xint PREWEIGHT, OLDMAXWEIGHT; Xint d_chance; Xchar drink`5B80`5D; X Xif ( (bp_num = check_inven( POTION)) != FALSE) `7B X item_num = identify( POTION); X if ( (--BACKPACK`5Bbp_num`5D.quantity) == 0) `7B X BACKPACK`5Bbp_num`5D.invenchar = SPACE; X compress_inven(); X `7D X if ( (d_chance = random(100)) < 5) `7B X if ( flags`5BSPEED`5D.valid) `7B X prt_msg("You feel yourself slow down a bit."); X if ( speed < 1) `09`09`09/* already SLOW */ X flags`5BSPEED`5D.moves += 301;`09 X else `20 X`09flags`5BSPEED`5D.moves = 301 - flags`5BSPEED`5D.moves;`20 X `7D X else `7B X prt_msg("You feel yourself slow down."); X change_speed( 0.5); X prt_speed(); X flags`5BSPEED`5D.valid = TRUE; X flags`5BSPEED`5D.moves = 301; X `7D X `7D X else if ( d_chance < 10) `7B X if ( flags`5BSPEED`5D.valid) `7B X prt_msg("You feel yourself speed up a bit."); X if ( speed > 1) `09`09`09/* already FAST */ X`09flags`5BSPEED`5D.moves += 301;`09 X else `20 X`09flags`5BSPEED`5D.moves = 301 - flags`5BSPEED`5D.moves;`20 X `7D X else `7B X prt_msg("You feel yourself speed up."); X change_speed( 2.0); X prt_speed(); X flags`5BSPEED`5D.valid = TRUE; X flags`5BSPEED`5D.moves = 301; X `7D X `7D X else if ( d_chance < 18) `7B`20 X prt_msg("You feel your health returning."); X health += 20; X prt_health(); X `7D X else if ( d_chance < 26) `7B X prt_msg("Your arms feel like tree trunks."); X STR += 1; X OLDMAXWEIGHT = MAXWEIGHT; X MAXWEIGHT = (STR*20); X if ( CURWEIGHT < MAXWEIGHT && CURWEIGHT >= OLDMAXWEIGHT) `7B X prt_msg("You feel yourself speed up."); X change_speed( 2.0); X prt_speed(); X prt_str(); X change = FALSE; X `7D X `7D X else if ( d_chance < 32) `7B X prt_msg("You feel healthier."); X CON += 1; X MAXHEALTH = ((CON+level)*8); X prt_con(); X `7D `20 X else if ( d_chance < 40) `7B X prt_msg("E = mc`5E2"); X INT += 1; X prt_int(); X `7D `20 X else if ( d_chance < 48) `7B X prt_msg("You feel light as a feather."); X DEX += 1; X prt_dex(); X `7D X else if ( d_chance < 56) `7B X prt_msg("An air of confusion surrounds you..."); X prt_msg("Everything seems funny all of a sudden."); X flags`5BCONFUSE`5D.valid = TRUE; X flags`5BCONFUSE`5D.moves += 301; X `7D `20 X else if ( d_chance < 64) `7B X prt_msg("You feel immortal!"); X flags`5BIMMUNITY`5D.valid = TRUE; X flags`5BIMMUNITY`5D.moves += 301; X `7D `20 X else if ( d_chance < 72) `7B X prt_msg("Your eyes sting - darkness surrounds you!"); X flags`5BBLIND`5D.valid = TRUE; X flags`5BBLIND`5D.moves += 151; X smg$unpaste_virtual_display(&dsp_main,&pb); X `7D X else `7B X prt_msg("You feel slightly refreshed."); X health += 5; X prt_health(); X `7D X PREWEIGHT = CURWEIGHT; X CURWEIGHT -= ITEM_PROPS`5Bitem_num`5D`5BWEIGHT`5D; X if ( (PREWEIGHT >= MAXWEIGHT) && (CURWEIGHT < MAXWEIGHT)) `7B X if ( change) change_speed( 2.0); X prt_msg("The burden of the pack is lifted."); X prt_speed(); X `7D X prt_wgt(); X`7D /* End check_inven IF */ Xelse prt_msg("You have nothing to drink."); X`7D X X Xcheck_object( testobj, number, direction)`09/* checks and parses object */ Xint number; Xchar testobj, direction; X`7B Xint rnd_num; Xchar dum_msg`5B10`5D; X Xswitch( testobj) `7B X`20 X case PIT:`20 X`09`09 do_move( direction); X`09`09 underchar = PIT; X`09 `09 map`5Bppos.y`5D`5Bppos.x`5D.number = 1; X`09`09 prt_msg("You fell into a pit!"); X`09 if ( random( 23)+1 > DEX)`20 X `09`09 take_damage( 10, "falling into a pit"); X`09`09 else `7B X prt_msg("Your quick reflexes soften the fall."); X`09`09 take_damage( random( 10)+1, "falling into a pit"); X`09 `7D X break; X`09case MINE:`20 X`09`09 if ( random( 20)+1 > DEX) `7B X `09`09 if (number < 2) prt_msg("The mine exploded!"); X`09`09 else prt_msg("The mines exploded!"); X`09`09 explode( ppos.y, ppos.x, MINE, number, NULL); X`09 `09 do_move( direction); X`09`09 underchar = SPACE; X`09`09 break; X`09`09 `7D X`09`09 /* Else continue and pickup below */ X`09case KEY: X`09case HAXE: X`09case AXE: X`09case SWORD: X`09case LSWORD: X`09case ARROW: X`09case ARMOR: X`09case BOW: X`09case HEALTH: X`09case POTION: X`09case ORB: X`09case SCROLL: X`09case CASH: X`09`09do_pickup( testobj, number, direction); X`09`09break; X`09case DOOR: X`09 do_move( direction); X`09 underchar = DOOR; X`09`09break; X`09case STORE: X`09`09do_move( direction); X`09`09underchar = STORE; X`09`09break; X`09case ARENA: X`09`09if ( !can_exit && in_arena) break; X`09`09else if ( can_exit && in_arena) `7B X `09`09 do_move( direction); X`09 underchar = ARENA; X`09`09 do_move( direction); /* push the player through the entrance */ X prt_msg("You feel the relief of freedom."); X`09`09 map`5Bppos.y`5D`5Bppos.x`5D.number = 1; X`09`09 in_arena = FALSE; X`09 `09`7D X`09`09else `7B X`09`09 do_move( direction); X`09`09 underchar = ARENA; X`09`09 do_move( direction); /* push the player through the entrance */ X prt_msg("You boldly stride into the arena."); X`09`09 map`5Bppos.y`5D`5Bppos.x`5D.number = 1; X`09`09 enter_arena(); X`09`09`7D X`09`09break; X`7D /* End of switch */ X`7D X X Xint add_inven( object, item_num, number) /* find nearest open slot & add */ Xint item_num, number; Xchar object; X`7B Xint spot_num; Xint PREWEIGHT; Xchar posess`5B80`5D; X Xif ( (spot_num = check_inven( SPACE)) == FALSE) return( FALSE); Xelse `7B X backpack_struct *bp; X bp = &BACKPACK`5Bspot_num`5D; X X bp->invenchar = object; X strcpy( bp->name, object_names`5Bitem_num`5D); X if ( combinable( item_num)) `7B X bp->quantity = number; X bp->condition = 1; X if ( number > 1) X sprintf(posess,"You have %d %ss (%c)",bp->quantity,bp->name,spot_num+MAG VIC_NUMBER); X else X sprintf(posess,"You have a %s (%c)",bp->name,spot_num+MAGIC_NUMBER); X `7D X else `7B X bp->condition = number; X bp->quantity = 1; X sprintf(posess,"You have a %s (%c)",bp->name,spot_num+MAGIC_NUMBER); X `7D X prt_msg( posess); X PREWEIGHT = CURWEIGHT; X CURWEIGHT += ITEM_PROPS`5Bitem_num`5D`5BWEIGHT`5D * bp->quantity; X if ( CURWEIGHT >= MAXWEIGHT && PREWEIGHT < MAXWEIGHT) `7B X prt_msg("You are moving at half speed due to the excess weight."); X change_speed( 0.5); X `7D X return( TRUE); X`7D X`7D X X X Xdo_pickup( object, number, direction)`09/* picks up an object you walk over V */ Xint number; Xchar object, direction; X`7B Xint item_num, bp_num, PREWEIGHT; Xint cash_flow; Xchar cash_pickup`5B80`5D; Xchar posess`5B80`5D; X Xif ( (item_num = identify( object)) != MAGIC_NUMBER) `7B `09 X if ( (bp_num = check_inven( object)) != FALSE && combinable( item_num)) `7 VB X PREWEIGHT = CURWEIGHT; X CURWEIGHT += ITEM_PROPS`5Bitem_num`5D`5BWEIGHT`5D * number; X if ( CURWEIGHT >= MAXWEIGHT && PREWEIGHT < MAXWEIGHT) `7B X prt_msg("You slow down from the excess weight."); X`09 change_speed( 0.5); X prt_speed(); X `7D X BACKPACK`5Bbp_num`5D.quantity += number;`09`09 X sprintf(posess,"You have %d %ss.",BACKPACK`5Bbp_num`5D.quantity, X `09`09 `09 object_names`5Bitem_num`5D); X prt_msg(posess); X do_move( direction); X prt_wgt(); X return; X `7D X else if ( add_inven( object, item_num, number)) `7B`20 X prt_speed(); X prt_wgt(); X do_move( direction);`20 X return; X `7D X else `7B X prt_msg("Your backpack is full."); X do_move( direction); X underchar = object; X map`5Bppos.y`5D`5Bppos.x`5D.number = number; X return; X `7D X do_move( direction); X return; X`7D X/* End cases, now this has to be "item not found" case */ X/* object must be CASH or KEY (or error) */ Xif ( object == KEY) `7B`09`09 X KEYPOSESS = TRUE; X prt_key_status(); X prt_msg("You found the key!"); X`7D Xelse `7B `09`09`09`09`09/* must be CASH */ X wealth += (cash_flow = random( 50)); X sprintf(cash_pickup,"You pick up %d gold pieces.",cash_flow); X prt_msg(cash_pickup); X prt_wealth(); X`7D Xdo_move( direction); X`7D X X Xenter_arena() X`7B Xchar rival`5B80`5D; X Xmonsters_struct *m; Xrival_num = random( 2*level) + 3; Xm = &monsters`5Brival_num`5D; Xsprintf( rival,"Your rival in a battle to the death is: %s.",mon_names`5Bm-> Vn_num`5D); Xprt_msg( rival); Xm->posy = a_posy; Xm->posx = a_posx; Xm->dead = FALSE; Xm->health = 3*(monsters`5Brival_num`5D.n_num+5); Xmap`5Bm->posy`5D`5Bm->posx`5D.mapchar = m->mon_char; Xmap`5Bm->posy`5D`5Bm->posx`5D.number = m->number; Xprt_char( m->mon_char, a_posy, a_posx); Xin_arena = TRUE; Xcan_exit = FALSE; X`7D X X Xdisplay_store_inven() X`7B Xint i; Xchar item_to_buy`5B40`5D; X$DESCRIPTOR(store_label,"Store Inventory"); X Xsmg$change_virtual_display(&dsp_status,&21,&37); Xsmg$erase_display(&dsp_status); Xsmg$label_border(&dsp_status,&store_label); `09/* use the stat disp. for sto Vre */ Xsmg$paste_virtual_display(&dsp_status,&pb,&2,&43); Xfor (i=1; i< MAXOBJECTS-NUMITEMS; i++) `7B X sprintf(item_to_buy,"%c) %17s %4d gp %4d lb.",i+MAGIC_NUMBER,object_names V`5Bi`5D, X ITEM_PROPS`5Bi`5D`5BCOST`5D,ITEM_PROPS`5 VBi`5D`5BWEIGHT`5D); X prt_in_disp(dsp_status,item_to_buy,i,1); X`7D X`7D X X Xshort get_purchase() X`7B Xint bp_num, quality; Xint PREWEIGHT; Xchar c; Xchar gold_amount`5B80`5D; Xchar purchased`5B80`5D; X$DESCRIPTOR(statlabel,"Character Stats"); X Xprt_msg("`5Bs`5Dell/`5Bp`5Durchase/`5Be`5Dxit"); Xsmg$read_keystroke(&kboard,&c); Xif ( c != 'e' && c != 's' && c != 'p') X if ( get_purchase()) return; Xif ( c == 'e') `7B`20 X smg$erase_display(&dsp_status);`20 X smg$change_virtual_display(&dsp_status,&10,&37); X prt_status(); `20 X smg$label_border(&dsp_status,&statlabel); X smg$paste_virtual_display(&dsp_status,&pb,&2,&43); X return( TRUE); /* means that you are leaving the store */ X`7D Xif ( c == 's') `7B X sell_item(); X sprintf(gold_amount,"You have %d gold remaining.",wealth); X prt_msg(gold_amount); X if ( get_purchase()) return; X`7D Xif ( c == 'p') `7B X sprintf(gold_amount,"You have %d gold remaining.",wealth); X prt_msg(gold_amount); X prt_msg("Purchase which item?"); X smg$read_keystroke(&kboard,&c); X if ( (c -= MAGIC_NUMBER) < 1 `7C`7C (c > 12)) `7B /* 12 items excluding H VANDS */ X prt_msg("Value out of range."); X if ( get_purchase()) return; X `7D X`7D Xif ( (wealth - ITEM_PROPS`5Bc`5D`5BCOST`5D) < 0) `7B X prt_msg("You don't have the cash flow for this."); X if ( get_purchase()) return; X`7D Xif ( (bp_num = check_inven( ITEM_PROPS`5Bc`5D`5BITEMCHAR`5D)) != FALSE &&`2 V0 X combinable( c)) `7B X wealth -= ITEM_PROPS`5Bc`5D`5BCOST`5D; X PREWEIGHT = CURWEIGHT; X CURWEIGHT += ITEM_PROPS`5Bc`5D`5BWEIGHT`5D; X if ( CURWEIGHT >= MAXWEIGHT && PREWEIGHT < MAXWEIGHT) `7B X prt_msg("You are moving very slowly due to the excess weight."); X change_speed( 0.5); X `7D X BACKPACK`5Bbp_num`5D.quantity++;`09`09/* add one to it */ X sprintf(purchased,"You have %d %ss.",BACKPACK`5Bbp_num`5D.quantity, X `09`09 `09 object_names`5Bc`5D); X prt_msg(purchased); X sprintf(gold_amount,"You have %d gold remaining.",wealth); X prt_msg(gold_amount); X`7D X/* new things bought are in perfect condition */ Xelse `7B X if ( combinable( c)) quality = 1; X else quality = 5; X if ( add_inven( ITEM_PROPS`5Bc`5D`5BITEMCHAR`5D, c, quality)) `7B X wealth -= ITEM_PROPS`5Bc`5D`5BCOST`5D; X sprintf(purchased,"%s purchased for %d cash.",object_names`5Bc`5D, X `09`09`09`09`09`09ITEM_PROPS`5Bc`5D`5BCOST`5D); X prt_msg(purchased); X sprintf(gold_amount,"You have %d gold remaining.",wealth); X prt_msg(gold_amount); X `7D X else prt_msg("You have no room in your backpack for this."); X`7D X Xif ( get_purchase()) return; /* endless loop until `5EZ is hit (TRUE) */ X`7D X Xenter_store() X`7B Xdisplay_store_inven(); Xget_purchase(); X`7D X X Xsell_item() X`7B Xint PREWEIGHT, delwealth, quan; Xint flag = 0; Xchar dummychar; Xint schar; Xint sellall = 0; Xchar sell_msg`5B80`5D; X Xwhile( 1) `7B Xschar = 0; Xprt_msg("Sell which item? `5B* for inventory`5D"); Xsmg$read_keystroke(&kboard,&schar); Xschar -= MAGIC_NUMBER; Xif ( schar+MAGIC_NUMBER == '*') `7B prt_inven(); flag = 1; `7D Xelse break; X`7D Xif ( schar < 1 `7C`7C schar > MAXINVEN-1) prt_msg("Value out of range.");` V20 Xelse if ( (dummychar = BACKPACK`5Bschar`5D.invenchar) != SPACE) `7B X`09if ( WORN == schar) WORN = 0; X else if ( WIELD == schar) WIELD = 0; X else if ( ALTWEAP == schar) ALTWEAP = 0; +-+-+-+-+-+-+-+- END OF PART 7 +-+-+-+-+-+-+-+-