-+-+-+-+-+-+-+-+ START OF PART 43 -+-+-+-+-+-+-+-+ X`09`09`09 item = -1; X`09`09`09 `7D X`09`09`09`7D X`09`09 if (item >= 0) X`09`09`09`7B X`09`09`09 /* OK. Wear it. */ X`09`09`09 free_turn_flag = FALSE; X X`09`09`09 /* first remove new item from inventory */ X`09`09`09 tmp_obj = inventory`5Bitem`5D; X`09`09`09 i_ptr = &tmp_obj; X X`09`09`09 wear_high--; X`09`09`09 /* Fix for torches`09 */ X`09`09`09 if (i_ptr->number > 1 X`09`09`09 && i_ptr->subval <= ITEM_SINGLE_STACK_MAX) X`09`09`09 `7B X`09`09`09 i_ptr->number = 1; X`09`09`09 wear_high++; X`09`09`09 `7D X`09`09`09 inven_weight += i_ptr->weight*i_ptr->number; X`09`09`09 inven_destroy(item);`09/* Subtracts weight */ X X`09`09`09 /* second, add old item to inv and remove from X`09`09`09 equipment list, if necessary */ X`09`09`09 i_ptr = &inventory`5Bslot`5D; X`09`09`09 if (i_ptr->tval != TV_NOTHING) X`09`09`09 `7B X`09`09`09 tmp2 = inven_ctr; X`09`09`09 tmp = inven_carry(i_ptr); X`09`09`09 /* if item removed did not stack with anything in X`09`09`09`09 inventory, then increment wear_high */ X`09`09`09 if (inven_ctr != tmp2) X`09`09`09`09wear_high++; X`09`09`09 takeoff(slot, tmp); X`09`09`09 `7D X X`09`09`09 /* third, wear new item */ X`09`09`09 *i_ptr = tmp_obj; X`09`09`09 equip_ctr++; X`09`09`09 py_bonuses(i_ptr, 1); X`09`09`09 if (slot == INVEN_WIELD) X`09`09`09 string = "You are wielding"; X`09`09`09 else if (slot == INVEN_LIGHT) X`09`09`09 string = "Your light source is"; X`09`09`09 else X`09`09`09 string = "You are wearing"; X`09`09`09 objdes(prt2, i_ptr, TRUE); X`09`09`09 /* Get the right equipment letter. */ X`09`09`09 tmp = INVEN_WIELD; X`09`09`09 item = 0; X`09`09`09 while (tmp != slot) X`09`09`09 if (inventory`5Btmp++`5D.tval != TV_NOTHING) X`09`09`09 item++; X X`09`09`09 (void) sprintf(prt1, "%s %s (%c)", string, prt2, X`09`09`09`09`09 'a'+item); X`09`09`09 msg_print(prt1); X`09`09`09 /* this is a new weapon, so clear the heavy flag */ X`09`09`09 if (slot == INVEN_WIELD) X`09`09`09 weapon_heavy = FALSE; X`09`09`09 check_strength(); X#ifdef ATARIST_MWC X`09`09`09 if (i_ptr->flags & (holder = TR_CURSED)) X#else X`09`09`09 if (i_ptr->flags & TR_CURSED) X#endif X`09`09`09 `7B X`09`09`09 msg_print("Oops! It feels deathly cold!"); X`09`09`09 add_inscribe(i_ptr, ID_DAMD); X`09`09`09 /* To force a cost of 0, even if unidentified. */ X`09`09`09 i_ptr->cost = -1; X`09`09`09 `7D X`09`09`09`7D X`09`09 `7D X`09`09 else /* command == 'd' */ X`09`09 `7B X`09`09 if (inventory`5Bitem`5D.number > 1) X`09`09`09`7B X`09`09`09 objdes(prt1, &inventory`5Bitem`5D, TRUE); X`09`09`09 prt1`5Bstrlen(prt1)-1`5D = '?'; X`09`09`09 (void) sprintf(prt2, "Drop all %s `5By/n`5D", prt1); X`09`09`09 prt1`5Bstrlen(prt1)-1`5D = '.'; X`09`09`09 prt(prt2, 0, 0); X`09`09`09 query = inkey(); X`09`09`09 if (query != 'y' && query != 'n') X`09`09`09 `7B X`09`09`09 if (query != ESCAPE) X`09`09`09`09bell(); X`09`09`09 erase_line(MSG_LINE, 0); X`09`09`09 item = -1; X`09`09`09 `7D X`09`09`09`7D X`09`09 else if (isupper((int)which) && !verify(prompt, item)) X`09`09`09item = -1; X`09`09 else X`09`09`09query = 'y'; X`09`09 if (item >= 0) X`09`09`09`7B X`09`09`09 free_turn_flag = FALSE; /* Player turn */ X`09`09`09 inven_drop(item, query == 'y'); X`09`09`09 check_strength(); X`09`09`09`7D X`09`09 selecting = FALSE; X`09`09 /* As a safety measure, set the player's inven weight X`09`09`09 to 0, when the last object is dropped. */ X`09`09 if (inven_ctr == 0 && equip_ctr == 0) X`09`09`09inven_weight = 0; X`09`09 `7D X`09`09 if (free_turn_flag == FALSE && scr_state == BLANK_SCR) X`09`09 selecting = FALSE; X`09`09`7D X`09 `7D X`09`7D X if (which == ESCAPE `7C`7C scr_state == BLANK_SCR) X`09command = ESCAPE; X else if (!free_turn_flag) X`09`7B X`09 /* Save state for recovery if they want to call us again next turn.*/ X`09 if (selecting) X`09 doing_inven = command; X`09 else X`09 doing_inven = ' ';`09/* A dummy command to recover screen. */ X`09 /* flush last message before clearing screen_change and exiting */ X`09 msg_print(CNIL); X`09 screen_change = FALSE;/* This lets us know if the world changes */ X`09 command = ESCAPE; X`09`7D X else X`09`7B X`09 /* Put an appropriate header. */ X`09 if (scr_state == INVEN_SCR) X`09 `7B X`09 if (! show_weight_flag `7C`7C inven_ctr == 0) X`09`09(void) sprintf(prt1, X`09`09 "You are carrying %d.%d pounds. In your pack there is %s", X`09`09`09 inven_weight / 10, inven_weight % 10, X`09`09`09 (inven_ctr == 0 ? "nothing." : "-")); X`09 else X`09`09(void) sprintf (prt1, X`09"You are carrying %d.%d pounds. Your capacity is %d.%d pounds. %s", X`09`09`09`09inven_weight / 10, inven_weight % 10, X`09`09`09`09weight_limit () / 10, weight_limit () % 10, X`09`09`09`09"In your pack is -"); X`09 prt(prt1, 0, 0); X`09 `7D X`09 else if (scr_state == WEAR_SCR) X`09 `7B X`09 if (wear_high < wear_low) X`09`09prt("You have nothing you could wield.", 0, 0); X`09 else X`09`09prt("You could wield -", 0, 0); X`09 `7D X`09 else if (scr_state == EQUIP_SCR) X`09 `7B X`09 if (equip_ctr == 0) X`09`09prt("You are not using anything.", 0, 0); X`09 else X`09`09prt("You are using -", 0, 0); X`09 `7D X`09 else X`09 prt("Allowed commands:", 0, 0); X`09 erase_line(scr_base, scr_left); X`09 put_buffer("e/i/t/w/x/d/?/ESC:", scr_base, 60); X`09 command = inkey(); X`09 erase_line(scr_base, scr_left); X`09`7D X `7D X while (command != ESCAPE); X if (scr_state != BLANK_SCR) X restore_screen(); X calc_bonuses(); X`7D X X X/* Get the ID of an item and return the CTR value of it`09-RAK-`09*/ Xint get_item(com_val, pmt, i, j, mask, message) Xint *com_val; Xchar *pmt; Xint i, j; Xchar *mask; Xchar *message; X`7B X vtype out_val; X char which; X register int test_flag, item; X int full, i_scr, redraw; X X item = FALSE; X redraw = FALSE; X *com_val = 0; X i_scr = 1; X if (j > INVEN_WIELD) X `7B X full = TRUE; X if (inven_ctr == 0) X`09`7B X`09 i_scr = 0; X`09 j = equip_ctr - 1; X`09`7D X else X`09j = inven_ctr - 1; X `7D X else X full = FALSE; X X if (inven_ctr > 0 `7C`7C (full && equip_ctr > 0)) X `7B X do X`09`7B X`09 if (redraw) X`09 `7B X`09 if (i_scr > 0) X`09`09(void) show_inven (i, j, FALSE, 80, mask); X`09 else X`09`09(void) show_equip (FALSE, 80); X`09 `7D X`09 if (full) X`09 (void) sprintf(out_val, X`09`09`09 "(%s: %c-%c,%s / for %s, or ESC) %s", X`09`09`09 (i_scr > 0 ? "Inven" : "Equip"), i+'a', j+'a', X`09`09`09 (redraw ? "" : " * to see,"), X`09`09`09 (i_scr > 0 ? "Equip" : "Inven"), pmt); X`09 else X`09 (void) sprintf(out_val, X`09`09`09 "(Items %c-%c,%s ESC to exit) %s", i+'a', j+'a', X`09`09`09 (redraw ? "" : " * for inventory list,"), pmt); X`09 test_flag = FALSE; X`09 prt(out_val, 0, 0); X`09 do X`09 `7B X`09 which = inkey(); X`09 switch(which) X`09`09`7B X`09`09case ESCAPE: X`09`09 test_flag = TRUE; X`09`09 free_turn_flag = TRUE; X`09`09 i_scr = -1; X`09`09 break; X`09`09case '/': X`09`09 if (full) X`09`09 `7B X`09`09 if (i_scr > 0) X`09`09`09`7B X`09`09`09 if (equip_ctr == 0) X`09`09`09 `7B X`09`09`09 prt("But you're not using anything -more-",0,0); X`09`09`09 (void) inkey(); X`09`09`09 `7D X`09`09`09 else X`09`09`09 `7B X`09`09`09 i_scr = 0; X`09`09`09 test_flag = TRUE; X`09`09`09 if (redraw) X`09`09`09`09`7B X`09`09`09`09 j = equip_ctr; X`09`09`09`09 while (j < inven_ctr) X`09`09`09`09 `7B X`09`09`09`09 j++; X`09`09`09`09 erase_line(j, 0); X`09`09`09`09 `7D X`09`09`09`09`7D X`09`09`09 j = equip_ctr - 1; X`09`09`09 `7D X`09`09`09 prt(out_val, 0, 0); X`09`09`09`7D X`09`09 else X`09`09`09`7B X`09`09`09 if (inven_ctr == 0) X`09`09`09 `7B X`09`09`09 prt("But you're not carrying anything -more-",0,0); X`09`09`09 (void) inkey(); X`09`09`09 `7D X`09`09`09 else X`09`09`09 `7B X`09`09`09 i_scr = 1; X`09`09`09 test_flag = TRUE; X`09`09`09 if (redraw) X`09`09`09`09`7B X`09`09`09`09 j = inven_ctr; X`09`09`09`09 while (j < equip_ctr) X`09`09`09`09 `7B X`09`09`09`09 j++; X`09`09`09`09 erase_line (j, 0); X`09`09`09`09 `7D X`09`09`09`09`7D X`09`09`09 j = inven_ctr - 1; X`09`09`09 `7D X`09`09`09`7D X`09`09 `7D X`09`09 break; X`09`09case '*': X`09`09 if (!redraw) X`09`09 `7B X`09`09 test_flag = TRUE; X`09`09 save_screen(); X`09`09 redraw = TRUE; X`09`09 `7D X`09`09 break; X`09`09default: X`09`09 if (isupper((int)which)) X`09`09 *com_val = which - 'A'; X`09`09 else X`09`09 *com_val = which - 'a'; X`09`09 if ((*com_val >= i) && (*com_val <= j) X`09`09 && (mask == CNIL `7C`7C mask`5B*com_val`5D)) X`09`09 `7B X`09`09 if (i_scr == 0) X`09`09`09`7B X`09`09`09 i = 21; X`09`09`09 j = *com_val; X`09`09`09 do X`09`09`09 `7B X`09`09`09 while (inventory`5B++i`5D.tval == TV_NOTHING); X`09`09`09 j--; X`09`09`09 `7D X`09`09`09 while (j >= 0); X`09`09`09 *com_val = i; X`09`09`09`7D X`09`09 if (isupper((int)which) && !verify("Try", *com_val)) X`09`09`09`7B X`09`09`09 test_flag = TRUE; X`09`09`09 free_turn_flag = TRUE; X`09`09`09 i_scr = -1; X`09`09`09 break; X`09`09`09`7D X`09`09 test_flag = TRUE; X`09`09 item = TRUE; X`09`09 i_scr = -1; X`09`09 `7D X`09`09 else if (message) X`09`09 `7B X`09`09 msg_print (message); X`09`09 /* Set test_flag to force redraw of the question. */ X`09`09 test_flag = TRUE; X`09`09 `7D X`09`09 else X`09`09 bell(); X`09`09 break; X`09`09`7D X`09 `7D X`09 while (!test_flag); X`09`7D X while (i_scr >= 0); X if (redraw) X`09restore_screen(); X erase_line(MSG_LINE, 0); X `7D X else X prt("You are not carrying anything.", 0, 0); X return(item); X`7D X X/* I may have written the town level code, but I'm not exactly`09 */ X/* proud of it.`09 Adding the stores required some real slucky`09 */ X/* hooks which I have not had time to re-think.`09`09 -RAK-`09 */ X X/* Returns true if player has no light`09`09`09-RAK-`09*/ Xint no_light() X`7B X register cave_type *c_ptr; X X c_ptr = &cave`5Bchar_row`5D`5Bchar_col`5D; X if (!c_ptr->tl && !c_ptr->pl) X return TRUE; X return FALSE; X`7D X X X/* map rogue_like direction commands into numbers */ Xstatic char map_roguedir(comval) Xregister char comval; X`7B X switch(comval) X `7B X case 'h': X comval = '4'; X break; X case 'y': X comval = '7'; X break; X case 'k': X comval = '8'; X break; X case 'u': X comval = '9'; X break; X case 'l': X comval = '6'; X break; X case 'n': X comval = '3'; X break; X case 'j': X comval = '2'; X break; X case 'b': X comval = '1'; X break; X case '.': X comval = '5'; X break; X `7D X return(comval); X`7D X X X/* Prompts for a direction`09`09`09`09-RAK-`09*/ X/* Direction memory added, for repeated commands. -CJS */ Xint get_dir(prompt, dir) Xchar *prompt; Xint *dir; X`7B X char command; X int save; X static char prev_dir;`09`09/* Direction memory. -CJS- */ X X if (default_dir)`09/* used in counted commands. -CJS- */ X `7B X *dir = prev_dir; X return TRUE; X `7D X if (prompt == CNIL) X prompt = "Which direction?"; X for (;;) X `7B X save = command_count;`09/* Don't end a counted command. -CJS- */ X#ifdef MAC X if (!get_comdir(prompt, &command)) X#else X if (!get_com(prompt, &command)) X#endif X`09`7B X`09 free_turn_flag = TRUE; X`09 return FALSE; X`09`7D X command_count = save; X if (rogue_like_commands) X`09command = map_roguedir(command); X if (command >= '1' && command <= '9' && command != '5') X`09`7B X`09 prev_dir = command - '0'; X`09 *dir = prev_dir; X`09 return TRUE; X`09`7D X bell(); X `7D X`7D X X X X/* Similar to get_dir, except that no memory exists, and it is`09`09-CJS- X allowed to enter the null direction. */ Xint get_alldir(prompt, dir) Xchar *prompt; Xint *dir; X`7B X char command; X X for(;;) X `7B X#ifdef MAC X if (!get_comdir(prompt, &command)) X#else X if (!get_com(prompt, &command)) X#endif X`09`7B X`09 free_turn_flag = TRUE; X`09 return FALSE; X`09`7D X if (rogue_like_commands) X`09command = map_roguedir(command); X if (command >= '1' && command <= '9') X`09`7B X`09 *dir = command - '0'; X`09 return TRUE; X`09`7D X bell(); X `7D X`7D X X X/* Moves creature record from one space to another`09-RAK-`09*/ Xvoid move_rec(y1, x1, y2, x2) Xregister int y1, x1, y2, x2; X`7B X int tmp; X X /* this always works correctly, even if y1==y2 and x1==x2 */ X tmp = cave`5By1`5D`5Bx1`5D.cptr; X cave`5By1`5D`5Bx1`5D.cptr = 0; X cave`5By2`5D`5Bx2`5D.cptr = tmp; X`7D X X X/* Room is lit, make it appear`09`09`09`09-RAK-`09*/ Xvoid light_room(y, x) Xint y, x; X`7B X register int i, j, start_col, end_col; X int tmp1, tmp2, start_row, end_row; X register cave_type *c_ptr; X int tval; X X tmp1 = (SCREEN_HEIGHT/2); X tmp2 = (SCREEN_WIDTH /2); X start_row = (y/tmp1)*tmp1; X start_col = (x/tmp2)*tmp2; X end_row = start_row + tmp1 - 1; X end_col = start_col + tmp2 - 1; X for (i = start_row; i <= end_row; i++) X for (j = start_col; j <= end_col; j++) X `7B X`09c_ptr = &cave`5Bi`5D`5Bj`5D; X`09if (c_ptr->lr && ! c_ptr->pl) X`09 `7B X`09 c_ptr->pl = TRUE; X`09 if (c_ptr->fval == DARK_FLOOR) X`09 c_ptr->fval = LIGHT_FLOOR; X`09 if (! c_ptr->fm && c_ptr->tptr != 0) X`09 `7B X`09`09tval = t_list`5Bc_ptr->tptr`5D.tval; X`09`09if (tval >= TV_MIN_VISIBLE && tval <= TV_MAX_VISIBLE) X`09`09 c_ptr->fm = TRUE; X`09 `7D X`09 print(loc_symbol(i, j), i, j); X`09 `7D X `7D X`7D X X X/* Lights up given location`09`09`09`09-RAK-`09*/ Xvoid lite_spot(y, x) Xregister int y, x; X`7B X if (panel_contains(y, x)) +-+-+-+-+-+-+-+- END OF PART 43 +-+-+-+-+-+-+-+-