OSDN Git Service

[Refactor] #37353 max_f_idx を feature.c/h へ移動.
[hengband/hengband.git] / src / store.c
1 /*!
2  * @file store.c
3  * @brief 店の処理 / Store commands
4  * @date 2014/02/02
5  * @author
6  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7  * This software may be copied and distributed for educational, research, and\n
8  * not for profit purposes provided that this copyright and statement are\n
9  * included in all such copies.\n
10  * 2014 Deskull rearranged comment for Doxygen.
11  */
12
13 #include "angband.h"
14 #include "util.h"
15 #include "term.h"
16
17 #include "floor.h"
18 #include "cmd-dump.h"
19 #include "cmd-item.h"
20 #include "cmd-smith.h"
21 #include "cmd-zapwand.h"
22 #include "cmd-magiceat.h"
23 #include "spells.h"
24 #include "store.h"
25 #include "avatar.h"
26 #include "cmd-spell.h"
27 #include "rumor.h"
28 #include "player-status.h"
29 #include "object-flavor.h"
30 #include "object-hook.h"
31 #include "floor-events.h"
32 #include "snipe.h"
33 #include "files.h"
34 #include "player-effects.h"
35 #include "player-race.h"
36 #include "mind.h"
37 #include "world.h"
38 #include "objectkind.h"
39 #include "autopick.h"
40 #include "floor-town.h"
41
42 #define MIN_STOCK 12
43
44  /*!
45   * @brief 闘技場のモンスターID及び報酬アイテムテーブル /
46   * Store owners (exactly four "possible" owners per store, chosen randomly)
47   * @details
48   * <pre>
49   * { name, purse, max greed, min greed, haggle_per, tolerance, race, unused }
50   *
51   * Lifted extra shopkeepers from CthAngband (don't you just love open source
52   * development? ;-)). Since this gave less than 32 unique names for some
53   * shops, those have their first x names copied to reach 32.
54   *
55   * For the weapon and armour shops, several owners have a limit of 5k.
56   *
57   * I want to do 50k owners, but the purse is currently s16b. Perhaps
58   * we should just store 1/10th of the purse?
59   * </pre>
60   */
61 const owner_type owners[MAX_STORES][MAX_OWNERS] =
62 {
63         {
64                 /* General store - 32 unique names */
65                 /*
66                   Raistlin は dragonlance の powerful wizard 。
67                   Rincewind the Chicken は Terry Pratchett の Discworld の登場人物 上記のパロディ?、
68                   { "憶病者ラストリン",       200,    175,  108,   4,  12,  RACE_HUMAN},
69                   { "Raistlin the Chicken",       200,    175, 108,  4, 12, RACE_HUMAN},
70                 */
71
72 #ifdef JP
73                 { "フレンドリーなビルボ",       200,    170,  108,   5,  15,  RACE_HOBBIT},
74                 { "憶病者リンスウィンド",       200,    175,  108,   4,  12,  RACE_HUMAN},
75                 { "背の低いサルタン",             300,    170,  107,   5,  15,  RACE_GNOME},
76                 { "ハンサムなライア=エル",      300,    165,  107,   6,  18,  RACE_ELF},
77                 { "親切なファリルマウエン",         250,    170, 108,  5, 15, RACE_HOBBIT},
78                 { "臆病者ヴォワラン",       500,    175, 108,  4, 12, RACE_HUMAN},
79                 { "チビのエラシュナク",          750,    170, 107,  5, 15, RACE_BEASTMAN},
80                 { "ハンサムなグラッグ",        1000,    165, 107,  6, 18, RACE_HALF_TITAN},
81                 { "ケチなフォロビア",         250,    170, 108,  5, 15, RACE_HUMAN},
82                 { "馬鹿のエリス",       500,    175, 108,  4, 12, RACE_HUMAN},
83                 { "腹ペコのフィルバート",          750,    170, 107,  5, 15, RACE_VAMPIRE},
84                 { "スナーグル・サシグア",        1000,    165, 107,  6, 18, RACE_MIND_FLAYER},
85                 { "長死きエロワーズ",         250,    170, 108,  5, 15, RACE_SPECTRE},
86                 { "ノロマのフンディ",       500,    175, 108,  4, 12, RACE_ZOMBIE},
87                 { "グランサス",          750,    170, 107,  5, 15, RACE_SKELETON},
88                 { "丁寧なロラックス",        1000,    165, 107,  6, 18, RACE_VAMPIRE},
89                 { "ブッチ",         250,    170, 108,  5, 15, RACE_HALF_ORC},
90                 { "美しきエルベレス",       500,    175, 108,  4, 12, RACE_HIGH_ELF},
91                 { "こそこそサーレス",          750,    170, 107,  5, 15, RACE_GNOME},
92                 { "ナーロック",        1000,    165, 107,  6, 18, RACE_DWARF},
93                 { "チビのヘイネッカ",         250,    170, 108,  5, 15, RACE_GNOME},
94                 { "きちがいロワラン",       500,    175, 108,  4, 12, RACE_HALF_GIANT},
95                 { "毒息のウート",          750,    170, 107,  5, 15, RACE_DRACONIAN},
96                 { "でぶっちょアラァカ",        1000,    165, 107,  6, 18, RACE_DRACONIAN},
97                 { "低能なプーゴー",         250,    170, 108,  5, 15, RACE_BEASTMAN},
98                 { "フェロールフィリアン",       500,    175, 108,  4, 12, RACE_ELF},
99                 { "年寄りマロカ",          750,    170, 107,  5, 15, RACE_GNOME},
100                 { "勇敢なサシン",        1000,    165, 107,  6, 18, RACE_HALF_GIANT},
101                 { "田舎者アビエマール",         250,    170, 108,  5, 15, RACE_HUMAN},
102                 { "貧乏なハーク",       500,    175, 108,  4, 12, RACE_HALF_ORC},
103                 { "みじめなソアリン",          750,    170, 107,  5, 15, RACE_ZOMBIE},
104                 { "質素なメルラ",        1000,    165, 107,  6, 18, RACE_ELF},
105 #else
106                 { "Bilbo the Friendly",         200,    170, 108,  5, 15, RACE_HOBBIT},
107                 { "Rincewind the Chicken",       200,    175, 108,  4, 12, RACE_HUMAN},
108                 { "Sultan the Midget",          300,    170, 107,  5, 15, RACE_GNOME},
109                 { "Lyar-el the Comely",         300,    165, 107,  6, 18, RACE_ELF},
110                 { "Falilmawen the Friendly",         250,    170, 108,  5, 15, RACE_HOBBIT},
111                 { "Voirin the Cowardly",       500,    175, 108,  4, 12, RACE_HUMAN},
112                 { "Erashnak the Midget",          750,    170, 107,  5, 15, RACE_BEASTMAN},
113                 { "Grug the Comely",        1000,    165, 107,  6, 18, RACE_HALF_TITAN},
114                 { "Forovir the Cheap",         250,    170, 108,  5, 15, RACE_HUMAN},
115                 { "Ellis the Fool",       500,    175, 108,  4, 12, RACE_HUMAN},
116                 { "Filbert the Hungry",          750,    170, 107,  5, 15, RACE_VAMPIRE},
117                 { "Fthnargl Psathiggua",        1000,    165, 107,  6, 18, RACE_MIND_FLAYER},
118                 { "Eloise Long-Dead",         250,    170, 108,  5, 15, RACE_SPECTRE},
119                 { "Fundi the Slow",       500,    175, 108,  4, 12, RACE_ZOMBIE},
120                 { "Granthus",          750,    170, 107,  5, 15, RACE_SKELETON},
121                 { "Lorax the Suave",        1000,    165, 107,  6, 18, RACE_VAMPIRE},
122                 { "Butch",         250,    170, 108,  5, 15, RACE_HALF_ORC},
123                 { "Elbereth the Beautiful",       500,    175, 108,  4, 12, RACE_HIGH_ELF},
124                 { "Sarleth the Sneaky",          750,    170, 107,  5, 15, RACE_GNOME},
125                 { "Narlock",        1000,    165, 107,  6, 18, RACE_DWARF},
126                 { "Haneka the Small",         250,    170, 108,  5, 15, RACE_GNOME},
127                 { "Loirin the Mad",       500,    175, 108,  4, 12, RACE_HALF_GIANT},
128                 { "Wuto Poisonbreath",          750,    170, 107,  5, 15, RACE_DRACONIAN},
129                 { "Araaka the Rotund",        1000,    165, 107,  6, 18, RACE_DRACONIAN},
130                 { "Poogor the Dumb",         250,    170, 108,  5, 15, RACE_BEASTMAN},
131                 { "Felorfiliand",       500,    175, 108,  4, 12, RACE_ELF},
132                 { "Maroka the Aged",          750,    170, 107,  5, 15, RACE_GNOME},
133                 { "Sasin the Bold",        1000,    165, 107,  6, 18, RACE_HALF_GIANT},
134                 { "Abiemar the Peasant",         250,    170, 108,  5, 15, RACE_HUMAN},
135                 { "Hurk the Poor",       500,    175, 108,  4, 12, RACE_HALF_ORC},
136                 { "Soalin the Wretched",          750,    170, 107,  5, 15, RACE_ZOMBIE},
137                 { "Merulla the Humble",        1000,    165, 107,  6, 18, RACE_ELF},
138 #endif
139         },
140         {
141                 /* Armoury - 28 unique names */
142 #ifdef JP
143                 { "醜悪コン=ダー",      5000,   210,  115,   5,   7,  RACE_HALF_ORC},
144                 { "頑固者ダーグ=ロウ",  10000,  190,  111,   4,   9,  RACE_HUMAN},
145                 { "賢者デカド",                 25000,  200,  112,   4,  10,  RACE_DUNADAN},
146                 { "鍛冶屋のウィーランド",   30000,  200,  112,   4,   5,  RACE_DWARF},
147                 { "醜悪コン=ダー",           10000,   210, 115,  5,  7, RACE_HALF_ORC},
148                 { "頑固者ダーグ=ロウ",          15000,  190, 111,  4,  9, RACE_HUMAN},
149                 { "ハンサムなデカド",            25000,  200, 112,  4, 10, RACE_AMBERITE},
150                 { "エロー・ドラゴンスケイル",          30000,  200, 112,  4,  5, RACE_ELF},
151                 { "デリカトス",           10000,   210, 115,  5,  7, RACE_SPRITE},
152                 { "巨大なグルース",          15000,  190, 111,  4,  9, RACE_HALF_GIANT},
153                 { "アニムス",            25000,  200, 112,  4, 10, RACE_GOLEM},
154                 { "マルヴァス",          30000,  200, 112,  4,  5, RACE_HALF_TITAN},
155                 { "セラクシス",           10000,   210, 115,  5,  7, RACE_ZOMBIE},
156                 { "デス・チル",          5000,  190, 111,  4,  9, RACE_SPECTRE},
157                 { "微かなドリオス",            25000,  200, 112,  4, 10, RACE_SPECTRE},
158                 { "冷たいバスリック",          30000,  200, 112,  4,  5, RACE_VAMPIRE},
159                 { "冷酷ヴェンジェラ",           10000,   210, 115,  5,  7, RACE_HALF_TROLL},
160                 { "強者ウィラナ",          15000,  190, 111,  4,  9, RACE_HUMAN},
161                 { "ヨジョ二世",            25000,  200, 112,  4, 10, RACE_DWARF},
162                 { "優しいラナラー",          30000,  200, 112,  4,  5, RACE_AMBERITE},
163                 { "不浄のホルバグ",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
164                 { "テレパスのエレレン",          15000,  190, 111,  4,  9, RACE_DARK_ELF},
165                 { "イスドリリアス",            25000,  200, 112,  4, 10, RACE_SPRITE},
166                 { "一つ目ヴェグナー",          5000,  200, 112,  4,  5, RACE_CYCLOPS},
167                 { "混沌のロディッシュ",           10000,   210, 115,  5,  7, RACE_BEASTMAN},
168                 { "剣豪ヘジン",          15000,  190, 111,  4,  9, RACE_NIBELUNG},
169                 { "ずる屋のエルベレリス",           10000,  200, 112,  4, 10, RACE_DARK_ELF},
170                 { "インプのザサス",          30000,  200, 112,  4,  5, RACE_IMP},
171                 { "醜悪コン=ダー",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
172                 { "頑固者ダーグ=ロウ",          10000,  190, 111,  4,  9, RACE_HUMAN},
173                 { "ハンサムなデカド",            25000,  200, 112,  4, 10, RACE_AMBERITE},
174                 { "鍛冶屋のウィーランド",          30000,  200, 112,  4,  5, RACE_DWARF},
175 #else
176                 { "Kon-Dar the Ugly",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
177                 { "Darg-Low the Grim",          10000,  190, 111,  4,  9, RACE_HUMAN},
178                 { "Decado the Handsome",            25000,  200, 112,  4, 10, RACE_DUNADAN},
179                 { "Wieland the Smith",          30000,  200, 112,  4,  5, RACE_DWARF},
180                 { "Kon-Dar the Ugly",           10000,   210, 115,  5,  7, RACE_HALF_ORC},
181                 { "Darg-Low the Grim",          15000,  190, 111,  4,  9, RACE_HUMAN},
182                 { "Decado the Handsome",            25000,  200, 112,  4, 10, RACE_AMBERITE},
183                 { "Elo Dragonscale",          30000,  200, 112,  4,  5, RACE_ELF},
184                 { "Delicatus",           10000,   210, 115,  5,  7, RACE_SPRITE},
185                 { "Gruce the Huge",          15000,  190, 111,  4,  9, RACE_HALF_GIANT},
186                 { "Animus",            25000,  200, 112,  4, 10, RACE_GOLEM},
187                 { "Malvus",          30000,  200, 112,  4,  5, RACE_HALF_TITAN},
188                 { "Selaxis",           10000,   210, 115,  5,  7, RACE_ZOMBIE},
189                 { "Deathchill",          5000,  190, 111,  4,  9, RACE_SPECTRE},
190                 { "Drios the Faint",            25000,  200, 112,  4, 10, RACE_SPECTRE},
191                 { "Bathric the Cold",          30000,  200, 112,  4,  5, RACE_VAMPIRE},
192                 { "Vengella the Cruel",           10000,   210, 115,  5,  7, RACE_HALF_TROLL},
193                 { "Wyrana the Mighty",          15000,  190, 111,  4,  9, RACE_HUMAN},
194                 { "Yojo II",            25000,  200, 112,  4, 10, RACE_DWARF},
195                 { "Ranalar the Sweet",          30000,  200, 112,  4,  5, RACE_AMBERITE},
196                 { "Horbag the Unclean",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
197                 { "Elelen the Telepath",          15000,  190, 111,  4,  9, RACE_DARK_ELF},
198                 { "Isedrelias",            25000,  200, 112,  4, 10, RACE_SPRITE},
199                 { "Vegnar One-eye",          5000,  200, 112,  4,  5, RACE_CYCLOPS},
200                 { "Rodish the Chaotic",           10000,   210, 115,  5,  7, RACE_BEASTMAN},
201                 { "Hesin Swordmaster",          15000,  190, 111,  4,  9, RACE_NIBELUNG},
202                 { "Elvererith the Cheat",           10000,  200, 112,  4, 10, RACE_DARK_ELF},
203                 { "Zzathath the Imp",          30000,  200, 112,  4,  5, RACE_IMP},
204                 { "Kon-Dar the Ugly",           5000,   210, 115,  5,  7, RACE_HALF_ORC},
205                 { "Darg-Low the Grim",          10000,  190, 111,  4,  9, RACE_HUMAN},
206                 { "Decado the Handsome",            25000,  200, 112,  4, 10, RACE_AMBERITE},
207                 { "Wieland the Smith",          30000,  200, 112,  4,  5, RACE_DWARF},
208 #endif
209         },
210
211         {
212                 /* Weapon Smith - 28 unique names */
213 #ifdef JP
214                 { "残忍なるアーノルド",        5000,   210,  115,   6,   6,  RACE_HALF_TROLL},
215                 { "獣殺しのアーンダル", 10000,  185,  110,   5,   9,  RACE_HALF_ELF},
216                 { "獣マスターのエディー", 25000,  190,  115,   5,   7,  RACE_HOBBIT},
217                 { "竜殺しのオグライン", 30000,  195,  112,   4,   8,  RACE_DWARF},
218                 { "熟練者ドリュー",      10000,   210, 115,  6,  6, RACE_HUMAN},
219                 { "龍の子オラックス",        15000,  185, 110,  5,  9, RACE_DRACONIAN},
220                 { "病気持ちのアンスラックス",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
221                 { "頑丈者アルコス",       30000,  195, 112,  4,  8, RACE_DWARF},
222                 { "腐れ者のサリアス",      5000,   210, 115,  6,  6, RACE_ZOMBIE},
223                 { "晒し骨のトゥエシク",        15000,  185, 110,  5,  9, RACE_SKELETON},
224                 { "ビリオス",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
225                 { "ファスガル",       30000,  195, 112,  4,  8, RACE_ZOMBIE},
226                 { "パラディンのエレフリス",      10000,   210, 115,  6,  6, RACE_BARBARIAN},
227                 { "キ'トリッ'ク",        15000,  185, 110,  5,  9, RACE_KLACKON},
228                 { "蜘蛛の友ドゥロカス",         25000,  190, 115,  5,  7, RACE_DARK_ELF},
229                 { "巨人殺しのフングス",       30000,  195, 112,  4,  8, RACE_DWARF},
230                 { "デランサ",      10000,   210, 115,  6,  6, RACE_ELF},
231                 { "レンジャーのソルビスタニ",        15000,  185, 110,  5,  9, RACE_HALF_ELF},
232                 { "ノロマのゾリル",         25000,  190, 115,  5,  7, RACE_GOLEM},
233                 { "イーオン・フラックス",       20000,  195, 112,  4,  8, RACE_HALF_ELF},
234                 { "強者ナドック",      10000,   210, 115,  6,  6, RACE_HOBBIT},
235                 { "弱虫エラモグ",        15000,  185, 110,  5,  9, RACE_KOBOLD},
236                 { "公正なエオウィリス",         25000,  190, 115,  5,  7, RACE_VAMPIRE},
237                 { "バルログ殺しのヒュイモグ",       30000,  195, 112,  4,  8, RACE_HALF_ORC},
238                 { "冷酷ピーダス",      5000,   210, 115,  6,  6, RACE_HUMAN},
239                 { "ヴァモグ スレイヤー",        15000,  185, 110,  5,  9, RACE_HALF_OGRE},
240                 { "性悪フーシュナク",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
241                 { "舞闘バレン",       30000,  195, 112,  4,  8, RACE_BARBARIAN},
242                 { "残忍なるアーノルド",      5000,   210, 115,  6,  6, RACE_BARBARIAN},
243                 { "獣殺しのアーンダル",        10000,  185, 110,  5,  9, RACE_HALF_ELF},
244                 { "ビーストマスター・エディー",         25000,  190, 115,  5,  7, RACE_HALF_ORC},
245                 { "竜殺しのオグライン",       30000,  195, 112,  4,  8, RACE_DWARF},
246 #else
247                 { "Arnold the Beastly",      5000,   210, 115,  6,  6, RACE_BARBARIAN},
248                 { "Arndal Beast-Slayer",        10000,  185, 110,  5,  9, RACE_HALF_ELF},
249                 { "Eddie Beast-Master",         25000,  190, 115,  5,  7, RACE_HALF_ORC},
250                 { "Oglign Dragon-Slayer",       30000,  195, 112,  4,  8, RACE_DWARF},
251                 { "Drew the Skilled",      10000,   210, 115,  6,  6, RACE_HUMAN},
252                 { "Orrax Dragonson",        15000,  185, 110,  5,  9, RACE_DRACONIAN},
253                 { "Anthrax Disease-Carrier",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
254                 { "Arkhoth the Stout",       30000,  195, 112,  4,  8, RACE_DWARF},
255                 { "Sarlyas the Rotten",      5000,   210, 115,  6,  6, RACE_ZOMBIE},
256                 { "Tuethic Bare-Bones",        15000,  185, 110,  5,  9, RACE_SKELETON},
257                 { "Bilious",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
258                 { "Fasgul",       30000,  195, 112,  4,  8, RACE_ZOMBIE},
259                 { "Ellefris the Paladin",      10000,   210, 115,  6,  6, RACE_BARBARIAN},
260                 { "K'trrik'k",        15000,  185, 110,  5,  9, RACE_KLACKON},
261                 { "Drocus Spiderfriend",         25000,  190, 115,  5,  7, RACE_DARK_ELF},
262                 { "Fungus Giant-Slayer",       30000,  195, 112,  4,  8, RACE_DWARF},
263                 { "Delantha",      10000,   210, 115,  6,  6, RACE_ELF},
264                 { "Solvistani the Ranger",        15000,  185, 110,  5,  9, RACE_HALF_ELF},
265                 { "Xoril the Slow",         25000,  190, 115,  5,  7, RACE_GOLEM},
266                 { "Aeon Flux",       20000,  195, 112,  4,  8, RACE_HALF_ELF},
267                 { "Nadoc the Strong",      10000,   210, 115,  6,  6, RACE_HOBBIT},
268                 { "Eramog the Weak",        15000,  185, 110,  5,  9, RACE_KOBOLD},
269                 { "Eowilith the Fair",         25000,  190, 115,  5,  7, RACE_VAMPIRE},
270                 { "Huimog Balrog-Slayer",       30000,  195, 112,  4,  8, RACE_HALF_ORC},
271                 { "Peadus the Cruel",      5000,   210, 115,  6,  6, RACE_HUMAN},
272                 { "Vamog Slayer",        15000,  185, 110,  5,  9, RACE_HALF_OGRE},
273                 { "Hooshnak the Vicious",         25000,  190, 115,  5,  7, RACE_BEASTMAN},
274                 { "Balenn War-Dancer",       30000,  195, 112,  4,  8, RACE_BARBARIAN},
275                 { "Arnold the Beastly",      5000,   210, 115,  6,  6, RACE_BARBARIAN},
276                 { "Arndal Beast-Slayer",        10000,  185, 110,  5,  9, RACE_HALF_ELF},
277                 { "Eddie Beast-Master",         25000,  190, 115,  5,  7, RACE_HALF_ORC},
278                 { "Oglign Dragon-Slayer",       30000,  195, 112,  4,  8, RACE_DWARF},
279 #endif
280         },
281         {
282                 /* Temple - 22 unique names */
283 #ifdef JP
284                 { "質素なルードヴィヒ",         5000,   175,  109,   6,  15,  RACE_HUMAN},
285                 { "パラディンのガンナー",       10000,  185,  110,   5,  23,  RACE_HUMAN},
286                 { "選ばれしトリン",                     25000,  180,  107,   6,  20,  RACE_ELF},
287                 { "賢明なるサラストロ",                     30000,  185,  109,   5,  15,  RACE_DWARF},
288                 { "パーシヴァル卿",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
289                 { "神聖なるアセナス",          30000,  185, 109,  5, 15, RACE_HUMAN},
290                 { "マッキノン",         10000,   175, 109,  6, 15, RACE_HUMAN},
291                 { "謹み婦人",         15000,  185, 110,  5, 23, RACE_HIGH_ELF},
292                 { "ドルイドのハシュニック",           25000,  180, 107,  6, 20, RACE_HOBBIT},
293                 { "フィナク",          30000,  185, 109,  5, 15, RACE_YEEK},
294                 { "クリキック",         10000,   175, 109,  6, 15, RACE_KLACKON},
295                 { "荒くれ者モリヴァル",         15000,  185, 110,  5, 23, RACE_ELF},
296                 { "暗きホシャック",           25000,  180, 107,  6, 20, RACE_IMP},
297                 { "賢者アタール",          30000,  185, 109,  5, 15, RACE_HUMAN},
298                 { "清きイベニッド",         10000,   175, 109,  6, 15, RACE_HUMAN},
299                 { "エリディシュ",         15000,  185, 110,  5, 23, RACE_HALF_TROLL},
300                 { "呪術師ヴルドゥシュ",           25000,  180, 107,  6, 20, RACE_HALF_OGRE},
301                 { "狂戦士ハオブ",          30000,  185, 109,  5, 15, RACE_BARBARIAN},
302                 { "若きプルーグディシュ",         10000,   175, 109,  6, 15, RACE_HALF_OGRE},
303                 { "きちがいラムワイズ",         15000,  185, 110,  5, 23, RACE_YEEK},
304                 { "有徳者ムワート",           25000,  180, 107,  6, 20, RACE_KOBOLD},
305                 { "弱虫ダードバード",          30000,  185, 109,  5, 15, RACE_SPECTRE},
306                 { "質素なルードヴィヒ",         5000,   175,  109,   6,  15,  RACE_HUMAN},
307                 { "パラディンのガンナー",       10000,  185,  110,   5,  23,  RACE_HUMAN},
308                 { "選ばれしトリン",                     25000,  180,  107,   6,  20,  RACE_ELF},
309                 { "賢明なるサラストロ",                     30000,  185,  109,   5,  15,  RACE_DWARF},
310                 { "パーシヴァル卿",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
311                 { "神聖なるアセナス",          30000,  185, 109,  5, 15, RACE_HUMAN},
312                 { "マッキノン",         10000,   175, 109,  6, 15, RACE_HUMAN},
313                 { "謹み婦人",         15000,  185, 110,  5, 23, RACE_HIGH_ELF},
314                 { "ドルイドのハシュニック",           25000,  180, 107,  6, 20, RACE_HOBBIT},
315                 { "フィナク",          30000,  185, 109,  5, 15, RACE_YEEK},
316 #else
317                 { "Ludwig the Humble",          5000,   175, 109,  6, 15, RACE_DWARF},
318                 { "Gunnar the Paladin",         10000,  185, 110,  5, 23, RACE_HALF_TROLL},
319                 { "Torin the Chosen",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
320                 { "Sarastro the Wise",          30000,  185, 109,  5, 15, RACE_HUMAN},
321                 { "Sir Parsival the Pure",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
322                 { "Asenath the Holy",          30000,  185, 109,  5, 15, RACE_HUMAN},
323                 { "McKinnon",         10000,   175, 109,  6, 15, RACE_HUMAN},
324                 { "Mistress Chastity",         15000,  185, 110,  5, 23, RACE_HIGH_ELF},
325                 { "Hashnik the Druid",           25000,  180, 107,  6, 20, RACE_HOBBIT},
326                 { "Finak",          30000,  185, 109,  5, 15, RACE_YEEK},
327                 { "Krikkik",         10000,   175, 109,  6, 15, RACE_KLACKON},
328                 { "Morival the Wild",         15000,  185, 110,  5, 23, RACE_ELF},
329                 { "Hoshak the Dark",           25000,  180, 107,  6, 20, RACE_IMP},
330                 { "Atal the Wise",          30000,  185, 109,  5, 15, RACE_HUMAN},
331                 { "Ibenidd the Chaste",         10000,   175, 109,  6, 15, RACE_HUMAN},
332                 { "Eridish",         15000,  185, 110,  5, 23, RACE_HALF_TROLL},
333                 { "Vrudush the Shaman",           25000,  180, 107,  6, 20, RACE_HALF_OGRE},
334                 { "Haob the Berserker",          30000,  185, 109,  5, 15, RACE_BARBARIAN},
335                 { "Proogdish the Youthfull",         10000,   175, 109,  6, 15, RACE_HALF_OGRE},
336                 { "Lumwise the Mad",         15000,  185, 110,  5, 23, RACE_YEEK},
337                 { "Muirt the Virtuous",           25000,  180, 107,  6, 20, RACE_KOBOLD},
338                 { "Dardobard the Weak",          30000,  185, 109,  5, 15, RACE_SPECTRE},
339                 { "Ludwig the Humble",          5000,   175, 109,  6, 15, RACE_DWARF},
340                 { "Gunnar the Paladin",         10000,  185, 110,  5, 23, RACE_HALF_TROLL},
341                 { "Torin the Chosen",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
342                 { "Sarastro the Wise",          30000,  185, 109,  5, 15, RACE_HUMAN},
343                 { "Sir Parsival the Pure",           25000,  180, 107,  6, 20, RACE_HIGH_ELF},
344                 { "Asenath the Holy",          30000,  185, 109,  5, 15, RACE_HUMAN},
345                 { "McKinnon",         10000,   175, 109,  6, 15, RACE_HUMAN},
346                 { "Mistress Chastity",         15000,  185, 110,  5, 23, RACE_HIGH_ELF},
347                 { "Hashnik the Druid",           25000,  180, 107,  6, 20, RACE_HOBBIT},
348                 { "Finak",          30000,  185, 109,  5, 15, RACE_YEEK},
349 #endif
350         },
351         {
352                 /* Alchemist - 26 unique names */
353 #ifdef JP
354                 { "化学者マウザー",             10000,  190,  111,   5,   8,  RACE_HALF_ELF},
355                 { "カオスのウィズル",   10000,  190,  110,   6,   8,  RACE_HOBBIT},
356                 { "強欲ミダス",              15000,  200,  116,   6,   9,  RACE_GNOME},
357                 { "貧弱ジャ=ファー",                   15000,  220,  111,   4,   9,  RACE_ELF},/*FIRST*/
358                 { "カカルラカカル",           15000,  200, 116,  6,  9, RACE_KLACKON},
359                 { "錬金術師ジャル=エス",       15000,  220, 111,  4,  9, RACE_ELF},
360                 { "用心深いファネラス",         10000,  190, 111,  5,  8, RACE_DWARF},
361                 { "キチガイのルンシー",         10000,  190, 110,  6,  8, RACE_HUMAN},
362                 { "グランブルワース",           15000,  200, 116,  6,  9, RACE_GNOME},
363                 { "フリッター",       15000,  220, 111,  4,  9, RACE_SPRITE},
364                 { "ザリルス",         10000,  190, 111,  5,  8, RACE_HUMAN},
365                 { "古きエグバート",         10000,  190, 110,  6,  8, RACE_DWARF},
366                 { "誇り高きヴァリンドラ",           15000,  200, 116,  6,  9, RACE_HIGH_ELF},
367                 { "錬金術師タエン",       15000,  220, 111,  4,  9, RACE_HUMAN},
368                 { "巧言カイド",         10000,  190, 111,  5,  8, RACE_VAMPIRE},
369                 { "暗きフリア",         10000,  190, 110,  6,  8, RACE_NIBELUNG},
370                 { "質素なドムリ",           15000,  200, 116,  6,  9, RACE_DWARF},
371                 { "魔の子ヤァジュッカ",       15000,  220, 111,  4,  9, RACE_IMP},
372                 { "薬草師ジェララルドール",         10000,  190, 111,  5,  8, RACE_HIGH_ELF},
373                 { "賢者オレラルダン",         10000,  190, 110,  6,  8, RACE_BARBARIAN},
374                 { "デモニシストのフゾグロ",           15000,  200, 116,  6,  9, RACE_IMP},
375                 { "錬金術師ドゥリアシュ",       15000,  220, 111,  4,  9, RACE_HALF_ORC},
376                 { "強者ネリア",         10000,  190, 111,  5,  8, RACE_CYCLOPS},
377                 { "辛口リグナス",         10000,  190, 110,  6,  8, RACE_HALF_ORC},
378                 { "ティルバ",           15000,  200, 116,  6,  9, RACE_HOBBIT},
379                 { "金持ちミリルドリック",       15000,  220, 111,  4,  9, RACE_HUMAN},
380
381                 { "科学者マウザー",         10000,  190, 111,  5,  8, RACE_HALF_ELF},
382                 { "カオスのウィズル",         10000,  190, 110,  6,  8, RACE_HOBBIT},
383                 { "強欲ミダス",           15000,  200, 116,  6,  9, RACE_GNOME},
384                 { "錬金術師ジャ=ファー",       15000,  220, 111,  4,  9, RACE_ELF},
385                 { "カカルラカカル",           15000,  200, 116,  6,  9, RACE_KLACKON},
386                 { "錬金術師ジャル=エス",       15000,  220, 111,  4,  9, RACE_ELF},
387 #else
388                 { "Mauser the Chemist",         10000,  190, 111,  5,  8, RACE_HALF_ELF},
389                 { "Wizzle the Chaotic",         10000,  190, 110,  6,  8, RACE_HOBBIT},
390                 { "Midas the Greedy",           15000,  200, 116,  6,  9, RACE_GNOME},
391                 { "Ja-Far the Alchemist",       15000,  220, 111,  4,  9, RACE_ELF},
392                 { "Kakalrakakal",           15000,  200, 116,  6,  9, RACE_KLACKON},
393                 { "Jal-Eth the Alchemist",       15000,  220, 111,  4,  9, RACE_ELF},
394                 { "Fanelath the Cautious",         10000,  190, 111,  5,  8, RACE_DWARF},
395                 { "Runcie the Insane",         10000,  190, 110,  6,  8, RACE_HUMAN},
396                 { "Grumbleworth",           15000,  200, 116,  6,  9, RACE_GNOME},
397                 { "Flitter",       15000,  220, 111,  4,  9, RACE_SPRITE},
398                 { "Xarillus",         10000,  190, 111,  5,  8, RACE_HUMAN},
399                 { "Egbert the Old",         10000,  190, 110,  6,  8, RACE_DWARF},
400                 { "Valindra the Proud",           15000,  200, 116,  6,  9, RACE_HIGH_ELF},
401                 { "Taen the Alchemist",       15000,  220, 111,  4,  9, RACE_HUMAN},
402                 { "Cayd the Sweet",         10000,  190, 111,  5,  8, RACE_VAMPIRE},
403                 { "Fulir the Dark",         10000,  190, 110,  6,  8, RACE_NIBELUNG},
404                 { "Domli the Humble",           15000,  200, 116,  6,  9, RACE_DWARF},
405                 { "Yaarjukka Demonspawn",       15000,  220, 111,  4,  9, RACE_IMP},
406                 { "Gelaraldor the Herbmaster",         10000,  190, 111,  5,  8, RACE_HIGH_ELF},
407                 { "Olelaldan the Wise",         10000,  190, 110,  6,  8, RACE_BARBARIAN},
408                 { "Fthoglo the Demonicist",           15000,  200, 116,  6,  9, RACE_IMP},
409                 { "Dridash the Alchemist",       15000,  220, 111,  4,  9, RACE_HALF_ORC},
410                 { "Nelir the Strong",         10000,  190, 111,  5,  8, RACE_CYCLOPS},
411                 { "Lignus the Pungent",         10000,  190, 110,  6,  8, RACE_HALF_ORC},
412                 { "Tilba",           15000,  200, 116,  6,  9, RACE_HOBBIT},
413                 { "Myrildric the Wealthy",       15000,  220, 111,  4,  9, RACE_HUMAN},
414
415                 { "Mauser the Chemist",         10000,  190, 111,  5,  8, RACE_HALF_ELF},
416                 { "Wizzle the Chaotic",         10000,  190, 110,  6,  8, RACE_HOBBIT},
417                 { "Midas the Greedy",           15000,  200, 116,  6,  9, RACE_GNOME},
418                 { "Ja-Far the Alchemist",       15000,  220, 111,  4,  9, RACE_ELF},
419                 { "Kakalrakakal",           15000,  200, 116,  6,  9, RACE_KLACKON},
420                 { "Jal-Eth the Alchemist",       15000,  220, 111,  4,  9, RACE_ELF},
421 #endif
422         },
423
424         {
425                 /* Magic Shop - 23 unique names */
426 #ifdef JP
427                 { "ソーサラーのロ=パン",       20000,  200,  110,   7,   8,  RACE_HALF_ELF},
428                 { "偉大なるブガービイ",         20000,  215,  113,   6,  10,  RACE_GNOME},
429                 { "イェンダーの魔法使い",     30000,  200,  110,   7,  10,  RACE_HUMAN},
430                 { "死霊使いリャク",30000,      175,  110,   5,  11,  RACE_HIGH_ELF},
431                 { "魔術師スキドゥニー",        15000,  200, 110,  7,  8, RACE_HALF_ELF},
432                 { "幻術師キリア",       30000,  200, 110,  7, 10, RACE_HUMAN},
433                 { "死霊術師ニッキ",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
434                 { "ソロストラン",        15000,  200, 110,  7,  8, RACE_SPRITE},
435                 { "烏賊口アチシェ",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
436                 { "貴族のカザ",       30000,  200, 110,  7, 10, RACE_HIGH_ELF},
437                 { "暗きファジル",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
438                 { "偉大なるケルドーン",        15000,  200, 110,  7,  8, RACE_DWARF},
439                 { "フィランスロプス",         20000,  215, 113,  6, 10, RACE_HOBBIT},
440                 { "魔女のアグナー",       30000,  200, 110,  7, 10, RACE_HUMAN},
441                 { "死霊術師ビュリアンス",       30000,  175, 110,  5, 11, RACE_BEASTMAN},
442                 { "ハイメイジのヴイラク",        15000,  200, 110,  7,  8, RACE_BEASTMAN},
443                 { "知恵者マディッシュ",         20000,  215, 113,  6, 10, RACE_BEASTMAN},
444                 { "ファレブリンボール",       30000,  200, 110,  7, 10, RACE_HIGH_ELF},
445                 { "陰険フェリル=ガンド",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
446                 { "呪術師サレゴード",        15000,  200, 110,  7,  8, RACE_BARBARIAN},
447                 { "神秘家クトゥアロス",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
448                 { "幻術師イベリ",       30000,  200, 110,  7, 10, RACE_SKELETON},
449                 { "死霊術師ヘトー",       30000,  175, 110,  5, 11, RACE_YEEK},
450                 { "魔術師ロ=パン",        20000,  200, 110,  7,  8, RACE_HALF_ELF},
451                 { "偉大なるブガービイ",         20000,  215, 113,  6, 10, RACE_GNOME},
452                 { "イェンダーの魔法使い",       30000,  200, 110,  7, 10, RACE_HUMAN},
453                 { "死霊術師リャク",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
454                 { "魔術師スキドゥニー",        15000,  200, 110,  7,  8, RACE_HALF_ELF},
455                 { "幻術師キリア",       30000,  200, 110,  7, 10, RACE_HUMAN},
456                 { "死霊術師ニッキ",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
457                 { "ソロストラン",        15000,  200, 110,  7,  8, RACE_SPRITE},
458                 { "烏賊口アチシェ",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
459 #else
460                 { "Lo Pan the Sorcerer",        20000,  200, 110,  7,  8, RACE_HALF_ELF},
461                 { "Buggerby the Great",         20000,  215, 113,  6, 10, RACE_GNOME},
462                 { "The Wizard of Yendor",       30000,  200, 110,  7, 10, RACE_HUMAN},
463                 { "Rjak the Necromancer",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
464                 { "Skidney the Sorcerer",        15000,  200, 110,  7,  8, RACE_HALF_ELF},
465                 { "Kyria the Illusionist",       30000,  200, 110,  7, 10, RACE_HUMAN},
466                 { "Nikki the Necromancer",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
467                 { "Solostoran",        15000,  200, 110,  7,  8, RACE_SPRITE},
468                 { "Achshe the Tentacled",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
469                 { "Kaza the Noble",       30000,  200, 110,  7, 10, RACE_HIGH_ELF},
470                 { "Fazzil the Dark",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
471                 { "Keldorn the Grand",        15000,  200, 110,  7,  8, RACE_DWARF},
472                 { "Philanthropus",         20000,  215, 113,  6, 10, RACE_HOBBIT},
473                 { "Agnar the Enchantress",       30000,  200, 110,  7, 10, RACE_HUMAN},
474                 { "Buliance the Necromancer",       30000,  175, 110,  5, 11, RACE_BEASTMAN},
475                 { "Vuirak the High-Mage",        15000,  200, 110,  7,  8, RACE_BEASTMAN},
476                 { "Madish the Smart",         20000,  215, 113,  6, 10, RACE_BEASTMAN},
477                 { "Falebrimbor",       30000,  200, 110,  7, 10, RACE_HIGH_ELF},
478                 { "Felil-Gand the Subtle",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
479                 { "Thalegord the Shaman",        15000,  200, 110,  7,  8, RACE_BARBARIAN},
480                 { "Cthoaloth the Mystic",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
481                 { "Ibeli the Illusionist",       30000,  200, 110,  7, 10, RACE_SKELETON},
482                 { "Heto the Necromancer",       30000,  175, 110,  5, 11, RACE_YEEK},
483                 { "Lo Pan the Sorcerer",        20000,  200, 110,  7,  8, RACE_HALF_ELF},
484                 { "Buggerby the Great",         20000,  215, 113,  6, 10, RACE_GNOME},
485                 { "The Wizard of Yendor",       30000,  200, 110,  7, 10, RACE_HUMAN},
486                 { "Rjak the Necromancer",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
487                 { "Skidney the Sorcerer",        15000,  200, 110,  7,  8, RACE_HALF_ELF},
488                 { "Kyria the Illusionist",       30000,  200, 110,  7, 10, RACE_HUMAN},
489                 { "Nikki the Necromancer",       30000,  175, 110,  5, 11, RACE_DARK_ELF},
490                 { "Solostoran",        15000,  200, 110,  7,  8, RACE_SPRITE},
491                 { "Achshe the Tentacled",         20000,  215, 113,  6, 10, RACE_MIND_FLAYER},
492 #endif
493         },
494         {
495                 /* Black Market - 32 unique names */
496 #ifdef JP
497                 { "ガリー=ギガズ",            20000,  250,  150,  10,   5,  RACE_HALF_TROLL},
498                 { "ゴブリンのヒストーア",       20000,  250,  150,  10,   5,  RACE_HALF_ORC},
499                 { "フェレンギ人クアーク",           30000,  250,  150,  10,   5,  RACE_HUMAN},
500                 { "公正なる(?)トッピ",                     30000,  250,  150,  10,   5,  RACE_ELF},
501                 { "死人ヴァッサ",             20000,  250, 150, 10,  5, RACE_ZOMBIE},
502                 { "裏切り者カイン",          20000,  250, 150, 10,  5, RACE_VAMPIRE},
503                 { "ブボニカス",          30000,  250, 150, 10,  5, RACE_BEASTMAN},
504                 { "コープスライト",           30000,  250, 150, 10,  5, RACE_SPECTRE},
505                 { "血に飢えしパリッシュ",                 20000,  250, 150, 10,  5, RACE_VAMPIRE},
506                 { "ヴァイル",          20000,  250, 150, 10,  5, RACE_SKELETON},
507                 { "信頼のプレンティス",          30000,  250, 150, 10,  5, RACE_SKELETON},
508                 { "人間殺しのグリエラ",           30000,  250, 150, 10,  5, RACE_IMP},
509                 { "エンジェル",                 20000,  250, 150, 10,  5, RACE_VAMPIRE},
510                 { "水膨れフロツァム",          20000,  250, 150, 10,  5, RACE_ZOMBIE},
511                 { "ニーヴァル",          30000,  250, 150, 10,  5, RACE_VAMPIRE},
512                 { "明るいアナスタシア",           30000,  250, 150, 10,  5, RACE_SPECTRE},
513                 { "死霊術師チャリティー", 20000,  250, 150, 10,  5, RACE_DARK_ELF},
514                 { "ボクサーのプグナシオス",          20000,  250, 150, 10,  5, RACE_HALF_ORC},
515                 { "幸運なフットソア",          30000,  250, 150, 10,  5, RACE_BEASTMAN},
516                 { "光指のシドリア",           30000,  250, 150, 10,  5, RACE_HUMAN},
517                 { "手品師リアソー",                 20000,  250, 150, 10,  5, RACE_HOBBIT},
518                 { "やりくり上手のジャナッカ",          20000,  250, 150, 10,  5, RACE_GNOME},
519                 { "悪党シーナ",          30000,  250, 150, 10,  5, RACE_GNOME},
520                 { "大爪アルニッキ",           30000,  250, 150, 10,  5, RACE_DRACONIAN},
521                 { "貧乏チャエアンド",                 20000,  250, 150, 10,  5, RACE_HUMAN},
522                 { "山賊アファードーフ",          20000,  250, 150, 10,  5, RACE_BARBARIAN},
523                 { "強欲ラザクスル",          30000,  250, 150, 10,  5, RACE_MIND_FLAYER},
524                 { "ファラレウィン",           30000,  250, 150, 10,  5, RACE_SPRITE},
525                 { "しわしわヴォスール",                 20000,  250, 150, 10,  5, RACE_NIBELUNG},
526                 { "ハンサムなアラオード",          20000,  250, 150, 10,  5, RACE_AMBERITE},
527                 { "負け犬セラドフリド",          30000,  250, 150, 10,  5, RACE_HUMAN},
528                 { "片足のエルーロ",           30000,  250, 150, 10,  5, RACE_HALF_OGRE},
529 #else
530                 { "Gary Gygaz",                 20000,  250, 150, 10,  5, RACE_HALF_TROLL},
531                 { "Histor the Goblin",          20000,  250, 150, 10,  5, RACE_HALF_ORC},
532                 { "Quark the Ferengi",          30000,  250, 150, 10,  5, RACE_DWARF},
533                 { "Topi the Fair(?)",           30000,  250, 150, 10,  5, RACE_HUMAN},
534                 { "Vhassa the Dead",             20000,  250, 150, 10,  5, RACE_ZOMBIE},
535                 { "Kyn the Treacherous",          20000,  250, 150, 10,  5, RACE_VAMPIRE},
536                 { "Bubonicus",          30000,  250, 150, 10,  5, RACE_BEASTMAN},
537                 { "Corpselight",           30000,  250, 150, 10,  5, RACE_SPECTRE},
538                 { "Parrish the Bloodthirsty",                 20000,  250, 150, 10,  5, RACE_VAMPIRE},
539                 { "Vile",          20000,  250, 150, 10,  5, RACE_SKELETON},
540                 { "Prentice the Trusted",          30000,  250, 150, 10,  5, RACE_SKELETON},
541                 { "Griella Humanslayer",           30000,  250, 150, 10,  5, RACE_IMP},
542                 { "Angel",                 20000,  250, 150, 10,  5, RACE_VAMPIRE},
543                 { "Flotsam the Bloated",          20000,  250, 150, 10,  5, RACE_ZOMBIE},
544                 { "Nieval",          30000,  250, 150, 10,  5, RACE_VAMPIRE},
545                 { "Anastasia the Luminous",           30000,  250, 150, 10,  5, RACE_SPECTRE},
546                 { "Charity the Necromancer", 20000,  250, 150, 10,  5, RACE_DARK_ELF},
547                 { "Pugnacious the Pugilist",          20000,  250, 150, 10,  5, RACE_HALF_ORC},
548                 { "Footsore the Lucky",          30000,  250, 150, 10,  5, RACE_BEASTMAN},
549                 { "Sidria Lighfingered",           30000,  250, 150, 10,  5, RACE_HUMAN},
550                 { "Riatho the Juggler",                 20000,  250, 150, 10,  5, RACE_HOBBIT},
551                 { "Janaaka the Shifty",          20000,  250, 150, 10,  5, RACE_GNOME},
552                 { "Cina the Rogue",          30000,  250, 150, 10,  5, RACE_GNOME},
553                 { "Arunikki Greatclaw",           30000,  250, 150, 10,  5, RACE_DRACONIAN},
554                 { "Chaeand the Poor",                 20000,  250, 150, 10,  5, RACE_HUMAN},
555                 { "Afardorf the Brigand",          20000,  250, 150, 10,  5, RACE_BARBARIAN},
556                 { "Lathaxl the Greedy",          30000,  250, 150, 10,  5, RACE_MIND_FLAYER},
557                 { "Falarewyn",           30000,  250, 150, 10,  5, RACE_SPRITE},
558                 { "Vosur the Wrinkled",                 20000,  250, 150, 10,  5, RACE_NIBELUNG},
559                 { "Araord the Handsome",          20000,  250, 150, 10,  5, RACE_AMBERITE},
560                 { "Theradfrid the Loser",          30000,  250, 150, 10,  5, RACE_HUMAN},
561                 { "One-Legged Eroolo",           30000,  250, 150, 10,  5, RACE_HALF_OGRE},
562 #endif
563         },
564         {
565                 /* Home */
566 #ifdef JP
567                 { "我が家",                          0,      100, 100,  0, 99, 99},
568                 { "我が家",                          0,      100, 100,  0, 99, 99},
569                 { "我が家",                          0,      100, 100,  0, 99, 99},
570                 { "我が家",                          0,      100, 100,  0, 99, 99},
571                 { "我が家",                          0,      100, 100,  0, 99, 99},
572                 { "我が家",                          0,      100, 100,  0, 99, 99},
573                 { "我が家",                          0,      100, 100,  0, 99, 99},
574                 { "我が家",                          0,      100, 100,  0, 99, 99},
575                 { "我が家",                          0,      100, 100,  0, 99, 99},
576                 { "我が家",                          0,      100, 100,  0, 99, 99},
577                 { "我が家",                          0,      100, 100,  0, 99, 99},
578                 { "我が家",                          0,      100, 100,  0, 99, 99},
579                 { "我が家",                          0,      100, 100,  0, 99, 99},
580                 { "我が家",                          0,      100, 100,  0, 99, 99},
581                 { "我が家",                          0,      100, 100,  0, 99, 99},
582                 { "我が家",                          0,      100, 100,  0, 99, 99},
583                 { "我が家",                          0,      100, 100,  0, 99, 99},
584                 { "我が家",                          0,      100, 100,  0, 99, 99},
585                 { "我が家",                          0,      100, 100,  0, 99, 99},
586                 { "我が家",                          0,      100, 100,  0, 99, 99},
587                 { "我が家",                          0,      100, 100,  0, 99, 99},
588                 { "我が家",                          0,      100, 100,  0, 99, 99},
589                 { "我が家",                          0,      100, 100,  0, 99, 99},
590                 { "我が家",                          0,      100, 100,  0, 99, 99},
591                 { "我が家",                          0,      100, 100,  0, 99, 99},
592                 { "我が家",                          0,      100, 100,  0, 99, 99},
593                 { "我が家",                          0,      100, 100,  0, 99, 99},
594                 { "我が家",                          0,      100, 100,  0, 99, 99},
595                 { "我が家",                          0,      100, 100,  0, 99, 99},
596                 { "我が家",                          0,      100, 100,  0, 99, 99},
597                 { "我が家",                          0,      100, 100,  0, 99, 99},
598                 { "我が家",                          0,      100, 100,  0, 99, 99},
599 #else
600                 { "Your home",                          0,      100, 100,  0, 99, 99},
601                 { "Your home",                          0,      100, 100,  0, 99, 99},
602                 { "Your home",                          0,      100, 100,  0, 99, 99},
603                 { "Your home",                          0,      100, 100,  0, 99, 99},
604                 { "Your home",                          0,      100, 100,  0, 99, 99},
605                 { "Your home",                          0,      100, 100,  0, 99, 99},
606                 { "Your home",                          0,      100, 100,  0, 99, 99},
607                 { "Your home",                          0,      100, 100,  0, 99, 99},
608                 { "Your home",                          0,      100, 100,  0, 99, 99},
609                 { "Your home",                          0,      100, 100,  0, 99, 99},
610                 { "Your home",                          0,      100, 100,  0, 99, 99},
611                 { "Your home",                          0,      100, 100,  0, 99, 99},
612                 { "Your home",                          0,      100, 100,  0, 99, 99},
613                 { "Your home",                          0,      100, 100,  0, 99, 99},
614                 { "Your home",                          0,      100, 100,  0, 99, 99},
615                 { "Your home",                          0,      100, 100,  0, 99, 99},
616                 { "Your home",                          0,      100, 100,  0, 99, 99},
617                 { "Your home",                          0,      100, 100,  0, 99, 99},
618                 { "Your home",                          0,      100, 100,  0, 99, 99},
619                 { "Your home",                          0,      100, 100,  0, 99, 99},
620                 { "Your home",                          0,      100, 100,  0, 99, 99},
621                 { "Your home",                          0,      100, 100,  0, 99, 99},
622                 { "Your home",                          0,      100, 100,  0, 99, 99},
623                 { "Your home",                          0,      100, 100,  0, 99, 99},
624                 { "Your home",                          0,      100, 100,  0, 99, 99},
625                 { "Your home",                          0,      100, 100,  0, 99, 99},
626                 { "Your home",                          0,      100, 100,  0, 99, 99},
627                 { "Your home",                          0,      100, 100,  0, 99, 99},
628                 { "Your home",                          0,      100, 100,  0, 99, 99},
629                 { "Your home",                          0,      100, 100,  0, 99, 99},
630                 { "Your home",                          0,      100, 100,  0, 99, 99},
631                 { "Your home",                          0,      100, 100,  0, 99, 99},
632 #endif
633
634         },
635
636         {
637                 /* Bookstore - 21 unique names */
638 #ifdef JP
639                 { "強欲ドラフ", 10000, 175, 108, 4, 12, RACE_HUMAN},
640                 { "賢者オドナー", 15000, 120, 105, 6, 16, RACE_HIGH_ELF},
641                 { "中立のガンダー", 25000, 120, 110, 7, 19, RACE_DARK_ELF},
642                 { "忍耐の人ロ=シャ", 30000, 140, 105, 6, 12, RACE_ELF},
643                 { "ランドルフ・カーター", 15000, 175, 108, 4, 12, RACE_HUMAN},
644                 { "隼のサライ", 15000, 175, 108, 4, 12, RACE_HUMAN},
645                 { "千里眼ボドリル", 20000, 120, 105, 6, 16, RACE_HIGH_ELF},
646                 { "沈黙のヴェオロイン", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
647                 { "学者のヴァンシラス", 30000, 140, 105, 6, 12, RACE_MIND_FLAYER},
648                 { "物書きオセイン", 15000, 175, 108, 4, 12, RACE_SKELETON},
649                 { "本の虫オルヴァー", 20000, 120, 105, 6, 16, RACE_VAMPIRE},
650                 { "浅井墓男", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
651                 { "デスマスク", 30000, 140, 105, 6, 12, RACE_ZOMBIE},
652                 { "学者のアスーヌ", 15000, 175, 108, 4, 12, RACE_MIND_FLAYER},
653                 { "死人のプリランド", 20000, 120, 105, 6, 16, RACE_ZOMBIE},
654                 { "鉄のロナール", 25000, 120, 110, 7, 19, RACE_GOLEM},
655 #else
656                 { "Dolaf the Greedy", 10000, 175, 108, 4, 12, RACE_HUMAN},
657                 { "Odnar the Sage", 15000, 120, 105, 6, 16, RACE_HIGH_ELF},
658                 { "Gandar the Neutral", 25000, 120, 110, 7, 19, RACE_DARK_ELF},
659                 { "Ro-sha the Patient", 30000, 140, 105, 6, 12, RACE_ELF},
660                 { "Randolph Carter", 15000, 175, 108, 4, 12, RACE_HUMAN},
661                 { "Sarai the Swift", 15000, 175, 108, 4, 12, RACE_HUMAN},
662                 { "Bodril the Seer", 20000, 120, 105, 6, 16, RACE_HIGH_ELF},
663                 { "Veloin the Quiet", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
664                 { "Vanthylas the Learned", 30000, 140, 105, 6, 12, RACE_MIND_FLAYER},
665                 { "Ossein the Literate", 15000, 175, 108, 4, 12, RACE_SKELETON},
666                 { "Olvar Bookworm", 20000, 120, 105, 6, 16, RACE_VAMPIRE},
667                 { "Shallowgrave", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
668                 { "Death Mask", 30000, 140, 105, 6, 12, RACE_ZOMBIE},
669                 { "Asuunu the Learned", 15000, 175, 108, 4, 12, RACE_MIND_FLAYER},
670                 { "Prirand the Dead", 20000, 120, 105, 6, 16, RACE_ZOMBIE},
671                 { "Ronar the Iron", 25000, 120, 110, 7, 19, RACE_GOLEM},
672 #endif
673 #ifdef JP
674                 { "ガリル=ガミル", 30000, 140, 105, 6, 12, RACE_ELF},
675                 { "本食いローバグ", 15000, 175, 108, 4, 12, RACE_KOBOLD},
676                 { "キリアリキーク", 20000, 120, 105, 6, 16, RACE_KLACKON},
677                 { "静かなるリリン", 25000, 120, 110, 7, 19, RACE_DWARF},
678                 { "王者イサング", 30000, 140, 105, 6, 12, RACE_HIGH_ELF},
679                 { "強欲ドラフ", 10000, 175, 108, 4, 12, RACE_HUMAN},
680                 { "賢者オドナー", 15000, 120, 105, 6, 16, RACE_HIGH_ELF},
681                 { "中立のガンダー", 25000, 120, 110, 7, 19, RACE_DARK_ELF},
682                 { "忍耐の人ロ=シャ", 30000, 140, 105, 6, 12, RACE_ELF},
683                 { "ランドルフ・カーター", 15000, 175, 108, 4, 12, RACE_HUMAN},
684                 { "隼サライ", 15000, 175, 108, 4, 12, RACE_HUMAN},
685                 { "千里眼ボドリル", 20000, 120, 105, 6, 16, RACE_HIGH_ELF},
686                 { "沈黙のヴェオロイン", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
687                 { "学者のヴァンシラス", 30000, 140, 105, 6, 12, RACE_MIND_FLAYER},
688                 { "物書きオセイン", 15000, 175, 108, 4, 12, RACE_SKELETON},
689                 { "本の虫オルヴァー", 20000, 120, 105, 6, 16, RACE_VAMPIRE},
690 #else
691                 { "Galil-Gamir", 30000, 140, 105, 6, 12, RACE_ELF},
692                 { "Rorbag Book-Eater", 15000, 175, 108, 4, 12, RACE_KOBOLD},
693                 { "Kiriarikirk", 20000, 120, 105, 6, 16, RACE_KLACKON},
694                 { "Rilin the Quiet", 25000, 120, 110, 7, 19, RACE_DWARF},
695                 { "Isung the Lord", 30000, 140, 105, 6, 12, RACE_HIGH_ELF},
696                 { "Dolaf the Greedy", 10000, 175, 108, 4, 12, RACE_HUMAN},
697                 { "Odnar the Sage", 15000, 120, 105, 6, 16, RACE_HIGH_ELF},
698                 { "Gandar the Neutral", 25000, 120, 110, 7, 19, RACE_DARK_ELF},
699                 { "Ro-sha the Patient", 30000, 140, 105, 6, 12, RACE_ELF},
700                 { "Randolph Carter", 15000, 175, 108, 4, 12, RACE_HUMAN},
701                 { "Sarai the Swift", 15000, 175, 108, 4, 12, RACE_HUMAN},
702                 { "Bodril the Seer", 20000, 120, 105, 6, 16, RACE_HIGH_ELF},
703                 { "Veloin the Quiet", 25000, 120, 110, 7, 19, RACE_ZOMBIE},
704                 { "Vanthylas the Learned", 30000, 140, 105, 6, 12, RACE_MIND_FLAYER},
705                 { "Ossein the Literate", 15000, 175, 108, 4, 12, RACE_SKELETON},
706                 { "Olvar Bookworm", 20000, 120, 105, 6, 16, RACE_VAMPIRE},
707 #endif
708         },
709
710         {
711                 /* Museum */
712 #ifdef JP
713                 { "博物館",                          0,      100, 100,  0, 99, 99},
714                 { "博物館",                          0,      100, 100,  0, 99, 99},
715                 { "博物館",                          0,      100, 100,  0, 99, 99},
716                 { "博物館",                          0,      100, 100,  0, 99, 99},
717                 { "博物館",                          0,      100, 100,  0, 99, 99},
718                 { "博物館",                          0,      100, 100,  0, 99, 99},
719                 { "博物館",                          0,      100, 100,  0, 99, 99},
720                 { "博物館",                          0,      100, 100,  0, 99, 99},
721                 { "博物館",                          0,      100, 100,  0, 99, 99},
722                 { "博物館",                          0,      100, 100,  0, 99, 99},
723                 { "博物館",                          0,      100, 100,  0, 99, 99},
724                 { "博物館",                          0,      100, 100,  0, 99, 99},
725                 { "博物館",                          0,      100, 100,  0, 99, 99},
726                 { "博物館",                          0,      100, 100,  0, 99, 99},
727                 { "博物館",                          0,      100, 100,  0, 99, 99},
728                 { "博物館",                          0,      100, 100,  0, 99, 99},
729                 { "博物館",                          0,      100, 100,  0, 99, 99},
730                 { "博物館",                          0,      100, 100,  0, 99, 99},
731                 { "博物館",                          0,      100, 100,  0, 99, 99},
732                 { "博物館",                          0,      100, 100,  0, 99, 99},
733                 { "博物館",                          0,      100, 100,  0, 99, 99},
734                 { "博物館",                          0,      100, 100,  0, 99, 99},
735                 { "博物館",                          0,      100, 100,  0, 99, 99},
736                 { "博物館",                          0,      100, 100,  0, 99, 99},
737                 { "博物館",                          0,      100, 100,  0, 99, 99},
738                 { "博物館",                          0,      100, 100,  0, 99, 99},
739                 { "博物館",                          0,      100, 100,  0, 99, 99},
740                 { "博物館",                          0,      100, 100,  0, 99, 99},
741                 { "博物館",                          0,      100, 100,  0, 99, 99},
742                 { "博物館",                          0,      100, 100,  0, 99, 99},
743                 { "博物館",                          0,      100, 100,  0, 99, 99},
744                 { "博物館",                          0,      100, 100,  0, 99, 99},
745 #else
746                 { "Museum",                          0,      100, 100,  0, 99, 99},
747                 { "Museum",                          0,      100, 100,  0, 99, 99},
748                 { "Museum",                          0,      100, 100,  0, 99, 99},
749                 { "Museum",                          0,      100, 100,  0, 99, 99},
750                 { "Museum",                          0,      100, 100,  0, 99, 99},
751                 { "Museum",                          0,      100, 100,  0, 99, 99},
752                 { "Museum",                          0,      100, 100,  0, 99, 99},
753                 { "Museum",                          0,      100, 100,  0, 99, 99},
754                 { "Museum",                          0,      100, 100,  0, 99, 99},
755                 { "Museum",                          0,      100, 100,  0, 99, 99},
756                 { "Museum",                          0,      100, 100,  0, 99, 99},
757                 { "Museum",                          0,      100, 100,  0, 99, 99},
758                 { "Museum",                          0,      100, 100,  0, 99, 99},
759                 { "Museum",                          0,      100, 100,  0, 99, 99},
760                 { "Museum",                          0,      100, 100,  0, 99, 99},
761                 { "Museum",                          0,      100, 100,  0, 99, 99},
762                 { "Museum",                          0,      100, 100,  0, 99, 99},
763                 { "Museum",                          0,      100, 100,  0, 99, 99},
764                 { "Museum",                          0,      100, 100,  0, 99, 99},
765                 { "Museum",                          0,      100, 100,  0, 99, 99},
766                 { "Museum",                          0,      100, 100,  0, 99, 99},
767                 { "Museum",                          0,      100, 100,  0, 99, 99},
768                 { "Museum",                          0,      100, 100,  0, 99, 99},
769                 { "Museum",                          0,      100, 100,  0, 99, 99},
770                 { "Museum",                          0,      100, 100,  0, 99, 99},
771                 { "Museum",                          0,      100, 100,  0, 99, 99},
772                 { "Museum",                          0,      100, 100,  0, 99, 99},
773                 { "Museum",                          0,      100, 100,  0, 99, 99},
774                 { "Museum",                          0,      100, 100,  0, 99, 99},
775                 { "Museum",                          0,      100, 100,  0, 99, 99},
776                 { "Museum",                          0,      100, 100,  0, 99, 99},
777                 { "Museum",                          0,      100, 100,  0, 99, 99},
778 #endif
779
780         },
781
782 };
783
784 static int cur_store_num = 0;
785 static int store_top = 0;
786 static int store_bottom = 0;
787 static int xtra_stock = 0;
788 static store_type *st_ptr = NULL;
789 static const owner_type *ot_ptr = NULL;
790 static s16b old_town_num = 0;
791 static s16b inner_town_num = 0;
792 #define RUMOR_CHANCE 8
793
794 #define MAX_COMMENT_1   6
795
796 static concptr comment_1[MAX_COMMENT_1] =
797 {
798 #ifdef JP
799         "オーケーだ。",
800         "結構だ。",
801         "そうしよう!",
802         "賛成だ!",
803         "よし!",
804         "わかった!"
805 #else
806         "Okay.",
807         "Fine.",
808         "Accepted!",
809         "Agreed!",
810         "Done!",
811         "Taken!"
812 #endif
813
814 };
815
816 #ifdef JP
817 /*! ブラックマーケット追加メッセージ(承諾) */
818 static concptr comment_1_B[MAX_COMMENT_1] = {
819         "まあ、それでいいや。",
820         "今日はそれで勘弁してやる。",
821         "分かったよ。",
822         "しょうがない。",
823         "それで我慢するよ。",
824         "こんなもんだろう。"
825 };
826 #endif
827 #define MAX_COMMENT_2A  2
828
829 static concptr comment_2a[MAX_COMMENT_2A] =
830 {
831 #ifdef JP
832         "私の忍耐力を試しているのかい? $%s が最後だ。",
833         "我慢にも限度があるぞ。 $%s が最後だ。"
834 #else
835         "You try my patience.  %s is final.",
836         "My patience grows thin.  %s is final."
837 #endif
838
839 };
840
841 #define MAX_COMMENT_2B  12
842
843 static concptr comment_2b[MAX_COMMENT_2B] =
844 {
845 #ifdef JP
846         " $%s ぐらいは出さなきゃダメだよ。",
847         " $%s なら受け取ってもいいが。",
848         "ハ! $%s 以下はないね。",
849         "何て奴だ! $%s 以下はあり得ないぞ。",
850         "それじゃ少なすぎる! $%s は欲しいところだ。",
851         "バカにしている! $%s はもらわないと。",
852         "嘘だろう! $%s でどうだい?",
853         "おいおい! $%s を考えてくれないか?",
854         "1000匹のオークのノミに苦しめられるがいい! $%s だ。",
855         "お前の大切なものに災いあれ! $%s でどうだ。",
856         "モルゴスに賞味されるがいい!本当は $%s なんだろう?",
857         "お前の母親はオーガか! $%s は出すつもりなんだろ?"
858 #else
859         "I can take no less than %s gold pieces.",
860         "I will accept no less than %s gold pieces.",
861         "Ha!  No less than %s gold pieces.",
862         "You knave!  No less than %s gold pieces.",
863         "That's a pittance!  I want %s gold pieces.",
864         "That's an insult!  I want %s gold pieces.",
865         "As if!  How about %s gold pieces?",
866         "My arse!  How about %s gold pieces?",
867         "May the fleas of 1000 orcs molest you!  Try %s gold pieces.",
868         "May your most favourite parts go moldy!  Try %s gold pieces.",
869         "May Morgoth find you tasty!  Perhaps %s gold pieces?",
870         "Your mother was an Ogre!  Perhaps %s gold pieces?"
871 #endif
872
873 };
874
875 #ifdef JP
876 /*! ブラックマーケット用追加メッセージ(売るとき) */
877 static concptr comment_2b_B[MAX_COMMENT_2B] = {
878         "いくら俺様がお人好しとはいえ $%s が限界だね。嫌なら帰りな。",
879         "金がないのかい、あんた?まずは家に帰って $%s 揃えてきな。",
880         "物の価値が分からん奴だな。これは $%s が普通なんだよ。",
881         "俺の付けた値段に文句があるのか? $%s が限界だ。",
882         "ひょっとして新手の冗談かい? $%s 持ってないなら帰りな。",
883         "うちは他の店とは違うんだよ。$%s ぐらいは出しな。",
884         "買う気がないなら帰りな。 $%s だと言っているんだ。",
885         "話にならないね。 $%s くらい持っているんだろ?",
886         "は?なんだそりゃ? $%s の間違いか、ひょっとして?",
887         "出口はあっちだよ。それとも $%s 出せるのかい、あんたに。",
888         "命知らずな奴だな。 $%s 出せば今日の所は勘弁してやるよ。",
889         "うちの店は貧乏人お断りだ。 $%s ぐらい出せないのかい?"
890 };
891 #endif
892 #define MAX_COMMENT_3A  2
893
894 static concptr comment_3a[MAX_COMMENT_3A] =
895 {
896 #ifdef JP
897         "私の忍耐力を試しているのかい? $%s が最後だ。",
898         "我慢にも限度があるぞ。 $%s が最後だ。"
899 #else
900         "You try my patience.  %s is final.",
901         "My patience grows thin.  %s is final."
902 #endif
903
904 };
905
906
907 #define MAX_COMMENT_3B  12
908
909 static concptr comment_3b[MAX_COMMENT_3B] =
910 {
911 #ifdef JP
912         "本音を言うと $%s でいいんだろ?",
913         " $%s でどうだい?",
914         " $%s ぐらいなら出してもいいが。",
915         " $%s 以上払うなんて考えられないね。",
916         "まあ落ちついて。 $%s でどうだい?",
917         "そのガラクタなら $%s で引き取るよ。",
918         "それじゃ高すぎる! $%s がいいとこだろ。",
919         "どうせいらないんだろ! $%s でいいだろ?",
920         "だめだめ! $%s がずっとお似合いだよ。",
921         "バカにしている! $%s がせいぜいだ。",
922         " $%s なら嬉しいところだがなあ。",
923         " $%s 、それ以上はビタ一文出さないよ!"
924 #else
925         "Perhaps %s gold pieces?",
926         "How about %s gold pieces?",
927         "I will pay no more than %s gold pieces.",
928         "I can afford no more than %s gold pieces.",
929         "Be reasonable.  How about %s gold pieces?",
930         "I'll buy it as scrap for %s gold pieces.",
931         "That is too much!  How about %s gold pieces?",
932         "That looks war surplus!  Say %s gold pieces?",
933         "Never!  %s is more like it.",
934         "That's an insult!  %s is more like it.",
935         "%s gold pieces and be thankful for it!",
936         "%s gold pieces and not a copper more!"
937 #endif
938
939 };
940
941 #ifdef JP
942 /*! ブラックマーケット用追加メッセージ(買い取り) */
943 static concptr comment_3b_B[MAX_COMMENT_3B] = {
944         " $%s ってところだね。そのどうしようもないガラクタは。",
945         "この俺が $%s って言っているんだから、その通りにした方が身のためだぞ。",
946         "俺の優しさに甘えるのもいい加減にしておけ。 $%s だ。",
947         "その品なら $%s で売ってくれているがね、常識ある紳士はみんな。",
948         "こりゃまた、がめつい奴だな。いくら俺が温厚とはいえ $%s が限界だ。",
949         " $%s だ。別に俺はそんなガラクタ欲しくはないんだから。",
950         "俺の鑑定額が気に入らないのか? $%s 、嫌なら帰りな。",
951         " $%s で引き取ってやるよ。喜んで受け取りな、貧乏人。",
952         "物の価値が分からん奴は始末におえんな。それは $%s なんだよ。",
953         "そんなに金が欲しいのか、あんた? $%s で満足できんのか?",
954         "入る店間違えてんじゃないのか? $%s で嫌なら他をあたってくれ。",
955         "俺の言い値にケチをつける奴がいるとは! その度胸に免じて $%s だ。"
956 };
957 #endif
958 #define MAX_COMMENT_4A  4
959
960 static concptr comment_4a[MAX_COMMENT_4A] =
961 {
962 #ifdef JP
963         "もうたくさんだ!何度も私をわずらわせないでくれ!",
964         "うがー!一日の我慢の限度を超えている!",
965         "もういい!時間の無駄以外のなにものでもない!",
966         "もうやってられないよ!顔も見たくない!"
967 #else
968         "Enough!  You have abused me once too often!",
969         "Arghhh!  I have had enough abuse for one day!",
970         "That does it!  You shall waste my time no more!",
971         "This is getting nowhere!  I'm going to Londis!"
972 #endif
973
974 };
975
976 #ifdef JP
977 /*! ブラックマーケット用追加メッセージ(怒りの頂点) */
978 static concptr comment_4a_B[MAX_COMMENT_4A] = {
979         "なめやがって!温厚な俺様でも限界があるってことを知れ!",
980         "俺をここまで怒らせて...命があるだけでもありがたいと思え!",
981         "ふざけてるのか!冷やかしなら相手を見てからにしろ!",
982         "いいかげんにしろ!今度こんなまねしたらただじゃおかねえぞ!"
983 };
984 #endif
985 #define MAX_COMMENT_4B  4
986
987 static concptr comment_4b[MAX_COMMENT_4B] =
988 {
989 #ifdef JP
990         "店から出て行け!",
991         "俺の前から消え失せろ!",
992         "どっかに行っちまえ!",
993         "出ろ、出ろ、出て行け!"
994 #else
995         "Leave my store!",
996         "Get out of my sight!",
997         "Begone, you scoundrel!",
998         "Out, out, out!"
999 #endif
1000
1001 };
1002
1003 #ifdef JP
1004 /*! ブラックマーケット用追加メッセージ(追い出し) */
1005 static concptr comment_4b_B[MAX_COMMENT_4B] = {
1006         "二度とうちに来るんじゃねえ!!",
1007         "とっとと、どっかへ失せろ!!",
1008         "今すぐ消え失せろ!!",
1009         "出ていけ!出ていけ!!"
1010 };
1011 #endif
1012 #define MAX_COMMENT_5   8
1013
1014 static concptr comment_5[MAX_COMMENT_5] =
1015 {
1016 #ifdef JP
1017         "考え直してくれ。",
1018         "そりゃおかしい!",
1019         "もっと真面目に言ってくれ!",
1020         "交渉する気があるのかい?",
1021         "冷やかしに来たのか!",
1022         "悪い冗談だ!",
1023         "我慢くらべかい。",
1024         "ふーむ、良い天気だ。"
1025 #else
1026         "Try again.",
1027         "Ridiculous!",
1028         "You will have to do better than that!",
1029         "Do you wish to do business or not?",
1030         "You've got to be kidding!",
1031         "You'd better be kidding!",
1032         "You try my patience.",
1033         "Hmmm, nice weather we're having."
1034 #endif
1035
1036 };
1037
1038 #ifdef JP
1039 /*! ブラックマーケット用追加メッセージ(怒り) */
1040 static concptr comment_5_B[MAX_COMMENT_5] = {
1041         "時間の無駄だな、これは。",
1042         "厄介なお客様だな!",
1043         "話して分かる相手じゃなさそうだ。",
1044         "痛い目にあいたいらしいな!",
1045         "なんて強欲な奴だ!",
1046         "話にならん輩だ!",
1047         "どうしようもない貧乏人だ!",
1048         "喧嘩を売っているのか?"
1049 };
1050 #endif
1051 #define MAX_COMMENT_6   4
1052
1053 static concptr comment_6[MAX_COMMENT_6] =
1054 {
1055 #ifdef JP
1056         "どうやら聞き間違えたらしい。",
1057         "失礼、よく聞こえなかったよ。",
1058         "すまない、何だって?",
1059         "悪い、もう一度言ってくれる?"
1060 #else
1061         "I must have heard you wrong.",
1062         "I'm sorry, I missed that.",
1063         "I'm sorry, what was that?",
1064         "Sorry, what was that again?"
1065 #endif
1066
1067 };
1068
1069 /*** Initialize others ***/
1070
1071 /*!
1072  * 店舗で販売するオブジェクトを定義する / Hack -- Objects sold in the stores -- by tval/sval pair.
1073  */
1074 byte store_table[MAX_STORES][STORE_CHOICES][2] =
1075 {
1076         {
1077                 /* General Store */
1078
1079                 { TV_FOOD, SV_FOOD_RATION },
1080                 { TV_FOOD, SV_FOOD_RATION },
1081                 { TV_FOOD, SV_FOOD_RATION },
1082                 { TV_FOOD, SV_FOOD_RATION },
1083
1084                 { TV_FOOD, SV_FOOD_RATION },
1085                 { TV_FOOD, SV_FOOD_BISCUIT },
1086                 { TV_FOOD, SV_FOOD_JERKY },
1087                 { TV_FOOD, SV_FOOD_JERKY },
1088
1089                 { TV_FOOD, SV_FOOD_PINT_OF_WINE },
1090                 { TV_FOOD, SV_FOOD_PINT_OF_ALE },
1091                 { TV_LITE, SV_LITE_TORCH },
1092                 { TV_LITE, SV_LITE_TORCH },
1093
1094                 { TV_LITE, SV_LITE_TORCH },
1095                 { TV_LITE, SV_LITE_TORCH },
1096                 { TV_LITE, SV_LITE_LANTERN },
1097                 { TV_LITE, SV_LITE_LANTERN },
1098
1099                 { TV_FLASK, 0 },
1100                 { TV_FLASK, 0 },
1101                 { TV_FLASK, 0 },
1102                 { TV_FLASK, 0 },
1103
1104                 { TV_FLASK, 0 },
1105                 { TV_FLASK, 0 },
1106                 { TV_SPIKE, 0 },
1107                 { TV_SPIKE, 0 },
1108
1109                 { TV_SHOT, SV_AMMO_NORMAL },
1110                 { TV_ARROW, SV_AMMO_NORMAL },
1111                 { TV_BOLT, SV_AMMO_NORMAL },
1112                 { TV_DIGGING, SV_SHOVEL },
1113
1114                 { TV_DIGGING, SV_PICK },
1115                 { TV_CLOAK, SV_CLOAK },
1116                 { TV_CLOAK, SV_CLOAK },
1117                 { TV_CLOAK, SV_FUR_CLOAK },
1118
1119                 { TV_FOOD, SV_FOOD_RATION },
1120                 { TV_FOOD, SV_FOOD_RATION },
1121                 { TV_FOOD, SV_FOOD_RATION },
1122                 { TV_FOOD, SV_FOOD_RATION },
1123
1124                 { TV_POTION, SV_POTION_WATER },
1125                 { TV_POTION, SV_POTION_WATER },
1126                 { TV_LITE, SV_LITE_LANTERN },
1127                 { TV_LITE, SV_LITE_LANTERN },
1128
1129                 { TV_FOOD, SV_FOOD_WAYBREAD },
1130                 { TV_FOOD, SV_FOOD_WAYBREAD },
1131                 { TV_CAPTURE, 0 },
1132                 { TV_FIGURINE, 0 },
1133
1134                 { TV_SHOT, SV_AMMO_NORMAL },
1135                 { TV_ARROW, SV_AMMO_NORMAL },
1136                 { TV_BOLT, SV_AMMO_NORMAL },
1137                 { TV_DIGGING, SV_SHOVEL }
1138         },
1139
1140         {
1141                 /* Armoury */
1142
1143                 { TV_BOOTS, SV_PAIR_OF_SOFT_LEATHER_BOOTS },
1144                 { TV_BOOTS, SV_PAIR_OF_SOFT_LEATHER_BOOTS },
1145                 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },
1146                 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },
1147
1148                 { TV_HELM, SV_HARD_LEATHER_CAP },
1149                 { TV_HELM, SV_HARD_LEATHER_CAP },
1150                 { TV_HELM, SV_METAL_CAP },
1151                 { TV_HELM, SV_IRON_HELM },
1152
1153                 { TV_SOFT_ARMOR, SV_ROBE },
1154                 { TV_SOFT_ARMOR, SV_ROBE },
1155                 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },
1156                 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },
1157
1158                 { TV_SOFT_ARMOR, SV_HARD_LEATHER_ARMOR },
1159                 { TV_SOFT_ARMOR, SV_HARD_LEATHER_ARMOR },
1160                 { TV_SOFT_ARMOR, SV_HARD_STUDDED_LEATHER },
1161                 { TV_SOFT_ARMOR, SV_HARD_STUDDED_LEATHER },
1162
1163                 { TV_SOFT_ARMOR, SV_RHINO_HIDE_ARMOR },
1164                 { TV_SOFT_ARMOR, SV_LEATHER_SCALE_MAIL },
1165                 { TV_HARD_ARMOR, SV_METAL_SCALE_MAIL },
1166                 { TV_HARD_ARMOR, SV_CHAIN_MAIL },
1167
1168                 { TV_HARD_ARMOR, SV_DOUBLE_RING_MAIL },
1169                 { TV_HARD_ARMOR, SV_AUGMENTED_CHAIN_MAIL },
1170                 { TV_HARD_ARMOR, SV_BAR_CHAIN_MAIL },
1171                 { TV_HARD_ARMOR, SV_DOUBLE_CHAIN_MAIL },
1172
1173                 { TV_HARD_ARMOR, SV_METAL_BRIGANDINE_ARMOUR },
1174                 { TV_HARD_ARMOR, SV_SPLINT_MAIL },
1175                 { TV_GLOVES, SV_SET_OF_LEATHER_GLOVES },
1176                 { TV_GLOVES, SV_SET_OF_LEATHER_GLOVES },
1177
1178                 { TV_GLOVES, SV_SET_OF_GAUNTLETS },
1179                 { TV_SHIELD, SV_SMALL_LEATHER_SHIELD },
1180                 { TV_SHIELD, SV_LARGE_LEATHER_SHIELD },
1181                 { TV_SHIELD, SV_SMALL_METAL_SHIELD },
1182
1183                 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },
1184                 { TV_BOOTS, SV_PAIR_OF_HARD_LEATHER_BOOTS },
1185                 { TV_HELM, SV_HARD_LEATHER_CAP },
1186                 { TV_HELM, SV_HARD_LEATHER_CAP },
1187
1188                 { TV_SOFT_ARMOR, SV_ROBE },
1189                 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },
1190                 { TV_SOFT_ARMOR, SV_SOFT_LEATHER_ARMOR },
1191                 { TV_SOFT_ARMOR, SV_HARD_LEATHER_ARMOR },
1192
1193                 { TV_SOFT_ARMOR, SV_LEATHER_JACK },
1194                 { TV_HARD_ARMOR, SV_METAL_SCALE_MAIL },
1195                 { TV_HARD_ARMOR, SV_CHAIN_MAIL },
1196                 { TV_HARD_ARMOR, SV_CHAIN_MAIL },
1197
1198                 { TV_GLOVES, SV_SET_OF_LEATHER_GLOVES },
1199                 { TV_GLOVES, SV_SET_OF_GAUNTLETS },
1200                 { TV_SHIELD, SV_SMALL_LEATHER_SHIELD },
1201                 { TV_SHIELD, SV_SMALL_LEATHER_SHIELD }
1202         },
1203
1204         {
1205                 /* Weaponsmith */
1206
1207                 { TV_SWORD, SV_DAGGER },
1208                 { TV_SWORD, SV_MAIN_GAUCHE },
1209                 { TV_SWORD, SV_RAPIER },
1210                 { TV_SWORD, SV_SMALL_SWORD },
1211
1212                 { TV_SWORD, SV_SHORT_SWORD },
1213                 { TV_SWORD, SV_SABRE },
1214                 { TV_SWORD, SV_CUTLASS },
1215                 { TV_SWORD, SV_TULWAR },
1216
1217                 { TV_SWORD, SV_BROAD_SWORD },
1218                 { TV_SWORD, SV_LONG_SWORD },
1219                 { TV_SWORD, SV_SCIMITAR },
1220                 { TV_SWORD, SV_KATANA },
1221
1222                 { TV_SWORD, SV_BASTARD_SWORD },
1223                 { TV_POLEARM, SV_SPEAR },
1224                 { TV_POLEARM, SV_AWL_PIKE },
1225                 { TV_POLEARM, SV_TRIDENT },
1226
1227                 { TV_POLEARM, SV_PIKE },
1228                 { TV_POLEARM, SV_BEAKED_AXE },
1229                 { TV_POLEARM, SV_BROAD_AXE },
1230                 { TV_POLEARM, SV_LANCE },
1231
1232                 { TV_POLEARM, SV_BATTLE_AXE },
1233                 { TV_POLEARM, SV_HATCHET },
1234                 { TV_BOW, SV_SLING },
1235                 { TV_BOW, SV_SHORT_BOW },
1236
1237                 { TV_BOW, SV_LIGHT_XBOW },
1238                 { TV_SHOT, SV_AMMO_NORMAL },
1239                 { TV_SHOT, SV_AMMO_NORMAL },
1240                 { TV_ARROW, SV_AMMO_NORMAL },
1241
1242                 { TV_ARROW, SV_AMMO_NORMAL },
1243                 { TV_BOLT, SV_AMMO_NORMAL },
1244                 { TV_BOLT, SV_AMMO_NORMAL },
1245                 { TV_BOW, SV_LIGHT_XBOW },
1246
1247                 { TV_ARROW, SV_AMMO_NORMAL },
1248                 { TV_BOLT, SV_AMMO_NORMAL },
1249                 { TV_BOW, SV_SHORT_BOW },
1250                 { TV_BOW, SV_LIGHT_XBOW },
1251
1252                 { TV_SWORD, SV_DAGGER },
1253                 { TV_SWORD, SV_TANTO },
1254                 { TV_SWORD, SV_RAPIER },
1255                 { TV_SWORD, SV_SMALL_SWORD },
1256
1257                 { TV_SWORD, SV_SHORT_SWORD },
1258                 { TV_SWORD, SV_LONG_SWORD },
1259                 { TV_SWORD, SV_SCIMITAR },
1260                 { TV_SWORD, SV_BROAD_SWORD },
1261
1262                 { TV_HISSATSU_BOOK, 0 },
1263                 { TV_HISSATSU_BOOK, 0 },
1264                 { TV_HISSATSU_BOOK, 1 },
1265                 { TV_HISSATSU_BOOK, 1 },
1266         },
1267
1268         {
1269                 /* Temple */
1270
1271                 { TV_HAFTED, SV_NUNCHAKU },
1272                 { TV_HAFTED, SV_QUARTERSTAFF },
1273                 { TV_HAFTED, SV_MACE },
1274                 { TV_HAFTED, SV_BO_STAFF },
1275
1276                 { TV_HAFTED, SV_WAR_HAMMER },
1277                 { TV_HAFTED, SV_WAR_HAMMER },
1278                 { TV_HAFTED, SV_MORNING_STAR },
1279                 { TV_HAFTED, SV_FLAIL },
1280
1281                 { TV_HAFTED, SV_LEAD_FILLED_MACE },
1282                 { TV_SCROLL, SV_SCROLL_REMOVE_CURSE },
1283                 { TV_SCROLL, SV_SCROLL_BLESSING },
1284                 { TV_SCROLL, SV_SCROLL_HOLY_CHANT },
1285
1286                 { TV_POTION, SV_POTION_HEROISM },
1287                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1288                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1289                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1290
1291                 { TV_POTION, SV_POTION_CURE_LIGHT },
1292                 { TV_POTION, SV_POTION_CURE_SERIOUS },
1293                 { TV_POTION, SV_POTION_CURE_SERIOUS },
1294                 { TV_POTION, SV_POTION_CURE_CRITICAL },
1295
1296                 { TV_POTION, SV_POTION_CURE_CRITICAL },
1297                 { TV_POTION, SV_POTION_RESTORE_EXP },
1298                 { TV_POTION, SV_POTION_RESTORE_EXP },
1299                 { TV_POTION, SV_POTION_RESTORE_EXP },
1300
1301                 { TV_LIFE_BOOK, 0 },
1302                 { TV_LIFE_BOOK, 0 },
1303                 { TV_LIFE_BOOK, 1 },
1304                 { TV_LIFE_BOOK, 1 },
1305
1306                 { TV_CRUSADE_BOOK, 0 },
1307                 { TV_CRUSADE_BOOK, 0 },
1308                 { TV_CRUSADE_BOOK, 1 },
1309                 { TV_CRUSADE_BOOK, 1 },
1310
1311                 { TV_HAFTED, SV_WHIP },
1312                 { TV_HAFTED, SV_MACE },
1313                 { TV_HAFTED, SV_BALL_AND_CHAIN },
1314                 { TV_HAFTED, SV_WAR_HAMMER },
1315
1316                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1317                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1318                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1319                 { TV_POTION, SV_POTION_CURE_CRITICAL },
1320
1321                 { TV_POTION, SV_POTION_CURE_CRITICAL },
1322                 { TV_POTION, SV_POTION_RESTORE_EXP },
1323
1324                 { TV_FIGURINE, 0 },
1325                 { TV_STATUE, SV_ANY },
1326
1327                 { TV_SCROLL, SV_SCROLL_REMOVE_CURSE },
1328                 { TV_SCROLL, SV_SCROLL_REMOVE_CURSE },
1329                 { TV_SCROLL, SV_SCROLL_STAR_REMOVE_CURSE },
1330                 { TV_SCROLL, SV_SCROLL_STAR_REMOVE_CURSE }
1331         },
1332
1333         {
1334                 /* Alchemy shop */
1335
1336                 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_HIT },
1337                 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_DAM },
1338                 { TV_SCROLL, SV_SCROLL_ENCHANT_ARMOR },
1339                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1340
1341                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1342                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1343                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1344                 { TV_SCROLL, SV_SCROLL_LIGHT },
1345
1346                 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },
1347                 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },
1348                 { TV_SCROLL, SV_SCROLL_TELEPORT },
1349                 { TV_SCROLL, SV_SCROLL_MONSTER_CONFUSION },
1350
1351                 { TV_SCROLL, SV_SCROLL_MAPPING },
1352                 { TV_SCROLL, SV_SCROLL_DETECT_GOLD },
1353                 { TV_SCROLL, SV_SCROLL_DETECT_ITEM },
1354                 { TV_SCROLL, SV_SCROLL_DETECT_TRAP },
1355
1356                 { TV_SCROLL, SV_SCROLL_DETECT_INVIS },
1357                 { TV_SCROLL, SV_SCROLL_RECHARGING },
1358                 { TV_SCROLL, SV_SCROLL_TELEPORT },
1359                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1360
1361                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1362                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1363                 { TV_SCROLL, SV_SCROLL_WORD_OF_RECALL },
1364                 { TV_SCROLL, SV_SCROLL_TELEPORT },
1365
1366                 { TV_SCROLL, SV_SCROLL_TELEPORT },
1367                 { TV_POTION, SV_POTION_RES_STR },
1368                 { TV_POTION, SV_POTION_RES_INT },
1369                 { TV_POTION, SV_POTION_RES_WIS },
1370
1371                 { TV_POTION, SV_POTION_RES_DEX },
1372                 { TV_POTION, SV_POTION_RES_CON },
1373                 { TV_POTION, SV_POTION_RES_CHR },
1374                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1375
1376                 { TV_SCROLL, SV_SCROLL_IDENTIFY },
1377                 { TV_SCROLL, SV_SCROLL_STAR_IDENTIFY },  /* Yep, occasionally! */
1378                 { TV_SCROLL, SV_SCROLL_STAR_IDENTIFY },
1379                 { TV_SCROLL, SV_SCROLL_LIGHT },
1380
1381                 { TV_POTION, SV_POTION_RES_STR },
1382                 { TV_POTION, SV_POTION_RES_INT },
1383                 { TV_POTION, SV_POTION_RES_WIS },
1384                 { TV_POTION, SV_POTION_RES_DEX },
1385
1386                 { TV_POTION, SV_POTION_RES_CON },
1387                 { TV_POTION, SV_POTION_RES_CHR },
1388                 { TV_SCROLL, SV_SCROLL_ENCHANT_ARMOR },
1389                 { TV_SCROLL, SV_SCROLL_ENCHANT_ARMOR },
1390
1391                 { TV_SCROLL, SV_SCROLL_RECHARGING },
1392                 { TV_SCROLL, SV_SCROLL_PHASE_DOOR },
1393                 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_HIT },
1394                 { TV_SCROLL, SV_SCROLL_ENCHANT_WEAPON_TO_DAM },
1395
1396         },
1397
1398         {
1399                 /* Magic-User store */
1400
1401                 { TV_RING, SV_RING_PROTECTION },
1402                 { TV_RING, SV_RING_LEVITATION_FALL },
1403                 { TV_RING, SV_RING_PROTECTION },
1404                 { TV_RING, SV_RING_RESIST_FIRE },
1405
1406                 { TV_RING, SV_RING_RESIST_COLD },
1407                 { TV_AMULET, SV_AMULET_CHARISMA },
1408                 { TV_RING, SV_RING_WARNING },
1409                 { TV_AMULET, SV_AMULET_RESIST_ACID },
1410
1411                 { TV_AMULET, SV_AMULET_SEARCHING },
1412                 { TV_WAND, SV_WAND_SLOW_MONSTER },
1413                 { TV_WAND, SV_WAND_CONFUSE_MONSTER },
1414                 { TV_WAND, SV_WAND_SLEEP_MONSTER },
1415
1416                 { TV_WAND, SV_WAND_MAGIC_MISSILE },
1417                 { TV_WAND, SV_WAND_STINKING_CLOUD },
1418                 { TV_WAND, SV_WAND_WONDER },
1419                 { TV_WAND, SV_WAND_DISARMING },
1420
1421                 { TV_STAFF, SV_STAFF_LITE },
1422                 { TV_STAFF, SV_STAFF_MAPPING },
1423                 { TV_STAFF, SV_STAFF_DETECT_TRAP },
1424                 { TV_STAFF, SV_STAFF_DETECT_DOOR },
1425
1426                 { TV_STAFF, SV_STAFF_DETECT_GOLD },
1427                 { TV_STAFF, SV_STAFF_DETECT_ITEM },
1428                 { TV_STAFF, SV_STAFF_DETECT_INVIS },
1429                 { TV_STAFF, SV_STAFF_DETECT_EVIL },
1430
1431                 { TV_STAFF, SV_STAFF_TELEPORTATION },
1432                 { TV_STAFF, SV_STAFF_TELEPORTATION },
1433                 { TV_STAFF, SV_STAFF_TELEPORTATION },
1434                 { TV_STAFF, SV_STAFF_TELEPORTATION },
1435
1436                 { TV_STAFF, SV_STAFF_IDENTIFY },
1437                 { TV_STAFF, SV_STAFF_IDENTIFY },
1438                 { TV_STAFF, SV_STAFF_IDENTIFY },
1439
1440                 { TV_STAFF, SV_STAFF_IDENTIFY },
1441                 { TV_STAFF, SV_STAFF_REMOVE_CURSE },
1442                 { TV_STAFF, SV_STAFF_CURE_LIGHT },
1443                 { TV_STAFF, SV_STAFF_PROBING },
1444
1445                 { TV_FIGURINE, 0 },
1446
1447                 { TV_SORCERY_BOOK, 0 },
1448                 { TV_SORCERY_BOOK, 0 },
1449                 { TV_SORCERY_BOOK, 1 },
1450                 { TV_SORCERY_BOOK, 1 },
1451
1452                 { TV_ARCANE_BOOK, 0 },
1453                 { TV_ARCANE_BOOK, 0 },
1454                 { TV_ARCANE_BOOK, 1 },
1455                 { TV_ARCANE_BOOK, 1 },
1456
1457                 { TV_ARCANE_BOOK, 2 },
1458                 { TV_ARCANE_BOOK, 2 },
1459                 { TV_ARCANE_BOOK, 3 },
1460                 { TV_ARCANE_BOOK, 3 },
1461
1462         },
1463
1464         {
1465                 /* Black Market (unused) */
1466                 { 0, 0 },
1467                 { 0, 0 },
1468                 { 0, 0 },
1469                 { 0, 0 },
1470                 { 0, 0 },
1471                 { 0, 0 },
1472                 { 0, 0 },
1473                 { 0, 0 },
1474                 { 0, 0 },
1475                 { 0, 0 },
1476                 { 0, 0 },
1477                 { 0, 0 },
1478                 { 0, 0 },
1479                 { 0, 0 },
1480                 { 0, 0 },
1481                 { 0, 0 },
1482                 { 0, 0 },
1483                 { 0, 0 },
1484                 { 0, 0 },
1485                 { 0, 0 },
1486                 { 0, 0 },
1487                 { 0, 0 },
1488                 { 0, 0 },
1489                 { 0, 0 },
1490                 { 0, 0 },
1491                 { 0, 0 },
1492                 { 0, 0 },
1493                 { 0, 0 },
1494                 { 0, 0 },
1495                 { 0, 0 },
1496                 { 0, 0 },
1497                 { 0, 0 }
1498         },
1499
1500         {
1501                 /* Home (unused) */
1502                 { 0, 0 },
1503                 { 0, 0 },
1504                 { 0, 0 },
1505                 { 0, 0 },
1506                 { 0, 0 },
1507                 { 0, 0 },
1508                 { 0, 0 },
1509                 { 0, 0 },
1510                 { 0, 0 },
1511                 { 0, 0 },
1512                 { 0, 0 },
1513                 { 0, 0 },
1514                 { 0, 0 },
1515                 { 0, 0 },
1516                 { 0, 0 },
1517                 { 0, 0 },
1518                 { 0, 0 },
1519                 { 0, 0 },
1520                 { 0, 0 },
1521                 { 0, 0 },
1522                 { 0, 0 },
1523                 { 0, 0 },
1524                 { 0, 0 },
1525                 { 0, 0 },
1526                 { 0, 0 },
1527                 { 0, 0 },
1528                 { 0, 0 },
1529                 { 0, 0 },
1530                 { 0, 0 },
1531                 { 0, 0 },
1532                 { 0, 0 },
1533                 { 0, 0 }
1534         },
1535
1536         {
1537                 /* Bookstore */
1538                 { TV_SORCERY_BOOK, 0 },
1539                 { TV_SORCERY_BOOK, 0 },
1540                 { TV_SORCERY_BOOK, 1 },
1541                 { TV_SORCERY_BOOK, 1 },
1542
1543                 { TV_NATURE_BOOK, 0 },
1544                 { TV_NATURE_BOOK, 0 },
1545                 { TV_NATURE_BOOK, 1 },
1546                 { TV_NATURE_BOOK, 1 },
1547
1548                 { TV_CHAOS_BOOK, 0 },
1549                 { TV_CHAOS_BOOK, 0 },
1550                 { TV_CHAOS_BOOK, 1 },
1551                 { TV_CHAOS_BOOK, 1 },
1552
1553                 { TV_DEATH_BOOK, 0 },
1554                 { TV_DEATH_BOOK, 0 },
1555                 { TV_DEATH_BOOK, 1 },
1556                 { TV_DEATH_BOOK, 1 },
1557
1558                 { TV_TRUMP_BOOK, 0 },           /* +16 */
1559                 { TV_TRUMP_BOOK, 0 },
1560                 { TV_TRUMP_BOOK, 1 },
1561                 { TV_TRUMP_BOOK, 1 },
1562
1563                 { TV_ARCANE_BOOK, 0 },
1564                 { TV_ARCANE_BOOK, 1 },
1565                 { TV_ARCANE_BOOK, 2 },
1566                 { TV_ARCANE_BOOK, 3 },
1567
1568                 { TV_CRAFT_BOOK, 0 },
1569                 { TV_CRAFT_BOOK, 0 },
1570                 { TV_CRAFT_BOOK, 1 },
1571                 { TV_CRAFT_BOOK, 1 },
1572
1573                 { TV_DAEMON_BOOK, 0 },
1574                 { TV_DAEMON_BOOK, 0 },
1575                 { TV_DAEMON_BOOK, 1 },
1576                 { TV_DAEMON_BOOK, 1 },
1577
1578                 { TV_MUSIC_BOOK, 0 },
1579                 { TV_MUSIC_BOOK, 0 },
1580                 { TV_MUSIC_BOOK, 1 },
1581                 { TV_MUSIC_BOOK, 1 },
1582
1583                 { TV_HEX_BOOK, 0 },
1584                 { TV_HEX_BOOK, 0 },
1585                 { TV_HEX_BOOK, 1 },
1586                 { TV_HEX_BOOK, 1 },
1587         },
1588
1589         {
1590                 /* Museum (unused) */
1591                 { 0, 0 },
1592                 { 0, 0 },
1593                 { 0, 0 },
1594                 { 0, 0 },
1595                 { 0, 0 },
1596                 { 0, 0 },
1597                 { 0, 0 },
1598                 { 0, 0 },
1599                 { 0, 0 },
1600                 { 0, 0 },
1601                 { 0, 0 },
1602                 { 0, 0 },
1603                 { 0, 0 },
1604                 { 0, 0 },
1605                 { 0, 0 },
1606                 { 0, 0 },
1607                 { 0, 0 },
1608                 { 0, 0 },
1609                 { 0, 0 },
1610                 { 0, 0 },
1611                 { 0, 0 },
1612                 { 0, 0 },
1613                 { 0, 0 },
1614                 { 0, 0 },
1615                 { 0, 0 },
1616                 { 0, 0 },
1617                 { 0, 0 },
1618                 { 0, 0 },
1619                 { 0, 0 },
1620                 { 0, 0 },
1621                 { 0, 0 },
1622                 { 0, 0 }
1623         }
1624 };
1625
1626
1627
1628 /*!
1629  * @brief 取引成功時の店主のメッセージ処理 /
1630  * Successful haggle.
1631  * @return なし
1632  */
1633 static void say_comment_1(void)
1634 {
1635 #ifdef JP
1636         /* ブラックマーケットのときは別のメッセージを出す */
1637         if ( cur_store_num == STORE_BLACK ) {
1638                 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
1639         }
1640         else{
1641                 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
1642         }
1643 #else
1644         msg_print(comment_1[randint0(MAX_COMMENT_1)]);
1645 #endif
1646
1647
1648         if (one_in_(RUMOR_CHANCE))
1649         {
1650 #ifdef JP
1651                 msg_print("店主は耳うちした:");
1652 #else
1653                 msg_print("The shopkeeper whispers something into your ear:");
1654 #endif
1655                 display_rumor(TRUE);
1656         }
1657 }
1658
1659
1660 /*!
1661  * @brief プレイヤーがアイテムを買う時の価格代案メッセージ処理 /
1662  * Continue haggling (player is buying)
1663  * @param value 店主の提示価格
1664  * @param annoyed 店主のいらつき度
1665  * @return なし
1666  */
1667 static void say_comment_2(PRICE value, int annoyed)
1668 {
1669         char    tmp_val[80];
1670
1671         /* Prepare a string to insert */
1672         sprintf(tmp_val, "%ld", (long)value);
1673
1674         /* Final offer */
1675         if (annoyed > 0)
1676         {
1677                 /* Formatted message */
1678                 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
1679         }
1680
1681         /* Normal offer */
1682         else
1683         {
1684                 /* Formatted message */
1685 #ifdef JP
1686                 /* ブラックマーケットの時は別のメッセージを出す */
1687                 if ( cur_store_num == STORE_BLACK ){
1688                         msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
1689                 }
1690                 else{
1691                 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
1692         }
1693 #else
1694                 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
1695 #endif
1696
1697         }
1698 }
1699
1700
1701 /*!
1702  * @brief プレイヤーがアイテムを売る時の価格代案メッセージ処理 /
1703  * Continue haggling (player is selling)
1704  * @param value 店主の提示価格
1705  * @param annoyed 店主のいらつき度
1706  * @return なし
1707  */
1708 static void say_comment_3(PRICE value, int annoyed)
1709 {
1710         char    tmp_val[80];
1711
1712         /* Prepare a string to insert */
1713         sprintf(tmp_val, "%ld", (long)value);
1714
1715         /* Final offer */
1716         if (annoyed > 0)
1717         {
1718                 /* Formatted message */
1719                 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
1720         }
1721
1722         /* Normal offer */
1723         else
1724         {
1725                 /* Formatted message */
1726 #ifdef JP
1727                 /* ブラックマーケットの時は別のメッセージを出す */
1728                 if ( cur_store_num == STORE_BLACK ){
1729                         msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
1730                 }
1731                 else{
1732                 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
1733         }
1734 #else
1735                 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
1736 #endif
1737
1738         }
1739 }
1740
1741
1742 /*!
1743  * @brief 店主がプレイヤーを追い出す時のメッセージ処理 /
1744  * Kick 'da bum out.                                    -RAK-
1745  * @return なし
1746  */
1747 static void say_comment_4(void)
1748 {
1749 #ifdef JP
1750         /* ブラックマーケットの時は別のメッセージを出す */
1751         if ( cur_store_num == STORE_BLACK ){
1752                 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
1753                 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
1754         }
1755         else{
1756                 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
1757                 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
1758         }
1759 #else
1760         msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
1761         msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
1762 #endif
1763
1764 }
1765
1766
1767 /*!
1768  * @brief 店主がプレイヤーに取り合わない時のメッセージ処理 /
1769  * You are insulting me
1770  * @return なし
1771  */
1772 static void say_comment_5(void)
1773 {
1774 #ifdef JP
1775         /* ブラックマーケットの時は別のメッセージを出す */
1776         if ( cur_store_num == STORE_BLACK ){
1777                 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
1778         }
1779         else{
1780                 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
1781         }
1782 #else
1783         msg_print(comment_5[randint0(MAX_COMMENT_5)]);
1784 #endif
1785
1786 }
1787
1788
1789 /*!
1790  * @brief 店主がプレイヤーの提示を理解できなかった時のメッセージ処理 /
1791  * That makes no sense.
1792  * @return なし
1793  */
1794 static void say_comment_6(void)
1795 {
1796         msg_print(comment_6[randint0(MAX_COMMENT_6)]);
1797 }
1798
1799
1800 #define MAX_COMMENT_7A  4
1801
1802 static concptr comment_7a[MAX_COMMENT_7A] =
1803 {
1804 #ifdef JP
1805         "うわああぁぁ!",
1806         "なんてこった!",
1807         "誰かがむせび泣く声が聞こえる...。",
1808         "店主が悔しげにわめいている!"
1809 #else
1810         "Arrgghh!",
1811         "You bastard!",
1812         "You hear someone sobbing...",
1813         "The shopkeeper howls in agony!"
1814 #endif
1815
1816 };
1817
1818 #define MAX_COMMENT_7B  4
1819
1820 static concptr comment_7b[MAX_COMMENT_7B] =
1821 {
1822 #ifdef JP
1823         "くそう!",
1824         "この悪魔め!",
1825         "店主が恨めしそうに見ている。",
1826         "店主が睨んでいる。"
1827 #else
1828         "Damn!",
1829         "You fiend!",
1830         "The shopkeeper curses at you.",
1831         "The shopkeeper glares at you."
1832 #endif
1833
1834 };
1835
1836 #define MAX_COMMENT_7C  4
1837
1838 static concptr comment_7c[MAX_COMMENT_7C] =
1839 {
1840 #ifdef JP
1841         "すばらしい!",
1842         "君が天使に見えるよ!",
1843         "店主がクスクス笑っている。",
1844         "店主が大声で笑っている。"
1845 #else
1846         "Cool!",
1847         "You've made my day!",
1848         "The shopkeeper giggles.",
1849         "The shopkeeper laughs loudly."
1850 #endif
1851
1852 };
1853
1854 #define MAX_COMMENT_7D  4
1855
1856 static concptr comment_7d[MAX_COMMENT_7D] =
1857 {
1858 #ifdef JP
1859         "やっほぅ!",
1860         "こんなおいしい思いをしたら、真面目に働けなくなるなぁ。",
1861         "店主は嬉しくて跳ね回っている。",
1862         "店主は満面に笑みをたたえている。"
1863 #else
1864         "Yipee!",
1865         "I think I'll retire!",
1866         "The shopkeeper jumps for joy.",
1867         "The shopkeeper smiles gleefully."
1868 #endif
1869
1870 };
1871
1872
1873 /*!
1874  * @brief 店主が交渉を終えた際の反応を返す処理 /
1875  * Let a shop-keeper React to a purchase
1876  * @param price アイテムの取引額
1877  * @param value アイテムの実際価値
1878  * @param guess 店主が当初予想していた価値
1879  * @return なし
1880  * @details 
1881  * We paid "price", it was worth "value", and we thought it was worth "guess"
1882  */
1883 static void purchase_analyze(PRICE price, PRICE value, PRICE guess)
1884 {
1885         /* Item was worthless, but we bought it */
1886         if ((value <= 0) && (price > value))
1887         {
1888                 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
1889                 chg_virtue(V_HONOUR, -1);
1890                 chg_virtue(V_JUSTICE, -1);
1891                 sound(SOUND_STORE1);
1892         }
1893
1894         /* Item was cheaper than we thought, and we paid more than necessary */
1895         else if ((value < guess) && (price > value))
1896         {
1897                 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
1898                 chg_virtue(V_JUSTICE, -1);
1899                 if (one_in_(4)) chg_virtue(V_HONOUR, -1);
1900                 sound(SOUND_STORE2);
1901         }
1902
1903         /* Item was a good bargain, and we got away with it */
1904         else if ((value > guess) && (value < (4 * guess)) && (price < value))
1905         {
1906                 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
1907                 if (one_in_(4)) chg_virtue(V_HONOUR, -1);
1908                 else if (one_in_(4)) chg_virtue(V_HONOUR, 1);
1909                 sound(SOUND_STORE3);
1910         }
1911
1912         /* Item was a great bargain, and we got away with it */
1913         else if ((value > guess) && (price < value))
1914         {
1915                 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
1916                 if (one_in_(2)) chg_virtue(V_HONOUR, -1);
1917                 if (one_in_(4)) chg_virtue(V_HONOUR, 1);
1918                 if (10 * price < value) chg_virtue(V_SACRIFICE, 1);
1919                 sound(SOUND_STORE4);
1920         }
1921 }
1922
1923
1924
1925 /*
1926  * We store the current "store feat" here so everyone can access it
1927  */
1928 static int cur_store_feat;
1929
1930
1931 /*
1932  * Buying and selling adjustments for race combinations.
1933  * Entry[owner][player] gives the basic "cost inflation".
1934  */
1935 static byte rgold_adj[MAX_RACES][MAX_RACES] =
1936 {
1937         /*Hum, HfE, Elf,  Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
1938          HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
1939          Imp,  Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
1940          Angel, Demon, Kutar, Android, Merfolk */
1941
1942         /* Human */
1943         { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
1944           124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
1945           115, 105, 125, 125, 125, 125, 105, 120, 105,  95, 140,
1946           100, 120, 110, 105, 110 },
1947
1948         /* Half-Elf */
1949         { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
1950           120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
1951           120, 110, 110, 110, 120, 110, 100, 125, 100,  95, 140,
1952           110, 115, 110, 110, 110 },
1953
1954         /* Elf */
1955         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
1956           120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
1957           120, 115, 110, 110, 120, 110, 100, 125, 100,  95, 140,
1958           110, 110, 105, 110, 110 },
1959
1960         /* Halfling */
1961         { 115, 110, 105,  95, 105, 110, 115, 130, 115, 105, 115,
1962           125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
1963           120, 110, 120, 120, 130, 110, 110, 130, 110,  95, 140,
1964           115, 120, 105, 115, 105 },
1965
1966         /* Gnome */
1967         { 115, 115, 110, 105,  95, 110, 115, 130, 115, 110, 115,
1968           120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
1969           120, 101, 110, 110, 120, 120, 115, 130, 115,  95, 140,
1970           115, 110, 110, 115, 110 },
1971
1972         /* Dwarf */
1973         { 115, 120, 120, 110, 110,  95, 125, 135, 115, 120, 115,
1974           125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
1975           120, 105, 115, 115, 115, 115, 120, 130, 120,  95, 140,
1976           115, 110, 115, 115, 120 },
1977
1978         /* Half-Orc */
1979         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
1980           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
1981           115, 125, 120, 120, 115, 120, 125, 115, 125,  95, 140,
1982           115, 110, 115, 115, 125 },
1983
1984         /* Half-Troll */
1985         { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
1986           110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
1987           110, 115, 112, 112, 115, 112, 120, 110, 120,  95, 140,
1988           110, 110, 115, 110, 130 },
1989
1990         /* Amberite */
1991         { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
1992           120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
1993           120, 105, 120, 120, 125, 120, 105, 135, 105,  95, 140,
1994           100, 110, 110, 100, 110 },
1995
1996         /* High_Elf */
1997         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
1998           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
1999           125, 115, 120, 120, 125, 120, 100, 125, 100,  95, 140,
2000           110, 110, 105, 110, 110 },
2001
2002         /* Human / Barbarian (copied from human) */
2003         { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
2004           124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
2005           115, 105, 125, 125, 130, 125, 115, 120, 115,  95, 140,
2006           100, 120, 110, 100, 110 },
2007
2008         /* Half-Ogre: theoretical, copied from half-troll */
2009         { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
2010           110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
2011           110, 115, 112, 112, 115, 112, 120, 110, 120,  95, 140,
2012           110, 110, 115, 110, 120 },
2013
2014         /* Half-Giant: theoretical, copied from half-troll */
2015         { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
2016           110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
2017           110, 115, 112, 112, 115, 112, 130, 120, 130,  95, 140,
2018           110, 110, 115, 110, 115 },
2019
2020         /* Half-Titan: theoretical, copied from High_Elf */
2021         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2022           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2023           125, 115, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2024           110, 110, 115, 110, 108 },
2025
2026         /* Cyclops: theoretical, copied from half-troll */
2027         { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
2028           110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
2029           110, 115, 112, 112, 115, 112, 130, 130, 130,  95, 140,
2030           110, 110, 115, 110, 115 },
2031
2032         /* Yeek: theoretical, copied from Half-Orc */
2033         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2034           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2035           115, 125, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2036           115, 110, 115, 115, 110 },
2037
2038         /* Klackon: theoretical, copied from Gnome */
2039         { 115, 115, 110, 105,  95, 110, 115, 130, 115, 110, 115,
2040           120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
2041           120, 101, 110, 110, 120, 120, 130, 130, 130,  95, 140,
2042           115, 110, 115, 115, 110 },
2043
2044         /* Kobold: theoretical, copied from Half-Orc */
2045         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2046           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2047           115, 125, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2048           115, 110, 115, 115, 120 },
2049
2050         /* Nibelung: theoretical, copied from Dwarf */
2051         { 115, 120, 120, 110, 110,  95, 125, 135, 115, 120, 115,
2052           125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
2053           120, 105, 115, 115, 120, 120, 130, 130, 130,  95, 140,
2054           115, 135, 115, 115, 120 },
2055
2056         /* Dark Elf */
2057         { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
2058           115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
2059           110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
2060           110, 101, 115, 110, 115 },
2061
2062         /* Draconian: theoretical, copied from High_Elf */
2063         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2064           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2065           125, 115, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2066           110, 110, 115, 110, 115 },
2067
2068         /* Mind Flayer: theoretical, copied from High_Elf */
2069         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2070           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2071           125, 115, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2072           110, 110, 115, 110, 110 },
2073
2074         /* Imp: theoretical, copied from High_Elf */
2075         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2076           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2077           125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2078           110, 110, 115, 110, 120 },
2079
2080         /* Golem: theoretical, copied from High_Elf */
2081         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2082           125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
2083           125, 115, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2084           110, 110, 115, 110, 110 },
2085
2086         /* Skeleton: theoretical, copied from half-orc */
2087         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2088           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2089           115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2090           115, 110, 125, 115, 110 },
2091
2092         /* Zombie: Theoretical, copied from half-orc */
2093         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2094           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2095           115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2096           115, 110, 125, 115, 110 },
2097
2098         /* Vampire: Theoretical, copied from half-orc */
2099         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2100           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2101           115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2102           115, 110, 125, 115, 120 },
2103
2104         /* Spectre: Theoretical, copied from half-orc */
2105         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2106           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2107           115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
2108           115, 110, 125, 115, 110 },
2109
2110         /* Sprite: Theoretical, copied from half-orc */
2111         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2112           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2113           115, 125, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2114           115, 110, 105, 115, 110 },
2115
2116         /* Beastman: Theoretical, copied from half-orc */
2117         { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
2118           110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
2119           115, 125, 120, 120, 120, 120, 130, 130, 130,  95, 140,
2120           115, 110, 115, 115, 125 },
2121
2122         /* Ent */
2123         { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
2124           120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
2125           120, 115, 110, 110, 120, 110, 100, 125, 100,  95, 140,
2126           110, 110, 105, 110, 110 },
2127
2128         /* Angel */
2129         {  95,  95,  95,  95,  95,  95,  95,  95,  95,  95,  95,
2130            95,  95,  95,  95,  95,  95,  95,  95,  95,  95,  95,
2131            95,  95,  95,  95,  95,  95,  95,  95,  95,  95, 160,
2132            95,  95,  95,  95,  95 },
2133
2134         /* Demon */
2135         { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
2136           140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
2137           140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
2138           140, 140, 140, 140, 140 },
2139
2140         /* Dunadan */
2141         { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
2142           124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
2143           115, 105, 125, 125, 125, 125, 105, 120, 105,  95, 140,
2144           100, 120, 110, 100, 110 },
2145
2146         /* Shadow Fairy */
2147         { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
2148           115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
2149           110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
2150           110, 101, 115, 110, 115 },
2151
2152         /* Kutar */
2153         { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
2154           115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
2155           115, 115, 125, 125, 125, 125, 105, 115, 105,  95, 140,
2156           110, 115, 100, 110, 110 },
2157
2158         /* Android */
2159         { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
2160           124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
2161           115, 105, 125, 125, 125, 125, 105, 120, 105,  95, 140,
2162           100, 120, 110, 100, 110 },
2163
2164         /* Merfolk */
2165         { 110, 110, 110, 105, 110, 120, 125, 130, 110, 110, 110,
2166           120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
2167           120, 110, 110, 110, 120, 110, 110, 125, 110,  95, 140,
2168           110, 115, 110, 110, 100 },
2169 };
2170
2171
2172
2173 /*!
2174  * @brief 店舗価格を決定する /
2175  * Determine the price of an item (qty one) in a store.
2176  * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
2177  * @param greed 店主の強欲度
2178  * @param flip TRUEならば店主にとっての買取価格、FALSEなら売出価格を計算
2179  * @return なし
2180  * @details 
2181  * <pre>
2182  * This function takes into account the player's charisma, and the
2183  * shop-keepers friendliness, and the shop-keeper's base greed, but
2184  * never lets a shop-keeper lose money in a transaction.
2185  * The "greed" value should exceed 100 when the player is "buying" the
2186  * item, and should be less than 100 when the player is "selling" it.
2187  * Hack -- the black market always charges twice as much as it should.
2188  * Charisma adjustment runs from 80 to 130
2189  * Racial adjustment runs from 95 to 130
2190  * Since greed/charisma/racial adjustments are centered at 100, we need
2191  * to adjust (by 200) to extract a usable multiplier.  Note that the
2192  * "greed" value is always something (?).
2193  * </pre>
2194  */
2195 static s32b price_item(object_type *o_ptr, int greed, bool flip)
2196 {
2197         int     factor;
2198         int     adjust;
2199         s32b    price;
2200
2201
2202         /* Get the value of one of the items */
2203         price = object_value(o_ptr);
2204
2205         /* Worthless items */
2206         if (price <= 0) return (0L);
2207
2208
2209         /* Compute the racial factor */
2210         factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
2211
2212         /* Add in the charisma factor */
2213         factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
2214
2215
2216         /* Shop is buying */
2217         if (flip)
2218         {
2219                 /* Adjust for greed */
2220                 adjust = 100 + (300 - (greed + factor));
2221
2222                 /* Never get "silly" */
2223                 if (adjust > 100) adjust = 100;
2224
2225                 /* Mega-Hack -- Black market sucks */
2226                 if (cur_store_num == STORE_BLACK)
2227                         price = price / 2;
2228
2229                 /* Compute the final price (with rounding) */
2230                 /* Hack -- prevent underflow */
2231                 price = (price * adjust + 50L) / 100L;
2232         }
2233
2234         /* Shop is selling */
2235         else
2236         {
2237                 /* Adjust for greed */
2238                 adjust = 100 + ((greed + factor) - 300);
2239
2240                 /* Never get "silly" */
2241                 if (adjust < 100) adjust = 100;
2242
2243                 /* Mega-Hack -- Black market sucks */
2244                 if (cur_store_num == STORE_BLACK)
2245                         price = price * 2;
2246
2247                 /* Compute the final price (with rounding) */
2248                 /* Hack -- prevent overflow */
2249                 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
2250         }
2251
2252         /* Note -- Never become "free" */
2253         if (price <= 0L) return (1L);
2254
2255         /* Return the price */
2256         return (price);
2257 }
2258
2259
2260 /*!
2261  * @brief 安価な消耗品の販売数を増やし、低確率で割引にする /
2262  * Certain "cheap" objects should be created in "piles"
2263  * @param o_ptr 店舗に並べるオブジェクト構造体の参照ポインタ
2264  * @return なし
2265  * @details 
2266  * <pre>
2267  * Some objects can be sold at a "discount" (in small piles)
2268  * </pre>
2269  */
2270 static void mass_produce(object_type *o_ptr)
2271 {
2272         int size = 1;
2273         DISCOUNT_RATE discount = 0;
2274
2275         PRICE cost = object_value(o_ptr);
2276
2277
2278         /* Analyze the type */
2279         switch (o_ptr->tval)
2280         {
2281                 /* Food, Flasks, and Lites */
2282                 case TV_FOOD:
2283                 case TV_FLASK:
2284                 case TV_LITE:
2285                 {
2286                         if (cost <= 5L) size += damroll(3, 5);
2287                         if (cost <= 20L) size += damroll(3, 5);
2288                         if (cost <= 50L) size += damroll(2, 2);
2289                         break;
2290                 }
2291
2292                 case TV_POTION:
2293                 case TV_SCROLL:
2294                 {
2295                         if (cost <= 60L) size += damroll(3, 5);
2296                         if (cost <= 240L) size += damroll(1, 5);
2297                         if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
2298                         if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
2299                         break;
2300                 }
2301
2302                 case TV_LIFE_BOOK:
2303                 case TV_SORCERY_BOOK:
2304                 case TV_NATURE_BOOK:
2305                 case TV_CHAOS_BOOK:
2306                 case TV_DEATH_BOOK:
2307                 case TV_TRUMP_BOOK:
2308                 case TV_ARCANE_BOOK:
2309                 case TV_CRAFT_BOOK:
2310                 case TV_DAEMON_BOOK:
2311                 case TV_CRUSADE_BOOK:
2312                 case TV_MUSIC_BOOK:
2313                 case TV_HISSATSU_BOOK:
2314                 case TV_HEX_BOOK:
2315                 {
2316                         if (cost <= 50L) size += damroll(2, 3);
2317                         if (cost <= 500L) size += damroll(1, 3);
2318                         break;
2319                 }
2320
2321                 case TV_SOFT_ARMOR:
2322                 case TV_HARD_ARMOR:
2323                 case TV_SHIELD:
2324                 case TV_GLOVES:
2325                 case TV_BOOTS:
2326                 case TV_CLOAK:
2327                 case TV_HELM:
2328                 case TV_CROWN:
2329                 case TV_SWORD:
2330                 case TV_POLEARM:
2331                 case TV_HAFTED:
2332                 case TV_DIGGING:
2333                 case TV_BOW:
2334                 {
2335                         if (object_is_artifact(o_ptr)) break;
2336                         if (object_is_ego(o_ptr)) break;
2337                         if (cost <= 10L) size += damroll(3, 5);
2338                         if (cost <= 100L) size += damroll(3, 5);
2339                         break;
2340                 }
2341
2342                 case TV_SPIKE:
2343                 case TV_SHOT:
2344                 case TV_ARROW:
2345                 case TV_BOLT:
2346                 {
2347                         if (cost <= 5L) size += damroll(5, 5);
2348                         if (cost <= 50L) size += damroll(5, 5);
2349                         if (cost <= 500L) size += damroll(5, 5);
2350                         break;
2351                 }
2352
2353                 case TV_FIGURINE:
2354                 {
2355                         if (cost <= 100L) size += damroll(2, 2);
2356                         if (cost <= 1000L) size += damroll(2, 2);
2357                         break;
2358                 }
2359
2360                 case TV_CAPTURE:
2361                 case TV_STATUE:
2362                 case TV_CARD:
2363                 {
2364                         size = 1;
2365                         break;
2366                 }
2367
2368                 /*
2369                  * Because many rods (and a few wands and staffs) are useful mainly
2370                  * in quantity, the Black Market will occasionally have a bunch of
2371                  * one kind. -LM-
2372                  */
2373                 case TV_ROD:
2374                 case TV_WAND:
2375                 case TV_STAFF:
2376                 {
2377                         if ((cur_store_num == STORE_BLACK) && one_in_(3))
2378                         {
2379                                 if (cost < 1601L) size += damroll(1, 5);
2380                                 else if (cost < 3201L) size += damroll(1, 3);
2381                         }
2382                         break;
2383                 }
2384         }
2385
2386
2387         /* Pick a discount */
2388         if (cost < 5)
2389         {
2390                 discount = 0;
2391         }
2392         else if (one_in_(25))
2393         {
2394                 discount = 25;
2395         }
2396         else if (one_in_(150))
2397         {
2398                 discount = 50;
2399         }
2400         else if (one_in_(300))
2401         {
2402                 discount = 75;
2403         }
2404         else if (one_in_(500))
2405         {
2406                 discount = 90;
2407         }
2408
2409         if (o_ptr->art_name)
2410         {
2411                 discount = 0;
2412         }
2413
2414         /* Save the discount */
2415         o_ptr->discount = discount;
2416
2417         /* Save the total pile size */
2418         o_ptr->number = size - (size * discount / 100);
2419
2420         /* Ensure that mass-produced rods and wands get the correct pvals. */
2421         if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
2422         {
2423                 o_ptr->pval *= (PARAMETER_VALUE)o_ptr->number;
2424         }
2425 }
2426
2427
2428
2429 /*!
2430  * @brief 店舗に並べた品を同一品であるかどうか判定する /
2431  * Determine if a store item can "absorb" another item
2432  * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
2433  * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
2434  * @return 同一扱いできるならTRUEを返す
2435  * @details 
2436  * <pre>
2437  * See "object_similar()" for the same function for the "player"
2438  * </pre>
2439  */
2440 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
2441 {
2442         int i;
2443
2444         /* Hack -- Identical items cannot be stacked */
2445         if (o_ptr == j_ptr) return (0);
2446
2447         /* Different objects cannot be stacked */
2448         if (o_ptr->k_idx != j_ptr->k_idx) return (0);
2449
2450         /* Different charges (etc) cannot be stacked, unless wands or rods. */
2451         if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
2452
2453         /* Require many identical values */
2454         if (o_ptr->to_h != j_ptr->to_h) return (0);
2455         if (o_ptr->to_d != j_ptr->to_d) return (0);
2456         if (o_ptr->to_a != j_ptr->to_a) return (0);
2457
2458         /* Require identical "ego-item" names */
2459         if (o_ptr->name2 != j_ptr->name2) return (0);
2460
2461         /* Artifacts don't stack! */
2462         if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
2463
2464         /* Hack -- Identical art_flags! */
2465         for (i = 0; i < TR_FLAG_SIZE; i++)
2466                 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
2467
2468         /* Hack -- Never stack "powerful" items */
2469         if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
2470
2471         /* Hack -- Never stack recharging items */
2472         if (o_ptr->timeout || j_ptr->timeout) return (0);
2473
2474         /* Require many identical values */
2475         if (o_ptr->ac != j_ptr->ac)   return (0);
2476         if (o_ptr->dd != j_ptr->dd)   return (0);
2477         if (o_ptr->ds != j_ptr->ds)   return (0);
2478
2479         /* Hack -- Never stack chests */
2480         if (o_ptr->tval == TV_CHEST) return (0);
2481         if (o_ptr->tval == TV_STATUE) return (0);
2482         if (o_ptr->tval == TV_CAPTURE) return (0);
2483
2484         /* Require matching discounts */
2485         if (o_ptr->discount != j_ptr->discount) return (0);
2486
2487         /* They match, so they must be similar */
2488         return (TRUE);
2489 }
2490
2491
2492 /*!
2493  * @brief 店舗に並べた品を重ね合わせできるかどうか判定する /
2494  * Allow a store item to absorb another item
2495  * @param o_ptr 判定するオブジェクト構造体の参照ポインタ1
2496  * @param j_ptr 判定するオブジェクト構造体の参照ポインタ2
2497  * @return 重ね合わせできるならTRUEを返す
2498  * @details 
2499  * <pre>
2500  * See "object_similar()" for the same function for the "player"
2501  * </pre>
2502  */
2503 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
2504 {
2505         int max_num = (o_ptr->tval == TV_ROD) ?
2506                 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
2507         int total = o_ptr->number + j_ptr->number;
2508         int diff = (total > max_num) ? total - max_num : 0;
2509
2510         /* Combine quantity, lose excess items */
2511         o_ptr->number = (total > max_num) ? max_num : total;
2512
2513         /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
2514         if (o_ptr->tval == TV_ROD)
2515         {
2516                 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
2517         }
2518
2519         /* Hack -- if wands are stacking, combine the charges. -LM- */
2520         if (o_ptr->tval == TV_WAND)
2521         {
2522                 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
2523         }
2524 }
2525
2526
2527 /*!
2528  * @brief 店舗に品を置くスペースがあるかどうかの判定を返す /
2529  * Check to see if the shop will be carrying too many objects   -RAK-
2530  * @param o_ptr 店舗に置きたいオブジェクト構造体の参照ポインタ
2531  * @return 置き場がないなら0、重ね合わせできるアイテムがあるなら-1、スペースがあるなら1を返す。
2532  * @details 
2533  * <pre>
2534  * Note that the shop, just like a player, will not accept things
2535  * it cannot hold.      Before, one could "nuke" potions this way.
2536  * Return value is now int:
2537  *  0 : No space
2538  * -1 : Can be combined to existing slot.
2539  *  1 : Cannot be combined but there are empty spaces.
2540  * </pre>
2541  */
2542 static int store_check_num(object_type *o_ptr)
2543 {
2544         int i;
2545         object_type *j_ptr;
2546
2547         /* The "home" acts like the player */
2548         if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2549         {
2550                 bool old_stack_force_notes = stack_force_notes;
2551                 bool old_stack_force_costs = stack_force_costs;
2552
2553                 if (cur_store_num != STORE_HOME)
2554                 {
2555                         stack_force_notes = FALSE;
2556                         stack_force_costs = FALSE;
2557                 }
2558
2559                 /* Check all the items */
2560                 for (i = 0; i < st_ptr->stock_num; i++)
2561                 {
2562                         /* Get the existing item */
2563                         j_ptr = &st_ptr->stock[i];
2564
2565                         /* Can the new object be combined with the old one? */
2566                         if (object_similar(j_ptr, o_ptr))
2567                         {
2568                                 if (cur_store_num != STORE_HOME)
2569                                 {
2570                                         stack_force_notes = old_stack_force_notes;
2571                                         stack_force_costs = old_stack_force_costs;
2572                                 }
2573
2574                                 return -1;
2575                         }
2576                 }
2577
2578                 if (cur_store_num != STORE_HOME)
2579                 {
2580                         stack_force_notes = old_stack_force_notes;
2581                         stack_force_costs = old_stack_force_costs;
2582                 }
2583         }
2584
2585         /* Normal stores do special stuff */
2586         else
2587         {
2588                 /* Check all the items */
2589                 for (i = 0; i < st_ptr->stock_num; i++)
2590                 {
2591                         /* Get the existing item */
2592                         j_ptr = &st_ptr->stock[i];
2593
2594                         /* Can the new object be combined with the old one? */
2595                         if (store_object_similar(j_ptr, o_ptr)) return -1;
2596                 }
2597         }
2598
2599         /* Free space is always usable */
2600         /*
2601          * オプション powerup_home が設定されていると
2602          * 我が家が 20 ページまで使える
2603          */
2604         if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
2605                 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
2606                         return 1;
2607                 }
2608         }
2609         else{
2610                 if (st_ptr->stock_num < st_ptr->stock_size) {
2611                         return 1;
2612                 }
2613         }
2614
2615         /* But there was no room at the inn... */
2616         return 0;
2617 }
2618
2619 /*!
2620  * @brief オブジェクトが祝福されているかの判定を返す /
2621  * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
2622  * @return アイテムが祝福されたアイテムならばTRUEを返す
2623  */
2624 static bool is_blessed(object_type *o_ptr)
2625 {
2626         BIT_FLAGS flgs[TR_FLAG_SIZE];
2627         object_flags(o_ptr, flgs);
2628         if (have_flag(flgs, TR_BLESSED)) return (TRUE);
2629         else return (FALSE);
2630 }
2631
2632
2633
2634 /*!
2635  * @brief オブジェクトが所定の店舗で引き取れるかどうかを返す /
2636  * Determine if the current store will purchase the given item
2637  * @param o_ptr 判定したいオブジェクト構造体の参照ポインタ
2638  * @return アイテムが買い取れるならばTRUEを返す
2639  * @note
2640  * Note that a shop-keeper must refuse to buy "worthless" items
2641  */
2642 static bool store_will_buy(object_type *o_ptr)
2643 {
2644         /* Hack -- The Home is simple */
2645         if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
2646
2647         /* Switch on the store */
2648         switch (cur_store_num)
2649         {
2650                 /* General Store */
2651                 case STORE_GENERAL:
2652                 {
2653                         /* Analyze the type */
2654                         switch (o_ptr->tval)
2655                         {
2656                                 case TV_POTION:
2657                                         if (o_ptr->sval != SV_POTION_WATER) return FALSE;
2658
2659                                 case TV_WHISTLE:
2660                                 case TV_FOOD:
2661                                 case TV_LITE:
2662                                 case TV_FLASK:
2663                                 case TV_SPIKE:
2664                                 case TV_SHOT:
2665                                 case TV_ARROW:
2666                                 case TV_BOLT:
2667                                 case TV_DIGGING:
2668                                 case TV_CLOAK:
2669                                 case TV_BOTTLE: /* 'Green', recycling Angband */
2670                                 case TV_FIGURINE:
2671                                 case TV_STATUE:
2672                                 case TV_CAPTURE:
2673                                 case TV_CARD:
2674                                 break;
2675                                 default:
2676                                 return (FALSE);
2677                         }
2678                         break;
2679                 }
2680
2681                 /* Armoury */
2682                 case STORE_ARMOURY:
2683                 {
2684                         /* Analyze the type */
2685                         switch (o_ptr->tval)
2686                         {
2687                                 case TV_BOOTS:
2688                                 case TV_GLOVES:
2689                                 case TV_CROWN:
2690                                 case TV_HELM:
2691                                 case TV_SHIELD:
2692                                 case TV_CLOAK:
2693                                 case TV_SOFT_ARMOR:
2694                                 case TV_HARD_ARMOR:
2695                                 case TV_DRAG_ARMOR:
2696                                 break;
2697                                 default:
2698                                 return (FALSE);
2699                         }
2700                         break;
2701                 }
2702
2703                 /* Weapon Shop */
2704                 case STORE_WEAPON:
2705                 {
2706                         /* Analyze the type */
2707                         switch (o_ptr->tval)
2708                         {
2709                                 case TV_SHOT:
2710                                 case TV_BOLT:
2711                                 case TV_ARROW:
2712                                 case TV_BOW:
2713                                 case TV_DIGGING:
2714                                 case TV_POLEARM:
2715                                 case TV_SWORD:
2716                                 case TV_HISSATSU_BOOK:
2717                                 break;
2718                                 case TV_HAFTED:
2719                                 {
2720                                         if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
2721                                 }
2722                                 break;
2723                                 default:
2724                                 return (FALSE);
2725                         }
2726                         break;
2727                 }
2728
2729                 /* Temple */
2730                 case STORE_TEMPLE:
2731                 {
2732                         /* Analyze the type */
2733                         switch (o_ptr->tval)
2734                         {
2735                                 case TV_LIFE_BOOK:
2736                                 case TV_CRUSADE_BOOK:
2737                                 case TV_SCROLL:
2738                                 case TV_POTION:
2739                                 case TV_HAFTED:
2740                                 {
2741                                         break;
2742                                 }
2743                                 case TV_FIGURINE:
2744                                 case TV_STATUE:
2745                                 {
2746                                         monster_race *r_ptr = &r_info[o_ptr->pval];
2747
2748                                         /* Decline evil */
2749                                         if (!(r_ptr->flags3 & RF3_EVIL))
2750                                         {
2751                                                 /* Accept good */
2752                                                 if (r_ptr->flags3 & RF3_GOOD) break;
2753
2754                                                 /* Accept animals */
2755                                                 if (r_ptr->flags3 & RF3_ANIMAL) break;
2756
2757                                                 /* Accept mimics */
2758                                                 if (my_strchr("?!", r_ptr->d_char)) break;
2759                                         }
2760                                 }
2761                                 case TV_POLEARM:
2762                                 case TV_SWORD:
2763                                 {
2764                                         if (is_blessed(o_ptr)) break;
2765                                 }
2766                                 default:
2767                                 return (FALSE);
2768                         }
2769                         break;
2770                 }
2771
2772                 /* Alchemist */
2773                 case STORE_ALCHEMIST:
2774                 {
2775                         /* Analyze the type */
2776                         switch (o_ptr->tval)
2777                         {
2778                                 case TV_SCROLL:
2779                                 case TV_POTION:
2780                                 break;
2781                                 default:
2782                                 return (FALSE);
2783                         }
2784                         break;
2785                 }
2786
2787                 /* Magic Shop */
2788                 case STORE_MAGIC:
2789                 {
2790                         /* Analyze the type */
2791                         switch (o_ptr->tval)
2792                         {
2793                                 case TV_SORCERY_BOOK:
2794                                 case TV_NATURE_BOOK:
2795                                 case TV_CHAOS_BOOK:
2796                                 case TV_DEATH_BOOK:
2797                                 case TV_TRUMP_BOOK:
2798                                 case TV_ARCANE_BOOK:
2799                                 case TV_CRAFT_BOOK:
2800                                 case TV_DAEMON_BOOK:
2801                                 case TV_MUSIC_BOOK:
2802                                 case TV_HEX_BOOK:
2803                                 case TV_AMULET:
2804                                 case TV_RING:
2805                                 case TV_STAFF:
2806                                 case TV_WAND:
2807                                 case TV_ROD:
2808                                 case TV_SCROLL:
2809                                 case TV_POTION:
2810                                 case TV_FIGURINE:
2811                                 break;
2812                                 case TV_HAFTED:
2813                                 {
2814                                         if(o_ptr->sval == SV_WIZSTAFF) break;
2815                                         else return (FALSE);
2816                                 }
2817                                 default:
2818                                 return (FALSE);
2819                         }
2820                         break;
2821                 }
2822                 /* Bookstore Shop */
2823                 case STORE_BOOK:
2824                 {
2825                         /* Analyze the type */
2826                         switch (o_ptr->tval)
2827                         {
2828                                 case TV_SORCERY_BOOK:
2829                                 case TV_NATURE_BOOK:
2830                                 case TV_CHAOS_BOOK:
2831                                 case TV_DEATH_BOOK:
2832                                 case TV_LIFE_BOOK:
2833                                 case TV_TRUMP_BOOK:
2834                                 case TV_ARCANE_BOOK:
2835                                 case TV_CRAFT_BOOK:
2836                                 case TV_DAEMON_BOOK:
2837                                 case TV_CRUSADE_BOOK:
2838                                 case TV_MUSIC_BOOK:
2839                                 case TV_HEX_BOOK:
2840                                         break;
2841                                 default:
2842                                         return (FALSE);
2843                         }
2844                         break;
2845                 }
2846         }
2847
2848         /* Ignore "worthless" items */
2849         if (object_value(o_ptr) <= 0) return (FALSE);
2850
2851         /* Assume okay */
2852         return (TRUE);
2853 }
2854
2855
2856 /*!
2857  * @brief 現在の町の指定された店舗のアイテムを整理する /
2858  * Combine and reorder items in store.
2859  * @param store_num 店舗ID
2860  * @return 実際に整理が行われたならばTRUEを返す。
2861  */
2862 bool combine_and_reorder_home(int store_num)
2863 {
2864         int         i, j, k;
2865         s32b        o_value;
2866         object_type forge, *o_ptr, *j_ptr;
2867         bool        flag = FALSE, combined;
2868         store_type  *old_st_ptr = st_ptr;
2869         bool        old_stack_force_notes = stack_force_notes;
2870         bool        old_stack_force_costs = stack_force_costs;
2871
2872         st_ptr = &town_info[1].store[store_num];
2873         if (store_num != STORE_HOME)
2874         {
2875                 stack_force_notes = FALSE;
2876                 stack_force_costs = FALSE;
2877         }
2878
2879         do
2880         {
2881                 combined = FALSE;
2882
2883                 /* Combine the items in the home (backwards) */
2884                 for (i = st_ptr->stock_num - 1; i > 0; i--)
2885                 {
2886                         o_ptr = &st_ptr->stock[i];
2887
2888                         /* Skip empty items */
2889                         if (!o_ptr->k_idx) continue;
2890
2891                         /* Scan the items above that item */
2892                         for (j = 0; j < i; j++)
2893                         {
2894                                 int max_num;
2895
2896                                 j_ptr = &st_ptr->stock[j];
2897
2898                                 /* Skip empty items */
2899                                 if (!j_ptr->k_idx) continue;
2900
2901                                 /*
2902                                  * Get maximum number of the stack if these
2903                                  * are similar, get zero otherwise.
2904                                  */
2905                                 max_num = object_similar_part(j_ptr, o_ptr);
2906
2907                                 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
2908                                 if (max_num && j_ptr->number < max_num)
2909                                 {
2910                                         if (o_ptr->number + j_ptr->number <= max_num)
2911                                         {
2912                                                 /* Add together the item counts */
2913                                                 object_absorb(j_ptr, o_ptr);
2914
2915                                                 /* One object is gone */
2916                                                 st_ptr->stock_num--;
2917
2918                                                 /* Slide everything down */
2919                                                 for (k = i; k < st_ptr->stock_num; k++)
2920                                                 {
2921                                                         /* Structure copy */
2922                                                         st_ptr->stock[k] = st_ptr->stock[k + 1];
2923                                                 }
2924
2925                                                 /* Erase the "final" slot */
2926                                                 object_wipe(&st_ptr->stock[k]);
2927                                         }
2928                                         else
2929                                         {
2930                                                 ITEM_NUMBER old_num = o_ptr->number;
2931                                                 ITEM_NUMBER remain = j_ptr->number + o_ptr->number - max_num;
2932
2933                                                 /* Add together the item counts */
2934                                                 object_absorb(j_ptr, o_ptr);
2935
2936                                                 o_ptr->number = remain;
2937
2938                                                 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
2939                                                 if (o_ptr->tval == TV_ROD)
2940                                                 {
2941                                                         o_ptr->pval =  o_ptr->pval * remain / old_num;
2942                                                         o_ptr->timeout = o_ptr->timeout * remain / old_num;
2943                                                 }
2944
2945                                                 /* Hack -- if wands are stacking, combine the charges. -LM- */
2946                                                 else if (o_ptr->tval == TV_WAND)
2947                                                 {
2948                                                         o_ptr->pval = o_ptr->pval * remain / old_num;
2949                                                 }
2950                                         }
2951
2952                                         /* Take note */
2953                                         combined = TRUE;
2954                                         break;
2955                                 }
2956                         }
2957                 }
2958
2959                 flag |= combined;
2960         }
2961         while (combined);
2962
2963         /* Re-order the items in the home (forwards) */
2964         for (i = 0; i < st_ptr->stock_num; i++)
2965         {
2966                 o_ptr = &st_ptr->stock[i];
2967
2968                 /* Skip empty slots */
2969                 if (!o_ptr->k_idx) continue;
2970
2971                 /* Get the "value" of the item */
2972                 o_value = object_value(o_ptr);
2973
2974                 /* Scan every occupied slot */
2975                 for (j = 0; j < st_ptr->stock_num; j++)
2976                 {
2977                         if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
2978                 }
2979
2980                 /* Never move down */
2981                 if (j >= i) continue;
2982
2983                 /* Take note */
2984                 flag = TRUE;
2985                 j_ptr = &forge;
2986
2987                 /* Save a copy of the moving item */
2988                 object_copy(j_ptr, &st_ptr->stock[i]);
2989
2990                 /* Slide the objects */
2991                 for (k = i; k > j; k--)
2992                 {
2993                         /* Slide the item */
2994                         object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
2995                 }
2996
2997                 /* Insert the moving item */
2998                 object_copy(&st_ptr->stock[j], j_ptr);
2999         }
3000
3001         st_ptr = old_st_ptr;
3002         if (store_num != STORE_HOME)
3003         {
3004                 stack_force_notes = old_stack_force_notes;
3005                 stack_force_costs = old_stack_force_costs;
3006         }
3007
3008         return flag;
3009 }
3010
3011
3012 /*!
3013  * @brief 我が家にオブジェクトを加える /
3014  * Add the item "o_ptr" to the p_ptr->inventory_list of the "Home"
3015  * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
3016  * @return 収めた先のID
3017  * @details
3018  * <pre>
3019  * In all cases, return the slot (or -1) where the object was placed
3020  * Note that this is a hacked up version of "inven_carry()".
3021  * Also note that it may not correctly "adapt" to "knowledge" bacoming
3022  * known, the player may have to pick stuff up and drop it again.
3023  * </pre>
3024  */
3025 static int home_carry(object_type *o_ptr)
3026 {
3027         int slot;
3028         PRICE value;
3029         int i;
3030         object_type *j_ptr;
3031         bool old_stack_force_notes = stack_force_notes;
3032         bool old_stack_force_costs = stack_force_costs;
3033
3034         if (cur_store_num != STORE_HOME)
3035         {
3036                 stack_force_notes = FALSE;
3037                 stack_force_costs = FALSE;
3038         }
3039
3040         /* Check each existing item (try to combine) */
3041         for (slot = 0; slot < st_ptr->stock_num; slot++)
3042         {
3043                 /* Get the existing item */
3044                 j_ptr = &st_ptr->stock[slot];
3045
3046                 /* The home acts just like the player */
3047                 if (object_similar(j_ptr, o_ptr))
3048                 {
3049                         /* Save the new number of items */
3050                         object_absorb(j_ptr, o_ptr);
3051
3052                         if (cur_store_num != STORE_HOME)
3053                         {
3054                                 stack_force_notes = old_stack_force_notes;
3055                                 stack_force_costs = old_stack_force_costs;
3056                         }
3057
3058                         /* All done */
3059                         return (slot);
3060                 }
3061         }
3062
3063         if (cur_store_num != STORE_HOME)
3064         {
3065                 stack_force_notes = old_stack_force_notes;
3066                 stack_force_costs = old_stack_force_costs;
3067         }
3068
3069         /* No space? */
3070         /*
3071          * 隠し機能: オプション powerup_home が設定されていると
3072          *           我が家が 20 ページまで使える
3073          */
3074         /* No space? */
3075         if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
3076                 if (st_ptr->stock_num >= st_ptr->stock_size) {
3077                         return (-1);
3078                 }
3079         }
3080         else{
3081                 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
3082                         return (-1);
3083                 }
3084         }
3085
3086
3087         /* Determine the "value" of the item */
3088         value = object_value(o_ptr);
3089
3090         /* Check existing slots to see if we must "slide" */
3091         for (slot = 0; slot < st_ptr->stock_num; slot++)
3092         {
3093                 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
3094         }
3095
3096         /* Slide the others up */
3097         for (i = st_ptr->stock_num; i > slot; i--)
3098         {
3099                 st_ptr->stock[i] = st_ptr->stock[i-1];
3100         }
3101
3102         /* More stuff now */
3103         st_ptr->stock_num++;
3104
3105         /* Insert the new item */
3106         st_ptr->stock[slot] = *o_ptr;
3107
3108         chg_virtue(V_SACRIFICE, -1);
3109
3110         (void)combine_and_reorder_home(cur_store_num);
3111
3112         /* Return the location */
3113         return (slot);
3114 }
3115
3116
3117 /*!
3118  * @brief 店舗にオブジェクトを加える /
3119  * Add the item "o_ptr" to a real stores p_ptr->inventory_list.
3120  * @param o_ptr 加えたいオブジェクトの構造体参照ポインタ
3121  * @return 収めた先のID
3122  * @details
3123  * <pre>
3124  * In all cases, return the slot (or -1) where the object was placed
3125  * Note that this is a hacked up version of "inven_carry()".
3126  * Also note that it may not correctly "adapt" to "knowledge" bacoming
3127  * known, the player may have to pick stuff up and drop it again.
3128  * </pre>
3129  */
3130 static int store_carry(object_type *o_ptr)
3131 {
3132         int i, slot;
3133         PRICE value, j_value;
3134         object_type *j_ptr;
3135
3136
3137         /* Evaluate the object */
3138         value = object_value(o_ptr);
3139
3140         /* Cursed/Worthless items "disappear" when sold */
3141         if (value <= 0) return (-1);
3142
3143         /* All store items are fully *identified* */
3144         o_ptr->ident |= IDENT_MENTAL;
3145
3146         /* Erase the inscription */
3147         o_ptr->inscription = 0;
3148
3149         /* Erase the "feeling" */
3150         o_ptr->feeling = FEEL_NONE;
3151
3152         /* Check each existing item (try to combine) */
3153         for (slot = 0; slot < st_ptr->stock_num; slot++)
3154         {
3155                 /* Get the existing item */
3156                 j_ptr = &st_ptr->stock[slot];
3157
3158                 /* Can the existing items be incremented? */
3159                 if (store_object_similar(j_ptr, o_ptr))
3160                 {
3161                         /* Hack -- extra items disappear */
3162                         store_object_absorb(j_ptr, o_ptr);
3163
3164                         /* All done */
3165                         return (slot);
3166                 }
3167         }
3168
3169         /* No space? */
3170         if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
3171
3172
3173         /* Check existing slots to see if we must "slide" */
3174         for (slot = 0; slot < st_ptr->stock_num; slot++)
3175         {
3176                 /* Get that item */
3177                 j_ptr = &st_ptr->stock[slot];
3178
3179                 /* Objects sort by decreasing type */
3180                 if (o_ptr->tval > j_ptr->tval) break;
3181                 if (o_ptr->tval < j_ptr->tval) continue;
3182
3183                 /* Objects sort by increasing sval */
3184                 if (o_ptr->sval < j_ptr->sval) break;
3185                 if (o_ptr->sval > j_ptr->sval) continue;
3186
3187                 /*
3188                  * Hack:  otherwise identical rods sort by
3189                  * increasing recharge time --dsb
3190                  */
3191                 if (o_ptr->tval == TV_ROD)
3192                 {
3193                         if (o_ptr->pval < j_ptr->pval) break;
3194                         if (o_ptr->pval > j_ptr->pval) continue;
3195                 }
3196
3197                 /* Evaluate that slot */
3198                 j_value = object_value(j_ptr);
3199
3200                 /* Objects sort by decreasing value */
3201                 if (value > j_value) break;
3202                 if (value < j_value) continue;
3203         }
3204
3205         /* Slide the others up */
3206         for (i = st_ptr->stock_num; i > slot; i--)
3207         {
3208                 st_ptr->stock[i] = st_ptr->stock[i-1];
3209         }
3210
3211         /* More stuff now */
3212         st_ptr->stock_num++;
3213
3214         /* Insert the new item */
3215         st_ptr->stock[slot] = *o_ptr;
3216
3217         /* Return the location */
3218         return (slot);
3219 }
3220
3221
3222 /*!
3223  * @brief 店舗のオブジェクト数を増やす /
3224  * Add the item "o_ptr" to a real stores p_ptr->inventory_list.
3225  * @param item 増やしたいアイテムのID
3226  * @param num 増やしたい数
3227  * @return なし
3228  * @details
3229  * <pre>
3230  * Increase, by a given amount, the number of a certain item
3231  * in a certain store.  This can result in zero items.
3232  * </pre>
3233  * @todo numは本来ITEM_NUMBER型にしたい。
3234  */
3235 static void store_item_increase(INVENTORY_IDX item, int num)
3236 {
3237         int             cnt;
3238         object_type *o_ptr;
3239
3240         o_ptr = &st_ptr->stock[item];
3241
3242         /* Verify the number */
3243         cnt = o_ptr->number + num;
3244         if (cnt > 255) cnt = 255;
3245         else if (cnt < 0) cnt = 0;
3246         num = cnt - o_ptr->number;
3247
3248         /* Save the new number */
3249         o_ptr->number += (ITEM_NUMBER)num;
3250 }
3251
3252
3253 /*!
3254  * @brief 店舗のオブジェクト数を削除する /
3255  * Remove a slot if it is empty
3256  * @param item 削除したいアイテムのID
3257  * @return なし
3258  */
3259 static void store_item_optimize(INVENTORY_IDX item)
3260 {
3261         int             j;
3262         object_type *o_ptr;
3263
3264         o_ptr = &st_ptr->stock[item];
3265
3266         /* Must exist */
3267         if (!o_ptr->k_idx) return;
3268
3269         /* Must have no items */
3270         if (o_ptr->number) return;
3271
3272         /* One less item */
3273         st_ptr->stock_num--;
3274
3275         /* Slide everyone */
3276         for (j = item; j < st_ptr->stock_num; j++)
3277         {
3278                 st_ptr->stock[j] = st_ptr->stock[j + 1];
3279         }
3280
3281         /* Nuke the final slot */
3282         object_wipe(&st_ptr->stock[j]);
3283 }
3284
3285 /*!
3286  * @brief ブラックマーケット用の無価値品の排除判定 /
3287  * This function will keep 'crap' out of the black market.
3288  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
3289  * @return ブラックマーケットにとって無価値な品ならばTRUEを返す
3290  * @details
3291  * <pre>
3292  * Crap is defined as any item that is "available" elsewhere
3293  * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
3294  * </pre>
3295  */
3296 static bool black_market_crap(object_type *o_ptr)
3297 {
3298         int i, j;
3299
3300         /* Ego items are never crap */
3301         if (object_is_ego(o_ptr)) return (FALSE);
3302
3303         /* Good items are never crap */
3304         if (o_ptr->to_a > 0) return (FALSE);
3305         if (o_ptr->to_h > 0) return (FALSE);
3306         if (o_ptr->to_d > 0) return (FALSE);
3307
3308         /* Check all stores */
3309         for (i = 0; i < MAX_STORES; i++)
3310         {
3311                 if (i == STORE_HOME) continue;
3312                 if (i == STORE_MUSEUM) continue;
3313
3314                 /* Check every item in the store */
3315                 for (j = 0; j < town_info[p_ptr->town_num].store[i].stock_num; j++)
3316                 {
3317                         object_type *j_ptr = &town_info[p_ptr->town_num].store[i].stock[j];
3318
3319                         /* Duplicate item "type", assume crappy */
3320                         if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
3321                 }
3322         }
3323
3324         /* Assume okay */
3325         return (FALSE);
3326 }
3327
3328
3329 /*!
3330  * @brief 店舗の品揃え変化のためにアイテムを削除する /
3331  * Attempt to delete (some of) a random item from the store
3332  * @return なし
3333  * @details
3334  * <pre>
3335  * Hack -- we attempt to "maintain" piles of items when possible.
3336  * </pre>
3337  */
3338 static void store_delete(void)
3339 {
3340         INVENTORY_IDX what;
3341         int num;
3342
3343         /* Pick a random slot */
3344         what = (INVENTORY_IDX)randint0(st_ptr->stock_num);
3345
3346         /* Determine how many items are here */
3347         num = st_ptr->stock[what].number;
3348
3349         /* Hack -- sometimes, only destroy half the items */
3350         if (randint0(100) < 50) num = (num + 1) / 2;
3351
3352         /* Hack -- sometimes, only destroy a single item */
3353         if (randint0(100) < 50) num = 1;
3354
3355         /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
3356         if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
3357         {
3358                 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
3359         }
3360
3361         /* Actually destroy (part of) the item */
3362         store_item_increase(what, -num);
3363         store_item_optimize(what);
3364 }
3365
3366
3367 /*!
3368  * @brief 店舗の品揃え変化のためにアイテムを追加する /
3369  * Creates a random item and gives it to a store
3370  * @return なし
3371  * @details
3372  * <pre>
3373  * This algorithm needs to be rethought.  A lot.
3374  * Currently, "normal" stores use a pre-built array.
3375  * Note -- the "level" given to "obj_get_num()" is a "favored"
3376  * level, that is, there is a much higher chance of getting
3377  * items with a level approaching that of the given level...
3378  * Should we check for "permission" to have the given item?
3379  * </pre>
3380  */
3381 static void store_create(void)
3382 {
3383         OBJECT_IDX i;
3384         int tries;
3385         DEPTH level;
3386
3387         object_type forge;
3388         object_type *q_ptr;
3389
3390         /* Paranoia -- no room left */
3391         if (st_ptr->stock_num >= st_ptr->stock_size) return;
3392
3393         /* Hack -- consider up to four items */
3394         for (tries = 0; tries < 4; tries++)
3395         {
3396                 /* Black Market */
3397                 if (cur_store_num == STORE_BLACK)
3398                 {
3399                         /* Pick a level for object/magic */
3400                         level = 25 + randint0(25);
3401
3402                         /* Random item (usually of given level) */
3403                         i = get_obj_num(level, 0x00000000);
3404
3405                         /* Handle failure */
3406                         if (!i) continue;
3407                 }
3408
3409                 /* Normal Store */
3410                 else
3411                 {
3412                         /* Hack -- Pick an item to sell */
3413                         i = st_ptr->table[randint0(st_ptr->table_num)];
3414
3415                         /* Hack -- fake level for apply_magic() */
3416                         level = rand_range(1, STORE_OBJ_LEVEL);
3417                 }
3418
3419                 q_ptr = &forge;
3420
3421                 /* Create a new object of the chosen kind */
3422                 object_prep(q_ptr, i);
3423
3424                 /* Apply some "low-level" magic (no artifacts) */
3425                 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
3426
3427                 /* Require valid object */
3428                 if (!store_will_buy(q_ptr)) continue;
3429
3430                 /* Hack -- Charge lite's */
3431                 if (q_ptr->tval == TV_LITE)
3432                 {
3433                         if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
3434                         if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
3435                 }
3436
3437
3438                 /* The item is "known" */
3439                 object_known(q_ptr);
3440
3441                 /* Mark it storebought */
3442                 q_ptr->ident |= IDENT_STORE;
3443
3444                 /* Mega-Hack -- no chests in stores */
3445                 if (q_ptr->tval == TV_CHEST) continue;
3446
3447                 /* Prune the black market */
3448                 if (cur_store_num == STORE_BLACK)
3449                 {
3450                         /* Hack -- No "crappy" items */
3451                         if (black_market_crap(q_ptr)) continue;
3452
3453                         /* Hack -- No "cheap" items */
3454                         if (object_value(q_ptr) < 10) continue;
3455
3456                         /* No "worthless" items */
3457                         /* if (object_value(q_ptr) <= 0) continue; */
3458                 }
3459
3460                 /* Prune normal stores */
3461                 else
3462                 {
3463                         /* No "worthless" items */
3464                         if (object_value(q_ptr) <= 0) continue;
3465                 }
3466
3467
3468                 /* Mass produce and/or Apply discount */
3469                 mass_produce(q_ptr);
3470
3471                 /* Attempt to carry the (known) item */
3472                 (void)store_carry(q_ptr);
3473
3474                 /* Definitely done */
3475                 break;
3476         }
3477 }
3478
3479
3480 /*!
3481  * @brief 店舗の割引対象外にするかどうかを判定 /
3482  * Eliminate need to bargain if player has haggled well in the past
3483  * @param minprice アイテムの最低販売価格
3484  * @return 割引を禁止するならTRUEを返す。
3485  */
3486 static bool noneedtobargain(PRICE minprice)
3487 {
3488         PRICE good = st_ptr->good_buy;
3489         PRICE bad = st_ptr->bad_buy;
3490
3491         /* Cheap items are "boring" */
3492         if (minprice < 10L) return (TRUE);
3493
3494         /* Perfect haggling */
3495         if (good == MAX_SHORT) return (TRUE);
3496
3497         /* Reward good haggles, punish bad haggles, notice price */
3498         if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
3499
3500         /* Return the flag */
3501         return (FALSE);
3502 }
3503
3504
3505 /*!
3506  * @brief 店主の持つプレイヤーに対する売買の良し悪し経験を記憶する /
3507  * Update the bargain info
3508  * @param price 実際の取引価格
3509  * @param minprice 店主の提示した価格
3510  * @param num 売買数 
3511  * @return なし
3512  */
3513 static void updatebargain(PRICE price, PRICE minprice, int num)
3514 {
3515         /* Hack -- auto-haggle */
3516         if (!manual_haggle) return;
3517
3518         /* Cheap items are "boring" */
3519         if ((minprice/num) < 10L) return;
3520
3521         /* Count the successful haggles */
3522         if (price == minprice)
3523         {
3524                 /* Just count the good haggles */
3525                 if (st_ptr->good_buy < MAX_SHORT)
3526                 {
3527                         st_ptr->good_buy++;
3528                 }
3529         }
3530
3531         /* Count the failed haggles */
3532         else
3533         {
3534                 /* Just count the bad haggles */
3535                 if (st_ptr->bad_buy < MAX_SHORT)
3536                 {
3537                         st_ptr->bad_buy++;
3538                 }
3539         }
3540 }
3541
3542
3543 /*!
3544  * @brief 店の商品リストを再表示する /
3545  * Re-displays a single store entry
3546  * @param pos 表示行
3547  * @return なし
3548  */
3549 static void display_entry(int pos)
3550 {
3551         int i, cur_col;
3552         object_type *o_ptr;
3553         s32b x;
3554
3555         GAME_TEXT o_name[MAX_NLEN];
3556         char out_val[160];
3557
3558         int maxwid = 75;
3559
3560         o_ptr = &st_ptr->stock[pos];
3561
3562         /* Get the "offset" */
3563         i = (pos % store_bottom);
3564
3565         /* Label it, clear the line --(-- */
3566         (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
3567         prt(out_val, i+6, 0);
3568
3569         cur_col = 3;
3570         if (show_item_graph)
3571         {
3572                 TERM_COLOR a = object_attr(o_ptr);
3573                 SYMBOL_CODE c = object_char(o_ptr);
3574
3575                 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
3576                 if (use_bigtile) cur_col++;
3577
3578                 cur_col += 2;
3579         }
3580
3581         /* Describe an item in the home */
3582         if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
3583         {
3584                 maxwid = 75;
3585
3586                 /* Leave room for weights, if necessary -DRS- */
3587                 if (show_weights) maxwid -= 10;
3588
3589                 object_desc(o_name, o_ptr, 0);
3590                 o_name[maxwid] = '\0';
3591                 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
3592
3593                 /* Show weights */
3594                 if(show_weights)
3595                 {
3596                         /* Only show the weight of an individual item */
3597                         WEIGHT wgt = o_ptr->weight;
3598 #ifdef JP
3599                         sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
3600                         put_str(out_val, i+6, 67);
3601 #else
3602                         (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
3603                         put_str(out_val, i+6, 68);
3604 #endif
3605
3606                 }
3607         }
3608
3609         /* Describe an item (fully) in a store */
3610         else
3611         {
3612                 /* Must leave room for the "price" */
3613                 maxwid = 65;
3614
3615                 /* Leave room for weights, if necessary -DRS- */
3616                 if (show_weights) maxwid -= 7;
3617
3618                 /* Describe the object (fully) */
3619                 object_desc(o_name, o_ptr, 0);
3620                 o_name[maxwid] = '\0';
3621                 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
3622
3623                 /* Show weights */
3624                 if (show_weights)
3625                 {
3626                         /* Only show the weight of an individual item */
3627                         int wgt = o_ptr->weight;
3628 #ifdef JP
3629                         sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
3630                         put_str(out_val, i+6, 60);
3631 #else
3632                         (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
3633                         put_str(out_val, i+6, 61);
3634 #endif
3635
3636                 }
3637
3638                 /* Display a "fixed" cost */
3639                 if (o_ptr->ident & (IDENT_FIXED))
3640                 {
3641                         /* Extract the "minimum" price */
3642                         x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
3643
3644                         /* Actually draw the price (not fixed) */
3645 #ifdef JP
3646                         (void)sprintf(out_val, "%9ld固", (long)x);
3647 #else
3648                         (void)sprintf(out_val, "%9ld F", (long)x);
3649 #endif
3650                         put_str(out_val, i+6, 68);
3651                 }
3652
3653                 /* Display a "taxed" cost */
3654                 else if (!manual_haggle)
3655                 {
3656                         /* Extract the "minimum" price */
3657                         x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
3658
3659                         /* Hack -- Apply Sales Tax if needed */
3660                         if (!noneedtobargain(x)) x += x / 10;
3661
3662                         /* Actually draw the price (with tax) */
3663                         (void)sprintf(out_val, "%9ld  ", (long)x);
3664                         put_str(out_val, i+6, 68);
3665                 }
3666
3667                 /* Display a "haggle" cost */
3668                 else
3669                 {
3670                         /* Extrect the "maximum" price */
3671                         x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
3672
3673                         /* Actually draw the price (not fixed) */
3674                         (void)sprintf(out_val, "%9ld  ", (long)x);
3675                         put_str(out_val, i+6, 68);
3676                 }
3677         }
3678 }
3679
3680
3681 /*!
3682  * @brief 店の商品リストを表示する /
3683  * Displays a store's p_ptr->inventory_list             -RAK-
3684  * @return なし
3685  * @details
3686  * All prices are listed as "per individual object".  -BEN-
3687  */
3688 static void display_inventory(void)
3689 {
3690         int i, k;
3691
3692         /* Display the next 12 items */
3693         for (k = 0; k < store_bottom; k++)
3694         {
3695                 /* Do not display "dead" items */
3696                 if (store_top + k >= st_ptr->stock_num) break;
3697
3698                 /* Display that line */
3699                 display_entry(store_top + k);
3700         }
3701
3702         /* Erase the extra lines and the "more" prompt */
3703         for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
3704
3705         /* Assume "no current page" */
3706 #ifdef JP
3707         put_str("          ", 5, 20);
3708 #else
3709         put_str("        ", 5, 20);
3710 #endif
3711
3712
3713         /* Visual reminder of "more items" */
3714         if (st_ptr->stock_num > store_bottom)
3715         {
3716                 /* Show "more" reminder (after the last item) */
3717                 prt(_("-続く-", "-more-"), k + 6, 3);
3718
3719                 /* Indicate the "current page" */
3720                 /* Trailing spaces are to display (Page xx) and (Page x) */
3721                 put_str(format(_("(%dページ)  ", "(Page %d)  "), store_top/store_bottom + 1), 5, 20);
3722         }
3723
3724         if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
3725         {
3726                 k = st_ptr->stock_size;
3727
3728                 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
3729 #ifdef JP
3730                 put_str(format("アイテム数:  %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
3731 #else
3732                 put_str(format("Objects:  %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
3733 #endif
3734         }
3735 }
3736
3737
3738 /*!
3739  * @brief プレイヤーの所持金を表示する /
3740  * Displays players gold                                        -RAK-
3741  * @return なし
3742  * @details
3743  */
3744 static void store_prt_gold(void)
3745 {
3746         char out_val[64];
3747
3748         prt(_("手持ちのお金: ", "Gold Remaining: "), 19 + xtra_stock, 53);
3749         sprintf(out_val, "%9ld", (long)p_ptr->au);
3750         prt(out_val, 19 + xtra_stock, 68);
3751 }
3752
3753 /*!
3754  * @brief 店舗情報全体を表示するメインルーチン /
3755  * Displays store (after clearing screen)               -RAK-
3756  * @return なし
3757  * @details
3758  */
3759 static void display_store(void)
3760 {
3761         char buf[80];
3762
3763         Term_clear();
3764
3765         /* The "Home" is special */
3766         if (cur_store_num == STORE_HOME)
3767         {
3768                 /* Put the owner name */
3769                 put_str(_("我が家", "Your Home"), 3, 31);
3770
3771                 /* Label the item descriptions */
3772                 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
3773
3774                 /* If showing weights, show label */
3775                 if (show_weights)
3776                 {
3777                         put_str(_("  重さ", "Weight"), 5, 70);
3778                 }
3779         }
3780
3781         /* The "Home" is special */
3782         else if (cur_store_num == STORE_MUSEUM)
3783         {
3784                 /* Put the owner name */
3785                 put_str(_("博物館", "Museum"), 3, 31);
3786
3787                 /* Label the item descriptions */
3788                 put_str(_("アイテムの一覧", "Item Description"), 5, 4);
3789
3790                 /* If showing weights, show label */
3791                 if (show_weights)
3792                 {
3793                         put_str(_("  重さ", "Weight"), 5, 70);
3794                 }
3795         }
3796
3797         /* Normal stores */
3798         else
3799         {
3800                 concptr store_name = (f_name + f_info[cur_store_feat].name);
3801                 concptr owner_name = (ot_ptr->owner_name);
3802                 concptr race_name = race_info[ot_ptr->owner_race].title;
3803
3804                 /* Put the owner name and race */
3805                 sprintf(buf, "%s (%s)", owner_name, race_name);
3806                 put_str(buf, 3, 10);
3807
3808                 /* Show the max price in the store (above prices) */
3809                 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
3810                 prt(buf, 3, 50);
3811
3812                 /* Label the item descriptions */
3813                 put_str(_("商品の一覧", "Item Description"), 5, 5);
3814
3815
3816                 /* If showing weights, show label */
3817                 if (show_weights)
3818                 {
3819                         put_str(_("  重さ", "Weight"), 5, 60);
3820                 }
3821
3822                 /* Label the asking price (in stores) */
3823                 put_str(_(" 価格", "Price"), 5, 72);
3824         }
3825
3826         /* Display the current gold */
3827         store_prt_gold();
3828
3829         /* Draw in the p_ptr->inventory_list */
3830         display_inventory();
3831 }
3832
3833
3834
3835 /*!
3836  * @brief 店舗からアイテムを選択する /
3837  * Get the ID of a store item and return its value      -RAK-
3838  * @param com_val 選択IDを返す参照ポインタ
3839  * @param pmt メッセージキャプション
3840  * @param i 選択範囲の最小値
3841  * @param j 選択範囲の最大値
3842  * @return 実際に選択したらTRUE、キャンセルしたらFALSE
3843  */
3844 static int get_stock(COMMAND_CODE *com_val, concptr pmt, int i, int j)
3845 {
3846         char command;
3847         char out_val[160];
3848         char lo, hi;
3849
3850         /* Get the item index */
3851         if (repeat_pull(com_val))
3852         {
3853                 /* Verify the item */
3854                 if ((*com_val >= i) && (*com_val <= j))
3855                 {
3856                         /* Success */
3857                         return (TRUE);
3858                 }
3859         }
3860         msg_print(NULL);
3861
3862         /* Assume failure */
3863         *com_val = (-1);
3864
3865         /* Build the prompt */
3866         lo = I2A(i);
3867         hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
3868 #ifdef JP
3869         (void)sprintf(out_val, "(%s:%c-%c, ESCで中断) %s",
3870                 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "アイテム" : "商品"), 
3871                                   lo, hi, pmt);
3872 #else
3873         (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
3874                                   lo, hi, pmt);
3875 #endif
3876
3877
3878         /* Ask until done */
3879         while (TRUE)
3880         {
3881                 COMMAND_CODE k;
3882
3883                 /* Escape */
3884                 if (!get_com(out_val, &command, FALSE)) break;
3885
3886                 /* Convert */
3887                 if (islower(command))
3888                         k = A2I(command);
3889                 else if (isupper(command))
3890                         k = A2I(tolower(command)) + 26;
3891                 else
3892                         k = -1;
3893
3894                 /* Legal responses */
3895                 if ((k >= i) && (k <= j))
3896                 {
3897                         *com_val = k;
3898                         break;
3899                 }
3900
3901                 bell();
3902         }
3903
3904         /* Clear the prompt */
3905         prt("", 0, 0);
3906
3907         if (command == ESCAPE) return (FALSE);
3908
3909         repeat_push(*com_val);
3910
3911         /* Success */
3912         return (TRUE);
3913 }
3914
3915
3916 /*!
3917  * @brief 店主の不満度を増やし、プレイヤーを締め出す判定と処理を行う /
3918  * Increase the insult counter and get angry if too many -RAK-
3919  * @return プレイヤーを締め出す場合TRUEを返す
3920  */
3921 static int increase_insults(void)
3922 {
3923         /* Increase insults */
3924         st_ptr->insult_cur++;
3925
3926         /* Become insulted */
3927         if (st_ptr->insult_cur > ot_ptr->insult_max)
3928         {
3929                 /* Complain */
3930                 say_comment_4();
3931
3932                 /* Reset insults */
3933                 st_ptr->insult_cur = 0;
3934                 st_ptr->good_buy = 0;
3935                 st_ptr->bad_buy = 0;
3936
3937                 /* Open tomorrow */
3938                 st_ptr->store_open = current_world_ptr->game_turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
3939
3940                 /* Closed */
3941                 return (TRUE);
3942         }
3943
3944         /* Not closed */
3945         return (FALSE);
3946 }
3947
3948
3949 /*!
3950  * @brief 店主の不満度を減らす /
3951  * Decrease insults                             -RAK-
3952  * @return プレイヤーを締め出す場合TRUEを返す
3953  */
3954 static void decrease_insults(void)
3955 {
3956         /* Decrease insults */
3957         if (st_ptr->insult_cur) st_ptr->insult_cur--;
3958 }
3959
3960
3961 /*!
3962  * @brief 店主の不満度が増えた場合のみのメッセージを表示する /
3963  * Have insulted while haggling                         -RAK-
3964  * @return プレイヤーを締め出す場合TRUEを返す
3965  */
3966 static int haggle_insults(void)
3967 {
3968         /* Increase insults */
3969         if (increase_insults()) return (TRUE);
3970
3971         /* Display and flush insult */
3972         say_comment_5();
3973
3974         /* Still okay */
3975         return (FALSE);
3976 }
3977
3978
3979 /*
3980  * Mega-Hack -- Enable "increments"
3981  */
3982 static bool allow_inc = FALSE;
3983
3984 /*
3985  * Mega-Hack -- Last "increment" during haggling
3986  */
3987 static s32b last_inc = 0L;
3988
3989
3990 /*!
3991  * @brief 交渉価格を確認と認証の是非を行う /
3992  * Get a haggle
3993  * @param pmt メッセージ
3994  * @param poffer 別途価格提示をした場合の値を返す参照ポインタ
3995  * @param price 現在の交渉価格
3996  * @param final 最終確定価格ならばTRUE
3997  * @return プレイヤーを締め出す場合TRUEを返す
3998  */
3999 static int get_haggle(concptr pmt, s32b *poffer, PRICE price, int final)
4000 {
4001         s32b i;
4002         concptr p;
4003         GAME_TEXT buf[128];
4004         GAME_TEXT out_val[160];
4005
4006         /* Clear old increment if necessary */
4007         if (!allow_inc) last_inc = 0L;
4008
4009         /* Final offer */
4010         if (final)
4011         {
4012                 sprintf(buf, _("%s [承諾] ", "%s [accept] "), pmt);
4013         }
4014
4015         /* Old (negative) increment, and not final */
4016         else if (last_inc < 0)
4017         {
4018                 sprintf(buf, _("%s [-$%ld] ", "%s [-%ld] "), pmt, (long)(ABS(last_inc)));
4019         }
4020
4021         /* Old (positive) increment, and not final */
4022         else if (last_inc > 0)
4023         {
4024                 sprintf(buf, _("%s [+$%ld] ", "%s [+%ld] "), pmt, (long)(ABS(last_inc)));
4025         }
4026
4027         /* Normal haggle */
4028         else
4029         {
4030                 sprintf(buf, "%s ", pmt);
4031         }
4032         msg_print(NULL);
4033
4034         /* Ask until done */
4035         while (TRUE)
4036         {
4037                 bool res;
4038
4039                 /* Display prompt */
4040                 prt(buf, 0, 0);
4041
4042                 /* Default */
4043                 strcpy(out_val, "");
4044
4045                 /*
4046                  * Ask the user for a response.
4047                  * Don't allow to use numpad as cursor key.
4048                  */
4049                 res = askfor_aux(out_val, 32, FALSE);
4050
4051                 /* Clear prompt */
4052                 prt("", 0, 0);
4053
4054                 /* Cancelled */
4055                 if (!res) return FALSE;
4056
4057                 /* Skip leading spaces */
4058                 for (p = out_val; *p == ' '; p++) /* loop */;
4059
4060                 /* Empty response */
4061                 if (*p == '\0')
4062                 {
4063                         /* Accept current price */
4064                         if (final)
4065                         {
4066                                 *poffer = price;
4067                                 last_inc = 0L;
4068                                 break;
4069                         }
4070
4071                         /* Use previous increment */
4072                         if (allow_inc && last_inc)
4073                         {
4074                                 *poffer += last_inc;
4075                                 break;
4076                         }
4077                 }
4078
4079                 /* Normal response */
4080                 else
4081                 {
4082                         /* Extract a number */
4083                         i = atol(p);
4084
4085                         /* Handle "incremental" number */
4086                         if ((*p == '+' || *p == '-'))
4087                         {
4088                                 /* Allow increments */
4089                                 if (allow_inc)
4090                                 {
4091                                         /* Use the given "increment" */
4092                                         *poffer += i;
4093                                         last_inc = i;
4094                                         break;
4095                                 }
4096                         }
4097
4098                         /* Handle normal number */
4099                         else
4100                         {
4101                                 /* Use the given "number" */
4102                                 *poffer = i;
4103                                 last_inc = 0L;
4104                                 break;
4105                         }
4106                 }
4107
4108                 /* Warning */
4109                 msg_print(_("値がおかしいです。", "Invalid response."));
4110                 msg_print(NULL);
4111         }
4112
4113         /* Success */
4114         return (TRUE);
4115 }
4116
4117
4118 /*!
4119  * @brief 店主がプレイヤーからの交渉価格を判断する /
4120  * Receive an offer (from the player)
4121  * @param pmt メッセージ
4122  * @param poffer 店主からの交渉価格を返す参照ポインタ
4123  * @param last_offer 現在の交渉価格
4124  * @param factor 店主の価格基準倍率
4125  * @param price アイテムの実価値
4126  * @param final 最終価格確定ならばTRUE
4127  * @return プレイヤーの価格に対して不服ならばTRUEを返す /
4128  * Return TRUE if offer is NOT okay
4129  */
4130 static bool receive_offer(concptr pmt, s32b *poffer,
4131                           s32b last_offer, int factor,
4132                           PRICE price, int final)
4133 {
4134         /* Haggle till done */
4135         while (TRUE)
4136         {
4137                 /* Get a haggle (or cancel) */
4138                 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
4139
4140                 /* Acceptable offer */
4141                 if (((*poffer) * factor) >= (last_offer * factor)) break;
4142
4143                 /* Insult, and check for kicked out */
4144                 if (haggle_insults()) return (TRUE);
4145
4146                 /* Reject offer (correctly) */
4147                 (*poffer) = last_offer;
4148         }
4149
4150         /* Success */
4151         return (FALSE);
4152 }
4153
4154
4155 /*!
4156  * @brief プレイヤーが購入する時の値切り処理メインルーチン /
4157  * Haggling routine                             -RAK-
4158  * @param o_ptr オブジェクトの構造体参照ポインタ
4159  * @param price 最終価格を返す参照ポインタ
4160  * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
4161  * Return TRUE if purchase is NOT successful
4162  */
4163 static bool purchase_haggle(object_type *o_ptr, s32b *price)
4164 {
4165         s32b                       cur_ask, final_ask;
4166         s32b                       last_offer, offer;
4167         s32b                       x1, x2, x3;
4168         s32b                       min_per, max_per;
4169         int                        flag, loop_flag, noneed;
4170         int                        annoyed = 0, final = FALSE;
4171         bool            cancel = FALSE;
4172         char            out_val[160];
4173         *price = 0;
4174
4175         concptr pmt = _("提示価格", "Asking");
4176
4177         /* Extract the starting offer and the final offer */
4178         cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
4179         final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
4180
4181         /* Determine if haggling is necessary */
4182         noneed = noneedtobargain(final_ask);
4183
4184         /* No need to haggle */
4185         if (noneed || !manual_haggle)
4186         {
4187                 /* No need to haggle */
4188                 if (noneed)
4189                 {
4190                         /* Message summary */
4191                         msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
4192                         msg_print(NULL);
4193                 }
4194
4195                 /* No haggle option */
4196                 else
4197                 {
4198                         /* Message summary */
4199                         msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
4200                         msg_print(NULL);
4201
4202                         /* Apply Sales Tax */
4203                         final_ask += final_ask / 10;
4204                 }
4205
4206                 /* Final price */
4207                 cur_ask = final_ask;
4208
4209                 /* Go to final offer */
4210                 pmt = _("最終提示価格", "Final Offer");
4211                 final = TRUE;
4212         }
4213
4214
4215         /* Haggle for the whole pile */
4216         cur_ask *= o_ptr->number;
4217         final_ask *= o_ptr->number;
4218
4219
4220         /* Haggle parameters */
4221         min_per = ot_ptr->haggle_per;
4222         max_per = min_per * 3;
4223
4224         /* Mega-Hack -- artificial "last offer" value */
4225         last_offer = object_value(o_ptr) * o_ptr->number;
4226         last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
4227         if (last_offer <= 0) last_offer = 1;
4228
4229         /* No offer yet */
4230         offer = 0;
4231
4232         /* No incremental haggling yet */
4233         allow_inc = FALSE;
4234
4235         /* Haggle until done */
4236         for (flag = FALSE; !flag; )
4237         {
4238                 loop_flag = TRUE;
4239
4240                 while (!flag && loop_flag)
4241                 {
4242                         (void)sprintf(out_val, "%s :  %ld", pmt, (long)cur_ask);
4243                         put_str(out_val, 1, 0);
4244                         cancel = receive_offer(_("提示する金額? ", "What do you offer? "), &offer, last_offer, 1, cur_ask, final);
4245                         if (cancel)
4246                         {
4247                                 flag = TRUE;
4248                         }
4249                         else if (offer > cur_ask)
4250                         {
4251                                 say_comment_6();
4252                                 offer = last_offer;
4253                         }
4254                         else if (offer == cur_ask)
4255                         {
4256                                 flag = TRUE;
4257                                 *price = offer;
4258                         }
4259                         else
4260                         {
4261                                 loop_flag = FALSE;
4262                         }
4263                 }
4264
4265                 if (!flag)
4266                 {
4267                         x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
4268                         if (x1 < min_per)
4269                         {
4270                                 if (haggle_insults())
4271                                 {
4272                                         flag = TRUE;
4273                                         cancel = TRUE;
4274                                 }
4275                         }
4276                         else if (x1 > max_per)
4277                         {
4278                                 x1 = x1 * 3 / 4;
4279                                 if (x1 < max_per) x1 = max_per;
4280                         }
4281                         x2 = rand_range(x1-2, x1+2);
4282                         x3 = ((cur_ask - offer) * x2 / 100L) + 1;
4283                         /* don't let the price go up */
4284                         if (x3 < 0) x3 = 0;
4285                         cur_ask -= x3;
4286
4287                         /* Too little */
4288                         if (cur_ask < final_ask)
4289                         {
4290                                 final = TRUE;
4291                                 cur_ask = final_ask;
4292                                 pmt = _("最終提示価格", "What do you offer? ");
4293                                 annoyed++;
4294                                 if (annoyed > 3)
4295                                 {
4296                                         (void)(increase_insults());
4297                                         cancel = TRUE;
4298                                         flag = TRUE;
4299                                 }
4300                         }
4301                         else if (offer >= cur_ask)
4302                         {
4303                                 flag = TRUE;
4304                                 *price = offer;
4305                         }
4306
4307                         if (!flag)
4308                         {
4309                                 last_offer = offer;
4310                                 allow_inc = TRUE;
4311                                 prt("", 1, 0);
4312                                 (void)sprintf(out_val, _("前回の提示金額: $%ld", "Your last offer: %ld"), (long)last_offer);
4313                                 put_str(out_val, 1, 39);
4314                                 say_comment_2(cur_ask, annoyed);
4315                         }
4316                 }
4317         }
4318
4319         if (cancel) return (TRUE);
4320
4321         updatebargain(*price, final_ask, o_ptr->number);
4322
4323         /* Do not cancel */
4324         return (FALSE);
4325 }
4326
4327
4328 /*!
4329  * @brief プレイヤーが売却する時の値切り処理メインルーチン /
4330  * Haggling routine                             -RAK-
4331  * @param o_ptr オブジェクトの構造体参照ポインタ
4332  * @param price 最終価格を返す参照ポインタ
4333  * @return プレイヤーの価格に対して店主が不服ならばTRUEを返す /
4334  * Return TRUE if purchase is NOT successful
4335  */
4336 static bool sell_haggle(object_type *o_ptr, s32b *price)
4337 {
4338         s32b    purse, cur_ask, final_ask;
4339         s32b    last_offer = 0, offer = 0;
4340         s32b    x1, x2, x3;
4341         s32b    min_per, max_per;
4342         int     flag, loop_flag, noneed;
4343         int     annoyed = 0, final = FALSE;
4344         bool    cancel = FALSE;
4345         concptr pmt = _("提示金額", "Offer");
4346
4347         char    out_val[160];
4348
4349         *price = 0;
4350
4351         /* Obtain the starting offer and the final offer */
4352         cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
4353         final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
4354
4355         /* Determine if haggling is necessary */
4356         noneed = noneedtobargain(final_ask);
4357
4358         /* Get the owner's payout limit */
4359         purse = (s32b)(ot_ptr->max_cost);
4360
4361         /* No need to haggle */
4362         if (noneed || !manual_haggle || (final_ask >= purse))
4363         {
4364                 /* Apply Sales Tax (if needed) */
4365                 if (!manual_haggle && !noneed)
4366                 {
4367                         final_ask -= final_ask / 10;
4368                 }
4369
4370                 /* No reason to haggle */
4371                 if (final_ask >= purse)
4372                 {
4373                         msg_print(_("即座にこの金額にまとまった。", "You instantly agree upon the price."));
4374                         msg_print(NULL);
4375
4376                         /* Offer full purse */
4377                         final_ask = purse;
4378                 }
4379
4380                 /* No need to haggle */
4381                 else if (noneed)
4382                 {
4383                         msg_print(_("結局この金額にまとまった。", "You eventually agree upon the price."));
4384                         msg_print(NULL);
4385                 }
4386
4387                 /* No haggle option */
4388                 else
4389                 {
4390                         /* Message summary */
4391                         msg_print(_("すんなりとこの金額にまとまった。", "You quickly agree upon the price."));
4392                         msg_print(NULL);
4393                 }
4394
4395                 /* Final price */
4396                 cur_ask = final_ask;
4397
4398                 /* Final offer */
4399                 final = TRUE;
4400                 pmt = _("最終提示金額", "Final Offer");
4401         }
4402
4403         /* Haggle for the whole pile */
4404         cur_ask *= o_ptr->number;
4405         final_ask *= o_ptr->number;
4406
4407
4408         /* Display commands */
4409
4410         /* Haggling parameters */
4411         min_per = ot_ptr->haggle_per;
4412         max_per = min_per * 3;
4413
4414         /* Mega-Hack -- artificial "last offer" value */
4415         last_offer = object_value(o_ptr) * o_ptr->number;
4416         last_offer = last_offer * ot_ptr->max_inflate / 100L;
4417
4418         /* No offer yet */
4419         offer = 0;
4420
4421         /* No incremental haggling yet */
4422         allow_inc = FALSE;
4423
4424         /* Haggle */
4425         for (flag = FALSE; !flag; )
4426         {
4427                 while (1)
4428                 {
4429                         loop_flag = TRUE;
4430
4431                         (void)sprintf(out_val, "%s :  %ld", pmt, (long)cur_ask);
4432                         put_str(out_val, 1, 0);
4433                         cancel = receive_offer(_("提示する価格? ", "What price do you ask? "),
4434                                                                    &offer, last_offer, -1, cur_ask, final);
4435
4436                         if (cancel)
4437                         {
4438                                 flag = TRUE;
4439                         }
4440                         else if (offer < cur_ask)
4441                         {
4442                                 say_comment_6();
4443                                 /* rejected, reset offer for incremental haggling */
4444                                 offer = last_offer;
4445                         }
4446                         else if (offer == cur_ask)
4447                         {
4448                                 flag = TRUE;
4449                                 *price = offer;
4450                         }
4451                         else
4452                         {
4453                                 loop_flag = FALSE;
4454                         }
4455
4456                         /* Stop */
4457                         if (flag || !loop_flag) break;
4458                 }
4459
4460                 if (!flag)
4461                 {
4462                         x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
4463                         if (x1 < min_per)
4464                         {
4465                                 if (haggle_insults())
4466                                 {
4467                                         flag = TRUE;
4468                                         cancel = TRUE;
4469                                 }
4470                         }
4471                         else if (x1 > max_per)
4472                         {
4473                                 x1 = x1 * 3 / 4;
4474                                 if (x1 < max_per) x1 = max_per;
4475                         }
4476                         x2 = rand_range(x1-2, x1+2);
4477                         x3 = ((offer - cur_ask) * x2 / 100L) + 1;
4478                         /* don't let the price go down */
4479                         if (x3 < 0) x3 = 0;
4480                         cur_ask += x3;
4481
4482                         if (cur_ask > final_ask)
4483                         {
4484                                 cur_ask = final_ask;
4485                                 final = TRUE;
4486                                 pmt = _("最終提示金額", "Final Offer");
4487
4488                                 annoyed++;
4489                                 if (annoyed > 3)
4490                                 {
4491                                         flag = TRUE;
4492 #ifdef JP
4493                                 /* 追加 $0 で買い取られてしまうのを防止 By FIRST*/
4494                                         cancel = TRUE;
4495 #endif
4496                                         (void)(increase_insults());
4497                                 }
4498                         }
4499                         else if (offer <= cur_ask)
4500                         {
4501                                 flag = TRUE;
4502                                 *price = offer;
4503                         }
4504
4505                         if (!flag)
4506                         {
4507                                 last_offer = offer;
4508                                 allow_inc = TRUE;
4509                                 prt("", 1, 0);
4510                                 (void)sprintf(out_val,
4511                                         _("前回の提示価格 $%ld", "Your last bid %ld"), (long)last_offer);
4512                                 put_str(out_val, 1, 39);
4513                                 say_comment_3(cur_ask, annoyed);
4514                         }
4515                 }
4516         }
4517
4518         if (cancel) return (TRUE);
4519
4520         updatebargain(*price, final_ask, o_ptr->number);
4521
4522         /* Do not cancel */
4523         return (FALSE);
4524 }
4525
4526
4527 /*!
4528  * @brief 店からの購入処理のメインルーチン /
4529  * Buy an item from a store                     -RAK-
4530  * @return なし
4531  */
4532 static void store_purchase(void)
4533 {
4534         int i, choice;
4535         COMMAND_CODE item, item_new;
4536
4537         ITEM_NUMBER amt;
4538
4539         PRICE price, best;
4540
4541         object_type forge;
4542         object_type *j_ptr;
4543
4544         object_type *o_ptr;
4545
4546         GAME_TEXT o_name[MAX_NLEN];
4547
4548         char out_val[160];
4549
4550         if (cur_store_num == STORE_MUSEUM)
4551         {
4552                 msg_print(_("博物館から取り出すことはできません。", "Museum."));
4553                 return;
4554         }
4555
4556         /* Empty? */
4557         if (st_ptr->stock_num <= 0)
4558         {
4559                 if (cur_store_num == STORE_HOME)
4560                         msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
4561                 else
4562                         msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
4563                 return;
4564         }
4565
4566         /* Find the number of objects on this and following pages */
4567         i = (st_ptr->stock_num - store_top);
4568
4569         /* And then restrict it to the current page */
4570         if (i > store_bottom) i = store_bottom;
4571
4572         /* Prompt */
4573 #ifdef JP
4574         /* ブラックマーケットの時は別のメッセージ */
4575         switch( cur_store_num ) {
4576                 case 7:
4577                         sprintf(out_val, "どのアイテムを取りますか? ");
4578                         break;
4579                 case 6:
4580                         sprintf(out_val, "どれ? ");
4581                         break;
4582                 default:
4583                         sprintf(out_val, "どの品物が欲しいんだい? ");
4584                         break;
4585         }
4586 #else
4587         if (cur_store_num == STORE_HOME)
4588         {
4589                 sprintf(out_val, "Which item do you want to take? ");
4590         }
4591         else
4592         {
4593                 sprintf(out_val, "Which item are you interested in? ");
4594         }
4595 #endif
4596
4597
4598         /* Get the item number to be bought */
4599         if (!get_stock(&item, out_val, 0, i - 1)) return;
4600
4601         /* Get the actual index */
4602         item = item + store_top;
4603
4604         /* Get the actual item */
4605         o_ptr = &st_ptr->stock[item];
4606
4607         /* Assume the player wants just one of them */
4608         amt = 1;
4609         j_ptr = &forge;
4610
4611         /* Get a copy of the object */
4612         object_copy(j_ptr, o_ptr);
4613
4614         /*
4615          * If a rod or wand, allocate total maximum timeouts or charges
4616          * between those purchased and left on the shelf.
4617          */
4618         reduce_charges(j_ptr, o_ptr->number - amt);
4619
4620         /* Modify quantity */
4621         j_ptr->number = amt;
4622
4623         /* Hack -- require room in pack */
4624         if (!inven_carry_okay(j_ptr))
4625         {
4626                 msg_print(_("そんなにアイテムを持てない。", "You cannot carry that many different items."));
4627                 return;
4628         }
4629
4630         /* Determine the "best" price (per item) */
4631         best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
4632
4633         /* Find out how many the player wants */
4634         if (o_ptr->number > 1)
4635         {
4636                 /* Hack -- note cost of "fixed" items */
4637                 if ((cur_store_num != STORE_HOME) &&
4638                     (o_ptr->ident & IDENT_FIXED))
4639                 {
4640                         msg_format(_("一つにつき $%ldです。", "That costs %ld gold per item."), (long)(best));
4641                 }
4642                 amt = get_quantity(NULL, o_ptr->number);
4643                 if (amt <= 0) return;
4644         }
4645         j_ptr = &forge;
4646
4647         /* Get desired object */
4648         object_copy(j_ptr, o_ptr);
4649
4650         /*
4651          * If a rod or wand, allocate total maximum timeouts or charges
4652          * between those purchased and left on the shelf.
4653          */
4654         reduce_charges(j_ptr, o_ptr->number - amt);
4655
4656         /* Modify quantity */
4657         j_ptr->number = amt;
4658
4659         /* Hack -- require room in pack */
4660         if (!inven_carry_okay(j_ptr))
4661         {
4662                 msg_print(_("ザックにそのアイテムを入れる隙間がない。", "You cannot carry that many items."));
4663                 return;
4664         }
4665
4666         /* Attempt to buy it */
4667         if (cur_store_num != STORE_HOME)
4668         {
4669                 /* Fixed price, quick buy */
4670                 if (o_ptr->ident & (IDENT_FIXED))
4671                 {
4672                         /* Assume accept */
4673                         choice = 0;
4674
4675                         /* Go directly to the "best" deal */
4676                         price = (best * j_ptr->number);
4677                 }
4678
4679                 /* Haggle for it */
4680                 else
4681                 {
4682                         /* Describe the object (fully) */
4683                         object_desc(o_name, j_ptr, 0);
4684                         msg_format(_("%s(%c)を購入する。", "Buying %s (%c)."), o_name, I2A(item));
4685                         msg_print(NULL);
4686
4687                         /* Haggle for a final price */
4688                         choice = purchase_haggle(j_ptr, &price);
4689
4690                         /* Hack -- Got kicked out */
4691                         if (st_ptr->store_open >= current_world_ptr->game_turn) return;
4692                 }
4693
4694                 /* Player wants it */
4695                 if (choice == 0)
4696                 {
4697                         /* Fix the item price (if "correctly" haggled) */
4698                         if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
4699
4700                         /* Player can afford it */
4701                         if (p_ptr->au >= price)
4702                         {
4703                                 /* Say "okay" */
4704                                 say_comment_1();
4705
4706                                 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
4707                                         chg_virtue(V_JUSTICE, -1);
4708                                 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
4709                                         chg_virtue(V_NATURE, -1);
4710
4711                                 /* Make a sound */
4712                                 sound(SOUND_BUY);
4713
4714                                 /* Be happy */
4715                                 decrease_insults();
4716
4717                                 /* Spend the money */
4718                                 p_ptr->au -= price;
4719
4720                                 /* Update the display */
4721                                 store_prt_gold();
4722
4723                                 /* Hack -- buying an item makes you aware of it */
4724                                 object_aware(j_ptr);
4725
4726                                 /* Hack -- clear the "fixed" flag from the item */
4727                                 j_ptr->ident &= ~(IDENT_FIXED);
4728
4729                                 /* Describe the transaction */
4730                                 object_desc(o_name, j_ptr, 0);
4731
4732                                 msg_format(_("%sを $%ldで購入しました。", "You bought %s for %ld gold."), o_name, (long)price);
4733
4734                                 strcpy(record_o_name, o_name);
4735                                 record_turn = current_world_ptr->game_turn;
4736
4737                                 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
4738                                 object_desc(o_name, o_ptr, OD_NAME_ONLY);
4739                                 if(record_rand_art && o_ptr->art_name)
4740                                         do_cmd_write_nikki(NIKKI_ART, 0, o_name);
4741
4742                                 /* Erase the inscription */
4743                                 j_ptr->inscription = 0;
4744
4745                                 /* Erase the "feeling" */
4746                                 j_ptr->feeling = FEEL_NONE;
4747                                 j_ptr->ident &= ~(IDENT_STORE);
4748                                 /* Give it to the player */
4749                                 item_new = inven_carry(j_ptr);
4750
4751                                 /* Describe the final result */
4752                                 object_desc(o_name, &p_ptr->inventory_list[item_new], 0);
4753                                 msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
4754
4755                                 /* Auto-inscription */
4756                                 autopick_alter_item(item_new, FALSE);
4757
4758                                 /* Now, reduce the original stack's pval. */
4759                                 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4760                                 {
4761                                         o_ptr->pval -= j_ptr->pval;
4762                                 }
4763                                 handle_stuff();
4764
4765                                 /* Note how many slots the store used to have */
4766                                 i = st_ptr->stock_num;
4767
4768                                 /* Remove the bought items from the store */
4769                                 store_item_increase(item, -amt);
4770                                 store_item_optimize(item);
4771
4772                                 /* Store is empty */
4773                                 if (st_ptr->stock_num == 0)
4774                                 {
4775                                         /* Shuffle */
4776                                         if (one_in_(STORE_SHUFFLE))
4777                                         {
4778                                                 char buf[80];
4779                                                 msg_print(_("店主は引退した。", "The shopkeeper retires."));
4780
4781                                                 /* Shuffle the store */
4782                                                 store_shuffle(cur_store_num);
4783
4784                                                 prt("",3,0);
4785                                                 sprintf(buf, "%s (%s)",
4786                                                         ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
4787                                                 put_str(buf, 3, 10);
4788                                                 sprintf(buf, "%s (%ld)",
4789                                                         (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
4790                                                 prt(buf, 3, 50);
4791                                         }
4792
4793                                         /* Maintain */
4794                                         else
4795                                         {
4796                                                 msg_print(_("店主は新たな在庫を取り出した。", "The shopkeeper brings out some new stock."));
4797                                         }
4798
4799                                         /* New p_ptr->inventory_list */
4800                                         for (i = 0; i < 10; i++)
4801                                         {
4802                                                 /* Maintain the store */
4803                                                 store_maint(p_ptr->town_num, cur_store_num);
4804                                         }
4805
4806                                         /* Start over */
4807                                         store_top = 0;
4808                                         display_inventory();
4809                                 }
4810
4811                                 /* The item is gone */
4812                                 else if (st_ptr->stock_num != i)
4813                                 {
4814                                         /* Pick the correct screen */
4815                                         if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4816                                         display_inventory();
4817                                 }
4818
4819                                 /* Item is still here */
4820                                 else
4821                                 {
4822                                         /* Redraw the item */
4823                                         display_entry(item);
4824                                 }
4825                         }
4826
4827                         /* Player cannot afford it */
4828                         else
4829                         {
4830                                 /* Simple message (no insult) */
4831                                 msg_print(_("お金が足りません。", "You do not have enough gold."));
4832                         }
4833                 }
4834         }
4835
4836         /* Home is much easier */
4837         else
4838         {
4839                 bool combined_or_reordered;
4840
4841                 /* Distribute charges of wands/rods */
4842                 distribute_charges(o_ptr, j_ptr, amt);
4843
4844                 /* Give it to the player */
4845                 item_new = inven_carry(j_ptr);
4846
4847                 /* Describe just the result */
4848                 object_desc(o_name, &p_ptr->inventory_list[item_new], 0);
4849
4850                 msg_format(_("%s(%c)を取った。", "You have %s (%c)."), o_name, index_to_label(item_new));
4851                 handle_stuff();
4852
4853                 /* Take note if we take the last one */
4854                 i = st_ptr->stock_num;
4855
4856                 /* Remove the items from the home */
4857                 store_item_increase(item, -amt);
4858                 store_item_optimize(item);
4859
4860                 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
4861
4862                 /* Hack -- Item is still here */
4863                 if (i == st_ptr->stock_num)
4864                 {
4865                         if (combined_or_reordered) display_inventory();
4866
4867                         /* Redraw the item */
4868                         else display_entry(item);
4869                 }
4870
4871                 /* The item is gone */
4872                 else
4873                 {
4874                         /* Nothing left */
4875                         if (st_ptr->stock_num == 0) store_top = 0;
4876
4877                         /* Nothing left on that screen */
4878                         else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4879                         display_inventory();
4880
4881                         chg_virtue(V_SACRIFICE, 1);
4882                 }
4883         }
4884
4885         /* Not kicked out */
4886         return;
4887 }
4888
4889
4890 /*!
4891  * @brief 店からの売却処理のメインルーチン /
4892  * Sell an item to the store (or home)
4893  * @return なし
4894  */
4895 static void store_sell(void)
4896 {
4897         int choice;
4898         OBJECT_IDX item;
4899         int item_pos;
4900         int amt;
4901
4902         PRICE price, value, dummy;
4903
4904         object_type forge;
4905         object_type *q_ptr;
4906         object_type *o_ptr;
4907
4908         concptr q, s;
4909
4910         GAME_TEXT o_name[MAX_NLEN];
4911
4912
4913         /* Prepare a prompt */
4914         if (cur_store_num == STORE_HOME)
4915                 q = _("どのアイテムを置きますか? ", "Drop which item? ");
4916
4917         else if (cur_store_num == STORE_MUSEUM)
4918                 q = _("どのアイテムを寄贈しますか? ", "Give which item? ");
4919
4920         else
4921                 q = _("どのアイテムを売りますか? ", "Sell which item? ");
4922
4923         /* Only allow items the store will buy */
4924         item_tester_hook = store_will_buy;
4925
4926         /* 我が家でおかしなメッセージが出るオリジナルのバグを修正 */
4927         if (cur_store_num == STORE_HOME)
4928         {
4929                 s = _("置けるアイテムを持っていません。", "You don't have any item to drop.");
4930         }
4931         else if (cur_store_num == STORE_MUSEUM)
4932         {
4933                 s = _("寄贈できるアイテムを持っていません。", "You don't have any item to give.");
4934         }
4935         else
4936         {
4937                 s = _("欲しい物がないですねえ。", "You have nothing that I want.");
4938         }
4939
4940         o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
4941         if (!o_ptr) return;
4942
4943         /* Hack -- Cannot remove cursed items */
4944         if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
4945         {
4946                 msg_print(_("ふーむ、どうやらそれは呪われているようだね。", "Hmmm, it seems to be cursed."));
4947                 return;
4948         }
4949
4950         /* Assume one item */
4951         amt = 1;
4952
4953         if (o_ptr->number > 1)
4954         {
4955                 amt = get_quantity(NULL, o_ptr->number);
4956                 if (amt <= 0) return;
4957         }
4958         q_ptr = &forge;
4959
4960         /* Get a copy of the object */
4961         object_copy(q_ptr, o_ptr);
4962
4963         /* Modify quantity */
4964         q_ptr->number = amt;
4965
4966         /*
4967          * Hack -- If a rod or wand, allocate total maximum
4968          * timeouts or charges to those being sold. -LM-
4969          */
4970         if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4971         {
4972                 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
4973         }
4974
4975         /* Get a full description */
4976         object_desc(o_name, q_ptr, 0);
4977
4978         /* Remove any inscription, feeling for stores */
4979         if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
4980         {
4981                 q_ptr->inscription = 0;
4982                 q_ptr->feeling = FEEL_NONE;
4983         }
4984
4985         /* Is there room in the store (or the home?) */
4986         if (!store_check_num(q_ptr))
4987         {
4988                 if (cur_store_num == STORE_HOME)
4989                         msg_print(_("我が家にはもう置く場所がない。", "Your home is full."));
4990
4991                 else if (cur_store_num == STORE_MUSEUM)
4992                         msg_print(_("博物館はもう満杯だ。", "Museum is full."));
4993
4994                 else
4995                         msg_print(_("すいませんが、店にはもう置く場所がありません。", "I have not the room in my store to keep it."));
4996
4997                 return;
4998         }
4999
5000
5001         /* Real store */
5002         if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
5003         {
5004                 /* Describe the transaction */
5005                 msg_format(_("%s(%c)を売却する。", "Selling %s (%c)."), o_name, index_to_label(item));
5006
5007                 msg_print(NULL);
5008
5009                 /* Haggle for it */
5010                 choice = sell_haggle(q_ptr, &price);
5011
5012                 /* Kicked out */
5013                 if (st_ptr->store_open >= current_world_ptr->game_turn) return;
5014
5015                 /* Sold... */
5016                 if (choice == 0)
5017                 {
5018                         /* Say "okay" */
5019                         say_comment_1();
5020
5021                         /* Make a sound */
5022                         sound(SOUND_SELL);
5023
5024                         /* Be happy */
5025                         if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
5026                                 chg_virtue(V_JUSTICE, -1);
5027
5028                         if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
5029                                 chg_virtue(V_NATURE, 1);
5030                         decrease_insults();
5031
5032                         /* Get some money */
5033                         p_ptr->au += price;
5034
5035                         /* Update the display */
5036                         store_prt_gold();
5037
5038                         /* Get the "apparent" value */
5039                         dummy = object_value(q_ptr) * q_ptr->number;
5040
5041                         identify_item(o_ptr);
5042                         q_ptr = &forge;
5043
5044                         /* Get a copy of the object */
5045                         object_copy(q_ptr, o_ptr);
5046
5047                         /* Modify quantity */
5048                         q_ptr->number = amt;
5049
5050                         /* Make it look like to be known */
5051                         q_ptr->ident |= IDENT_STORE;
5052
5053                         /*
5054                          * Hack -- If a rod or wand, let the shopkeeper know just
5055                          * how many charges he really paid for. -LM-
5056                          */
5057                         if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
5058                         {
5059                                 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
5060                         }
5061
5062                         /* Get the "actual" value */
5063                         value = object_value(q_ptr) * q_ptr->number;
5064
5065                         /* Get the description all over again */
5066                         object_desc(o_name, q_ptr, 0);
5067
5068                         /* Describe the result (in message buffer) */
5069                         msg_format(_("%sを $%ldで売却しました。", "You sold %s for %ld gold."), o_name, (long)price);
5070
5071                         if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
5072
5073                         if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
5074                         {
5075                          /* Analyze the prices (and comment verbally) unless a figurine*/
5076                         purchase_analyze(price, value, dummy);
5077                         }
5078
5079                         /*
5080                          * Hack -- Allocate charges between those wands or rods sold
5081                          * and retained, unless all are being sold. -LM-
5082                          */
5083                         distribute_charges(o_ptr, q_ptr, amt);
5084
5085                         /* Reset timeouts of the sold items */
5086                         q_ptr->timeout = 0;
5087
5088                         /* Take the item from the player, describe the result */
5089                         inven_item_increase(item, -amt);
5090                         inven_item_describe(item);
5091
5092                         /* If items remain, auto-inscribe before optimizing */
5093                         if (o_ptr->number > 0)
5094                                 autopick_alter_item(item, FALSE);
5095
5096                         inven_item_optimize(item);
5097                         handle_stuff();
5098
5099                         /* The store gets that (known) item */
5100                         item_pos = store_carry(q_ptr);
5101
5102                         /* Re-display if item is now in store */
5103                         if (item_pos >= 0)
5104                         {
5105                                 store_top = (item_pos / store_bottom) * store_bottom;
5106                                 display_inventory();
5107                         }
5108                 }
5109         }
5110
5111         /* Player is at museum */
5112         else if (cur_store_num == STORE_MUSEUM)
5113         {
5114                 char o2_name[MAX_NLEN];
5115                 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
5116
5117                 if (-1 == store_check_num(q_ptr))
5118                 {
5119                         msg_print(_("それと同じ品物は既に博物館にあるようです。", "The same object as it is already in the Museum."));
5120                 }
5121                 else
5122                 {
5123                         msg_print(_("博物館に寄贈したものは取り出すことができません!!", "You cannot take items which is given to the Museum back!!"));
5124                 }
5125
5126                 if (!get_check(format(_("本当に%sを寄贈しますか?", "Really give %s to the Museum? "), o2_name))) return;
5127
5128                 identify_item(q_ptr);
5129                 q_ptr->ident |= IDENT_MENTAL;
5130
5131                 /* Distribute charges of wands/rods */
5132                 distribute_charges(o_ptr, q_ptr, amt);
5133                 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
5134                 choice = 0;
5135
5136                 /* Take it from the players p_ptr->inventory_list */
5137                 inven_item_increase(item, -amt);
5138                 inven_item_describe(item);
5139                 inven_item_optimize(item);
5140                 handle_stuff();
5141
5142                 /* Let the home carry it */
5143                 item_pos = home_carry(q_ptr);
5144
5145                 /* Update store display */
5146                 if (item_pos >= 0)
5147                 {
5148                         store_top = (item_pos / store_bottom) * store_bottom;
5149                         display_inventory();
5150                 }
5151         }
5152         /* Player is at home */
5153         else
5154         {
5155                 /* Distribute charges of wands/rods */
5156                 distribute_charges(o_ptr, q_ptr, amt);
5157                 msg_format(_("%sを置いた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
5158
5159                 choice = 0;
5160
5161                 /* Take it from the players p_ptr->inventory_list */
5162                 inven_item_increase(item, -amt);
5163                 inven_item_describe(item);
5164                 inven_item_optimize(item);
5165                 handle_stuff();
5166
5167                 /* Let the home carry it */
5168                 item_pos = home_carry(q_ptr);
5169
5170                 /* Update store display */
5171                 if (item_pos >= 0)
5172                 {
5173                         store_top = (item_pos / store_bottom) * store_bottom;
5174                         display_inventory();
5175                 }
5176         }
5177
5178         if ((choice == 0) && (item >= INVEN_RARM))
5179         {
5180                 calc_android_exp();
5181                 kamaenaoshi(item);
5182         }
5183 }
5184
5185
5186 /*!
5187  * @brief 店のアイテムを調べるコマンドのメインルーチン /
5188  * Examine an item in a store                      -JDL-
5189  * @return なし
5190  */
5191 static void store_examine(void)
5192 {
5193         int         i;
5194         COMMAND_CODE item;
5195         object_type *o_ptr;
5196         GAME_TEXT o_name[MAX_NLEN];
5197         char        out_val[160];
5198
5199         /* Empty? */
5200         if (st_ptr->stock_num <= 0)
5201         {
5202                 if (cur_store_num == STORE_HOME)
5203                         msg_print(_("我が家には何も置いてありません。", "Your home is empty."));
5204                 else if (cur_store_num == STORE_MUSEUM)
5205                         msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
5206                 else
5207                         msg_print(_("現在商品の在庫を切らしています。", "I am currently out of stock."));
5208                 return;
5209         }
5210
5211         /* Find the number of objects on this and following pages */
5212         i = (st_ptr->stock_num - store_top);
5213
5214         /* And then restrict it to the current page */
5215         if (i > store_bottom) i = store_bottom;
5216
5217         /* Prompt */
5218         sprintf(out_val, _("どれを調べますか?", "Which item do you want to examine? "));
5219
5220         /* Get the item number to be examined */
5221         if (!get_stock(&item, out_val, 0, i - 1)) return;
5222
5223         /* Get the actual index */
5224         item = item + store_top;
5225
5226         /* Get the actual item */
5227         o_ptr = &st_ptr->stock[item];
5228
5229         /* Require full knowledge */
5230         if (!(o_ptr->ident & IDENT_MENTAL))
5231         {
5232                 /* This can only happen in the home */
5233                 msg_print(_("このアイテムについて特に知っていることはない。", "You have no special knowledge about that item."));
5234                 return;
5235         }
5236
5237         object_desc(o_name, o_ptr, 0);
5238         msg_format(_("%sを調べている...", "Examining %s..."), o_name);
5239
5240         if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
5241                 msg_print(_("特に変わったところはないようだ。", "You see nothing special."));
5242
5243         return;
5244 }
5245
5246
5247 /*!
5248  * @brief 博物館のアイテムを除去するコマンドのメインルーチン /
5249  * Remove an item from museum (Originally from TOband)
5250  * @return なし
5251  */
5252 static void museum_remove_object(void)
5253 {
5254         int i;
5255         COMMAND_CODE item;
5256         object_type *o_ptr;
5257         GAME_TEXT o_name[MAX_NLEN];
5258         char out_val[160];
5259
5260         /* Empty? */
5261         if (st_ptr->stock_num <= 0)
5262         {
5263                 msg_print(_("博物館には何も置いてありません。", "Museum is empty."));
5264                 return;
5265         }
5266
5267         /* Find the number of objects on this and following pages */
5268         i = st_ptr->stock_num - store_top;
5269
5270         /* And then restrict it to the current page */
5271         if (i > store_bottom) i = store_bottom;
5272
5273         /* Prompt */
5274         sprintf(out_val, _("どのアイテムの展示をやめさせますか?", "Which item do you want to order to remove? "));
5275
5276         /* Get the item number to be removed */
5277         if (!get_stock(&item, out_val, 0, i - 1)) return;
5278
5279         /* Get the actual index */
5280         item = item + store_top;
5281
5282         /* Get the actual item */
5283         o_ptr = &st_ptr->stock[item];
5284
5285         object_desc(o_name, o_ptr, 0);
5286
5287         msg_print(_("展示をやめさせたアイテムは二度と見ることはできません!", "You cannot see items which is removed from the Museum!"));
5288         if (!get_check(format(_("本当に%sの展示をやめさせますか?", "Really order to remove %s from the Museum? "), o_name))) return;
5289
5290         msg_format(_("%sの展示をやめさせた。", "You ordered to remove %s."), o_name);
5291
5292         /* Remove the items from the home */
5293         store_item_increase(item, -o_ptr->number);
5294         store_item_optimize(item);
5295
5296         (void)combine_and_reorder_home(STORE_MUSEUM);
5297
5298         /* The item is gone */
5299
5300         /* Nothing left */
5301         if (st_ptr->stock_num == 0) store_top = 0;
5302
5303         /* Nothing left on that screen */
5304         else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
5305         display_inventory();
5306
5307         return;
5308 }
5309
5310
5311 /*
5312  * Hack -- set this to leave the store
5313  */
5314 static bool leave_store = FALSE;
5315
5316
5317 /*!
5318  * @brief 店舗処理コマンド選択のメインルーチン /
5319  * Process a command in a store
5320  * @return なし
5321  * @note
5322  * <pre>
5323  * Note that we must allow the use of a few "special" commands
5324  * in the stores which are not allowed in the dungeon, and we
5325  * must disable some commands which are allowed in the dungeon
5326  * but not in the stores, to prevent chaos.
5327  * </pre>
5328  */
5329 static void store_process_command(void)
5330 {
5331         /* Handle repeating the last command */
5332         repeat_check();
5333
5334         if (rogue_like_commands && command_cmd == 'l')
5335         {
5336                 command_cmd = 'x';      /* hack! */
5337         }
5338
5339         /* Parse the command */
5340         switch (command_cmd)
5341         {
5342                 /* Leave */
5343                 case ESCAPE:
5344                 {
5345                         leave_store = TRUE;
5346                         break;
5347                 }
5348
5349                 /* 日本語版追加 */
5350                 /* 1 ページ戻るコマンド: 我が家のページ数が多いので重宝するはず By BUG */
5351                 case '-':
5352                 {
5353                         if (st_ptr->stock_num <= store_bottom) {
5354                                 msg_print(_("これで全部です。", "Entire p_ptr->inventory_list is shown."));
5355                         }
5356                         else{
5357                                 store_top -= store_bottom;
5358                                 if ( store_top < 0 )
5359                                         store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
5360                                 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
5361                                         if ( store_top >= store_bottom ) store_top = store_bottom;
5362                                 display_inventory();
5363                         }
5364                         break;
5365                 }
5366
5367                 /* Browse */
5368                 case ' ':
5369                 {
5370                         if (st_ptr->stock_num <= store_bottom)
5371                         {
5372                                 msg_print(_("これで全部です。", "Entire p_ptr->inventory_list is shown."));
5373                         }
5374                         else
5375                         {
5376                                 store_top += store_bottom;
5377                                 /*
5378                                  * 隠しオプション(powerup_home)がセットされていないときは
5379                                  * 我が家では 2 ページまでしか表示しない
5380                                  */
5381                                 if ((cur_store_num == STORE_HOME) && 
5382                                     (powerup_home == FALSE) && 
5383                                         (st_ptr->stock_num >= STORE_INVEN_MAX))
5384                                 {
5385                                         if (store_top >= (STORE_INVEN_MAX - 1))
5386                                         {
5387                                                 store_top = 0;
5388                                         }
5389                                 }
5390                                 else
5391                                 {
5392                                         if (store_top >= st_ptr->stock_num) store_top = 0;
5393                                 }
5394
5395                                 display_inventory();
5396                         }
5397                         break;
5398                 }
5399
5400                 case KTRL('R'):
5401                 {
5402                         do_cmd_redraw();
5403                         display_store();
5404                         break;
5405                 }
5406
5407                 /* Get (purchase) */
5408                 case 'g':
5409                 {
5410                         store_purchase();
5411                         break;
5412                 }
5413
5414                 /* Drop (Sell) */
5415                 case 'd':
5416                 {
5417                         store_sell();
5418                         break;
5419                 }
5420
5421                 /* Examine */
5422                 case 'x':
5423                 {
5424                         store_examine();
5425                         break;
5426                 }
5427
5428                 /* Ignore return */
5429                 case '\r':
5430                 {
5431                         break;
5432                 }
5433
5434                 /*** Inventory Commands ***/
5435
5436                 /* Wear/wield equipment */
5437                 case 'w':
5438                 {
5439                         do_cmd_wield();
5440                         break;
5441                 }
5442
5443                 /* Take off equipment */
5444                 case 't':
5445                 {
5446                         do_cmd_takeoff();
5447                         break;
5448                 }
5449
5450                 /* Destroy an item */
5451                 case 'k':
5452                 {
5453                         do_cmd_destroy();
5454                         break;
5455                 }
5456
5457                 /* Equipment list */
5458                 case 'e':
5459                 {
5460                         do_cmd_equip();
5461                         break;
5462                 }
5463
5464                 /* Inventory list */
5465                 case 'i':
5466                 {
5467                         do_cmd_inven();
5468                         break;
5469                 }
5470
5471
5472                 /*** Various commands ***/
5473
5474                 /* Identify an object */
5475                 case 'I':
5476                 {
5477                         do_cmd_observe();
5478                         break;
5479                 }
5480
5481                 /* Hack -- toggle windows */
5482                 case KTRL('I'):
5483                 {
5484                         toggle_inven_equip();
5485                         break;
5486                 }
5487
5488                 /*** Use various objects ***/
5489
5490                 /* Browse a book */
5491                 case 'b':
5492                 {
5493                         if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
5494                              (p_ptr->pclass == CLASS_BERSERKER) ||
5495                              (p_ptr->pclass == CLASS_NINJA) ||
5496                              (p_ptr->pclass == CLASS_MIRROR_MASTER) 
5497                              ) do_cmd_mind_browse();
5498                         else if (p_ptr->pclass == CLASS_SMITH)
5499                                 do_cmd_kaji(TRUE);
5500                         else if (p_ptr->pclass == CLASS_MAGIC_EATER)
5501                                 do_cmd_magic_eater(TRUE, FALSE);
5502                         else if (p_ptr->pclass == CLASS_SNIPER)
5503                                 do_cmd_snipe_browse();
5504                         else do_cmd_browse();
5505                         break;
5506                 }
5507
5508                 /* Inscribe an object */
5509                 case '{':
5510                 {
5511                         do_cmd_inscribe();
5512                         break;
5513                 }
5514
5515                 /* Uninscribe an object */
5516                 case '}':
5517                 {
5518                         do_cmd_uninscribe();
5519                         break;
5520                 }
5521
5522
5523
5524                 /*** Help and Such ***/
5525
5526                 /* Help */
5527                 case '?':
5528                 {
5529                         do_cmd_help();
5530                         break;
5531                 }
5532
5533                 /* Identify symbol */
5534                 case '/':
5535                 {
5536                         do_cmd_query_symbol();
5537                         break;
5538                 }
5539
5540                 /* Character description */
5541                 case 'C':
5542                 {
5543                         p_ptr->town_num = old_town_num;
5544                         do_cmd_change_name();
5545                         p_ptr->town_num = inner_town_num;
5546                         display_store();
5547                         break;
5548                 }
5549
5550
5551                 /*** System Commands ***/
5552
5553                 /* Hack -- User interface */
5554                 case '!':
5555                 {
5556                         (void)Term_user(0);
5557                         break;
5558                 }
5559
5560                 /* Single line from a pref file */
5561                 case '"':
5562                 {
5563                         p_ptr->town_num = old_town_num;
5564                         do_cmd_pref();
5565                         p_ptr->town_num = inner_town_num;
5566                         break;
5567                 }
5568
5569                 /* Interact with macros */
5570                 case '@':
5571                 {
5572                         p_ptr->town_num = old_town_num;
5573                         do_cmd_macros();
5574                         p_ptr->town_num = inner_town_num;
5575                         break;
5576                 }
5577
5578                 /* Interact with visuals */
5579                 case '%':
5580                 {
5581                         p_ptr->town_num = old_town_num;
5582                         do_cmd_visuals();
5583                         p_ptr->town_num = inner_town_num;
5584                         break;
5585                 }
5586
5587                 /* Interact with colors */
5588                 case '&':
5589                 {
5590                         p_ptr->town_num = old_town_num;
5591                         do_cmd_colors();
5592                         p_ptr->town_num = inner_town_num;
5593                         break;
5594                 }
5595
5596                 /* Interact with options */
5597                 case '=':
5598                 {
5599                         do_cmd_options();
5600                         (void)combine_and_reorder_home(STORE_HOME);
5601                         do_cmd_redraw();
5602                         display_store();
5603                         break;
5604                 }
5605
5606                 /*** Misc Commands ***/
5607
5608                 /* Take notes */
5609                 case ':':
5610                 {
5611                         do_cmd_note();
5612                         break;
5613                 }
5614
5615                 /* Version info */
5616                 case 'V':
5617                 {
5618                         do_cmd_version();
5619                         break;
5620                 }
5621
5622                 /* Repeat level feeling */
5623                 case KTRL('F'):
5624                 {
5625                         do_cmd_feeling();
5626                         break;
5627                 }
5628
5629                 /* Show previous message */
5630                 case KTRL('O'):
5631                 {
5632                         do_cmd_message_one();
5633                         break;
5634                 }
5635
5636                 /* Show previous messages */
5637                 case KTRL('P'):
5638                 {
5639                         do_cmd_messages(0);
5640                         break;
5641                 }
5642
5643                 case '|':
5644                 {
5645                         do_cmd_nikki();
5646                         break;
5647                 }
5648
5649                 /* Check artifacts, uniques etc. */
5650                 case '~':
5651                 {
5652                         do_cmd_knowledge();
5653                         break;
5654                 }
5655
5656                 /* Load "screen dump" */
5657                 case '(':
5658                 {
5659                         do_cmd_load_screen();
5660                         break;
5661                 }
5662
5663                 /* Save "screen dump" */
5664                 case ')':
5665                 {
5666                         do_cmd_save_screen();
5667                         break;
5668                 }
5669
5670                 /* Hack -- Unknown command */
5671                 default:
5672                 {
5673                         if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
5674                         {
5675                                 museum_remove_object();
5676                         }
5677                         else
5678                         {
5679                                 msg_print(_("そのコマンドは店の中では使えません。", "That command does not work in stores."));
5680                         }
5681                         break;
5682                 }
5683         }
5684 }
5685
5686
5687 /*!
5688  * @brief 店舗処理全体のメインルーチン /
5689  * Enter a store, and interact with it. *
5690  * @return なし
5691  * @note
5692  * <pre>
5693  * Note that we use the standard "request_command()" function
5694  * to get a command, allowing us to use "command_arg" and all
5695  * command macros and other nifty stuff, but we use the special
5696  * "shopping" argument, to force certain commands to be converted
5697  * into other commands, normally, we convert "p" (pray) and "m"
5698  * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
5699  * </pre>
5700  */
5701 void do_cmd_store(void)
5702 {
5703         int which;
5704         int maintain_num;
5705         int i;
5706         grid_type *g_ptr;
5707         bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
5708         TERM_LEN w, h;
5709
5710         if(p_ptr->wild_mode) return;
5711         Term_get_size(&w, &h);
5712
5713         /* Calculate stocks per 1 page */
5714         xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
5715         store_bottom = MIN_STOCK + xtra_stock;
5716
5717         /* Access the player grid */
5718         g_ptr = &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x];
5719
5720         /* Verify a store */
5721         if (!cave_have_flag_grid(g_ptr, FF_STORE))
5722         {
5723                 msg_print(_("ここには店がありません。", "You see no store here."));
5724                 return;
5725         }
5726
5727         /* Extract the store code */
5728         which = f_info[g_ptr->feat].subtype;
5729
5730         old_town_num = p_ptr->town_num;
5731         if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
5732         if (current_floor_ptr->dun_level) p_ptr->town_num = NO_TOWN;
5733         inner_town_num = p_ptr->town_num;
5734
5735         /* Hack -- Check the "locked doors" */
5736         if ((town_info[p_ptr->town_num].store[which].store_open >= current_world_ptr->game_turn) ||
5737             (ironman_shops))
5738         {
5739                 msg_print(_("ドアに鍵がかかっている。", "The doors are locked."));
5740                 p_ptr->town_num = old_town_num;
5741                 return;
5742         }
5743
5744         /* Calculate the number of store maintainances since the last visit */
5745         maintain_num = (current_world_ptr->game_turn - town_info[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
5746
5747         /* Maintain the store max. 10 times */
5748         if (maintain_num > 10) maintain_num = 10;
5749
5750         if (maintain_num)
5751         {
5752                 /* Maintain the store */
5753                 for (i = 0; i < maintain_num; i++)
5754                         store_maint(p_ptr->town_num, which);
5755
5756                 /* Save the visit */
5757                 town_info[p_ptr->town_num].store[which].last_visit = current_world_ptr->game_turn;
5758         }
5759
5760         forget_lite();
5761         forget_view();
5762
5763         /* Hack -- Character is in "icky" mode */
5764         character_icky = TRUE;
5765
5766         /* command reset */
5767         command_arg = 0;
5768         command_rep = 0;
5769         command_new = 0;
5770
5771         /* Do not expand macros */
5772         get_com_no_macros = TRUE;
5773
5774         /* Save the store number */
5775         cur_store_num = which;
5776
5777         /* Hack -- save the store feature */
5778         cur_store_feat = g_ptr->feat;
5779
5780         /* Save the store and owner pointers */
5781         st_ptr = &town_info[p_ptr->town_num].store[cur_store_num];
5782         ot_ptr = &owners[cur_store_num][st_ptr->owner];
5783
5784         /* Start at the beginning */
5785         store_top = 0;
5786
5787         play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_BUILD);
5788
5789         display_store();
5790
5791         /* Do not leave */
5792         leave_store = FALSE;
5793
5794         /* Interact with player */
5795         while (!leave_store)
5796         {
5797                 /* Hack -- Clear line 1 */
5798                 prt("", 1, 0);
5799
5800                 /* Clear */
5801                 clear_from(20 + xtra_stock);
5802
5803                 /* Basic commands */
5804                 prt(_(" ESC) 建物から出る", " ESC) Exit from Building."), 21 + xtra_stock, 0);
5805
5806                 /* Browse if necessary */
5807                 if (st_ptr->stock_num > store_bottom)
5808                 {
5809                         prt(_(" -)前ページ", " -) Previous page"), 22 + xtra_stock, 0);
5810                         prt(_(" スペース) 次ページ", " SPACE) Next page"), 23 + xtra_stock, 0);
5811                 }
5812
5813                 /* Home commands */
5814                 if (cur_store_num == STORE_HOME)
5815                 {
5816                         prt(_("g) アイテムを取る", "g) Get an item."), 21 + xtra_stock, 27);
5817                         prt(_("d) アイテムを置く", "d) Drop an item."), 22 + xtra_stock, 27);
5818                         prt(_("x) 家のアイテムを調べる", "x) eXamine an item in the home."), 23 + xtra_stock, 27);
5819                 }
5820
5821                 /* Museum commands */
5822                 else if (cur_store_num == STORE_MUSEUM)
5823                 {
5824                         prt(_("d) アイテムを置く", "d) Drop an item."), 21 + xtra_stock, 27);
5825                         prt(_("r) アイテムの展示をやめる", "r) order to Remove an item."), 22 + xtra_stock, 27);
5826                         prt(_("x) 博物館のアイテムを調べる", "x) eXamine an item in the museum."), 23 + xtra_stock, 27);
5827                 }
5828
5829                 /* Shop commands */
5830                 else
5831                 {
5832                         prt(_("p) 商品を買う", "p) Purchase an item."), 21 + xtra_stock, 30);
5833                         prt(_("s) アイテムを売る", "s) Sell an item."), 22 + xtra_stock, 30);
5834                         prt(_("x) 商品を調べる", "x) eXamine an item in the shop"), 23 + xtra_stock,30);
5835                 }
5836
5837                 /* 基本的なコマンドの追加表示 */
5838                 prt(_("i/e) 持ち物/装備の一覧", "i/e) Inventry/Equipment list"), 21 + xtra_stock, 56);
5839
5840                 if (rogue_like_commands)
5841                 {
5842                         prt(_("w/T) 装備する/はずす", "w/T) Wear/Take off equipment"), 22 + xtra_stock, 56);
5843                 }
5844                 else
5845                 {
5846                         prt(_("w/t) 装備する/はずす", "w/t) Wear/Take off equipment"), 22 + xtra_stock, 56);
5847                 }
5848
5849                 /* Prompt */
5850                 prt(_("コマンド:", "You may: "), 20 + xtra_stock, 0);
5851
5852                 request_command(TRUE);
5853
5854                 /* Process the command */
5855                 store_process_command();
5856
5857                 /*
5858                  * Hack -- To redraw missiles damage and prices in store
5859                  * If player's charisma changes, or if player changes a bow, PU_BONUS is set
5860                  */
5861                 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
5862
5863                 /* Hack -- Character is still in "icky" mode */
5864                 character_icky = TRUE;
5865
5866                 handle_stuff();
5867
5868                 /* Pack Overflow */
5869                 if (p_ptr->inventory_list[INVEN_PACK].k_idx)
5870                 {
5871                         INVENTORY_IDX item = INVEN_PACK;
5872
5873                         object_type *o_ptr = &p_ptr->inventory_list[item];
5874
5875                         /* Hack -- Flee from the store */
5876                         if (cur_store_num != STORE_HOME)
5877                         {
5878                                 if (cur_store_num == STORE_MUSEUM)
5879                                         msg_print(_("ザックからアイテムがあふれそうなので、あわてて博物館から出た...", "Your pack is so full that you flee the Museum..."));
5880                                 else
5881                                         msg_print(_("ザックからアイテムがあふれそうなので、あわてて店から出た...", "Your pack is so full that you flee the store..."));
5882
5883                                 /* Leave */
5884                                 leave_store = TRUE;
5885                         }
5886
5887                         /* Hack -- Flee from the home */
5888                         else if (!store_check_num(o_ptr))
5889                         {
5890                                 msg_print(_("ザックからアイテムがあふれそうなので、あわてて家から出た...", "Your pack is so full that you flee your home..."));
5891                                 /* Leave */
5892                                 leave_store = TRUE;
5893                         }
5894
5895                         /* Hack -- Drop items into the home */
5896                         else
5897                         {
5898                                 int item_pos;
5899
5900                                 object_type forge;
5901                                 object_type *q_ptr;
5902
5903                                 GAME_TEXT o_name[MAX_NLEN];
5904
5905                                 /* Give a message */
5906                                 msg_print(_("ザックからアイテムがあふれてしまった!", "Your pack overflows!"));
5907
5908                                 q_ptr = &forge;
5909
5910                                 object_copy(q_ptr, o_ptr);
5911                                 object_desc(o_name, q_ptr, 0);
5912
5913                                 msg_format(_("%sが落ちた。(%c)", "You drop %s (%c)."), o_name, index_to_label(item));
5914
5915                                 /* Remove it from the players p_ptr->inventory_list */
5916                                 inven_item_increase(item, -255);
5917                                 inven_item_describe(item);
5918                                 inven_item_optimize(item);
5919                                 handle_stuff();
5920
5921                                 /* Let the home carry it */
5922                                 item_pos = home_carry(q_ptr);
5923
5924                                 /* Redraw the home */
5925                                 if (item_pos >= 0)
5926                                 {
5927                                         store_top = (item_pos / store_bottom) * store_bottom;
5928                                         display_inventory();
5929                                 }
5930                         }
5931                 }
5932
5933                 /* Hack -- Redisplay store prices if charisma changes */
5934                 /* Hack -- Redraw missiles damage if player changes bow */
5935                 if (need_redraw_store_inv) display_inventory();
5936
5937                 /* Hack -- get kicked out of the store */
5938                 if (st_ptr->store_open >= current_world_ptr->game_turn) leave_store = TRUE;
5939         }
5940
5941         select_floor_music();
5942
5943         p_ptr->town_num = old_town_num;
5944
5945         take_turn(p_ptr, 100);
5946
5947         /* Hack -- Character is no longer in "icky" mode */
5948         character_icky = FALSE;
5949
5950         /* Hack -- Cancel automatic command */
5951         command_new = 0;
5952
5953         /* Hack -- Cancel "see" mode */
5954         command_see = FALSE;
5955
5956         /* Allow expanding macros */
5957         get_com_no_macros = FALSE;
5958
5959         msg_erase();
5960         Term_clear();
5961
5962         /* Update everything */
5963         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
5964         p_ptr->update |= (PU_MONSTERS);
5965
5966         /* Redraw entire screen */
5967         p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5968         p_ptr->redraw |= (PR_MAP);
5969         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5970 }
5971
5972
5973
5974 /*!
5975  * @brief 現在の町の店主を交代させる /
5976  * Shuffle one of the stores.
5977  * @param which 店舗種類のID
5978  * @return なし
5979  */
5980 void store_shuffle(int which)
5981 {
5982         int i, j;
5983
5984
5985         /* Ignore home */
5986         if (which == STORE_HOME) return;
5987         if (which == STORE_MUSEUM) return;
5988
5989
5990         /* Save the store index */
5991         cur_store_num = which;
5992
5993         /* Activate that store */
5994         st_ptr = &town_info[p_ptr->town_num].store[cur_store_num];
5995
5996         j = st_ptr->owner;
5997         /* Pick a new owner */
5998         while(1)
5999         {
6000                 st_ptr->owner = (byte)randint0(MAX_OWNERS);
6001                 if (j == st_ptr->owner) continue;
6002                 for (i = 1;i < max_towns; i++)
6003                 {
6004                         if (i == p_ptr->town_num) continue;
6005                         if (st_ptr->owner == town_info[i].store[cur_store_num].owner) break;
6006                 }
6007                 if (i == max_towns) break;
6008         }
6009
6010         /* Activate the new owner */
6011         ot_ptr = &owners[cur_store_num][st_ptr->owner];
6012
6013
6014         /* Reset the owner data */
6015         st_ptr->insult_cur = 0;
6016         st_ptr->store_open = 0;
6017         st_ptr->good_buy = 0;
6018         st_ptr->bad_buy = 0;
6019
6020
6021         /* Hack -- discount all the items */
6022         for (i = 0; i < st_ptr->stock_num; i++)
6023         {
6024                 object_type *o_ptr;
6025
6026                 o_ptr = &st_ptr->stock[i];
6027
6028                 if (!object_is_artifact(o_ptr))
6029                 {
6030                         /* Hack -- Sell all non-artifact old items for "half price" */
6031                         o_ptr->discount = 50;
6032
6033                         /* Hack -- Items are no longer "fixed price" */
6034                         o_ptr->ident &= ~(IDENT_FIXED);
6035
6036                         /* Mega-Hack -- Note that the item is "on sale" */
6037                         o_ptr->inscription = quark_add(_("売出中", "on sale"));
6038                 }
6039         }
6040 }
6041
6042
6043 /*!
6044  * @brief 店の品揃えを変化させる /
6045  * Maintain the p_ptr->inventory_list at the stores.
6046  * @param town_num 町のID
6047  * @param store_num 店舗種類のID
6048  * @return なし
6049  */
6050 void store_maint(int town_num, int store_num)
6051 {
6052         INVENTORY_IDX j;
6053
6054         cur_store_num = store_num;
6055
6056         /* Ignore home */
6057         if (store_num == STORE_HOME) return;
6058         if (store_num == STORE_MUSEUM) return;
6059
6060         /* Activate that store */
6061         st_ptr = &town_info[town_num].store[store_num];
6062
6063         /* Activate the owner */
6064         ot_ptr = &owners[store_num][st_ptr->owner];
6065
6066         /* Store keeper forgives the player */
6067         st_ptr->insult_cur = 0;
6068
6069         /* Mega-Hack -- prune the black market */
6070         if (store_num == STORE_BLACK)
6071         {
6072                 /* Destroy crappy black market items */
6073                 for (j = st_ptr->stock_num - 1; j >= 0; j--)
6074                 {
6075                         object_type *o_ptr = &st_ptr->stock[j];
6076
6077                         /* Destroy crappy items */
6078                         if (black_market_crap(o_ptr))
6079                         {
6080                                 /* Destroy the item */
6081                                 store_item_increase(j, 0 - o_ptr->number);
6082                                 store_item_optimize(j);
6083                         }
6084                 }
6085         }
6086
6087
6088         /* Choose the number of slots to keep */
6089         j = st_ptr->stock_num;
6090
6091         /* Sell a few items */
6092         j = j - randint1(STORE_TURNOVER);
6093
6094         /* Never keep more than "STORE_MAX_KEEP" slots */
6095         if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
6096
6097         /* Always "keep" at least "STORE_MIN_KEEP" items */
6098         if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
6099
6100         /* Hack -- prevent "underflow" */
6101         if (j < 0) j = 0;
6102
6103         /* Destroy objects until only "j" slots are left */
6104         while (st_ptr->stock_num > j) store_delete();
6105
6106
6107         /* Choose the number of slots to fill */
6108         j = st_ptr->stock_num;
6109
6110         /* Buy some more items */
6111         j = j + randint1(STORE_TURNOVER);
6112
6113         /* Never keep more than "STORE_MAX_KEEP" slots */
6114         if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
6115
6116         /* Always "keep" at least "STORE_MIN_KEEP" items */
6117         if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
6118
6119         /* Hack -- prevent "overflow" */
6120         if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
6121
6122         /* Acquire some new items */
6123         while (st_ptr->stock_num < j) store_create();
6124 }
6125
6126
6127 /*!
6128  * @brief 店舗情報を初期化する /
6129  * Initialize the stores
6130  * @param town_num 町のID
6131  * @param store_num 店舗種類のID
6132  * @return なし
6133  */
6134 void store_init(int town_num, int store_num)
6135 {
6136         int k;
6137         cur_store_num = store_num;
6138
6139         /* Activate that store */
6140         st_ptr = &town_info[town_num].store[store_num];
6141
6142
6143         /* Pick an owner */
6144         while(1)
6145         {
6146                 int i;
6147
6148                 st_ptr->owner = (byte)randint0(MAX_OWNERS);
6149                 for (i = 1;i < max_towns; i++)
6150                 {
6151                         if (i == town_num) continue;
6152                         if (st_ptr->owner == town_info[i].store[store_num].owner) break;
6153                 }
6154                 if (i == max_towns) break;
6155         }
6156
6157         /* Activate the new owner */
6158         ot_ptr = &owners[store_num][st_ptr->owner];
6159
6160
6161         /* Initialize the store */
6162         st_ptr->store_open = 0;
6163         st_ptr->insult_cur = 0;
6164         st_ptr->good_buy = 0;
6165         st_ptr->bad_buy = 0;
6166
6167         /* Nothing in stock */
6168         st_ptr->stock_num = 0;
6169
6170         /*
6171          * MEGA-HACK - Last visit to store is
6172          * BEFORE player birth to enable store restocking
6173          */
6174         st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
6175
6176         /* Clear any old items */
6177         for (k = 0; k < st_ptr->stock_size; k++)
6178         {
6179                 object_wipe(&st_ptr->stock[k]);
6180         }
6181 }
6182
6183
6184 /*!
6185  * @brief アイテムを町のブラックマーケットに移動させる /
6186  * @param o_ptr 移動させたいオブジェクトの構造体参照ポインタ
6187  * @return なし
6188  */
6189 void move_to_black_market(object_type *o_ptr)
6190 {
6191         /* Not in town */
6192         if (!p_ptr->town_num) return;
6193
6194         st_ptr = &town_info[p_ptr->town_num].store[STORE_BLACK];
6195
6196         o_ptr->ident |= IDENT_STORE;
6197
6198         (void)store_carry(o_ptr);
6199
6200         object_wipe(o_ptr); /* Don't leave a bogus object behind... */
6201 }
6202