X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fstore.c;h=7506c03ca70085b3ae70e0ad27308469b7e87998;hb=89bd2eeb45f0c5f519c9cfb11048b6901540b896;hp=fd492cbc0cc68087e3fe483e9ee692ea819b7f32;hpb=f20dd18f65b23597ee27e3d91245c5763f1d99c2;p=hengband%2Fhengband.git diff --git a/src/store.c b/src/store.c index fd492cbc0..7506c03ca 100644 --- a/src/store.c +++ b/src/store.c @@ -1,15 +1,15 @@ /* File: store.c */ -/* Purpose: Store commands */ - /* - * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke + * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke * - * This software may be copied and distributed for educational, research, and - * not for profit purposes provided that this copyright and statement are - * included in all such copies. + * This software may be copied and distributed for educational, research, + * and not for profit purposes provided that this copyright and statement + * are included in all such copies. Other copyrights may also apply. */ +/* Purpose: Store commands */ + #include "angband.h" @@ -20,6 +20,8 @@ static int store_top = 0; static store_type *st_ptr = NULL; static owner_type *ot_ptr = NULL; #endif +static s16b old_town_num = 0; +static s16b inner_town_num = 0; #define RUMOR_CHANCE 8 #define MAX_COMMENT_1 6 @@ -307,15 +309,15 @@ static void say_comment_1(void) char rumour[1024]; #ifdef JP - /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤­¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */ - if ( cur_store_num == STORE_BLACK ) { - msg_print(comment_1_B[rand_int(MAX_COMMENT_1)]); - } - else{ - msg_print(comment_1[rand_int(MAX_COMMENT_1)]); - } + /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤­¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */ + if ( cur_store_num == STORE_BLACK ) { + msg_print(comment_1_B[randint0(MAX_COMMENT_1)]); + } + else{ + msg_print(comment_1[randint0(MAX_COMMENT_1)]); + } #else - msg_print(comment_1[rand_int(MAX_COMMENT_1)]); + msg_print(comment_1[randint0(MAX_COMMENT_1)]); #endif @@ -353,7 +355,7 @@ static void say_comment_2(s32b value, int annoyed) if (annoyed > 0) { /* Formatted message */ - msg_format(comment_2a[rand_int(MAX_COMMENT_2A)], tmp_val); + msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val); } /* Normal offer */ @@ -363,13 +365,13 @@ static void say_comment_2(s32b value, int annoyed) #ifdef JP /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */ if ( cur_store_num == STORE_BLACK ){ - msg_format(comment_2b_B[rand_int(MAX_COMMENT_2B)], tmp_val); + msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val); } else{ - msg_format(comment_2b[rand_int(MAX_COMMENT_2B)], tmp_val); + msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val); } #else - msg_format(comment_2b[rand_int(MAX_COMMENT_2B)], tmp_val); + msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val); #endif } @@ -390,7 +392,7 @@ static void say_comment_3(s32b value, int annoyed) if (annoyed > 0) { /* Formatted message */ - msg_format(comment_3a[rand_int(MAX_COMMENT_3A)], tmp_val); + msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val); } /* Normal offer */ @@ -400,13 +402,13 @@ static void say_comment_3(s32b value, int annoyed) #ifdef JP /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */ if ( cur_store_num == STORE_BLACK ){ - msg_format(comment_3b_B[rand_int(MAX_COMMENT_3B)], tmp_val); + msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val); } else{ - msg_format(comment_3b[rand_int(MAX_COMMENT_3B)], tmp_val); + msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val); } #else - msg_format(comment_3b[rand_int(MAX_COMMENT_3B)], tmp_val); + msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val); #endif } @@ -419,18 +421,18 @@ static void say_comment_3(s32b value, int annoyed) static void say_comment_4(void) { #ifdef JP - /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */ - if ( cur_store_num == STORE_BLACK ){ - msg_print(comment_4a_B[rand_int(MAX_COMMENT_4A)]); - msg_print(comment_4b_B[rand_int(MAX_COMMENT_4B)]); - } - else{ - msg_print(comment_4a[rand_int(MAX_COMMENT_4A)]); - msg_print(comment_4b[rand_int(MAX_COMMENT_4B)]); - } + /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */ + if ( cur_store_num == STORE_BLACK ){ + msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]); + msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]); + } + else{ + msg_print(comment_4a[randint0(MAX_COMMENT_4A)]); + msg_print(comment_4b[randint0(MAX_COMMENT_4B)]); + } #else - msg_print(comment_4a[rand_int(MAX_COMMENT_4A)]); - msg_print(comment_4b[rand_int(MAX_COMMENT_4B)]); + msg_print(comment_4a[randint0(MAX_COMMENT_4A)]); + msg_print(comment_4b[randint0(MAX_COMMENT_4B)]); #endif } @@ -442,15 +444,15 @@ static void say_comment_4(void) static void say_comment_5(void) { #ifdef JP - /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */ - if ( cur_store_num == STORE_BLACK ){ - msg_print(comment_5_B[rand_int(MAX_COMMENT_5)]); - } - else{ - msg_print(comment_5[rand_int(MAX_COMMENT_5)]); - } + /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */ + if ( cur_store_num == STORE_BLACK ){ + msg_print(comment_5_B[randint0(MAX_COMMENT_5)]); + } + else{ + msg_print(comment_5[randint0(MAX_COMMENT_5)]); + } #else - msg_print(comment_5[rand_int(MAX_COMMENT_5)]); + msg_print(comment_5[randint0(MAX_COMMENT_5)]); #endif } @@ -461,7 +463,7 @@ static void say_comment_5(void) */ static void say_comment_6(void) { - msg_print(comment_6[rand_int(MAX_COMMENT_6)]); + msg_print(comment_6[randint0(MAX_COMMENT_6)]); } @@ -554,7 +556,7 @@ static void purchase_analyze(s32b price, s32b value, s32b guess) if ((value <= 0) && (price > value)) { /* Comment */ - msg_print(comment_7a[rand_int(MAX_COMMENT_7A)]); + msg_print(comment_7a[randint0(MAX_COMMENT_7A)]); chg_virtue(V_HONOUR, -1); chg_virtue(V_JUSTICE, -1); @@ -567,7 +569,7 @@ static void purchase_analyze(s32b price, s32b value, s32b guess) else if ((value < guess) && (price > value)) { /* Comment */ - msg_print(comment_7b[rand_int(MAX_COMMENT_7B)]); + msg_print(comment_7b[randint0(MAX_COMMENT_7B)]); chg_virtue(V_JUSTICE, -1); if (one_in_(4)) @@ -581,7 +583,7 @@ static void purchase_analyze(s32b price, s32b value, s32b guess) else if ((value > guess) && (value < (4 * guess)) && (price < value)) { /* Comment */ - msg_print(comment_7c[rand_int(MAX_COMMENT_7C)]); + msg_print(comment_7c[randint0(MAX_COMMENT_7C)]); if (one_in_(4)) chg_virtue(V_HONOUR, -1); @@ -596,7 +598,7 @@ static void purchase_analyze(s32b price, s32b value, s32b guess) else if ((value > guess) && (price < value)) { /* Comment */ - msg_print(comment_7d[rand_int(MAX_COMMENT_7D)]); + msg_print(comment_7d[randint0(MAX_COMMENT_7D)]); if (one_in_(2)) chg_virtue(V_HONOUR, -1); @@ -934,6 +936,10 @@ static s32b price_item(object_type *o_ptr, int greed, bool flip) /* Mega-Hack -- Black market sucks */ if (cur_store_num == STORE_BLACK) price = price / 2; + + /* Compute the final price (with rounding) */ + /* Hack -- prevent underflow */ + price = (price * adjust + 50L) / 100L; } /* Shop is selling */ @@ -948,10 +954,11 @@ static s32b price_item(object_type *o_ptr, int greed, bool flip) /* Mega-Hack -- Black market sucks */ if (cur_store_num == STORE_BLACK) price = price * 2; - } - /* Compute the final price (with rounding) */ - price = (price * adjust + 50L) / 100L; + /* Compute the final price (with rounding) */ + /* Hack -- prevent overflow */ + price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL); + } /* Note -- Never become "free" */ if (price <= 0L) return (1L); @@ -983,6 +990,7 @@ static void mass_produce(object_type *o_ptr) { if (cost <= 5L) size += damroll(3, 5); if (cost <= 20L) size += damroll(3, 5); + if (cost <= 50L) size += damroll(2, 2); break; } @@ -992,6 +1000,7 @@ static void mass_produce(object_type *o_ptr) if (cost <= 60L) size += damroll(3, 5); if (cost <= 240L) size += damroll(1, 5); if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5); + if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4); break; } @@ -1004,6 +1013,7 @@ static void mass_produce(object_type *o_ptr) case TV_ARCANE_BOOK: case TV_ENCHANT_BOOK: case TV_DAEMON_BOOK: + case TV_CRUSADE_BOOK: case TV_MUSIC_BOOK: case TV_HISSATSU_BOOK: { @@ -1136,6 +1146,8 @@ msg_print(" */ static bool store_object_similar(object_type *o_ptr, object_type *j_ptr) { + int i; + /* Hack -- Identical items cannot be stacked */ if (o_ptr == j_ptr) return (0); @@ -1160,10 +1172,8 @@ static bool store_object_similar(object_type *o_ptr, object_type *j_ptr) if (o_ptr->art_name || j_ptr->art_name) return (0); /* Hack -- Identical art_flags! */ - if ((o_ptr->art_flags1 != j_ptr->art_flags1) || - (o_ptr->art_flags2 != j_ptr->art_flags2) || - (o_ptr->art_flags3 != j_ptr->art_flags3)) - return (0); + for (i = 0; i < TR_FLAG_SIZE; i++) + if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0); /* Hack -- Never stack "powerful" items */ if (o_ptr->xtra1 || j_ptr->xtra1) return (0); @@ -1194,21 +1204,24 @@ static bool store_object_similar(object_type *o_ptr, object_type *j_ptr) */ static void store_object_absorb(object_type *o_ptr, object_type *j_ptr) { + int max_num = (o_ptr->tval == TV_ROD) ? + MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99; int total = o_ptr->number + j_ptr->number; + int diff = (total > max_num) ? total - max_num : 0; /* Combine quantity, lose excess items */ - o_ptr->number = (total > 99) ? 99 : total; + o_ptr->number = (total > max_num) ? max_num : total; /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */ if (o_ptr->tval == TV_ROD) { - o_ptr->pval += j_ptr->pval; + o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number; } /* Hack -- if wands are stacking, combine the charges. -LM- */ if (o_ptr->tval == TV_WAND) { - o_ptr->pval += j_ptr->pval; + o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number; } } @@ -1217,28 +1230,17 @@ static void store_object_absorb(object_type *o_ptr, object_type *j_ptr) * Check to see if the shop will be carrying too many objects -RAK- * Note that the shop, just like a player, will not accept things * it cannot hold. Before, one could "nuke" potions this way. + * + * Return value is now int: + * 0 : No space + * -1 : Can be combined to existing slot. + * 1 : Cannot be combined but there are empty spaces. */ -static bool store_check_num(object_type *o_ptr) +static int store_check_num(object_type *o_ptr) { int i; object_type *j_ptr; - /* Free space is always usable */ - /* - * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È - * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë - */ - if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) { - if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) { - return TRUE; - } - } - else{ - if (st_ptr->stock_num < st_ptr->stock_size) { - return TRUE; - } - } - /* The "home" acts like the player */ if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) { @@ -1249,7 +1251,7 @@ static bool store_check_num(object_type *o_ptr) j_ptr = &st_ptr->stock[i]; /* Can the new object be combined with the old one? */ - if (object_similar(j_ptr, o_ptr)) return (TRUE); + if (object_similar(j_ptr, o_ptr)) return -1; } } @@ -1263,20 +1265,36 @@ static bool store_check_num(object_type *o_ptr) j_ptr = &st_ptr->stock[i]; /* Can the new object be combined with the old one? */ - if (store_object_similar(j_ptr, o_ptr)) return (TRUE); + if (store_object_similar(j_ptr, o_ptr)) return -1; + } + } + + /* Free space is always usable */ + /* + * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È + * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë + */ + if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) { + if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) { + return 1; + } + } + else{ + if (st_ptr->stock_num < st_ptr->stock_size) { + return 1; } } /* But there was no room at the inn... */ - return (FALSE); + return 0; } static bool is_blessed(object_type *o_ptr) { - u32b f1, f2, f3; - object_flags(o_ptr, &f1, &f2, &f3); - if (f3 & TR3_BLESSED) return (TRUE); + u32b flgs[TR_FLAG_SIZE]; + object_flags(o_ptr, flgs); + if (have_flag(flgs, TR_BLESSED)) return (TRUE); else return (FALSE); } @@ -1301,6 +1319,9 @@ static bool store_will_buy(object_type *o_ptr) /* Analyze the type */ switch (o_ptr->tval) { + case TV_POTION: + if (o_ptr->sval != SV_POTION_WATER) return FALSE; + case TV_WHISTLE: case TV_FOOD: case TV_LITE: @@ -1378,6 +1399,7 @@ static bool store_will_buy(object_type *o_ptr) switch (o_ptr->tval) { case TV_LIFE_BOOK: + case TV_CRUSADE_BOOK: case TV_SCROLL: case TV_POTION: case TV_HAFTED: @@ -1477,6 +1499,7 @@ static bool store_will_buy(object_type *o_ptr) case TV_ARCANE_BOOK: case TV_ENCHANT_BOOK: case TV_DAEMON_BOOK: + case TV_CRUSADE_BOOK: case TV_MUSIC_BOOK: break; default: @@ -1824,16 +1847,16 @@ static void store_delete(void) int what, num; /* Pick a random slot */ - what = rand_int(st_ptr->stock_num); + what = randint0(st_ptr->stock_num); /* Determine how many items are here */ num = st_ptr->stock[what].number; /* Hack -- sometimes, only destroy half the items */ - if (rand_int(100) < 50) num = (num + 1) / 2; + if (randint0(100) < 50) num = (num + 1) / 2; /* Hack -- sometimes, only destroy a single item */ - if (rand_int(100) < 50) num = 1; + if (randint0(100) < 50) num = 1; /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */ if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND)) @@ -1877,7 +1900,7 @@ static void store_create(void) if (cur_store_num == STORE_BLACK) { /* Pick a level for object/magic */ - level = 25 + rand_int(25); + level = 25 + randint0(25); /* Random item (usually of given level) */ i = get_obj_num(level); @@ -1890,7 +1913,7 @@ static void store_create(void) else { /* Hack -- Pick an item to sell */ - i = st_ptr->table[rand_int(st_ptr->table_num)]; + i = st_ptr->table[randint0(st_ptr->table_num)]; /* Hack -- fake level for apply_magic() */ level = rand_range(1, STORE_OBJ_LEVEL); @@ -1904,7 +1927,7 @@ static void store_create(void) object_prep(q_ptr, i); /* Apply some "low-level" magic (no artifacts) */ - apply_magic(q_ptr, level, FALSE, FALSE, FALSE, FALSE); + apply_magic(q_ptr, level, AM_NO_FIXED_ART); /* Require valid object */ if (!store_will_buy(q_ptr)) continue; @@ -2021,7 +2044,7 @@ static void updatebargain(s32b price, s32b minprice, int num) */ static void display_entry(int pos) { - int i; + int i, cur_col; object_type *o_ptr; s32b x; @@ -2041,6 +2064,7 @@ static void display_entry(int pos) (void)sprintf(out_val, "%c) ", I2A(i)); prt(out_val, i+6, 0); + cur_col = 3; if (show_item_graph) { byte a = object_attr(o_ptr); @@ -2051,7 +2075,14 @@ static void display_entry(int pos) a |= 0x40; #endif - Term_draw(3, i + 6, a, c); + Term_draw(cur_col, i + 6, a, c); + if (use_bigtile) + { + cur_col++; + if (a & 0x80) + Term_draw(cur_col, i + 6, 255, -1); + } + cur_col += 2; } /* Describe an item in the home */ @@ -2065,7 +2096,7 @@ static void display_entry(int pos) /* Describe the object */ object_desc(o_name, o_ptr, TRUE, 3); o_name[maxwid] = '\0'; - c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, show_item_graph ? 5 : 3); + c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col); /* Show weights */ if (show_weights) @@ -2073,8 +2104,8 @@ static void display_entry(int pos) /* Only show the weight of an individual item */ int wgt = o_ptr->weight; #ifdef JP - sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) ); - put_str(out_val, i+6, 67); + sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) ); + put_str(out_val, i+6, 67); #else (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10); put_str(out_val, i+6, 68); @@ -2095,7 +2126,7 @@ static void display_entry(int pos) /* Describe the object (fully) */ object_desc_store(o_name, o_ptr, TRUE, 3); o_name[maxwid] = '\0'; - c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, show_item_graph ? 5 : 3); + c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col); /* Show weights */ if (show_weights) @@ -2103,8 +2134,8 @@ static void display_entry(int pos) /* Only show the weight of an individual item */ int wgt = o_ptr->weight; #ifdef JP - sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) ); - put_str(out_val, i+6, 60); + sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) ); + put_str(out_val, i+6, 60); #else (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10); put_str(out_val, i+6, 61); @@ -2197,10 +2228,11 @@ static void display_inventory(void) /* Indicate the "current page" */ + /* Trailing spaces are to display (Page xx) and (Page x) */ #ifdef JP - put_str(format("(%d¥Ú¡¼¥¸)", store_top/12 + 1), 5, 20); + put_str(format("(%d¥Ú¡¼¥¸) ", store_top/12 + 1), 5, 20); #else - put_str(format("(Page %d)", store_top/12 + 1), 5, 20); + put_str(format("(Page %d) ", store_top/12 + 1), 5, 20); #endif } @@ -2384,8 +2416,8 @@ static int get_stock(int *com_val, cptr pmt, int i, int j) /* Build the prompt */ #ifdef JP - (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s", - (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"), + (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s", + (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"), I2A(i), I2A(j), pmt); #else (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s", @@ -2452,7 +2484,7 @@ static int increase_insults(void) st_ptr->bad_buy = 0; /* Open tomorrow */ - st_ptr->store_open = turn + 25000 + randint(25000); + st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8); /* Closed */ return (TRUE); @@ -2642,8 +2674,8 @@ static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final) * Return TRUE if offer is NOT okay */ static bool receive_offer(cptr pmt, s32b *poffer, - s32b last_offer, int factor, - s32b price, int final) + s32b last_offer, int factor, + s32b price, int final) { /* Haggle till done */ while (TRUE) @@ -2783,7 +2815,7 @@ static bool purchase_haggle(object_type *o_ptr, s32b *price) cancel = receive_offer("What do you offer? ", #endif - &offer, last_offer, 1, cur_ask, final); + &offer, last_offer, 1, cur_ask, final); if (cancel) { @@ -2920,6 +2952,12 @@ static bool sell_haggle(object_type *o_ptr, s32b *price) /* No need to haggle */ if (noneed || !manual_haggle || (final_ask >= purse)) { + /* Apply Sales Tax (if needed) */ + if (!manual_haggle && !noneed) + { + final_ask -= final_ask / 10; + } + /* No reason to haggle */ if (final_ask >= purse) { @@ -2960,9 +2998,6 @@ static bool sell_haggle(object_type *o_ptr, s32b *price) #endif msg_print(NULL); - - /* Apply Sales Tax */ - final_ask -= final_ask / 10; } /* Final price */ @@ -3096,7 +3131,7 @@ static bool sell_haggle(object_type *o_ptr, s32b *price) prt("", 1, 0); (void)sprintf(out_val, #ifdef JP - "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer); + "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer); #else "Your last bid %ld", (long)last_offer); #endif @@ -3177,18 +3212,18 @@ static void store_purchase(void) /* Prompt */ #ifdef JP - /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */ - switch( cur_store_num ) { - case 7: - sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? "); - break; - case 6: - sprintf(out_val, "¤É¤ì? "); - break; - default: - sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? "); - break; - } + /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */ + switch( cur_store_num ) { + case 7: + sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? "); + break; + case 6: + sprintf(out_val, "¤É¤ì? "); + break; + default: + sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? "); + break; + } #else if (cur_store_num == STORE_HOME) { @@ -3336,6 +3371,8 @@ msg_format("%s(%c) /* Player can afford it */ if (p_ptr->au >= price) { + int idx; + /* Say "okay" */ say_comment_1(); @@ -3400,6 +3437,9 @@ msg_format("%s o_name, index_to_label(item_new)); #endif + /* Auto-inscription */ + idx = is_autopick(&inventory[item_new]); + auto_inscribe_item(item_new, idx); /* Now, reduce the original stack's pval. */ if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND)) @@ -3855,11 +3895,26 @@ msg_format("%s { char o2_name[MAX_NLEN]; object_desc(o2_name, q_ptr, TRUE, 0); + + if (-1 == store_check_num(q_ptr)) + { +#ifdef JP + msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£"); +#else + msg_print("The same object as it is already in the Museum."); +#endif + } + else + { +#ifdef JP + msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡ª¡ª"); +#else + msg_print("You cannot take items which is given to the Museum back!!"); +#endif + } #ifdef JP - msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¡ª¡ª"); if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return; #else - msg_print("You cannot take items which is given to the Museum back!!"); if (!get_check(format("Really give %s to the Museum? ", o2_name))) return; #endif @@ -3952,21 +4007,21 @@ static void store_examine(void) { if (cur_store_num == STORE_HOME) #ifdef JP -msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£"); + msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£"); #else msg_print("Your home is empty."); #endif - if (cur_store_num == STORE_MUSEUM) + else if (cur_store_num == STORE_MUSEUM) #ifdef JP -msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£"); + msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£"); #else msg_print("Museum is empty."); #endif else #ifdef JP -msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£"); + msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£"); #else msg_print("I am currently out of stock."); #endif @@ -4023,7 +4078,7 @@ msg_format("%s /* Describe it fully */ - if (!identify_fully_aux(o_ptr)) + if (!screen_object(o_ptr, TRUE)) #ifdef JP msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£"); #else @@ -4110,23 +4165,23 @@ static void store_process_command(void) else { store_top += 12; - /* - * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤­¤Ï - * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤ - */ - if ((cur_store_num == STORE_HOME) && - (powerup_home == FALSE) && - (st_ptr->stock_num >= STORE_INVEN_MAX)) - { - if (store_top >= (STORE_INVEN_MAX - 1)) - { - store_top = 0; - } - } - else - { - if (store_top >= st_ptr->stock_num) store_top = 0; - } + /* + * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤­¤Ï + * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤ + */ + if ((cur_store_num == STORE_HOME) && + (powerup_home == FALSE) && + (st_ptr->stock_num >= STORE_INVEN_MAX)) + { + if (store_top >= (STORE_INVEN_MAX - 1)) + { + store_top = 0; + } + } + else + { + if (store_top >= st_ptr->stock_num) store_top = 0; + } display_inventory(); } @@ -4268,7 +4323,9 @@ static void store_process_command(void) /* Character description */ case 'C': { + p_ptr->town_num = old_town_num; do_cmd_change_name(); + p_ptr->town_num = inner_town_num; display_store(); break; } @@ -4286,28 +4343,36 @@ static void store_process_command(void) /* Single line from a pref file */ case '"': { + p_ptr->town_num = old_town_num; do_cmd_pref(); + p_ptr->town_num = inner_town_num; break; } /* Interact with macros */ case '@': { + p_ptr->town_num = old_town_num; do_cmd_macros(); + p_ptr->town_num = inner_town_num; break; } /* Interact with visuals */ case '%': { + p_ptr->town_num = old_town_num; do_cmd_visuals(); + p_ptr->town_num = inner_town_num; break; } /* Interact with colors */ case '&': { + p_ptr->town_num = old_town_num; do_cmd_colors(); + p_ptr->town_num = inner_town_num; break; } @@ -4411,10 +4476,9 @@ void do_cmd_store(void) { int which; int maintain_num; - int tmp_chr; int i; cave_type *c_ptr; - s16b old_town_num; + bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */ /* Access the player grid */ @@ -4441,6 +4505,7 @@ void do_cmd_store(void) old_town_num = p_ptr->town_num; if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1; if (dun_level) p_ptr->town_num = NO_TOWN; + inner_town_num = p_ptr->town_num; /* Hack -- Check the "locked doors" */ if ((town[p_ptr->town_num].store[which].store_open >= turn) || @@ -4457,7 +4522,7 @@ void do_cmd_store(void) } /* Calculate the number of store maintainances since the last visit */ - maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (20L * STORE_TURNS); + maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS); /* Maintain the store max. 10 times */ if (maintain_num > 10) maintain_num = 10; @@ -4516,9 +4581,6 @@ void do_cmd_store(void) /* Hack -- Clear line 1 */ prt("", 1, 0); - /* Hack -- Check the charisma */ - tmp_chr = p_ptr->stat_use[A_CHR]; - /* Clear */ clear_from(20); @@ -4548,8 +4610,8 @@ void do_cmd_store(void) if (cur_store_num == STORE_HOME) { #ifdef JP - prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27); - prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27); + prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27); + prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27); prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27); #else prt("g) Get an item.", 21, 27); @@ -4563,7 +4625,7 @@ void do_cmd_store(void) else if (cur_store_num == STORE_MUSEUM) { #ifdef JP - prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27); + prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27); prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27); #else prt("d) Drop an item.", 21, 27); @@ -4576,8 +4638,8 @@ void do_cmd_store(void) else { #ifdef JP - prt("p) ¾¦ÉʤòÇ㤦", 21, 30); - prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30); + prt("p) ¾¦ÉʤòÇ㤦", 21, 30); + prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30); prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,30); #else prt("p) Purchase an item.", 21, 30); @@ -4588,29 +4650,29 @@ void do_cmd_store(void) } #ifdef JP - /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */ - - prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56); - - if( rogue_like_commands == TRUE ) - { - prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56); - } - else - { - prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56); - } + /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */ + + prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56); + + if( rogue_like_commands == TRUE ) + { + prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56); + } + else + { + prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56); + } #else - prt("i/e) Inventry/Equipment list", 21, 56); - - if( rogue_like_commands == TRUE ) - { - prt("w/T) Wear/Take off equipment", 22, 56); - } - else - { - prt("w/t) Wear/Take off equipment", 22, 56); - } + prt("i/e) Inventry/Equipment list", 21, 56); + + if( rogue_like_commands == TRUE ) + { + prt("w/T) Wear/Take off equipment", 22, 56); + } + else + { + prt("w/t) Wear/Take off equipment", 22, 56); + } #endif /* Prompt */ #ifdef JP @@ -4626,6 +4688,12 @@ void do_cmd_store(void) /* Process the command */ store_process_command(); + /* + * Hack -- To redraw missiles damage and prices in store + * If player's charisma changes, or if player changes a bow, PU_BONUS is set + */ + need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE; + /* Hack -- Character is still in "icky" mode */ character_icky = TRUE; @@ -4735,7 +4803,8 @@ void do_cmd_store(void) } /* Hack -- Redisplay store prices if charisma changes */ - if (tmp_chr != p_ptr->stat_use[A_CHR]) display_inventory(); + /* Hack -- Redraw missiles damage if player changes bow */ + if (need_redraw_store_inv) display_inventory(); /* Hack -- get kicked out of the store */ if (st_ptr->store_open >= turn) leave_store = TRUE; @@ -4767,7 +4836,7 @@ void do_cmd_store(void) /* Update everything */ - p_ptr->update |= (PU_VIEW | PU_LITE); + p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE); p_ptr->update |= (PU_MONSTERS); /* Redraw entire screen */ @@ -4805,7 +4874,7 @@ void store_shuffle(int which) /* Pick a new owner */ while(1) { - st_ptr->owner = (byte)rand_int(MAX_OWNERS); + st_ptr->owner = (byte)randint0(MAX_OWNERS); if (j == st_ptr->owner) continue; for (i = 1;i < max_towns; i++) { @@ -4899,7 +4968,7 @@ void store_maint(int town_num, int store_num) j = st_ptr->stock_num; /* Sell a few items */ - j = j - randint(STORE_TURNOVER); + j = j - randint1(STORE_TURNOVER); /* Never keep more than "STORE_MAX_KEEP" slots */ if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP; @@ -4918,7 +4987,7 @@ void store_maint(int town_num, int store_num) j = st_ptr->stock_num; /* Buy some more items */ - j = j + randint(STORE_TURNOVER); + j = j + randint1(STORE_TURNOVER); /* Never keep more than "STORE_MAX_KEEP" slots */ if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP; @@ -4956,7 +5025,7 @@ void store_init(int town_num, int store_num) { int i; - st_ptr->owner = (byte)rand_int(MAX_OWNERS); + st_ptr->owner = (byte)randint0(MAX_OWNERS); for (i = 1;i < max_towns; i++) { if (i == town_num) continue; @@ -4982,7 +5051,7 @@ void store_init(int town_num, int store_num) * MEGA-HACK - Last visit to store is * BEFORE player birth to enable store restocking */ - st_ptr->last_visit = -200L * STORE_TURNS; + st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS; /* Clear any old items */ for (k = 0; k < st_ptr->stock_size; k++)