3 * @brief Ź¤Î½èÍý / Store commands
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research, and\n
8 * not for profit purposes provided that this copyright and statement are\n
9 * included in all such copies.\n
10 * 2014 Deskull rearranged comment for Doxygen.
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 const 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?"
305 * @brief ¼è°úÀ®¸ù»þ¤ÎŹ¼ç¤Î¥á¥Ã¥»¡¼¥¸ / Successful haggle.
308 static void say_comment_1(void)
311 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
312 if ( cur_store_num == STORE_BLACK ) {
313 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
316 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
319 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
323 if (one_in_(RUMOR_CHANCE))
326 msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
328 msg_print("The shopkeeper whispers something into your ear:");
336 * Continue haggling (player is buying)
338 static void say_comment_2(s32b value, int annoyed)
342 /* Prepare a string to insert */
343 sprintf(tmp_val, "%ld", (long)value);
348 /* Formatted message */
349 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
355 /* Formatted message */
357 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
358 if ( cur_store_num == STORE_BLACK ){
359 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
362 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
365 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
373 * Continue haggling (player is selling)
375 static void say_comment_3(s32b value, int annoyed)
379 /* Prepare a string to insert */
380 sprintf(tmp_val, "%ld", (long)value);
385 /* Formatted message */
386 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
392 /* Formatted message */
394 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
395 if ( cur_store_num == STORE_BLACK ){
396 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
399 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
402 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
410 * Kick 'da bum out. -RAK-
412 static void say_comment_4(void)
415 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
416 if ( cur_store_num == STORE_BLACK ){
417 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
418 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
421 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
422 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
425 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
426 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
433 * You are insulting me
435 static void say_comment_5(void)
438 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
439 if ( cur_store_num == STORE_BLACK ){
440 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
443 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
446 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
453 * That makes no sense.
455 static void say_comment_6(void)
457 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
463 * Messages for reacting to purchase prices.
466 #define MAX_COMMENT_7A 4
468 static cptr comment_7a[MAX_COMMENT_7A] =
473 "狼¤¬¤à¤»¤Óµã¤¯À¼¤¬Ê¹¤³¤¨¤ë...¡£",
474 "Ź¼ç¤¬²ù¤·¤²¤Ë¤ï¤á¤¤¤Æ¤¤¤ë¡ª"
478 "You hear someone sobbing...",
479 "The shopkeeper howls in agony!"
484 #define MAX_COMMENT_7B 4
486 static cptr comment_7b[MAX_COMMENT_7B] =
491 "Ź¼ç¤¬º¨¤á¤·¤½¤¦¤Ë¸«¤Æ¤¤¤ë¡£",
496 "The shopkeeper curses at you.",
497 "The shopkeeper glares at you."
502 #define MAX_COMMENT_7C 4
504 static cptr comment_7c[MAX_COMMENT_7C] =
508 "·¯¤¬Å·»È¤Ë¸«¤¨¤ë¤è¡ª",
509 "Ź¼ç¤¬¥¯¥¹¥¯¥¹¾Ð¤Ã¤Æ¤¤¤ë¡£",
510 "Ź¼ç¤¬ÂçÀ¼¤Ç¾Ð¤Ã¤Æ¤¤¤ë¡£"
513 "You've made my day!",
514 "The shopkeeper giggles.",
515 "The shopkeeper laughs loudly."
520 #define MAX_COMMENT_7D 4
522 static cptr comment_7d[MAX_COMMENT_7D] =
526 "¤³¤ó¤Ê¤ª¤¤¤·¤¤»×¤¤¤ò¤·¤¿¤é¡¢¿¿ÌÌÌܤËƯ¤±¤Ê¤¯¤Ê¤ë¤Ê¤¡¡£",
527 "Ź¼ç¤Ï´ò¤·¤¯¤ÆÄ·¤Í²ó¤Ã¤Æ¤¤¤ë¡£",
528 "Ź¼ç¤ÏËþÌ̤˾Фߤò¤¿¤¿¤¨¤Æ¤¤¤ë¡£"
531 "I think I'll retire!",
532 "The shopkeeper jumps for joy.",
533 "The shopkeeper smiles gleefully."
540 * Let a shop-keeper React to a purchase
542 * We paid "price", it was worth "value", and we thought it was worth "guess"
544 static void purchase_analyze(s32b price, s32b value, s32b guess)
546 /* Item was worthless, but we bought it */
547 if ((value <= 0) && (price > value))
550 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
552 chg_virtue(V_HONOUR, -1);
553 chg_virtue(V_JUSTICE, -1);
559 /* Item was cheaper than we thought, and we paid more than necessary */
560 else if ((value < guess) && (price > value))
563 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
565 chg_virtue(V_JUSTICE, -1);
567 chg_virtue(V_HONOUR, -1);
573 /* Item was a good bargain, and we got away with it */
574 else if ((value > guess) && (value < (4 * guess)) && (price < value))
577 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
580 chg_virtue(V_HONOUR, -1);
582 chg_virtue(V_HONOUR, 1);
588 /* Item was a great bargain, and we got away with it */
589 else if ((value > guess) && (price < value))
592 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
595 chg_virtue(V_HONOUR, -1);
597 chg_virtue(V_HONOUR, 1);
599 if (10 * price < value)
600 chg_virtue(V_SACRIFICE, 1);
610 * We store the current "store feat" here so everyone can access it
612 static int cur_store_feat;
616 * Buying and selling adjustments for race combinations.
617 * Entry[owner][player] gives the basic "cost inflation".
619 static byte rgold_adj[MAX_RACES][MAX_RACES] =
621 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
622 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
623 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
624 Angel, Demon, Kutar */
627 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
628 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
629 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
630 100, 120, 110, 105 },
633 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
634 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
635 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
636 110, 115, 110, 110 },
639 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
640 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
641 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
642 110, 110, 105, 110 },
645 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
646 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
647 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
648 115, 120, 105, 115 },
651 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
652 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
653 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
654 115, 110, 110, 115 },
657 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
658 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
659 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
660 115, 110, 115, 115 },
663 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
664 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
665 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
666 115, 110, 115, 115 },
669 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
670 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
671 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
672 110, 110, 115, 110 },
675 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
676 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
677 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
678 100, 110, 110, 100 },
681 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
682 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
683 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
684 110, 110, 105, 110 },
686 /* Human / Barbarian (copied from human) */
687 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
688 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
689 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
690 100, 120, 110, 100 },
692 /* Half-Ogre: theoretical, copied from half-troll */
693 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
694 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
695 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
696 110, 110, 115, 110 },
698 /* Half-Giant: theoretical, copied from half-troll */
699 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
700 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
701 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
702 110, 110, 115, 110 },
704 /* Half-Titan: theoretical, copied from High_Elf */
705 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
706 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
707 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
708 110, 110, 115, 110 },
710 /* Cyclops: theoretical, copied from half-troll */
711 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
712 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
713 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
714 110, 110, 115, 110 },
716 /* Yeek: theoretical, copied from Half-Orc */
717 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
718 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
719 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
720 115, 110, 115, 115 },
722 /* Klackon: theoretical, copied from Gnome */
723 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
724 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
725 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
726 115, 110, 115, 115 },
728 /* Kobold: theoretical, copied from Half-Orc */
729 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
730 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
731 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
732 115, 110, 115, 115 },
734 /* Nibelung: theoretical, copied from Dwarf */
735 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
736 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
737 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
738 115, 135, 115, 115 },
741 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
742 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
743 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
744 110, 101, 115, 110 },
746 /* Draconian: theoretical, copied from High_Elf */
747 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
748 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
749 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
750 110, 110, 115, 110 },
752 /* Mind Flayer: theoretical, copied from High_Elf */
753 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
754 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
755 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
756 110, 110, 115, 110 },
758 /* Imp: theoretical, copied from High_Elf */
759 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
760 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
761 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
762 110, 110, 115, 110 },
764 /* Golem: theoretical, copied from High_Elf */
765 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
766 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
767 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
768 110, 110, 115, 110 },
770 /* Skeleton: theoretical, copied from half-orc */
771 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
772 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
773 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
774 115, 110, 125, 115 },
776 /* Zombie: Theoretical, copied from half-orc */
777 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
778 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
779 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
780 115, 110, 125, 115 },
782 /* Vampire: Theoretical, copied from half-orc */
783 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
784 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
785 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
786 115, 110, 125, 115 },
788 /* Spectre: Theoretical, copied from half-orc */
789 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
790 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
791 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
792 115, 110, 125, 115 },
794 /* Sprite: Theoretical, copied from half-orc */
795 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
796 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
797 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
798 115, 110, 105, 115 },
800 /* Beastman: Theoretical, copied from half-orc */
801 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
802 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
803 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
804 115, 110, 115, 115 },
807 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
808 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
809 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
810 110, 110, 105, 110 },
813 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
814 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
815 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
819 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
820 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
821 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
822 140, 140, 140, 140 },
825 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
826 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
827 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
828 100, 120, 110, 100 },
831 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
832 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
833 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
834 110, 101, 115, 110 },
837 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
838 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
839 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
840 110, 115, 100, 110 },
843 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
844 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
845 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
846 100, 120, 110, 100 },
853 * Determine the price of an item (qty one) in a store.
855 * This function takes into account the player's charisma, and the
856 * shop-keepers friendliness, and the shop-keeper's base greed, but
857 * never lets a shop-keeper lose money in a transaction.
859 * The "greed" value should exceed 100 when the player is "buying" the
860 * item, and should be less than 100 when the player is "selling" it.
862 * Hack -- the black market always charges twice as much as it should.
864 * Charisma adjustment runs from 80 to 130
865 * Racial adjustment runs from 95 to 130
867 * Since greed/charisma/racial adjustments are centered at 100, we need
868 * to adjust (by 200) to extract a usable multiplier. Note that the
869 * "greed" value is always something (?).
871 static s32b price_item(object_type *o_ptr, int greed, bool flip)
878 /* Get the value of one of the items */
879 price = object_value(o_ptr);
881 /* Worthless items */
882 if (price <= 0) return (0L);
885 /* Compute the racial factor */
886 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
888 /* Add in the charisma factor */
889 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
895 /* Adjust for greed */
896 adjust = 100 + (300 - (greed + factor));
898 /* Never get "silly" */
899 if (adjust > 100) adjust = 100;
901 /* Mega-Hack -- Black market sucks */
902 if (cur_store_num == STORE_BLACK)
905 /* Compute the final price (with rounding) */
906 /* Hack -- prevent underflow */
907 price = (price * adjust + 50L) / 100L;
910 /* Shop is selling */
913 /* Adjust for greed */
914 adjust = 100 + ((greed + factor) - 300);
916 /* Never get "silly" */
917 if (adjust < 100) adjust = 100;
919 /* Mega-Hack -- Black market sucks */
920 if (cur_store_num == STORE_BLACK)
923 /* Compute the final price (with rounding) */
924 /* Hack -- prevent overflow */
925 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
928 /* Note -- Never become "free" */
929 if (price <= 0L) return (1L);
931 /* Return the price */
937 * Certain "cheap" objects should be created in "piles"
938 * Some objects can be sold at a "discount" (in small piles)
940 static void mass_produce(object_type *o_ptr)
945 s32b cost = object_value(o_ptr);
948 /* Analyze the type */
951 /* Food, Flasks, and Lites */
956 if (cost <= 5L) size += damroll(3, 5);
957 if (cost <= 20L) size += damroll(3, 5);
958 if (cost <= 50L) size += damroll(2, 2);
965 if (cost <= 60L) size += damroll(3, 5);
966 if (cost <= 240L) size += damroll(1, 5);
967 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
968 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
973 case TV_SORCERY_BOOK:
981 case TV_CRUSADE_BOOK:
983 case TV_HISSATSU_BOOK:
986 if (cost <= 50L) size += damroll(2, 3);
987 if (cost <= 500L) size += damroll(1, 3);
1005 if (object_is_artifact(o_ptr)) break;
1006 if (object_is_ego(o_ptr)) break;
1007 if (cost <= 10L) size += damroll(3, 5);
1008 if (cost <= 100L) size += damroll(3, 5);
1017 if (cost <= 5L) size += damroll(5, 5);
1018 if (cost <= 50L) size += damroll(5, 5);
1019 if (cost <= 500L) size += damroll(5, 5);
1025 if (cost <= 100L) size += damroll(2, 2);
1026 if (cost <= 1000L) size += damroll(2, 2);
1039 * Because many rods (and a few wands and staffs) are useful mainly
1040 * in quantity, the Black Market will occasionally have a bunch of
1047 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1049 if (cost < 1601L) size += damroll(1, 5);
1050 else if (cost < 3201L) size += damroll(1, 3);
1057 /* Pick a discount */
1062 else if (one_in_(25))
1066 else if (one_in_(150))
1070 else if (one_in_(300))
1074 else if (one_in_(500))
1080 if (o_ptr->art_name)
1082 if (cheat_peek && discount)
1085 msg_print("¥é¥ó¥À¥à¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÏÃÍ°ú¤¤Ê¤·¡£");
1087 msg_print("No discount on random artifacts.");
1094 /* Save the discount */
1095 o_ptr->discount = discount;
1097 /* Save the total pile size */
1098 o_ptr->number = size - (size * discount / 100);
1100 /* Ensure that mass-produced rods and wands get the correct pvals. */
1101 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1103 o_ptr->pval *= o_ptr->number;
1110 * Determine if a store item can "absorb" another item
1112 * See "object_similar()" for the same function for the "player"
1114 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1118 /* Hack -- Identical items cannot be stacked */
1119 if (o_ptr == j_ptr) return (0);
1121 /* Different objects cannot be stacked */
1122 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1124 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1125 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1127 /* Require many identical values */
1128 if (o_ptr->to_h != j_ptr->to_h) return (0);
1129 if (o_ptr->to_d != j_ptr->to_d) return (0);
1130 if (o_ptr->to_a != j_ptr->to_a) return (0);
1132 /* Require identical "ego-item" names */
1133 if (o_ptr->name2 != j_ptr->name2) return (0);
1135 /* Artifacts don't stack! */
1136 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
1138 /* Hack -- Identical art_flags! */
1139 for (i = 0; i < TR_FLAG_SIZE; i++)
1140 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1142 /* Hack -- Never stack "powerful" items */
1143 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1145 /* Hack -- Never stack recharging items */
1146 if (o_ptr->timeout || j_ptr->timeout) return (0);
1148 /* Require many identical values */
1149 if (o_ptr->ac != j_ptr->ac) return (0);
1150 if (o_ptr->dd != j_ptr->dd) return (0);
1151 if (o_ptr->ds != j_ptr->ds) return (0);
1153 /* Hack -- Never stack chests */
1154 if (o_ptr->tval == TV_CHEST) return (0);
1155 if (o_ptr->tval == TV_STATUE) return (0);
1156 if (o_ptr->tval == TV_CAPTURE) return (0);
1158 /* Require matching discounts */
1159 if (o_ptr->discount != j_ptr->discount) return (0);
1161 /* They match, so they must be similar */
1167 * Allow a store item to absorb another item
1169 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1171 int max_num = (o_ptr->tval == TV_ROD) ?
1172 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1173 int total = o_ptr->number + j_ptr->number;
1174 int diff = (total > max_num) ? total - max_num : 0;
1176 /* Combine quantity, lose excess items */
1177 o_ptr->number = (total > max_num) ? max_num : total;
1179 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1180 if (o_ptr->tval == TV_ROD)
1182 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1185 /* Hack -- if wands are stacking, combine the charges. -LM- */
1186 if (o_ptr->tval == TV_WAND)
1188 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1194 * Check to see if the shop will be carrying too many objects -RAK-
1195 * Note that the shop, just like a player, will not accept things
1196 * it cannot hold. Before, one could "nuke" potions this way.
1198 * Return value is now int:
1200 * -1 : Can be combined to existing slot.
1201 * 1 : Cannot be combined but there are empty spaces.
1203 static int store_check_num(object_type *o_ptr)
1208 /* The "home" acts like the player */
1209 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1211 bool old_stack_force_notes = stack_force_notes;
1212 bool old_stack_force_costs = stack_force_costs;
1214 if (cur_store_num != STORE_HOME)
1216 stack_force_notes = FALSE;
1217 stack_force_costs = FALSE;
1220 /* Check all the items */
1221 for (i = 0; i < st_ptr->stock_num; i++)
1223 /* Get the existing item */
1224 j_ptr = &st_ptr->stock[i];
1226 /* Can the new object be combined with the old one? */
1227 if (object_similar(j_ptr, o_ptr))
1229 if (cur_store_num != STORE_HOME)
1231 stack_force_notes = old_stack_force_notes;
1232 stack_force_costs = old_stack_force_costs;
1239 if (cur_store_num != STORE_HOME)
1241 stack_force_notes = old_stack_force_notes;
1242 stack_force_costs = old_stack_force_costs;
1246 /* Normal stores do special stuff */
1249 /* Check all the items */
1250 for (i = 0; i < st_ptr->stock_num; i++)
1252 /* Get the existing item */
1253 j_ptr = &st_ptr->stock[i];
1255 /* Can the new object be combined with the old one? */
1256 if (store_object_similar(j_ptr, o_ptr)) return -1;
1260 /* Free space is always usable */
1262 * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1263 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1265 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1266 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1271 if (st_ptr->stock_num < st_ptr->stock_size) {
1276 /* But there was no room at the inn... */
1281 static bool is_blessed(object_type *o_ptr)
1283 u32b flgs[TR_FLAG_SIZE];
1284 object_flags(o_ptr, flgs);
1285 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1286 else return (FALSE);
1292 * Determine if the current store will purchase the given item
1294 * Note that a shop-keeper must refuse to buy "worthless" items
1296 static bool store_will_buy(object_type *o_ptr)
1298 /* Hack -- The Home is simple */
1299 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1301 /* Switch on the store */
1302 switch (cur_store_num)
1307 /* Analyze the type */
1308 switch (o_ptr->tval)
1311 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1323 case TV_BOTTLE: /* 'Green', recycling Angband */
1338 /* Analyze the type */
1339 switch (o_ptr->tval)
1360 /* Analyze the type */
1361 switch (o_ptr->tval)
1370 case TV_HISSATSU_BOOK:
1374 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1386 /* Analyze the type */
1387 switch (o_ptr->tval)
1390 case TV_CRUSADE_BOOK:
1400 monster_race *r_ptr = &r_info[o_ptr->pval];
1403 if (!(r_ptr->flags3 & RF3_EVIL))
1406 if (r_ptr->flags3 & RF3_GOOD) break;
1408 /* Accept animals */
1409 if (r_ptr->flags3 & RF3_ANIMAL) break;
1412 if (my_strchr("?!", r_ptr->d_char)) break;
1418 if (is_blessed(o_ptr)) break;
1427 case STORE_ALCHEMIST:
1429 /* Analyze the type */
1430 switch (o_ptr->tval)
1444 /* Analyze the type */
1445 switch (o_ptr->tval)
1447 case TV_SORCERY_BOOK:
1448 case TV_NATURE_BOOK:
1452 case TV_ARCANE_BOOK:
1454 case TV_DAEMON_BOOK:
1468 if(o_ptr->sval == SV_WIZSTAFF) break;
1469 else return (FALSE);
1476 /* Bookstore Shop */
1479 /* Analyze the type */
1480 switch (o_ptr->tval)
1482 case TV_SORCERY_BOOK:
1483 case TV_NATURE_BOOK:
1488 case TV_ARCANE_BOOK:
1490 case TV_DAEMON_BOOK:
1491 case TV_CRUSADE_BOOK:
1502 /* XXX XXX XXX Ignore "worthless" items */
1503 if (object_value(o_ptr) <= 0) return (FALSE);
1511 * Combine and reorder items in the home
1513 bool combine_and_reorder_home(int store_num)
1517 object_type forge, *o_ptr, *j_ptr;
1518 bool flag = FALSE, combined;
1519 store_type *old_st_ptr = st_ptr;
1520 bool old_stack_force_notes = stack_force_notes;
1521 bool old_stack_force_costs = stack_force_costs;
1523 st_ptr = &town[1].store[store_num];
1524 if (store_num != STORE_HOME)
1526 stack_force_notes = FALSE;
1527 stack_force_costs = FALSE;
1534 /* Combine the items in the home (backwards) */
1535 for (i = st_ptr->stock_num - 1; i > 0; i--)
1538 o_ptr = &st_ptr->stock[i];
1540 /* Skip empty items */
1541 if (!o_ptr->k_idx) continue;
1543 /* Scan the items above that item */
1544 for (j = 0; j < i; j++)
1549 j_ptr = &st_ptr->stock[j];
1551 /* Skip empty items */
1552 if (!j_ptr->k_idx) continue;
1555 * Get maximum number of the stack if these
1556 * are similar, get zero otherwise.
1558 max_num = object_similar_part(j_ptr, o_ptr);
1560 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
1561 if (max_num && j_ptr->number < max_num)
1563 if (o_ptr->number + j_ptr->number <= max_num)
1565 /* Add together the item counts */
1566 object_absorb(j_ptr, o_ptr);
1568 /* One object is gone */
1569 st_ptr->stock_num--;
1571 /* Slide everything down */
1572 for (k = i; k < st_ptr->stock_num; k++)
1574 /* Structure copy */
1575 st_ptr->stock[k] = st_ptr->stock[k + 1];
1578 /* Erase the "final" slot */
1579 object_wipe(&st_ptr->stock[k]);
1583 int old_num = o_ptr->number;
1584 int remain = j_ptr->number + o_ptr->number - max_num;
1586 /* Add together the item counts */
1587 object_absorb(j_ptr, o_ptr);
1589 o_ptr->number = remain;
1591 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1592 if (o_ptr->tval == TV_ROD)
1594 o_ptr->pval = o_ptr->pval * remain / old_num;
1595 o_ptr->timeout = o_ptr->timeout * remain / old_num;
1598 /* Hack -- if wands are stacking, combine the charges. -LM- */
1599 else if (o_ptr->tval == TV_WAND)
1601 o_ptr->pval = o_ptr->pval * remain / old_num;
1618 /* Re-order the items in the home (forwards) */
1619 for (i = 0; i < st_ptr->stock_num; i++)
1622 o_ptr = &st_ptr->stock[i];
1624 /* Skip empty slots */
1625 if (!o_ptr->k_idx) continue;
1627 /* Get the "value" of the item */
1628 o_value = object_value(o_ptr);
1630 /* Scan every occupied slot */
1631 for (j = 0; j < st_ptr->stock_num; j++)
1633 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
1636 /* Never move down */
1637 if (j >= i) continue;
1642 /* Get local object */
1645 /* Save a copy of the moving item */
1646 object_copy(j_ptr, &st_ptr->stock[i]);
1648 /* Slide the objects */
1649 for (k = i; k > j; k--)
1651 /* Slide the item */
1652 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
1655 /* Insert the moving item */
1656 object_copy(&st_ptr->stock[j], j_ptr);
1659 st_ptr = old_st_ptr;
1660 if (store_num != STORE_HOME)
1662 stack_force_notes = old_stack_force_notes;
1663 stack_force_costs = old_stack_force_costs;
1671 * Add the item "o_ptr" to the inventory of the "Home"
1673 * In all cases, return the slot (or -1) where the object was placed
1675 * Note that this is a hacked up version of "inven_carry()".
1677 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1678 * known, the player may have to pick stuff up and drop it again.
1680 static int home_carry(object_type *o_ptr)
1686 bool old_stack_force_notes = stack_force_notes;
1687 bool old_stack_force_costs = stack_force_costs;
1689 if (cur_store_num != STORE_HOME)
1691 stack_force_notes = FALSE;
1692 stack_force_costs = FALSE;
1695 /* Check each existing item (try to combine) */
1696 for (slot = 0; slot < st_ptr->stock_num; slot++)
1698 /* Get the existing item */
1699 j_ptr = &st_ptr->stock[slot];
1701 /* The home acts just like the player */
1702 if (object_similar(j_ptr, o_ptr))
1704 /* Save the new number of items */
1705 object_absorb(j_ptr, o_ptr);
1707 if (cur_store_num != STORE_HOME)
1709 stack_force_notes = old_stack_force_notes;
1710 stack_force_costs = old_stack_force_costs;
1718 if (cur_store_num != STORE_HOME)
1720 stack_force_notes = old_stack_force_notes;
1721 stack_force_costs = old_stack_force_costs;
1726 * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1727 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1730 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
1731 if (st_ptr->stock_num >= st_ptr->stock_size) {
1736 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1742 /* Determine the "value" of the item */
1743 value = object_value(o_ptr);
1745 /* Check existing slots to see if we must "slide" */
1746 for (slot = 0; slot < st_ptr->stock_num; slot++)
1748 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
1751 /* Slide the others up */
1752 for (i = st_ptr->stock_num; i > slot; i--)
1754 st_ptr->stock[i] = st_ptr->stock[i-1];
1757 /* More stuff now */
1758 st_ptr->stock_num++;
1760 /* Insert the new item */
1761 st_ptr->stock[slot] = *o_ptr;
1763 chg_virtue(V_SACRIFICE, -1);
1765 (void)combine_and_reorder_home(cur_store_num);
1767 /* Return the location */
1773 * Add the item "o_ptr" to a real stores inventory.
1775 * If the item is "worthless", it is thrown away (except in the home).
1777 * If the item cannot be combined with an object already in the inventory,
1778 * make a new slot for it, and calculate its "per item" price. Note that
1779 * this price will be negative, since the price will not be "fixed" yet.
1780 * Adding an item to a "fixed" price stack will not change the fixed price.
1782 * In all cases, return the slot (or -1) where the object was placed
1784 static int store_carry(object_type *o_ptr)
1787 s32b value, j_value;
1791 /* Evaluate the object */
1792 value = object_value(o_ptr);
1794 /* Cursed/Worthless items "disappear" when sold */
1795 if (value <= 0) return (-1);
1797 /* All store items are fully *identified* */
1798 o_ptr->ident |= IDENT_MENTAL;
1800 /* Erase the inscription */
1801 o_ptr->inscription = 0;
1803 /* Erase the "feeling" */
1804 o_ptr->feeling = FEEL_NONE;
1806 /* Check each existing item (try to combine) */
1807 for (slot = 0; slot < st_ptr->stock_num; slot++)
1809 /* Get the existing item */
1810 j_ptr = &st_ptr->stock[slot];
1812 /* Can the existing items be incremented? */
1813 if (store_object_similar(j_ptr, o_ptr))
1815 /* Hack -- extra items disappear */
1816 store_object_absorb(j_ptr, o_ptr);
1824 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1827 /* Check existing slots to see if we must "slide" */
1828 for (slot = 0; slot < st_ptr->stock_num; slot++)
1831 j_ptr = &st_ptr->stock[slot];
1833 /* Objects sort by decreasing type */
1834 if (o_ptr->tval > j_ptr->tval) break;
1835 if (o_ptr->tval < j_ptr->tval) continue;
1837 /* Objects sort by increasing sval */
1838 if (o_ptr->sval < j_ptr->sval) break;
1839 if (o_ptr->sval > j_ptr->sval) continue;
1842 * Hack: otherwise identical rods sort by
1843 * increasing recharge time --dsb
1845 if (o_ptr->tval == TV_ROD)
1847 if (o_ptr->pval < j_ptr->pval) break;
1848 if (o_ptr->pval > j_ptr->pval) continue;
1851 /* Evaluate that slot */
1852 j_value = object_value(j_ptr);
1854 /* Objects sort by decreasing value */
1855 if (value > j_value) break;
1856 if (value < j_value) continue;
1859 /* Slide the others up */
1860 for (i = st_ptr->stock_num; i > slot; i--)
1862 st_ptr->stock[i] = st_ptr->stock[i-1];
1865 /* More stuff now */
1866 st_ptr->stock_num++;
1868 /* Insert the new item */
1869 st_ptr->stock[slot] = *o_ptr;
1871 /* Return the location */
1877 * Increase, by a given amount, the number of a certain item
1878 * in a certain store. This can result in zero items.
1880 static void store_item_increase(int item, int num)
1886 o_ptr = &st_ptr->stock[item];
1888 /* Verify the number */
1889 cnt = o_ptr->number + num;
1890 if (cnt > 255) cnt = 255;
1891 else if (cnt < 0) cnt = 0;
1892 num = cnt - o_ptr->number;
1894 /* Save the new number */
1895 o_ptr->number += num;
1900 * Remove a slot if it is empty
1902 static void store_item_optimize(int item)
1908 o_ptr = &st_ptr->stock[item];
1911 if (!o_ptr->k_idx) return;
1913 /* Must have no items */
1914 if (o_ptr->number) return;
1917 st_ptr->stock_num--;
1919 /* Slide everyone */
1920 for (j = item; j < st_ptr->stock_num; j++)
1922 st_ptr->stock[j] = st_ptr->stock[j + 1];
1925 /* Nuke the final slot */
1926 object_wipe(&st_ptr->stock[j]);
1931 * This function will keep 'crap' out of the black market.
1932 * Crap is defined as any item that is "available" elsewhere
1933 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1935 static bool black_market_crap(object_type *o_ptr)
1939 /* Ego items are never crap */
1940 if (object_is_ego(o_ptr)) return (FALSE);
1942 /* Good items are never crap */
1943 if (o_ptr->to_a > 0) return (FALSE);
1944 if (o_ptr->to_h > 0) return (FALSE);
1945 if (o_ptr->to_d > 0) return (FALSE);
1947 /* Check all stores */
1948 for (i = 0; i < MAX_STORES; i++)
1950 if (i == STORE_HOME) continue;
1951 if (i == STORE_MUSEUM) continue;
1953 /* Check every item in the store */
1954 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1956 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1958 /* Duplicate item "type", assume crappy */
1959 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
1969 * Attempt to delete (some of) a random item from the store
1970 * Hack -- we attempt to "maintain" piles of items when possible.
1972 static void store_delete(void)
1976 /* Pick a random slot */
1977 what = randint0(st_ptr->stock_num);
1979 /* Determine how many items are here */
1980 num = st_ptr->stock[what].number;
1982 /* Hack -- sometimes, only destroy half the items */
1983 if (randint0(100) < 50) num = (num + 1) / 2;
1985 /* Hack -- sometimes, only destroy a single item */
1986 if (randint0(100) < 50) num = 1;
1988 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
1989 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
1991 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
1994 /* Actually destroy (part of) the item */
1995 store_item_increase(what, -num);
1996 store_item_optimize(what);
2001 * Creates a random item and gives it to a store
2002 * This algorithm needs to be rethought. A lot.
2003 * Currently, "normal" stores use a pre-built array.
2005 * Note -- the "level" given to "obj_get_num()" is a "favored"
2006 * level, that is, there is a much higher chance of getting
2007 * items with a level approaching that of the given level...
2009 * Should we check for "permission" to have the given item?
2011 static void store_create(void)
2013 int i, tries, level;
2019 /* Paranoia -- no room left */
2020 if (st_ptr->stock_num >= st_ptr->stock_size) return;
2023 /* Hack -- consider up to four items */
2024 for (tries = 0; tries < 4; tries++)
2027 if (cur_store_num == STORE_BLACK)
2029 /* Pick a level for object/magic */
2030 level = 25 + randint0(25);
2032 /* Random item (usually of given level) */
2033 i = get_obj_num(level);
2035 /* Handle failure */
2042 /* Hack -- Pick an item to sell */
2043 i = st_ptr->table[randint0(st_ptr->table_num)];
2045 /* Hack -- fake level for apply_magic() */
2046 level = rand_range(1, STORE_OBJ_LEVEL);
2050 /* Get local object */
2053 /* Create a new object of the chosen kind */
2054 object_prep(q_ptr, i);
2056 /* Apply some "low-level" magic (no artifacts) */
2057 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
2059 /* Require valid object */
2060 if (!store_will_buy(q_ptr)) continue;
2062 /* Hack -- Charge lite's */
2063 if (q_ptr->tval == TV_LITE)
2065 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
2066 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
2070 /* The item is "known" */
2071 object_known(q_ptr);
2073 /* Mark it storebought */
2074 q_ptr->ident |= IDENT_STORE;
2076 /* Mega-Hack -- no chests in stores */
2077 if (q_ptr->tval == TV_CHEST) continue;
2079 /* Prune the black market */
2080 if (cur_store_num == STORE_BLACK)
2082 /* Hack -- No "crappy" items */
2083 if (black_market_crap(q_ptr)) continue;
2085 /* Hack -- No "cheap" items */
2086 if (object_value(q_ptr) < 10) continue;
2088 /* No "worthless" items */
2089 /* if (object_value(q_ptr) <= 0) continue; */
2092 /* Prune normal stores */
2095 /* No "worthless" items */
2096 if (object_value(q_ptr) <= 0) continue;
2100 /* Mass produce and/or Apply discount */
2101 mass_produce(q_ptr);
2103 /* Attempt to carry the (known) item */
2104 (void)store_carry(q_ptr);
2106 /* Definitely done */
2114 * Eliminate need to bargain if player has haggled well in the past
2116 static bool noneedtobargain(s32b minprice)
2118 s32b good = st_ptr->good_buy;
2119 s32b bad = st_ptr->bad_buy;
2121 /* Cheap items are "boring" */
2122 if (minprice < 10L) return (TRUE);
2124 /* Perfect haggling */
2125 if (good == MAX_SHORT) return (TRUE);
2127 /* Reward good haggles, punish bad haggles, notice price */
2128 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
2130 /* Return the flag */
2136 * Update the bargain info
2138 static void updatebargain(s32b price, s32b minprice, int num)
2140 /* Hack -- auto-haggle */
2141 if (!manual_haggle) return;
2143 /* Cheap items are "boring" */
2144 if ((minprice/num) < 10L) return;
2146 /* Count the successful haggles */
2147 if (price == minprice)
2149 /* Just count the good haggles */
2150 if (st_ptr->good_buy < MAX_SHORT)
2156 /* Count the failed haggles */
2159 /* Just count the bad haggles */
2160 if (st_ptr->bad_buy < MAX_SHORT)
2170 * Re-displays a single store entry
2172 static void display_entry(int pos)
2178 char o_name[MAX_NLEN];
2185 o_ptr = &st_ptr->stock[pos];
2187 /* Get the "offset" */
2188 i = (pos % store_bottom);
2190 /* Label it, clear the line --(-- */
2191 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
2192 prt(out_val, i+6, 0);
2195 if (show_item_graph)
2197 byte a = object_attr(o_ptr);
2198 char c = object_char(o_ptr);
2205 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
2206 if (use_bigtile) cur_col++;
2211 /* Describe an item in the home */
2212 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2216 /* Leave room for weights, if necessary -DRS- */
2217 if (show_weights) maxwid -= 10;
2219 /* Describe the object */
2220 object_desc(o_name, o_ptr, 0);
2221 o_name[maxwid] = '\0';
2222 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2227 /* Only show the weight of an individual item */
2228 int wgt = o_ptr->weight;
2230 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2231 put_str(out_val, i+6, 67);
2233 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2234 put_str(out_val, i+6, 68);
2240 /* Describe an item (fully) in a store */
2243 /* Must leave room for the "price" */
2246 /* Leave room for weights, if necessary -DRS- */
2247 if (show_weights) maxwid -= 7;
2249 /* Describe the object (fully) */
2250 object_desc(o_name, o_ptr, 0);
2251 o_name[maxwid] = '\0';
2252 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2257 /* Only show the weight of an individual item */
2258 int wgt = o_ptr->weight;
2260 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2261 put_str(out_val, i+6, 60);
2263 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2264 put_str(out_val, i+6, 61);
2269 /* Display a "fixed" cost */
2270 if (o_ptr->ident & (IDENT_FIXED))
2272 /* Extract the "minimum" price */
2273 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2275 /* Actually draw the price (not fixed) */
2277 (void)sprintf(out_val, "%9ld¸Ç", (long)x);
2279 (void)sprintf(out_val, "%9ld F", (long)x);
2282 put_str(out_val, i+6, 68);
2285 /* Display a "taxed" cost */
2286 else if (!manual_haggle)
2288 /* Extract the "minimum" price */
2289 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2291 /* Hack -- Apply Sales Tax if needed */
2292 if (!noneedtobargain(x)) x += x / 10;
2294 /* Actually draw the price (with tax) */
2295 (void)sprintf(out_val, "%9ld ", (long)x);
2296 put_str(out_val, i+6, 68);
2299 /* Display a "haggle" cost */
2302 /* Extrect the "maximum" price */
2303 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2305 /* Actually draw the price (not fixed) */
2306 (void)sprintf(out_val, "%9ld ", (long)x);
2307 put_str(out_val, i+6, 68);
2314 * Displays a store's inventory -RAK-
2315 * All prices are listed as "per individual object". -BEN-
2317 static void display_inventory(void)
2321 /* Display the next 12 items */
2322 for (k = 0; k < store_bottom; k++)
2324 /* Do not display "dead" items */
2325 if (store_top + k >= st_ptr->stock_num) break;
2327 /* Display that line */
2328 display_entry(store_top + k);
2331 /* Erase the extra lines and the "more" prompt */
2332 for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
2334 /* Assume "no current page" */
2336 put_str(" ", 5, 20);
2338 put_str(" ", 5, 20);
2342 /* Visual reminder of "more items" */
2343 if (st_ptr->stock_num > store_bottom)
2345 /* Show "more" reminder (after the last item) */
2347 prt("-³¤¯-", k + 6, 3);
2349 prt("-more-", k + 6, 3);
2353 /* Indicate the "current page" */
2354 /* Trailing spaces are to display (Page xx) and (Page x) */
2356 put_str(format("(%d¥Ú¡¼¥¸) ", store_top/store_bottom + 1), 5, 20);
2358 put_str(format("(Page %d) ", store_top/store_bottom + 1), 5, 20);
2363 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
2365 k = st_ptr->stock_size;
2367 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
2369 put_str(format("¥¢¥¤¥Æ¥à¿ô: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
2371 put_str(format("Objects: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
2378 * Displays players gold -RAK-
2380 static void store_prt_gold(void)
2385 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19 + xtra_stock, 53);
2387 prt("Gold Remaining: ", 19 + xtra_stock, 53);
2391 sprintf(out_val, "%9ld", (long)p_ptr->au);
2392 prt(out_val, 19 + xtra_stock, 68);
2397 * Displays store (after clearing screen) -RAK-
2399 static void display_store(void)
2407 /* The "Home" is special */
2408 if (cur_store_num == STORE_HOME)
2410 /* Put the owner name */
2412 put_str("²æ¤¬²È", 3, 31);
2414 put_str("Your Home", 3, 30);
2418 /* Label the item descriptions */
2420 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2422 put_str("Item Description", 5, 3);
2426 /* If showing weights, show label */
2430 put_str("½Å¤µ", 5, 72);
2432 put_str("Weight", 5, 70);
2438 /* The "Home" is special */
2439 else if (cur_store_num == STORE_MUSEUM)
2441 /* Put the owner name */
2443 put_str("Çîʪ´Û", 3, 31);
2445 put_str("Museum", 3, 30);
2449 /* Label the item descriptions */
2451 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2453 put_str("Item Description", 5, 3);
2457 /* If showing weights, show label */
2461 put_str("½Å¤µ", 5, 72);
2463 put_str("Weight", 5, 70);
2472 cptr store_name = (f_name + f_info[cur_store_feat].name);
2473 cptr owner_name = (ot_ptr->owner_name);
2474 cptr race_name = race_info[ot_ptr->owner_race].title;
2476 /* Put the owner name and race */
2477 sprintf(buf, "%s (%s)", owner_name, race_name);
2478 put_str(buf, 3, 10);
2480 /* Show the max price in the store (above prices) */
2481 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2484 /* Label the item descriptions */
2486 put_str("¾¦ÉʤΰìÍ÷", 5, 7);
2488 put_str("Item Description", 5, 3);
2492 /* If showing weights, show label */
2496 put_str("½Å¤µ", 5, 62);
2498 put_str("Weight", 5, 60);
2503 /* Label the asking price (in stores) */
2505 put_str("²Á³Ê", 5, 73);
2507 put_str("Price", 5, 72);
2512 /* Display the current gold */
2515 /* Draw in the inventory */
2516 display_inventory();
2522 * Get the ID of a store item and return its value -RAK-
2524 static int get_stock(int *com_val, cptr pmt, int i, int j)
2530 #ifdef ALLOW_REPEAT /* TNB */
2532 /* Get the item index */
2533 if (repeat_pull(com_val))
2535 /* Verify the item */
2536 if ((*com_val >= i) && (*com_val <= j))
2543 #endif /* ALLOW_REPEAT -- TNB */
2545 /* Paranoia XXX XXX XXX */
2549 /* Assume failure */
2552 /* Build the prompt */
2554 hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
2556 (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
2557 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
2560 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2565 /* Ask until done */
2571 if (!get_com(out_val, &command, FALSE)) break;
2574 if (islower(command))
2576 else if (isupper(command))
2577 k = A2I(tolower(command)) + 26;
2581 /* Legal responses */
2582 if ((k >= i) && (k <= j))
2592 /* Clear the prompt */
2596 if (command == ESCAPE) return (FALSE);
2598 #ifdef ALLOW_REPEAT /* TNB */
2600 repeat_push(*com_val);
2602 #endif /* ALLOW_REPEAT -- TNB */
2610 * Increase the insult counter and get angry if too many -RAK-
2612 static int increase_insults(void)
2614 /* Increase insults */
2615 st_ptr->insult_cur++;
2617 /* Become insulted */
2618 if (st_ptr->insult_cur > ot_ptr->insult_max)
2624 st_ptr->insult_cur = 0;
2625 st_ptr->good_buy = 0;
2626 st_ptr->bad_buy = 0;
2629 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2641 * Decrease insults -RAK-
2643 static void decrease_insults(void)
2645 /* Decrease insults */
2646 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2651 * Have insulted while haggling -RAK-
2653 static int haggle_insults(void)
2655 /* Increase insults */
2656 if (increase_insults()) return (TRUE);
2658 /* Display and flush insult */
2667 * Mega-Hack -- Enable "increments"
2669 static bool allow_inc = FALSE;
2672 * Mega-Hack -- Last "increment" during haggling
2674 static s32b last_inc = 0L;
2680 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
2690 /* Clear old increment if necessary */
2691 if (!allow_inc) last_inc = 0L;
2698 sprintf(buf, "%s [¾µÂú] ", pmt);
2700 sprintf(buf, "%s [accept] ", pmt);
2705 /* Old (negative) increment, and not final */
2706 else if (last_inc < 0)
2709 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2711 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2716 /* Old (positive) increment, and not final */
2717 else if (last_inc > 0)
2720 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2722 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2730 sprintf(buf, "%s ", pmt);
2734 /* Paranoia XXX XXX XXX */
2738 /* Ask until done */
2743 /* Display prompt */
2747 strcpy(out_val, "");
2750 * Ask the user for a response.
2751 * Don't allow to use numpad as cursor key.
2753 res = askfor_aux(out_val, 32, FALSE);
2759 if (!res) return FALSE;
2761 /* Skip leading spaces */
2762 for (p = out_val; *p == ' '; p++) /* loop */;
2764 /* Empty response */
2767 /* Accept current price */
2775 /* Use previous increment */
2776 if (allow_inc && last_inc)
2778 *poffer += last_inc;
2783 /* Normal response */
2786 /* Extract a number */
2789 /* Handle "incremental" number */
2790 if ((*p == '+' || *p == '-'))
2792 /* Allow increments */
2795 /* Use the given "increment" */
2802 /* Handle normal number */
2805 /* Use the given "number" */
2814 msg_print("Ãͤ¬¤ª¤«¤·¤¤¤Ç¤¹¡£");
2816 msg_print("Invalid response.");
2828 * Receive an offer (from the player)
2830 * Return TRUE if offer is NOT okay
2832 static bool receive_offer(cptr pmt, s32b *poffer,
2833 s32b last_offer, int factor,
2834 s32b price, int final)
2836 /* Haggle till done */
2839 /* Get a haggle (or cancel) */
2840 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2842 /* Acceptable offer */
2843 if (((*poffer) * factor) >= (last_offer * factor)) break;
2845 /* Insult, and check for kicked out */
2846 if (haggle_insults()) return (TRUE);
2848 /* Reject offer (correctly) */
2849 (*poffer) = last_offer;
2858 * Haggling routine -RAK-
2860 * Return TRUE if purchase is NOT successful
2862 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2864 s32b cur_ask, final_ask;
2865 s32b last_offer, offer;
2867 s32b min_per, max_per;
2868 int flag, loop_flag, noneed;
2869 int annoyed = 0, final = FALSE;
2871 bool cancel = FALSE;
2874 cptr pmt = "Ä󼨲Á³Ê";
2876 cptr pmt = "Asking";
2886 /* Extract the starting offer and the final offer */
2887 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2888 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2890 /* Determine if haggling is necessary */
2891 noneed = noneedtobargain(final_ask);
2893 /* No need to haggle */
2894 if (noneed || !manual_haggle)
2896 /* No need to haggle */
2899 /* Message summary */
2901 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2903 msg_print("You eventually agree upon the price.");
2909 /* No haggle option */
2912 /* Message summary */
2914 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2916 msg_print("You quickly agree upon the price.");
2921 /* Apply Sales Tax */
2922 final_ask += final_ask / 10;
2926 cur_ask = final_ask;
2928 /* Go to final offer */
2930 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2932 pmt = "Final Offer";
2939 /* Haggle for the whole pile */
2940 cur_ask *= o_ptr->number;
2941 final_ask *= o_ptr->number;
2944 /* Haggle parameters */
2945 min_per = ot_ptr->haggle_per;
2946 max_per = min_per * 3;
2948 /* Mega-Hack -- artificial "last offer" value */
2949 last_offer = object_value(o_ptr) * o_ptr->number;
2950 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
2951 if (last_offer <= 0) last_offer = 1;
2956 /* No incremental haggling yet */
2959 /* Haggle until done */
2960 for (flag = FALSE; !flag; )
2964 while (!flag && loop_flag)
2966 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
2967 put_str(out_val, 1, 0);
2969 cancel = receive_offer("Ä󼨤¹¤ë¶â³Û? ",
2971 cancel = receive_offer("What do you offer? ",
2974 &offer, last_offer, 1, cur_ask, final);
2980 else if (offer > cur_ask)
2985 else if (offer == cur_ask)
2998 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
3001 if (haggle_insults())
3007 else if (x1 > max_per)
3010 if (x1 < max_per) x1 = max_per;
3012 x2 = rand_range(x1-2, x1+2);
3013 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
3014 /* don't let the price go up */
3019 if (cur_ask < final_ask)
3022 cur_ask = final_ask;
3024 pmt = "ºÇ½ªÄ󼨲Á³Ê";
3026 pmt = "Final Offer";
3032 (void)(increase_insults());
3037 else if (offer >= cur_ask)
3049 (void)sprintf(out_val, "Á°²ó¤ÎÄ󼨶â³Û: $%ld",
3051 (void)sprintf(out_val, "Your last offer: %ld",
3055 put_str(out_val, 1, 39);
3056 say_comment_2(cur_ask, annoyed);
3062 if (cancel) return (TRUE);
3064 /* Update bargaining info */
3065 updatebargain(*price, final_ask, o_ptr->number);
3073 * Haggling routine -RAK-
3075 * Return TRUE if purchase is NOT successful
3077 static bool sell_haggle(object_type *o_ptr, s32b *price)
3079 s32b purse, cur_ask, final_ask;
3080 s32b last_offer = 0, offer = 0;
3082 s32b min_per, max_per;
3083 int flag, loop_flag, noneed;
3084 int annoyed = 0, final = FALSE;
3085 bool cancel = FALSE;
3087 cptr pmt = "Ä󼨶â³Û";
3098 /* Obtain the starting offer and the final offer */
3099 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
3100 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
3102 /* Determine if haggling is necessary */
3103 noneed = noneedtobargain(final_ask);
3105 /* Get the owner's payout limit */
3106 purse = (s32b)(ot_ptr->max_cost);
3108 /* No need to haggle */
3109 if (noneed || !manual_haggle || (final_ask >= purse))
3111 /* Apply Sales Tax (if needed) */
3112 if (!manual_haggle && !noneed)
3114 final_ask -= final_ask / 10;
3117 /* No reason to haggle */
3118 if (final_ask >= purse)
3122 msg_print("¨ºÂ¤Ë¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3124 msg_print("You instantly agree upon the price.");
3129 /* Offer full purse */
3133 /* No need to haggle */
3138 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3140 msg_print("You eventually agree upon the price.");
3146 /* No haggle option */
3149 /* Message summary */
3151 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3153 msg_print("You quickly agree upon the price.");
3160 cur_ask = final_ask;
3165 pmt = "ºÇ½ªÄ󼨶â³Û";
3167 pmt = "Final Offer";
3172 /* Haggle for the whole pile */
3173 cur_ask *= o_ptr->number;
3174 final_ask *= o_ptr->number;
3177 /* XXX XXX XXX Display commands */
3179 /* Haggling parameters */
3180 min_per = ot_ptr->haggle_per;
3181 max_per = min_per * 3;
3183 /* Mega-Hack -- artificial "last offer" value */
3184 last_offer = object_value(o_ptr) * o_ptr->number;
3185 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3190 /* No incremental haggling yet */
3194 for (flag = FALSE; !flag; )
3200 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3201 put_str(out_val, 1, 0);
3203 cancel = receive_offer("Ä󼨤¹¤ë²Á³Ê? ",
3205 cancel = receive_offer("What price do you ask? ",
3208 &offer, last_offer, -1, cur_ask, final);
3214 else if (offer < cur_ask)
3217 /* rejected, reset offer for incremental haggling */
3220 else if (offer == cur_ask)
3231 if (flag || !loop_flag) break;
3236 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3239 if (haggle_insults())
3245 else if (x1 > max_per)
3248 if (x1 < max_per) x1 = max_per;
3250 x2 = rand_range(x1-2, x1+2);
3251 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3252 /* don't let the price go down */
3256 if (cur_ask > final_ask)
3258 cur_ask = final_ask;
3261 pmt = "ºÇ½ªÄ󼨶â³Û";
3263 pmt = "Final Offer";
3271 /* Äɲà $0 ¤ÇÇ㤤¼è¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ»ß By FIRST*/
3274 (void)(increase_insults());
3277 else if (offer <= cur_ask)
3288 (void)sprintf(out_val,
3290 "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
3292 "Your last bid %ld", (long)last_offer);
3295 put_str(out_val, 1, 39);
3296 say_comment_3(cur_ask, annoyed);
3302 if (cancel) return (TRUE);
3304 /* Update bargaining info */
3305 updatebargain(*price, final_ask, o_ptr->number);
3313 * Buy an item from a store -RAK-
3315 static void store_purchase(void)
3327 char o_name[MAX_NLEN];
3331 if (cur_store_num == STORE_MUSEUM)
3334 msg_print("Çîʪ´Û¤«¤é¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
3336 msg_print("Museum.");
3342 if (st_ptr->stock_num <= 0)
3344 if (cur_store_num == STORE_HOME)
3346 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3348 msg_print("Your home is empty.");
3353 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
3355 msg_print("I am currently out of stock.");
3362 /* Find the number of objects on this and following pages */
3363 i = (st_ptr->stock_num - store_top);
3365 /* And then restrict it to the current page */
3366 if (i > store_bottom) i = store_bottom;
3370 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
3371 switch( cur_store_num ) {
3373 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
3376 sprintf(out_val, "¤É¤ì? ");
3379 sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
3383 if (cur_store_num == STORE_HOME)
3385 sprintf(out_val, "Which item do you want to take? ");
3389 sprintf(out_val, "Which item are you interested in? ");
3394 /* Get the item number to be bought */
3395 if (!get_stock(&item, out_val, 0, i - 1)) return;
3397 /* Get the actual index */
3398 item = item + store_top;
3400 /* Get the actual item */
3401 o_ptr = &st_ptr->stock[item];
3403 /* Assume the player wants just one of them */
3406 /* Get local object */
3409 /* Get a copy of the object */
3410 object_copy(j_ptr, o_ptr);
3413 * If a rod or wand, allocate total maximum timeouts or charges
3414 * between those purchased and left on the shelf.
3416 reduce_charges(j_ptr, o_ptr->number - amt);
3418 /* Modify quantity */
3419 j_ptr->number = amt;
3421 /* Hack -- require room in pack */
3422 if (!inven_carry_okay(j_ptr))
3425 msg_print("¤½¤ó¤Ê¤Ë¥¢¥¤¥Æ¥à¤ò»ý¤Æ¤Ê¤¤¡£");
3427 msg_print("You cannot carry that many different items.");
3433 /* Determine the "best" price (per item) */
3434 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3436 /* Find out how many the player wants */
3437 if (o_ptr->number > 1)
3439 /* Hack -- note cost of "fixed" items */
3440 if ((cur_store_num != STORE_HOME) &&
3441 (o_ptr->ident & IDENT_FIXED))
3444 msg_format("°ì¤Ä¤Ë¤Ä¤ $%ld¤Ç¤¹¡£", (long)(best));
3446 msg_format("That costs %ld gold per item.", (long)(best));
3451 /* Get a quantity */
3452 amt = get_quantity(NULL, o_ptr->number);
3454 /* Allow user abort */
3455 if (amt <= 0) return;
3458 /* Get local object */
3461 /* Get desired object */
3462 object_copy(j_ptr, o_ptr);
3465 * If a rod or wand, allocate total maximum timeouts or charges
3466 * between those purchased and left on the shelf.
3468 reduce_charges(j_ptr, o_ptr->number - amt);
3470 /* Modify quantity */
3471 j_ptr->number = amt;
3473 /* Hack -- require room in pack */
3474 if (!inven_carry_okay(j_ptr))
3477 msg_print("¥¶¥Ã¥¯¤Ë¤½¤Î¥¢¥¤¥Æ¥à¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£");
3479 msg_print("You cannot carry that many items.");
3485 /* Attempt to buy it */
3486 if (cur_store_num != STORE_HOME)
3488 /* Fixed price, quick buy */
3489 if (o_ptr->ident & (IDENT_FIXED))
3494 /* Go directly to the "best" deal */
3495 price = (best * j_ptr->number);
3501 /* Describe the object (fully) */
3502 object_desc(o_name, j_ptr, 0);
3506 msg_format("%s(%c)¤ò¹ØÆþ¤¹¤ë¡£", o_name, I2A(item));
3508 msg_format("Buying %s (%c).", o_name, I2A(item));
3513 /* Haggle for a final price */
3514 choice = purchase_haggle(j_ptr, &price);
3516 /* Hack -- Got kicked out */
3517 if (st_ptr->store_open >= turn) return;
3520 /* Player wants it */
3523 /* Fix the item price (if "correctly" haggled) */
3524 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3526 /* Player can afford it */
3527 if (p_ptr->au >= price)
3532 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3533 chg_virtue(V_JUSTICE, -1);
3534 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3535 chg_virtue(V_NATURE, -1);
3543 /* Spend the money */
3546 /* Update the display */
3549 /* Hack -- buying an item makes you aware of it */
3550 object_aware(j_ptr);
3552 /* Hack -- clear the "fixed" flag from the item */
3553 j_ptr->ident &= ~(IDENT_FIXED);
3555 /* Describe the transaction */
3556 object_desc(o_name, j_ptr, 0);
3560 msg_format("%s¤ò $%ld¤Ç¹ØÆþ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3562 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3565 strcpy(record_o_name, o_name);
3568 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3569 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3570 if(record_rand_art && o_ptr->art_name)
3571 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3573 /* Erase the inscription */
3574 j_ptr->inscription = 0;
3576 /* Erase the "feeling" */
3577 j_ptr->feeling = FEEL_NONE;
3578 j_ptr->ident &= ~(IDENT_STORE);
3579 /* Give it to the player */
3580 item_new = inven_carry(j_ptr);
3582 /* Describe the final result */
3583 object_desc(o_name, &inventory[item_new], 0);
3587 msg_format("%s(%c)¤ò¼ê¤ËÆþ¤ì¤¿¡£", o_name, index_to_label(item_new));
3589 msg_format("You have %s (%c).",
3590 o_name, index_to_label(item_new));
3593 /* Auto-inscription */
3594 autopick_alter_item(item_new, FALSE);
3596 /* Now, reduce the original stack's pval. */
3597 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3599 o_ptr->pval -= j_ptr->pval;
3605 /* Note how many slots the store used to have */
3606 i = st_ptr->stock_num;
3608 /* Remove the bought items from the store */
3609 store_item_increase(item, -amt);
3610 store_item_optimize(item);
3612 /* Store is empty */
3613 if (st_ptr->stock_num == 0)
3616 if (one_in_(STORE_SHUFFLE))
3621 msg_print("Ź¼ç¤Ï°úÂष¤¿¡£");
3623 msg_print("The shopkeeper retires.");
3627 /* Shuffle the store */
3628 store_shuffle(cur_store_num);
3631 sprintf(buf, "%s (%s)",
3632 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3633 put_str(buf, 3, 10);
3634 sprintf(buf, "%s (%ld)",
3635 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
3644 msg_print("Ź¼ç¤Ï¿·¤¿¤Êºß¸Ë¤ò¼è¤ê½Ð¤·¤¿¡£");
3646 msg_print("The shopkeeper brings out some new stock.");
3652 for (i = 0; i < 10; i++)
3654 /* Maintain the store */
3655 store_maint(p_ptr->town_num, cur_store_num);
3661 /* Redraw everything */
3662 display_inventory();
3665 /* The item is gone */
3666 else if (st_ptr->stock_num != i)
3668 /* Pick the correct screen */
3669 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3671 /* Redraw everything */
3672 display_inventory();
3675 /* Item is still here */
3678 /* Redraw the item */
3679 display_entry(item);
3683 /* Player cannot afford it */
3686 /* Simple message (no insult) */
3688 msg_print("¤ª¶â¤¬Â¤ê¤Þ¤»¤ó¡£");
3690 msg_print("You do not have enough gold.");
3697 /* Home is much easier */
3700 bool combined_or_reordered;
3702 /* Distribute charges of wands/rods */
3703 distribute_charges(o_ptr, j_ptr, amt);
3705 /* Give it to the player */
3706 item_new = inven_carry(j_ptr);
3708 /* Describe just the result */
3709 object_desc(o_name, &inventory[item_new], 0);
3713 msg_format("%s(%c)¤ò¼è¤Ã¤¿¡£",
3715 msg_format("You have %s (%c).",
3717 o_name, index_to_label(item_new));
3722 /* Take note if we take the last one */
3723 i = st_ptr->stock_num;
3725 /* Remove the items from the home */
3726 store_item_increase(item, -amt);
3727 store_item_optimize(item);
3729 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
3731 /* Hack -- Item is still here */
3732 if (i == st_ptr->stock_num)
3734 /* Redraw everything */
3735 if (combined_or_reordered) display_inventory();
3737 /* Redraw the item */
3738 else display_entry(item);
3741 /* The item is gone */
3745 if (st_ptr->stock_num == 0) store_top = 0;
3747 /* Nothing left on that screen */
3748 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3750 /* Redraw everything */
3751 display_inventory();
3753 chg_virtue(V_SACRIFICE, 1);
3757 /* Not kicked out */
3763 * Sell an item to the store (or home)
3765 static void store_sell(void)
3771 s32b price, value, dummy;
3780 char o_name[MAX_NLEN];
3783 /* Prepare a prompt */
3784 if (cur_store_num == STORE_HOME)
3786 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÃÖ¤¤Þ¤¹¤«? ";
3788 q = "Drop which item? ";
3791 else if (cur_store_num == STORE_MUSEUM)
3793 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ó£¤·¤Þ¤¹¤«? ";
3795 q = "Give which item? ";
3800 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÇä¤ê¤Þ¤¹¤«? ";
3802 q = "Sell which item? ";
3806 item_tester_no_ryoute = TRUE;
3807 /* Only allow items the store will buy */
3808 item_tester_hook = store_will_buy;
3811 /* ²æ¤¬²È¤Ç¤ª¤«¤·¤Ê¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¥ª¥ê¥¸¥Ê¥ë¤Î¥Ð¥°¤ò½¤Àµ */
3812 if (cur_store_num == STORE_HOME)
3815 s = "ÃÖ¤±¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3817 s = "You don't have any item to drop.";
3820 else if (cur_store_num == STORE_MUSEUM)
3823 s = "´ó£¤Ç¤¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3825 s = "You don't have any item to give.";
3831 s = "Íߤ·¤¤Êª¤¬¤Ê¤¤¤Ç¤¹¤Í¤¨¡£";
3833 s = "You have nothing that I want.";
3837 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3839 /* Get the item (in the pack) */
3842 o_ptr = &inventory[item];
3845 /* Get the item (on the floor) */
3848 o_ptr = &o_list[0 - item];
3852 /* Hack -- Cannot remove cursed items */
3853 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
3857 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¤Í¡£");
3859 msg_print("Hmmm, it seems to be cursed.");
3868 /* Assume one item */
3871 /* Find out how many the player wants (letter means "all") */
3872 if (o_ptr->number > 1)
3874 /* Get a quantity */
3875 amt = get_quantity(NULL, o_ptr->number);
3877 /* Allow user abort */
3878 if (amt <= 0) return;
3881 /* Get local object */
3884 /* Get a copy of the object */
3885 object_copy(q_ptr, o_ptr);
3887 /* Modify quantity */
3888 q_ptr->number = amt;
3891 * Hack -- If a rod or wand, allocate total maximum
3892 * timeouts or charges to those being sold. -LM-
3894 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3896 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3899 /* Get a full description */
3900 object_desc(o_name, q_ptr, 0);
3902 /* Remove any inscription, feeling for stores */
3903 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3905 q_ptr->inscription = 0;
3906 q_ptr->feeling = FEEL_NONE;
3909 /* Is there room in the store (or the home?) */
3910 if (!store_check_num(q_ptr))
3912 if (cur_store_num == STORE_HOME)
3914 msg_print("²æ¤¬²È¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤Ê¤¤¡£");
3916 msg_print("Your home is full.");
3919 else if (cur_store_num == STORE_MUSEUM)
3921 msg_print("Çîʪ´Û¤Ï¤â¤¦ËþÇÕ¤À¡£");
3923 msg_print("Museum is full.");
3928 msg_print("¤¹¤¤¤Þ¤»¤ó¤¬¡¢Å¹¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤¢¤ê¤Þ¤»¤ó¡£");
3930 msg_print("I have not the room in my store to keep it.");
3938 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3940 /* Describe the transaction */
3942 msg_format("%s(%c)¤òÇäµÑ¤¹¤ë¡£", o_name, index_to_label(item));
3944 msg_format("Selling %s (%c).", o_name, index_to_label(item));
3950 choice = sell_haggle(q_ptr, &price);
3953 if (st_ptr->store_open >= turn) return;
3965 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3966 chg_virtue(V_JUSTICE, -1);
3968 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3969 chg_virtue(V_NATURE, 1);
3972 /* Get some money */
3975 /* Update the display */
3978 /* Get the "apparent" value */
3979 dummy = object_value(q_ptr) * q_ptr->number;
3982 identify_item(o_ptr);
3984 /* Get local object */
3987 /* Get a copy of the object */
3988 object_copy(q_ptr, o_ptr);
3990 /* Modify quantity */
3991 q_ptr->number = amt;
3993 /* Make it look like to be known */
3994 q_ptr->ident |= IDENT_STORE;
3997 * Hack -- If a rod or wand, let the shopkeeper know just
3998 * how many charges he really paid for. -LM-
4000 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4002 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
4005 /* Get the "actual" value */
4006 value = object_value(q_ptr) * q_ptr->number;
4008 /* Get the description all over again */
4009 object_desc(o_name, q_ptr, 0);
4011 /* Describe the result (in message buffer) */
4013 msg_format("%s¤ò $%ld¤ÇÇäµÑ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
4015 msg_format("You sold %s for %ld gold.", o_name, (long)price);
4018 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
4020 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
4022 /* Analyze the prices (and comment verbally) unless a figurine*/
4023 purchase_analyze(price, value, dummy);
4027 * Hack -- Allocate charges between those wands or rods sold
4028 * and retained, unless all are being sold. -LM-
4030 distribute_charges(o_ptr, q_ptr, amt);
4032 /* Reset timeouts of the sold items */
4035 /* Take the item from the player, describe the result */
4036 inven_item_increase(item, -amt);
4037 inven_item_describe(item);
4039 /* If items remain, auto-inscribe before optimizing */
4040 if (o_ptr->number > 0)
4041 autopick_alter_item(item, FALSE);
4043 inven_item_optimize(item);
4048 /* The store gets that (known) item */
4049 item_pos = store_carry(q_ptr);
4051 /* Re-display if item is now in store */
4054 store_top = (item_pos / store_bottom) * store_bottom;
4055 display_inventory();
4060 /* Player is at museum */
4061 else if (cur_store_num == STORE_MUSEUM)
4063 char o2_name[MAX_NLEN];
4064 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
4066 if (-1 == store_check_num(q_ptr))
4069 msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£");
4071 msg_print("The same object as it is already in the Museum.");
4077 msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª¡ª");
4079 msg_print("You cannot take items which is given to the Museum back!!");
4083 if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return;
4085 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
4089 identify_item(q_ptr);
4090 q_ptr->ident |= IDENT_MENTAL;
4092 /* Distribute charges of wands/rods */
4093 distribute_charges(o_ptr, q_ptr, amt);
4097 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
4099 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4104 /* Take it from the players inventory */
4105 inven_item_increase(item, -amt);
4106 inven_item_describe(item);
4107 inven_item_optimize(item);
4112 /* Let the home carry it */
4113 item_pos = home_carry(q_ptr);
4115 /* Update store display */
4118 store_top = (item_pos / store_bottom) * store_bottom;
4119 display_inventory();
4122 /* Player is at home */
4125 /* Distribute charges of wands/rods */
4126 distribute_charges(o_ptr, q_ptr, amt);
4130 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
4132 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4137 /* Take it from the players inventory */
4138 inven_item_increase(item, -amt);
4139 inven_item_describe(item);
4140 inven_item_optimize(item);
4145 /* Let the home carry it */
4146 item_pos = home_carry(q_ptr);
4148 /* Update store display */
4151 store_top = (item_pos / store_bottom) * store_bottom;
4152 display_inventory();
4156 if ((choice == 0) && (item >= INVEN_RARM))
4165 * Examine an item in a store -JDL-
4167 static void store_examine(void)
4172 char o_name[MAX_NLEN];
4177 if (st_ptr->stock_num <= 0)
4179 if (cur_store_num == STORE_HOME)
4181 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4183 msg_print("Your home is empty.");
4186 else if (cur_store_num == STORE_MUSEUM)
4188 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4190 msg_print("Museum is empty.");
4195 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
4197 msg_print("I am currently out of stock.");
4204 /* Find the number of objects on this and following pages */
4205 i = (st_ptr->stock_num - store_top);
4207 /* And then restrict it to the current page */
4208 if (i > store_bottom) i = store_bottom;
4212 sprintf(out_val, "¤É¤ì¤òÄ´¤Ù¤Þ¤¹¤«¡©");
4214 sprintf(out_val, "Which item do you want to examine? ");
4218 /* Get the item number to be examined */
4219 if (!get_stock(&item, out_val, 0, i - 1)) return;
4221 /* Get the actual index */
4222 item = item + store_top;
4224 /* Get the actual item */
4225 o_ptr = &st_ptr->stock[item];
4227 /* Require full knowledge */
4228 if (!(o_ptr->ident & IDENT_MENTAL))
4230 /* This can only happen in the home */
4232 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
4234 msg_print("You have no special knowledge about that item.");
4241 object_desc(o_name, o_ptr, 0);
4245 msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
4247 msg_format("Examining %s...", o_name);
4251 /* Describe it fully */
4252 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
4254 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
4256 msg_print("You see nothing special.");
4265 * Remove an item from museum (Originally from TOband)
4267 static void museum_remove_object(void)
4272 char o_name[MAX_NLEN];
4276 if (st_ptr->stock_num <= 0)
4279 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4281 msg_print("Museum is empty.");
4287 /* Find the number of objects on this and following pages */
4288 i = st_ptr->stock_num - store_top;
4290 /* And then restrict it to the current page */
4291 if (i > store_bottom) i = store_bottom;
4295 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©");
4297 sprintf(out_val, "Which item do you want to order to remove? ");
4300 /* Get the item number to be removed */
4301 if (!get_stock(&item, out_val, 0, i - 1)) return;
4303 /* Get the actual index */
4304 item = item + store_top;
4306 /* Get the actual item */
4307 o_ptr = &st_ptr->stock[item];
4310 object_desc(o_name, o_ptr, 0);
4313 msg_print("Ÿ¼¨¤ò¤ä¤á¤µ¤»¤¿¥¢¥¤¥Æ¥à¤ÏÆóÅ٤ȸ«¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡ª");
4314 if (!get_check(format("ËÜÅö¤Ë%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©", o_name))) return;
4316 msg_print("You cannot see items which is removed from the Museum!");
4317 if (!get_check(format("Really order to remove %s from the Museum? ", o_name))) return;
4322 msg_format("%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤¿¡£", o_name);
4324 msg_format("You ordered to remove %s.", o_name);
4327 /* Remove the items from the home */
4328 store_item_increase(item, -o_ptr->number);
4329 store_item_optimize(item);
4331 (void)combine_and_reorder_home(STORE_MUSEUM);
4333 /* The item is gone */
4336 if (st_ptr->stock_num == 0) store_top = 0;
4338 /* Nothing left on that screen */
4339 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4341 /* Redraw everything */
4342 display_inventory();
4349 * Hack -- set this to leave the store
4351 static bool leave_store = FALSE;
4355 * Process a command in a store
4357 * Note that we must allow the use of a few "special" commands
4358 * in the stores which are not allowed in the dungeon, and we
4359 * must disable some commands which are allowed in the dungeon
4360 * but not in the stores, to prevent chaos.
4362 static void store_process_command(void)
4364 #ifdef ALLOW_REPEAT /* TNB */
4366 /* Handle repeating the last command */
4369 #endif /* ALLOW_REPEAT -- TNB */
4371 if (rogue_like_commands && command_cmd == 'l')
4373 command_cmd = 'x'; /* hack! */
4376 /* Parse the command */
4377 switch (command_cmd)
4387 /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
4390 if (st_ptr->stock_num <= store_bottom) {
4392 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4394 msg_print("Entire inventory is shown.");
4398 store_top -= store_bottom;
4399 if ( store_top < 0 )
4400 store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
4401 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4402 if ( store_top >= store_bottom ) store_top = store_bottom;
4403 display_inventory();
4411 if (st_ptr->stock_num <= store_bottom)
4414 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4416 msg_print("Entire inventory is shown.");
4422 store_top += store_bottom;
4424 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
4425 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
4427 if ((cur_store_num == STORE_HOME) &&
4428 (powerup_home == FALSE) &&
4429 (st_ptr->stock_num >= STORE_INVEN_MAX))
4431 if (store_top >= (STORE_INVEN_MAX - 1))
4438 if (store_top >= st_ptr->stock_num) store_top = 0;
4441 display_inventory();
4454 /* Get (purchase) */
4481 /*** Inventory Commands ***/
4483 /* Wear/wield equipment */
4490 /* Take off equipment */
4497 /* Destroy an item */
4504 /* Equipment list */
4511 /* Inventory list */
4519 /*** Various commands ***/
4521 /* Identify an object */
4528 /* Hack -- toggle windows */
4531 toggle_inven_equip();
4537 /*** Use various objects ***/
4542 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4543 (p_ptr->pclass == CLASS_BERSERKER) ||
4544 (p_ptr->pclass == CLASS_NINJA) ||
4545 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4546 ) do_cmd_mind_browse();
4547 else if (p_ptr->pclass == CLASS_SMITH)
4549 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4550 do_cmd_magic_eater(TRUE, FALSE);
4551 else if (p_ptr->pclass == CLASS_SNIPER)
4552 do_cmd_snipe_browse();
4553 else do_cmd_browse();
4557 /* Inscribe an object */
4564 /* Uninscribe an object */
4567 do_cmd_uninscribe();
4573 /*** Help and Such ***/
4582 /* Identify symbol */
4585 do_cmd_query_symbol();
4589 /* Character description */
4592 p_ptr->town_num = old_town_num;
4593 do_cmd_change_name();
4594 p_ptr->town_num = inner_town_num;
4600 /*** System Commands ***/
4602 /* Hack -- User interface */
4609 /* Single line from a pref file */
4612 p_ptr->town_num = old_town_num;
4614 p_ptr->town_num = inner_town_num;
4618 /* Interact with macros */
4621 p_ptr->town_num = old_town_num;
4623 p_ptr->town_num = inner_town_num;
4627 /* Interact with visuals */
4630 p_ptr->town_num = old_town_num;
4632 p_ptr->town_num = inner_town_num;
4636 /* Interact with colors */
4639 p_ptr->town_num = old_town_num;
4641 p_ptr->town_num = inner_town_num;
4645 /* Interact with options */
4649 (void)combine_and_reorder_home(STORE_HOME);
4655 /*** Misc Commands ***/
4671 /* Repeat level feeling */
4678 /* Show previous message */
4681 do_cmd_message_one();
4685 /* Show previous messages */
4698 /* Check artifacts, uniques etc. */
4705 /* Load "screen dump" */
4708 do_cmd_load_screen();
4712 /* Save "screen dump" */
4715 do_cmd_save_screen();
4719 /* Hack -- Unknown command */
4722 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
4724 museum_remove_object();
4729 msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
4731 msg_print("That command does not work in stores.");
4742 * Enter a store, and interact with it.
4744 * Note that we use the standard "request_command()" function
4745 * to get a command, allowing us to use "command_arg" and all
4746 * command macros and other nifty stuff, but we use the special
4747 * "shopping" argument, to force certain commands to be converted
4748 * into other commands, normally, we convert "p" (pray) and "m"
4749 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4751 void do_cmd_store(void)
4757 bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
4761 Term_get_size(&w, &h);
4763 /* Calculate stocks per 1 page */
4764 xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
4765 store_bottom = MIN_STOCK + xtra_stock;
4767 /* Access the player grid */
4768 c_ptr = &cave[py][px];
4770 /* Verify a store */
4771 if (!cave_have_flag_grid(c_ptr, FF_STORE))
4774 msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
4776 msg_print("You see no store here.");
4782 /* Extract the store code */
4783 which = f_info[c_ptr->feat].subtype;
4785 old_town_num = p_ptr->town_num;
4786 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4787 if (dun_level) p_ptr->town_num = NO_TOWN;
4788 inner_town_num = p_ptr->town_num;
4790 /* Hack -- Check the "locked doors" */
4791 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4795 msg_print("¥É¥¢¤Ë¸°¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£");
4797 msg_print("The doors are locked.");
4800 p_ptr->town_num = old_town_num;
4804 /* Calculate the number of store maintainances since the last visit */
4805 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4807 /* Maintain the store max. 10 times */
4808 if (maintain_num > 10) maintain_num = 10;
4812 /* Maintain the store */
4813 for (i = 0; i < maintain_num; i++)
4814 store_maint(p_ptr->town_num, which);
4816 /* Save the visit */
4817 town[p_ptr->town_num].store[which].last_visit = turn;
4820 /* Forget the lite */
4823 /* Forget the view */
4827 /* Hack -- Character is in "icky" mode */
4828 character_icky = TRUE;
4831 /* No command argument */
4834 /* No repeated command */
4837 /* No automatic command */
4840 /* Do not expand macros */
4841 get_com_no_macros = TRUE;
4843 /* Save the store number */
4844 cur_store_num = which;
4846 /* Hack -- save the store feature */
4847 cur_store_feat = c_ptr->feat;
4849 /* Save the store and owner pointers */
4850 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4851 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4854 /* Start at the beginning */
4857 /* Display the store */
4861 leave_store = FALSE;
4863 /* Interact with player */
4864 while (!leave_store)
4866 /* Hack -- Clear line 1 */
4870 clear_from(20 + xtra_stock);
4873 /* Basic commands */
4875 prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21 + xtra_stock, 0);
4877 prt(" ESC) Exit from Building.", 21 + xtra_stock, 0);
4881 /* Browse if necessary */
4882 if (st_ptr->stock_num > store_bottom)
4885 prt(" -)Á°¥Ú¡¼¥¸", 22 + xtra_stock, 0);
4886 prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23 + xtra_stock, 0);
4888 prt(" -) Previous page", 22 + xtra_stock, 0);
4889 prt(" SPACE) Next page", 23 + xtra_stock, 0);
4895 if (cur_store_num == STORE_HOME)
4898 prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21 + xtra_stock, 27);
4899 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22 + xtra_stock, 27);
4900 prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
4902 prt("g) Get an item.", 21 + xtra_stock, 27);
4903 prt("d) Drop an item.", 22 + xtra_stock, 27);
4904 prt("x) eXamine an item in the home.", 23 + xtra_stock, 27);
4908 /* Museum commands */
4909 else if (cur_store_num == STORE_MUSEUM)
4912 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21 + xtra_stock, 27);
4913 prt("r) ¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤ë", 22 + xtra_stock, 27);
4914 prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
4916 prt("d) Drop an item.", 21 + xtra_stock, 27);
4917 prt("r) order to Remove an item.", 22 + xtra_stock, 27);
4918 prt("x) eXamine an item in the museum.", 23 + xtra_stock, 27);
4922 /* Shop commands XXX XXX XXX */
4926 prt("p) ¾¦ÉʤòÇ㤦", 21 + xtra_stock, 30);
4927 prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22 + xtra_stock, 30);
4928 prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23 + xtra_stock,30);
4930 prt("p) Purchase an item.", 21 + xtra_stock, 30);
4931 prt("s) Sell an item.", 22 + xtra_stock, 30);
4932 prt("x) eXamine an item in the shop", 23 + xtra_stock,30);
4937 /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
4939 prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21 + xtra_stock, 56);
4941 if (rogue_like_commands)
4943 prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
4947 prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
4950 prt("i/e) Inventry/Equipment list", 21 + xtra_stock, 56);
4952 if (rogue_like_commands)
4954 prt("w/T) Wear/Take off equipment", 22 + xtra_stock, 56);
4958 prt("w/t) Wear/Take off equipment", 22 + xtra_stock, 56);
4963 prt("¥³¥Þ¥ó¥É:", 20 + xtra_stock, 0);
4965 prt("You may: ", 20 + xtra_stock, 0);
4970 request_command(TRUE);
4972 /* Process the command */
4973 store_process_command();
4976 * Hack -- To redraw missiles damage and prices in store
4977 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
4979 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
4981 /* Hack -- Character is still in "icky" mode */
4982 character_icky = TRUE;
4990 /* XXX XXX XXX Pack Overflow */
4991 if (inventory[INVEN_PACK].k_idx)
4993 int item = INVEN_PACK;
4995 object_type *o_ptr = &inventory[item];
4997 /* Hack -- Flee from the store */
4998 if (cur_store_num != STORE_HOME)
5002 if (cur_store_num == STORE_MUSEUM)
5003 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆÇîʪ´Û¤«¤é½Ð¤¿...");
5005 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆŹ¤«¤é½Ð¤¿...");
5007 if (cur_store_num == STORE_MUSEUM)
5008 msg_print("Your pack is so full that you flee the Museum...");
5010 msg_print("Your pack is so full that you flee the store...");
5018 /* Hack -- Flee from the home */
5019 else if (!store_check_num(o_ptr))
5023 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤Æ²È¤«¤é½Ð¤¿...");
5025 msg_print("Your pack is so full that you flee your home...");
5033 /* Hack -- Drop items into the home */
5041 char o_name[MAX_NLEN];
5044 /* Give a message */
5046 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
5048 msg_print("Your pack overflows!");
5052 /* Get local object */
5055 /* Grab a copy of the item */
5056 object_copy(q_ptr, o_ptr);
5059 object_desc(o_name, q_ptr, 0);
5063 msg_format("%s¤¬Íî¤Á¤¿¡£(%c)", o_name, index_to_label(item));
5065 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5069 /* Remove it from the players inventory */
5070 inven_item_increase(item, -255);
5071 inven_item_describe(item);
5072 inven_item_optimize(item);
5077 /* Let the home carry it */
5078 item_pos = home_carry(q_ptr);
5080 /* Redraw the home */
5083 store_top = (item_pos / store_bottom) * store_bottom;
5084 display_inventory();
5089 /* Hack -- Redisplay store prices if charisma changes */
5090 /* Hack -- Redraw missiles damage if player changes bow */
5091 if (need_redraw_store_inv) display_inventory();
5093 /* Hack -- get kicked out of the store */
5094 if (st_ptr->store_open >= turn) leave_store = TRUE;
5097 p_ptr->town_num = old_town_num;
5099 /* Free turn XXX XXX XXX */
5103 /* Hack -- Character is no longer in "icky" mode */
5104 character_icky = FALSE;
5107 /* Hack -- Cancel automatic command */
5110 /* Hack -- Cancel "see" mode */
5111 command_see = FALSE;
5113 /* Allow expanding macros */
5114 get_com_no_macros = FALSE;
5116 /* Flush messages XXX XXX XXX */
5120 /* Clear the screen */
5124 /* Update everything */
5125 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
5126 p_ptr->update |= (PU_MONSTERS);
5128 /* Redraw entire screen */
5129 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5132 p_ptr->redraw |= (PR_MAP);
5135 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5141 * Shuffle one of the stores.
5143 void store_shuffle(int which)
5149 if (which == STORE_HOME) return;
5150 if (which == STORE_MUSEUM) return;
5153 /* Save the store index */
5154 cur_store_num = which;
5156 /* Activate that store */
5157 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
5160 /* Pick a new owner */
5163 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5164 if (j == st_ptr->owner) continue;
5165 for (i = 1;i < max_towns; i++)
5167 if (i == p_ptr->town_num) continue;
5168 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
5170 if (i == max_towns) break;
5173 /* Activate the new owner */
5174 ot_ptr = &owners[cur_store_num][st_ptr->owner];
5177 /* Reset the owner data */
5178 st_ptr->insult_cur = 0;
5179 st_ptr->store_open = 0;
5180 st_ptr->good_buy = 0;
5181 st_ptr->bad_buy = 0;
5184 /* Hack -- discount all the items */
5185 for (i = 0; i < st_ptr->stock_num; i++)
5190 o_ptr = &st_ptr->stock[i];
5192 if (!object_is_artifact(o_ptr))
5194 /* Hack -- Sell all non-artifact old items for "half price" */
5195 o_ptr->discount = 50;
5197 /* Hack -- Items are no longer "fixed price" */
5198 o_ptr->ident &= ~(IDENT_FIXED);
5200 /* Mega-Hack -- Note that the item is "on sale" */
5202 o_ptr->inscription = quark_add("Çä½ÐÃæ");
5204 o_ptr->inscription = quark_add("on sale");
5212 * Maintain the inventory at the stores.
5214 void store_maint(int town_num, int store_num)
5218 cur_store_num = store_num;
5221 if (store_num == STORE_HOME) return;
5222 if (store_num == STORE_MUSEUM) return;
5224 /* Activate that store */
5225 st_ptr = &town[town_num].store[store_num];
5227 /* Activate the owner */
5228 ot_ptr = &owners[store_num][st_ptr->owner];
5230 /* Store keeper forgives the player */
5231 st_ptr->insult_cur = 0;
5233 /* Mega-Hack -- prune the black market */
5234 if (store_num == STORE_BLACK)
5236 /* Destroy crappy black market items */
5237 for (j = st_ptr->stock_num - 1; j >= 0; j--)
5239 object_type *o_ptr = &st_ptr->stock[j];
5241 /* Destroy crappy items */
5242 if (black_market_crap(o_ptr))
5244 /* Destroy the item */
5245 store_item_increase(j, 0 - o_ptr->number);
5246 store_item_optimize(j);
5252 /* Choose the number of slots to keep */
5253 j = st_ptr->stock_num;
5255 /* Sell a few items */
5256 j = j - randint1(STORE_TURNOVER);
5258 /* Never keep more than "STORE_MAX_KEEP" slots */
5259 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5261 /* Always "keep" at least "STORE_MIN_KEEP" items */
5262 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5264 /* Hack -- prevent "underflow" */
5267 /* Destroy objects until only "j" slots are left */
5268 while (st_ptr->stock_num > j) store_delete();
5271 /* Choose the number of slots to fill */
5272 j = st_ptr->stock_num;
5274 /* Buy some more items */
5275 j = j + randint1(STORE_TURNOVER);
5277 /* Never keep more than "STORE_MAX_KEEP" slots */
5278 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5280 /* Always "keep" at least "STORE_MIN_KEEP" items */
5281 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5283 /* Hack -- prevent "overflow" */
5284 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
5286 /* Acquire some new items */
5287 while (st_ptr->stock_num < j) store_create();
5292 * Initialize the stores
5294 void store_init(int town_num, int store_num)
5298 cur_store_num = store_num;
5300 /* Activate that store */
5301 st_ptr = &town[town_num].store[store_num];
5309 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5310 for (i = 1;i < max_towns; i++)
5312 if (i == town_num) continue;
5313 if (st_ptr->owner == town[i].store[store_num].owner) break;
5315 if (i == max_towns) break;
5318 /* Activate the new owner */
5319 ot_ptr = &owners[store_num][st_ptr->owner];
5322 /* Initialize the store */
5323 st_ptr->store_open = 0;
5324 st_ptr->insult_cur = 0;
5325 st_ptr->good_buy = 0;
5326 st_ptr->bad_buy = 0;
5328 /* Nothing in stock */
5329 st_ptr->stock_num = 0;
5332 * MEGA-HACK - Last visit to store is
5333 * BEFORE player birth to enable store restocking
5335 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5337 /* Clear any old items */
5338 for (k = 0; k < st_ptr->stock_size; k++)
5340 object_wipe(&st_ptr->stock[k]);
5345 void move_to_black_market(object_type *o_ptr)
5348 if (!p_ptr->town_num) return;
5350 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5352 o_ptr->ident |= IDENT_STORE;
5354 (void)store_carry(o_ptr);
5356 object_wipe(o_ptr); /* Don't leave a bogus object behind... */