4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Store commands */
17 static int cur_store_num = 0;
18 static int store_top = 0;
19 static int store_bottom = 0;
20 static int xtra_stock = 0;
21 static store_type *st_ptr = NULL;
22 static owner_type *ot_ptr = NULL;
23 static s16b old_town_num = 0;
24 static s16b inner_town_num = 0;
25 #define RUMOR_CHANCE 8
27 #define MAX_COMMENT_1 6
29 static cptr comment_1[MAX_COMMENT_1] =
50 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÄɲåá¥Ã¥»¡¼¥¸¡Ê¾µÂú¡Ë */
51 static cptr comment_1_B[MAX_COMMENT_1] = {
52 "¤Þ¤¢¡¢¤½¤ì¤Ç¤¤¤¤¤ä¡£",
53 "º£Æü¤Ï¤½¤ì¤Ç´ªÊÛ¤·¤Æ¤ä¤ë¡£",
60 #define MAX_COMMENT_2A 2
62 static cptr comment_2a[MAX_COMMENT_2A] =
65 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
66 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
68 "You try my patience. %s is final.",
69 "My patience grows thin. %s is final."
74 #define MAX_COMMENT_2B 12
76 static cptr comment_2b[MAX_COMMENT_2B] =
79 " $%s ¤°¤é¤¤¤Ï½Ð¤µ¤Ê¤¤ã¥À¥á¤À¤è¡£",
80 " $%s ¤Ê¤é¼õ¤±¼è¤Ã¤Æ¤â¤¤¤¤¤¬¡£",
81 "¥Ï¡ª $%s °Ê²¼¤Ï¤Ê¤¤¤Í¡£",
82 "²¿¤ÆÅÛ¤À¡ª $%s °Ê²¼¤Ï¤¢¤êÆÀ¤Ê¤¤¤¾¡£",
83 "¤½¤ì¤¸¤ã¾¯¤Ê¤¹¤®¤ë¡ª $%s ¤ÏÍߤ·¤¤¤È¤³¤í¤À¡£",
84 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤Ï¤â¤é¤ï¤Ê¤¤¤È¡£",
85 "±³¤À¤í¤¦¡ª $%s ¤Ç¤É¤¦¤À¤¤¡©",
86 "¤ª¤¤¤ª¤¤¡ª $%s ¤ò¹Í¤¨¤Æ¤¯¤ì¤Ê¤¤¤«¡©",
87 "1000ɤ¤Î¥ª¡¼¥¯¤Î¥Î¥ß¤Ë¶ì¤·¤á¤é¤ì¤ë¤¬¤¤¤¤¡ª $%s ¤À¡£",
88 "¤ªÁ°¤ÎÂçÀڤʤâ¤Î¤ËºÒ¤¤¤¢¤ì¡ª $%s ¤Ç¤É¤¦¤À¡£",
89 "¥â¥ë¥´¥¹¤Ë¾ÞÌ£¤µ¤ì¤ë¤¬¤¤¤¤¡ªËÜÅö¤Ï $%s ¤Ê¤ó¤À¤í¤¦¡©",
90 "¤ªÁ°¤ÎÊì¿Æ¤Ï¥ª¡¼¥¬¤«¡ª $%s ¤Ï½Ð¤¹¤Ä¤â¤ê¤Ê¤ó¤À¤í¡©"
92 "I can take no less than %s gold pieces.",
93 "I will accept no less than %s gold pieces.",
94 "Ha! No less than %s gold pieces.",
95 "You knave! No less than %s gold pieces.",
96 "That's a pittance! I want %s gold pieces.",
97 "That's an insult! I want %s gold pieces.",
98 "As if! How about %s gold pieces?",
99 "My arse! How about %s gold pieces?",
100 "May the fleas of 1000 orcs molest you! Try %s gold pieces.",
101 "May your most favourite parts go moldy! Try %s gold pieces.",
102 "May Morgoth find you tasty! Perhaps %s gold pieces?",
103 "Your mother was an Ogre! Perhaps %s gold pieces?"
109 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇä¤ë¤È¤¡Ë */
110 static cptr comment_2b_B[MAX_COMMENT_2B] = {
111 "¤¤¤¯¤é²¶Íͤ¬¤ª¿Í¹¥¤·¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¤Í¡£·ù¤Ê¤éµ¢¤ê¤Ê¡£",
112 "¶â¤¬¤Ê¤¤¤Î¤«¤¤¡¢¤¢¤ó¤¿¡©¤Þ¤º¤Ï²È¤Ëµ¢¤Ã¤Æ $%s ·¤¨¤Æ¤¤Ê¡£",
113 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅÛ¤À¤Ê¡£¤³¤ì¤Ï $%s ¤¬ÉáÄ̤ʤó¤À¤è¡£",
114 "²¶¤ÎÉÕ¤±¤¿ÃÍÃʤËʸ¶ç¤¬¤¢¤ë¤Î¤«¡© $%s ¤¬¸Â³¦¤À¡£",
115 "¤Ò¤ç¤Ã¤È¤·¤Æ¿·¼ê¤Î¾éÃ̤«¤¤¡© $%s »ý¤Ã¤Æ¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£",
116 "¤¦¤Á¤Ï¾¤ÎŹ¤È¤Ï°ã¤¦¤ó¤À¤è¡£$%s ¤°¤é¤¤¤Ï½Ð¤·¤Ê¡£",
117 "Ç㤦µ¤¤¬¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£ $%s ¤À¤È¸À¤Ã¤Æ¤¤¤ë¤ó¤À¡£",
118 "Ïäˤʤé¤Ê¤¤¤Í¡£ $%s ¤¯¤é¤¤»ý¤Ã¤Æ¤¤¤ë¤ó¤À¤í¡©",
119 "¤Ï¡©¤Ê¤ó¤À¤½¤ê¤ã¡© $%s ¤Î´Ö°ã¤¤¤«¡¢¤Ò¤ç¤Ã¤È¤·¤Æ¡©",
120 "½Ð¸ý¤Ï¤¢¤Ã¤Á¤À¤è¡£¤½¤ì¤È¤â $%s ½Ð¤»¤ë¤Î¤«¤¤¡¢¤¢¤ó¤¿¤Ë¡£",
121 "Ì¿ÃΤ餺¤ÊÅÛ¤À¤Ê¡£ $%s ½Ð¤»¤Ðº£Æü¤Î½ê¤Ï´ªÊÛ¤·¤Æ¤ä¤ë¤è¡£",
122 "¤¦¤Á¤ÎŹ¤ÏÉÏ˳¿Í¤ªÃǤê¤À¡£ $%s ¤°¤é¤¤½Ð¤»¤Ê¤¤¤Î¤«¤¤¡©"
125 #define MAX_COMMENT_3A 2
127 static cptr comment_3a[MAX_COMMENT_3A] =
130 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
131 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
133 "You try my patience. %s is final.",
134 "My patience grows thin. %s is final."
140 #define MAX_COMMENT_3B 12
142 static cptr comment_3b[MAX_COMMENT_3B] =
145 "Ëܲ»¤ò¸À¤¦¤È $%s ¤Ç¤¤¤¤¤ó¤À¤í¡©",
147 " $%s ¤°¤é¤¤¤Ê¤é½Ð¤·¤Æ¤â¤¤¤¤¤¬¡£",
148 " $%s °Ê¾åʧ¤¦¤Ê¤ó¤Æ¹Í¤¨¤é¤ì¤Ê¤¤¤Í¡£",
149 "¤Þ¤¢Íî¤Á¤Ä¤¤¤Æ¡£ $%s ¤Ç¤É¤¦¤À¤¤¡©",
150 "¤½¤Î¥¬¥é¥¯¥¿¤Ê¤é $%s ¤Ç°ú¤¼è¤ë¤è¡£",
151 "¤½¤ì¤¸¤ã¹â¤¹¤®¤ë¡ª $%s ¤¬¤¤¤¤¤È¤³¤À¤í¡£",
152 "¤É¤¦¤»¤¤¤é¤Ê¤¤¤ó¤À¤í¡ª $%s ¤Ç¤¤¤¤¤À¤í¡©",
153 "¤À¤á¤À¤á¡ª $%s ¤¬¤º¤Ã¤È¤ª»÷¹ç¤¤¤À¤è¡£",
154 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤¬¤»¤¤¤¼¤¤¤À¡£",
155 " $%s ¤Ê¤é´ò¤·¤¤¤È¤³¤í¤À¤¬¤Ê¤¢¡£",
156 " $%s ¡¢¤½¤ì°Ê¾å¤Ï¥Ó¥¿°ìʸ½Ð¤µ¤Ê¤¤¤è¡ª"
158 "Perhaps %s gold pieces?",
159 "How about %s gold pieces?",
160 "I will pay no more than %s gold pieces.",
161 "I can afford no more than %s gold pieces.",
162 "Be reasonable. How about %s gold pieces?",
163 "I'll buy it as scrap for %s gold pieces.",
164 "That is too much! How about %s gold pieces?",
165 "That looks war surplus! Say %s gold pieces?",
166 "Never! %s is more like it.",
167 "That's an insult! %s is more like it.",
168 "%s gold pieces and be thankful for it!",
169 "%s gold pieces and not a copper more!"
175 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇ㤤¼è¤ê¡Ë */
176 static cptr comment_3b_B[MAX_COMMENT_3B] = {
177 " $%s ¤Ã¤Æ¤È¤³¤í¤À¤Í¡£¤½¤Î¤É¤¦¤·¤è¤¦¤â¤Ê¤¤¥¬¥é¥¯¥¿¤Ï¡£",
178 "¤³¤Î²¶¤¬ $%s ¤Ã¤Æ¸À¤Ã¤Æ¤¤¤ë¤ó¤À¤«¤é¡¢¤½¤ÎÄ̤ê¤Ë¤·¤¿Êý¤¬¿È¤Î¤¿¤á¤À¤¾¡£",
179 "²¶¤ÎÍ¥¤·¤µ¤Ë´Å¤¨¤ë¤Î¤â¤¤¤¤²Ã¸º¤Ë¤·¤Æ¤ª¤±¡£ $%s ¤À¡£",
180 "¤½¤ÎÉʤʤé $%s ¤ÇÇä¤Ã¤Æ¤¯¤ì¤Æ¤¤¤ë¤¬¤Í¡¢¾ï¼±¤¢¤ë¿Â»Î¤Ï¤ß¤ó¤Ê¡£",
181 "¤³¤ê¤ã¤Þ¤¿¡¢¤¬¤á¤Ä¤¤ÅÛ¤À¤Ê¡£¤¤¤¯¤é²¶¤¬²¹¸ü¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¡£",
182 " $%s ¤À¡£Ê̤˲¶¤Ï¤½¤ó¤Ê¥¬¥é¥¯¥¿Íߤ·¤¯¤Ï¤Ê¤¤¤ó¤À¤«¤é¡£",
183 "²¶¤Î´ÕÄê³Û¤¬µ¤¤ËÆþ¤é¤Ê¤¤¤Î¤«¡© $%s ¡¢·ù¤Ê¤éµ¢¤ê¤Ê¡£",
184 " $%s ¤Ç°ú¤¼è¤Ã¤Æ¤ä¤ë¤è¡£´î¤ó¤Ç¼õ¤±¼è¤ê¤Ê¡¢ÉÏ˳¿Í¡£",
185 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅۤϻÏËö¤Ë¤ª¤¨¤ó¤Ê¡£¤½¤ì¤Ï $%s ¤Ê¤ó¤À¤è¡£",
186 "¤½¤ó¤Ê¤Ë¶â¤¬Íߤ·¤¤¤Î¤«¡¢¤¢¤ó¤¿¡© $%s ¤ÇËþ¤Ǥ¤ó¤Î¤«¡©",
187 "Æþ¤ëŹ´Ö°ã¤¨¤Æ¤ó¤¸¤ã¤Ê¤¤¤Î¤«¡© $%s ¤Ç·ù¤Ê¤é¾¤ò¤¢¤¿¤Ã¤Æ¤¯¤ì¡£",
188 "²¶¤Î¸À¤¤Ãͤ˥±¥Á¤ò¤Ä¤±¤ëÅÛ¤¬¤¤¤ë¤È¤Ï¡ª ¤½¤ÎÅÙ¶»¤ËÌȤ¸¤Æ $%s ¤À¡£"
191 #define MAX_COMMENT_4A 4
193 static cptr comment_4a[MAX_COMMENT_4A] =
196 "¤â¤¦¤¿¤¯¤µ¤ó¤À¡ª²¿ÅÙ¤â»ä¤ò¤ï¤º¤é¤ï¤»¤Ê¤¤¤Ç¤¯¤ì¡ª",
197 "¤¦¤¬¡¼¡ª°ìÆü¤Î²æËý¤Î¸ÂÅÙ¤òĶ¤¨¤Æ¤¤¤ë¡ª",
198 "¤â¤¦¤¤¤¤¡ª»þ´Ö¤Î̵Â̰ʳ°¤Î¤Ê¤Ë¤â¤Î¤Ç¤â¤Ê¤¤¡ª",
199 "¤â¤¦¤ä¤Ã¤Æ¤é¤ì¤Ê¤¤¤è¡ª´é¤â¸«¤¿¤¯¤Ê¤¤¡ª"
201 "Enough! You have abused me once too often!",
202 "Arghhh! I have had enough abuse for one day!",
203 "That does it! You shall waste my time no more!",
204 "This is getting nowhere! I'm going to Londis!"
210 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¤ÎĺÅÀ¡Ë */
211 static cptr comment_4a_B[MAX_COMMENT_4A] = {
212 "¤Ê¤á¤ä¤¬¤Ã¤Æ¡ª²¹¸ü¤Ê²¶ÍͤǤâ¸Â³¦¤¬¤¢¤ë¤Ã¤Æ¤³¤È¤òÃΤ졪",
213 "²¶¤ò¤³¤³¤Þ¤ÇÅܤ餻¤Æ...Ì¿¤¬¤¢¤ë¤À¤±¤Ç¤â¤¢¤ê¤¬¤¿¤¤¤È»×¤¨¡ª",
214 "¤Õ¤¶¤±¤Æ¤ë¤Î¤«¡ªÎä¤ä¤«¤·¤Ê¤éÁê¼ê¤ò¸«¤Æ¤«¤é¤Ë¤·¤í¡ª",
215 "¤¤¤¤¤«¤²¤ó¤Ë¤·¤í¡ªº£ÅÙ¤³¤ó¤Ê¤Þ¤Í¤·¤¿¤é¤¿¤À¤¸¤ã¤ª¤«¤Í¤¨¤¾¡ª"
218 #define MAX_COMMENT_4B 4
220 static cptr comment_4b[MAX_COMMENT_4B] =
224 "²¶¤ÎÁ°¤«¤é¾Ã¤¨¼º¤»¤í¡ª",
225 "¤É¤Ã¤«¤Ë¹Ô¤Ã¤Á¤Þ¤¨¡ª",
226 "½Ð¤í¡¢½Ð¤í¡¢½Ð¤Æ¹Ô¤±¡ª"
229 "Get out of my sight!",
230 "Begone, you scoundrel!",
237 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÄɤ¤½Ð¤·¡Ë */
238 static cptr comment_4b_B[MAX_COMMENT_4B] = {
239 "ÆóÅ٤Ȥ¦¤Á¤ËÍè¤ë¤ó¤¸¤ã¤Í¤¨¡ª¡ª",
240 "¤È¤Ã¤È¤È¡¢¤É¤Ã¤«¤Ø¼º¤»¤í¡ª¡ª",
241 "º£¤¹¤°¾Ã¤¨¼º¤»¤í¡ª¡ª",
242 "½Ð¤Æ¤¤¤±¡ª½Ð¤Æ¤¤¤±¡ª¡ª"
245 #define MAX_COMMENT_5 8
247 static cptr comment_5[MAX_COMMENT_5] =
252 "¤â¤Ã¤È¿¿ÌÌÌܤ˸À¤Ã¤Æ¤¯¤ì¡ª",
253 "¸ò¾Ä¤¹¤ëµ¤¤¬¤¢¤ë¤Î¤«¤¤¡©",
254 "Îä¤ä¤«¤·¤ËÍ褿¤Î¤«¡ª",
257 "¤Õ¡¼¤à¡¢Îɤ¤Å·µ¤¤À¡£"
261 "You will have to do better than that!",
262 "Do you wish to do business or not?",
263 "You've got to be kidding!",
264 "You'd better be kidding!",
265 "You try my patience.",
266 "Hmmm, nice weather we're having."
272 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¡Ë */
273 static cptr comment_5_B[MAX_COMMENT_5] = {
274 "»þ´Ö¤Î̵Â̤À¤Ê¡¢¤³¤ì¤Ï¡£",
275 "Ìñ²ð¤Ê¤ªµÒÍͤÀ¤Ê¡ª",
276 "Ïä·¤Æʬ¤«¤ëÁê¼ê¤¸¤ã¤Ê¤µ¤½¤¦¤À¡£",
277 "Äˤ¤Ìܤˤ¢¤¤¤¿¤¤¤é¤·¤¤¤Ê¡ª",
278 "¤Ê¤ó¤Æ¶¯ÍߤÊÅÛ¤À¡ª",
280 "¤É¤¦¤·¤è¤¦¤â¤Ê¤¤ÉÏ˳¿Í¤À¡ª",
281 "·ö²Þ¤òÇä¤Ã¤Æ¤¤¤ë¤Î¤«¡©"
284 #define MAX_COMMENT_6 4
286 static cptr comment_6[MAX_COMMENT_6] =
289 "¤É¤¦¤ä¤éʹ¤´Ö°ã¤¨¤¿¤é¤·¤¤¡£",
290 "¼ºÎé¡¢¤è¤¯Ê¹¤³¤¨¤Ê¤«¤Ã¤¿¤è¡£",
291 "¤¹¤Þ¤Ê¤¤¡¢²¿¤À¤Ã¤Æ¡©",
292 "°¤¤¡¢¤â¤¦°ìÅÙ¸À¤Ã¤Æ¤¯¤ì¤ë¡©"
294 "I must have heard you wrong.",
295 "I'm sorry, I missed that.",
296 "I'm sorry, what was that?",
297 "Sorry, what was that again?"
307 static void say_comment_1(void)
312 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
313 if ( cur_store_num == STORE_BLACK ) {
314 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
317 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
320 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
324 if (one_in_(RUMOR_CHANCE))
327 msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
329 msg_print("The shopkeeper whispers something into your ear:");
334 if (!get_rnd_line_jonly("rumors_j.txt", 0, rumour, 10))
336 if (!get_rnd_line("rumors.txt", 0, rumour))
345 * Continue haggling (player is buying)
347 static void say_comment_2(s32b value, int annoyed)
351 /* Prepare a string to insert */
352 sprintf(tmp_val, "%ld", (long)value);
357 /* Formatted message */
358 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
364 /* Formatted message */
366 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
367 if ( cur_store_num == STORE_BLACK ){
368 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
371 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
374 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
382 * Continue haggling (player is selling)
384 static void say_comment_3(s32b value, int annoyed)
388 /* Prepare a string to insert */
389 sprintf(tmp_val, "%ld", (long)value);
394 /* Formatted message */
395 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
401 /* Formatted message */
403 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
404 if ( cur_store_num == STORE_BLACK ){
405 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
408 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
411 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
419 * Kick 'da bum out. -RAK-
421 static void say_comment_4(void)
424 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
425 if ( cur_store_num == STORE_BLACK ){
426 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
427 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
430 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
431 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
434 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
435 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
442 * You are insulting me
444 static void say_comment_5(void)
447 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
448 if ( cur_store_num == STORE_BLACK ){
449 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
452 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
455 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
462 * That makes no sense.
464 static void say_comment_6(void)
466 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
472 * Messages for reacting to purchase prices.
475 #define MAX_COMMENT_7A 4
477 static cptr comment_7a[MAX_COMMENT_7A] =
482 "狼¤¬¤à¤»¤Óµã¤¯À¼¤¬Ê¹¤³¤¨¤ë...¡£",
483 "Ź¼ç¤¬²ù¤·¤²¤Ë¤ï¤á¤¤¤Æ¤¤¤ë¡ª"
487 "You hear someone sobbing...",
488 "The shopkeeper howls in agony!"
493 #define MAX_COMMENT_7B 4
495 static cptr comment_7b[MAX_COMMENT_7B] =
500 "Ź¼ç¤¬º¨¤á¤·¤½¤¦¤Ë¸«¤Æ¤¤¤ë¡£",
505 "The shopkeeper curses at you.",
506 "The shopkeeper glares at you."
511 #define MAX_COMMENT_7C 4
513 static cptr comment_7c[MAX_COMMENT_7C] =
517 "·¯¤¬Å·»È¤Ë¸«¤¨¤ë¤è¡ª",
518 "Ź¼ç¤¬¥¯¥¹¥¯¥¹¾Ð¤Ã¤Æ¤¤¤ë¡£",
519 "Ź¼ç¤¬ÂçÀ¼¤Ç¾Ð¤Ã¤Æ¤¤¤ë¡£"
522 "You've made my day!",
523 "The shopkeeper giggles.",
524 "The shopkeeper laughs loudly."
529 #define MAX_COMMENT_7D 4
531 static cptr comment_7d[MAX_COMMENT_7D] =
535 "¤³¤ó¤Ê¤ª¤¤¤·¤¤»×¤¤¤ò¤·¤¿¤é¡¢¿¿ÌÌÌܤËƯ¤±¤Ê¤¯¤Ê¤ë¤Ê¤¡¡£",
536 "Ź¼ç¤Ï´ò¤·¤¯¤ÆÄ·¤Í²ó¤Ã¤Æ¤¤¤ë¡£",
537 "Ź¼ç¤ÏËþÌ̤˾Фߤò¤¿¤¿¤¨¤Æ¤¤¤ë¡£"
540 "I think I'll retire!",
541 "The shopkeeper jumps for joy.",
542 "The shopkeeper smiles gleefully."
549 * Let a shop-keeper React to a purchase
551 * We paid "price", it was worth "value", and we thought it was worth "guess"
553 static void purchase_analyze(s32b price, s32b value, s32b guess)
555 /* Item was worthless, but we bought it */
556 if ((value <= 0) && (price > value))
559 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
561 chg_virtue(V_HONOUR, -1);
562 chg_virtue(V_JUSTICE, -1);
568 /* Item was cheaper than we thought, and we paid more than necessary */
569 else if ((value < guess) && (price > value))
572 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
574 chg_virtue(V_JUSTICE, -1);
576 chg_virtue(V_HONOUR, -1);
582 /* Item was a good bargain, and we got away with it */
583 else if ((value > guess) && (value < (4 * guess)) && (price < value))
586 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
589 chg_virtue(V_HONOUR, -1);
591 chg_virtue(V_HONOUR, 1);
597 /* Item was a great bargain, and we got away with it */
598 else if ((value > guess) && (price < value))
601 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
604 chg_virtue(V_HONOUR, -1);
606 chg_virtue(V_HONOUR, 1);
608 if (10 * price < value)
609 chg_virtue(V_SACRIFICE, 1);
619 * We store the current "store feat" here so everyone can access it
621 static int cur_store_feat;
625 * Buying and selling adjustments for race combinations.
626 * Entry[owner][player] gives the basic "cost inflation".
628 static byte rgold_adj[MAX_RACES][MAX_RACES] =
630 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
631 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
632 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
633 Angel, Demon, Kutar */
636 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
637 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
638 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
639 100, 120, 110, 105 },
642 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
643 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
644 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
645 110, 115, 110, 110 },
648 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
649 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
650 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
651 110, 110, 105, 110 },
654 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
655 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
656 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
657 115, 120, 105, 115 },
660 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
661 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
662 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
663 115, 110, 110, 115 },
666 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
667 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
668 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
669 115, 110, 115, 115 },
672 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
673 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
674 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
675 115, 110, 115, 115 },
678 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
679 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
680 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
681 110, 110, 115, 110 },
684 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
685 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
686 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
687 100, 110, 110, 100 },
690 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
691 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
692 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
693 110, 110, 105, 110 },
695 /* Human / Barbarian (copied from human) */
696 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
697 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
698 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
699 100, 120, 110, 100 },
701 /* Half-Ogre: theoretical, copied from half-troll */
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 },
707 /* Half-Giant: theoretical, copied from half-troll */
708 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
709 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
710 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
711 110, 110, 115, 110 },
713 /* Half-Titan: theoretical, copied from High_Elf */
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, 120, 120, 130, 130, 130, 95, 140,
717 110, 110, 115, 110 },
719 /* Cyclops: theoretical, copied from half-troll */
720 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
721 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
722 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
723 110, 110, 115, 110 },
725 /* Yeek: theoretical, copied from Half-Orc */
726 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
727 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
728 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
729 115, 110, 115, 115 },
731 /* Klackon: theoretical, copied from Gnome */
732 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
733 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
734 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
735 115, 110, 115, 115 },
737 /* Kobold: theoretical, copied from Half-Orc */
738 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
739 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
740 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
741 115, 110, 115, 115 },
743 /* Nibelung: theoretical, copied from Dwarf */
744 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
745 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
746 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
747 115, 135, 115, 115 },
750 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
751 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
752 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
753 110, 101, 115, 110 },
755 /* Draconian: theoretical, copied from High_Elf */
756 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
757 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
758 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
759 110, 110, 115, 110 },
761 /* Mind Flayer: theoretical, copied from High_Elf */
762 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
763 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
764 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
765 110, 110, 115, 110 },
767 /* Imp: theoretical, copied from High_Elf */
768 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
769 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
770 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
771 110, 110, 115, 110 },
773 /* Golem: theoretical, copied from High_Elf */
774 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
775 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
776 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
777 110, 110, 115, 110 },
779 /* Skeleton: theoretical, copied from half-orc */
780 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
781 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
782 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
783 115, 110, 125, 115 },
785 /* Zombie: Theoretical, copied from half-orc */
786 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
787 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
788 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
789 115, 110, 125, 115 },
791 /* Vampire: Theoretical, copied from half-orc */
792 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
793 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
794 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
795 115, 110, 125, 115 },
797 /* Spectre: Theoretical, copied from half-orc */
798 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
799 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
800 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
801 115, 110, 125, 115 },
803 /* Sprite: 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, 95, 140,
807 115, 110, 105, 115 },
809 /* Beastman: 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, 95, 140,
813 115, 110, 115, 115 },
816 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
817 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
818 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
819 110, 110, 105, 110 },
822 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
823 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
824 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
828 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
829 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
830 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
831 140, 140, 140, 140 },
834 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
835 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
836 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
837 100, 120, 110, 100 },
840 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
841 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
842 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
843 110, 101, 115, 110 },
846 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
847 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
848 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
849 110, 115, 100, 110 },
852 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
853 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
854 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
855 100, 120, 110, 100 },
862 * Determine the price of an item (qty one) in a store.
864 * This function takes into account the player's charisma, and the
865 * shop-keepers friendliness, and the shop-keeper's base greed, but
866 * never lets a shop-keeper lose money in a transaction.
868 * The "greed" value should exceed 100 when the player is "buying" the
869 * item, and should be less than 100 when the player is "selling" it.
871 * Hack -- the black market always charges twice as much as it should.
873 * Charisma adjustment runs from 80 to 130
874 * Racial adjustment runs from 95 to 130
876 * Since greed/charisma/racial adjustments are centered at 100, we need
877 * to adjust (by 200) to extract a usable multiplier. Note that the
878 * "greed" value is always something (?).
880 static s32b price_item(object_type *o_ptr, int greed, bool flip)
887 /* Get the value of one of the items */
888 price = object_value(o_ptr);
890 /* Worthless items */
891 if (price <= 0) return (0L);
894 /* Compute the racial factor */
895 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
897 /* Add in the charisma factor */
898 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
904 /* Adjust for greed */
905 adjust = 100 + (300 - (greed + factor));
907 /* Never get "silly" */
908 if (adjust > 100) adjust = 100;
910 /* Mega-Hack -- Black market sucks */
911 if (cur_store_num == STORE_BLACK)
914 /* Compute the final price (with rounding) */
915 /* Hack -- prevent underflow */
916 price = (price * adjust + 50L) / 100L;
919 /* Shop is selling */
922 /* Adjust for greed */
923 adjust = 100 + ((greed + factor) - 300);
925 /* Never get "silly" */
926 if (adjust < 100) adjust = 100;
928 /* Mega-Hack -- Black market sucks */
929 if (cur_store_num == STORE_BLACK)
932 /* Compute the final price (with rounding) */
933 /* Hack -- prevent overflow */
934 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
937 /* Note -- Never become "free" */
938 if (price <= 0L) return (1L);
940 /* Return the price */
946 * Certain "cheap" objects should be created in "piles"
947 * Some objects can be sold at a "discount" (in small piles)
949 static void mass_produce(object_type *o_ptr)
954 s32b cost = object_value(o_ptr);
957 /* Analyze the type */
960 /* Food, Flasks, and Lites */
965 if (cost <= 5L) size += damroll(3, 5);
966 if (cost <= 20L) size += damroll(3, 5);
967 if (cost <= 50L) size += damroll(2, 2);
974 if (cost <= 60L) size += damroll(3, 5);
975 if (cost <= 240L) size += damroll(1, 5);
976 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
977 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
982 case TV_SORCERY_BOOK:
990 case TV_CRUSADE_BOOK:
992 case TV_HISSATSU_BOOK:
995 if (cost <= 50L) size += damroll(2, 3);
996 if (cost <= 500L) size += damroll(1, 3);
1014 if (object_is_artifact(o_ptr)) break;
1015 if (object_is_ego(o_ptr)) break;
1016 if (cost <= 10L) size += damroll(3, 5);
1017 if (cost <= 100L) size += damroll(3, 5);
1026 if (cost <= 5L) size += damroll(5, 5);
1027 if (cost <= 50L) size += damroll(5, 5);
1028 if (cost <= 500L) size += damroll(5, 5);
1034 if (cost <= 100L) size += damroll(2, 2);
1035 if (cost <= 1000L) size += damroll(2, 2);
1048 * Because many rods (and a few wands and staffs) are useful mainly
1049 * in quantity, the Black Market will occasionally have a bunch of
1056 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1058 if (cost < 1601L) size += damroll(1, 5);
1059 else if (cost < 3201L) size += damroll(1, 3);
1062 /* Ensure that mass-produced rods and wands get the correct pvals. */
1063 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1065 o_ptr->pval *= size;
1072 /* Pick a discount */
1077 else if (one_in_(25))
1081 else if (one_in_(150))
1085 else if (one_in_(300))
1089 else if (one_in_(500))
1095 if (o_ptr->art_name)
1097 if (cheat_peek && discount)
1100 msg_print("¥é¥ó¥À¥à¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÏÃÍ°ú¤¤Ê¤·¡£");
1102 msg_print("No discount on random artifacts.");
1109 /* Save the discount */
1110 o_ptr->discount = discount;
1112 /* Save the total pile size */
1113 o_ptr->number = size - (size * discount / 100);
1119 * Determine if a store item can "absorb" another item
1121 * See "object_similar()" for the same function for the "player"
1123 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1127 /* Hack -- Identical items cannot be stacked */
1128 if (o_ptr == j_ptr) return (0);
1130 /* Different objects cannot be stacked */
1131 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1133 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1134 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1136 /* Require many identical values */
1137 if (o_ptr->to_h != j_ptr->to_h) return (0);
1138 if (o_ptr->to_d != j_ptr->to_d) return (0);
1139 if (o_ptr->to_a != j_ptr->to_a) return (0);
1141 /* Require identical "ego-item" names */
1142 if (o_ptr->name2 != j_ptr->name2) return (0);
1144 /* Artifacts don't stack! */
1145 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
1147 /* Hack -- Identical art_flags! */
1148 for (i = 0; i < TR_FLAG_SIZE; i++)
1149 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1151 /* Hack -- Never stack "powerful" items */
1152 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1154 /* Hack -- Never stack recharging items */
1155 if (o_ptr->timeout || j_ptr->timeout) return (0);
1157 /* Require many identical values */
1158 if (o_ptr->ac != j_ptr->ac) return (0);
1159 if (o_ptr->dd != j_ptr->dd) return (0);
1160 if (o_ptr->ds != j_ptr->ds) return (0);
1162 /* Hack -- Never stack chests */
1163 if (o_ptr->tval == TV_CHEST) return (0);
1164 if (o_ptr->tval == TV_STATUE) return (0);
1165 if (o_ptr->tval == TV_CAPTURE) return (0);
1167 /* Require matching discounts */
1168 if (o_ptr->discount != j_ptr->discount) return (0);
1170 /* They match, so they must be similar */
1176 * Allow a store item to absorb another item
1178 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1180 int max_num = (o_ptr->tval == TV_ROD) ?
1181 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1182 int total = o_ptr->number + j_ptr->number;
1183 int diff = (total > max_num) ? total - max_num : 0;
1185 /* Combine quantity, lose excess items */
1186 o_ptr->number = (total > max_num) ? max_num : total;
1188 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1189 if (o_ptr->tval == TV_ROD)
1191 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1194 /* Hack -- if wands are stacking, combine the charges. -LM- */
1195 if (o_ptr->tval == TV_WAND)
1197 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1203 * Check to see if the shop will be carrying too many objects -RAK-
1204 * Note that the shop, just like a player, will not accept things
1205 * it cannot hold. Before, one could "nuke" potions this way.
1207 * Return value is now int:
1209 * -1 : Can be combined to existing slot.
1210 * 1 : Cannot be combined but there are empty spaces.
1212 static int store_check_num(object_type *o_ptr)
1217 /* The "home" acts like the player */
1218 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1220 bool old_stack_force_notes = stack_force_notes;
1221 bool old_stack_force_costs = stack_force_costs;
1223 if (cur_store_num != STORE_HOME)
1225 stack_force_notes = FALSE;
1226 stack_force_costs = FALSE;
1229 /* Check all the items */
1230 for (i = 0; i < st_ptr->stock_num; i++)
1232 /* Get the existing item */
1233 j_ptr = &st_ptr->stock[i];
1235 /* Can the new object be combined with the old one? */
1236 if (object_similar(j_ptr, o_ptr))
1238 if (cur_store_num != STORE_HOME)
1240 stack_force_notes = old_stack_force_notes;
1241 stack_force_costs = old_stack_force_costs;
1248 if (cur_store_num != STORE_HOME)
1250 stack_force_notes = old_stack_force_notes;
1251 stack_force_costs = old_stack_force_costs;
1255 /* Normal stores do special stuff */
1258 /* Check all the items */
1259 for (i = 0; i < st_ptr->stock_num; i++)
1261 /* Get the existing item */
1262 j_ptr = &st_ptr->stock[i];
1264 /* Can the new object be combined with the old one? */
1265 if (store_object_similar(j_ptr, o_ptr)) return -1;
1269 /* Free space is always usable */
1271 * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1272 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1274 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1275 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1280 if (st_ptr->stock_num < st_ptr->stock_size) {
1285 /* But there was no room at the inn... */
1290 static bool is_blessed(object_type *o_ptr)
1292 u32b flgs[TR_FLAG_SIZE];
1293 object_flags(o_ptr, flgs);
1294 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1295 else return (FALSE);
1301 * Determine if the current store will purchase the given item
1303 * Note that a shop-keeper must refuse to buy "worthless" items
1305 static bool store_will_buy(object_type *o_ptr)
1307 /* Hack -- The Home is simple */
1308 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1310 /* Switch on the store */
1311 switch (cur_store_num)
1316 /* Analyze the type */
1317 switch (o_ptr->tval)
1320 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1332 case TV_BOTTLE: /* 'Green', recycling Angband */
1347 /* Analyze the type */
1348 switch (o_ptr->tval)
1369 /* Analyze the type */
1370 switch (o_ptr->tval)
1379 case TV_HISSATSU_BOOK:
1383 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1395 /* Analyze the type */
1396 switch (o_ptr->tval)
1399 case TV_CRUSADE_BOOK:
1409 monster_race *r_ptr = &r_info[o_ptr->pval];
1412 if (!(r_ptr->flags3 & RF3_EVIL))
1415 if (r_ptr->flags3 & RF3_GOOD) break;
1417 /* Accept animals */
1418 if (r_ptr->flags3 & RF3_ANIMAL) break;
1421 if (my_strchr("?!", r_ptr->d_char)) break;
1427 if (is_blessed(o_ptr)) break;
1436 case STORE_ALCHEMIST:
1438 /* Analyze the type */
1439 switch (o_ptr->tval)
1453 /* Analyze the type */
1454 switch (o_ptr->tval)
1456 case TV_SORCERY_BOOK:
1457 case TV_NATURE_BOOK:
1461 case TV_ARCANE_BOOK:
1463 case TV_DAEMON_BOOK:
1477 if(o_ptr->sval == SV_WIZSTAFF) break;
1478 else return (FALSE);
1485 /* Bookstore Shop */
1488 /* Analyze the type */
1489 switch (o_ptr->tval)
1491 case TV_SORCERY_BOOK:
1492 case TV_NATURE_BOOK:
1497 case TV_ARCANE_BOOK:
1499 case TV_DAEMON_BOOK:
1500 case TV_CRUSADE_BOOK:
1511 /* XXX XXX XXX Ignore "worthless" items */
1512 if (object_value(o_ptr) <= 0) return (FALSE);
1520 * Combine and reorder items in the home
1522 bool combine_and_reorder_home(int store_num)
1526 object_type forge, *o_ptr, *j_ptr;
1527 bool flag = FALSE, combined;
1528 store_type *old_st_ptr = st_ptr;
1529 bool old_stack_force_notes = stack_force_notes;
1530 bool old_stack_force_costs = stack_force_costs;
1532 st_ptr = &town[1].store[store_num];
1533 if (store_num != STORE_HOME)
1535 stack_force_notes = FALSE;
1536 stack_force_costs = FALSE;
1543 /* Combine the items in the home (backwards) */
1544 for (i = st_ptr->stock_num - 1; i > 0; i--)
1547 o_ptr = &st_ptr->stock[i];
1549 /* Skip empty items */
1550 if (!o_ptr->k_idx) continue;
1552 /* Scan the items above that item */
1553 for (j = 0; j < i; j++)
1558 j_ptr = &st_ptr->stock[j];
1560 /* Skip empty items */
1561 if (!j_ptr->k_idx) continue;
1564 * Get maximum number of the stack if these
1565 * are similar, get zero otherwise.
1567 max_num = object_similar_part(j_ptr, o_ptr);
1569 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
1570 if (max_num && j_ptr->number < max_num)
1572 if (o_ptr->number + j_ptr->number <= max_num)
1574 /* Add together the item counts */
1575 object_absorb(j_ptr, o_ptr);
1577 /* One object is gone */
1578 st_ptr->stock_num--;
1580 /* Slide everything down */
1581 for (k = i; k < st_ptr->stock_num; k++)
1583 /* Structure copy */
1584 st_ptr->stock[k] = st_ptr->stock[k + 1];
1587 /* Erase the "final" slot */
1588 object_wipe(&st_ptr->stock[k]);
1592 int old_num = o_ptr->number;
1593 int remain = j_ptr->number + o_ptr->number - max_num;
1595 /* Add together the item counts */
1596 object_absorb(j_ptr, o_ptr);
1598 o_ptr->number = remain;
1600 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1601 if (o_ptr->tval == TV_ROD)
1603 o_ptr->pval = o_ptr->pval * remain / old_num;
1604 o_ptr->timeout = o_ptr->timeout * remain / old_num;
1607 /* Hack -- if wands are stacking, combine the charges. -LM- */
1608 else if (o_ptr->tval == TV_WAND)
1610 o_ptr->pval = o_ptr->pval * remain / old_num;
1627 /* Re-order the items in the home (forwards) */
1628 for (i = 0; i < st_ptr->stock_num; i++)
1631 o_ptr = &st_ptr->stock[i];
1633 /* Skip empty slots */
1634 if (!o_ptr->k_idx) continue;
1636 /* Get the "value" of the item */
1637 o_value = object_value(o_ptr);
1639 /* Scan every occupied slot */
1640 for (j = 0; j < st_ptr->stock_num; j++)
1642 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
1645 /* Never move down */
1646 if (j >= i) continue;
1651 /* Get local object */
1654 /* Save a copy of the moving item */
1655 object_copy(j_ptr, &st_ptr->stock[i]);
1657 /* Slide the objects */
1658 for (k = i; k > j; k--)
1660 /* Slide the item */
1661 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
1664 /* Insert the moving item */
1665 object_copy(&st_ptr->stock[j], j_ptr);
1668 st_ptr = old_st_ptr;
1669 if (store_num != STORE_HOME)
1671 stack_force_notes = old_stack_force_notes;
1672 stack_force_costs = old_stack_force_costs;
1680 * Add the item "o_ptr" to the inventory of the "Home"
1682 * In all cases, return the slot (or -1) where the object was placed
1684 * Note that this is a hacked up version of "inven_carry()".
1686 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1687 * known, the player may have to pick stuff up and drop it again.
1689 static int home_carry(object_type *o_ptr)
1695 bool old_stack_force_notes = stack_force_notes;
1696 bool old_stack_force_costs = stack_force_costs;
1698 if (cur_store_num != STORE_HOME)
1700 stack_force_notes = FALSE;
1701 stack_force_costs = FALSE;
1704 /* Check each existing item (try to combine) */
1705 for (slot = 0; slot < st_ptr->stock_num; slot++)
1707 /* Get the existing item */
1708 j_ptr = &st_ptr->stock[slot];
1710 /* The home acts just like the player */
1711 if (object_similar(j_ptr, o_ptr))
1713 /* Save the new number of items */
1714 object_absorb(j_ptr, o_ptr);
1716 if (cur_store_num != STORE_HOME)
1718 stack_force_notes = old_stack_force_notes;
1719 stack_force_costs = old_stack_force_costs;
1727 if (cur_store_num != STORE_HOME)
1729 stack_force_notes = old_stack_force_notes;
1730 stack_force_costs = old_stack_force_costs;
1735 * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1736 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1739 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
1740 if (st_ptr->stock_num >= st_ptr->stock_size) {
1745 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1751 /* Determine the "value" of the item */
1752 value = object_value(o_ptr);
1754 /* Check existing slots to see if we must "slide" */
1755 for (slot = 0; slot < st_ptr->stock_num; slot++)
1757 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
1760 /* Slide the others up */
1761 for (i = st_ptr->stock_num; i > slot; i--)
1763 st_ptr->stock[i] = st_ptr->stock[i-1];
1766 /* More stuff now */
1767 st_ptr->stock_num++;
1769 /* Insert the new item */
1770 st_ptr->stock[slot] = *o_ptr;
1772 chg_virtue(V_SACRIFICE, -1);
1774 (void)combine_and_reorder_home(cur_store_num);
1776 /* Return the location */
1782 * Add the item "o_ptr" to a real stores inventory.
1784 * If the item is "worthless", it is thrown away (except in the home).
1786 * If the item cannot be combined with an object already in the inventory,
1787 * make a new slot for it, and calculate its "per item" price. Note that
1788 * this price will be negative, since the price will not be "fixed" yet.
1789 * Adding an item to a "fixed" price stack will not change the fixed price.
1791 * In all cases, return the slot (or -1) where the object was placed
1793 static int store_carry(object_type *o_ptr)
1796 s32b value, j_value;
1800 /* Evaluate the object */
1801 value = object_value(o_ptr);
1803 /* Cursed/Worthless items "disappear" when sold */
1804 if (value <= 0) return (-1);
1806 /* All store items are fully *identified* */
1807 o_ptr->ident |= IDENT_MENTAL;
1809 /* Erase the inscription */
1810 o_ptr->inscription = 0;
1812 /* Erase the "feeling" */
1813 o_ptr->feeling = FEEL_NONE;
1815 /* Check each existing item (try to combine) */
1816 for (slot = 0; slot < st_ptr->stock_num; slot++)
1818 /* Get the existing item */
1819 j_ptr = &st_ptr->stock[slot];
1821 /* Can the existing items be incremented? */
1822 if (store_object_similar(j_ptr, o_ptr))
1824 /* Hack -- extra items disappear */
1825 store_object_absorb(j_ptr, o_ptr);
1833 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1836 /* Check existing slots to see if we must "slide" */
1837 for (slot = 0; slot < st_ptr->stock_num; slot++)
1840 j_ptr = &st_ptr->stock[slot];
1842 /* Objects sort by decreasing type */
1843 if (o_ptr->tval > j_ptr->tval) break;
1844 if (o_ptr->tval < j_ptr->tval) continue;
1846 /* Objects sort by increasing sval */
1847 if (o_ptr->sval < j_ptr->sval) break;
1848 if (o_ptr->sval > j_ptr->sval) continue;
1851 * Hack: otherwise identical rods sort by
1852 * increasing recharge time --dsb
1854 if (o_ptr->tval == TV_ROD)
1856 if (o_ptr->pval < j_ptr->pval) break;
1857 if (o_ptr->pval > j_ptr->pval) continue;
1860 /* Evaluate that slot */
1861 j_value = object_value(j_ptr);
1863 /* Objects sort by decreasing value */
1864 if (value > j_value) break;
1865 if (value < j_value) continue;
1868 /* Slide the others up */
1869 for (i = st_ptr->stock_num; i > slot; i--)
1871 st_ptr->stock[i] = st_ptr->stock[i-1];
1874 /* More stuff now */
1875 st_ptr->stock_num++;
1877 /* Insert the new item */
1878 st_ptr->stock[slot] = *o_ptr;
1880 /* Return the location */
1886 * Increase, by a given amount, the number of a certain item
1887 * in a certain store. This can result in zero items.
1889 static void store_item_increase(int item, int num)
1895 o_ptr = &st_ptr->stock[item];
1897 /* Verify the number */
1898 cnt = o_ptr->number + num;
1899 if (cnt > 255) cnt = 255;
1900 else if (cnt < 0) cnt = 0;
1901 num = cnt - o_ptr->number;
1903 /* Save the new number */
1904 o_ptr->number += num;
1909 * Remove a slot if it is empty
1911 static void store_item_optimize(int item)
1917 o_ptr = &st_ptr->stock[item];
1920 if (!o_ptr->k_idx) return;
1922 /* Must have no items */
1923 if (o_ptr->number) return;
1926 st_ptr->stock_num--;
1928 /* Slide everyone */
1929 for (j = item; j < st_ptr->stock_num; j++)
1931 st_ptr->stock[j] = st_ptr->stock[j + 1];
1934 /* Nuke the final slot */
1935 object_wipe(&st_ptr->stock[j]);
1940 * This function will keep 'crap' out of the black market.
1941 * Crap is defined as any item that is "available" elsewhere
1942 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1944 static bool black_market_crap(object_type *o_ptr)
1948 /* Ego items are never crap */
1949 if (object_is_ego(o_ptr)) return (FALSE);
1951 /* Good items are never crap */
1952 if (o_ptr->to_a > 0) return (FALSE);
1953 if (o_ptr->to_h > 0) return (FALSE);
1954 if (o_ptr->to_d > 0) return (FALSE);
1956 /* Check all stores */
1957 for (i = 0; i < MAX_STORES; i++)
1959 if (i == STORE_HOME) continue;
1960 if (i == STORE_MUSEUM) continue;
1962 /* Check every item in the store */
1963 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1965 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1967 /* Duplicate item "type", assume crappy */
1968 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
1978 * Attempt to delete (some of) a random item from the store
1979 * Hack -- we attempt to "maintain" piles of items when possible.
1981 static void store_delete(void)
1985 /* Pick a random slot */
1986 what = randint0(st_ptr->stock_num);
1988 /* Determine how many items are here */
1989 num = st_ptr->stock[what].number;
1991 /* Hack -- sometimes, only destroy half the items */
1992 if (randint0(100) < 50) num = (num + 1) / 2;
1994 /* Hack -- sometimes, only destroy a single item */
1995 if (randint0(100) < 50) num = 1;
1997 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
1998 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
2000 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
2003 /* Actually destroy (part of) the item */
2004 store_item_increase(what, -num);
2005 store_item_optimize(what);
2010 * Creates a random item and gives it to a store
2011 * This algorithm needs to be rethought. A lot.
2012 * Currently, "normal" stores use a pre-built array.
2014 * Note -- the "level" given to "obj_get_num()" is a "favored"
2015 * level, that is, there is a much higher chance of getting
2016 * items with a level approaching that of the given level...
2018 * Should we check for "permission" to have the given item?
2020 static void store_create(void)
2022 int i, tries, level;
2028 /* Paranoia -- no room left */
2029 if (st_ptr->stock_num >= st_ptr->stock_size) return;
2032 /* Hack -- consider up to four items */
2033 for (tries = 0; tries < 4; tries++)
2036 if (cur_store_num == STORE_BLACK)
2038 /* Pick a level for object/magic */
2039 level = 25 + randint0(25);
2041 /* Random item (usually of given level) */
2042 i = get_obj_num(level);
2044 /* Handle failure */
2051 /* Hack -- Pick an item to sell */
2052 i = st_ptr->table[randint0(st_ptr->table_num)];
2054 /* Hack -- fake level for apply_magic() */
2055 level = rand_range(1, STORE_OBJ_LEVEL);
2059 /* Get local object */
2062 /* Create a new object of the chosen kind */
2063 object_prep(q_ptr, i);
2065 /* Apply some "low-level" magic (no artifacts) */
2066 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
2068 /* Require valid object */
2069 if (!store_will_buy(q_ptr)) continue;
2071 /* Hack -- Charge lite's */
2072 if (q_ptr->tval == TV_LITE)
2074 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
2075 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
2079 /* The item is "known" */
2080 object_known(q_ptr);
2082 /* Mark it storebought */
2083 q_ptr->ident |= IDENT_STORE;
2085 /* Mega-Hack -- no chests in stores */
2086 if (q_ptr->tval == TV_CHEST) continue;
2088 /* Prune the black market */
2089 if (cur_store_num == STORE_BLACK)
2091 /* Hack -- No "crappy" items */
2092 if (black_market_crap(q_ptr)) continue;
2094 /* Hack -- No "cheap" items */
2095 if (object_value(q_ptr) < 10) continue;
2097 /* No "worthless" items */
2098 /* if (object_value(q_ptr) <= 0) continue; */
2101 /* Prune normal stores */
2104 /* No "worthless" items */
2105 if (object_value(q_ptr) <= 0) continue;
2109 /* Mass produce and/or Apply discount */
2110 mass_produce(q_ptr);
2112 /* Attempt to carry the (known) item */
2113 (void)store_carry(q_ptr);
2115 /* Definitely done */
2123 * Eliminate need to bargain if player has haggled well in the past
2125 static bool noneedtobargain(s32b minprice)
2127 s32b good = st_ptr->good_buy;
2128 s32b bad = st_ptr->bad_buy;
2130 /* Cheap items are "boring" */
2131 if (minprice < 10L) return (TRUE);
2133 /* Perfect haggling */
2134 if (good == MAX_SHORT) return (TRUE);
2136 /* Reward good haggles, punish bad haggles, notice price */
2137 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
2139 /* Return the flag */
2145 * Update the bargain info
2147 static void updatebargain(s32b price, s32b minprice, int num)
2149 /* Hack -- auto-haggle */
2150 if (!manual_haggle) return;
2152 /* Cheap items are "boring" */
2153 if ((minprice/num) < 10L) return;
2155 /* Count the successful haggles */
2156 if (price == minprice)
2158 /* Just count the good haggles */
2159 if (st_ptr->good_buy < MAX_SHORT)
2165 /* Count the failed haggles */
2168 /* Just count the bad haggles */
2169 if (st_ptr->bad_buy < MAX_SHORT)
2179 * Re-displays a single store entry
2181 static void display_entry(int pos)
2187 char o_name[MAX_NLEN];
2194 o_ptr = &st_ptr->stock[pos];
2196 /* Get the "offset" */
2197 i = (pos % store_bottom);
2199 /* Label it, clear the line --(-- */
2200 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
2201 prt(out_val, i+6, 0);
2204 if (show_item_graph)
2206 byte a = object_attr(o_ptr);
2207 char c = object_char(o_ptr);
2214 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
2215 if (use_bigtile) cur_col++;
2220 /* Describe an item in the home */
2221 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2225 /* Leave room for weights, if necessary -DRS- */
2226 if (show_weights) maxwid -= 10;
2228 /* Describe the object */
2229 object_desc(o_name, o_ptr, 0);
2230 o_name[maxwid] = '\0';
2231 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2236 /* Only show the weight of an individual item */
2237 int wgt = o_ptr->weight;
2239 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2240 put_str(out_val, i+6, 67);
2242 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2243 put_str(out_val, i+6, 68);
2249 /* Describe an item (fully) in a store */
2252 /* Must leave room for the "price" */
2255 /* Leave room for weights, if necessary -DRS- */
2256 if (show_weights) maxwid -= 7;
2258 /* Describe the object (fully) */
2259 object_desc(o_name, o_ptr, 0);
2260 o_name[maxwid] = '\0';
2261 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2266 /* Only show the weight of an individual item */
2267 int wgt = o_ptr->weight;
2269 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2270 put_str(out_val, i+6, 60);
2272 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2273 put_str(out_val, i+6, 61);
2278 /* Display a "fixed" cost */
2279 if (o_ptr->ident & (IDENT_FIXED))
2281 /* Extract the "minimum" price */
2282 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2284 /* Actually draw the price (not fixed) */
2286 (void)sprintf(out_val, "%9ld¸Ç", (long)x);
2288 (void)sprintf(out_val, "%9ld F", (long)x);
2291 put_str(out_val, i+6, 68);
2294 /* Display a "taxed" cost */
2295 else if (!manual_haggle)
2297 /* Extract the "minimum" price */
2298 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2300 /* Hack -- Apply Sales Tax if needed */
2301 if (!noneedtobargain(x)) x += x / 10;
2303 /* Actually draw the price (with tax) */
2304 (void)sprintf(out_val, "%9ld ", (long)x);
2305 put_str(out_val, i+6, 68);
2308 /* Display a "haggle" cost */
2311 /* Extrect the "maximum" price */
2312 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2314 /* Actually draw the price (not fixed) */
2315 (void)sprintf(out_val, "%9ld ", (long)x);
2316 put_str(out_val, i+6, 68);
2323 * Displays a store's inventory -RAK-
2324 * All prices are listed as "per individual object". -BEN-
2326 static void display_inventory(void)
2330 /* Display the next 12 items */
2331 for (k = 0; k < store_bottom; k++)
2333 /* Do not display "dead" items */
2334 if (store_top + k >= st_ptr->stock_num) break;
2336 /* Display that line */
2337 display_entry(store_top + k);
2340 /* Erase the extra lines and the "more" prompt */
2341 for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
2343 /* Assume "no current page" */
2345 put_str(" ", 5, 20);
2347 put_str(" ", 5, 20);
2351 /* Visual reminder of "more items" */
2352 if (st_ptr->stock_num > store_bottom)
2354 /* Show "more" reminder (after the last item) */
2356 prt("-³¤¯-", k + 6, 3);
2358 prt("-more-", k + 6, 3);
2362 /* Indicate the "current page" */
2363 /* Trailing spaces are to display (Page xx) and (Page x) */
2365 put_str(format("(%d¥Ú¡¼¥¸) ", store_top/store_bottom + 1), 5, 20);
2367 put_str(format("(Page %d) ", store_top/store_bottom + 1), 5, 20);
2375 * Displays players gold -RAK-
2377 static void store_prt_gold(void)
2382 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19 + xtra_stock, 53);
2384 prt("Gold Remaining: ", 19 + xtra_stock, 53);
2388 sprintf(out_val, "%9ld", (long)p_ptr->au);
2389 prt(out_val, 19 + xtra_stock, 68);
2394 * Displays store (after clearing screen) -RAK-
2396 static void display_store(void)
2404 /* The "Home" is special */
2405 if (cur_store_num == STORE_HOME)
2407 /* Put the owner name */
2409 put_str("²æ¤¬²È", 3, 31);
2411 put_str("Your Home", 3, 30);
2415 /* Label the item descriptions */
2417 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2419 put_str("Item Description", 5, 3);
2423 /* If showing weights, show label */
2427 put_str("½Å¤µ", 5, 72);
2429 put_str("Weight", 5, 70);
2435 /* The "Home" is special */
2436 else if (cur_store_num == STORE_MUSEUM)
2438 /* Put the owner name */
2440 put_str("Çîʪ´Û", 3, 31);
2442 put_str("Museum", 3, 30);
2446 /* Label the item descriptions */
2448 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2450 put_str("Item Description", 5, 3);
2454 /* If showing weights, show label */
2458 put_str("½Å¤µ", 5, 72);
2460 put_str("Weight", 5, 70);
2469 cptr store_name = (f_name + f_info[cur_store_feat].name);
2470 cptr owner_name = (ot_ptr->owner_name);
2471 cptr race_name = race_info[ot_ptr->owner_race].title;
2473 /* Put the owner name and race */
2474 sprintf(buf, "%s (%s)", owner_name, race_name);
2475 put_str(buf, 3, 10);
2477 /* Show the max price in the store (above prices) */
2478 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2481 /* Label the item descriptions */
2483 put_str("¾¦ÉʤΰìÍ÷", 5, 7);
2485 put_str("Item Description", 5, 3);
2489 /* If showing weights, show label */
2493 put_str("½Å¤µ", 5, 62);
2495 put_str("Weight", 5, 60);
2500 /* Label the asking price (in stores) */
2502 put_str("²Á³Ê", 5, 73);
2504 put_str("Price", 5, 72);
2509 /* Display the current gold */
2512 /* Draw in the inventory */
2513 display_inventory();
2519 * Get the ID of a store item and return its value -RAK-
2521 static int get_stock(int *com_val, cptr pmt, int i, int j)
2527 #ifdef ALLOW_REPEAT /* TNB */
2529 /* Get the item index */
2530 if (repeat_pull(com_val))
2532 /* Verify the item */
2533 if ((*com_val >= i) && (*com_val <= j))
2540 #endif /* ALLOW_REPEAT -- TNB */
2542 /* Paranoia XXX XXX XXX */
2546 /* Assume failure */
2549 /* Build the prompt */
2551 hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
2553 (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
2554 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
2557 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2562 /* Ask until done */
2568 if (!get_com(out_val, &command, FALSE)) break;
2571 if (islower(command))
2573 else if (isupper(command))
2574 k = A2I(tolower(command)) + 26;
2578 /* Legal responses */
2579 if ((k >= i) && (k <= j))
2589 /* Clear the prompt */
2593 if (command == ESCAPE) return (FALSE);
2595 #ifdef ALLOW_REPEAT /* TNB */
2597 repeat_push(*com_val);
2599 #endif /* ALLOW_REPEAT -- TNB */
2607 * Increase the insult counter and get angry if too many -RAK-
2609 static int increase_insults(void)
2611 /* Increase insults */
2612 st_ptr->insult_cur++;
2614 /* Become insulted */
2615 if (st_ptr->insult_cur > ot_ptr->insult_max)
2621 st_ptr->insult_cur = 0;
2622 st_ptr->good_buy = 0;
2623 st_ptr->bad_buy = 0;
2626 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2638 * Decrease insults -RAK-
2640 static void decrease_insults(void)
2642 /* Decrease insults */
2643 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2648 * Have insulted while haggling -RAK-
2650 static int haggle_insults(void)
2652 /* Increase insults */
2653 if (increase_insults()) return (TRUE);
2655 /* Display and flush insult */
2664 * Mega-Hack -- Enable "increments"
2666 static bool allow_inc = FALSE;
2669 * Mega-Hack -- Last "increment" during haggling
2671 static s32b last_inc = 0L;
2677 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
2687 /* Clear old increment if necessary */
2688 if (!allow_inc) last_inc = 0L;
2695 sprintf(buf, "%s [¾µÂú] ", pmt);
2697 sprintf(buf, "%s [accept] ", pmt);
2702 /* Old (negative) increment, and not final */
2703 else if (last_inc < 0)
2706 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2708 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2713 /* Old (positive) increment, and not final */
2714 else if (last_inc > 0)
2717 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2719 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2727 sprintf(buf, "%s ", pmt);
2731 /* Paranoia XXX XXX XXX */
2735 /* Ask until done */
2740 /* Display prompt */
2744 strcpy(out_val, "");
2747 * Ask the user for a response.
2748 * Don't allow to use numpad as cursor key.
2750 res = askfor_aux(out_val, 32, FALSE);
2756 if (!res) return FALSE;
2758 /* Skip leading spaces */
2759 for (p = out_val; *p == ' '; p++) /* loop */;
2761 /* Empty response */
2764 /* Accept current price */
2772 /* Use previous increment */
2773 if (allow_inc && last_inc)
2775 *poffer += last_inc;
2780 /* Normal response */
2783 /* Extract a number */
2786 /* Handle "incremental" number */
2787 if ((*p == '+' || *p == '-'))
2789 /* Allow increments */
2792 /* Use the given "increment" */
2799 /* Handle normal number */
2802 /* Use the given "number" */
2811 msg_print("Ãͤ¬¤ª¤«¤·¤¤¤Ç¤¹¡£");
2813 msg_print("Invalid response.");
2825 * Receive an offer (from the player)
2827 * Return TRUE if offer is NOT okay
2829 static bool receive_offer(cptr pmt, s32b *poffer,
2830 s32b last_offer, int factor,
2831 s32b price, int final)
2833 /* Haggle till done */
2836 /* Get a haggle (or cancel) */
2837 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2839 /* Acceptable offer */
2840 if (((*poffer) * factor) >= (last_offer * factor)) break;
2842 /* Insult, and check for kicked out */
2843 if (haggle_insults()) return (TRUE);
2845 /* Reject offer (correctly) */
2846 (*poffer) = last_offer;
2855 * Haggling routine -RAK-
2857 * Return TRUE if purchase is NOT successful
2859 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2861 s32b cur_ask, final_ask;
2862 s32b last_offer, offer;
2864 s32b min_per, max_per;
2865 int flag, loop_flag, noneed;
2866 int annoyed = 0, final = FALSE;
2868 bool cancel = FALSE;
2871 cptr pmt = "Ä󼨲Á³Ê";
2873 cptr pmt = "Asking";
2883 /* Extract the starting offer and the final offer */
2884 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2885 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2887 /* Determine if haggling is necessary */
2888 noneed = noneedtobargain(final_ask);
2890 /* No need to haggle */
2891 if (noneed || !manual_haggle)
2893 /* No need to haggle */
2896 /* Message summary */
2898 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2900 msg_print("You eventually agree upon the price.");
2906 /* No haggle option */
2909 /* Message summary */
2911 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2913 msg_print("You quickly agree upon the price.");
2918 /* Apply Sales Tax */
2919 final_ask += final_ask / 10;
2923 cur_ask = final_ask;
2925 /* Go to final offer */
2927 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2929 pmt = "Final Offer";
2936 /* Haggle for the whole pile */
2937 cur_ask *= o_ptr->number;
2938 final_ask *= o_ptr->number;
2941 /* Haggle parameters */
2942 min_per = ot_ptr->haggle_per;
2943 max_per = min_per * 3;
2945 /* Mega-Hack -- artificial "last offer" value */
2946 last_offer = object_value(o_ptr) * o_ptr->number;
2947 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
2948 if (last_offer <= 0) last_offer = 1;
2953 /* No incremental haggling yet */
2956 /* Haggle until done */
2957 for (flag = FALSE; !flag; )
2961 while (!flag && loop_flag)
2963 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
2964 put_str(out_val, 1, 0);
2966 cancel = receive_offer("Ä󼨤¹¤ë¶â³Û? ",
2968 cancel = receive_offer("What do you offer? ",
2971 &offer, last_offer, 1, cur_ask, final);
2977 else if (offer > cur_ask)
2982 else if (offer == cur_ask)
2995 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
2998 if (haggle_insults())
3004 else if (x1 > max_per)
3007 if (x1 < max_per) x1 = max_per;
3009 x2 = rand_range(x1-2, x1+2);
3010 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
3011 /* don't let the price go up */
3016 if (cur_ask < final_ask)
3019 cur_ask = final_ask;
3021 pmt = "ºÇ½ªÄ󼨲Á³Ê";
3023 pmt = "Final Offer";
3029 (void)(increase_insults());
3034 else if (offer >= cur_ask)
3046 (void)sprintf(out_val, "Á°²ó¤ÎÄ󼨶â³Û: $%ld",
3048 (void)sprintf(out_val, "Your last offer: %ld",
3052 put_str(out_val, 1, 39);
3053 say_comment_2(cur_ask, annoyed);
3059 if (cancel) return (TRUE);
3061 /* Update bargaining info */
3062 updatebargain(*price, final_ask, o_ptr->number);
3070 * Haggling routine -RAK-
3072 * Return TRUE if purchase is NOT successful
3074 static bool sell_haggle(object_type *o_ptr, s32b *price)
3076 s32b purse, cur_ask, final_ask;
3077 s32b last_offer = 0, offer = 0;
3079 s32b min_per, max_per;
3080 int flag, loop_flag, noneed;
3081 int annoyed = 0, final = FALSE;
3082 bool cancel = FALSE;
3084 cptr pmt = "Ä󼨶â³Û";
3095 /* Obtain the starting offer and the final offer */
3096 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
3097 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
3099 /* Determine if haggling is necessary */
3100 noneed = noneedtobargain(final_ask);
3102 /* Get the owner's payout limit */
3103 purse = (s32b)(ot_ptr->max_cost);
3105 /* No need to haggle */
3106 if (noneed || !manual_haggle || (final_ask >= purse))
3108 /* Apply Sales Tax (if needed) */
3109 if (!manual_haggle && !noneed)
3111 final_ask -= final_ask / 10;
3114 /* No reason to haggle */
3115 if (final_ask >= purse)
3119 msg_print("¨ºÂ¤Ë¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3121 msg_print("You instantly agree upon the price.");
3126 /* Offer full purse */
3130 /* No need to haggle */
3135 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3137 msg_print("You eventually agree upon the price.");
3143 /* No haggle option */
3146 /* Message summary */
3148 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3150 msg_print("You quickly agree upon the price.");
3157 cur_ask = final_ask;
3162 pmt = "ºÇ½ªÄ󼨶â³Û";
3164 pmt = "Final Offer";
3169 /* Haggle for the whole pile */
3170 cur_ask *= o_ptr->number;
3171 final_ask *= o_ptr->number;
3174 /* XXX XXX XXX Display commands */
3176 /* Haggling parameters */
3177 min_per = ot_ptr->haggle_per;
3178 max_per = min_per * 3;
3180 /* Mega-Hack -- artificial "last offer" value */
3181 last_offer = object_value(o_ptr) * o_ptr->number;
3182 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3187 /* No incremental haggling yet */
3191 for (flag = FALSE; !flag; )
3197 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3198 put_str(out_val, 1, 0);
3200 cancel = receive_offer("Ä󼨤¹¤ë²Á³Ê? ",
3202 cancel = receive_offer("What price do you ask? ",
3205 &offer, last_offer, -1, cur_ask, final);
3211 else if (offer < cur_ask)
3214 /* rejected, reset offer for incremental haggling */
3217 else if (offer == cur_ask)
3228 if (flag || !loop_flag) break;
3233 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3236 if (haggle_insults())
3242 else if (x1 > max_per)
3245 if (x1 < max_per) x1 = max_per;
3247 x2 = rand_range(x1-2, x1+2);
3248 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3249 /* don't let the price go down */
3253 if (cur_ask > final_ask)
3255 cur_ask = final_ask;
3258 pmt = "ºÇ½ªÄ󼨶â³Û";
3260 pmt = "Final Offer";
3268 /* Äɲà $0 ¤ÇÇ㤤¼è¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ»ß By FIRST*/
3271 (void)(increase_insults());
3274 else if (offer <= cur_ask)
3285 (void)sprintf(out_val,
3287 "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
3289 "Your last bid %ld", (long)last_offer);
3292 put_str(out_val, 1, 39);
3293 say_comment_3(cur_ask, annoyed);
3299 if (cancel) return (TRUE);
3301 /* Update bargaining info */
3302 updatebargain(*price, final_ask, o_ptr->number);
3310 * Buy an item from a store -RAK-
3312 static void store_purchase(void)
3324 char o_name[MAX_NLEN];
3328 if (cur_store_num == STORE_MUSEUM)
3331 msg_print("Çîʪ´Û¤«¤é¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
3333 msg_print("Museum.");
3339 if (st_ptr->stock_num <= 0)
3341 if (cur_store_num == STORE_HOME)
3343 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3345 msg_print("Your home is empty.");
3350 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
3352 msg_print("I am currently out of stock.");
3359 /* Find the number of objects on this and following pages */
3360 i = (st_ptr->stock_num - store_top);
3362 /* And then restrict it to the current page */
3363 if (i > store_bottom) i = store_bottom;
3367 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
3368 switch( cur_store_num ) {
3370 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
3373 sprintf(out_val, "¤É¤ì? ");
3376 sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
3380 if (cur_store_num == STORE_HOME)
3382 sprintf(out_val, "Which item do you want to take? ");
3386 sprintf(out_val, "Which item are you interested in? ");
3391 /* Get the item number to be bought */
3392 if (!get_stock(&item, out_val, 0, i - 1)) return;
3394 /* Get the actual index */
3395 item = item + store_top;
3397 /* Get the actual item */
3398 o_ptr = &st_ptr->stock[item];
3400 /* Assume the player wants just one of them */
3403 /* Get local object */
3406 /* Get a copy of the object */
3407 object_copy(j_ptr, o_ptr);
3410 * If a rod or wand, allocate total maximum timeouts or charges
3411 * between those purchased and left on the shelf.
3413 reduce_charges(j_ptr, o_ptr->number - amt);
3415 /* Modify quantity */
3416 j_ptr->number = amt;
3418 /* Hack -- require room in pack */
3419 if (!inven_carry_okay(j_ptr))
3422 msg_print("¤½¤ó¤Ê¤Ë¥¢¥¤¥Æ¥à¤ò»ý¤Æ¤Ê¤¤¡£");
3424 msg_print("You cannot carry that many different items.");
3430 /* Determine the "best" price (per item) */
3431 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3433 /* Find out how many the player wants */
3434 if (o_ptr->number > 1)
3436 /* Hack -- note cost of "fixed" items */
3437 if ((cur_store_num != STORE_HOME) &&
3438 (o_ptr->ident & IDENT_FIXED))
3441 msg_format("°ì¤Ä¤Ë¤Ä¤ $%ld¤Ç¤¹¡£", (long)(best));
3443 msg_format("That costs %ld gold per item.", (long)(best));
3448 /* Get a quantity */
3449 amt = get_quantity(NULL, o_ptr->number);
3451 /* Allow user abort */
3452 if (amt <= 0) return;
3455 /* Get local object */
3458 /* Get desired object */
3459 object_copy(j_ptr, o_ptr);
3462 * If a rod or wand, allocate total maximum timeouts or charges
3463 * between those purchased and left on the shelf.
3465 reduce_charges(j_ptr, o_ptr->number - amt);
3467 /* Modify quantity */
3468 j_ptr->number = amt;
3470 /* Hack -- require room in pack */
3471 if (!inven_carry_okay(j_ptr))
3474 msg_print("¥¶¥Ã¥¯¤Ë¤½¤Î¥¢¥¤¥Æ¥à¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£");
3476 msg_print("You cannot carry that many items.");
3482 /* Attempt to buy it */
3483 if (cur_store_num != STORE_HOME)
3485 /* Fixed price, quick buy */
3486 if (o_ptr->ident & (IDENT_FIXED))
3491 /* Go directly to the "best" deal */
3492 price = (best * j_ptr->number);
3498 /* Describe the object (fully) */
3499 object_desc(o_name, j_ptr, 0);
3503 msg_format("%s(%c)¤ò¹ØÆþ¤¹¤ë¡£", o_name, I2A(item));
3505 msg_format("Buying %s (%c).", o_name, I2A(item));
3510 /* Haggle for a final price */
3511 choice = purchase_haggle(j_ptr, &price);
3513 /* Hack -- Got kicked out */
3514 if (st_ptr->store_open >= turn) return;
3517 /* Player wants it */
3520 /* Fix the item price (if "correctly" haggled) */
3521 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3523 /* Player can afford it */
3524 if (p_ptr->au >= price)
3529 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3530 chg_virtue(V_JUSTICE, -1);
3531 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3532 chg_virtue(V_NATURE, -1);
3540 /* Spend the money */
3543 /* Update the display */
3546 /* Hack -- buying an item makes you aware of it */
3547 object_aware(j_ptr);
3549 /* Hack -- clear the "fixed" flag from the item */
3550 j_ptr->ident &= ~(IDENT_FIXED);
3552 /* Describe the transaction */
3553 object_desc(o_name, j_ptr, 0);
3557 msg_format("%s¤ò $%ld¤Ç¹ØÆþ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3559 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3562 strcpy(record_o_name, o_name);
3565 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3566 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3567 if(record_rand_art && o_ptr->art_name)
3568 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3570 /* Erase the inscription */
3571 j_ptr->inscription = 0;
3573 /* Erase the "feeling" */
3574 j_ptr->feeling = FEEL_NONE;
3575 j_ptr->ident &= ~(IDENT_STORE);
3576 /* Give it to the player */
3577 item_new = inven_carry(j_ptr);
3579 /* Describe the final result */
3580 object_desc(o_name, &inventory[item_new], 0);
3584 msg_format("%s(%c)¤ò¼ê¤ËÆþ¤ì¤¿¡£", o_name, index_to_label(item_new));
3586 msg_format("You have %s (%c).",
3587 o_name, index_to_label(item_new));
3590 /* Auto-inscription */
3591 autopick_alter_item(item_new, FALSE);
3593 /* Now, reduce the original stack's pval. */
3594 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3596 o_ptr->pval -= j_ptr->pval;
3602 /* Note how many slots the store used to have */
3603 i = st_ptr->stock_num;
3605 /* Remove the bought items from the store */
3606 store_item_increase(item, -amt);
3607 store_item_optimize(item);
3609 /* Store is empty */
3610 if (st_ptr->stock_num == 0)
3613 if (one_in_(STORE_SHUFFLE))
3618 msg_print("Ź¼ç¤Ï°úÂष¤¿¡£");
3620 msg_print("The shopkeeper retires.");
3624 /* Shuffle the store */
3625 store_shuffle(cur_store_num);
3628 sprintf(buf, "%s (%s)",
3629 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3630 put_str(buf, 3, 10);
3631 sprintf(buf, "%s (%ld)",
3632 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
3641 msg_print("Ź¼ç¤Ï¿·¤¿¤Êºß¸Ë¤ò¼è¤ê½Ð¤·¤¿¡£");
3643 msg_print("The shopkeeper brings out some new stock.");
3649 for (i = 0; i < 10; i++)
3651 /* Maintain the store */
3652 store_maint(p_ptr->town_num, cur_store_num);
3658 /* Redraw everything */
3659 display_inventory();
3662 /* The item is gone */
3663 else if (st_ptr->stock_num != i)
3665 /* Pick the correct screen */
3666 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3668 /* Redraw everything */
3669 display_inventory();
3672 /* Item is still here */
3675 /* Redraw the item */
3676 display_entry(item);
3680 /* Player cannot afford it */
3683 /* Simple message (no insult) */
3685 msg_print("¤ª¶â¤¬Â¤ê¤Þ¤»¤ó¡£");
3687 msg_print("You do not have enough gold.");
3694 /* Home is much easier */
3697 bool combined_or_reordered;
3699 /* Distribute charges of wands/rods */
3700 distribute_charges(o_ptr, j_ptr, amt);
3702 /* Give it to the player */
3703 item_new = inven_carry(j_ptr);
3705 /* Describe just the result */
3706 object_desc(o_name, &inventory[item_new], 0);
3710 msg_format("%s(%c)¤ò¼è¤Ã¤¿¡£",
3712 msg_format("You have %s (%c).",
3714 o_name, index_to_label(item_new));
3719 /* Take note if we take the last one */
3720 i = st_ptr->stock_num;
3722 /* Remove the items from the home */
3723 store_item_increase(item, -amt);
3724 store_item_optimize(item);
3726 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
3728 /* Hack -- Item is still here */
3729 if (i == st_ptr->stock_num)
3731 /* Redraw everything */
3732 if (combined_or_reordered) display_inventory();
3734 /* Redraw the item */
3735 else display_entry(item);
3738 /* The item is gone */
3742 if (st_ptr->stock_num == 0) store_top = 0;
3744 /* Nothing left on that screen */
3745 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3747 /* Redraw everything */
3748 display_inventory();
3750 chg_virtue(V_SACRIFICE, 1);
3754 /* Not kicked out */
3760 * Sell an item to the store (or home)
3762 static void store_sell(void)
3768 s32b price, value, dummy;
3777 char o_name[MAX_NLEN];
3780 /* Prepare a prompt */
3781 if (cur_store_num == STORE_HOME)
3783 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÃÖ¤¤Þ¤¹¤«? ";
3785 q = "Drop which item? ";
3788 else if (cur_store_num == STORE_MUSEUM)
3790 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ó£¤·¤Þ¤¹¤«? ";
3792 q = "Give which item? ";
3797 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÇä¤ê¤Þ¤¹¤«? ";
3799 q = "Sell which item? ";
3803 item_tester_no_ryoute = TRUE;
3804 /* Only allow items the store will buy */
3805 item_tester_hook = store_will_buy;
3808 /* ²æ¤¬²È¤Ç¤ª¤«¤·¤Ê¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¥ª¥ê¥¸¥Ê¥ë¤Î¥Ð¥°¤ò½¤Àµ */
3809 if (cur_store_num == STORE_HOME)
3812 s = "ÃÖ¤±¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3814 s = "You don't have any item to drop.";
3817 else if (cur_store_num == STORE_MUSEUM)
3820 s = "´ó£¤Ç¤¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3822 s = "You don't have any item to give.";
3828 s = "Íߤ·¤¤Êª¤¬¤Ê¤¤¤Ç¤¹¤Í¤¨¡£";
3830 s = "You have nothing that I want.";
3834 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3836 /* Get the item (in the pack) */
3839 o_ptr = &inventory[item];
3842 /* Get the item (on the floor) */
3845 o_ptr = &o_list[0 - item];
3849 /* Hack -- Cannot remove cursed items */
3850 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
3854 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¤Í¡£");
3856 msg_print("Hmmm, it seems to be cursed.");
3865 /* Assume one item */
3868 /* Find out how many the player wants (letter means "all") */
3869 if (o_ptr->number > 1)
3871 /* Get a quantity */
3872 amt = get_quantity(NULL, o_ptr->number);
3874 /* Allow user abort */
3875 if (amt <= 0) return;
3878 /* Get local object */
3881 /* Get a copy of the object */
3882 object_copy(q_ptr, o_ptr);
3884 /* Modify quantity */
3885 q_ptr->number = amt;
3888 * Hack -- If a rod or wand, allocate total maximum
3889 * timeouts or charges to those being sold. -LM-
3891 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3893 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3896 /* Get a full description */
3897 object_desc(o_name, q_ptr, 0);
3899 /* Remove any inscription, feeling for stores */
3900 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3902 q_ptr->inscription = 0;
3903 q_ptr->feeling = FEEL_NONE;
3906 /* Is there room in the store (or the home?) */
3907 if (!store_check_num(q_ptr))
3909 if (cur_store_num == STORE_HOME)
3911 msg_print("²æ¤¬²È¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤Ê¤¤¡£");
3913 msg_print("Your home is full.");
3916 else if (cur_store_num == STORE_MUSEUM)
3918 msg_print("Çîʪ´Û¤Ï¤â¤¦ËþÇÕ¤À¡£");
3920 msg_print("Museum is full.");
3925 msg_print("¤¹¤¤¤Þ¤»¤ó¤¬¡¢Å¹¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤¢¤ê¤Þ¤»¤ó¡£");
3927 msg_print("I have not the room in my store to keep it.");
3935 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3937 /* Describe the transaction */
3939 msg_format("%s(%c)¤òÇäµÑ¤¹¤ë¡£", o_name, index_to_label(item));
3941 msg_format("Selling %s (%c).", o_name, index_to_label(item));
3947 choice = sell_haggle(q_ptr, &price);
3950 if (st_ptr->store_open >= turn) return;
3962 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3963 chg_virtue(V_JUSTICE, -1);
3965 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3966 chg_virtue(V_NATURE, 1);
3969 /* Get some money */
3972 /* Update the display */
3975 /* Get the "apparent" value */
3976 dummy = object_value(q_ptr) * q_ptr->number;
3979 identify_item(o_ptr);
3981 /* Get local object */
3984 /* Get a copy of the object */
3985 object_copy(q_ptr, o_ptr);
3987 /* Modify quantity */
3988 q_ptr->number = amt;
3990 /* Make it look like to be known */
3991 q_ptr->ident |= IDENT_STORE;
3994 * Hack -- If a rod or wand, let the shopkeeper know just
3995 * how many charges he really paid for. -LM-
3997 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3999 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
4002 /* Get the "actual" value */
4003 value = object_value(q_ptr) * q_ptr->number;
4005 /* Get the description all over again */
4006 object_desc(o_name, q_ptr, 0);
4008 /* Describe the result (in message buffer) */
4010 msg_format("%s¤ò $%ld¤ÇÇäµÑ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
4012 msg_format("You sold %s for %ld gold.", o_name, (long)price);
4015 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
4017 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
4019 /* Analyze the prices (and comment verbally) unless a figurine*/
4020 purchase_analyze(price, value, dummy);
4024 * Hack -- Allocate charges between those wands or rods sold
4025 * and retained, unless all are being sold. -LM-
4027 distribute_charges(o_ptr, q_ptr, amt);
4029 /* Reset timeouts of the sold items */
4032 /* Take the item from the player, describe the result */
4033 inven_item_increase(item, -amt);
4034 inven_item_describe(item);
4036 /* If items remain, auto-inscribe before optimizing */
4037 if (o_ptr->number > 0)
4038 autopick_alter_item(item, FALSE);
4040 inven_item_optimize(item);
4045 /* The store gets that (known) item */
4046 item_pos = store_carry(q_ptr);
4048 /* Re-display if item is now in store */
4051 store_top = (item_pos / store_bottom) * store_bottom;
4052 display_inventory();
4057 /* Player is at museum */
4058 else if (cur_store_num == STORE_MUSEUM)
4060 char o2_name[MAX_NLEN];
4061 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
4063 if (-1 == store_check_num(q_ptr))
4066 msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£");
4068 msg_print("The same object as it is already in the Museum.");
4074 msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª¡ª");
4076 msg_print("You cannot take items which is given to the Museum back!!");
4080 if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return;
4082 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
4086 identify_item(q_ptr);
4087 q_ptr->ident |= IDENT_MENTAL;
4089 /* Distribute charges of wands/rods */
4090 distribute_charges(o_ptr, q_ptr, amt);
4094 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
4096 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4101 /* Take it from the players inventory */
4102 inven_item_increase(item, -amt);
4103 inven_item_describe(item);
4104 inven_item_optimize(item);
4109 /* Let the home carry it */
4110 item_pos = home_carry(q_ptr);
4112 /* Update store display */
4115 store_top = (item_pos / store_bottom) * store_bottom;
4116 display_inventory();
4119 /* Player is at home */
4122 /* Distribute charges of wands/rods */
4123 distribute_charges(o_ptr, q_ptr, amt);
4127 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
4129 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4134 /* Take it from the players inventory */
4135 inven_item_increase(item, -amt);
4136 inven_item_describe(item);
4137 inven_item_optimize(item);
4142 /* Let the home carry it */
4143 item_pos = home_carry(q_ptr);
4145 /* Update store display */
4148 store_top = (item_pos / store_bottom) * store_bottom;
4149 display_inventory();
4153 if ((choice == 0) && (item >= INVEN_RARM))
4162 * Examine an item in a store -JDL-
4164 static void store_examine(void)
4169 char o_name[MAX_NLEN];
4174 if (st_ptr->stock_num <= 0)
4176 if (cur_store_num == STORE_HOME)
4178 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4180 msg_print("Your home is empty.");
4183 else if (cur_store_num == STORE_MUSEUM)
4185 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4187 msg_print("Museum is empty.");
4192 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
4194 msg_print("I am currently out of stock.");
4201 /* Find the number of objects on this and following pages */
4202 i = (st_ptr->stock_num - store_top);
4204 /* And then restrict it to the current page */
4205 if (i > store_bottom) i = store_bottom;
4209 sprintf(out_val, "¤É¤ì¤òÄ´¤Ù¤Þ¤¹¤«¡©");
4211 sprintf(out_val, "Which item do you want to examine? ");
4215 /* Get the item number to be examined */
4216 if (!get_stock(&item, out_val, 0, i - 1)) return;
4218 /* Get the actual index */
4219 item = item + store_top;
4221 /* Get the actual item */
4222 o_ptr = &st_ptr->stock[item];
4224 /* Require full knowledge */
4225 if (!(o_ptr->ident & IDENT_MENTAL))
4227 /* This can only happen in the home */
4229 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
4231 msg_print("You have no special knowledge about that item.");
4238 object_desc(o_name, o_ptr, 0);
4242 msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
4244 msg_format("Examining %s...", o_name);
4248 /* Describe it fully */
4249 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
4251 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
4253 msg_print("You see nothing special.");
4262 * Remove an item from museum (Originally from TOband)
4264 static void museum_remove_object(void)
4269 char o_name[MAX_NLEN];
4273 if (st_ptr->stock_num <= 0)
4276 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4278 msg_print("Museum is empty.");
4284 /* Find the number of objects on this and following pages */
4285 i = st_ptr->stock_num - store_top;
4287 /* And then restrict it to the current page */
4288 if (i > store_bottom) i = store_bottom;
4292 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©");
4294 sprintf(out_val, "Which item do you want to order to remove? ");
4297 /* Get the item number to be removed */
4298 if (!get_stock(&item, out_val, 0, i - 1)) return;
4300 /* Get the actual index */
4301 item = item + store_top;
4303 /* Get the actual item */
4304 o_ptr = &st_ptr->stock[item];
4307 object_desc(o_name, o_ptr, 0);
4310 msg_print("Ÿ¼¨¤ò¤ä¤á¤µ¤»¤¿¥¢¥¤¥Æ¥à¤ÏÆóÅ٤ȸ«¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡ª");
4311 if (!get_check(format("ËÜÅö¤Ë%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©", o_name))) return;
4313 msg_print("You cannot see items which is removed from the Museum!");
4314 if (!get_check(format("Really order to remove %s from the Museum? ", o_name))) return;
4319 msg_format("%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤¿¡£", o_name);
4321 msg_format("You ordered to remove %s.", o_name);
4324 /* Remove the items from the home */
4325 store_item_increase(item, -o_ptr->number);
4326 store_item_optimize(item);
4328 (void)combine_and_reorder_home(STORE_MUSEUM);
4330 /* The item is gone */
4333 if (st_ptr->stock_num == 0) store_top = 0;
4335 /* Nothing left on that screen */
4336 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4338 /* Redraw everything */
4339 display_inventory();
4346 * Hack -- set this to leave the store
4348 static bool leave_store = FALSE;
4352 * Process a command in a store
4354 * Note that we must allow the use of a few "special" commands
4355 * in the stores which are not allowed in the dungeon, and we
4356 * must disable some commands which are allowed in the dungeon
4357 * but not in the stores, to prevent chaos.
4359 static void store_process_command(void)
4361 #ifdef ALLOW_REPEAT /* TNB */
4363 /* Handle repeating the last command */
4366 #endif /* ALLOW_REPEAT -- TNB */
4368 if (rogue_like_commands && command_cmd == 'l')
4370 command_cmd = 'x'; /* hack! */
4373 /* Parse the command */
4374 switch (command_cmd)
4384 /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
4387 if (st_ptr->stock_num <= store_bottom) {
4389 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4391 msg_print("Entire inventory is shown.");
4395 store_top -= store_bottom;
4396 if ( store_top < 0 )
4397 store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
4398 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4399 if ( store_top >= store_bottom ) store_top = store_bottom;
4400 display_inventory();
4408 if (st_ptr->stock_num <= store_bottom)
4411 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4413 msg_print("Entire inventory is shown.");
4419 store_top += store_bottom;
4421 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
4422 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
4424 if ((cur_store_num == STORE_HOME) &&
4425 (powerup_home == FALSE) &&
4426 (st_ptr->stock_num >= STORE_INVEN_MAX))
4428 if (store_top >= (STORE_INVEN_MAX - 1))
4435 if (store_top >= st_ptr->stock_num) store_top = 0;
4438 display_inventory();
4451 /* Get (purchase) */
4478 /*** Inventory Commands ***/
4480 /* Wear/wield equipment */
4487 /* Take off equipment */
4494 /* Destroy an item */
4501 /* Equipment list */
4508 /* Inventory list */
4516 /*** Various commands ***/
4518 /* Identify an object */
4525 /* Hack -- toggle windows */
4528 toggle_inven_equip();
4534 /*** Use various objects ***/
4539 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4540 (p_ptr->pclass == CLASS_BERSERKER) ||
4541 (p_ptr->pclass == CLASS_NINJA) ||
4542 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4543 ) do_cmd_mind_browse();
4544 else if (p_ptr->pclass == CLASS_SMITH)
4546 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4547 do_cmd_magic_eater(TRUE);
4548 else if (p_ptr->pclass == CLASS_SNIPER)
4549 do_cmd_snipe_browse();
4550 else do_cmd_browse();
4554 /* Inscribe an object */
4561 /* Uninscribe an object */
4564 do_cmd_uninscribe();
4570 /*** Help and Such ***/
4579 /* Identify symbol */
4582 do_cmd_query_symbol();
4586 /* Character description */
4589 p_ptr->town_num = old_town_num;
4590 do_cmd_change_name();
4591 p_ptr->town_num = inner_town_num;
4597 /*** System Commands ***/
4599 /* Hack -- User interface */
4606 /* Single line from a pref file */
4609 p_ptr->town_num = old_town_num;
4611 p_ptr->town_num = inner_town_num;
4615 /* Interact with macros */
4618 p_ptr->town_num = old_town_num;
4620 p_ptr->town_num = inner_town_num;
4624 /* Interact with visuals */
4627 p_ptr->town_num = old_town_num;
4629 p_ptr->town_num = inner_town_num;
4633 /* Interact with colors */
4636 p_ptr->town_num = old_town_num;
4638 p_ptr->town_num = inner_town_num;
4642 /* Interact with options */
4646 (void)combine_and_reorder_home(STORE_HOME);
4652 /*** Misc Commands ***/
4668 /* Repeat level feeling */
4675 /* Show previous message */
4678 do_cmd_message_one();
4682 /* Show previous messages */
4695 /* Check artifacts, uniques etc. */
4702 /* Load "screen dump" */
4705 do_cmd_load_screen();
4709 /* Save "screen dump" */
4712 do_cmd_save_screen();
4716 /* Hack -- Unknown command */
4719 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
4721 museum_remove_object();
4726 msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
4728 msg_print("That command does not work in stores.");
4739 * Enter a store, and interact with it.
4741 * Note that we use the standard "request_command()" function
4742 * to get a command, allowing us to use "command_arg" and all
4743 * command macros and other nifty stuff, but we use the special
4744 * "shopping" argument, to force certain commands to be converted
4745 * into other commands, normally, we convert "p" (pray) and "m"
4746 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4748 void do_cmd_store(void)
4754 bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
4758 Term_get_size(&w, &h);
4760 /* Calculate stocks per 1 page */
4761 xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
4762 store_bottom = MIN_STOCK + xtra_stock;
4764 /* Access the player grid */
4765 c_ptr = &cave[py][px];
4767 /* Verify a store */
4768 if (!cave_have_flag_grid(c_ptr, FF_STORE))
4771 msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
4773 msg_print("You see no store here.");
4779 /* Extract the store code */
4780 which = f_info[c_ptr->feat].subtype;
4782 old_town_num = p_ptr->town_num;
4783 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4784 if (dun_level) p_ptr->town_num = NO_TOWN;
4785 inner_town_num = p_ptr->town_num;
4787 /* Hack -- Check the "locked doors" */
4788 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4792 msg_print("¥É¥¢¤Ë¸°¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£");
4794 msg_print("The doors are locked.");
4797 p_ptr->town_num = old_town_num;
4801 /* Calculate the number of store maintainances since the last visit */
4802 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4804 /* Maintain the store max. 10 times */
4805 if (maintain_num > 10) maintain_num = 10;
4809 /* Maintain the store */
4810 for (i = 0; i < maintain_num; i++)
4811 store_maint(p_ptr->town_num, which);
4813 /* Save the visit */
4814 town[p_ptr->town_num].store[which].last_visit = turn;
4817 /* Forget the lite */
4820 /* Forget the view */
4824 /* Hack -- Character is in "icky" mode */
4825 character_icky = TRUE;
4828 /* No command argument */
4831 /* No repeated command */
4834 /* No automatic command */
4837 /* Do not expand macros */
4838 get_com_no_macros = TRUE;
4840 /* Save the store number */
4841 cur_store_num = which;
4843 /* Hack -- save the store feature */
4844 cur_store_feat = c_ptr->feat;
4846 /* Save the store and owner pointers */
4847 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4848 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4851 /* Start at the beginning */
4854 /* Display the store */
4858 leave_store = FALSE;
4860 /* Interact with player */
4861 while (!leave_store)
4863 /* Hack -- Clear line 1 */
4867 clear_from(20 + xtra_stock);
4870 /* Basic commands */
4872 prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21 + xtra_stock, 0);
4874 prt(" ESC) Exit from Building.", 21 + xtra_stock, 0);
4878 /* Browse if necessary */
4879 if (st_ptr->stock_num > store_bottom)
4882 prt(" -)Á°¥Ú¡¼¥¸", 22 + xtra_stock, 0);
4883 prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23 + xtra_stock, 0);
4885 prt(" -) Previous page", 22 + xtra_stock, 0);
4886 prt(" SPACE) Next page", 23 + xtra_stock, 0);
4892 if (cur_store_num == STORE_HOME)
4895 prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21 + xtra_stock, 27);
4896 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22 + xtra_stock, 27);
4897 prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
4899 prt("g) Get an item.", 21 + xtra_stock, 27);
4900 prt("d) Drop an item.", 22 + xtra_stock, 27);
4901 prt("x) eXamine an item in the home.", 23 + xtra_stock, 27);
4905 /* Museum commands */
4906 else if (cur_store_num == STORE_MUSEUM)
4909 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21 + xtra_stock, 27);
4910 prt("r) ¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤ë", 22 + xtra_stock, 27);
4911 prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
4913 prt("d) Drop an item.", 21 + xtra_stock, 27);
4914 prt("r) order to Remove an item.", 22 + xtra_stock, 27);
4915 prt("x) eXamine an item in the museum.", 23 + xtra_stock, 27);
4919 /* Shop commands XXX XXX XXX */
4923 prt("p) ¾¦ÉʤòÇ㤦", 21 + xtra_stock, 30);
4924 prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22 + xtra_stock, 30);
4925 prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23 + xtra_stock,30);
4927 prt("p) Purchase an item.", 21 + xtra_stock, 30);
4928 prt("s) Sell an item.", 22 + xtra_stock, 30);
4929 prt("x) eXamine an item in the shop", 23 + xtra_stock,30);
4934 /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
4936 prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21 + xtra_stock, 56);
4938 if (rogue_like_commands)
4940 prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
4944 prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
4947 prt("i/e) Inventry/Equipment list", 21 + xtra_stock, 56);
4949 if (rogue_like_commands)
4951 prt("w/T) Wear/Take off equipment", 22 + xtra_stock, 56);
4955 prt("w/t) Wear/Take off equipment", 22 + xtra_stock, 56);
4960 prt("¥³¥Þ¥ó¥É:", 20 + xtra_stock, 0);
4962 prt("You may: ", 20 + xtra_stock, 0);
4967 request_command(TRUE);
4969 /* Process the command */
4970 store_process_command();
4973 * Hack -- To redraw missiles damage and prices in store
4974 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
4976 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
4978 /* Hack -- Character is still in "icky" mode */
4979 character_icky = TRUE;
4987 /* XXX XXX XXX Pack Overflow */
4988 if (inventory[INVEN_PACK].k_idx)
4990 int item = INVEN_PACK;
4992 object_type *o_ptr = &inventory[item];
4994 /* Hack -- Flee from the store */
4995 if (cur_store_num != STORE_HOME)
4999 if (cur_store_num == STORE_MUSEUM)
5000 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆÇîʪ´Û¤«¤é½Ð¤¿...");
5002 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆŹ¤«¤é½Ð¤¿...");
5004 if (cur_store_num == STORE_MUSEUM)
5005 msg_print("Your pack is so full that you flee the Museum...");
5007 msg_print("Your pack is so full that you flee the store...");
5015 /* Hack -- Flee from the home */
5016 else if (!store_check_num(o_ptr))
5020 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤Æ²È¤«¤é½Ð¤¿...");
5022 msg_print("Your pack is so full that you flee your home...");
5030 /* Hack -- Drop items into the home */
5038 char o_name[MAX_NLEN];
5041 /* Give a message */
5043 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
5045 msg_print("Your pack overflows!");
5049 /* Get local object */
5052 /* Grab a copy of the item */
5053 object_copy(q_ptr, o_ptr);
5056 object_desc(o_name, q_ptr, 0);
5060 msg_format("%s¤¬Íî¤Á¤¿¡£(%c)", o_name, index_to_label(item));
5062 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5066 /* Remove it from the players inventory */
5067 inven_item_increase(item, -255);
5068 inven_item_describe(item);
5069 inven_item_optimize(item);
5074 /* Let the home carry it */
5075 item_pos = home_carry(q_ptr);
5077 /* Redraw the home */
5080 store_top = (item_pos / store_bottom) * store_bottom;
5081 display_inventory();
5086 /* Hack -- Redisplay store prices if charisma changes */
5087 /* Hack -- Redraw missiles damage if player changes bow */
5088 if (need_redraw_store_inv) display_inventory();
5090 /* Hack -- get kicked out of the store */
5091 if (st_ptr->store_open >= turn) leave_store = TRUE;
5094 p_ptr->town_num = old_town_num;
5096 /* Free turn XXX XXX XXX */
5100 /* Hack -- Character is no longer in "icky" mode */
5101 character_icky = FALSE;
5104 /* Hack -- Cancel automatic command */
5107 /* Hack -- Cancel "see" mode */
5108 command_see = FALSE;
5110 /* Allow expanding macros */
5111 get_com_no_macros = FALSE;
5113 /* Flush messages XXX XXX XXX */
5117 /* Clear the screen */
5121 /* Update everything */
5122 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
5123 p_ptr->update |= (PU_MONSTERS);
5125 /* Redraw entire screen */
5126 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5129 p_ptr->redraw |= (PR_MAP);
5132 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5138 * Shuffle one of the stores.
5140 void store_shuffle(int which)
5146 if (which == STORE_HOME) return;
5147 if (which == STORE_MUSEUM) return;
5150 /* Save the store index */
5151 cur_store_num = which;
5153 /* Activate that store */
5154 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
5157 /* Pick a new owner */
5160 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5161 if (j == st_ptr->owner) continue;
5162 for (i = 1;i < max_towns; i++)
5164 if (i == p_ptr->town_num) continue;
5165 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
5167 if (i == max_towns) break;
5170 /* Activate the new owner */
5171 ot_ptr = &owners[cur_store_num][st_ptr->owner];
5174 /* Reset the owner data */
5175 st_ptr->insult_cur = 0;
5176 st_ptr->store_open = 0;
5177 st_ptr->good_buy = 0;
5178 st_ptr->bad_buy = 0;
5181 /* Hack -- discount all the items */
5182 for (i = 0; i < st_ptr->stock_num; i++)
5187 o_ptr = &st_ptr->stock[i];
5189 if (!object_is_artifact(o_ptr))
5191 /* Hack -- Sell all non-artifact old items for "half price" */
5192 o_ptr->discount = 50;
5194 /* Hack -- Items are no longer "fixed price" */
5195 o_ptr->ident &= ~(IDENT_FIXED);
5197 /* Mega-Hack -- Note that the item is "on sale" */
5199 o_ptr->inscription = quark_add("Çä½ÐÃæ");
5201 o_ptr->inscription = quark_add("on sale");
5209 * Maintain the inventory at the stores.
5211 void store_maint(int town_num, int store_num)
5215 cur_store_num = store_num;
5218 if (store_num == STORE_HOME) return;
5219 if (store_num == STORE_MUSEUM) return;
5221 /* Activate that store */
5222 st_ptr = &town[town_num].store[store_num];
5224 /* Activate the owner */
5225 ot_ptr = &owners[store_num][st_ptr->owner];
5227 /* Store keeper forgives the player */
5228 st_ptr->insult_cur = 0;
5230 /* Mega-Hack -- prune the black market */
5231 if (store_num == STORE_BLACK)
5233 /* Destroy crappy black market items */
5234 for (j = st_ptr->stock_num - 1; j >= 0; j--)
5236 object_type *o_ptr = &st_ptr->stock[j];
5238 /* Destroy crappy items */
5239 if (black_market_crap(o_ptr))
5241 /* Destroy the item */
5242 store_item_increase(j, 0 - o_ptr->number);
5243 store_item_optimize(j);
5249 /* Choose the number of slots to keep */
5250 j = st_ptr->stock_num;
5252 /* Sell a few items */
5253 j = j - randint1(STORE_TURNOVER);
5255 /* Never keep more than "STORE_MAX_KEEP" slots */
5256 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5258 /* Always "keep" at least "STORE_MIN_KEEP" items */
5259 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5261 /* Hack -- prevent "underflow" */
5264 /* Destroy objects until only "j" slots are left */
5265 while (st_ptr->stock_num > j) store_delete();
5268 /* Choose the number of slots to fill */
5269 j = st_ptr->stock_num;
5271 /* Buy some more items */
5272 j = j + randint1(STORE_TURNOVER);
5274 /* Never keep more than "STORE_MAX_KEEP" slots */
5275 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5277 /* Always "keep" at least "STORE_MIN_KEEP" items */
5278 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5280 /* Hack -- prevent "overflow" */
5281 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
5283 /* Acquire some new items */
5284 while (st_ptr->stock_num < j) store_create();
5289 * Initialize the stores
5291 void store_init(int town_num, int store_num)
5295 cur_store_num = store_num;
5297 /* Activate that store */
5298 st_ptr = &town[town_num].store[store_num];
5306 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5307 for (i = 1;i < max_towns; i++)
5309 if (i == town_num) continue;
5310 if (st_ptr->owner == town[i].store[store_num].owner) break;
5312 if (i == max_towns) break;
5315 /* Activate the new owner */
5316 ot_ptr = &owners[store_num][st_ptr->owner];
5319 /* Initialize the store */
5320 st_ptr->store_open = 0;
5321 st_ptr->insult_cur = 0;
5322 st_ptr->good_buy = 0;
5323 st_ptr->bad_buy = 0;
5325 /* Nothing in stock */
5326 st_ptr->stock_num = 0;
5329 * MEGA-HACK - Last visit to store is
5330 * BEFORE player birth to enable store restocking
5332 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5334 /* Clear any old items */
5335 for (k = 0; k < st_ptr->stock_size; k++)
5337 object_wipe(&st_ptr->stock[k]);
5342 void move_to_black_market(object_type *o_ptr)
5345 if (!p_ptr->town_num) return;
5347 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5349 o_ptr->ident |= IDENT_STORE;
5351 (void)store_carry(o_ptr);
5353 object_wipe(o_ptr); /* Don't leave a bogus object behind... */