4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Store commands */
17 static int cur_store_num = 0;
18 static int store_top = 0;
19 static int store_bottom = 0;
20 static int xtra_stock = 0;
21 static store_type *st_ptr = NULL;
22 static 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?"
307 static void say_comment_1(void)
310 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
311 if ( cur_store_num == STORE_BLACK ) {
312 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
315 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
318 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
322 if (one_in_(RUMOR_CHANCE))
325 msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
327 msg_print("The shopkeeper whispers something into your ear:");
335 * Continue haggling (player is buying)
337 static void say_comment_2(s32b value, int annoyed)
341 /* Prepare a string to insert */
342 sprintf(tmp_val, "%ld", (long)value);
347 /* Formatted message */
348 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
354 /* Formatted message */
356 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
357 if ( cur_store_num == STORE_BLACK ){
358 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
361 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
364 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
372 * Continue haggling (player is selling)
374 static void say_comment_3(s32b value, int annoyed)
378 /* Prepare a string to insert */
379 sprintf(tmp_val, "%ld", (long)value);
384 /* Formatted message */
385 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
391 /* Formatted message */
393 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
394 if ( cur_store_num == STORE_BLACK ){
395 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
398 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
401 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
409 * Kick 'da bum out. -RAK-
411 static void say_comment_4(void)
414 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
415 if ( cur_store_num == STORE_BLACK ){
416 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
417 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
420 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
421 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
424 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
425 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
432 * You are insulting me
434 static void say_comment_5(void)
437 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
438 if ( cur_store_num == STORE_BLACK ){
439 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
442 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
445 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
452 * That makes no sense.
454 static void say_comment_6(void)
456 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
462 * Messages for reacting to purchase prices.
465 #define MAX_COMMENT_7A 4
467 static cptr comment_7a[MAX_COMMENT_7A] =
472 "狼¤¬¤à¤»¤Óµã¤¯À¼¤¬Ê¹¤³¤¨¤ë...¡£",
473 "Ź¼ç¤¬²ù¤·¤²¤Ë¤ï¤á¤¤¤Æ¤¤¤ë¡ª"
477 "You hear someone sobbing...",
478 "The shopkeeper howls in agony!"
483 #define MAX_COMMENT_7B 4
485 static cptr comment_7b[MAX_COMMENT_7B] =
490 "Ź¼ç¤¬º¨¤á¤·¤½¤¦¤Ë¸«¤Æ¤¤¤ë¡£",
495 "The shopkeeper curses at you.",
496 "The shopkeeper glares at you."
501 #define MAX_COMMENT_7C 4
503 static cptr comment_7c[MAX_COMMENT_7C] =
507 "·¯¤¬Å·»È¤Ë¸«¤¨¤ë¤è¡ª",
508 "Ź¼ç¤¬¥¯¥¹¥¯¥¹¾Ð¤Ã¤Æ¤¤¤ë¡£",
509 "Ź¼ç¤¬ÂçÀ¼¤Ç¾Ð¤Ã¤Æ¤¤¤ë¡£"
512 "You've made my day!",
513 "The shopkeeper giggles.",
514 "The shopkeeper laughs loudly."
519 #define MAX_COMMENT_7D 4
521 static cptr comment_7d[MAX_COMMENT_7D] =
525 "¤³¤ó¤Ê¤ª¤¤¤·¤¤»×¤¤¤ò¤·¤¿¤é¡¢¿¿ÌÌÌܤËƯ¤±¤Ê¤¯¤Ê¤ë¤Ê¤¡¡£",
526 "Ź¼ç¤Ï´ò¤·¤¯¤ÆÄ·¤Í²ó¤Ã¤Æ¤¤¤ë¡£",
527 "Ź¼ç¤ÏËþÌ̤˾Фߤò¤¿¤¿¤¨¤Æ¤¤¤ë¡£"
530 "I think I'll retire!",
531 "The shopkeeper jumps for joy.",
532 "The shopkeeper smiles gleefully."
539 * Let a shop-keeper React to a purchase
541 * We paid "price", it was worth "value", and we thought it was worth "guess"
543 static void purchase_analyze(s32b price, s32b value, s32b guess)
545 /* Item was worthless, but we bought it */
546 if ((value <= 0) && (price > value))
549 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
551 chg_virtue(V_HONOUR, -1);
552 chg_virtue(V_JUSTICE, -1);
558 /* Item was cheaper than we thought, and we paid more than necessary */
559 else if ((value < guess) && (price > value))
562 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
564 chg_virtue(V_JUSTICE, -1);
566 chg_virtue(V_HONOUR, -1);
572 /* Item was a good bargain, and we got away with it */
573 else if ((value > guess) && (value < (4 * guess)) && (price < value))
576 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
579 chg_virtue(V_HONOUR, -1);
581 chg_virtue(V_HONOUR, 1);
587 /* Item was a great bargain, and we got away with it */
588 else if ((value > guess) && (price < value))
591 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
594 chg_virtue(V_HONOUR, -1);
596 chg_virtue(V_HONOUR, 1);
598 if (10 * price < value)
599 chg_virtue(V_SACRIFICE, 1);
609 * We store the current "store feat" here so everyone can access it
611 static int cur_store_feat;
615 * Buying and selling adjustments for race combinations.
616 * Entry[owner][player] gives the basic "cost inflation".
618 static byte rgold_adj[MAX_RACES][MAX_RACES] =
620 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
621 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
622 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
623 Angel, Demon, Kutar */
626 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
627 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
628 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
629 100, 120, 110, 105 },
632 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
633 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
634 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
635 110, 115, 110, 110 },
638 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
639 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
640 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
641 110, 110, 105, 110 },
644 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
645 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
646 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
647 115, 120, 105, 115 },
650 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
651 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
652 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
653 115, 110, 110, 115 },
656 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
657 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
658 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
659 115, 110, 115, 115 },
662 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
663 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
664 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
665 115, 110, 115, 115 },
668 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
669 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
670 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
671 110, 110, 115, 110 },
674 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
675 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
676 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
677 100, 110, 110, 100 },
680 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
681 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
682 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
683 110, 110, 105, 110 },
685 /* Human / Barbarian (copied from human) */
686 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
687 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
688 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
689 100, 120, 110, 100 },
691 /* Half-Ogre: theoretical, copied from half-troll */
692 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
693 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
694 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
695 110, 110, 115, 110 },
697 /* Half-Giant: theoretical, copied from half-troll */
698 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
699 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
700 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
701 110, 110, 115, 110 },
703 /* Half-Titan: theoretical, copied from High_Elf */
704 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
705 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
706 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
707 110, 110, 115, 110 },
709 /* Cyclops: theoretical, copied from half-troll */
710 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
711 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
712 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
713 110, 110, 115, 110 },
715 /* Yeek: theoretical, copied from Half-Orc */
716 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
717 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
718 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
719 115, 110, 115, 115 },
721 /* Klackon: theoretical, copied from Gnome */
722 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
723 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
724 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
725 115, 110, 115, 115 },
727 /* Kobold: theoretical, copied from Half-Orc */
728 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
729 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
730 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
731 115, 110, 115, 115 },
733 /* Nibelung: theoretical, copied from Dwarf */
734 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
735 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
736 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
737 115, 135, 115, 115 },
740 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
741 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
742 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
743 110, 101, 115, 110 },
745 /* Draconian: theoretical, copied from High_Elf */
746 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
747 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
748 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
749 110, 110, 115, 110 },
751 /* Mind Flayer: theoretical, copied from High_Elf */
752 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
753 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
754 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
755 110, 110, 115, 110 },
757 /* Imp: theoretical, copied from High_Elf */
758 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
759 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
760 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
761 110, 110, 115, 110 },
763 /* Golem: theoretical, copied from High_Elf */
764 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
765 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
766 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
767 110, 110, 115, 110 },
769 /* Skeleton: theoretical, copied from half-orc */
770 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
771 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
772 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
773 115, 110, 125, 115 },
775 /* Zombie: Theoretical, copied from half-orc */
776 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
777 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
778 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
779 115, 110, 125, 115 },
781 /* Vampire: Theoretical, copied from half-orc */
782 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
783 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
784 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
785 115, 110, 125, 115 },
787 /* Spectre: Theoretical, copied from half-orc */
788 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
789 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
790 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
791 115, 110, 125, 115 },
793 /* Sprite: Theoretical, copied from half-orc */
794 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
795 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
796 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
797 115, 110, 105, 115 },
799 /* Beastman: Theoretical, copied from half-orc */
800 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
801 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
802 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
803 115, 110, 115, 115 },
806 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
807 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
808 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
809 110, 110, 105, 110 },
812 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
813 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
814 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
818 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
819 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
820 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
821 140, 140, 140, 140 },
824 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
825 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
826 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
827 100, 120, 110, 100 },
830 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
831 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
832 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
833 110, 101, 115, 110 },
836 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
837 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
838 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
839 110, 115, 100, 110 },
842 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
843 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
844 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
845 100, 120, 110, 100 },
852 * Determine the price of an item (qty one) in a store.
854 * This function takes into account the player's charisma, and the
855 * shop-keepers friendliness, and the shop-keeper's base greed, but
856 * never lets a shop-keeper lose money in a transaction.
858 * The "greed" value should exceed 100 when the player is "buying" the
859 * item, and should be less than 100 when the player is "selling" it.
861 * Hack -- the black market always charges twice as much as it should.
863 * Charisma adjustment runs from 80 to 130
864 * Racial adjustment runs from 95 to 130
866 * Since greed/charisma/racial adjustments are centered at 100, we need
867 * to adjust (by 200) to extract a usable multiplier. Note that the
868 * "greed" value is always something (?).
870 static s32b price_item(object_type *o_ptr, int greed, bool flip)
877 /* Get the value of one of the items */
878 price = object_value(o_ptr);
880 /* Worthless items */
881 if (price <= 0) return (0L);
884 /* Compute the racial factor */
885 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
887 /* Add in the charisma factor */
888 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
894 /* Adjust for greed */
895 adjust = 100 + (300 - (greed + factor));
897 /* Never get "silly" */
898 if (adjust > 100) adjust = 100;
900 /* Mega-Hack -- Black market sucks */
901 if (cur_store_num == STORE_BLACK)
904 /* Compute the final price (with rounding) */
905 /* Hack -- prevent underflow */
906 price = (price * adjust + 50L) / 100L;
909 /* Shop is selling */
912 /* Adjust for greed */
913 adjust = 100 + ((greed + factor) - 300);
915 /* Never get "silly" */
916 if (adjust < 100) adjust = 100;
918 /* Mega-Hack -- Black market sucks */
919 if (cur_store_num == STORE_BLACK)
922 /* Compute the final price (with rounding) */
923 /* Hack -- prevent overflow */
924 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
927 /* Note -- Never become "free" */
928 if (price <= 0L) return (1L);
930 /* Return the price */
936 * Certain "cheap" objects should be created in "piles"
937 * Some objects can be sold at a "discount" (in small piles)
939 static void mass_produce(object_type *o_ptr)
944 s32b cost = object_value(o_ptr);
947 /* Analyze the type */
950 /* Food, Flasks, and Lites */
955 if (cost <= 5L) size += damroll(3, 5);
956 if (cost <= 20L) size += damroll(3, 5);
957 if (cost <= 50L) size += damroll(2, 2);
964 if (cost <= 60L) size += damroll(3, 5);
965 if (cost <= 240L) size += damroll(1, 5);
966 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
967 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
972 case TV_SORCERY_BOOK:
980 case TV_CRUSADE_BOOK:
982 case TV_HISSATSU_BOOK:
985 if (cost <= 50L) size += damroll(2, 3);
986 if (cost <= 500L) size += damroll(1, 3);
1004 if (object_is_artifact(o_ptr)) break;
1005 if (object_is_ego(o_ptr)) break;
1006 if (cost <= 10L) size += damroll(3, 5);
1007 if (cost <= 100L) size += damroll(3, 5);
1016 if (cost <= 5L) size += damroll(5, 5);
1017 if (cost <= 50L) size += damroll(5, 5);
1018 if (cost <= 500L) size += damroll(5, 5);
1024 if (cost <= 100L) size += damroll(2, 2);
1025 if (cost <= 1000L) size += damroll(2, 2);
1038 * Because many rods (and a few wands and staffs) are useful mainly
1039 * in quantity, the Black Market will occasionally have a bunch of
1046 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1048 if (cost < 1601L) size += damroll(1, 5);
1049 else if (cost < 3201L) size += damroll(1, 3);
1056 /* Pick a discount */
1061 else if (one_in_(25))
1065 else if (one_in_(150))
1069 else if (one_in_(300))
1073 else if (one_in_(500))
1079 if (o_ptr->art_name)
1081 if (cheat_peek && discount)
1084 msg_print("¥é¥ó¥À¥à¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÏÃÍ°ú¤¤Ê¤·¡£");
1086 msg_print("No discount on random artifacts.");
1093 /* Save the discount */
1094 o_ptr->discount = discount;
1096 /* Save the total pile size */
1097 o_ptr->number = size - (size * discount / 100);
1099 /* Ensure that mass-produced rods and wands get the correct pvals. */
1100 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1102 o_ptr->pval *= o_ptr->number;
1109 * Determine if a store item can "absorb" another item
1111 * See "object_similar()" for the same function for the "player"
1113 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1117 /* Hack -- Identical items cannot be stacked */
1118 if (o_ptr == j_ptr) return (0);
1120 /* Different objects cannot be stacked */
1121 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1123 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1124 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1126 /* Require many identical values */
1127 if (o_ptr->to_h != j_ptr->to_h) return (0);
1128 if (o_ptr->to_d != j_ptr->to_d) return (0);
1129 if (o_ptr->to_a != j_ptr->to_a) return (0);
1131 /* Require identical "ego-item" names */
1132 if (o_ptr->name2 != j_ptr->name2) return (0);
1134 /* Artifacts don't stack! */
1135 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
1137 /* Hack -- Identical art_flags! */
1138 for (i = 0; i < TR_FLAG_SIZE; i++)
1139 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1141 /* Hack -- Never stack "powerful" items */
1142 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1144 /* Hack -- Never stack recharging items */
1145 if (o_ptr->timeout || j_ptr->timeout) return (0);
1147 /* Require many identical values */
1148 if (o_ptr->ac != j_ptr->ac) return (0);
1149 if (o_ptr->dd != j_ptr->dd) return (0);
1150 if (o_ptr->ds != j_ptr->ds) return (0);
1152 /* Hack -- Never stack chests */
1153 if (o_ptr->tval == TV_CHEST) return (0);
1154 if (o_ptr->tval == TV_STATUE) return (0);
1155 if (o_ptr->tval == TV_CAPTURE) return (0);
1157 /* Require matching discounts */
1158 if (o_ptr->discount != j_ptr->discount) return (0);
1160 /* They match, so they must be similar */
1166 * Allow a store item to absorb another item
1168 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1170 int max_num = (o_ptr->tval == TV_ROD) ?
1171 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1172 int total = o_ptr->number + j_ptr->number;
1173 int diff = (total > max_num) ? total - max_num : 0;
1175 /* Combine quantity, lose excess items */
1176 o_ptr->number = (total > max_num) ? max_num : total;
1178 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1179 if (o_ptr->tval == TV_ROD)
1181 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1184 /* Hack -- if wands are stacking, combine the charges. -LM- */
1185 if (o_ptr->tval == TV_WAND)
1187 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1193 * Check to see if the shop will be carrying too many objects -RAK-
1194 * Note that the shop, just like a player, will not accept things
1195 * it cannot hold. Before, one could "nuke" potions this way.
1197 * Return value is now int:
1199 * -1 : Can be combined to existing slot.
1200 * 1 : Cannot be combined but there are empty spaces.
1202 static int store_check_num(object_type *o_ptr)
1207 /* The "home" acts like the player */
1208 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1210 bool old_stack_force_notes = stack_force_notes;
1211 bool old_stack_force_costs = stack_force_costs;
1213 if (cur_store_num != STORE_HOME)
1215 stack_force_notes = FALSE;
1216 stack_force_costs = FALSE;
1219 /* Check all the items */
1220 for (i = 0; i < st_ptr->stock_num; i++)
1222 /* Get the existing item */
1223 j_ptr = &st_ptr->stock[i];
1225 /* Can the new object be combined with the old one? */
1226 if (object_similar(j_ptr, o_ptr))
1228 if (cur_store_num != STORE_HOME)
1230 stack_force_notes = old_stack_force_notes;
1231 stack_force_costs = old_stack_force_costs;
1238 if (cur_store_num != STORE_HOME)
1240 stack_force_notes = old_stack_force_notes;
1241 stack_force_costs = old_stack_force_costs;
1245 /* Normal stores do special stuff */
1248 /* Check all the items */
1249 for (i = 0; i < st_ptr->stock_num; i++)
1251 /* Get the existing item */
1252 j_ptr = &st_ptr->stock[i];
1254 /* Can the new object be combined with the old one? */
1255 if (store_object_similar(j_ptr, o_ptr)) return -1;
1259 /* Free space is always usable */
1261 * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1262 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1264 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1265 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1270 if (st_ptr->stock_num < st_ptr->stock_size) {
1275 /* But there was no room at the inn... */
1280 static bool is_blessed(object_type *o_ptr)
1282 u32b flgs[TR_FLAG_SIZE];
1283 object_flags(o_ptr, flgs);
1284 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1285 else return (FALSE);
1291 * Determine if the current store will purchase the given item
1293 * Note that a shop-keeper must refuse to buy "worthless" items
1295 static bool store_will_buy(object_type *o_ptr)
1297 /* Hack -- The Home is simple */
1298 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1300 /* Switch on the store */
1301 switch (cur_store_num)
1306 /* Analyze the type */
1307 switch (o_ptr->tval)
1310 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1322 case TV_BOTTLE: /* 'Green', recycling Angband */
1337 /* Analyze the type */
1338 switch (o_ptr->tval)
1359 /* Analyze the type */
1360 switch (o_ptr->tval)
1369 case TV_HISSATSU_BOOK:
1373 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1385 /* Analyze the type */
1386 switch (o_ptr->tval)
1389 case TV_CRUSADE_BOOK:
1399 monster_race *r_ptr = &r_info[o_ptr->pval];
1402 if (!(r_ptr->flags3 & RF3_EVIL))
1405 if (r_ptr->flags3 & RF3_GOOD) break;
1407 /* Accept animals */
1408 if (r_ptr->flags3 & RF3_ANIMAL) break;
1411 if (my_strchr("?!", r_ptr->d_char)) break;
1417 if (is_blessed(o_ptr)) break;
1426 case STORE_ALCHEMIST:
1428 /* Analyze the type */
1429 switch (o_ptr->tval)
1443 /* Analyze the type */
1444 switch (o_ptr->tval)
1446 case TV_SORCERY_BOOK:
1447 case TV_NATURE_BOOK:
1451 case TV_ARCANE_BOOK:
1453 case TV_DAEMON_BOOK:
1467 if(o_ptr->sval == SV_WIZSTAFF) break;
1468 else return (FALSE);
1475 /* Bookstore Shop */
1478 /* Analyze the type */
1479 switch (o_ptr->tval)
1481 case TV_SORCERY_BOOK:
1482 case TV_NATURE_BOOK:
1487 case TV_ARCANE_BOOK:
1489 case TV_DAEMON_BOOK:
1490 case TV_CRUSADE_BOOK:
1501 /* XXX XXX XXX Ignore "worthless" items */
1502 if (object_value(o_ptr) <= 0) return (FALSE);
1510 * Combine and reorder items in the home
1512 bool combine_and_reorder_home(int store_num)
1516 object_type forge, *o_ptr, *j_ptr;
1517 bool flag = FALSE, combined;
1518 store_type *old_st_ptr = st_ptr;
1519 bool old_stack_force_notes = stack_force_notes;
1520 bool old_stack_force_costs = stack_force_costs;
1522 st_ptr = &town[1].store[store_num];
1523 if (store_num != STORE_HOME)
1525 stack_force_notes = FALSE;
1526 stack_force_costs = FALSE;
1533 /* Combine the items in the home (backwards) */
1534 for (i = st_ptr->stock_num - 1; i > 0; i--)
1537 o_ptr = &st_ptr->stock[i];
1539 /* Skip empty items */
1540 if (!o_ptr->k_idx) continue;
1542 /* Scan the items above that item */
1543 for (j = 0; j < i; j++)
1548 j_ptr = &st_ptr->stock[j];
1550 /* Skip empty items */
1551 if (!j_ptr->k_idx) continue;
1554 * Get maximum number of the stack if these
1555 * are similar, get zero otherwise.
1557 max_num = object_similar_part(j_ptr, o_ptr);
1559 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
1560 if (max_num && j_ptr->number < max_num)
1562 if (o_ptr->number + j_ptr->number <= max_num)
1564 /* Add together the item counts */
1565 object_absorb(j_ptr, o_ptr);
1567 /* One object is gone */
1568 st_ptr->stock_num--;
1570 /* Slide everything down */
1571 for (k = i; k < st_ptr->stock_num; k++)
1573 /* Structure copy */
1574 st_ptr->stock[k] = st_ptr->stock[k + 1];
1577 /* Erase the "final" slot */
1578 object_wipe(&st_ptr->stock[k]);
1582 int old_num = o_ptr->number;
1583 int remain = j_ptr->number + o_ptr->number - max_num;
1585 /* Add together the item counts */
1586 object_absorb(j_ptr, o_ptr);
1588 o_ptr->number = remain;
1590 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1591 if (o_ptr->tval == TV_ROD)
1593 o_ptr->pval = o_ptr->pval * remain / old_num;
1594 o_ptr->timeout = o_ptr->timeout * remain / old_num;
1597 /* Hack -- if wands are stacking, combine the charges. -LM- */
1598 else if (o_ptr->tval == TV_WAND)
1600 o_ptr->pval = o_ptr->pval * remain / old_num;
1617 /* Re-order the items in the home (forwards) */
1618 for (i = 0; i < st_ptr->stock_num; i++)
1621 o_ptr = &st_ptr->stock[i];
1623 /* Skip empty slots */
1624 if (!o_ptr->k_idx) continue;
1626 /* Get the "value" of the item */
1627 o_value = object_value(o_ptr);
1629 /* Scan every occupied slot */
1630 for (j = 0; j < st_ptr->stock_num; j++)
1632 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
1635 /* Never move down */
1636 if (j >= i) continue;
1641 /* Get local object */
1644 /* Save a copy of the moving item */
1645 object_copy(j_ptr, &st_ptr->stock[i]);
1647 /* Slide the objects */
1648 for (k = i; k > j; k--)
1650 /* Slide the item */
1651 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
1654 /* Insert the moving item */
1655 object_copy(&st_ptr->stock[j], j_ptr);
1658 st_ptr = old_st_ptr;
1659 if (store_num != STORE_HOME)
1661 stack_force_notes = old_stack_force_notes;
1662 stack_force_costs = old_stack_force_costs;
1670 * Add the item "o_ptr" to the inventory of the "Home"
1672 * In all cases, return the slot (or -1) where the object was placed
1674 * Note that this is a hacked up version of "inven_carry()".
1676 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1677 * known, the player may have to pick stuff up and drop it again.
1679 static int home_carry(object_type *o_ptr)
1685 bool old_stack_force_notes = stack_force_notes;
1686 bool old_stack_force_costs = stack_force_costs;
1688 if (cur_store_num != STORE_HOME)
1690 stack_force_notes = FALSE;
1691 stack_force_costs = FALSE;
1694 /* Check each existing item (try to combine) */
1695 for (slot = 0; slot < st_ptr->stock_num; slot++)
1697 /* Get the existing item */
1698 j_ptr = &st_ptr->stock[slot];
1700 /* The home acts just like the player */
1701 if (object_similar(j_ptr, o_ptr))
1703 /* Save the new number of items */
1704 object_absorb(j_ptr, o_ptr);
1706 if (cur_store_num != STORE_HOME)
1708 stack_force_notes = old_stack_force_notes;
1709 stack_force_costs = old_stack_force_costs;
1717 if (cur_store_num != STORE_HOME)
1719 stack_force_notes = old_stack_force_notes;
1720 stack_force_costs = old_stack_force_costs;
1725 * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1726 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1729 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
1730 if (st_ptr->stock_num >= st_ptr->stock_size) {
1735 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1741 /* Determine the "value" of the item */
1742 value = object_value(o_ptr);
1744 /* Check existing slots to see if we must "slide" */
1745 for (slot = 0; slot < st_ptr->stock_num; slot++)
1747 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
1750 /* Slide the others up */
1751 for (i = st_ptr->stock_num; i > slot; i--)
1753 st_ptr->stock[i] = st_ptr->stock[i-1];
1756 /* More stuff now */
1757 st_ptr->stock_num++;
1759 /* Insert the new item */
1760 st_ptr->stock[slot] = *o_ptr;
1762 chg_virtue(V_SACRIFICE, -1);
1764 (void)combine_and_reorder_home(cur_store_num);
1766 /* Return the location */
1772 * Add the item "o_ptr" to a real stores inventory.
1774 * If the item is "worthless", it is thrown away (except in the home).
1776 * If the item cannot be combined with an object already in the inventory,
1777 * make a new slot for it, and calculate its "per item" price. Note that
1778 * this price will be negative, since the price will not be "fixed" yet.
1779 * Adding an item to a "fixed" price stack will not change the fixed price.
1781 * In all cases, return the slot (or -1) where the object was placed
1783 static int store_carry(object_type *o_ptr)
1786 s32b value, j_value;
1790 /* Evaluate the object */
1791 value = object_value(o_ptr);
1793 /* Cursed/Worthless items "disappear" when sold */
1794 if (value <= 0) return (-1);
1796 /* All store items are fully *identified* */
1797 o_ptr->ident |= IDENT_MENTAL;
1799 /* Erase the inscription */
1800 o_ptr->inscription = 0;
1802 /* Erase the "feeling" */
1803 o_ptr->feeling = FEEL_NONE;
1805 /* Check each existing item (try to combine) */
1806 for (slot = 0; slot < st_ptr->stock_num; slot++)
1808 /* Get the existing item */
1809 j_ptr = &st_ptr->stock[slot];
1811 /* Can the existing items be incremented? */
1812 if (store_object_similar(j_ptr, o_ptr))
1814 /* Hack -- extra items disappear */
1815 store_object_absorb(j_ptr, o_ptr);
1823 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1826 /* Check existing slots to see if we must "slide" */
1827 for (slot = 0; slot < st_ptr->stock_num; slot++)
1830 j_ptr = &st_ptr->stock[slot];
1832 /* Objects sort by decreasing type */
1833 if (o_ptr->tval > j_ptr->tval) break;
1834 if (o_ptr->tval < j_ptr->tval) continue;
1836 /* Objects sort by increasing sval */
1837 if (o_ptr->sval < j_ptr->sval) break;
1838 if (o_ptr->sval > j_ptr->sval) continue;
1841 * Hack: otherwise identical rods sort by
1842 * increasing recharge time --dsb
1844 if (o_ptr->tval == TV_ROD)
1846 if (o_ptr->pval < j_ptr->pval) break;
1847 if (o_ptr->pval > j_ptr->pval) continue;
1850 /* Evaluate that slot */
1851 j_value = object_value(j_ptr);
1853 /* Objects sort by decreasing value */
1854 if (value > j_value) break;
1855 if (value < j_value) continue;
1858 /* Slide the others up */
1859 for (i = st_ptr->stock_num; i > slot; i--)
1861 st_ptr->stock[i] = st_ptr->stock[i-1];
1864 /* More stuff now */
1865 st_ptr->stock_num++;
1867 /* Insert the new item */
1868 st_ptr->stock[slot] = *o_ptr;
1870 /* Return the location */
1876 * Increase, by a given amount, the number of a certain item
1877 * in a certain store. This can result in zero items.
1879 static void store_item_increase(int item, int num)
1885 o_ptr = &st_ptr->stock[item];
1887 /* Verify the number */
1888 cnt = o_ptr->number + num;
1889 if (cnt > 255) cnt = 255;
1890 else if (cnt < 0) cnt = 0;
1891 num = cnt - o_ptr->number;
1893 /* Save the new number */
1894 o_ptr->number += num;
1899 * Remove a slot if it is empty
1901 static void store_item_optimize(int item)
1907 o_ptr = &st_ptr->stock[item];
1910 if (!o_ptr->k_idx) return;
1912 /* Must have no items */
1913 if (o_ptr->number) return;
1916 st_ptr->stock_num--;
1918 /* Slide everyone */
1919 for (j = item; j < st_ptr->stock_num; j++)
1921 st_ptr->stock[j] = st_ptr->stock[j + 1];
1924 /* Nuke the final slot */
1925 object_wipe(&st_ptr->stock[j]);
1930 * This function will keep 'crap' out of the black market.
1931 * Crap is defined as any item that is "available" elsewhere
1932 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1934 static bool black_market_crap(object_type *o_ptr)
1938 /* Ego items are never crap */
1939 if (object_is_ego(o_ptr)) return (FALSE);
1941 /* Good items are never crap */
1942 if (o_ptr->to_a > 0) return (FALSE);
1943 if (o_ptr->to_h > 0) return (FALSE);
1944 if (o_ptr->to_d > 0) return (FALSE);
1946 /* Check all stores */
1947 for (i = 0; i < MAX_STORES; i++)
1949 if (i == STORE_HOME) continue;
1950 if (i == STORE_MUSEUM) continue;
1952 /* Check every item in the store */
1953 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1955 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1957 /* Duplicate item "type", assume crappy */
1958 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
1968 * Attempt to delete (some of) a random item from the store
1969 * Hack -- we attempt to "maintain" piles of items when possible.
1971 static void store_delete(void)
1975 /* Pick a random slot */
1976 what = randint0(st_ptr->stock_num);
1978 /* Determine how many items are here */
1979 num = st_ptr->stock[what].number;
1981 /* Hack -- sometimes, only destroy half the items */
1982 if (randint0(100) < 50) num = (num + 1) / 2;
1984 /* Hack -- sometimes, only destroy a single item */
1985 if (randint0(100) < 50) num = 1;
1987 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
1988 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
1990 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
1993 /* Actually destroy (part of) the item */
1994 store_item_increase(what, -num);
1995 store_item_optimize(what);
2000 * Creates a random item and gives it to a store
2001 * This algorithm needs to be rethought. A lot.
2002 * Currently, "normal" stores use a pre-built array.
2004 * Note -- the "level" given to "obj_get_num()" is a "favored"
2005 * level, that is, there is a much higher chance of getting
2006 * items with a level approaching that of the given level...
2008 * Should we check for "permission" to have the given item?
2010 static void store_create(void)
2012 int i, tries, level;
2018 /* Paranoia -- no room left */
2019 if (st_ptr->stock_num >= st_ptr->stock_size) return;
2022 /* Hack -- consider up to four items */
2023 for (tries = 0; tries < 4; tries++)
2026 if (cur_store_num == STORE_BLACK)
2028 /* Pick a level for object/magic */
2029 level = 25 + randint0(25);
2031 /* Random item (usually of given level) */
2032 i = get_obj_num(level);
2034 /* Handle failure */
2041 /* Hack -- Pick an item to sell */
2042 i = st_ptr->table[randint0(st_ptr->table_num)];
2044 /* Hack -- fake level for apply_magic() */
2045 level = rand_range(1, STORE_OBJ_LEVEL);
2049 /* Get local object */
2052 /* Create a new object of the chosen kind */
2053 object_prep(q_ptr, i);
2055 /* Apply some "low-level" magic (no artifacts) */
2056 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
2058 /* Require valid object */
2059 if (!store_will_buy(q_ptr)) continue;
2061 /* Hack -- Charge lite's */
2062 if (q_ptr->tval == TV_LITE)
2064 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
2065 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
2069 /* The item is "known" */
2070 object_known(q_ptr);
2072 /* Mark it storebought */
2073 q_ptr->ident |= IDENT_STORE;
2075 /* Mega-Hack -- no chests in stores */
2076 if (q_ptr->tval == TV_CHEST) continue;
2078 /* Prune the black market */
2079 if (cur_store_num == STORE_BLACK)
2081 /* Hack -- No "crappy" items */
2082 if (black_market_crap(q_ptr)) continue;
2084 /* Hack -- No "cheap" items */
2085 if (object_value(q_ptr) < 10) continue;
2087 /* No "worthless" items */
2088 /* if (object_value(q_ptr) <= 0) continue; */
2091 /* Prune normal stores */
2094 /* No "worthless" items */
2095 if (object_value(q_ptr) <= 0) continue;
2099 /* Mass produce and/or Apply discount */
2100 mass_produce(q_ptr);
2102 /* Attempt to carry the (known) item */
2103 (void)store_carry(q_ptr);
2105 /* Definitely done */
2113 * Eliminate need to bargain if player has haggled well in the past
2115 static bool noneedtobargain(s32b minprice)
2117 s32b good = st_ptr->good_buy;
2118 s32b bad = st_ptr->bad_buy;
2120 /* Cheap items are "boring" */
2121 if (minprice < 10L) return (TRUE);
2123 /* Perfect haggling */
2124 if (good == MAX_SHORT) return (TRUE);
2126 /* Reward good haggles, punish bad haggles, notice price */
2127 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
2129 /* Return the flag */
2135 * Update the bargain info
2137 static void updatebargain(s32b price, s32b minprice, int num)
2139 /* Hack -- auto-haggle */
2140 if (!manual_haggle) return;
2142 /* Cheap items are "boring" */
2143 if ((minprice/num) < 10L) return;
2145 /* Count the successful haggles */
2146 if (price == minprice)
2148 /* Just count the good haggles */
2149 if (st_ptr->good_buy < MAX_SHORT)
2155 /* Count the failed haggles */
2158 /* Just count the bad haggles */
2159 if (st_ptr->bad_buy < MAX_SHORT)
2169 * Re-displays a single store entry
2171 static void display_entry(int pos)
2177 char o_name[MAX_NLEN];
2184 o_ptr = &st_ptr->stock[pos];
2186 /* Get the "offset" */
2187 i = (pos % store_bottom);
2189 /* Label it, clear the line --(-- */
2190 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
2191 prt(out_val, i+6, 0);
2194 if (show_item_graph)
2196 byte a = object_attr(o_ptr);
2197 char c = object_char(o_ptr);
2204 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
2205 if (use_bigtile) cur_col++;
2210 /* Describe an item in the home */
2211 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2215 /* Leave room for weights, if necessary -DRS- */
2216 if (show_weights) maxwid -= 10;
2218 /* Describe the object */
2219 object_desc(o_name, o_ptr, 0);
2220 o_name[maxwid] = '\0';
2221 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2226 /* Only show the weight of an individual item */
2227 int wgt = o_ptr->weight;
2229 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2230 put_str(out_val, i+6, 67);
2232 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2233 put_str(out_val, i+6, 68);
2239 /* Describe an item (fully) in a store */
2242 /* Must leave room for the "price" */
2245 /* Leave room for weights, if necessary -DRS- */
2246 if (show_weights) maxwid -= 7;
2248 /* Describe the object (fully) */
2249 object_desc(o_name, o_ptr, 0);
2250 o_name[maxwid] = '\0';
2251 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2256 /* Only show the weight of an individual item */
2257 int wgt = o_ptr->weight;
2259 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2260 put_str(out_val, i+6, 60);
2262 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2263 put_str(out_val, i+6, 61);
2268 /* Display a "fixed" cost */
2269 if (o_ptr->ident & (IDENT_FIXED))
2271 /* Extract the "minimum" price */
2272 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2274 /* Actually draw the price (not fixed) */
2276 (void)sprintf(out_val, "%9ld¸Ç", (long)x);
2278 (void)sprintf(out_val, "%9ld F", (long)x);
2281 put_str(out_val, i+6, 68);
2284 /* Display a "taxed" cost */
2285 else if (!manual_haggle)
2287 /* Extract the "minimum" price */
2288 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2290 /* Hack -- Apply Sales Tax if needed */
2291 if (!noneedtobargain(x)) x += x / 10;
2293 /* Actually draw the price (with tax) */
2294 (void)sprintf(out_val, "%9ld ", (long)x);
2295 put_str(out_val, i+6, 68);
2298 /* Display a "haggle" cost */
2301 /* Extrect the "maximum" price */
2302 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2304 /* Actually draw the price (not fixed) */
2305 (void)sprintf(out_val, "%9ld ", (long)x);
2306 put_str(out_val, i+6, 68);
2313 * Displays a store's inventory -RAK-
2314 * All prices are listed as "per individual object". -BEN-
2316 static void display_inventory(void)
2320 /* Display the next 12 items */
2321 for (k = 0; k < store_bottom; k++)
2323 /* Do not display "dead" items */
2324 if (store_top + k >= st_ptr->stock_num) break;
2326 /* Display that line */
2327 display_entry(store_top + k);
2330 /* Erase the extra lines and the "more" prompt */
2331 for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
2333 /* Assume "no current page" */
2335 put_str(" ", 5, 20);
2337 put_str(" ", 5, 20);
2341 /* Visual reminder of "more items" */
2342 if (st_ptr->stock_num > store_bottom)
2344 /* Show "more" reminder (after the last item) */
2346 prt("-³¤¯-", k + 6, 3);
2348 prt("-more-", k + 6, 3);
2352 /* Indicate the "current page" */
2353 /* Trailing spaces are to display (Page xx) and (Page x) */
2355 put_str(format("(%d¥Ú¡¼¥¸) ", store_top/store_bottom + 1), 5, 20);
2357 put_str(format("(Page %d) ", store_top/store_bottom + 1), 5, 20);
2362 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
2364 k = st_ptr->stock_size;
2366 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
2368 put_str(format("¥¢¥¤¥Æ¥à¿ô: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
2370 put_str(format("Objects: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
2377 * Displays players gold -RAK-
2379 static void store_prt_gold(void)
2384 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19 + xtra_stock, 53);
2386 prt("Gold Remaining: ", 19 + xtra_stock, 53);
2390 sprintf(out_val, "%9ld", (long)p_ptr->au);
2391 prt(out_val, 19 + xtra_stock, 68);
2396 * Displays store (after clearing screen) -RAK-
2398 static void display_store(void)
2406 /* The "Home" is special */
2407 if (cur_store_num == STORE_HOME)
2409 /* Put the owner name */
2411 put_str("²æ¤¬²È", 3, 31);
2413 put_str("Your Home", 3, 30);
2417 /* Label the item descriptions */
2419 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2421 put_str("Item Description", 5, 3);
2425 /* If showing weights, show label */
2429 put_str("½Å¤µ", 5, 72);
2431 put_str("Weight", 5, 70);
2437 /* The "Home" is special */
2438 else if (cur_store_num == STORE_MUSEUM)
2440 /* Put the owner name */
2442 put_str("Çîʪ´Û", 3, 31);
2444 put_str("Museum", 3, 30);
2448 /* Label the item descriptions */
2450 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2452 put_str("Item Description", 5, 3);
2456 /* If showing weights, show label */
2460 put_str("½Å¤µ", 5, 72);
2462 put_str("Weight", 5, 70);
2471 cptr store_name = (f_name + f_info[cur_store_feat].name);
2472 cptr owner_name = (ot_ptr->owner_name);
2473 cptr race_name = race_info[ot_ptr->owner_race].title;
2475 /* Put the owner name and race */
2476 sprintf(buf, "%s (%s)", owner_name, race_name);
2477 put_str(buf, 3, 10);
2479 /* Show the max price in the store (above prices) */
2480 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2483 /* Label the item descriptions */
2485 put_str("¾¦ÉʤΰìÍ÷", 5, 7);
2487 put_str("Item Description", 5, 3);
2491 /* If showing weights, show label */
2495 put_str("½Å¤µ", 5, 62);
2497 put_str("Weight", 5, 60);
2502 /* Label the asking price (in stores) */
2504 put_str("²Á³Ê", 5, 73);
2506 put_str("Price", 5, 72);
2511 /* Display the current gold */
2514 /* Draw in the inventory */
2515 display_inventory();
2521 * Get the ID of a store item and return its value -RAK-
2523 static int get_stock(int *com_val, cptr pmt, int i, int j)
2529 #ifdef ALLOW_REPEAT /* TNB */
2531 /* Get the item index */
2532 if (repeat_pull(com_val))
2534 /* Verify the item */
2535 if ((*com_val >= i) && (*com_val <= j))
2542 #endif /* ALLOW_REPEAT -- TNB */
2544 /* Paranoia XXX XXX XXX */
2548 /* Assume failure */
2551 /* Build the prompt */
2553 hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
2555 (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
2556 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
2559 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2564 /* Ask until done */
2570 if (!get_com(out_val, &command, FALSE)) break;
2573 if (islower(command))
2575 else if (isupper(command))
2576 k = A2I(tolower(command)) + 26;
2580 /* Legal responses */
2581 if ((k >= i) && (k <= j))
2591 /* Clear the prompt */
2595 if (command == ESCAPE) return (FALSE);
2597 #ifdef ALLOW_REPEAT /* TNB */
2599 repeat_push(*com_val);
2601 #endif /* ALLOW_REPEAT -- TNB */
2609 * Increase the insult counter and get angry if too many -RAK-
2611 static int increase_insults(void)
2613 /* Increase insults */
2614 st_ptr->insult_cur++;
2616 /* Become insulted */
2617 if (st_ptr->insult_cur > ot_ptr->insult_max)
2623 st_ptr->insult_cur = 0;
2624 st_ptr->good_buy = 0;
2625 st_ptr->bad_buy = 0;
2628 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2640 * Decrease insults -RAK-
2642 static void decrease_insults(void)
2644 /* Decrease insults */
2645 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2650 * Have insulted while haggling -RAK-
2652 static int haggle_insults(void)
2654 /* Increase insults */
2655 if (increase_insults()) return (TRUE);
2657 /* Display and flush insult */
2666 * Mega-Hack -- Enable "increments"
2668 static bool allow_inc = FALSE;
2671 * Mega-Hack -- Last "increment" during haggling
2673 static s32b last_inc = 0L;
2679 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
2689 /* Clear old increment if necessary */
2690 if (!allow_inc) last_inc = 0L;
2697 sprintf(buf, "%s [¾µÂú] ", pmt);
2699 sprintf(buf, "%s [accept] ", pmt);
2704 /* Old (negative) increment, and not final */
2705 else if (last_inc < 0)
2708 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2710 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2715 /* Old (positive) increment, and not final */
2716 else if (last_inc > 0)
2719 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2721 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2729 sprintf(buf, "%s ", pmt);
2733 /* Paranoia XXX XXX XXX */
2737 /* Ask until done */
2742 /* Display prompt */
2746 strcpy(out_val, "");
2749 * Ask the user for a response.
2750 * Don't allow to use numpad as cursor key.
2752 res = askfor_aux(out_val, 32, FALSE);
2758 if (!res) return FALSE;
2760 /* Skip leading spaces */
2761 for (p = out_val; *p == ' '; p++) /* loop */;
2763 /* Empty response */
2766 /* Accept current price */
2774 /* Use previous increment */
2775 if (allow_inc && last_inc)
2777 *poffer += last_inc;
2782 /* Normal response */
2785 /* Extract a number */
2788 /* Handle "incremental" number */
2789 if ((*p == '+' || *p == '-'))
2791 /* Allow increments */
2794 /* Use the given "increment" */
2801 /* Handle normal number */
2804 /* Use the given "number" */
2813 msg_print("Ãͤ¬¤ª¤«¤·¤¤¤Ç¤¹¡£");
2815 msg_print("Invalid response.");
2827 * Receive an offer (from the player)
2829 * Return TRUE if offer is NOT okay
2831 static bool receive_offer(cptr pmt, s32b *poffer,
2832 s32b last_offer, int factor,
2833 s32b price, int final)
2835 /* Haggle till done */
2838 /* Get a haggle (or cancel) */
2839 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2841 /* Acceptable offer */
2842 if (((*poffer) * factor) >= (last_offer * factor)) break;
2844 /* Insult, and check for kicked out */
2845 if (haggle_insults()) return (TRUE);
2847 /* Reject offer (correctly) */
2848 (*poffer) = last_offer;
2857 * Haggling routine -RAK-
2859 * Return TRUE if purchase is NOT successful
2861 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2863 s32b cur_ask, final_ask;
2864 s32b last_offer, offer;
2866 s32b min_per, max_per;
2867 int flag, loop_flag, noneed;
2868 int annoyed = 0, final = FALSE;
2870 bool cancel = FALSE;
2873 cptr pmt = "Ä󼨲Á³Ê";
2875 cptr pmt = "Asking";
2885 /* Extract the starting offer and the final offer */
2886 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2887 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2889 /* Determine if haggling is necessary */
2890 noneed = noneedtobargain(final_ask);
2892 /* No need to haggle */
2893 if (noneed || !manual_haggle)
2895 /* No need to haggle */
2898 /* Message summary */
2900 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2902 msg_print("You eventually agree upon the price.");
2908 /* No haggle option */
2911 /* Message summary */
2913 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2915 msg_print("You quickly agree upon the price.");
2920 /* Apply Sales Tax */
2921 final_ask += final_ask / 10;
2925 cur_ask = final_ask;
2927 /* Go to final offer */
2929 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2931 pmt = "Final Offer";
2938 /* Haggle for the whole pile */
2939 cur_ask *= o_ptr->number;
2940 final_ask *= o_ptr->number;
2943 /* Haggle parameters */
2944 min_per = ot_ptr->haggle_per;
2945 max_per = min_per * 3;
2947 /* Mega-Hack -- artificial "last offer" value */
2948 last_offer = object_value(o_ptr) * o_ptr->number;
2949 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
2950 if (last_offer <= 0) last_offer = 1;
2955 /* No incremental haggling yet */
2958 /* Haggle until done */
2959 for (flag = FALSE; !flag; )
2963 while (!flag && loop_flag)
2965 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
2966 put_str(out_val, 1, 0);
2968 cancel = receive_offer("Ä󼨤¹¤ë¶â³Û? ",
2970 cancel = receive_offer("What do you offer? ",
2973 &offer, last_offer, 1, cur_ask, final);
2979 else if (offer > cur_ask)
2984 else if (offer == cur_ask)
2997 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
3000 if (haggle_insults())
3006 else if (x1 > max_per)
3009 if (x1 < max_per) x1 = max_per;
3011 x2 = rand_range(x1-2, x1+2);
3012 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
3013 /* don't let the price go up */
3018 if (cur_ask < final_ask)
3021 cur_ask = final_ask;
3023 pmt = "ºÇ½ªÄ󼨲Á³Ê";
3025 pmt = "Final Offer";
3031 (void)(increase_insults());
3036 else if (offer >= cur_ask)
3048 (void)sprintf(out_val, "Á°²ó¤ÎÄ󼨶â³Û: $%ld",
3050 (void)sprintf(out_val, "Your last offer: %ld",
3054 put_str(out_val, 1, 39);
3055 say_comment_2(cur_ask, annoyed);
3061 if (cancel) return (TRUE);
3063 /* Update bargaining info */
3064 updatebargain(*price, final_ask, o_ptr->number);
3072 * Haggling routine -RAK-
3074 * Return TRUE if purchase is NOT successful
3076 static bool sell_haggle(object_type *o_ptr, s32b *price)
3078 s32b purse, cur_ask, final_ask;
3079 s32b last_offer = 0, offer = 0;
3081 s32b min_per, max_per;
3082 int flag, loop_flag, noneed;
3083 int annoyed = 0, final = FALSE;
3084 bool cancel = FALSE;
3086 cptr pmt = "Ä󼨶â³Û";
3097 /* Obtain the starting offer and the final offer */
3098 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
3099 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
3101 /* Determine if haggling is necessary */
3102 noneed = noneedtobargain(final_ask);
3104 /* Get the owner's payout limit */
3105 purse = (s32b)(ot_ptr->max_cost);
3107 /* No need to haggle */
3108 if (noneed || !manual_haggle || (final_ask >= purse))
3110 /* Apply Sales Tax (if needed) */
3111 if (!manual_haggle && !noneed)
3113 final_ask -= final_ask / 10;
3116 /* No reason to haggle */
3117 if (final_ask >= purse)
3121 msg_print("¨ºÂ¤Ë¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3123 msg_print("You instantly agree upon the price.");
3128 /* Offer full purse */
3132 /* No need to haggle */
3137 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3139 msg_print("You eventually agree upon the price.");
3145 /* No haggle option */
3148 /* Message summary */
3150 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3152 msg_print("You quickly agree upon the price.");
3159 cur_ask = final_ask;
3164 pmt = "ºÇ½ªÄ󼨶â³Û";
3166 pmt = "Final Offer";
3171 /* Haggle for the whole pile */
3172 cur_ask *= o_ptr->number;
3173 final_ask *= o_ptr->number;
3176 /* XXX XXX XXX Display commands */
3178 /* Haggling parameters */
3179 min_per = ot_ptr->haggle_per;
3180 max_per = min_per * 3;
3182 /* Mega-Hack -- artificial "last offer" value */
3183 last_offer = object_value(o_ptr) * o_ptr->number;
3184 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3189 /* No incremental haggling yet */
3193 for (flag = FALSE; !flag; )
3199 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3200 put_str(out_val, 1, 0);
3202 cancel = receive_offer("Ä󼨤¹¤ë²Á³Ê? ",
3204 cancel = receive_offer("What price do you ask? ",
3207 &offer, last_offer, -1, cur_ask, final);
3213 else if (offer < cur_ask)
3216 /* rejected, reset offer for incremental haggling */
3219 else if (offer == cur_ask)
3230 if (flag || !loop_flag) break;
3235 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3238 if (haggle_insults())
3244 else if (x1 > max_per)
3247 if (x1 < max_per) x1 = max_per;
3249 x2 = rand_range(x1-2, x1+2);
3250 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3251 /* don't let the price go down */
3255 if (cur_ask > final_ask)
3257 cur_ask = final_ask;
3260 pmt = "ºÇ½ªÄ󼨶â³Û";
3262 pmt = "Final Offer";
3270 /* Äɲà $0 ¤ÇÇ㤤¼è¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ»ß By FIRST*/
3273 (void)(increase_insults());
3276 else if (offer <= cur_ask)
3287 (void)sprintf(out_val,
3289 "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
3291 "Your last bid %ld", (long)last_offer);
3294 put_str(out_val, 1, 39);
3295 say_comment_3(cur_ask, annoyed);
3301 if (cancel) return (TRUE);
3303 /* Update bargaining info */
3304 updatebargain(*price, final_ask, o_ptr->number);
3312 * Buy an item from a store -RAK-
3314 static void store_purchase(void)
3326 char o_name[MAX_NLEN];
3330 if (cur_store_num == STORE_MUSEUM)
3333 msg_print("Çîʪ´Û¤«¤é¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
3335 msg_print("Museum.");
3341 if (st_ptr->stock_num <= 0)
3343 if (cur_store_num == STORE_HOME)
3345 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3347 msg_print("Your home is empty.");
3352 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
3354 msg_print("I am currently out of stock.");
3361 /* Find the number of objects on this and following pages */
3362 i = (st_ptr->stock_num - store_top);
3364 /* And then restrict it to the current page */
3365 if (i > store_bottom) i = store_bottom;
3369 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
3370 switch( cur_store_num ) {
3372 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
3375 sprintf(out_val, "¤É¤ì? ");
3378 sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
3382 if (cur_store_num == STORE_HOME)
3384 sprintf(out_val, "Which item do you want to take? ");
3388 sprintf(out_val, "Which item are you interested in? ");
3393 /* Get the item number to be bought */
3394 if (!get_stock(&item, out_val, 0, i - 1)) return;
3396 /* Get the actual index */
3397 item = item + store_top;
3399 /* Get the actual item */
3400 o_ptr = &st_ptr->stock[item];
3402 /* Assume the player wants just one of them */
3405 /* Get local object */
3408 /* Get a copy of the object */
3409 object_copy(j_ptr, o_ptr);
3412 * If a rod or wand, allocate total maximum timeouts or charges
3413 * between those purchased and left on the shelf.
3415 reduce_charges(j_ptr, o_ptr->number - amt);
3417 /* Modify quantity */
3418 j_ptr->number = amt;
3420 /* Hack -- require room in pack */
3421 if (!inven_carry_okay(j_ptr))
3424 msg_print("¤½¤ó¤Ê¤Ë¥¢¥¤¥Æ¥à¤ò»ý¤Æ¤Ê¤¤¡£");
3426 msg_print("You cannot carry that many different items.");
3432 /* Determine the "best" price (per item) */
3433 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3435 /* Find out how many the player wants */
3436 if (o_ptr->number > 1)
3438 /* Hack -- note cost of "fixed" items */
3439 if ((cur_store_num != STORE_HOME) &&
3440 (o_ptr->ident & IDENT_FIXED))
3443 msg_format("°ì¤Ä¤Ë¤Ä¤ $%ld¤Ç¤¹¡£", (long)(best));
3445 msg_format("That costs %ld gold per item.", (long)(best));
3450 /* Get a quantity */
3451 amt = get_quantity(NULL, o_ptr->number);
3453 /* Allow user abort */
3454 if (amt <= 0) return;
3457 /* Get local object */
3460 /* Get desired object */
3461 object_copy(j_ptr, o_ptr);
3464 * If a rod or wand, allocate total maximum timeouts or charges
3465 * between those purchased and left on the shelf.
3467 reduce_charges(j_ptr, o_ptr->number - amt);
3469 /* Modify quantity */
3470 j_ptr->number = amt;
3472 /* Hack -- require room in pack */
3473 if (!inven_carry_okay(j_ptr))
3476 msg_print("¥¶¥Ã¥¯¤Ë¤½¤Î¥¢¥¤¥Æ¥à¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£");
3478 msg_print("You cannot carry that many items.");
3484 /* Attempt to buy it */
3485 if (cur_store_num != STORE_HOME)
3487 /* Fixed price, quick buy */
3488 if (o_ptr->ident & (IDENT_FIXED))
3493 /* Go directly to the "best" deal */
3494 price = (best * j_ptr->number);
3500 /* Describe the object (fully) */
3501 object_desc(o_name, j_ptr, 0);
3505 msg_format("%s(%c)¤ò¹ØÆþ¤¹¤ë¡£", o_name, I2A(item));
3507 msg_format("Buying %s (%c).", o_name, I2A(item));
3512 /* Haggle for a final price */
3513 choice = purchase_haggle(j_ptr, &price);
3515 /* Hack -- Got kicked out */
3516 if (st_ptr->store_open >= turn) return;
3519 /* Player wants it */
3522 /* Fix the item price (if "correctly" haggled) */
3523 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3525 /* Player can afford it */
3526 if (p_ptr->au >= price)
3531 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3532 chg_virtue(V_JUSTICE, -1);
3533 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3534 chg_virtue(V_NATURE, -1);
3542 /* Spend the money */
3545 /* Update the display */
3548 /* Hack -- buying an item makes you aware of it */
3549 object_aware(j_ptr);
3551 /* Hack -- clear the "fixed" flag from the item */
3552 j_ptr->ident &= ~(IDENT_FIXED);
3554 /* Describe the transaction */
3555 object_desc(o_name, j_ptr, 0);
3559 msg_format("%s¤ò $%ld¤Ç¹ØÆþ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3561 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3564 strcpy(record_o_name, o_name);
3567 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3568 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3569 if(record_rand_art && o_ptr->art_name)
3570 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3572 /* Erase the inscription */
3573 j_ptr->inscription = 0;
3575 /* Erase the "feeling" */
3576 j_ptr->feeling = FEEL_NONE;
3577 j_ptr->ident &= ~(IDENT_STORE);
3578 /* Give it to the player */
3579 item_new = inven_carry(j_ptr);
3581 /* Describe the final result */
3582 object_desc(o_name, &inventory[item_new], 0);
3586 msg_format("%s(%c)¤ò¼ê¤ËÆþ¤ì¤¿¡£", o_name, index_to_label(item_new));
3588 msg_format("You have %s (%c).",
3589 o_name, index_to_label(item_new));
3592 /* Auto-inscription */
3593 autopick_alter_item(item_new, FALSE);
3595 /* Now, reduce the original stack's pval. */
3596 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3598 o_ptr->pval -= j_ptr->pval;
3604 /* Note how many slots the store used to have */
3605 i = st_ptr->stock_num;
3607 /* Remove the bought items from the store */
3608 store_item_increase(item, -amt);
3609 store_item_optimize(item);
3611 /* Store is empty */
3612 if (st_ptr->stock_num == 0)
3615 if (one_in_(STORE_SHUFFLE))
3620 msg_print("Ź¼ç¤Ï°úÂष¤¿¡£");
3622 msg_print("The shopkeeper retires.");
3626 /* Shuffle the store */
3627 store_shuffle(cur_store_num);
3630 sprintf(buf, "%s (%s)",
3631 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3632 put_str(buf, 3, 10);
3633 sprintf(buf, "%s (%ld)",
3634 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
3643 msg_print("Ź¼ç¤Ï¿·¤¿¤Êºß¸Ë¤ò¼è¤ê½Ð¤·¤¿¡£");
3645 msg_print("The shopkeeper brings out some new stock.");
3651 for (i = 0; i < 10; i++)
3653 /* Maintain the store */
3654 store_maint(p_ptr->town_num, cur_store_num);
3660 /* Redraw everything */
3661 display_inventory();
3664 /* The item is gone */
3665 else if (st_ptr->stock_num != i)
3667 /* Pick the correct screen */
3668 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3670 /* Redraw everything */
3671 display_inventory();
3674 /* Item is still here */
3677 /* Redraw the item */
3678 display_entry(item);
3682 /* Player cannot afford it */
3685 /* Simple message (no insult) */
3687 msg_print("¤ª¶â¤¬Â¤ê¤Þ¤»¤ó¡£");
3689 msg_print("You do not have enough gold.");
3696 /* Home is much easier */
3699 bool combined_or_reordered;
3701 /* Distribute charges of wands/rods */
3702 distribute_charges(o_ptr, j_ptr, amt);
3704 /* Give it to the player */
3705 item_new = inven_carry(j_ptr);
3707 /* Describe just the result */
3708 object_desc(o_name, &inventory[item_new], 0);
3712 msg_format("%s(%c)¤ò¼è¤Ã¤¿¡£",
3714 msg_format("You have %s (%c).",
3716 o_name, index_to_label(item_new));
3721 /* Take note if we take the last one */
3722 i = st_ptr->stock_num;
3724 /* Remove the items from the home */
3725 store_item_increase(item, -amt);
3726 store_item_optimize(item);
3728 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
3730 /* Hack -- Item is still here */
3731 if (i == st_ptr->stock_num)
3733 /* Redraw everything */
3734 if (combined_or_reordered) display_inventory();
3736 /* Redraw the item */
3737 else display_entry(item);
3740 /* The item is gone */
3744 if (st_ptr->stock_num == 0) store_top = 0;
3746 /* Nothing left on that screen */
3747 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3749 /* Redraw everything */
3750 display_inventory();
3752 chg_virtue(V_SACRIFICE, 1);
3756 /* Not kicked out */
3762 * Sell an item to the store (or home)
3764 static void store_sell(void)
3770 s32b price, value, dummy;
3779 char o_name[MAX_NLEN];
3782 /* Prepare a prompt */
3783 if (cur_store_num == STORE_HOME)
3785 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÃÖ¤¤Þ¤¹¤«? ";
3787 q = "Drop which item? ";
3790 else if (cur_store_num == STORE_MUSEUM)
3792 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ó£¤·¤Þ¤¹¤«? ";
3794 q = "Give which item? ";
3799 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÇä¤ê¤Þ¤¹¤«? ";
3801 q = "Sell which item? ";
3805 item_tester_no_ryoute = TRUE;
3806 /* Only allow items the store will buy */
3807 item_tester_hook = store_will_buy;
3810 /* ²æ¤¬²È¤Ç¤ª¤«¤·¤Ê¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¥ª¥ê¥¸¥Ê¥ë¤Î¥Ð¥°¤ò½¤Àµ */
3811 if (cur_store_num == STORE_HOME)
3814 s = "ÃÖ¤±¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3816 s = "You don't have any item to drop.";
3819 else if (cur_store_num == STORE_MUSEUM)
3822 s = "´ó£¤Ç¤¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3824 s = "You don't have any item to give.";
3830 s = "Íߤ·¤¤Êª¤¬¤Ê¤¤¤Ç¤¹¤Í¤¨¡£";
3832 s = "You have nothing that I want.";
3836 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3838 /* Get the item (in the pack) */
3841 o_ptr = &inventory[item];
3844 /* Get the item (on the floor) */
3847 o_ptr = &o_list[0 - item];
3851 /* Hack -- Cannot remove cursed items */
3852 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
3856 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¤Í¡£");
3858 msg_print("Hmmm, it seems to be cursed.");
3867 /* Assume one item */
3870 /* Find out how many the player wants (letter means "all") */
3871 if (o_ptr->number > 1)
3873 /* Get a quantity */
3874 amt = get_quantity(NULL, o_ptr->number);
3876 /* Allow user abort */
3877 if (amt <= 0) return;
3880 /* Get local object */
3883 /* Get a copy of the object */
3884 object_copy(q_ptr, o_ptr);
3886 /* Modify quantity */
3887 q_ptr->number = amt;
3890 * Hack -- If a rod or wand, allocate total maximum
3891 * timeouts or charges to those being sold. -LM-
3893 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3895 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3898 /* Get a full description */
3899 object_desc(o_name, q_ptr, 0);
3901 /* Remove any inscription, feeling for stores */
3902 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3904 q_ptr->inscription = 0;
3905 q_ptr->feeling = FEEL_NONE;
3908 /* Is there room in the store (or the home?) */
3909 if (!store_check_num(q_ptr))
3911 if (cur_store_num == STORE_HOME)
3913 msg_print("²æ¤¬²È¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤Ê¤¤¡£");
3915 msg_print("Your home is full.");
3918 else if (cur_store_num == STORE_MUSEUM)
3920 msg_print("Çîʪ´Û¤Ï¤â¤¦ËþÇÕ¤À¡£");
3922 msg_print("Museum is full.");
3927 msg_print("¤¹¤¤¤Þ¤»¤ó¤¬¡¢Å¹¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤¢¤ê¤Þ¤»¤ó¡£");
3929 msg_print("I have not the room in my store to keep it.");
3937 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3939 /* Describe the transaction */
3941 msg_format("%s(%c)¤òÇäµÑ¤¹¤ë¡£", o_name, index_to_label(item));
3943 msg_format("Selling %s (%c).", o_name, index_to_label(item));
3949 choice = sell_haggle(q_ptr, &price);
3952 if (st_ptr->store_open >= turn) return;
3964 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3965 chg_virtue(V_JUSTICE, -1);
3967 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3968 chg_virtue(V_NATURE, 1);
3971 /* Get some money */
3974 /* Update the display */
3977 /* Get the "apparent" value */
3978 dummy = object_value(q_ptr) * q_ptr->number;
3981 identify_item(o_ptr);
3983 /* Get local object */
3986 /* Get a copy of the object */
3987 object_copy(q_ptr, o_ptr);
3989 /* Modify quantity */
3990 q_ptr->number = amt;
3992 /* Make it look like to be known */
3993 q_ptr->ident |= IDENT_STORE;
3996 * Hack -- If a rod or wand, let the shopkeeper know just
3997 * how many charges he really paid for. -LM-
3999 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4001 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
4004 /* Get the "actual" value */
4005 value = object_value(q_ptr) * q_ptr->number;
4007 /* Get the description all over again */
4008 object_desc(o_name, q_ptr, 0);
4010 /* Describe the result (in message buffer) */
4012 msg_format("%s¤ò $%ld¤ÇÇäµÑ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
4014 msg_format("You sold %s for %ld gold.", o_name, (long)price);
4017 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
4019 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
4021 /* Analyze the prices (and comment verbally) unless a figurine*/
4022 purchase_analyze(price, value, dummy);
4026 * Hack -- Allocate charges between those wands or rods sold
4027 * and retained, unless all are being sold. -LM-
4029 distribute_charges(o_ptr, q_ptr, amt);
4031 /* Reset timeouts of the sold items */
4034 /* Take the item from the player, describe the result */
4035 inven_item_increase(item, -amt);
4036 inven_item_describe(item);
4038 /* If items remain, auto-inscribe before optimizing */
4039 if (o_ptr->number > 0)
4040 autopick_alter_item(item, FALSE);
4042 inven_item_optimize(item);
4047 /* The store gets that (known) item */
4048 item_pos = store_carry(q_ptr);
4050 /* Re-display if item is now in store */
4053 store_top = (item_pos / store_bottom) * store_bottom;
4054 display_inventory();
4059 /* Player is at museum */
4060 else if (cur_store_num == STORE_MUSEUM)
4062 char o2_name[MAX_NLEN];
4063 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
4065 if (-1 == store_check_num(q_ptr))
4068 msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£");
4070 msg_print("The same object as it is already in the Museum.");
4076 msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª¡ª");
4078 msg_print("You cannot take items which is given to the Museum back!!");
4082 if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return;
4084 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
4088 identify_item(q_ptr);
4089 q_ptr->ident |= IDENT_MENTAL;
4091 /* Distribute charges of wands/rods */
4092 distribute_charges(o_ptr, q_ptr, amt);
4096 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
4098 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4103 /* Take it from the players inventory */
4104 inven_item_increase(item, -amt);
4105 inven_item_describe(item);
4106 inven_item_optimize(item);
4111 /* Let the home carry it */
4112 item_pos = home_carry(q_ptr);
4114 /* Update store display */
4117 store_top = (item_pos / store_bottom) * store_bottom;
4118 display_inventory();
4121 /* Player is at home */
4124 /* Distribute charges of wands/rods */
4125 distribute_charges(o_ptr, q_ptr, amt);
4129 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
4131 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4136 /* Take it from the players inventory */
4137 inven_item_increase(item, -amt);
4138 inven_item_describe(item);
4139 inven_item_optimize(item);
4144 /* Let the home carry it */
4145 item_pos = home_carry(q_ptr);
4147 /* Update store display */
4150 store_top = (item_pos / store_bottom) * store_bottom;
4151 display_inventory();
4155 if ((choice == 0) && (item >= INVEN_RARM))
4164 * Examine an item in a store -JDL-
4166 static void store_examine(void)
4171 char o_name[MAX_NLEN];
4176 if (st_ptr->stock_num <= 0)
4178 if (cur_store_num == STORE_HOME)
4180 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4182 msg_print("Your home is empty.");
4185 else if (cur_store_num == STORE_MUSEUM)
4187 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4189 msg_print("Museum is empty.");
4194 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
4196 msg_print("I am currently out of stock.");
4203 /* Find the number of objects on this and following pages */
4204 i = (st_ptr->stock_num - store_top);
4206 /* And then restrict it to the current page */
4207 if (i > store_bottom) i = store_bottom;
4211 sprintf(out_val, "¤É¤ì¤òÄ´¤Ù¤Þ¤¹¤«¡©");
4213 sprintf(out_val, "Which item do you want to examine? ");
4217 /* Get the item number to be examined */
4218 if (!get_stock(&item, out_val, 0, i - 1)) return;
4220 /* Get the actual index */
4221 item = item + store_top;
4223 /* Get the actual item */
4224 o_ptr = &st_ptr->stock[item];
4226 /* Require full knowledge */
4227 if (!(o_ptr->ident & IDENT_MENTAL))
4229 /* This can only happen in the home */
4231 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
4233 msg_print("You have no special knowledge about that item.");
4240 object_desc(o_name, o_ptr, 0);
4244 msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
4246 msg_format("Examining %s...", o_name);
4250 /* Describe it fully */
4251 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
4253 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
4255 msg_print("You see nothing special.");
4264 * Remove an item from museum (Originally from TOband)
4266 static void museum_remove_object(void)
4271 char o_name[MAX_NLEN];
4275 if (st_ptr->stock_num <= 0)
4278 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4280 msg_print("Museum is empty.");
4286 /* Find the number of objects on this and following pages */
4287 i = st_ptr->stock_num - store_top;
4289 /* And then restrict it to the current page */
4290 if (i > store_bottom) i = store_bottom;
4294 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©");
4296 sprintf(out_val, "Which item do you want to order to remove? ");
4299 /* Get the item number to be removed */
4300 if (!get_stock(&item, out_val, 0, i - 1)) return;
4302 /* Get the actual index */
4303 item = item + store_top;
4305 /* Get the actual item */
4306 o_ptr = &st_ptr->stock[item];
4309 object_desc(o_name, o_ptr, 0);
4312 msg_print("Ÿ¼¨¤ò¤ä¤á¤µ¤»¤¿¥¢¥¤¥Æ¥à¤ÏÆóÅ٤ȸ«¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡ª");
4313 if (!get_check(format("ËÜÅö¤Ë%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©", o_name))) return;
4315 msg_print("You cannot see items which is removed from the Museum!");
4316 if (!get_check(format("Really order to remove %s from the Museum? ", o_name))) return;
4321 msg_format("%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤¿¡£", o_name);
4323 msg_format("You ordered to remove %s.", o_name);
4326 /* Remove the items from the home */
4327 store_item_increase(item, -o_ptr->number);
4328 store_item_optimize(item);
4330 (void)combine_and_reorder_home(STORE_MUSEUM);
4332 /* The item is gone */
4335 if (st_ptr->stock_num == 0) store_top = 0;
4337 /* Nothing left on that screen */
4338 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4340 /* Redraw everything */
4341 display_inventory();
4348 * Hack -- set this to leave the store
4350 static bool leave_store = FALSE;
4354 * Process a command in a store
4356 * Note that we must allow the use of a few "special" commands
4357 * in the stores which are not allowed in the dungeon, and we
4358 * must disable some commands which are allowed in the dungeon
4359 * but not in the stores, to prevent chaos.
4361 static void store_process_command(void)
4363 #ifdef ALLOW_REPEAT /* TNB */
4365 /* Handle repeating the last command */
4368 #endif /* ALLOW_REPEAT -- TNB */
4370 if (rogue_like_commands && command_cmd == 'l')
4372 command_cmd = 'x'; /* hack! */
4375 /* Parse the command */
4376 switch (command_cmd)
4386 /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
4389 if (st_ptr->stock_num <= store_bottom) {
4391 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4393 msg_print("Entire inventory is shown.");
4397 store_top -= store_bottom;
4398 if ( store_top < 0 )
4399 store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
4400 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4401 if ( store_top >= store_bottom ) store_top = store_bottom;
4402 display_inventory();
4410 if (st_ptr->stock_num <= store_bottom)
4413 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4415 msg_print("Entire inventory is shown.");
4421 store_top += store_bottom;
4423 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
4424 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
4426 if ((cur_store_num == STORE_HOME) &&
4427 (powerup_home == FALSE) &&
4428 (st_ptr->stock_num >= STORE_INVEN_MAX))
4430 if (store_top >= (STORE_INVEN_MAX - 1))
4437 if (store_top >= st_ptr->stock_num) store_top = 0;
4440 display_inventory();
4453 /* Get (purchase) */
4480 /*** Inventory Commands ***/
4482 /* Wear/wield equipment */
4489 /* Take off equipment */
4496 /* Destroy an item */
4503 /* Equipment list */
4510 /* Inventory list */
4518 /*** Various commands ***/
4520 /* Identify an object */
4527 /* Hack -- toggle windows */
4530 toggle_inven_equip();
4536 /*** Use various objects ***/
4541 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4542 (p_ptr->pclass == CLASS_BERSERKER) ||
4543 (p_ptr->pclass == CLASS_NINJA) ||
4544 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4545 ) do_cmd_mind_browse();
4546 else if (p_ptr->pclass == CLASS_SMITH)
4548 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4549 do_cmd_magic_eater(TRUE, FALSE);
4550 else if (p_ptr->pclass == CLASS_SNIPER)
4551 do_cmd_snipe_browse();
4552 else do_cmd_browse();
4556 /* Inscribe an object */
4563 /* Uninscribe an object */
4566 do_cmd_uninscribe();
4572 /*** Help and Such ***/
4581 /* Identify symbol */
4584 do_cmd_query_symbol();
4588 /* Character description */
4591 p_ptr->town_num = old_town_num;
4592 do_cmd_change_name();
4593 p_ptr->town_num = inner_town_num;
4599 /*** System Commands ***/
4601 /* Hack -- User interface */
4608 /* Single line from a pref file */
4611 p_ptr->town_num = old_town_num;
4613 p_ptr->town_num = inner_town_num;
4617 /* Interact with macros */
4620 p_ptr->town_num = old_town_num;
4622 p_ptr->town_num = inner_town_num;
4626 /* Interact with visuals */
4629 p_ptr->town_num = old_town_num;
4631 p_ptr->town_num = inner_town_num;
4635 /* Interact with colors */
4638 p_ptr->town_num = old_town_num;
4640 p_ptr->town_num = inner_town_num;
4644 /* Interact with options */
4648 (void)combine_and_reorder_home(STORE_HOME);
4654 /*** Misc Commands ***/
4670 /* Repeat level feeling */
4677 /* Show previous message */
4680 do_cmd_message_one();
4684 /* Show previous messages */
4697 /* Check artifacts, uniques etc. */
4704 /* Load "screen dump" */
4707 do_cmd_load_screen();
4711 /* Save "screen dump" */
4714 do_cmd_save_screen();
4718 /* Hack -- Unknown command */
4721 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
4723 museum_remove_object();
4728 msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
4730 msg_print("That command does not work in stores.");
4741 * Enter a store, and interact with it.
4743 * Note that we use the standard "request_command()" function
4744 * to get a command, allowing us to use "command_arg" and all
4745 * command macros and other nifty stuff, but we use the special
4746 * "shopping" argument, to force certain commands to be converted
4747 * into other commands, normally, we convert "p" (pray) and "m"
4748 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4750 void do_cmd_store(void)
4756 bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
4760 Term_get_size(&w, &h);
4762 /* Calculate stocks per 1 page */
4763 xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
4764 store_bottom = MIN_STOCK + xtra_stock;
4766 /* Access the player grid */
4767 c_ptr = &cave[py][px];
4769 /* Verify a store */
4770 if (!cave_have_flag_grid(c_ptr, FF_STORE))
4773 msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
4775 msg_print("You see no store here.");
4781 /* Extract the store code */
4782 which = f_info[c_ptr->feat].subtype;
4784 old_town_num = p_ptr->town_num;
4785 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4786 if (dun_level) p_ptr->town_num = NO_TOWN;
4787 inner_town_num = p_ptr->town_num;
4789 /* Hack -- Check the "locked doors" */
4790 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4794 msg_print("¥É¥¢¤Ë¸°¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£");
4796 msg_print("The doors are locked.");
4799 p_ptr->town_num = old_town_num;
4803 /* Calculate the number of store maintainances since the last visit */
4804 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4806 /* Maintain the store max. 10 times */
4807 if (maintain_num > 10) maintain_num = 10;
4811 /* Maintain the store */
4812 for (i = 0; i < maintain_num; i++)
4813 store_maint(p_ptr->town_num, which);
4815 /* Save the visit */
4816 town[p_ptr->town_num].store[which].last_visit = turn;
4819 /* Forget the lite */
4822 /* Forget the view */
4826 /* Hack -- Character is in "icky" mode */
4827 character_icky = TRUE;
4830 /* No command argument */
4833 /* No repeated command */
4836 /* No automatic command */
4839 /* Do not expand macros */
4840 get_com_no_macros = TRUE;
4842 /* Save the store number */
4843 cur_store_num = which;
4845 /* Hack -- save the store feature */
4846 cur_store_feat = c_ptr->feat;
4848 /* Save the store and owner pointers */
4849 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4850 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4853 /* Start at the beginning */
4856 /* Display the store */
4860 leave_store = FALSE;
4862 /* Interact with player */
4863 while (!leave_store)
4865 /* Hack -- Clear line 1 */
4869 clear_from(20 + xtra_stock);
4872 /* Basic commands */
4874 prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21 + xtra_stock, 0);
4876 prt(" ESC) Exit from Building.", 21 + xtra_stock, 0);
4880 /* Browse if necessary */
4881 if (st_ptr->stock_num > store_bottom)
4884 prt(" -)Á°¥Ú¡¼¥¸", 22 + xtra_stock, 0);
4885 prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23 + xtra_stock, 0);
4887 prt(" -) Previous page", 22 + xtra_stock, 0);
4888 prt(" SPACE) Next page", 23 + xtra_stock, 0);
4894 if (cur_store_num == STORE_HOME)
4897 prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21 + xtra_stock, 27);
4898 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22 + xtra_stock, 27);
4899 prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
4901 prt("g) Get an item.", 21 + xtra_stock, 27);
4902 prt("d) Drop an item.", 22 + xtra_stock, 27);
4903 prt("x) eXamine an item in the home.", 23 + xtra_stock, 27);
4907 /* Museum commands */
4908 else if (cur_store_num == STORE_MUSEUM)
4911 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21 + xtra_stock, 27);
4912 prt("r) ¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤ë", 22 + xtra_stock, 27);
4913 prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
4915 prt("d) Drop an item.", 21 + xtra_stock, 27);
4916 prt("r) order to Remove an item.", 22 + xtra_stock, 27);
4917 prt("x) eXamine an item in the museum.", 23 + xtra_stock, 27);
4921 /* Shop commands XXX XXX XXX */
4925 prt("p) ¾¦ÉʤòÇ㤦", 21 + xtra_stock, 30);
4926 prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22 + xtra_stock, 30);
4927 prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23 + xtra_stock,30);
4929 prt("p) Purchase an item.", 21 + xtra_stock, 30);
4930 prt("s) Sell an item.", 22 + xtra_stock, 30);
4931 prt("x) eXamine an item in the shop", 23 + xtra_stock,30);
4936 /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
4938 prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21 + xtra_stock, 56);
4940 if (rogue_like_commands)
4942 prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
4946 prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
4949 prt("i/e) Inventry/Equipment list", 21 + xtra_stock, 56);
4951 if (rogue_like_commands)
4953 prt("w/T) Wear/Take off equipment", 22 + xtra_stock, 56);
4957 prt("w/t) Wear/Take off equipment", 22 + xtra_stock, 56);
4962 prt("¥³¥Þ¥ó¥É:", 20 + xtra_stock, 0);
4964 prt("You may: ", 20 + xtra_stock, 0);
4969 request_command(TRUE);
4971 /* Process the command */
4972 store_process_command();
4975 * Hack -- To redraw missiles damage and prices in store
4976 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
4978 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
4980 /* Hack -- Character is still in "icky" mode */
4981 character_icky = TRUE;
4989 /* XXX XXX XXX Pack Overflow */
4990 if (inventory[INVEN_PACK].k_idx)
4992 int item = INVEN_PACK;
4994 object_type *o_ptr = &inventory[item];
4996 /* Hack -- Flee from the store */
4997 if (cur_store_num != STORE_HOME)
5001 if (cur_store_num == STORE_MUSEUM)
5002 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆÇîʪ´Û¤«¤é½Ð¤¿...");
5004 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆŹ¤«¤é½Ð¤¿...");
5006 if (cur_store_num == STORE_MUSEUM)
5007 msg_print("Your pack is so full that you flee the Museum...");
5009 msg_print("Your pack is so full that you flee the store...");
5017 /* Hack -- Flee from the home */
5018 else if (!store_check_num(o_ptr))
5022 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤Æ²È¤«¤é½Ð¤¿...");
5024 msg_print("Your pack is so full that you flee your home...");
5032 /* Hack -- Drop items into the home */
5040 char o_name[MAX_NLEN];
5043 /* Give a message */
5045 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
5047 msg_print("Your pack overflows!");
5051 /* Get local object */
5054 /* Grab a copy of the item */
5055 object_copy(q_ptr, o_ptr);
5058 object_desc(o_name, q_ptr, 0);
5062 msg_format("%s¤¬Íî¤Á¤¿¡£(%c)", o_name, index_to_label(item));
5064 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5068 /* Remove it from the players inventory */
5069 inven_item_increase(item, -255);
5070 inven_item_describe(item);
5071 inven_item_optimize(item);
5076 /* Let the home carry it */
5077 item_pos = home_carry(q_ptr);
5079 /* Redraw the home */
5082 store_top = (item_pos / store_bottom) * store_bottom;
5083 display_inventory();
5088 /* Hack -- Redisplay store prices if charisma changes */
5089 /* Hack -- Redraw missiles damage if player changes bow */
5090 if (need_redraw_store_inv) display_inventory();
5092 /* Hack -- get kicked out of the store */
5093 if (st_ptr->store_open >= turn) leave_store = TRUE;
5096 p_ptr->town_num = old_town_num;
5098 /* Free turn XXX XXX XXX */
5102 /* Hack -- Character is no longer in "icky" mode */
5103 character_icky = FALSE;
5106 /* Hack -- Cancel automatic command */
5109 /* Hack -- Cancel "see" mode */
5110 command_see = FALSE;
5112 /* Allow expanding macros */
5113 get_com_no_macros = FALSE;
5115 /* Flush messages XXX XXX XXX */
5119 /* Clear the screen */
5123 /* Update everything */
5124 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
5125 p_ptr->update |= (PU_MONSTERS);
5127 /* Redraw entire screen */
5128 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5131 p_ptr->redraw |= (PR_MAP);
5134 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5140 * Shuffle one of the stores.
5142 void store_shuffle(int which)
5148 if (which == STORE_HOME) return;
5149 if (which == STORE_MUSEUM) return;
5152 /* Save the store index */
5153 cur_store_num = which;
5155 /* Activate that store */
5156 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
5159 /* Pick a new owner */
5162 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5163 if (j == st_ptr->owner) continue;
5164 for (i = 1;i < max_towns; i++)
5166 if (i == p_ptr->town_num) continue;
5167 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
5169 if (i == max_towns) break;
5172 /* Activate the new owner */
5173 ot_ptr = &owners[cur_store_num][st_ptr->owner];
5176 /* Reset the owner data */
5177 st_ptr->insult_cur = 0;
5178 st_ptr->store_open = 0;
5179 st_ptr->good_buy = 0;
5180 st_ptr->bad_buy = 0;
5183 /* Hack -- discount all the items */
5184 for (i = 0; i < st_ptr->stock_num; i++)
5189 o_ptr = &st_ptr->stock[i];
5191 if (!object_is_artifact(o_ptr))
5193 /* Hack -- Sell all non-artifact old items for "half price" */
5194 o_ptr->discount = 50;
5196 /* Hack -- Items are no longer "fixed price" */
5197 o_ptr->ident &= ~(IDENT_FIXED);
5199 /* Mega-Hack -- Note that the item is "on sale" */
5201 o_ptr->inscription = quark_add("Çä½ÐÃæ");
5203 o_ptr->inscription = quark_add("on sale");
5211 * Maintain the inventory at the stores.
5213 void store_maint(int town_num, int store_num)
5217 cur_store_num = store_num;
5220 if (store_num == STORE_HOME) return;
5221 if (store_num == STORE_MUSEUM) return;
5223 /* Activate that store */
5224 st_ptr = &town[town_num].store[store_num];
5226 /* Activate the owner */
5227 ot_ptr = &owners[store_num][st_ptr->owner];
5229 /* Store keeper forgives the player */
5230 st_ptr->insult_cur = 0;
5232 /* Mega-Hack -- prune the black market */
5233 if (store_num == STORE_BLACK)
5235 /* Destroy crappy black market items */
5236 for (j = st_ptr->stock_num - 1; j >= 0; j--)
5238 object_type *o_ptr = &st_ptr->stock[j];
5240 /* Destroy crappy items */
5241 if (black_market_crap(o_ptr))
5243 /* Destroy the item */
5244 store_item_increase(j, 0 - o_ptr->number);
5245 store_item_optimize(j);
5251 /* Choose the number of slots to keep */
5252 j = st_ptr->stock_num;
5254 /* Sell a few items */
5255 j = j - randint1(STORE_TURNOVER);
5257 /* Never keep more than "STORE_MAX_KEEP" slots */
5258 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5260 /* Always "keep" at least "STORE_MIN_KEEP" items */
5261 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5263 /* Hack -- prevent "underflow" */
5266 /* Destroy objects until only "j" slots are left */
5267 while (st_ptr->stock_num > j) store_delete();
5270 /* Choose the number of slots to fill */
5271 j = st_ptr->stock_num;
5273 /* Buy some more items */
5274 j = j + randint1(STORE_TURNOVER);
5276 /* Never keep more than "STORE_MAX_KEEP" slots */
5277 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5279 /* Always "keep" at least "STORE_MIN_KEEP" items */
5280 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5282 /* Hack -- prevent "overflow" */
5283 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
5285 /* Acquire some new items */
5286 while (st_ptr->stock_num < j) store_create();
5291 * Initialize the stores
5293 void store_init(int town_num, int store_num)
5297 cur_store_num = store_num;
5299 /* Activate that store */
5300 st_ptr = &town[town_num].store[store_num];
5308 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5309 for (i = 1;i < max_towns; i++)
5311 if (i == town_num) continue;
5312 if (st_ptr->owner == town[i].store[store_num].owner) break;
5314 if (i == max_towns) break;
5317 /* Activate the new owner */
5318 ot_ptr = &owners[store_num][st_ptr->owner];
5321 /* Initialize the store */
5322 st_ptr->store_open = 0;
5323 st_ptr->insult_cur = 0;
5324 st_ptr->good_buy = 0;
5325 st_ptr->bad_buy = 0;
5327 /* Nothing in stock */
5328 st_ptr->stock_num = 0;
5331 * MEGA-HACK - Last visit to store is
5332 * BEFORE player birth to enable store restocking
5334 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5336 /* Clear any old items */
5337 for (k = 0; k < st_ptr->stock_size; k++)
5339 object_wipe(&st_ptr->stock[k]);
5344 void move_to_black_market(object_type *o_ptr)
5347 if (!p_ptr->town_num) return;
5349 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5351 o_ptr->ident |= IDENT_STORE;
5353 (void)store_carry(o_ptr);
5355 object_wipe(o_ptr); /* Don't leave a bogus object behind... */