3 /* Purpose: Store commands */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
17 /* ²¼¤ÎÊý¤«¤é°ÜÆ°¤·¤Æ¤¤Þ¤·¤¿ */
18 static int cur_store_num = 0;
19 static int store_top = 0;
20 static store_type *st_ptr = NULL;
21 static owner_type *ot_ptr = NULL;
23 #define RUMOR_CHANCE 8
25 #define MAX_COMMENT_1 6
27 static cptr comment_1[MAX_COMMENT_1] =
48 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÄɲåá¥Ã¥»¡¼¥¸¡Ê¾µÂú¡Ë */
49 static cptr comment_1_B[MAX_COMMENT_1] = {
50 "¤Þ¤¢¡¢¤½¤ì¤Ç¤¤¤¤¤ä¡£",
51 "º£Æü¤Ï¤½¤ì¤Ç´ªÊÛ¤·¤Æ¤ä¤ë¡£",
58 #define MAX_COMMENT_2A 2
60 static cptr comment_2a[MAX_COMMENT_2A] =
63 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
64 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
66 "You try my patience. %s is final.",
67 "My patience grows thin. %s is final."
72 #define MAX_COMMENT_2B 12
74 static cptr comment_2b[MAX_COMMENT_2B] =
77 " $%s ¤°¤é¤¤¤Ï½Ð¤µ¤Ê¤¤ã¥À¥á¤À¤è¡£",
78 " $%s ¤Ê¤é¼õ¤±¼è¤Ã¤Æ¤â¤¤¤¤¤¬¡£",
79 "¥Ï¡ª $%s °Ê²¼¤Ï¤Ê¤¤¤Í¡£",
80 "²¿¤ÆÅÛ¤À¡ª $%s °Ê²¼¤Ï¤¢¤êÆÀ¤Ê¤¤¤¾¡£",
81 "¤½¤ì¤¸¤ã¾¯¤Ê¤¹¤®¤ë¡ª $%s ¤ÏÍߤ·¤¤¤È¤³¤í¤À¡£",
82 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤Ï¤â¤é¤ï¤Ê¤¤¤È¡£",
83 "±³¤À¤í¤¦¡ª $%s ¤Ç¤É¤¦¤À¤¤¡©",
84 "¤ª¤¤¤ª¤¤¡ª $%s ¤ò¹Í¤¨¤Æ¤¯¤ì¤Ê¤¤¤«¡©",
85 "1000ɤ¤Î¥ª¡¼¥¯¤Î¥Î¥ß¤Ë¶ì¤·¤á¤é¤ì¤ë¤¬¤¤¤¤¡ª $%s ¤À¡£",
86 "¤ªÁ°¤ÎÂçÀڤʤâ¤Î¤ËºÒ¤¤¤¢¤ì¡ª $%s ¤Ç¤É¤¦¤À¡£",
87 "¥â¥ë¥´¥¹¤Ë¾ÞÌ£¤µ¤ì¤ë¤¬¤¤¤¤¡ªËÜÅö¤Ï $%s ¤Ê¤ó¤À¤í¤¦¡©",
88 "¤ªÁ°¤ÎÊì¿Æ¤Ï¥ª¡¼¥¬¤«¡ª $%s ¤Ï½Ð¤¹¤Ä¤â¤ê¤Ê¤ó¤À¤í¡©"
90 "I can take no less than %s gold pieces.",
91 "I will accept no less than %s gold pieces.",
92 "Ha! No less than %s gold pieces.",
93 "You knave! No less than %s gold pieces.",
94 "That's a pittance! I want %s gold pieces.",
95 "That's an insult! I want %s gold pieces.",
96 "As if! How about %s gold pieces?",
97 "My arse! How about %s gold pieces?",
98 "May the fleas of 1000 orcs molest you! Try %s gold pieces.",
99 "May your most favourite parts go moldy! Try %s gold pieces.",
100 "May Morgoth find you tasty! Perhaps %s gold pieces?",
101 "Your mother was an Ogre! Perhaps %s gold pieces?"
107 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇä¤ë¤È¤¡Ë */
108 static cptr comment_2b_B[MAX_COMMENT_2B] = {
109 "¤¤¤¯¤é²¶Íͤ¬¤ª¿Í¹¥¤·¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¤Í¡£·ù¤Ê¤éµ¢¤ê¤Ê¡£",
110 "¶â¤¬¤Ê¤¤¤Î¤«¤¤¡¢¤¢¤ó¤¿¡©¤Þ¤º¤Ï²È¤Ëµ¢¤Ã¤Æ $%s ·¤¨¤Æ¤¤Ê¡£",
111 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅÛ¤À¤Ê¡£¤³¤ì¤Ï $%s ¤¬ÉáÄ̤ʤó¤À¤è¡£",
112 "²¶¤ÎÉÕ¤±¤¿ÃÍÃʤËʸ¶ç¤¬¤¢¤ë¤Î¤«¡© $%s ¤¬¸Â³¦¤À¡£",
113 "¤Ò¤ç¤Ã¤È¤·¤Æ¿·¼ê¤Î¾éÃ̤«¤¤¡© $%s »ý¤Ã¤Æ¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£",
114 "¤¦¤Á¤Ï¾¤ÎŹ¤È¤Ï°ã¤¦¤ó¤À¤è¡£$%s ¤°¤é¤¤¤Ï½Ð¤·¤Ê¡£",
115 "Ç㤦µ¤¤¬¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£ $%s ¤À¤È¸À¤Ã¤Æ¤¤¤ë¤ó¤À¡£",
116 "Ïäˤʤé¤Ê¤¤¤Í¡£ $%s ¤¯¤é¤¤»ý¤Ã¤Æ¤¤¤ë¤ó¤À¤í¡©",
117 "¤Ï¡©¤Ê¤ó¤À¤½¤ê¤ã¡© $%s ¤Î´Ö°ã¤¤¤«¡¢¤Ò¤ç¤Ã¤È¤·¤Æ¡©",
118 "½Ð¸ý¤Ï¤¢¤Ã¤Á¤À¤è¡£¤½¤ì¤È¤â $%s ½Ð¤»¤ë¤Î¤«¤¤¡¢¤¢¤ó¤¿¤Ë¡£",
119 "Ì¿ÃΤ餺¤ÊÅÛ¤À¤Ê¡£ $%s ½Ð¤»¤Ðº£Æü¤Î½ê¤Ï´ªÊÛ¤·¤Æ¤ä¤ë¤è¡£",
120 "¤¦¤Á¤ÎŹ¤ÏÉÏ˳¿Í¤ªÃǤê¤À¡£ $%s ¤°¤é¤¤½Ð¤»¤Ê¤¤¤Î¤«¤¤¡©"
123 #define MAX_COMMENT_3A 2
125 static cptr comment_3a[MAX_COMMENT_3A] =
128 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
129 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
131 "You try my patience. %s is final.",
132 "My patience grows thin. %s is final."
138 #define MAX_COMMENT_3B 12
140 static cptr comment_3b[MAX_COMMENT_3B] =
143 "Ëܲ»¤ò¸À¤¦¤È $%s ¤Ç¤¤¤¤¤ó¤À¤í¡©",
145 " $%s ¤°¤é¤¤¤Ê¤é½Ð¤·¤Æ¤â¤¤¤¤¤¬¡£",
146 " $%s °Ê¾åʧ¤¦¤Ê¤ó¤Æ¹Í¤¨¤é¤ì¤Ê¤¤¤Í¡£",
147 "¤Þ¤¢Íî¤Á¤Ä¤¤¤Æ¡£ $%s ¤Ç¤É¤¦¤À¤¤¡©",
148 "¤½¤Î¥¬¥é¥¯¥¿¤Ê¤é $%s ¤Ç°ú¤¼è¤ë¤è¡£",
149 "¤½¤ì¤¸¤ã¹â¤¹¤®¤ë¡ª $%s ¤¬¤¤¤¤¤È¤³¤À¤í¡£",
150 "¤É¤¦¤»¤¤¤é¤Ê¤¤¤ó¤À¤í¡ª $%s ¤Ç¤¤¤¤¤À¤í¡©",
151 "¤À¤á¤À¤á¡ª $%s ¤¬¤º¤Ã¤È¤ª»÷¹ç¤¤¤À¤è¡£",
152 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤¬¤»¤¤¤¼¤¤¤À¡£",
153 " $%s ¤Ê¤é´ò¤·¤¤¤È¤³¤í¤À¤¬¤Ê¤¢¡£",
154 " $%s ¡¢¤½¤ì°Ê¾å¤Ï¥Ó¥¿°ìʸ½Ð¤µ¤Ê¤¤¤è¡ª"
156 "Perhaps %s gold pieces?",
157 "How about %s gold pieces?",
158 "I will pay no more than %s gold pieces.",
159 "I can afford no more than %s gold pieces.",
160 "Be reasonable. How about %s gold pieces?",
161 "I'll buy it as scrap for %s gold pieces.",
162 "That is too much! How about %s gold pieces?",
163 "That looks war surplus! Say %s gold pieces?",
164 "Never! %s is more like it.",
165 "That's an insult! %s is more like it.",
166 "%s gold pieces and be thankful for it!",
167 "%s gold pieces and not a copper more!"
173 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇ㤤¼è¤ê¡Ë */
174 static cptr comment_3b_B[MAX_COMMENT_3B] = {
175 " $%s ¤Ã¤Æ¤È¤³¤í¤À¤Í¡£¤½¤Î¤É¤¦¤·¤è¤¦¤â¤Ê¤¤¥¬¥é¥¯¥¿¤Ï¡£",
176 "¤³¤Î²¶¤¬ $%s ¤Ã¤Æ¸À¤Ã¤Æ¤¤¤ë¤ó¤À¤«¤é¡¢¤½¤ÎÄ̤ê¤Ë¤·¤¿Êý¤¬¿È¤Î¤¿¤á¤À¤¾¡£",
177 "²¶¤ÎÍ¥¤·¤µ¤Ë´Å¤¨¤ë¤Î¤â¤¤¤¤²Ã¸º¤Ë¤·¤Æ¤ª¤±¡£ $%s ¤À¡£",
178 "¤½¤ÎÉʤʤé $%s ¤ÇÇä¤Ã¤Æ¤¯¤ì¤Æ¤¤¤ë¤¬¤Í¡¢¾ï¼±¤¢¤ë¿Â»Î¤Ï¤ß¤ó¤Ê¡£",
179 "¤³¤ê¤ã¤Þ¤¿¡¢¤¬¤á¤Ä¤¤ÅÛ¤À¤Ê¡£¤¤¤¯¤é²¶¤¬²¹¸ü¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¡£",
180 " $%s ¤À¡£Ê̤˲¶¤Ï¤½¤ó¤Ê¥¬¥é¥¯¥¿Íߤ·¤¯¤Ï¤Ê¤¤¤ó¤À¤«¤é¡£",
181 "²¶¤Î´ÕÄê³Û¤¬µ¤¤ËÆþ¤é¤Ê¤¤¤Î¤«¡© $%s ¡¢·ù¤Ê¤éµ¢¤ê¤Ê¡£",
182 " $%s ¤Ç°ú¤¼è¤Ã¤Æ¤ä¤ë¤è¡£´î¤ó¤Ç¼õ¤±¼è¤ê¤Ê¡¢ÉÏ˳¿Í¡£",
183 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅۤϻÏËö¤Ë¤ª¤¨¤ó¤Ê¡£¤½¤ì¤Ï $%s ¤Ê¤ó¤À¤è¡£",
184 "¤½¤ó¤Ê¤Ë¶â¤¬Íߤ·¤¤¤Î¤«¡¢¤¢¤ó¤¿¡© $%s ¤ÇËþ¤Ǥ¤ó¤Î¤«¡©",
185 "Æþ¤ëŹ´Ö°ã¤¨¤Æ¤ó¤¸¤ã¤Ê¤¤¤Î¤«¡© $%s ¤Ç·ù¤Ê¤é¾¤ò¤¢¤¿¤Ã¤Æ¤¯¤ì¡£",
186 "²¶¤Î¸À¤¤Ãͤ˥±¥Á¤ò¤Ä¤±¤ëÅÛ¤¬¤¤¤ë¤È¤Ï¡ª ¤½¤ÎÅÙ¶»¤ËÌȤ¸¤Æ $%s ¤À¡£"
189 #define MAX_COMMENT_4A 4
191 static cptr comment_4a[MAX_COMMENT_4A] =
194 "¤â¤¦¤¿¤¯¤µ¤ó¤À¡ª²¿ÅÙ¤â»ä¤ò¤ï¤º¤é¤ï¤»¤Ê¤¤¤Ç¤¯¤ì¡ª",
195 "¤¦¤¬¡¼¡ª°ìÆü¤Î²æËý¤Î¸ÂÅÙ¤òĶ¤¨¤Æ¤¤¤ë¡ª",
196 "¤â¤¦¤¤¤¤¡ª»þ´Ö¤Î̵Â̰ʳ°¤Î¤Ê¤Ë¤â¤Î¤Ç¤â¤Ê¤¤¡ª",
197 "¤â¤¦¤ä¤Ã¤Æ¤é¤ì¤Ê¤¤¤è¡ª´é¤â¸«¤¿¤¯¤Ê¤¤¡ª"
199 "Enough! You have abused me once too often!",
200 "Arghhh! I have had enough abuse for one day!",
201 "That does it! You shall waste my time no more!",
202 "This is getting nowhere! I'm going to Londis!"
208 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¤ÎĺÅÀ¡Ë */
209 static cptr comment_4a_B[MAX_COMMENT_4A] = {
210 "¤Ê¤á¤ä¤¬¤Ã¤Æ¡ª²¹¸ü¤Ê²¶ÍͤǤâ¸Â³¦¤¬¤¢¤ë¤Ã¤Æ¤³¤È¤òÃΤ졪",
211 "²¶¤ò¤³¤³¤Þ¤ÇÅܤ餻¤Æ...Ì¿¤¬¤¢¤ë¤À¤±¤Ç¤â¤¢¤ê¤¬¤¿¤¤¤È»×¤¨¡ª",
212 "¤Õ¤¶¤±¤Æ¤ë¤Î¤«¡ªÎä¤ä¤«¤·¤Ê¤éÁê¼ê¤ò¸«¤Æ¤«¤é¤Ë¤·¤í¡ª",
213 "¤¤¤¤¤«¤²¤ó¤Ë¤·¤í¡ªº£ÅÙ¤³¤ó¤Ê¤Þ¤Í¤·¤¿¤é¤¿¤À¤¸¤ã¤ª¤«¤Í¤¨¤¾¡ª"
216 #define MAX_COMMENT_4B 4
218 static cptr comment_4b[MAX_COMMENT_4B] =
222 "²¶¤ÎÁ°¤«¤é¾Ã¤¨¼º¤»¤í¡ª",
223 "¤É¤Ã¤«¤Ë¹Ô¤Ã¤Á¤Þ¤¨¡ª",
224 "½Ð¤í¡¢½Ð¤í¡¢½Ð¤Æ¹Ô¤±¡ª"
227 "Get out of my sight!",
228 "Begone, you scoundrel!",
235 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÄɤ¤½Ð¤·¡Ë */
236 static cptr comment_4b_B[MAX_COMMENT_4B] = {
237 "ÆóÅ٤Ȥ¦¤Á¤ËÍè¤ë¤ó¤¸¤ã¤Í¤¨¡ª¡ª",
238 "¤È¤Ã¤È¤È¡¢¤É¤Ã¤«¤Ø¼º¤»¤í¡ª¡ª",
239 "º£¤¹¤°¾Ã¤¨¼º¤»¤í¡ª¡ª",
240 "½Ð¤Æ¤¤¤±¡ª½Ð¤Æ¤¤¤±¡ª¡ª"
243 #define MAX_COMMENT_5 8
245 static cptr comment_5[MAX_COMMENT_5] =
250 "¤â¤Ã¤È¿¿ÌÌÌܤ˸À¤Ã¤Æ¤¯¤ì¡ª",
251 "¸ò¾Ä¤¹¤ëµ¤¤¬¤¢¤ë¤Î¤«¤¤¡©",
252 "Îä¤ä¤«¤·¤ËÍ褿¤Î¤«¡ª",
255 "¤Õ¡¼¤à¡¢Îɤ¤Å·µ¤¤À¡£"
259 "You will have to do better than that!",
260 "Do you wish to do business or not?",
261 "You've got to be kidding!",
262 "You'd better be kidding!",
263 "You try my patience.",
264 "Hmmm, nice weather we're having."
270 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¡Ë */
271 static cptr comment_5_B[MAX_COMMENT_5] = {
272 "»þ´Ö¤Î̵Â̤À¤Ê¡¢¤³¤ì¤Ï¡£",
273 "Ìñ²ð¤Ê¤ªµÒÍͤÀ¤Ê¡ª",
274 "Ïä·¤Æʬ¤«¤ëÁê¼ê¤¸¤ã¤Ê¤µ¤½¤¦¤À¡£",
275 "Äˤ¤Ìܤˤ¢¤¤¤¿¤¤¤é¤·¤¤¤Ê¡ª",
276 "¤Ê¤ó¤Æ¶¯ÍߤÊÅÛ¤À¡ª",
278 "¤É¤¦¤·¤è¤¦¤â¤Ê¤¤ÉÏ˳¿Í¤À¡ª",
279 "·ö²Þ¤òÇä¤Ã¤Æ¤¤¤ë¤Î¤«¡©"
282 #define MAX_COMMENT_6 4
284 static cptr comment_6[MAX_COMMENT_6] =
287 "¤É¤¦¤ä¤éʹ¤´Ö°ã¤¨¤¿¤é¤·¤¤¡£",
288 "¼ºÎé¡¢¤è¤¯Ê¹¤³¤¨¤Ê¤«¤Ã¤¿¤è¡£",
289 "¤¹¤Þ¤Ê¤¤¡¢²¿¤À¤Ã¤Æ¡©",
290 "°¤¤¡¢¤â¤¦°ìÅÙ¸À¤Ã¤Æ¤¯¤ì¤ë¡©"
292 "I must have heard you wrong.",
293 "I'm sorry, I missed that.",
294 "I'm sorry, what was that?",
295 "Sorry, what was that again?"
305 static void say_comment_1(void)
310 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
311 if ( cur_store_num == STORE_BLACK ) {
312 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
315 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
318 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
322 if (one_in_(RUMOR_CHANCE))
325 msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
327 msg_print("The shopkeeper whispers something into your ear:");
332 if (!get_rnd_line_jonly("rumors_j.txt", 0, rumour, 10))
334 if (!get_rnd_line("rumors.txt", 0, rumour))
343 * Continue haggling (player is buying)
345 static void say_comment_2(s32b value, int annoyed)
349 /* Prepare a string to insert */
350 sprintf(tmp_val, "%ld", (long)value);
355 /* Formatted message */
356 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
362 /* Formatted message */
364 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
365 if ( cur_store_num == STORE_BLACK ){
366 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
369 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
372 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
380 * Continue haggling (player is selling)
382 static void say_comment_3(s32b value, int annoyed)
386 /* Prepare a string to insert */
387 sprintf(tmp_val, "%ld", (long)value);
392 /* Formatted message */
393 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
399 /* Formatted message */
401 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
402 if ( cur_store_num == STORE_BLACK ){
403 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
406 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
409 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
417 * Kick 'da bum out. -RAK-
419 static void say_comment_4(void)
422 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
423 if ( cur_store_num == STORE_BLACK ){
424 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
425 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
428 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
429 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
432 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
433 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
440 * You are insulting me
442 static void say_comment_5(void)
445 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
446 if ( cur_store_num == STORE_BLACK ){
447 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
450 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
453 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
460 * That makes no sense.
462 static void say_comment_6(void)
464 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
470 * Messages for reacting to purchase prices.
473 #define MAX_COMMENT_7A 4
475 static cptr comment_7a[MAX_COMMENT_7A] =
480 "狼¤¬¤à¤»¤Óµã¤¯À¼¤¬Ê¹¤³¤¨¤ë...¡£",
481 "Ź¼ç¤¬²ù¤·¤²¤Ë¤ï¤á¤¤¤Æ¤¤¤ë¡ª"
485 "You hear someone sobbing...",
486 "The shopkeeper howls in agony!"
491 #define MAX_COMMENT_7B 4
493 static cptr comment_7b[MAX_COMMENT_7B] =
498 "Ź¼ç¤¬º¨¤á¤·¤½¤¦¤Ë¸«¤Æ¤¤¤ë¡£",
503 "The shopkeeper curses at you.",
504 "The shopkeeper glares at you."
509 #define MAX_COMMENT_7C 4
511 static cptr comment_7c[MAX_COMMENT_7C] =
515 "·¯¤¬Å·»È¤Ë¸«¤¨¤ë¤è¡ª",
516 "Ź¼ç¤¬¥¯¥¹¥¯¥¹¾Ð¤Ã¤Æ¤¤¤ë¡£",
517 "Ź¼ç¤¬ÂçÀ¼¤Ç¾Ð¤Ã¤Æ¤¤¤ë¡£"
520 "You've made my day!",
521 "The shopkeeper giggles.",
522 "The shopkeeper laughs loudly."
527 #define MAX_COMMENT_7D 4
529 static cptr comment_7d[MAX_COMMENT_7D] =
533 "¤³¤ó¤Ê¤ª¤¤¤·¤¤»×¤¤¤ò¤·¤¿¤é¡¢¿¿ÌÌÌܤËƯ¤±¤Ê¤¯¤Ê¤ë¤Ê¤¡¡£",
534 "Ź¼ç¤Ï´ò¤·¤¯¤ÆÄ·¤Í²ó¤Ã¤Æ¤¤¤ë¡£",
535 "Ź¼ç¤ÏËþÌ̤˾Фߤò¤¿¤¿¤¨¤Æ¤¤¤ë¡£"
538 "I think I'll retire!",
539 "The shopkeeper jumps for joy.",
540 "The shopkeeper smiles gleefully."
547 * Let a shop-keeper React to a purchase
549 * We paid "price", it was worth "value", and we thought it was worth "guess"
551 static void purchase_analyze(s32b price, s32b value, s32b guess)
553 /* Item was worthless, but we bought it */
554 if ((value <= 0) && (price > value))
557 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
559 chg_virtue(V_HONOUR, -1);
560 chg_virtue(V_JUSTICE, -1);
566 /* Item was cheaper than we thought, and we paid more than necessary */
567 else if ((value < guess) && (price > value))
570 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
572 chg_virtue(V_JUSTICE, -1);
574 chg_virtue(V_HONOUR, -1);
580 /* Item was a good bargain, and we got away with it */
581 else if ((value > guess) && (value < (4 * guess)) && (price < value))
584 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
587 chg_virtue(V_HONOUR, -1);
589 chg_virtue(V_HONOUR, 1);
595 /* Item was a great bargain, and we got away with it */
596 else if ((value > guess) && (price < value))
599 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
602 chg_virtue(V_HONOUR, -1);
604 chg_virtue(V_HONOUR, 1);
606 if (10 * price < value)
607 chg_virtue(V_SACRIFICE, 1);
619 /* ÆüËܸìÈǤξì¹ç¤Ï¾å¤ÎÊý¤Ë°ÜÆ°¤·¤Æ¤¢¤ê¤Þ¤¹ */
622 * We store the current "store number" here so everyone can access it
624 static int cur_store_num = 7;
627 * We store the current "store page" here so everyone can access it
629 static int store_top = 0;
632 * We store the current "store pointer" here so everyone can access it
634 static store_type *st_ptr = NULL;
637 * We store the current "owner type" here so everyone can access it
639 static owner_type *ot_ptr = NULL;
649 * Buying and selling adjustments for race combinations.
650 * Entry[owner][player] gives the basic "cost inflation".
652 static byte rgold_adj[MAX_RACES][MAX_RACES] =
654 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
655 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
656 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
660 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
661 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
662 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
663 100, 120, 110, 105 },
666 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
667 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
668 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
669 110, 115, 110, 110 },
672 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
673 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
674 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
675 110, 110, 105, 110 },
678 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
679 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
680 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
681 115, 120, 105, 115 },
684 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
685 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
686 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
687 115, 110, 110, 115 },
690 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
691 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
692 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
693 115, 110, 115, 115 },
696 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
697 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
698 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
699 115, 110, 115, 115 },
702 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
703 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
704 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
705 110, 110, 115, 110 },
708 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
709 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
710 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
711 100, 110, 110, 100 },
714 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
715 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
716 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
717 110, 110, 105, 110 },
719 /* Human / Barbarian (copied from human) */
720 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
721 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
722 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
723 100, 120, 110, 100 },
725 /* Half-Ogre: theoretical, copied from half-troll */
726 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
727 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
728 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
729 110, 110, 115, 110 },
731 /* Half-Giant: theoretical, copied from half-troll */
732 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
733 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
734 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
735 110, 110, 115, 110 },
737 /* Half-Titan: theoretical, copied from High_Elf */
738 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
739 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
740 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
741 110, 110, 115, 110 },
743 /* Cyclops: theoretical, copied from half-troll */
744 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
745 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
746 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
747 110, 110, 115, 110 },
749 /* Yeek: theoretical, copied from Half-Orc */
750 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
751 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
752 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
753 115, 110, 115, 115 },
755 /* Klackon: theoretical, copied from Gnome */
756 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
757 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
758 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
759 115, 110, 115, 115 },
761 /* Kobold: theoretical, copied from Half-Orc */
762 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
763 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
764 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
765 115, 110, 115, 115 },
767 /* Nibelung: theoretical, copied from Dwarf */
768 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
769 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
770 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
771 115, 135, 115, 115 },
774 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
775 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
776 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
777 110, 101, 115, 110 },
779 /* Draconian: theoretical, copied from High_Elf */
780 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
781 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
782 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
783 110, 110, 115, 110 },
785 /* Mind Flayer: theoretical, copied from High_Elf */
786 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
787 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
788 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
789 110, 110, 115, 110 },
791 /* Imp: theoretical, copied from High_Elf */
792 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
793 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
794 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
795 110, 110, 115, 110 },
797 /* Golem: theoretical, copied from High_Elf */
798 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
799 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
800 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
801 110, 110, 115, 110 },
803 /* Skeleton: theoretical, copied from half-orc */
804 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
805 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
806 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
807 115, 110, 125, 115 },
809 /* Zombie: Theoretical, copied from half-orc */
810 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
811 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
812 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
813 115, 110, 125, 115 },
815 /* Vampire: Theoretical, copied from half-orc */
816 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
817 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
818 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
819 115, 110, 125, 115 },
821 /* Spectre: Theoretical, copied from half-orc */
822 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
823 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
824 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
825 115, 110, 125, 115 },
827 /* Sprite: Theoretical, copied from half-orc */
828 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
829 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
830 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
831 115, 110, 105, 115 },
833 /* Beastman: Theoretical, copied from half-orc */
834 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
835 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
836 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
837 115, 110, 115, 115 },
840 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
841 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
842 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
843 110, 110, 105, 110 },
846 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
847 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
848 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
852 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
853 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
854 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
855 140, 140, 140, 140 },
858 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
859 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
860 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
861 100, 120, 110, 100 },
864 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
865 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
866 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
867 110, 101, 115, 110 },
870 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
871 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
872 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
873 110, 115, 100, 110 },
876 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
877 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
878 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
879 100, 120, 110, 100 },
886 * Determine the price of an item (qty one) in a store.
888 * This function takes into account the player's charisma, and the
889 * shop-keepers friendliness, and the shop-keeper's base greed, but
890 * never lets a shop-keeper lose money in a transaction.
892 * The "greed" value should exceed 100 when the player is "buying" the
893 * item, and should be less than 100 when the player is "selling" it.
895 * Hack -- the black market always charges twice as much as it should.
897 * Charisma adjustment runs from 80 to 130
898 * Racial adjustment runs from 95 to 130
900 * Since greed/charisma/racial adjustments are centered at 100, we need
901 * to adjust (by 200) to extract a usable multiplier. Note that the
902 * "greed" value is always something (?).
904 static s32b price_item(object_type *o_ptr, int greed, bool flip)
911 /* Get the value of one of the items */
912 price = object_value(o_ptr);
914 /* Worthless items */
915 if (price <= 0) return (0L);
918 /* Compute the racial factor */
919 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
921 /* Add in the charisma factor */
922 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
928 /* Adjust for greed */
929 adjust = 100 + (300 - (greed + factor));
931 /* Never get "silly" */
932 if (adjust > 100) adjust = 100;
934 /* Mega-Hack -- Black market sucks */
935 if (cur_store_num == STORE_BLACK)
939 /* Shop is selling */
942 /* Adjust for greed */
943 adjust = 100 + ((greed + factor) - 300);
945 /* Never get "silly" */
946 if (adjust < 100) adjust = 100;
948 /* Mega-Hack -- Black market sucks */
949 if (cur_store_num == STORE_BLACK)
953 /* Compute the final price (with rounding) */
954 price = (price * adjust + 50L) / 100L;
956 /* Note -- Never become "free" */
957 if (price <= 0L) return (1L);
959 /* Return the price */
965 * Certain "cheap" objects should be created in "piles"
966 * Some objects can be sold at a "discount" (in small piles)
968 static void mass_produce(object_type *o_ptr)
973 s32b cost = object_value(o_ptr);
976 /* Analyze the type */
979 /* Food, Flasks, and Lites */
984 if (cost <= 5L) size += damroll(3, 5);
985 if (cost <= 20L) size += damroll(3, 5);
992 if (cost <= 60L) size += damroll(3, 5);
993 if (cost <= 240L) size += damroll(1, 5);
994 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
995 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
1000 case TV_SORCERY_BOOK:
1001 case TV_NATURE_BOOK:
1005 case TV_ARCANE_BOOK:
1006 case TV_ENCHANT_BOOK:
1007 case TV_DAEMON_BOOK:
1008 case TV_CRUSADE_BOOK:
1010 case TV_HISSATSU_BOOK:
1012 if (cost <= 50L) size += damroll(2, 3);
1013 if (cost <= 500L) size += damroll(1, 3);
1031 if (o_ptr->name2) break;
1032 if (cost <= 10L) size += damroll(3, 5);
1033 if (cost <= 100L) size += damroll(3, 5);
1042 if (cost <= 5L) size += damroll(5, 5);
1043 if (cost <= 50L) size += damroll(5, 5);
1044 if (cost <= 500L) size += damroll(5, 5);
1050 if (cost <= 100L) size += damroll(2, 2);
1051 if (cost <= 1000L) size += damroll(2, 2);
1064 * Because many rods (and a few wands and staffs) are useful mainly
1065 * in quantity, the Black Market will occasionally have a bunch of
1072 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1074 if (cost < 1601L) size += damroll(1, 5);
1075 else if (cost < 3201L) size += damroll(1, 3);
1078 /* Ensure that mass-produced rods and wands get the correct pvals. */
1079 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1081 o_ptr->pval *= size;
1088 /* Pick a discount */
1093 else if (one_in_(25))
1097 else if (one_in_(150))
1101 else if (one_in_(300))
1105 else if (one_in_(500))
1111 if (o_ptr->art_name)
1113 if (cheat_peek && discount)
1116 msg_print("¥é¥ó¥À¥à¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÏÃÍ°ú¤¤Ê¤·¡£");
1118 msg_print("No discount on random artifacts.");
1125 /* Save the discount */
1126 o_ptr->discount = discount;
1128 /* Save the total pile size */
1129 o_ptr->number = size - (size * discount / 100);
1135 * Determine if a store item can "absorb" another item
1137 * See "object_similar()" for the same function for the "player"
1139 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1143 /* Hack -- Identical items cannot be stacked */
1144 if (o_ptr == j_ptr) return (0);
1146 /* Different objects cannot be stacked */
1147 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1149 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1150 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1152 /* Require many identical values */
1153 if (o_ptr->to_h != j_ptr->to_h) return (0);
1154 if (o_ptr->to_d != j_ptr->to_d) return (0);
1155 if (o_ptr->to_a != j_ptr->to_a) return (0);
1157 /* Require identical "artifact" names */
1158 if (o_ptr->name1 != j_ptr->name1) return (0);
1160 /* Require identical "ego-item" names */
1161 if (o_ptr->name2 != j_ptr->name2) return (0);
1163 /* Random artifacts don't stack !*/
1164 if (o_ptr->art_name || j_ptr->art_name) return (0);
1166 /* Hack -- Identical art_flags! */
1167 for (i = 0; i < TR_FLAG_SIZE; i++)
1168 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1170 /* Hack -- Never stack "powerful" items */
1171 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1173 /* Hack -- Never stack recharging items */
1174 if (o_ptr->timeout || j_ptr->timeout) return (0);
1176 /* Require many identical values */
1177 if (o_ptr->ac != j_ptr->ac) return (0);
1178 if (o_ptr->dd != j_ptr->dd) return (0);
1179 if (o_ptr->ds != j_ptr->ds) return (0);
1181 /* Hack -- Never stack chests */
1182 if (o_ptr->tval == TV_CHEST) return (0);
1183 if (o_ptr->tval == TV_STATUE) return (0);
1184 if (o_ptr->tval == TV_CAPTURE) return (0);
1186 /* Require matching discounts */
1187 if (o_ptr->discount != j_ptr->discount) return (0);
1189 /* They match, so they must be similar */
1195 * Allow a store item to absorb another item
1197 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1199 int total = o_ptr->number + j_ptr->number;
1201 /* Combine quantity, lose excess items */
1202 o_ptr->number = (total > 99) ? 99 : total;
1204 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1205 if (o_ptr->tval == TV_ROD)
1207 o_ptr->pval += j_ptr->pval;
1210 /* Hack -- if wands are stacking, combine the charges. -LM- */
1211 if (o_ptr->tval == TV_WAND)
1213 o_ptr->pval += j_ptr->pval;
1219 * Check to see if the shop will be carrying too many objects -RAK-
1220 * Note that the shop, just like a player, will not accept things
1221 * it cannot hold. Before, one could "nuke" potions this way.
1223 * Return value is now int:
1225 * -1 : Can be combined to existing slot.
1226 * 1 : Cannot be combined but there are empty spaces.
1228 static int store_check_num(object_type *o_ptr)
1233 /* The "home" acts like the player */
1234 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1236 /* Check all the items */
1237 for (i = 0; i < st_ptr->stock_num; i++)
1239 /* Get the existing item */
1240 j_ptr = &st_ptr->stock[i];
1242 /* Can the new object be combined with the old one? */
1243 if (object_similar(j_ptr, o_ptr)) return -1;
1247 /* Normal stores do special stuff */
1250 /* Check all the items */
1251 for (i = 0; i < st_ptr->stock_num; i++)
1253 /* Get the existing item */
1254 j_ptr = &st_ptr->stock[i];
1256 /* Can the new object be combined with the old one? */
1257 if (store_object_similar(j_ptr, o_ptr)) return -1;
1261 /* Free space is always usable */
1263 * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1264 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1266 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1267 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1272 if (st_ptr->stock_num < st_ptr->stock_size) {
1277 /* But there was no room at the inn... */
1282 static bool is_blessed(object_type *o_ptr)
1284 u32b flgs[TR_FLAG_SIZE];
1285 object_flags(o_ptr, flgs);
1286 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1287 else return (FALSE);
1293 * Determine if the current store will purchase the given item
1295 * Note that a shop-keeper must refuse to buy "worthless" items
1297 static bool store_will_buy(object_type *o_ptr)
1299 /* Hack -- The Home is simple */
1300 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1302 /* Switch on the store */
1303 switch (cur_store_num)
1308 /* Analyze the type */
1309 switch (o_ptr->tval)
1312 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1324 case TV_BOTTLE: /* 'Green', recycling Angband */
1339 /* Analyze the type */
1340 switch (o_ptr->tval)
1361 /* Analyze the type */
1362 switch (o_ptr->tval)
1371 case TV_HISSATSU_BOOK:
1375 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1387 /* Analyze the type */
1388 switch (o_ptr->tval)
1391 case TV_CRUSADE_BOOK:
1401 monster_race *r_ptr = &r_info[o_ptr->pval];
1404 if (!(r_ptr->flags3 & RF3_EVIL))
1407 if (r_ptr->flags3 & RF3_GOOD) break;
1409 /* Accept animals */
1410 if (r_ptr->flags3 & RF3_ANIMAL) break;
1413 if (strchr("?!", r_ptr->d_char)) break;
1419 if (is_blessed(o_ptr)) break;
1428 case STORE_ALCHEMIST:
1430 /* Analyze the type */
1431 switch (o_ptr->tval)
1445 /* Analyze the type */
1446 switch (o_ptr->tval)
1448 case TV_SORCERY_BOOK:
1449 case TV_NATURE_BOOK:
1453 case TV_ARCANE_BOOK:
1454 case TV_ENCHANT_BOOK:
1455 case TV_DAEMON_BOOK:
1468 if(o_ptr->sval == SV_WIZSTAFF) break;
1469 else return (FALSE);
1476 /* Bookstore Shop */
1479 /* Analyze the type */
1480 switch (o_ptr->tval)
1482 case TV_SORCERY_BOOK:
1483 case TV_NATURE_BOOK:
1488 case TV_ARCANE_BOOK:
1489 case TV_ENCHANT_BOOK:
1490 case TV_DAEMON_BOOK:
1491 case TV_CRUSADE_BOOK:
1501 /* XXX XXX XXX Ignore "worthless" items */
1502 if (object_value(o_ptr) <= 0) return (FALSE);
1511 * Add the item "o_ptr" to the inventory of the "Home"
1513 * In all cases, return the slot (or -1) where the object was placed
1515 * Note that this is a hacked up version of "inven_carry()".
1517 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1518 * known, the player may have to pick stuff up and drop it again.
1520 static int home_carry(object_type *o_ptr)
1523 s32b value, j_value;
1528 /* Check each existing item (try to combine) */
1529 for (slot = 0; slot < st_ptr->stock_num; slot++)
1531 /* Get the existing item */
1532 j_ptr = &st_ptr->stock[slot];
1534 /* The home acts just like the player */
1535 if (object_similar(j_ptr, o_ptr))
1537 /* Save the new number of items */
1538 object_absorb(j_ptr, o_ptr);
1547 * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1548 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1551 if ( powerup_home == TRUE) {
1552 if (st_ptr->stock_num >= st_ptr->stock_size) {
1557 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1563 /* Determine the "value" of the item */
1564 value = object_value(o_ptr);
1566 /* Check existing slots to see if we must "slide" */
1567 for (slot = 0; slot < st_ptr->stock_num; slot++)
1570 j_ptr = &st_ptr->stock[slot];
1572 /* Hack -- readable books always come first */
1573 if ((o_ptr->tval == mp_ptr->spell_book) &&
1574 (j_ptr->tval != mp_ptr->spell_book)) break;
1575 if ((j_ptr->tval == mp_ptr->spell_book) &&
1576 (o_ptr->tval != mp_ptr->spell_book)) continue;
1578 /* Objects sort by decreasing type */
1579 if (o_ptr->tval > j_ptr->tval) break;
1580 if (o_ptr->tval < j_ptr->tval) continue;
1582 /* Can happen in the home */
1583 if (!object_aware_p(o_ptr)) continue;
1584 if (!object_aware_p(j_ptr)) break;
1586 /* Objects sort by increasing sval */
1587 if (o_ptr->sval < j_ptr->sval) break;
1588 if (o_ptr->sval > j_ptr->sval) continue;
1590 /* Objects in the home can be unknown */
1591 if (!object_known_p(o_ptr)) continue;
1592 if (!object_known_p(j_ptr)) break;
1595 * Hack: otherwise identical rods sort by
1596 * increasing recharge time --dsb
1598 if (o_ptr->tval == TV_ROD)
1600 if (o_ptr->pval < j_ptr->pval) break;
1601 if (o_ptr->pval > j_ptr->pval) continue;
1603 if ((o_ptr->tval == TV_CORPSE) || (o_ptr->tval == TV_FIGURINE) || (o_ptr->tval == TV_STATUE))
1605 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) break;
1606 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) break;
1609 /* Objects sort by decreasing value */
1610 j_value = object_value(j_ptr);
1611 if (value > j_value) break;
1612 if (value < j_value) continue;
1615 /* Slide the others up */
1616 for (i = st_ptr->stock_num; i > slot; i--)
1618 st_ptr->stock[i] = st_ptr->stock[i-1];
1621 /* More stuff now */
1622 st_ptr->stock_num++;
1624 /* Insert the new item */
1625 st_ptr->stock[slot] = *o_ptr;
1627 chg_virtue(V_SACRIFICE, -1);
1629 /* Return the location */
1635 * Add the item "o_ptr" to a real stores inventory.
1637 * If the item is "worthless", it is thrown away (except in the home).
1639 * If the item cannot be combined with an object already in the inventory,
1640 * make a new slot for it, and calculate its "per item" price. Note that
1641 * this price will be negative, since the price will not be "fixed" yet.
1642 * Adding an item to a "fixed" price stack will not change the fixed price.
1644 * In all cases, return the slot (or -1) where the object was placed
1646 static int store_carry(object_type *o_ptr)
1649 s32b value, j_value;
1653 /* Evaluate the object */
1654 value = object_value(o_ptr);
1656 /* Cursed/Worthless items "disappear" when sold */
1657 if (value <= 0) return (-1);
1659 /* All store items are fully *identified* */
1660 o_ptr->ident |= IDENT_MENTAL;
1662 /* Erase the inscription */
1663 o_ptr->inscription = 0;
1665 /* Erase the "feeling" */
1666 o_ptr->feeling = FEEL_NONE;
1668 /* Check each existing item (try to combine) */
1669 for (slot = 0; slot < st_ptr->stock_num; slot++)
1671 /* Get the existing item */
1672 j_ptr = &st_ptr->stock[slot];
1674 /* Can the existing items be incremented? */
1675 if (store_object_similar(j_ptr, o_ptr))
1677 /* Hack -- extra items disappear */
1678 store_object_absorb(j_ptr, o_ptr);
1686 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1689 /* Check existing slots to see if we must "slide" */
1690 for (slot = 0; slot < st_ptr->stock_num; slot++)
1693 j_ptr = &st_ptr->stock[slot];
1695 /* Objects sort by decreasing type */
1696 if (o_ptr->tval > j_ptr->tval) break;
1697 if (o_ptr->tval < j_ptr->tval) continue;
1699 /* Objects sort by increasing sval */
1700 if (o_ptr->sval < j_ptr->sval) break;
1701 if (o_ptr->sval > j_ptr->sval) continue;
1704 * Hack: otherwise identical rods sort by
1705 * increasing recharge time --dsb
1707 if (o_ptr->tval == TV_ROD)
1709 if (o_ptr->pval < j_ptr->pval) break;
1710 if (o_ptr->pval > j_ptr->pval) continue;
1713 /* Evaluate that slot */
1714 j_value = object_value(j_ptr);
1716 /* Objects sort by decreasing value */
1717 if (value > j_value) break;
1718 if (value < j_value) continue;
1721 /* Slide the others up */
1722 for (i = st_ptr->stock_num; i > slot; i--)
1724 st_ptr->stock[i] = st_ptr->stock[i-1];
1727 /* More stuff now */
1728 st_ptr->stock_num++;
1730 /* Insert the new item */
1731 st_ptr->stock[slot] = *o_ptr;
1733 /* Return the location */
1739 * Increase, by a given amount, the number of a certain item
1740 * in a certain store. This can result in zero items.
1742 static void store_item_increase(int item, int num)
1748 o_ptr = &st_ptr->stock[item];
1750 /* Verify the number */
1751 cnt = o_ptr->number + num;
1752 if (cnt > 255) cnt = 255;
1753 else if (cnt < 0) cnt = 0;
1754 num = cnt - o_ptr->number;
1756 /* Save the new number */
1757 o_ptr->number += num;
1762 * Remove a slot if it is empty
1764 static void store_item_optimize(int item)
1770 o_ptr = &st_ptr->stock[item];
1773 if (!o_ptr->k_idx) return;
1775 /* Must have no items */
1776 if (o_ptr->number) return;
1779 st_ptr->stock_num--;
1781 /* Slide everyone */
1782 for (j = item; j < st_ptr->stock_num; j++)
1784 st_ptr->stock[j] = st_ptr->stock[j + 1];
1787 /* Nuke the final slot */
1788 object_wipe(&st_ptr->stock[j]);
1793 * This function will keep 'crap' out of the black market.
1794 * Crap is defined as any item that is "available" elsewhere
1795 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1797 static bool black_market_crap(object_type *o_ptr)
1801 /* Ego items are never crap */
1802 if (o_ptr->name2) return (FALSE);
1804 /* Good items are never crap */
1805 if (o_ptr->to_a > 0) return (FALSE);
1806 if (o_ptr->to_h > 0) return (FALSE);
1807 if (o_ptr->to_d > 0) return (FALSE);
1809 /* Check all stores */
1810 for (i = 0; i < MAX_STORES; i++)
1812 if (i == STORE_HOME) continue;
1813 if (i == STORE_MUSEUM) continue;
1815 /* Check every item in the store */
1816 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1818 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1820 /* Duplicate item "type", assume crappy */
1821 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
1831 * Attempt to delete (some of) a random item from the store
1832 * Hack -- we attempt to "maintain" piles of items when possible.
1834 static void store_delete(void)
1838 /* Pick a random slot */
1839 what = randint0(st_ptr->stock_num);
1841 /* Determine how many items are here */
1842 num = st_ptr->stock[what].number;
1844 /* Hack -- sometimes, only destroy half the items */
1845 if (randint0(100) < 50) num = (num + 1) / 2;
1847 /* Hack -- sometimes, only destroy a single item */
1848 if (randint0(100) < 50) num = 1;
1850 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
1851 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
1853 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
1856 /* Actually destroy (part of) the item */
1857 store_item_increase(what, -num);
1858 store_item_optimize(what);
1863 * Creates a random item and gives it to a store
1864 * This algorithm needs to be rethought. A lot.
1865 * Currently, "normal" stores use a pre-built array.
1867 * Note -- the "level" given to "obj_get_num()" is a "favored"
1868 * level, that is, there is a much higher chance of getting
1869 * items with a level approaching that of the given level...
1871 * Should we check for "permission" to have the given item?
1873 static void store_create(void)
1875 int i, tries, level;
1881 /* Paranoia -- no room left */
1882 if (st_ptr->stock_num >= st_ptr->stock_size) return;
1885 /* Hack -- consider up to four items */
1886 for (tries = 0; tries < 4; tries++)
1889 if (cur_store_num == STORE_BLACK)
1891 /* Pick a level for object/magic */
1892 level = 25 + randint0(25);
1894 /* Random item (usually of given level) */
1895 i = get_obj_num(level);
1897 /* Handle failure */
1904 /* Hack -- Pick an item to sell */
1905 i = st_ptr->table[randint0(st_ptr->table_num)];
1907 /* Hack -- fake level for apply_magic() */
1908 level = rand_range(1, STORE_OBJ_LEVEL);
1912 /* Get local object */
1915 /* Create a new object of the chosen kind */
1916 object_prep(q_ptr, i);
1918 /* Apply some "low-level" magic (no artifacts) */
1919 apply_magic(q_ptr, level, FALSE, FALSE, FALSE, FALSE);
1921 /* Require valid object */
1922 if (!store_will_buy(q_ptr)) continue;
1924 /* Hack -- Charge lite's */
1925 if (q_ptr->tval == TV_LITE)
1927 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
1928 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
1932 /* The item is "known" */
1933 object_known(q_ptr);
1935 /* Mark it storebought */
1936 q_ptr->ident |= IDENT_STOREB;
1938 /* Mega-Hack -- no chests in stores */
1939 if (q_ptr->tval == TV_CHEST) continue;
1941 /* Prune the black market */
1942 if (cur_store_num == STORE_BLACK)
1944 /* Hack -- No "crappy" items */
1945 if (black_market_crap(q_ptr)) continue;
1947 /* Hack -- No "cheap" items */
1948 if (object_value(q_ptr) < 10) continue;
1950 /* No "worthless" items */
1951 /* if (object_value(q_ptr) <= 0) continue; */
1954 /* Prune normal stores */
1957 /* No "worthless" items */
1958 if (object_value(q_ptr) <= 0) continue;
1962 /* Mass produce and/or Apply discount */
1963 mass_produce(q_ptr);
1965 /* Attempt to carry the (known) item */
1966 (void)store_carry(q_ptr);
1968 /* Definitely done */
1976 * Eliminate need to bargain if player has haggled well in the past
1978 static bool noneedtobargain(s32b minprice)
1980 s32b good = st_ptr->good_buy;
1981 s32b bad = st_ptr->bad_buy;
1983 /* Cheap items are "boring" */
1984 if (minprice < 10L) return (TRUE);
1986 /* Perfect haggling */
1987 if (good == MAX_SHORT) return (TRUE);
1989 /* Reward good haggles, punish bad haggles, notice price */
1990 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
1992 /* Return the flag */
1998 * Update the bargain info
2000 static void updatebargain(s32b price, s32b minprice, int num)
2002 /* Hack -- auto-haggle */
2003 if (!manual_haggle) return;
2005 /* Cheap items are "boring" */
2006 if ((minprice/num) < 10L) return;
2008 /* Count the successful haggles */
2009 if (price == minprice)
2011 /* Just count the good haggles */
2012 if (st_ptr->good_buy < MAX_SHORT)
2018 /* Count the failed haggles */
2021 /* Just count the bad haggles */
2022 if (st_ptr->bad_buy < MAX_SHORT)
2032 * Re-displays a single store entry
2034 static void display_entry(int pos)
2040 char o_name[MAX_NLEN];
2047 o_ptr = &st_ptr->stock[pos];
2049 /* Get the "offset" */
2052 /* Label it, clear the line --(-- */
2053 (void)sprintf(out_val, "%c) ", I2A(i));
2054 prt(out_val, i+6, 0);
2057 if (show_item_graph)
2059 byte a = object_attr(o_ptr);
2060 char c = object_char(o_ptr);
2067 Term_draw(cur_col, i + 6, a, c);
2072 Term_draw(cur_col, i + 6, 255, -1);
2077 /* Describe an item in the home */
2078 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2082 /* Leave room for weights, if necessary -DRS- */
2083 if (show_weights) maxwid -= 10;
2085 /* Describe the object */
2086 object_desc(o_name, o_ptr, TRUE, 3);
2087 o_name[maxwid] = '\0';
2088 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2093 /* Only show the weight of an individual item */
2094 int wgt = o_ptr->weight;
2096 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2097 put_str(out_val, i+6, 67);
2099 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2100 put_str(out_val, i+6, 68);
2106 /* Describe an item (fully) in a store */
2109 /* Must leave room for the "price" */
2112 /* Leave room for weights, if necessary -DRS- */
2113 if (show_weights) maxwid -= 7;
2115 /* Describe the object (fully) */
2116 object_desc_store(o_name, o_ptr, TRUE, 3);
2117 o_name[maxwid] = '\0';
2118 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2123 /* Only show the weight of an individual item */
2124 int wgt = o_ptr->weight;
2126 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2127 put_str(out_val, i+6, 60);
2129 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2130 put_str(out_val, i+6, 61);
2135 /* Display a "fixed" cost */
2136 if (o_ptr->ident & (IDENT_FIXED))
2138 /* Extract the "minimum" price */
2139 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2141 /* Actually draw the price (not fixed) */
2143 (void)sprintf(out_val, "%9ld¸Ç", (long)x);
2145 (void)sprintf(out_val, "%9ld F", (long)x);
2148 put_str(out_val, i+6, 68);
2151 /* Display a "taxed" cost */
2152 else if (!manual_haggle)
2154 /* Extract the "minimum" price */
2155 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2157 /* Hack -- Apply Sales Tax if needed */
2158 if (!noneedtobargain(x)) x += x / 10;
2160 /* Actually draw the price (with tax) */
2161 (void)sprintf(out_val, "%9ld ", (long)x);
2162 put_str(out_val, i+6, 68);
2165 /* Display a "haggle" cost */
2168 /* Extrect the "maximum" price */
2169 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2171 /* Actually draw the price (not fixed) */
2172 (void)sprintf(out_val, "%9ld ", (long)x);
2173 put_str(out_val, i+6, 68);
2180 * Displays a store's inventory -RAK-
2181 * All prices are listed as "per individual object". -BEN-
2183 static void display_inventory(void)
2187 /* Display the next 12 items */
2188 for (k = 0; k < 12; k++)
2190 /* Do not display "dead" items */
2191 if (store_top + k >= st_ptr->stock_num) break;
2193 /* Display that line */
2194 display_entry(store_top + k);
2197 /* Erase the extra lines and the "more" prompt */
2198 for (i = k; i < 13; i++) prt("", i + 6, 0);
2200 /* Assume "no current page" */
2202 put_str(" ", 5, 20);
2204 put_str(" ", 5, 20);
2208 /* Visual reminder of "more items" */
2209 if (st_ptr->stock_num > 12)
2211 /* Show "more" reminder (after the last item) */
2213 prt("-³¤¯-", k + 6, 3);
2215 prt("-more-", k + 6, 3);
2219 /* Indicate the "current page" */
2220 /* Trailing spaces are to display (Page xx) and (Page x) */
2222 put_str(format("(%d¥Ú¡¼¥¸) ", store_top/12 + 1), 5, 20);
2224 put_str(format("(Page %d) ", store_top/12 + 1), 5, 20);
2232 * Displays players gold -RAK-
2234 static void store_prt_gold(void)
2239 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19, 53);
2241 prt("Gold Remaining: ", 19, 53);
2245 sprintf(out_val, "%9ld", (long)p_ptr->au);
2246 prt(out_val, 19, 68);
2251 * Displays store (after clearing screen) -RAK-
2253 static void display_store(void)
2261 /* The "Home" is special */
2262 if (cur_store_num == STORE_HOME)
2264 /* Put the owner name */
2266 put_str("²æ¤¬²È", 3, 31);
2268 put_str("Your Home", 3, 30);
2272 /* Label the item descriptions */
2274 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2276 put_str("Item Description", 5, 3);
2280 /* If showing weights, show label */
2284 put_str("½Å¤µ", 5, 72);
2286 put_str("Weight", 5, 70);
2292 /* The "Home" is special */
2293 else if (cur_store_num == STORE_MUSEUM)
2295 /* Put the owner name */
2297 put_str("Çîʪ´Û", 3, 31);
2299 put_str("Museum", 3, 30);
2303 /* Label the item descriptions */
2305 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2307 put_str("Item Description", 5, 3);
2311 /* If showing weights, show label */
2315 put_str("½Å¤µ", 5, 72);
2317 put_str("Weight", 5, 70);
2326 cptr store_name = (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name);
2327 cptr owner_name = (ot_ptr->owner_name);
2328 cptr race_name = race_info[ot_ptr->owner_race].title;
2330 /* Put the owner name and race */
2331 sprintf(buf, "%s (%s)", owner_name, race_name);
2332 put_str(buf, 3, 10);
2334 /* Show the max price in the store (above prices) */
2335 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2338 /* Label the item descriptions */
2340 put_str("¾¦ÉʤΰìÍ÷", 5, 7);
2342 put_str("Item Description", 5, 3);
2346 /* If showing weights, show label */
2350 put_str("½Å¤µ", 5, 62);
2352 put_str("Weight", 5, 60);
2357 /* Label the asking price (in stores) */
2359 put_str("²Á³Ê", 5, 73);
2361 put_str("Price", 5, 72);
2366 /* Display the current gold */
2369 /* Draw in the inventory */
2370 display_inventory();
2376 * Get the ID of a store item and return its value -RAK-
2378 static int get_stock(int *com_val, cptr pmt, int i, int j)
2384 #ifdef ALLOW_REPEAT /* TNB */
2386 /* Get the item index */
2387 if (repeat_pull(com_val))
2389 /* Verify the item */
2390 if ((*com_val >= i) && (*com_val <= j))
2397 #endif /* ALLOW_REPEAT -- TNB */
2399 /* Paranoia XXX XXX XXX */
2403 /* Assume failure */
2406 /* Build the prompt */
2408 (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
2409 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
2410 I2A(i), I2A(j), pmt);
2412 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2413 I2A(i), I2A(j), pmt);
2417 /* Ask until done */
2423 if (!get_com(out_val, &command, FALSE)) break;
2426 k = (islower(command) ? A2I(command) : -1);
2428 /* Legal responses */
2429 if ((k >= i) && (k <= j))
2439 /* Clear the prompt */
2443 if (command == ESCAPE) return (FALSE);
2445 #ifdef ALLOW_REPEAT /* TNB */
2447 repeat_push(*com_val);
2449 #endif /* ALLOW_REPEAT -- TNB */
2457 * Increase the insult counter and get angry if too many -RAK-
2459 static int increase_insults(void)
2461 /* Increase insults */
2462 st_ptr->insult_cur++;
2464 /* Become insulted */
2465 if (st_ptr->insult_cur > ot_ptr->insult_max)
2471 st_ptr->insult_cur = 0;
2472 st_ptr->good_buy = 0;
2473 st_ptr->bad_buy = 0;
2476 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2488 * Decrease insults -RAK-
2490 static void decrease_insults(void)
2492 /* Decrease insults */
2493 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2498 * Have insulted while haggling -RAK-
2500 static int haggle_insults(void)
2502 /* Increase insults */
2503 if (increase_insults()) return (TRUE);
2505 /* Display and flush insult */
2514 * Mega-Hack -- Enable "increments"
2516 static bool allow_inc = FALSE;
2519 * Mega-Hack -- Last "increment" during haggling
2521 static s32b last_inc = 0L;
2527 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
2537 /* Clear old increment if necessary */
2538 if (!allow_inc) last_inc = 0L;
2545 sprintf(buf, "%s [¾µÂú] ", pmt);
2547 sprintf(buf, "%s [accept] ", pmt);
2552 /* Old (negative) increment, and not final */
2553 else if (last_inc < 0)
2556 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2558 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2563 /* Old (positive) increment, and not final */
2564 else if (last_inc > 0)
2567 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2569 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2577 sprintf(buf, "%s ", pmt);
2581 /* Paranoia XXX XXX XXX */
2585 /* Ask until done */
2589 strcpy(out_val, "");
2591 /* Ask the user for a response */
2592 if (!get_string(buf, out_val, 32)) return (FALSE);
2594 /* Skip leading spaces */
2595 for (p = out_val; *p == ' '; p++) /* loop */;
2597 /* Empty response */
2600 /* Accept current price */
2608 /* Use previous increment */
2609 if (allow_inc && last_inc)
2611 *poffer += last_inc;
2616 /* Normal response */
2619 /* Extract a number */
2622 /* Handle "incremental" number */
2623 if ((*p == '+' || *p == '-'))
2625 /* Allow increments */
2628 /* Use the given "increment" */
2635 /* Handle normal number */
2638 /* Use the given "number" */
2647 msg_print("Ãͤ¬¤ª¤«¤·¤¤¤Ç¤¹¡£");
2649 msg_print("Invalid response.");
2661 * Receive an offer (from the player)
2663 * Return TRUE if offer is NOT okay
2665 static bool receive_offer(cptr pmt, s32b *poffer,
2666 s32b last_offer, int factor,
2667 s32b price, int final)
2669 /* Haggle till done */
2672 /* Get a haggle (or cancel) */
2673 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2675 /* Acceptable offer */
2676 if (((*poffer) * factor) >= (last_offer * factor)) break;
2678 /* Insult, and check for kicked out */
2679 if (haggle_insults()) return (TRUE);
2681 /* Reject offer (correctly) */
2682 (*poffer) = last_offer;
2691 * Haggling routine -RAK-
2693 * Return TRUE if purchase is NOT successful
2695 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2697 s32b cur_ask, final_ask;
2698 s32b last_offer, offer;
2700 s32b min_per, max_per;
2701 int flag, loop_flag, noneed;
2702 int annoyed = 0, final = FALSE;
2704 bool cancel = FALSE;
2707 cptr pmt = "Ä󼨲Á³Ê";
2709 cptr pmt = "Asking";
2719 /* Extract the starting offer and the final offer */
2720 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2721 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2723 /* Determine if haggling is necessary */
2724 noneed = noneedtobargain(final_ask);
2726 /* No need to haggle */
2727 if (noneed || !manual_haggle)
2729 /* No need to haggle */
2732 /* Message summary */
2734 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2736 msg_print("You eventually agree upon the price.");
2742 /* No haggle option */
2745 /* Message summary */
2747 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2749 msg_print("You quickly agree upon the price.");
2754 /* Apply Sales Tax */
2755 final_ask += final_ask / 10;
2759 cur_ask = final_ask;
2761 /* Go to final offer */
2763 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2765 pmt = "Final Offer";
2772 /* Haggle for the whole pile */
2773 cur_ask *= o_ptr->number;
2774 final_ask *= o_ptr->number;
2777 /* Haggle parameters */
2778 min_per = ot_ptr->haggle_per;
2779 max_per = min_per * 3;
2781 /* Mega-Hack -- artificial "last offer" value */
2782 last_offer = object_value(o_ptr) * o_ptr->number;
2783 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
2784 if (last_offer <= 0) last_offer = 1;
2789 /* No incremental haggling yet */
2792 /* Haggle until done */
2793 for (flag = FALSE; !flag; )
2797 while (!flag && loop_flag)
2799 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
2800 put_str(out_val, 1, 0);
2802 cancel = receive_offer("Ä󼨤¹¤ë¶â³Û? ",
2804 cancel = receive_offer("What do you offer? ",
2807 &offer, last_offer, 1, cur_ask, final);
2813 else if (offer > cur_ask)
2818 else if (offer == cur_ask)
2831 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
2834 if (haggle_insults())
2840 else if (x1 > max_per)
2843 if (x1 < max_per) x1 = max_per;
2845 x2 = rand_range(x1-2, x1+2);
2846 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
2847 /* don't let the price go up */
2852 if (cur_ask < final_ask)
2855 cur_ask = final_ask;
2857 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2859 pmt = "Final Offer";
2865 (void)(increase_insults());
2870 else if (offer >= cur_ask)
2882 (void)sprintf(out_val, "Á°²ó¤ÎÄ󼨶â³Û: $%ld",
2884 (void)sprintf(out_val, "Your last offer: %ld",
2888 put_str(out_val, 1, 39);
2889 say_comment_2(cur_ask, annoyed);
2895 if (cancel) return (TRUE);
2897 /* Update bargaining info */
2898 updatebargain(*price, final_ask, o_ptr->number);
2906 * Haggling routine -RAK-
2908 * Return TRUE if purchase is NOT successful
2910 static bool sell_haggle(object_type *o_ptr, s32b *price)
2912 s32b purse, cur_ask, final_ask;
2913 s32b last_offer = 0, offer = 0;
2915 s32b min_per, max_per;
2916 int flag, loop_flag, noneed;
2917 int annoyed = 0, final = FALSE;
2918 bool cancel = FALSE;
2920 cptr pmt = "Ä󼨶â³Û";
2931 /* Obtain the starting offer and the final offer */
2932 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
2933 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
2935 /* Determine if haggling is necessary */
2936 noneed = noneedtobargain(final_ask);
2938 /* Get the owner's payout limit */
2939 purse = (s32b)(ot_ptr->max_cost);
2941 /* No need to haggle */
2942 if (noneed || !manual_haggle || (final_ask >= purse))
2944 /* Apply Sales Tax (if needed) */
2945 if (!manual_haggle && !noneed)
2947 final_ask -= final_ask / 10;
2950 /* No reason to haggle */
2951 if (final_ask >= purse)
2955 msg_print("¨ºÂ¤Ë¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2957 msg_print("You instantly agree upon the price.");
2962 /* Offer full purse */
2966 /* No need to haggle */
2971 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2973 msg_print("You eventually agree upon the price.");
2979 /* No haggle option */
2982 /* Message summary */
2984 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2986 msg_print("You quickly agree upon the price.");
2993 cur_ask = final_ask;
2998 pmt = "ºÇ½ªÄ󼨶â³Û";
3000 pmt = "Final Offer";
3005 /* Haggle for the whole pile */
3006 cur_ask *= o_ptr->number;
3007 final_ask *= o_ptr->number;
3010 /* XXX XXX XXX Display commands */
3012 /* Haggling parameters */
3013 min_per = ot_ptr->haggle_per;
3014 max_per = min_per * 3;
3016 /* Mega-Hack -- artificial "last offer" value */
3017 last_offer = object_value(o_ptr) * o_ptr->number;
3018 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3023 /* No incremental haggling yet */
3027 for (flag = FALSE; !flag; )
3033 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3034 put_str(out_val, 1, 0);
3036 cancel = receive_offer("Ä󼨤¹¤ë²Á³Ê? ",
3038 cancel = receive_offer("What price do you ask? ",
3041 &offer, last_offer, -1, cur_ask, final);
3047 else if (offer < cur_ask)
3050 /* rejected, reset offer for incremental haggling */
3053 else if (offer == cur_ask)
3064 if (flag || !loop_flag) break;
3069 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3072 if (haggle_insults())
3078 else if (x1 > max_per)
3081 if (x1 < max_per) x1 = max_per;
3083 x2 = rand_range(x1-2, x1+2);
3084 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3085 /* don't let the price go down */
3089 if (cur_ask > final_ask)
3091 cur_ask = final_ask;
3094 pmt = "ºÇ½ªÄ󼨶â³Û";
3096 pmt = "Final Offer";
3104 /* Äɲà $0 ¤ÇÇ㤤¼è¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ»ß By FIRST*/
3107 (void)(increase_insults());
3110 else if (offer <= cur_ask)
3121 (void)sprintf(out_val,
3123 "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
3125 "Your last bid %ld", (long)last_offer);
3128 put_str(out_val, 1, 39);
3129 say_comment_3(cur_ask, annoyed);
3135 if (cancel) return (TRUE);
3137 /* Update bargaining info */
3138 updatebargain(*price, final_ask, o_ptr->number);
3146 * Buy an item from a store -RAK-
3148 static void store_purchase(void)
3160 char o_name[MAX_NLEN];
3165 if (cur_store_num == STORE_MUSEUM)
3168 msg_print("Çîʪ´Û¤«¤é¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
3170 msg_print("Museum.");
3176 if (st_ptr->stock_num <= 0)
3178 if (cur_store_num == STORE_HOME)
3180 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3182 msg_print("Your home is empty.");
3187 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
3189 msg_print("I am currently out of stock.");
3196 /* Find the number of objects on this and following pages */
3197 i = (st_ptr->stock_num - store_top);
3199 /* And then restrict it to the current page */
3204 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
3205 switch( cur_store_num ) {
3207 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
3210 sprintf(out_val, "¤É¤ì? ");
3213 sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
3217 if (cur_store_num == STORE_HOME)
3219 sprintf(out_val, "Which item do you want to take? ");
3223 sprintf(out_val, "Which item are you interested in? ");
3228 /* Get the item number to be bought */
3229 if (!get_stock(&item, out_val, 0, i - 1)) return;
3231 /* Get the actual index */
3232 item = item + store_top;
3234 /* Get the actual item */
3235 o_ptr = &st_ptr->stock[item];
3237 /* Assume the player wants just one of them */
3240 /* Get local object */
3243 /* Get a copy of the object */
3244 object_copy(j_ptr, o_ptr);
3247 * If a rod or wand, allocate total maximum timeouts or charges
3248 * between those purchased and left on the shelf.
3250 reduce_charges(j_ptr, o_ptr->number - amt);
3252 /* Modify quantity */
3253 j_ptr->number = amt;
3255 /* Hack -- require room in pack */
3256 if (!inven_carry_okay(j_ptr))
3259 msg_print("¤½¤ó¤Ê¤Ë¥¢¥¤¥Æ¥à¤ò»ý¤Æ¤Ê¤¤¡£");
3261 msg_print("You cannot carry that many different items.");
3267 /* Determine the "best" price (per item) */
3268 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3270 /* Find out how many the player wants */
3271 if (o_ptr->number > 1)
3273 /* Hack -- note cost of "fixed" items */
3274 if ((cur_store_num != STORE_HOME) &&
3275 (o_ptr->ident & IDENT_FIXED))
3278 msg_format("°ì¤Ä¤Ë¤Ä¤ $%ld¤Ç¤¹¡£", (long)(best));
3280 msg_format("That costs %ld gold per item.", (long)(best));
3285 /* Get a quantity */
3286 amt = get_quantity(NULL, o_ptr->number);
3288 /* Allow user abort */
3289 if (amt <= 0) return;
3292 /* Get local object */
3295 /* Get desired object */
3296 object_copy(j_ptr, o_ptr);
3299 * If a rod or wand, allocate total maximum timeouts or charges
3300 * between those purchased and left on the shelf.
3302 reduce_charges(j_ptr, o_ptr->number - amt);
3304 /* Modify quantity */
3305 j_ptr->number = amt;
3307 /* Hack -- require room in pack */
3308 if (!inven_carry_okay(j_ptr))
3311 msg_print("¥¶¥Ã¥¯¤Ë¤½¤Î¥¢¥¤¥Æ¥à¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£");
3313 msg_print("You cannot carry that many items.");
3319 /* Attempt to buy it */
3320 if (cur_store_num != STORE_HOME)
3322 /* Fixed price, quick buy */
3323 if (o_ptr->ident & (IDENT_FIXED))
3328 /* Go directly to the "best" deal */
3329 price = (best * j_ptr->number);
3335 /* Describe the object (fully) */
3336 object_desc_store(o_name, j_ptr, TRUE, 3);
3340 msg_format("%s(%c)¤ò¹ØÆþ¤¹¤ë¡£", o_name, I2A(item));
3342 msg_format("Buying %s (%c).", o_name, I2A(item));
3347 /* Haggle for a final price */
3348 choice = purchase_haggle(j_ptr, &price);
3350 /* Hack -- Got kicked out */
3351 if (st_ptr->store_open >= turn) return;
3354 /* Player wants it */
3357 /* Fix the item price (if "correctly" haggled) */
3358 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3360 /* Player can afford it */
3361 if (p_ptr->au >= price)
3368 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3369 chg_virtue(V_JUSTICE, -1);
3370 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3371 chg_virtue(V_NATURE, -1);
3379 /* Spend the money */
3382 /* Update the display */
3385 /* Hack -- buying an item makes you aware of it */
3386 object_aware(j_ptr);
3388 /* Hack -- clear the "fixed" flag from the item */
3389 j_ptr->ident &= ~(IDENT_FIXED);
3391 /* Describe the transaction */
3392 object_desc(o_name, j_ptr, TRUE, 3);
3396 msg_format("%s¤ò $%ld¤Ç¹ØÆþ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3398 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3401 strcpy(record_o_name, o_name);
3404 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3405 object_desc(o_name, o_ptr, TRUE, 0);
3406 if(record_rand_art && o_ptr->art_name)
3407 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3409 /* Erase the inscription */
3410 j_ptr->inscription = 0;
3412 /* Erase the "feeling" */
3413 j_ptr->feeling = FEEL_NONE;
3414 j_ptr->ident &= ~(IDENT_STOREB);
3415 /* Give it to the player */
3416 item_new = inven_carry(j_ptr);
3418 /* Describe the final result */
3419 object_desc(o_name, &inventory[item_new], TRUE, 3);
3423 msg_format("%s(%c)¤ò¼ê¤ËÆþ¤ì¤¿¡£", o_name, index_to_label(item_new));
3425 msg_format("You have %s (%c).",
3426 o_name, index_to_label(item_new));
3429 /* Auto-inscription */
3430 idx = is_autopick(&inventory[item_new]);
3431 auto_inscribe_item(item_new, idx);
3433 /* Now, reduce the original stack's pval. */
3434 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3436 o_ptr->pval -= j_ptr->pval;
3442 /* Note how many slots the store used to have */
3443 i = st_ptr->stock_num;
3445 /* Remove the bought items from the store */
3446 store_item_increase(item, -amt);
3447 store_item_optimize(item);
3449 /* Store is empty */
3450 if (st_ptr->stock_num == 0)
3453 if (one_in_(STORE_SHUFFLE))
3458 msg_print("Ź¼ç¤Ï°úÂष¤¿¡£");
3460 msg_print("The shopkeeper retires.");
3464 /* Shuffle the store */
3465 store_shuffle(cur_store_num);
3468 sprintf(buf, "%s (%s)",
3469 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3470 put_str(buf, 3, 10);
3471 sprintf(buf, "%s (%ld)",
3472 (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name), (long)(ot_ptr->max_cost));
3481 msg_print("Ź¼ç¤Ï¿·¤¿¤Êºß¸Ë¤ò¼è¤ê½Ð¤·¤¿¡£");
3483 msg_print("The shopkeeper brings out some new stock.");
3489 for (i = 0; i < 10; i++)
3491 /* Maintain the store */
3492 store_maint(p_ptr->town_num, cur_store_num);
3498 /* Redraw everything */
3499 display_inventory();
3502 /* The item is gone */
3503 else if (st_ptr->stock_num != i)
3505 /* Pick the correct screen */
3506 if (store_top >= st_ptr->stock_num) store_top -= 12;
3508 /* Redraw everything */
3509 display_inventory();
3512 /* Item is still here */
3515 /* Redraw the item */
3516 display_entry(item);
3520 /* Player cannot afford it */
3523 /* Simple message (no insult) */
3525 msg_print("¤ª¶â¤¬Â¤ê¤Þ¤»¤ó¡£");
3527 msg_print("You do not have enough gold.");
3534 /* Home is much easier */
3537 /* Distribute charges of wands/rods */
3538 distribute_charges(o_ptr, j_ptr, amt);
3540 /* Give it to the player */
3541 item_new = inven_carry(j_ptr);
3543 /* Describe just the result */
3544 object_desc(o_name, &inventory[item_new], TRUE, 3);
3548 msg_format("%s(%c)¤ò¼è¤Ã¤¿¡£",
3550 msg_format("You have %s (%c).",
3552 o_name, index_to_label(item_new));
3557 /* Take note if we take the last one */
3558 i = st_ptr->stock_num;
3560 /* Remove the items from the home */
3561 store_item_increase(item, -amt);
3562 store_item_optimize(item);
3564 /* Hack -- Item is still here */
3565 if (i == st_ptr->stock_num)
3567 /* Redraw the item */
3568 display_entry(item);
3571 /* The item is gone */
3575 if (st_ptr->stock_num == 0) store_top = 0;
3577 /* Nothing left on that screen */
3578 else if (store_top >= st_ptr->stock_num) store_top -= 12;
3580 /* Redraw everything */
3581 display_inventory();
3583 chg_virtue(V_SACRIFICE, 1);
3587 /* Not kicked out */
3593 * Sell an item to the store (or home)
3595 static void store_sell(void)
3601 s32b price, value, dummy;
3610 char o_name[MAX_NLEN];
3613 /* Prepare a prompt */
3614 if (cur_store_num == STORE_HOME)
3616 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÃÖ¤¤Þ¤¹¤«? ";
3618 q = "Drop which item? ";
3621 else if (cur_store_num == STORE_MUSEUM)
3623 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ó£¤·¤Þ¤¹¤«? ";
3625 q = "Give which item? ";
3630 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÇä¤ê¤Þ¤¹¤«? ";
3632 q = "Sell which item? ";
3636 item_tester_no_ryoute = TRUE;
3637 /* Only allow items the store will buy */
3638 item_tester_hook = store_will_buy;
3641 /* ²æ¤¬²È¤Ç¤ª¤«¤·¤Ê¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¥ª¥ê¥¸¥Ê¥ë¤Î¥Ð¥°¤ò½¤Àµ */
3642 if (cur_store_num == STORE_HOME)
3645 s = "ÃÖ¤±¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3647 s = "You don't have any item to drop.";
3650 else if (cur_store_num == STORE_MUSEUM)
3653 s = "´ó£¤Ç¤¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3655 s = "You don't have any item to give.";
3661 s = "Íߤ·¤¤Êª¤¬¤Ê¤¤¤Ç¤¹¤Í¤¨¡£";
3663 s = "You have nothing that I want.";
3667 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3669 /* Get the item (in the pack) */
3672 o_ptr = &inventory[item];
3675 /* Get the item (on the floor) */
3678 o_ptr = &o_list[0 - item];
3682 /* Hack -- Cannot remove cursed items */
3683 if ((item >= INVEN_RARM) && cursed_p(o_ptr))
3687 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¤Í¡£");
3689 msg_print("Hmmm, it seems to be cursed.");
3698 /* Assume one item */
3701 /* Find out how many the player wants (letter means "all") */
3702 if (o_ptr->number > 1)
3704 /* Get a quantity */
3705 amt = get_quantity(NULL, o_ptr->number);
3707 /* Allow user abort */
3708 if (amt <= 0) return;
3711 /* Get local object */
3714 /* Get a copy of the object */
3715 object_copy(q_ptr, o_ptr);
3717 /* Modify quantity */
3718 q_ptr->number = amt;
3721 * Hack -- If a rod or wand, allocate total maximum
3722 * timeouts or charges to those being sold. -LM-
3724 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3726 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3729 /* Get a full description */
3730 object_desc(o_name, q_ptr, TRUE, 3);
3732 /* Remove any inscription, feeling for stores */
3733 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3735 q_ptr->inscription = 0;
3736 q_ptr->feeling = FEEL_NONE;
3739 /* Is there room in the store (or the home?) */
3740 if (!store_check_num(q_ptr))
3742 if (cur_store_num == STORE_HOME)
3744 msg_print("²æ¤¬²È¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤Ê¤¤¡£");
3746 msg_print("Your home is full.");
3749 else if (cur_store_num == STORE_MUSEUM)
3751 msg_print("Çîʪ´Û¤Ï¤â¤¦ËþÇÕ¤À¡£");
3753 msg_print("Museum is full.");
3758 msg_print("¤¹¤¤¤Þ¤»¤ó¤¬¡¢Å¹¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤¢¤ê¤Þ¤»¤ó¡£");
3760 msg_print("I have not the room in my store to keep it.");
3768 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3770 /* Describe the transaction */
3772 msg_format("%s(%c)¤òÇäµÑ¤¹¤ë¡£", o_name, index_to_label(item));
3774 msg_format("Selling %s (%c).", o_name, index_to_label(item));
3780 choice = sell_haggle(q_ptr, &price);
3783 if (st_ptr->store_open >= turn) return;
3795 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3796 chg_virtue(V_JUSTICE, -1);
3798 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3799 chg_virtue(V_NATURE, 1);
3802 /* Get some money */
3805 /* Update the display */
3808 /* Get the "apparent" value */
3809 dummy = object_value(q_ptr) * q_ptr->number;
3812 identify_item(o_ptr);
3814 /* Get local object */
3817 /* Get a copy of the object */
3818 object_copy(q_ptr, o_ptr);
3820 /* Modify quantity */
3821 q_ptr->number = amt;
3824 * Hack -- If a rod or wand, let the shopkeeper know just
3825 * how many charges he really paid for. -LM-
3827 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3829 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3832 /* Get the "actual" value */
3833 value = object_value(q_ptr) * q_ptr->number;
3835 /* Get the description all over again */
3836 object_desc(o_name, q_ptr, TRUE, 3);
3838 /* Describe the result (in message buffer) */
3840 msg_format("%s¤ò $%ld¤ÇÇäµÑ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3842 msg_format("You sold %s for %ld gold.", o_name, (long)price);
3845 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
3847 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
3849 /* Analyze the prices (and comment verbally) unless a figurine*/
3850 purchase_analyze(price, value, dummy);
3854 * Hack -- Allocate charges between those wands or rods sold
3855 * and retained, unless all are being sold. -LM-
3857 distribute_charges(o_ptr, q_ptr, amt);
3859 /* Reset timeouts of the sold items */
3862 /* Take the item from the player, describe the result */
3863 inven_item_increase(item, -amt);
3864 inven_item_describe(item);
3865 inven_item_optimize(item);
3870 /* The store gets that (known) item */
3871 item_pos = store_carry(q_ptr);
3873 /* Re-display if item is now in store */
3876 store_top = (item_pos / 12) * 12;
3877 display_inventory();
3882 /* Player is at museum */
3883 else if (cur_store_num == STORE_MUSEUM)
3885 char o2_name[MAX_NLEN];
3886 object_desc(o2_name, q_ptr, TRUE, 0);
3888 if (-1 == store_check_num(q_ptr))
3891 msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£");
3893 msg_print("The same object as it is already in the Museum.");
3899 msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª¡ª");
3901 msg_print("You cannot take items which is given to the Museum back!!");
3905 if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return;
3907 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
3911 identify_item(q_ptr);
3912 q_ptr->ident |= IDENT_MENTAL;
3914 /* Distribute charges of wands/rods */
3915 distribute_charges(o_ptr, q_ptr, amt);
3919 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
3921 msg_format("You drop %s (%c).", o_name, index_to_label(item));
3926 /* Take it from the players inventory */
3927 inven_item_increase(item, -amt);
3928 inven_item_describe(item);
3929 inven_item_optimize(item);
3934 /* Let the home carry it */
3935 item_pos = home_carry(q_ptr);
3937 /* Update store display */
3940 store_top = (item_pos / 12) * 12;
3941 display_inventory();
3944 /* Player is at home */
3947 /* Distribute charges of wands/rods */
3948 distribute_charges(o_ptr, q_ptr, amt);
3952 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
3954 msg_format("You drop %s (%c).", o_name, index_to_label(item));
3959 /* Take it from the players inventory */
3960 inven_item_increase(item, -amt);
3961 inven_item_describe(item);
3962 inven_item_optimize(item);
3967 /* Let the home carry it */
3968 item_pos = home_carry(q_ptr);
3970 /* Update store display */
3973 store_top = (item_pos / 12) * 12;
3974 display_inventory();
3977 if (item >= INVEN_RARM) calc_android_exp();
3978 if ((choice == 0) && ((item == INVEN_RARM) || (item == INVEN_LARM))) kamaenaoshi(item);
3983 * Examine an item in a store -JDL-
3985 static void store_examine(void)
3990 char o_name[MAX_NLEN];
3995 if (st_ptr->stock_num <= 0)
3997 if (cur_store_num == STORE_HOME)
3999 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4001 msg_print("Your home is empty.");
4004 else if (cur_store_num == STORE_MUSEUM)
4006 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4008 msg_print("Museum is empty.");
4013 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
4015 msg_print("I am currently out of stock.");
4022 /* Find the number of objects on this and following pages */
4023 i = (st_ptr->stock_num - store_top);
4025 /* And then restrict it to the current page */
4030 sprintf(out_val, "¤É¤ì¤òÄ´¤Ù¤Þ¤¹¤«¡©");
4032 sprintf(out_val, "Which item do you want to examine? ");
4036 /* Get the item number to be examined */
4037 if (!get_stock(&item, out_val, 0, i - 1)) return;
4039 /* Get the actual index */
4040 item = item + store_top;
4042 /* Get the actual item */
4043 o_ptr = &st_ptr->stock[item];
4045 /* Require full knowledge */
4046 if (!(o_ptr->ident & IDENT_MENTAL))
4048 /* This can only happen in the home */
4050 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
4052 msg_print("You have no special knowledge about that item.");
4059 object_desc(o_name, o_ptr, TRUE, 3);
4063 msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
4065 msg_format("Examining %s...", o_name);
4069 /* Describe it fully */
4070 if (!screen_object(o_ptr, TRUE))
4072 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
4074 msg_print("You see nothing special.");
4083 * Hack -- set this to leave the store
4085 static bool leave_store = FALSE;
4089 * Process a command in a store
4091 * Note that we must allow the use of a few "special" commands
4092 * in the stores which are not allowed in the dungeon, and we
4093 * must disable some commands which are allowed in the dungeon
4094 * but not in the stores, to prevent chaos.
4096 static void store_process_command(void)
4098 #ifdef ALLOW_REPEAT /* TNB */
4100 /* Handle repeating the last command */
4103 #endif /* ALLOW_REPEAT -- TNB */
4105 if (rogue_like_commands && command_cmd == 'l')
4107 command_cmd = 'x'; /* hack! */
4110 /* Parse the command */
4111 switch (command_cmd)
4121 /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
4124 if (st_ptr->stock_num <= 12) {
4126 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4128 msg_print("Entire inventory is shown.");
4133 if ( store_top < 0 )
4134 store_top = ((st_ptr->stock_num - 1 )/12) * 12;
4135 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4136 if ( store_top >= 12 ) store_top = 12;
4137 display_inventory();
4145 if (st_ptr->stock_num <= 12)
4148 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4150 msg_print("Entire inventory is shown.");
4158 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
4159 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
4161 if ((cur_store_num == STORE_HOME) &&
4162 (powerup_home == FALSE) &&
4163 (st_ptr->stock_num >= STORE_INVEN_MAX))
4165 if (store_top >= (STORE_INVEN_MAX - 1))
4172 if (store_top >= st_ptr->stock_num) store_top = 0;
4175 display_inventory();
4188 /* Get (purchase) */
4215 /*** Inventory Commands ***/
4217 /* Wear/wield equipment */
4224 /* Take off equipment */
4231 /* Destroy an item */
4238 /* Equipment list */
4245 /* Inventory list */
4253 /*** Various commands ***/
4255 /* Identify an object */
4262 /* Hack -- toggle windows */
4265 toggle_inven_equip();
4271 /*** Use various objects ***/
4280 /* Inscribe an object */
4287 /* Uninscribe an object */
4290 do_cmd_uninscribe();
4296 /*** Help and Such ***/
4305 /* Identify symbol */
4308 do_cmd_query_symbol();
4312 /* Character description */
4315 do_cmd_change_name();
4321 /*** System Commands ***/
4323 /* Hack -- User interface */
4330 /* Single line from a pref file */
4337 /* Interact with macros */
4344 /* Interact with visuals */
4351 /* Interact with colors */
4358 /* Interact with options */
4365 /*** Misc Commands ***/
4381 /* Repeat level feeling */
4388 /* Show previous message */
4391 do_cmd_message_one();
4395 /* Show previous messages */
4408 /* Check artifacts, uniques etc. */
4415 /* Load "screen dump" */
4418 do_cmd_load_screen();
4422 /* Save "screen dump" */
4425 do_cmd_save_screen();
4429 /* Hack -- Unknown command */
4433 msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
4435 msg_print("That command does not work in stores.");
4445 * Enter a store, and interact with it.
4447 * Note that we use the standard "request_command()" function
4448 * to get a command, allowing us to use "command_arg" and all
4449 * command macros and other nifty stuff, but we use the special
4450 * "shopping" argument, to force certain commands to be converted
4451 * into other commands, normally, we convert "p" (pray) and "m"
4452 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4454 void do_cmd_store(void)
4464 /* Access the player grid */
4465 c_ptr = &cave[py][px];
4467 /* Verify a store */
4468 if (!((c_ptr->feat >= FEAT_SHOP_HEAD) &&
4469 (c_ptr->feat <= FEAT_SHOP_TAIL)) &&
4470 (c_ptr->feat != FEAT_MUSEUM))
4473 msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
4475 msg_print("You see no store here.");
4481 /* Extract the store code */
4482 if (c_ptr->feat == FEAT_MUSEUM) which = STORE_MUSEUM;
4483 else which = (c_ptr->feat - FEAT_SHOP_HEAD);
4485 old_town_num = p_ptr->town_num;
4486 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4487 if (dun_level) p_ptr->town_num = NO_TOWN;
4489 /* Hack -- Check the "locked doors" */
4490 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4494 msg_print("¥É¥¢¤Ë¸°¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£");
4496 msg_print("The doors are locked.");
4499 p_ptr->town_num = old_town_num;
4503 /* Calculate the number of store maintainances since the last visit */
4504 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TURNS);
4506 /* Maintain the store max. 10 times */
4507 if (maintain_num > 10) maintain_num = 10;
4511 /* Maintain the store */
4512 for (i = 0; i < maintain_num; i++)
4513 store_maint(p_ptr->town_num, which);
4515 /* Save the visit */
4516 town[p_ptr->town_num].store[which].last_visit = turn;
4519 /* Forget the lite */
4522 /* Forget the view */
4526 /* Hack -- Character is in "icky" mode */
4527 character_icky = TRUE;
4530 /* No command argument */
4533 /* No repeated command */
4536 /* No automatic command */
4540 /* Save the store number */
4541 cur_store_num = which;
4543 /* Save the store and owner pointers */
4544 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4545 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4548 /* Start at the beginning */
4551 /* Display the store */
4555 leave_store = FALSE;
4557 /* Interact with player */
4558 while (!leave_store)
4560 /* Hack -- Clear line 1 */
4563 /* Hack -- Check the charisma */
4564 tmp_chr = p_ptr->stat_use[A_CHR];
4570 /* Basic commands */
4572 prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21, 0);
4574 prt(" ESC) Exit from Building.", 21, 0);
4578 /* Browse if necessary */
4579 if (st_ptr->stock_num > 12)
4582 prt(" -)Á°¥Ú¡¼¥¸", 22, 0);
4583 prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23, 0);
4585 prt(" -) Previous page", 22, 0);
4586 prt(" SPACE) Next page", 23, 0);
4592 if (cur_store_num == STORE_HOME)
4595 prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
4596 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
4597 prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
4599 prt("g) Get an item.", 21, 27);
4600 prt("d) Drop an item.", 22, 27);
4601 prt("x) eXamine an item in the home.", 23,27);
4606 /* Museum commands */
4607 else if (cur_store_num == STORE_MUSEUM)
4610 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
4611 prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
4613 prt("d) Drop an item.", 21, 27);
4614 prt("x) eXamine an item in the museum.", 23,27);
4619 /* Shop commands XXX XXX XXX */
4623 prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
4624 prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
4625 prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,30);
4627 prt("p) Purchase an item.", 21, 30);
4628 prt("s) Sell an item.", 22, 30);
4629 prt("x) eXamine an item in the shop", 23,30);
4635 /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
4637 prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56);
4639 if( rogue_like_commands == TRUE )
4641 prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
4645 prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
4648 prt("i/e) Inventry/Equipment list", 21, 56);
4650 if( rogue_like_commands == TRUE )
4652 prt("w/T) Wear/Take off equipment", 22, 56);
4656 prt("w/t) Wear/Take off equipment", 22, 56);
4661 prt("¥³¥Þ¥ó¥É:", 20, 0);
4663 prt("You may: ", 20, 0);
4668 request_command(TRUE);
4670 /* Process the command */
4671 store_process_command();
4673 /* Hack -- Character is still in "icky" mode */
4674 character_icky = TRUE;
4682 /* XXX XXX XXX Pack Overflow */
4683 if (inventory[INVEN_PACK].k_idx)
4685 int item = INVEN_PACK;
4687 object_type *o_ptr = &inventory[item];
4689 /* Hack -- Flee from the store */
4690 if (cur_store_num != STORE_HOME)
4694 if (cur_store_num == STORE_MUSEUM)
4695 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆÇîʪ´Û¤«¤é½Ð¤¿...");
4697 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆŹ¤«¤é½Ð¤¿...");
4699 if (cur_store_num == STORE_MUSEUM)
4700 msg_print("Your pack is so full that you flee the Museum...");
4702 msg_print("Your pack is so full that you flee the store...");
4710 /* Hack -- Flee from the home */
4711 else if (!store_check_num(o_ptr))
4715 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤Æ²È¤«¤é½Ð¤¿...");
4717 msg_print("Your pack is so full that you flee your home...");
4725 /* Hack -- Drop items into the home */
4733 char o_name[MAX_NLEN];
4736 /* Give a message */
4738 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
4740 msg_print("Your pack overflows!");
4744 /* Get local object */
4747 /* Grab a copy of the item */
4748 object_copy(q_ptr, o_ptr);
4751 object_desc(o_name, q_ptr, TRUE, 3);
4755 msg_format("%s¤¬Íî¤Á¤¿¡£(%c)", o_name, index_to_label(item));
4757 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4761 /* Remove it from the players inventory */
4762 inven_item_increase(item, -255);
4763 inven_item_describe(item);
4764 inven_item_optimize(item);
4769 /* Let the home carry it */
4770 item_pos = home_carry(q_ptr);
4772 /* Redraw the home */
4775 store_top = (item_pos / 12) * 12;
4776 display_inventory();
4781 /* Hack -- Redisplay store prices if charisma changes */
4782 if (tmp_chr != p_ptr->stat_use[A_CHR]) display_inventory();
4784 /* Hack -- get kicked out of the store */
4785 if (st_ptr->store_open >= turn) leave_store = TRUE;
4788 p_ptr->town_num = old_town_num;
4790 /* Free turn XXX XXX XXX */
4794 /* Hack -- Character is no longer in "icky" mode */
4795 character_icky = FALSE;
4798 /* Hack -- Cancel automatic command */
4801 /* Hack -- Cancel "see" mode */
4802 command_see = FALSE;
4805 /* Flush messages XXX XXX XXX */
4809 /* Clear the screen */
4813 /* Update everything */
4814 p_ptr->update |= (PU_VIEW | PU_LITE);
4815 p_ptr->update |= (PU_MONSTERS);
4817 /* Redraw entire screen */
4818 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
4821 p_ptr->redraw |= (PR_MAP);
4824 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4830 * Shuffle one of the stores.
4832 void store_shuffle(int which)
4838 if (which == STORE_HOME) return;
4839 if (which == STORE_MUSEUM) return;
4842 /* Save the store index */
4843 cur_store_num = which;
4845 /* Activate that store */
4846 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4849 /* Pick a new owner */
4852 st_ptr->owner = (byte)randint0(MAX_OWNERS);
4853 if (j == st_ptr->owner) continue;
4854 for (i = 1;i < max_towns; i++)
4856 if (i == p_ptr->town_num) continue;
4857 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
4859 if (i == max_towns) break;
4862 /* Activate the new owner */
4863 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4866 /* Reset the owner data */
4867 st_ptr->insult_cur = 0;
4868 st_ptr->store_open = 0;
4869 st_ptr->good_buy = 0;
4870 st_ptr->bad_buy = 0;
4873 /* Hack -- discount all the items */
4874 for (i = 0; i < st_ptr->stock_num; i++)
4879 o_ptr = &st_ptr->stock[i];
4881 /* Hack -- Sell all old items for "half price" */
4882 if (!(o_ptr->art_name))
4883 o_ptr->discount = 50;
4885 /* Hack -- Items are no longer "fixed price" */
4886 o_ptr->ident &= ~(IDENT_FIXED);
4888 /* Mega-Hack -- Note that the item is "on sale" */
4890 o_ptr->inscription = quark_add("Çä½ÐÃæ");
4892 o_ptr->inscription = quark_add("on sale");
4900 * Maintain the inventory at the stores.
4902 void store_maint(int town_num, int store_num)
4906 int old_rating = rating;
4908 cur_store_num = store_num;
4911 if (store_num == STORE_HOME) return;
4912 if (store_num == STORE_MUSEUM) return;
4914 /* Activate that store */
4915 st_ptr = &town[town_num].store[store_num];
4917 /* Activate the owner */
4918 ot_ptr = &owners[store_num][st_ptr->owner];
4920 /* Store keeper forgives the player */
4921 st_ptr->insult_cur = 0;
4923 /* Mega-Hack -- prune the black market */
4924 if (store_num == STORE_BLACK)
4926 /* Destroy crappy black market items */
4927 for (j = st_ptr->stock_num - 1; j >= 0; j--)
4929 object_type *o_ptr = &st_ptr->stock[j];
4931 /* Destroy crappy items */
4932 if (black_market_crap(o_ptr))
4934 /* Destroy the item */
4935 store_item_increase(j, 0 - o_ptr->number);
4936 store_item_optimize(j);
4942 /* Choose the number of slots to keep */
4943 j = st_ptr->stock_num;
4945 /* Sell a few items */
4946 j = j - randint1(STORE_TURNOVER);
4948 /* Never keep more than "STORE_MAX_KEEP" slots */
4949 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
4951 /* Always "keep" at least "STORE_MIN_KEEP" items */
4952 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
4954 /* Hack -- prevent "underflow" */
4957 /* Destroy objects until only "j" slots are left */
4958 while (st_ptr->stock_num > j) store_delete();
4961 /* Choose the number of slots to fill */
4962 j = st_ptr->stock_num;
4964 /* Buy some more items */
4965 j = j + randint1(STORE_TURNOVER);
4967 /* Never keep more than "STORE_MAX_KEEP" slots */
4968 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
4970 /* Always "keep" at least "STORE_MIN_KEEP" items */
4971 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
4973 /* Hack -- prevent "overflow" */
4974 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
4976 /* Acquire some new items */
4977 while (st_ptr->stock_num < j) store_create();
4980 /* Hack -- Restore the rating */
4981 rating = old_rating;
4986 * Initialize the stores
4988 void store_init(int town_num, int store_num)
4992 cur_store_num = store_num;
4994 /* Activate that store */
4995 st_ptr = &town[town_num].store[store_num];
5003 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5004 for (i = 1;i < max_towns; i++)
5006 if (i == town_num) continue;
5007 if (st_ptr->owner == town[i].store[store_num].owner) break;
5009 if (i == max_towns) break;
5012 /* Activate the new owner */
5013 ot_ptr = &owners[store_num][st_ptr->owner];
5016 /* Initialize the store */
5017 st_ptr->store_open = 0;
5018 st_ptr->insult_cur = 0;
5019 st_ptr->good_buy = 0;
5020 st_ptr->bad_buy = 0;
5022 /* Nothing in stock */
5023 st_ptr->stock_num = 0;
5026 * MEGA-HACK - Last visit to store is
5027 * BEFORE player birth to enable store restocking
5029 st_ptr->last_visit = -200L * STORE_TURNS;
5031 /* Clear any old items */
5032 for (k = 0; k < st_ptr->stock_size; k++)
5034 object_wipe(&st_ptr->stock[k]);
5039 void move_to_black_market(object_type *o_ptr)
5042 if (!p_ptr->town_num) return;
5044 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5046 o_ptr->ident |= IDENT_STOREB;
5048 (void)store_carry(o_ptr);
5050 object_wipe(o_ptr); /* Don't leave a bogus object behind... */