4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: Store commands */
17 static int cur_store_num = 0;
18 static int store_top = 0;
19 static int store_bottom = 0;
20 static int xtra_stock = 0;
21 static store_type *st_ptr = NULL;
22 static owner_type *ot_ptr = NULL;
23 static s16b old_town_num = 0;
24 static s16b inner_town_num = 0;
25 #define RUMOR_CHANCE 8
27 #define MAX_COMMENT_1 6
29 static cptr comment_1[MAX_COMMENT_1] =
50 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÄɲåá¥Ã¥»¡¼¥¸¡Ê¾µÂú¡Ë */
51 static cptr comment_1_B[MAX_COMMENT_1] = {
52 "¤Þ¤¢¡¢¤½¤ì¤Ç¤¤¤¤¤ä¡£",
53 "º£Æü¤Ï¤½¤ì¤Ç´ªÊÛ¤·¤Æ¤ä¤ë¡£",
60 #define MAX_COMMENT_2A 2
62 static cptr comment_2a[MAX_COMMENT_2A] =
65 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
66 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
68 "You try my patience. %s is final.",
69 "My patience grows thin. %s is final."
74 #define MAX_COMMENT_2B 12
76 static cptr comment_2b[MAX_COMMENT_2B] =
79 " $%s ¤°¤é¤¤¤Ï½Ð¤µ¤Ê¤¤ã¥À¥á¤À¤è¡£",
80 " $%s ¤Ê¤é¼õ¤±¼è¤Ã¤Æ¤â¤¤¤¤¤¬¡£",
81 "¥Ï¡ª $%s °Ê²¼¤Ï¤Ê¤¤¤Í¡£",
82 "²¿¤ÆÅÛ¤À¡ª $%s °Ê²¼¤Ï¤¢¤êÆÀ¤Ê¤¤¤¾¡£",
83 "¤½¤ì¤¸¤ã¾¯¤Ê¤¹¤®¤ë¡ª $%s ¤ÏÍߤ·¤¤¤È¤³¤í¤À¡£",
84 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤Ï¤â¤é¤ï¤Ê¤¤¤È¡£",
85 "±³¤À¤í¤¦¡ª $%s ¤Ç¤É¤¦¤À¤¤¡©",
86 "¤ª¤¤¤ª¤¤¡ª $%s ¤ò¹Í¤¨¤Æ¤¯¤ì¤Ê¤¤¤«¡©",
87 "1000ɤ¤Î¥ª¡¼¥¯¤Î¥Î¥ß¤Ë¶ì¤·¤á¤é¤ì¤ë¤¬¤¤¤¤¡ª $%s ¤À¡£",
88 "¤ªÁ°¤ÎÂçÀڤʤâ¤Î¤ËºÒ¤¤¤¢¤ì¡ª $%s ¤Ç¤É¤¦¤À¡£",
89 "¥â¥ë¥´¥¹¤Ë¾ÞÌ£¤µ¤ì¤ë¤¬¤¤¤¤¡ªËÜÅö¤Ï $%s ¤Ê¤ó¤À¤í¤¦¡©",
90 "¤ªÁ°¤ÎÊì¿Æ¤Ï¥ª¡¼¥¬¤«¡ª $%s ¤Ï½Ð¤¹¤Ä¤â¤ê¤Ê¤ó¤À¤í¡©"
92 "I can take no less than %s gold pieces.",
93 "I will accept no less than %s gold pieces.",
94 "Ha! No less than %s gold pieces.",
95 "You knave! No less than %s gold pieces.",
96 "That's a pittance! I want %s gold pieces.",
97 "That's an insult! I want %s gold pieces.",
98 "As if! How about %s gold pieces?",
99 "My arse! How about %s gold pieces?",
100 "May the fleas of 1000 orcs molest you! Try %s gold pieces.",
101 "May your most favourite parts go moldy! Try %s gold pieces.",
102 "May Morgoth find you tasty! Perhaps %s gold pieces?",
103 "Your mother was an Ogre! Perhaps %s gold pieces?"
109 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇä¤ë¤È¤¡Ë */
110 static cptr comment_2b_B[MAX_COMMENT_2B] = {
111 "¤¤¤¯¤é²¶Íͤ¬¤ª¿Í¹¥¤·¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¤Í¡£·ù¤Ê¤éµ¢¤ê¤Ê¡£",
112 "¶â¤¬¤Ê¤¤¤Î¤«¤¤¡¢¤¢¤ó¤¿¡©¤Þ¤º¤Ï²È¤Ëµ¢¤Ã¤Æ $%s ·¤¨¤Æ¤¤Ê¡£",
113 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅÛ¤À¤Ê¡£¤³¤ì¤Ï $%s ¤¬ÉáÄ̤ʤó¤À¤è¡£",
114 "²¶¤ÎÉÕ¤±¤¿ÃÍÃʤËʸ¶ç¤¬¤¢¤ë¤Î¤«¡© $%s ¤¬¸Â³¦¤À¡£",
115 "¤Ò¤ç¤Ã¤È¤·¤Æ¿·¼ê¤Î¾éÃ̤«¤¤¡© $%s »ý¤Ã¤Æ¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£",
116 "¤¦¤Á¤Ï¾¤ÎŹ¤È¤Ï°ã¤¦¤ó¤À¤è¡£$%s ¤°¤é¤¤¤Ï½Ð¤·¤Ê¡£",
117 "Ç㤦µ¤¤¬¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£ $%s ¤À¤È¸À¤Ã¤Æ¤¤¤ë¤ó¤À¡£",
118 "Ïäˤʤé¤Ê¤¤¤Í¡£ $%s ¤¯¤é¤¤»ý¤Ã¤Æ¤¤¤ë¤ó¤À¤í¡©",
119 "¤Ï¡©¤Ê¤ó¤À¤½¤ê¤ã¡© $%s ¤Î´Ö°ã¤¤¤«¡¢¤Ò¤ç¤Ã¤È¤·¤Æ¡©",
120 "½Ð¸ý¤Ï¤¢¤Ã¤Á¤À¤è¡£¤½¤ì¤È¤â $%s ½Ð¤»¤ë¤Î¤«¤¤¡¢¤¢¤ó¤¿¤Ë¡£",
121 "Ì¿ÃΤ餺¤ÊÅÛ¤À¤Ê¡£ $%s ½Ð¤»¤Ðº£Æü¤Î½ê¤Ï´ªÊÛ¤·¤Æ¤ä¤ë¤è¡£",
122 "¤¦¤Á¤ÎŹ¤ÏÉÏ˳¿Í¤ªÃǤê¤À¡£ $%s ¤°¤é¤¤½Ð¤»¤Ê¤¤¤Î¤«¤¤¡©"
125 #define MAX_COMMENT_3A 2
127 static cptr comment_3a[MAX_COMMENT_3A] =
130 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
131 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
133 "You try my patience. %s is final.",
134 "My patience grows thin. %s is final."
140 #define MAX_COMMENT_3B 12
142 static cptr comment_3b[MAX_COMMENT_3B] =
145 "Ëܲ»¤ò¸À¤¦¤È $%s ¤Ç¤¤¤¤¤ó¤À¤í¡©",
147 " $%s ¤°¤é¤¤¤Ê¤é½Ð¤·¤Æ¤â¤¤¤¤¤¬¡£",
148 " $%s °Ê¾åʧ¤¦¤Ê¤ó¤Æ¹Í¤¨¤é¤ì¤Ê¤¤¤Í¡£",
149 "¤Þ¤¢Íî¤Á¤Ä¤¤¤Æ¡£ $%s ¤Ç¤É¤¦¤À¤¤¡©",
150 "¤½¤Î¥¬¥é¥¯¥¿¤Ê¤é $%s ¤Ç°ú¤¼è¤ë¤è¡£",
151 "¤½¤ì¤¸¤ã¹â¤¹¤®¤ë¡ª $%s ¤¬¤¤¤¤¤È¤³¤À¤í¡£",
152 "¤É¤¦¤»¤¤¤é¤Ê¤¤¤ó¤À¤í¡ª $%s ¤Ç¤¤¤¤¤À¤í¡©",
153 "¤À¤á¤À¤á¡ª $%s ¤¬¤º¤Ã¤È¤ª»÷¹ç¤¤¤À¤è¡£",
154 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤¬¤»¤¤¤¼¤¤¤À¡£",
155 " $%s ¤Ê¤é´ò¤·¤¤¤È¤³¤í¤À¤¬¤Ê¤¢¡£",
156 " $%s ¡¢¤½¤ì°Ê¾å¤Ï¥Ó¥¿°ìʸ½Ð¤µ¤Ê¤¤¤è¡ª"
158 "Perhaps %s gold pieces?",
159 "How about %s gold pieces?",
160 "I will pay no more than %s gold pieces.",
161 "I can afford no more than %s gold pieces.",
162 "Be reasonable. How about %s gold pieces?",
163 "I'll buy it as scrap for %s gold pieces.",
164 "That is too much! How about %s gold pieces?",
165 "That looks war surplus! Say %s gold pieces?",
166 "Never! %s is more like it.",
167 "That's an insult! %s is more like it.",
168 "%s gold pieces and be thankful for it!",
169 "%s gold pieces and not a copper more!"
175 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇ㤤¼è¤ê¡Ë */
176 static cptr comment_3b_B[MAX_COMMENT_3B] = {
177 " $%s ¤Ã¤Æ¤È¤³¤í¤À¤Í¡£¤½¤Î¤É¤¦¤·¤è¤¦¤â¤Ê¤¤¥¬¥é¥¯¥¿¤Ï¡£",
178 "¤³¤Î²¶¤¬ $%s ¤Ã¤Æ¸À¤Ã¤Æ¤¤¤ë¤ó¤À¤«¤é¡¢¤½¤ÎÄ̤ê¤Ë¤·¤¿Êý¤¬¿È¤Î¤¿¤á¤À¤¾¡£",
179 "²¶¤ÎÍ¥¤·¤µ¤Ë´Å¤¨¤ë¤Î¤â¤¤¤¤²Ã¸º¤Ë¤·¤Æ¤ª¤±¡£ $%s ¤À¡£",
180 "¤½¤ÎÉʤʤé $%s ¤ÇÇä¤Ã¤Æ¤¯¤ì¤Æ¤¤¤ë¤¬¤Í¡¢¾ï¼±¤¢¤ë¿Â»Î¤Ï¤ß¤ó¤Ê¡£",
181 "¤³¤ê¤ã¤Þ¤¿¡¢¤¬¤á¤Ä¤¤ÅÛ¤À¤Ê¡£¤¤¤¯¤é²¶¤¬²¹¸ü¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¡£",
182 " $%s ¤À¡£Ê̤˲¶¤Ï¤½¤ó¤Ê¥¬¥é¥¯¥¿Íߤ·¤¯¤Ï¤Ê¤¤¤ó¤À¤«¤é¡£",
183 "²¶¤Î´ÕÄê³Û¤¬µ¤¤ËÆþ¤é¤Ê¤¤¤Î¤«¡© $%s ¡¢·ù¤Ê¤éµ¢¤ê¤Ê¡£",
184 " $%s ¤Ç°ú¤¼è¤Ã¤Æ¤ä¤ë¤è¡£´î¤ó¤Ç¼õ¤±¼è¤ê¤Ê¡¢ÉÏ˳¿Í¡£",
185 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅۤϻÏËö¤Ë¤ª¤¨¤ó¤Ê¡£¤½¤ì¤Ï $%s ¤Ê¤ó¤À¤è¡£",
186 "¤½¤ó¤Ê¤Ë¶â¤¬Íߤ·¤¤¤Î¤«¡¢¤¢¤ó¤¿¡© $%s ¤ÇËþ¤Ǥ¤ó¤Î¤«¡©",
187 "Æþ¤ëŹ´Ö°ã¤¨¤Æ¤ó¤¸¤ã¤Ê¤¤¤Î¤«¡© $%s ¤Ç·ù¤Ê¤é¾¤ò¤¢¤¿¤Ã¤Æ¤¯¤ì¡£",
188 "²¶¤Î¸À¤¤Ãͤ˥±¥Á¤ò¤Ä¤±¤ëÅÛ¤¬¤¤¤ë¤È¤Ï¡ª ¤½¤ÎÅÙ¶»¤ËÌȤ¸¤Æ $%s ¤À¡£"
191 #define MAX_COMMENT_4A 4
193 static cptr comment_4a[MAX_COMMENT_4A] =
196 "¤â¤¦¤¿¤¯¤µ¤ó¤À¡ª²¿ÅÙ¤â»ä¤ò¤ï¤º¤é¤ï¤»¤Ê¤¤¤Ç¤¯¤ì¡ª",
197 "¤¦¤¬¡¼¡ª°ìÆü¤Î²æËý¤Î¸ÂÅÙ¤òĶ¤¨¤Æ¤¤¤ë¡ª",
198 "¤â¤¦¤¤¤¤¡ª»þ´Ö¤Î̵Â̰ʳ°¤Î¤Ê¤Ë¤â¤Î¤Ç¤â¤Ê¤¤¡ª",
199 "¤â¤¦¤ä¤Ã¤Æ¤é¤ì¤Ê¤¤¤è¡ª´é¤â¸«¤¿¤¯¤Ê¤¤¡ª"
201 "Enough! You have abused me once too often!",
202 "Arghhh! I have had enough abuse for one day!",
203 "That does it! You shall waste my time no more!",
204 "This is getting nowhere! I'm going to Londis!"
210 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¤ÎĺÅÀ¡Ë */
211 static cptr comment_4a_B[MAX_COMMENT_4A] = {
212 "¤Ê¤á¤ä¤¬¤Ã¤Æ¡ª²¹¸ü¤Ê²¶ÍͤǤâ¸Â³¦¤¬¤¢¤ë¤Ã¤Æ¤³¤È¤òÃΤ졪",
213 "²¶¤ò¤³¤³¤Þ¤ÇÅܤ餻¤Æ...Ì¿¤¬¤¢¤ë¤À¤±¤Ç¤â¤¢¤ê¤¬¤¿¤¤¤È»×¤¨¡ª",
214 "¤Õ¤¶¤±¤Æ¤ë¤Î¤«¡ªÎä¤ä¤«¤·¤Ê¤éÁê¼ê¤ò¸«¤Æ¤«¤é¤Ë¤·¤í¡ª",
215 "¤¤¤¤¤«¤²¤ó¤Ë¤·¤í¡ªº£ÅÙ¤³¤ó¤Ê¤Þ¤Í¤·¤¿¤é¤¿¤À¤¸¤ã¤ª¤«¤Í¤¨¤¾¡ª"
218 #define MAX_COMMENT_4B 4
220 static cptr comment_4b[MAX_COMMENT_4B] =
224 "²¶¤ÎÁ°¤«¤é¾Ã¤¨¼º¤»¤í¡ª",
225 "¤É¤Ã¤«¤Ë¹Ô¤Ã¤Á¤Þ¤¨¡ª",
226 "½Ð¤í¡¢½Ð¤í¡¢½Ð¤Æ¹Ô¤±¡ª"
229 "Get out of my sight!",
230 "Begone, you scoundrel!",
237 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÄɤ¤½Ð¤·¡Ë */
238 static cptr comment_4b_B[MAX_COMMENT_4B] = {
239 "ÆóÅ٤Ȥ¦¤Á¤ËÍè¤ë¤ó¤¸¤ã¤Í¤¨¡ª¡ª",
240 "¤È¤Ã¤È¤È¡¢¤É¤Ã¤«¤Ø¼º¤»¤í¡ª¡ª",
241 "º£¤¹¤°¾Ã¤¨¼º¤»¤í¡ª¡ª",
242 "½Ð¤Æ¤¤¤±¡ª½Ð¤Æ¤¤¤±¡ª¡ª"
245 #define MAX_COMMENT_5 8
247 static cptr comment_5[MAX_COMMENT_5] =
252 "¤â¤Ã¤È¿¿ÌÌÌܤ˸À¤Ã¤Æ¤¯¤ì¡ª",
253 "¸ò¾Ä¤¹¤ëµ¤¤¬¤¢¤ë¤Î¤«¤¤¡©",
254 "Îä¤ä¤«¤·¤ËÍ褿¤Î¤«¡ª",
257 "¤Õ¡¼¤à¡¢Îɤ¤Å·µ¤¤À¡£"
261 "You will have to do better than that!",
262 "Do you wish to do business or not?",
263 "You've got to be kidding!",
264 "You'd better be kidding!",
265 "You try my patience.",
266 "Hmmm, nice weather we're having."
272 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¡Ë */
273 static cptr comment_5_B[MAX_COMMENT_5] = {
274 "»þ´Ö¤Î̵Â̤À¤Ê¡¢¤³¤ì¤Ï¡£",
275 "Ìñ²ð¤Ê¤ªµÒÍͤÀ¤Ê¡ª",
276 "Ïä·¤Æʬ¤«¤ëÁê¼ê¤¸¤ã¤Ê¤µ¤½¤¦¤À¡£",
277 "Äˤ¤Ìܤˤ¢¤¤¤¿¤¤¤é¤·¤¤¤Ê¡ª",
278 "¤Ê¤ó¤Æ¶¯ÍߤÊÅÛ¤À¡ª",
280 "¤É¤¦¤·¤è¤¦¤â¤Ê¤¤ÉÏ˳¿Í¤À¡ª",
281 "·ö²Þ¤òÇä¤Ã¤Æ¤¤¤ë¤Î¤«¡©"
284 #define MAX_COMMENT_6 4
286 static cptr comment_6[MAX_COMMENT_6] =
289 "¤É¤¦¤ä¤éʹ¤´Ö°ã¤¨¤¿¤é¤·¤¤¡£",
290 "¼ºÎé¡¢¤è¤¯Ê¹¤³¤¨¤Ê¤«¤Ã¤¿¤è¡£",
291 "¤¹¤Þ¤Ê¤¤¡¢²¿¤À¤Ã¤Æ¡©",
292 "°¤¤¡¢¤â¤¦°ìÅÙ¸À¤Ã¤Æ¤¯¤ì¤ë¡©"
294 "I must have heard you wrong.",
295 "I'm sorry, I missed that.",
296 "I'm sorry, what was that?",
297 "Sorry, what was that again?"
307 static void say_comment_1(void)
312 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
313 if ( cur_store_num == STORE_BLACK ) {
314 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
317 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
320 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
324 if (one_in_(RUMOR_CHANCE))
327 msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
329 msg_print("The shopkeeper whispers something into your ear:");
337 * Continue haggling (player is buying)
339 static void say_comment_2(s32b value, int annoyed)
343 /* Prepare a string to insert */
344 sprintf(tmp_val, "%ld", (long)value);
349 /* Formatted message */
350 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
356 /* Formatted message */
358 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
359 if ( cur_store_num == STORE_BLACK ){
360 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
363 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
366 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
374 * Continue haggling (player is selling)
376 static void say_comment_3(s32b value, int annoyed)
380 /* Prepare a string to insert */
381 sprintf(tmp_val, "%ld", (long)value);
386 /* Formatted message */
387 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
393 /* Formatted message */
395 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
396 if ( cur_store_num == STORE_BLACK ){
397 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
400 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
403 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
411 * Kick 'da bum out. -RAK-
413 static void say_comment_4(void)
416 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
417 if ( cur_store_num == STORE_BLACK ){
418 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
419 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
422 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
423 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
426 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
427 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
434 * You are insulting me
436 static void say_comment_5(void)
439 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
440 if ( cur_store_num == STORE_BLACK ){
441 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
444 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
447 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
454 * That makes no sense.
456 static void say_comment_6(void)
458 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
464 * Messages for reacting to purchase prices.
467 #define MAX_COMMENT_7A 4
469 static cptr comment_7a[MAX_COMMENT_7A] =
474 "狼¤¬¤à¤»¤Óµã¤¯À¼¤¬Ê¹¤³¤¨¤ë...¡£",
475 "Ź¼ç¤¬²ù¤·¤²¤Ë¤ï¤á¤¤¤Æ¤¤¤ë¡ª"
479 "You hear someone sobbing...",
480 "The shopkeeper howls in agony!"
485 #define MAX_COMMENT_7B 4
487 static cptr comment_7b[MAX_COMMENT_7B] =
492 "Ź¼ç¤¬º¨¤á¤·¤½¤¦¤Ë¸«¤Æ¤¤¤ë¡£",
497 "The shopkeeper curses at you.",
498 "The shopkeeper glares at you."
503 #define MAX_COMMENT_7C 4
505 static cptr comment_7c[MAX_COMMENT_7C] =
509 "·¯¤¬Å·»È¤Ë¸«¤¨¤ë¤è¡ª",
510 "Ź¼ç¤¬¥¯¥¹¥¯¥¹¾Ð¤Ã¤Æ¤¤¤ë¡£",
511 "Ź¼ç¤¬ÂçÀ¼¤Ç¾Ð¤Ã¤Æ¤¤¤ë¡£"
514 "You've made my day!",
515 "The shopkeeper giggles.",
516 "The shopkeeper laughs loudly."
521 #define MAX_COMMENT_7D 4
523 static cptr comment_7d[MAX_COMMENT_7D] =
527 "¤³¤ó¤Ê¤ª¤¤¤·¤¤»×¤¤¤ò¤·¤¿¤é¡¢¿¿ÌÌÌܤËƯ¤±¤Ê¤¯¤Ê¤ë¤Ê¤¡¡£",
528 "Ź¼ç¤Ï´ò¤·¤¯¤ÆÄ·¤Í²ó¤Ã¤Æ¤¤¤ë¡£",
529 "Ź¼ç¤ÏËþÌ̤˾Фߤò¤¿¤¿¤¨¤Æ¤¤¤ë¡£"
532 "I think I'll retire!",
533 "The shopkeeper jumps for joy.",
534 "The shopkeeper smiles gleefully."
541 * Let a shop-keeper React to a purchase
543 * We paid "price", it was worth "value", and we thought it was worth "guess"
545 static void purchase_analyze(s32b price, s32b value, s32b guess)
547 /* Item was worthless, but we bought it */
548 if ((value <= 0) && (price > value))
551 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
553 chg_virtue(V_HONOUR, -1);
554 chg_virtue(V_JUSTICE, -1);
560 /* Item was cheaper than we thought, and we paid more than necessary */
561 else if ((value < guess) && (price > value))
564 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
566 chg_virtue(V_JUSTICE, -1);
568 chg_virtue(V_HONOUR, -1);
574 /* Item was a good bargain, and we got away with it */
575 else if ((value > guess) && (value < (4 * guess)) && (price < value))
578 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
581 chg_virtue(V_HONOUR, -1);
583 chg_virtue(V_HONOUR, 1);
589 /* Item was a great bargain, and we got away with it */
590 else if ((value > guess) && (price < value))
593 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
596 chg_virtue(V_HONOUR, -1);
598 chg_virtue(V_HONOUR, 1);
600 if (10 * price < value)
601 chg_virtue(V_SACRIFICE, 1);
611 * We store the current "store feat" here so everyone can access it
613 static int cur_store_feat;
617 * Buying and selling adjustments for race combinations.
618 * Entry[owner][player] gives the basic "cost inflation".
620 static byte rgold_adj[MAX_RACES][MAX_RACES] =
622 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
623 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
624 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
625 Angel, Demon, Kutar */
628 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
629 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
630 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
631 100, 120, 110, 105 },
634 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
635 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
636 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
637 110, 115, 110, 110 },
640 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
641 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
642 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
643 110, 110, 105, 110 },
646 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
647 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
648 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
649 115, 120, 105, 115 },
652 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
653 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
654 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
655 115, 110, 110, 115 },
658 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
659 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
660 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
661 115, 110, 115, 115 },
664 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
665 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
666 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
667 115, 110, 115, 115 },
670 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
671 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
672 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
673 110, 110, 115, 110 },
676 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
677 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
678 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
679 100, 110, 110, 100 },
682 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
683 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
684 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
685 110, 110, 105, 110 },
687 /* Human / Barbarian (copied from human) */
688 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
689 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
690 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
691 100, 120, 110, 100 },
693 /* Half-Ogre: theoretical, copied from half-troll */
694 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
695 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
696 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
697 110, 110, 115, 110 },
699 /* Half-Giant: theoretical, copied from half-troll */
700 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
701 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
702 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
703 110, 110, 115, 110 },
705 /* Half-Titan: theoretical, copied from High_Elf */
706 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
707 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
708 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
709 110, 110, 115, 110 },
711 /* Cyclops: theoretical, copied from half-troll */
712 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
713 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
714 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
715 110, 110, 115, 110 },
717 /* Yeek: theoretical, copied from Half-Orc */
718 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
719 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
720 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
721 115, 110, 115, 115 },
723 /* Klackon: theoretical, copied from Gnome */
724 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
725 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
726 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
727 115, 110, 115, 115 },
729 /* Kobold: theoretical, copied from Half-Orc */
730 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
731 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
732 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
733 115, 110, 115, 115 },
735 /* Nibelung: theoretical, copied from Dwarf */
736 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
737 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
738 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
739 115, 135, 115, 115 },
742 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
743 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
744 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
745 110, 101, 115, 110 },
747 /* Draconian: theoretical, copied from High_Elf */
748 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
749 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
750 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
751 110, 110, 115, 110 },
753 /* Mind Flayer: theoretical, copied from High_Elf */
754 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
755 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
756 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
757 110, 110, 115, 110 },
759 /* Imp: theoretical, copied from High_Elf */
760 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
761 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
762 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
763 110, 110, 115, 110 },
765 /* Golem: theoretical, copied from High_Elf */
766 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
767 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
768 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
769 110, 110, 115, 110 },
771 /* Skeleton: theoretical, copied from half-orc */
772 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
773 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
774 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
775 115, 110, 125, 115 },
777 /* Zombie: Theoretical, copied from half-orc */
778 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
779 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
780 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
781 115, 110, 125, 115 },
783 /* Vampire: Theoretical, copied from half-orc */
784 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
785 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
786 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
787 115, 110, 125, 115 },
789 /* Spectre: Theoretical, copied from half-orc */
790 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
791 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
792 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
793 115, 110, 125, 115 },
795 /* Sprite: Theoretical, copied from half-orc */
796 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
797 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
798 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
799 115, 110, 105, 115 },
801 /* Beastman: Theoretical, copied from half-orc */
802 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
803 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
804 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
805 115, 110, 115, 115 },
808 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
809 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
810 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
811 110, 110, 105, 110 },
814 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
815 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
816 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
820 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
821 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
822 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
823 140, 140, 140, 140 },
826 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
827 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
828 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
829 100, 120, 110, 100 },
832 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
833 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
834 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
835 110, 101, 115, 110 },
838 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
839 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
840 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
841 110, 115, 100, 110 },
844 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
845 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
846 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
847 100, 120, 110, 100 },
854 * Determine the price of an item (qty one) in a store.
856 * This function takes into account the player's charisma, and the
857 * shop-keepers friendliness, and the shop-keeper's base greed, but
858 * never lets a shop-keeper lose money in a transaction.
860 * The "greed" value should exceed 100 when the player is "buying" the
861 * item, and should be less than 100 when the player is "selling" it.
863 * Hack -- the black market always charges twice as much as it should.
865 * Charisma adjustment runs from 80 to 130
866 * Racial adjustment runs from 95 to 130
868 * Since greed/charisma/racial adjustments are centered at 100, we need
869 * to adjust (by 200) to extract a usable multiplier. Note that the
870 * "greed" value is always something (?).
872 static s32b price_item(object_type *o_ptr, int greed, bool flip)
879 /* Get the value of one of the items */
880 price = object_value(o_ptr);
882 /* Worthless items */
883 if (price <= 0) return (0L);
886 /* Compute the racial factor */
887 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
889 /* Add in the charisma factor */
890 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
896 /* Adjust for greed */
897 adjust = 100 + (300 - (greed + factor));
899 /* Never get "silly" */
900 if (adjust > 100) adjust = 100;
902 /* Mega-Hack -- Black market sucks */
903 if (cur_store_num == STORE_BLACK)
906 /* Compute the final price (with rounding) */
907 /* Hack -- prevent underflow */
908 price = (price * adjust + 50L) / 100L;
911 /* Shop is selling */
914 /* Adjust for greed */
915 adjust = 100 + ((greed + factor) - 300);
917 /* Never get "silly" */
918 if (adjust < 100) adjust = 100;
920 /* Mega-Hack -- Black market sucks */
921 if (cur_store_num == STORE_BLACK)
924 /* Compute the final price (with rounding) */
925 /* Hack -- prevent overflow */
926 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
929 /* Note -- Never become "free" */
930 if (price <= 0L) return (1L);
932 /* Return the price */
938 * Certain "cheap" objects should be created in "piles"
939 * Some objects can be sold at a "discount" (in small piles)
941 static void mass_produce(object_type *o_ptr)
946 s32b cost = object_value(o_ptr);
949 /* Analyze the type */
952 /* Food, Flasks, and Lites */
957 if (cost <= 5L) size += damroll(3, 5);
958 if (cost <= 20L) size += damroll(3, 5);
959 if (cost <= 50L) size += damroll(2, 2);
966 if (cost <= 60L) size += damroll(3, 5);
967 if (cost <= 240L) size += damroll(1, 5);
968 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
969 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
974 case TV_SORCERY_BOOK:
982 case TV_CRUSADE_BOOK:
984 case TV_HISSATSU_BOOK:
987 if (cost <= 50L) size += damroll(2, 3);
988 if (cost <= 500L) size += damroll(1, 3);
1006 if (object_is_artifact(o_ptr)) break;
1007 if (object_is_ego(o_ptr)) break;
1008 if (cost <= 10L) size += damroll(3, 5);
1009 if (cost <= 100L) size += damroll(3, 5);
1018 if (cost <= 5L) size += damroll(5, 5);
1019 if (cost <= 50L) size += damroll(5, 5);
1020 if (cost <= 500L) size += damroll(5, 5);
1026 if (cost <= 100L) size += damroll(2, 2);
1027 if (cost <= 1000L) size += damroll(2, 2);
1040 * Because many rods (and a few wands and staffs) are useful mainly
1041 * in quantity, the Black Market will occasionally have a bunch of
1048 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1050 if (cost < 1601L) size += damroll(1, 5);
1051 else if (cost < 3201L) size += damroll(1, 3);
1058 /* Pick a discount */
1063 else if (one_in_(25))
1067 else if (one_in_(150))
1071 else if (one_in_(300))
1075 else if (one_in_(500))
1081 if (o_ptr->art_name)
1083 if (cheat_peek && discount)
1086 msg_print("¥é¥ó¥À¥à¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÏÃÍ°ú¤¤Ê¤·¡£");
1088 msg_print("No discount on random artifacts.");
1095 /* Save the discount */
1096 o_ptr->discount = discount;
1098 /* Save the total pile size */
1099 o_ptr->number = size - (size * discount / 100);
1101 /* Ensure that mass-produced rods and wands get the correct pvals. */
1102 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1104 o_ptr->pval *= o_ptr->number;
1111 * Determine if a store item can "absorb" another item
1113 * See "object_similar()" for the same function for the "player"
1115 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1119 /* Hack -- Identical items cannot be stacked */
1120 if (o_ptr == j_ptr) return (0);
1122 /* Different objects cannot be stacked */
1123 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1125 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1126 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1128 /* Require many identical values */
1129 if (o_ptr->to_h != j_ptr->to_h) return (0);
1130 if (o_ptr->to_d != j_ptr->to_d) return (0);
1131 if (o_ptr->to_a != j_ptr->to_a) return (0);
1133 /* Require identical "ego-item" names */
1134 if (o_ptr->name2 != j_ptr->name2) return (0);
1136 /* Artifacts don't stack! */
1137 if (object_is_artifact(o_ptr) || object_is_artifact(j_ptr)) return (0);
1139 /* Hack -- Identical art_flags! */
1140 for (i = 0; i < TR_FLAG_SIZE; i++)
1141 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1143 /* Hack -- Never stack "powerful" items */
1144 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1146 /* Hack -- Never stack recharging items */
1147 if (o_ptr->timeout || j_ptr->timeout) return (0);
1149 /* Require many identical values */
1150 if (o_ptr->ac != j_ptr->ac) return (0);
1151 if (o_ptr->dd != j_ptr->dd) return (0);
1152 if (o_ptr->ds != j_ptr->ds) return (0);
1154 /* Hack -- Never stack chests */
1155 if (o_ptr->tval == TV_CHEST) return (0);
1156 if (o_ptr->tval == TV_STATUE) return (0);
1157 if (o_ptr->tval == TV_CAPTURE) return (0);
1159 /* Require matching discounts */
1160 if (o_ptr->discount != j_ptr->discount) return (0);
1162 /* They match, so they must be similar */
1168 * Allow a store item to absorb another item
1170 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1172 int max_num = (o_ptr->tval == TV_ROD) ?
1173 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1174 int total = o_ptr->number + j_ptr->number;
1175 int diff = (total > max_num) ? total - max_num : 0;
1177 /* Combine quantity, lose excess items */
1178 o_ptr->number = (total > max_num) ? max_num : total;
1180 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1181 if (o_ptr->tval == TV_ROD)
1183 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1186 /* Hack -- if wands are stacking, combine the charges. -LM- */
1187 if (o_ptr->tval == TV_WAND)
1189 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1195 * Check to see if the shop will be carrying too many objects -RAK-
1196 * Note that the shop, just like a player, will not accept things
1197 * it cannot hold. Before, one could "nuke" potions this way.
1199 * Return value is now int:
1201 * -1 : Can be combined to existing slot.
1202 * 1 : Cannot be combined but there are empty spaces.
1204 static int store_check_num(object_type *o_ptr)
1209 /* The "home" acts like the player */
1210 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1212 bool old_stack_force_notes = stack_force_notes;
1213 bool old_stack_force_costs = stack_force_costs;
1215 if (cur_store_num != STORE_HOME)
1217 stack_force_notes = FALSE;
1218 stack_force_costs = FALSE;
1221 /* Check all the items */
1222 for (i = 0; i < st_ptr->stock_num; i++)
1224 /* Get the existing item */
1225 j_ptr = &st_ptr->stock[i];
1227 /* Can the new object be combined with the old one? */
1228 if (object_similar(j_ptr, o_ptr))
1230 if (cur_store_num != STORE_HOME)
1232 stack_force_notes = old_stack_force_notes;
1233 stack_force_costs = old_stack_force_costs;
1240 if (cur_store_num != STORE_HOME)
1242 stack_force_notes = old_stack_force_notes;
1243 stack_force_costs = old_stack_force_costs;
1247 /* Normal stores do special stuff */
1250 /* Check all the items */
1251 for (i = 0; i < st_ptr->stock_num; i++)
1253 /* Get the existing item */
1254 j_ptr = &st_ptr->stock[i];
1256 /* Can the new object be combined with the old one? */
1257 if (store_object_similar(j_ptr, o_ptr)) return -1;
1261 /* Free space is always usable */
1263 * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1264 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1266 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1267 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1272 if (st_ptr->stock_num < st_ptr->stock_size) {
1277 /* But there was no room at the inn... */
1282 static bool is_blessed(object_type *o_ptr)
1284 u32b flgs[TR_FLAG_SIZE];
1285 object_flags(o_ptr, flgs);
1286 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1287 else return (FALSE);
1293 * Determine if the current store will purchase the given item
1295 * Note that a shop-keeper must refuse to buy "worthless" items
1297 static bool store_will_buy(object_type *o_ptr)
1299 /* Hack -- The Home is simple */
1300 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1302 /* Switch on the store */
1303 switch (cur_store_num)
1308 /* Analyze the type */
1309 switch (o_ptr->tval)
1312 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1324 case TV_BOTTLE: /* 'Green', recycling Angband */
1339 /* Analyze the type */
1340 switch (o_ptr->tval)
1361 /* Analyze the type */
1362 switch (o_ptr->tval)
1371 case TV_HISSATSU_BOOK:
1375 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1387 /* Analyze the type */
1388 switch (o_ptr->tval)
1391 case TV_CRUSADE_BOOK:
1401 monster_race *r_ptr = &r_info[o_ptr->pval];
1404 if (!(r_ptr->flags3 & RF3_EVIL))
1407 if (r_ptr->flags3 & RF3_GOOD) break;
1409 /* Accept animals */
1410 if (r_ptr->flags3 & RF3_ANIMAL) break;
1413 if (my_strchr("?!", r_ptr->d_char)) break;
1419 if (is_blessed(o_ptr)) break;
1428 case STORE_ALCHEMIST:
1430 /* Analyze the type */
1431 switch (o_ptr->tval)
1445 /* Analyze the type */
1446 switch (o_ptr->tval)
1448 case TV_SORCERY_BOOK:
1449 case TV_NATURE_BOOK:
1453 case TV_ARCANE_BOOK:
1455 case TV_DAEMON_BOOK:
1469 if(o_ptr->sval == SV_WIZSTAFF) break;
1470 else return (FALSE);
1477 /* Bookstore Shop */
1480 /* Analyze the type */
1481 switch (o_ptr->tval)
1483 case TV_SORCERY_BOOK:
1484 case TV_NATURE_BOOK:
1489 case TV_ARCANE_BOOK:
1491 case TV_DAEMON_BOOK:
1492 case TV_CRUSADE_BOOK:
1503 /* XXX XXX XXX Ignore "worthless" items */
1504 if (object_value(o_ptr) <= 0) return (FALSE);
1512 * Combine and reorder items in the home
1514 bool combine_and_reorder_home(int store_num)
1518 object_type forge, *o_ptr, *j_ptr;
1519 bool flag = FALSE, combined;
1520 store_type *old_st_ptr = st_ptr;
1521 bool old_stack_force_notes = stack_force_notes;
1522 bool old_stack_force_costs = stack_force_costs;
1524 st_ptr = &town[1].store[store_num];
1525 if (store_num != STORE_HOME)
1527 stack_force_notes = FALSE;
1528 stack_force_costs = FALSE;
1535 /* Combine the items in the home (backwards) */
1536 for (i = st_ptr->stock_num - 1; i > 0; i--)
1539 o_ptr = &st_ptr->stock[i];
1541 /* Skip empty items */
1542 if (!o_ptr->k_idx) continue;
1544 /* Scan the items above that item */
1545 for (j = 0; j < i; j++)
1550 j_ptr = &st_ptr->stock[j];
1552 /* Skip empty items */
1553 if (!j_ptr->k_idx) continue;
1556 * Get maximum number of the stack if these
1557 * are similar, get zero otherwise.
1559 max_num = object_similar_part(j_ptr, o_ptr);
1561 /* Can we (partialy) drop "o_ptr" onto "j_ptr"? */
1562 if (max_num && j_ptr->number < max_num)
1564 if (o_ptr->number + j_ptr->number <= max_num)
1566 /* Add together the item counts */
1567 object_absorb(j_ptr, o_ptr);
1569 /* One object is gone */
1570 st_ptr->stock_num--;
1572 /* Slide everything down */
1573 for (k = i; k < st_ptr->stock_num; k++)
1575 /* Structure copy */
1576 st_ptr->stock[k] = st_ptr->stock[k + 1];
1579 /* Erase the "final" slot */
1580 object_wipe(&st_ptr->stock[k]);
1584 int old_num = o_ptr->number;
1585 int remain = j_ptr->number + o_ptr->number - max_num;
1587 /* Add together the item counts */
1588 object_absorb(j_ptr, o_ptr);
1590 o_ptr->number = remain;
1592 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) and current timeouts together. -LM- */
1593 if (o_ptr->tval == TV_ROD)
1595 o_ptr->pval = o_ptr->pval * remain / old_num;
1596 o_ptr->timeout = o_ptr->timeout * remain / old_num;
1599 /* Hack -- if wands are stacking, combine the charges. -LM- */
1600 else if (o_ptr->tval == TV_WAND)
1602 o_ptr->pval = o_ptr->pval * remain / old_num;
1619 /* Re-order the items in the home (forwards) */
1620 for (i = 0; i < st_ptr->stock_num; i++)
1623 o_ptr = &st_ptr->stock[i];
1625 /* Skip empty slots */
1626 if (!o_ptr->k_idx) continue;
1628 /* Get the "value" of the item */
1629 o_value = object_value(o_ptr);
1631 /* Scan every occupied slot */
1632 for (j = 0; j < st_ptr->stock_num; j++)
1634 if (object_sort_comp(o_ptr, o_value, &st_ptr->stock[j])) break;
1637 /* Never move down */
1638 if (j >= i) continue;
1643 /* Get local object */
1646 /* Save a copy of the moving item */
1647 object_copy(j_ptr, &st_ptr->stock[i]);
1649 /* Slide the objects */
1650 for (k = i; k > j; k--)
1652 /* Slide the item */
1653 object_copy(&st_ptr->stock[k], &st_ptr->stock[k - 1]);
1656 /* Insert the moving item */
1657 object_copy(&st_ptr->stock[j], j_ptr);
1660 st_ptr = old_st_ptr;
1661 if (store_num != STORE_HOME)
1663 stack_force_notes = old_stack_force_notes;
1664 stack_force_costs = old_stack_force_costs;
1672 * Add the item "o_ptr" to the inventory of the "Home"
1674 * In all cases, return the slot (or -1) where the object was placed
1676 * Note that this is a hacked up version of "inven_carry()".
1678 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1679 * known, the player may have to pick stuff up and drop it again.
1681 static int home_carry(object_type *o_ptr)
1687 bool old_stack_force_notes = stack_force_notes;
1688 bool old_stack_force_costs = stack_force_costs;
1690 if (cur_store_num != STORE_HOME)
1692 stack_force_notes = FALSE;
1693 stack_force_costs = FALSE;
1696 /* Check each existing item (try to combine) */
1697 for (slot = 0; slot < st_ptr->stock_num; slot++)
1699 /* Get the existing item */
1700 j_ptr = &st_ptr->stock[slot];
1702 /* The home acts just like the player */
1703 if (object_similar(j_ptr, o_ptr))
1705 /* Save the new number of items */
1706 object_absorb(j_ptr, o_ptr);
1708 if (cur_store_num != STORE_HOME)
1710 stack_force_notes = old_stack_force_notes;
1711 stack_force_costs = old_stack_force_costs;
1719 if (cur_store_num != STORE_HOME)
1721 stack_force_notes = old_stack_force_notes;
1722 stack_force_costs = old_stack_force_costs;
1727 * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1728 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1731 if ((cur_store_num != STORE_HOME) || (powerup_home == TRUE)) {
1732 if (st_ptr->stock_num >= st_ptr->stock_size) {
1737 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1743 /* Determine the "value" of the item */
1744 value = object_value(o_ptr);
1746 /* Check existing slots to see if we must "slide" */
1747 for (slot = 0; slot < st_ptr->stock_num; slot++)
1749 if (object_sort_comp(o_ptr, value, &st_ptr->stock[slot])) break;
1752 /* Slide the others up */
1753 for (i = st_ptr->stock_num; i > slot; i--)
1755 st_ptr->stock[i] = st_ptr->stock[i-1];
1758 /* More stuff now */
1759 st_ptr->stock_num++;
1761 /* Insert the new item */
1762 st_ptr->stock[slot] = *o_ptr;
1764 chg_virtue(V_SACRIFICE, -1);
1766 (void)combine_and_reorder_home(cur_store_num);
1768 /* Return the location */
1774 * Add the item "o_ptr" to a real stores inventory.
1776 * If the item is "worthless", it is thrown away (except in the home).
1778 * If the item cannot be combined with an object already in the inventory,
1779 * make a new slot for it, and calculate its "per item" price. Note that
1780 * this price will be negative, since the price will not be "fixed" yet.
1781 * Adding an item to a "fixed" price stack will not change the fixed price.
1783 * In all cases, return the slot (or -1) where the object was placed
1785 static int store_carry(object_type *o_ptr)
1788 s32b value, j_value;
1792 /* Evaluate the object */
1793 value = object_value(o_ptr);
1795 /* Cursed/Worthless items "disappear" when sold */
1796 if (value <= 0) return (-1);
1798 /* All store items are fully *identified* */
1799 o_ptr->ident |= IDENT_MENTAL;
1801 /* Erase the inscription */
1802 o_ptr->inscription = 0;
1804 /* Erase the "feeling" */
1805 o_ptr->feeling = FEEL_NONE;
1807 /* Check each existing item (try to combine) */
1808 for (slot = 0; slot < st_ptr->stock_num; slot++)
1810 /* Get the existing item */
1811 j_ptr = &st_ptr->stock[slot];
1813 /* Can the existing items be incremented? */
1814 if (store_object_similar(j_ptr, o_ptr))
1816 /* Hack -- extra items disappear */
1817 store_object_absorb(j_ptr, o_ptr);
1825 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1828 /* Check existing slots to see if we must "slide" */
1829 for (slot = 0; slot < st_ptr->stock_num; slot++)
1832 j_ptr = &st_ptr->stock[slot];
1834 /* Objects sort by decreasing type */
1835 if (o_ptr->tval > j_ptr->tval) break;
1836 if (o_ptr->tval < j_ptr->tval) continue;
1838 /* Objects sort by increasing sval */
1839 if (o_ptr->sval < j_ptr->sval) break;
1840 if (o_ptr->sval > j_ptr->sval) continue;
1843 * Hack: otherwise identical rods sort by
1844 * increasing recharge time --dsb
1846 if (o_ptr->tval == TV_ROD)
1848 if (o_ptr->pval < j_ptr->pval) break;
1849 if (o_ptr->pval > j_ptr->pval) continue;
1852 /* Evaluate that slot */
1853 j_value = object_value(j_ptr);
1855 /* Objects sort by decreasing value */
1856 if (value > j_value) break;
1857 if (value < j_value) continue;
1860 /* Slide the others up */
1861 for (i = st_ptr->stock_num; i > slot; i--)
1863 st_ptr->stock[i] = st_ptr->stock[i-1];
1866 /* More stuff now */
1867 st_ptr->stock_num++;
1869 /* Insert the new item */
1870 st_ptr->stock[slot] = *o_ptr;
1872 /* Return the location */
1878 * Increase, by a given amount, the number of a certain item
1879 * in a certain store. This can result in zero items.
1881 static void store_item_increase(int item, int num)
1887 o_ptr = &st_ptr->stock[item];
1889 /* Verify the number */
1890 cnt = o_ptr->number + num;
1891 if (cnt > 255) cnt = 255;
1892 else if (cnt < 0) cnt = 0;
1893 num = cnt - o_ptr->number;
1895 /* Save the new number */
1896 o_ptr->number += num;
1901 * Remove a slot if it is empty
1903 static void store_item_optimize(int item)
1909 o_ptr = &st_ptr->stock[item];
1912 if (!o_ptr->k_idx) return;
1914 /* Must have no items */
1915 if (o_ptr->number) return;
1918 st_ptr->stock_num--;
1920 /* Slide everyone */
1921 for (j = item; j < st_ptr->stock_num; j++)
1923 st_ptr->stock[j] = st_ptr->stock[j + 1];
1926 /* Nuke the final slot */
1927 object_wipe(&st_ptr->stock[j]);
1932 * This function will keep 'crap' out of the black market.
1933 * Crap is defined as any item that is "available" elsewhere
1934 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1936 static bool black_market_crap(object_type *o_ptr)
1940 /* Ego items are never crap */
1941 if (object_is_ego(o_ptr)) return (FALSE);
1943 /* Good items are never crap */
1944 if (o_ptr->to_a > 0) return (FALSE);
1945 if (o_ptr->to_h > 0) return (FALSE);
1946 if (o_ptr->to_d > 0) return (FALSE);
1948 /* Check all stores */
1949 for (i = 0; i < MAX_STORES; i++)
1951 if (i == STORE_HOME) continue;
1952 if (i == STORE_MUSEUM) continue;
1954 /* Check every item in the store */
1955 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1957 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1959 /* Duplicate item "type", assume crappy */
1960 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
1970 * Attempt to delete (some of) a random item from the store
1971 * Hack -- we attempt to "maintain" piles of items when possible.
1973 static void store_delete(void)
1977 /* Pick a random slot */
1978 what = randint0(st_ptr->stock_num);
1980 /* Determine how many items are here */
1981 num = st_ptr->stock[what].number;
1983 /* Hack -- sometimes, only destroy half the items */
1984 if (randint0(100) < 50) num = (num + 1) / 2;
1986 /* Hack -- sometimes, only destroy a single item */
1987 if (randint0(100) < 50) num = 1;
1989 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
1990 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
1992 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
1995 /* Actually destroy (part of) the item */
1996 store_item_increase(what, -num);
1997 store_item_optimize(what);
2002 * Creates a random item and gives it to a store
2003 * This algorithm needs to be rethought. A lot.
2004 * Currently, "normal" stores use a pre-built array.
2006 * Note -- the "level" given to "obj_get_num()" is a "favored"
2007 * level, that is, there is a much higher chance of getting
2008 * items with a level approaching that of the given level...
2010 * Should we check for "permission" to have the given item?
2012 static void store_create(void)
2014 int i, tries, level;
2020 /* Paranoia -- no room left */
2021 if (st_ptr->stock_num >= st_ptr->stock_size) return;
2024 /* Hack -- consider up to four items */
2025 for (tries = 0; tries < 4; tries++)
2028 if (cur_store_num == STORE_BLACK)
2030 /* Pick a level for object/magic */
2031 level = 25 + randint0(25);
2033 /* Random item (usually of given level) */
2034 i = get_obj_num(level);
2036 /* Handle failure */
2043 /* Hack -- Pick an item to sell */
2044 i = st_ptr->table[randint0(st_ptr->table_num)];
2046 /* Hack -- fake level for apply_magic() */
2047 level = rand_range(1, STORE_OBJ_LEVEL);
2051 /* Get local object */
2054 /* Create a new object of the chosen kind */
2055 object_prep(q_ptr, i);
2057 /* Apply some "low-level" magic (no artifacts) */
2058 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
2060 /* Require valid object */
2061 if (!store_will_buy(q_ptr)) continue;
2063 /* Hack -- Charge lite's */
2064 if (q_ptr->tval == TV_LITE)
2066 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
2067 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
2071 /* The item is "known" */
2072 object_known(q_ptr);
2074 /* Mark it storebought */
2075 q_ptr->ident |= IDENT_STORE;
2077 /* Mega-Hack -- no chests in stores */
2078 if (q_ptr->tval == TV_CHEST) continue;
2080 /* Prune the black market */
2081 if (cur_store_num == STORE_BLACK)
2083 /* Hack -- No "crappy" items */
2084 if (black_market_crap(q_ptr)) continue;
2086 /* Hack -- No "cheap" items */
2087 if (object_value(q_ptr) < 10) continue;
2089 /* No "worthless" items */
2090 /* if (object_value(q_ptr) <= 0) continue; */
2093 /* Prune normal stores */
2096 /* No "worthless" items */
2097 if (object_value(q_ptr) <= 0) continue;
2101 /* Mass produce and/or Apply discount */
2102 mass_produce(q_ptr);
2104 /* Attempt to carry the (known) item */
2105 (void)store_carry(q_ptr);
2107 /* Definitely done */
2115 * Eliminate need to bargain if player has haggled well in the past
2117 static bool noneedtobargain(s32b minprice)
2119 s32b good = st_ptr->good_buy;
2120 s32b bad = st_ptr->bad_buy;
2122 /* Cheap items are "boring" */
2123 if (minprice < 10L) return (TRUE);
2125 /* Perfect haggling */
2126 if (good == MAX_SHORT) return (TRUE);
2128 /* Reward good haggles, punish bad haggles, notice price */
2129 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
2131 /* Return the flag */
2137 * Update the bargain info
2139 static void updatebargain(s32b price, s32b minprice, int num)
2141 /* Hack -- auto-haggle */
2142 if (!manual_haggle) return;
2144 /* Cheap items are "boring" */
2145 if ((minprice/num) < 10L) return;
2147 /* Count the successful haggles */
2148 if (price == minprice)
2150 /* Just count the good haggles */
2151 if (st_ptr->good_buy < MAX_SHORT)
2157 /* Count the failed haggles */
2160 /* Just count the bad haggles */
2161 if (st_ptr->bad_buy < MAX_SHORT)
2171 * Re-displays a single store entry
2173 static void display_entry(int pos)
2179 char o_name[MAX_NLEN];
2186 o_ptr = &st_ptr->stock[pos];
2188 /* Get the "offset" */
2189 i = (pos % store_bottom);
2191 /* Label it, clear the line --(-- */
2192 (void)sprintf(out_val, "%c) ", ((i > 25) ? toupper(I2A(i - 26)) : I2A(i)));
2193 prt(out_val, i+6, 0);
2196 if (show_item_graph)
2198 byte a = object_attr(o_ptr);
2199 char c = object_char(o_ptr);
2206 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
2207 if (use_bigtile) cur_col++;
2212 /* Describe an item in the home */
2213 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2217 /* Leave room for weights, if necessary -DRS- */
2218 if (show_weights) maxwid -= 10;
2220 /* Describe the object */
2221 object_desc(o_name, o_ptr, 0);
2222 o_name[maxwid] = '\0';
2223 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2228 /* Only show the weight of an individual item */
2229 int wgt = o_ptr->weight;
2231 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2232 put_str(out_val, i+6, 67);
2234 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2235 put_str(out_val, i+6, 68);
2241 /* Describe an item (fully) in a store */
2244 /* Must leave room for the "price" */
2247 /* Leave room for weights, if necessary -DRS- */
2248 if (show_weights) maxwid -= 7;
2250 /* Describe the object (fully) */
2251 object_desc(o_name, o_ptr, 0);
2252 o_name[maxwid] = '\0';
2253 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2258 /* Only show the weight of an individual item */
2259 int wgt = o_ptr->weight;
2261 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2262 put_str(out_val, i+6, 60);
2264 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2265 put_str(out_val, i+6, 61);
2270 /* Display a "fixed" cost */
2271 if (o_ptr->ident & (IDENT_FIXED))
2273 /* Extract the "minimum" price */
2274 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2276 /* Actually draw the price (not fixed) */
2278 (void)sprintf(out_val, "%9ld¸Ç", (long)x);
2280 (void)sprintf(out_val, "%9ld F", (long)x);
2283 put_str(out_val, i+6, 68);
2286 /* Display a "taxed" cost */
2287 else if (!manual_haggle)
2289 /* Extract the "minimum" price */
2290 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2292 /* Hack -- Apply Sales Tax if needed */
2293 if (!noneedtobargain(x)) x += x / 10;
2295 /* Actually draw the price (with tax) */
2296 (void)sprintf(out_val, "%9ld ", (long)x);
2297 put_str(out_val, i+6, 68);
2300 /* Display a "haggle" cost */
2303 /* Extrect the "maximum" price */
2304 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2306 /* Actually draw the price (not fixed) */
2307 (void)sprintf(out_val, "%9ld ", (long)x);
2308 put_str(out_val, i+6, 68);
2315 * Displays a store's inventory -RAK-
2316 * All prices are listed as "per individual object". -BEN-
2318 static void display_inventory(void)
2322 /* Display the next 12 items */
2323 for (k = 0; k < store_bottom; k++)
2325 /* Do not display "dead" items */
2326 if (store_top + k >= st_ptr->stock_num) break;
2328 /* Display that line */
2329 display_entry(store_top + k);
2332 /* Erase the extra lines and the "more" prompt */
2333 for (i = k; i < store_bottom + 1; i++) prt("", i + 6, 0);
2335 /* Assume "no current page" */
2337 put_str(" ", 5, 20);
2339 put_str(" ", 5, 20);
2343 /* Visual reminder of "more items" */
2344 if (st_ptr->stock_num > store_bottom)
2346 /* Show "more" reminder (after the last item) */
2348 prt("-³¤¯-", k + 6, 3);
2350 prt("-more-", k + 6, 3);
2354 /* Indicate the "current page" */
2355 /* Trailing spaces are to display (Page xx) and (Page x) */
2357 put_str(format("(%d¥Ú¡¼¥¸) ", store_top/store_bottom + 1), 5, 20);
2359 put_str(format("(Page %d) ", store_top/store_bottom + 1), 5, 20);
2364 if (cur_store_num == STORE_HOME || cur_store_num == STORE_MUSEUM)
2366 k = st_ptr->stock_size;
2368 if (cur_store_num == STORE_HOME && !powerup_home) k /= 10;
2370 put_str(format("¥¢¥¤¥Æ¥à¿ô: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 27);
2372 put_str(format("Objects: %4d/%4d", st_ptr->stock_num, k), 19 + xtra_stock, 30);
2379 * Displays players gold -RAK-
2381 static void store_prt_gold(void)
2386 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19 + xtra_stock, 53);
2388 prt("Gold Remaining: ", 19 + xtra_stock, 53);
2392 sprintf(out_val, "%9ld", (long)p_ptr->au);
2393 prt(out_val, 19 + xtra_stock, 68);
2398 * Displays store (after clearing screen) -RAK-
2400 static void display_store(void)
2408 /* The "Home" is special */
2409 if (cur_store_num == STORE_HOME)
2411 /* Put the owner name */
2413 put_str("²æ¤¬²È", 3, 31);
2415 put_str("Your Home", 3, 30);
2419 /* Label the item descriptions */
2421 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2423 put_str("Item Description", 5, 3);
2427 /* If showing weights, show label */
2431 put_str("½Å¤µ", 5, 72);
2433 put_str("Weight", 5, 70);
2439 /* The "Home" is special */
2440 else if (cur_store_num == STORE_MUSEUM)
2442 /* Put the owner name */
2444 put_str("Çîʪ´Û", 3, 31);
2446 put_str("Museum", 3, 30);
2450 /* Label the item descriptions */
2452 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2454 put_str("Item Description", 5, 3);
2458 /* If showing weights, show label */
2462 put_str("½Å¤µ", 5, 72);
2464 put_str("Weight", 5, 70);
2473 cptr store_name = (f_name + f_info[cur_store_feat].name);
2474 cptr owner_name = (ot_ptr->owner_name);
2475 cptr race_name = race_info[ot_ptr->owner_race].title;
2477 /* Put the owner name and race */
2478 sprintf(buf, "%s (%s)", owner_name, race_name);
2479 put_str(buf, 3, 10);
2481 /* Show the max price in the store (above prices) */
2482 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2485 /* Label the item descriptions */
2487 put_str("¾¦ÉʤΰìÍ÷", 5, 7);
2489 put_str("Item Description", 5, 3);
2493 /* If showing weights, show label */
2497 put_str("½Å¤µ", 5, 62);
2499 put_str("Weight", 5, 60);
2504 /* Label the asking price (in stores) */
2506 put_str("²Á³Ê", 5, 73);
2508 put_str("Price", 5, 72);
2513 /* Display the current gold */
2516 /* Draw in the inventory */
2517 display_inventory();
2523 * Get the ID of a store item and return its value -RAK-
2525 static int get_stock(int *com_val, cptr pmt, int i, int j)
2531 #ifdef ALLOW_REPEAT /* TNB */
2533 /* Get the item index */
2534 if (repeat_pull(com_val))
2536 /* Verify the item */
2537 if ((*com_val >= i) && (*com_val <= j))
2544 #endif /* ALLOW_REPEAT -- TNB */
2546 /* Paranoia XXX XXX XXX */
2550 /* Assume failure */
2553 /* Build the prompt */
2555 hi = (j > 25) ? toupper(I2A(j - 26)) : I2A(j);
2557 (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
2558 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
2561 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2566 /* Ask until done */
2572 if (!get_com(out_val, &command, FALSE)) break;
2575 if (islower(command))
2577 else if (isupper(command))
2578 k = A2I(tolower(command)) + 26;
2582 /* Legal responses */
2583 if ((k >= i) && (k <= j))
2593 /* Clear the prompt */
2597 if (command == ESCAPE) return (FALSE);
2599 #ifdef ALLOW_REPEAT /* TNB */
2601 repeat_push(*com_val);
2603 #endif /* ALLOW_REPEAT -- TNB */
2611 * Increase the insult counter and get angry if too many -RAK-
2613 static int increase_insults(void)
2615 /* Increase insults */
2616 st_ptr->insult_cur++;
2618 /* Become insulted */
2619 if (st_ptr->insult_cur > ot_ptr->insult_max)
2625 st_ptr->insult_cur = 0;
2626 st_ptr->good_buy = 0;
2627 st_ptr->bad_buy = 0;
2630 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2642 * Decrease insults -RAK-
2644 static void decrease_insults(void)
2646 /* Decrease insults */
2647 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2652 * Have insulted while haggling -RAK-
2654 static int haggle_insults(void)
2656 /* Increase insults */
2657 if (increase_insults()) return (TRUE);
2659 /* Display and flush insult */
2668 * Mega-Hack -- Enable "increments"
2670 static bool allow_inc = FALSE;
2673 * Mega-Hack -- Last "increment" during haggling
2675 static s32b last_inc = 0L;
2681 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
2691 /* Clear old increment if necessary */
2692 if (!allow_inc) last_inc = 0L;
2699 sprintf(buf, "%s [¾µÂú] ", pmt);
2701 sprintf(buf, "%s [accept] ", pmt);
2706 /* Old (negative) increment, and not final */
2707 else if (last_inc < 0)
2710 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2712 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2717 /* Old (positive) increment, and not final */
2718 else if (last_inc > 0)
2721 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2723 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2731 sprintf(buf, "%s ", pmt);
2735 /* Paranoia XXX XXX XXX */
2739 /* Ask until done */
2744 /* Display prompt */
2748 strcpy(out_val, "");
2751 * Ask the user for a response.
2752 * Don't allow to use numpad as cursor key.
2754 res = askfor_aux(out_val, 32, FALSE);
2760 if (!res) return FALSE;
2762 /* Skip leading spaces */
2763 for (p = out_val; *p == ' '; p++) /* loop */;
2765 /* Empty response */
2768 /* Accept current price */
2776 /* Use previous increment */
2777 if (allow_inc && last_inc)
2779 *poffer += last_inc;
2784 /* Normal response */
2787 /* Extract a number */
2790 /* Handle "incremental" number */
2791 if ((*p == '+' || *p == '-'))
2793 /* Allow increments */
2796 /* Use the given "increment" */
2803 /* Handle normal number */
2806 /* Use the given "number" */
2815 msg_print("Ãͤ¬¤ª¤«¤·¤¤¤Ç¤¹¡£");
2817 msg_print("Invalid response.");
2829 * Receive an offer (from the player)
2831 * Return TRUE if offer is NOT okay
2833 static bool receive_offer(cptr pmt, s32b *poffer,
2834 s32b last_offer, int factor,
2835 s32b price, int final)
2837 /* Haggle till done */
2840 /* Get a haggle (or cancel) */
2841 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2843 /* Acceptable offer */
2844 if (((*poffer) * factor) >= (last_offer * factor)) break;
2846 /* Insult, and check for kicked out */
2847 if (haggle_insults()) return (TRUE);
2849 /* Reject offer (correctly) */
2850 (*poffer) = last_offer;
2859 * Haggling routine -RAK-
2861 * Return TRUE if purchase is NOT successful
2863 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2865 s32b cur_ask, final_ask;
2866 s32b last_offer, offer;
2868 s32b min_per, max_per;
2869 int flag, loop_flag, noneed;
2870 int annoyed = 0, final = FALSE;
2872 bool cancel = FALSE;
2875 cptr pmt = "Ä󼨲Á³Ê";
2877 cptr pmt = "Asking";
2887 /* Extract the starting offer and the final offer */
2888 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2889 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2891 /* Determine if haggling is necessary */
2892 noneed = noneedtobargain(final_ask);
2894 /* No need to haggle */
2895 if (noneed || !manual_haggle)
2897 /* No need to haggle */
2900 /* Message summary */
2902 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2904 msg_print("You eventually agree upon the price.");
2910 /* No haggle option */
2913 /* Message summary */
2915 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2917 msg_print("You quickly agree upon the price.");
2922 /* Apply Sales Tax */
2923 final_ask += final_ask / 10;
2927 cur_ask = final_ask;
2929 /* Go to final offer */
2931 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2933 pmt = "Final Offer";
2940 /* Haggle for the whole pile */
2941 cur_ask *= o_ptr->number;
2942 final_ask *= o_ptr->number;
2945 /* Haggle parameters */
2946 min_per = ot_ptr->haggle_per;
2947 max_per = min_per * 3;
2949 /* Mega-Hack -- artificial "last offer" value */
2950 last_offer = object_value(o_ptr) * o_ptr->number;
2951 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
2952 if (last_offer <= 0) last_offer = 1;
2957 /* No incremental haggling yet */
2960 /* Haggle until done */
2961 for (flag = FALSE; !flag; )
2965 while (!flag && loop_flag)
2967 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
2968 put_str(out_val, 1, 0);
2970 cancel = receive_offer("Ä󼨤¹¤ë¶â³Û? ",
2972 cancel = receive_offer("What do you offer? ",
2975 &offer, last_offer, 1, cur_ask, final);
2981 else if (offer > cur_ask)
2986 else if (offer == cur_ask)
2999 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
3002 if (haggle_insults())
3008 else if (x1 > max_per)
3011 if (x1 < max_per) x1 = max_per;
3013 x2 = rand_range(x1-2, x1+2);
3014 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
3015 /* don't let the price go up */
3020 if (cur_ask < final_ask)
3023 cur_ask = final_ask;
3025 pmt = "ºÇ½ªÄ󼨲Á³Ê";
3027 pmt = "Final Offer";
3033 (void)(increase_insults());
3038 else if (offer >= cur_ask)
3050 (void)sprintf(out_val, "Á°²ó¤ÎÄ󼨶â³Û: $%ld",
3052 (void)sprintf(out_val, "Your last offer: %ld",
3056 put_str(out_val, 1, 39);
3057 say_comment_2(cur_ask, annoyed);
3063 if (cancel) return (TRUE);
3065 /* Update bargaining info */
3066 updatebargain(*price, final_ask, o_ptr->number);
3074 * Haggling routine -RAK-
3076 * Return TRUE if purchase is NOT successful
3078 static bool sell_haggle(object_type *o_ptr, s32b *price)
3080 s32b purse, cur_ask, final_ask;
3081 s32b last_offer = 0, offer = 0;
3083 s32b min_per, max_per;
3084 int flag, loop_flag, noneed;
3085 int annoyed = 0, final = FALSE;
3086 bool cancel = FALSE;
3088 cptr pmt = "Ä󼨶â³Û";
3099 /* Obtain the starting offer and the final offer */
3100 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
3101 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
3103 /* Determine if haggling is necessary */
3104 noneed = noneedtobargain(final_ask);
3106 /* Get the owner's payout limit */
3107 purse = (s32b)(ot_ptr->max_cost);
3109 /* No need to haggle */
3110 if (noneed || !manual_haggle || (final_ask >= purse))
3112 /* Apply Sales Tax (if needed) */
3113 if (!manual_haggle && !noneed)
3115 final_ask -= final_ask / 10;
3118 /* No reason to haggle */
3119 if (final_ask >= purse)
3123 msg_print("¨ºÂ¤Ë¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3125 msg_print("You instantly agree upon the price.");
3130 /* Offer full purse */
3134 /* No need to haggle */
3139 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3141 msg_print("You eventually agree upon the price.");
3147 /* No haggle option */
3150 /* Message summary */
3152 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3154 msg_print("You quickly agree upon the price.");
3161 cur_ask = final_ask;
3166 pmt = "ºÇ½ªÄ󼨶â³Û";
3168 pmt = "Final Offer";
3173 /* Haggle for the whole pile */
3174 cur_ask *= o_ptr->number;
3175 final_ask *= o_ptr->number;
3178 /* XXX XXX XXX Display commands */
3180 /* Haggling parameters */
3181 min_per = ot_ptr->haggle_per;
3182 max_per = min_per * 3;
3184 /* Mega-Hack -- artificial "last offer" value */
3185 last_offer = object_value(o_ptr) * o_ptr->number;
3186 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3191 /* No incremental haggling yet */
3195 for (flag = FALSE; !flag; )
3201 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3202 put_str(out_val, 1, 0);
3204 cancel = receive_offer("Ä󼨤¹¤ë²Á³Ê? ",
3206 cancel = receive_offer("What price do you ask? ",
3209 &offer, last_offer, -1, cur_ask, final);
3215 else if (offer < cur_ask)
3218 /* rejected, reset offer for incremental haggling */
3221 else if (offer == cur_ask)
3232 if (flag || !loop_flag) break;
3237 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3240 if (haggle_insults())
3246 else if (x1 > max_per)
3249 if (x1 < max_per) x1 = max_per;
3251 x2 = rand_range(x1-2, x1+2);
3252 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3253 /* don't let the price go down */
3257 if (cur_ask > final_ask)
3259 cur_ask = final_ask;
3262 pmt = "ºÇ½ªÄ󼨶â³Û";
3264 pmt = "Final Offer";
3272 /* Äɲà $0 ¤ÇÇ㤤¼è¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ»ß By FIRST*/
3275 (void)(increase_insults());
3278 else if (offer <= cur_ask)
3289 (void)sprintf(out_val,
3291 "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
3293 "Your last bid %ld", (long)last_offer);
3296 put_str(out_val, 1, 39);
3297 say_comment_3(cur_ask, annoyed);
3303 if (cancel) return (TRUE);
3305 /* Update bargaining info */
3306 updatebargain(*price, final_ask, o_ptr->number);
3314 * Buy an item from a store -RAK-
3316 static void store_purchase(void)
3328 char o_name[MAX_NLEN];
3332 if (cur_store_num == STORE_MUSEUM)
3335 msg_print("Çîʪ´Û¤«¤é¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
3337 msg_print("Museum.");
3343 if (st_ptr->stock_num <= 0)
3345 if (cur_store_num == STORE_HOME)
3347 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3349 msg_print("Your home is empty.");
3354 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
3356 msg_print("I am currently out of stock.");
3363 /* Find the number of objects on this and following pages */
3364 i = (st_ptr->stock_num - store_top);
3366 /* And then restrict it to the current page */
3367 if (i > store_bottom) i = store_bottom;
3371 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
3372 switch( cur_store_num ) {
3374 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
3377 sprintf(out_val, "¤É¤ì? ");
3380 sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
3384 if (cur_store_num == STORE_HOME)
3386 sprintf(out_val, "Which item do you want to take? ");
3390 sprintf(out_val, "Which item are you interested in? ");
3395 /* Get the item number to be bought */
3396 if (!get_stock(&item, out_val, 0, i - 1)) return;
3398 /* Get the actual index */
3399 item = item + store_top;
3401 /* Get the actual item */
3402 o_ptr = &st_ptr->stock[item];
3404 /* Assume the player wants just one of them */
3407 /* Get local object */
3410 /* Get a copy of the object */
3411 object_copy(j_ptr, o_ptr);
3414 * If a rod or wand, allocate total maximum timeouts or charges
3415 * between those purchased and left on the shelf.
3417 reduce_charges(j_ptr, o_ptr->number - amt);
3419 /* Modify quantity */
3420 j_ptr->number = amt;
3422 /* Hack -- require room in pack */
3423 if (!inven_carry_okay(j_ptr))
3426 msg_print("¤½¤ó¤Ê¤Ë¥¢¥¤¥Æ¥à¤ò»ý¤Æ¤Ê¤¤¡£");
3428 msg_print("You cannot carry that many different items.");
3434 /* Determine the "best" price (per item) */
3435 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3437 /* Find out how many the player wants */
3438 if (o_ptr->number > 1)
3440 /* Hack -- note cost of "fixed" items */
3441 if ((cur_store_num != STORE_HOME) &&
3442 (o_ptr->ident & IDENT_FIXED))
3445 msg_format("°ì¤Ä¤Ë¤Ä¤ $%ld¤Ç¤¹¡£", (long)(best));
3447 msg_format("That costs %ld gold per item.", (long)(best));
3452 /* Get a quantity */
3453 amt = get_quantity(NULL, o_ptr->number);
3455 /* Allow user abort */
3456 if (amt <= 0) return;
3459 /* Get local object */
3462 /* Get desired object */
3463 object_copy(j_ptr, o_ptr);
3466 * If a rod or wand, allocate total maximum timeouts or charges
3467 * between those purchased and left on the shelf.
3469 reduce_charges(j_ptr, o_ptr->number - amt);
3471 /* Modify quantity */
3472 j_ptr->number = amt;
3474 /* Hack -- require room in pack */
3475 if (!inven_carry_okay(j_ptr))
3478 msg_print("¥¶¥Ã¥¯¤Ë¤½¤Î¥¢¥¤¥Æ¥à¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£");
3480 msg_print("You cannot carry that many items.");
3486 /* Attempt to buy it */
3487 if (cur_store_num != STORE_HOME)
3489 /* Fixed price, quick buy */
3490 if (o_ptr->ident & (IDENT_FIXED))
3495 /* Go directly to the "best" deal */
3496 price = (best * j_ptr->number);
3502 /* Describe the object (fully) */
3503 object_desc(o_name, j_ptr, 0);
3507 msg_format("%s(%c)¤ò¹ØÆþ¤¹¤ë¡£", o_name, I2A(item));
3509 msg_format("Buying %s (%c).", o_name, I2A(item));
3514 /* Haggle for a final price */
3515 choice = purchase_haggle(j_ptr, &price);
3517 /* Hack -- Got kicked out */
3518 if (st_ptr->store_open >= turn) return;
3521 /* Player wants it */
3524 /* Fix the item price (if "correctly" haggled) */
3525 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3527 /* Player can afford it */
3528 if (p_ptr->au >= price)
3533 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3534 chg_virtue(V_JUSTICE, -1);
3535 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3536 chg_virtue(V_NATURE, -1);
3544 /* Spend the money */
3547 /* Update the display */
3550 /* Hack -- buying an item makes you aware of it */
3551 object_aware(j_ptr);
3553 /* Hack -- clear the "fixed" flag from the item */
3554 j_ptr->ident &= ~(IDENT_FIXED);
3556 /* Describe the transaction */
3557 object_desc(o_name, j_ptr, 0);
3561 msg_format("%s¤ò $%ld¤Ç¹ØÆþ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3563 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3566 strcpy(record_o_name, o_name);
3569 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3570 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3571 if(record_rand_art && o_ptr->art_name)
3572 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3574 /* Erase the inscription */
3575 j_ptr->inscription = 0;
3577 /* Erase the "feeling" */
3578 j_ptr->feeling = FEEL_NONE;
3579 j_ptr->ident &= ~(IDENT_STORE);
3580 /* Give it to the player */
3581 item_new = inven_carry(j_ptr);
3583 /* Describe the final result */
3584 object_desc(o_name, &inventory[item_new], 0);
3588 msg_format("%s(%c)¤ò¼ê¤ËÆþ¤ì¤¿¡£", o_name, index_to_label(item_new));
3590 msg_format("You have %s (%c).",
3591 o_name, index_to_label(item_new));
3594 /* Auto-inscription */
3595 autopick_alter_item(item_new, FALSE);
3597 /* Now, reduce the original stack's pval. */
3598 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3600 o_ptr->pval -= j_ptr->pval;
3606 /* Note how many slots the store used to have */
3607 i = st_ptr->stock_num;
3609 /* Remove the bought items from the store */
3610 store_item_increase(item, -amt);
3611 store_item_optimize(item);
3613 /* Store is empty */
3614 if (st_ptr->stock_num == 0)
3617 if (one_in_(STORE_SHUFFLE))
3622 msg_print("Ź¼ç¤Ï°úÂष¤¿¡£");
3624 msg_print("The shopkeeper retires.");
3628 /* Shuffle the store */
3629 store_shuffle(cur_store_num);
3632 sprintf(buf, "%s (%s)",
3633 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3634 put_str(buf, 3, 10);
3635 sprintf(buf, "%s (%ld)",
3636 (f_name + f_info[cur_store_feat].name), (long)(ot_ptr->max_cost));
3645 msg_print("Ź¼ç¤Ï¿·¤¿¤Êºß¸Ë¤ò¼è¤ê½Ð¤·¤¿¡£");
3647 msg_print("The shopkeeper brings out some new stock.");
3653 for (i = 0; i < 10; i++)
3655 /* Maintain the store */
3656 store_maint(p_ptr->town_num, cur_store_num);
3662 /* Redraw everything */
3663 display_inventory();
3666 /* The item is gone */
3667 else if (st_ptr->stock_num != i)
3669 /* Pick the correct screen */
3670 if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3672 /* Redraw everything */
3673 display_inventory();
3676 /* Item is still here */
3679 /* Redraw the item */
3680 display_entry(item);
3684 /* Player cannot afford it */
3687 /* Simple message (no insult) */
3689 msg_print("¤ª¶â¤¬Â¤ê¤Þ¤»¤ó¡£");
3691 msg_print("You do not have enough gold.");
3698 /* Home is much easier */
3701 bool combined_or_reordered;
3703 /* Distribute charges of wands/rods */
3704 distribute_charges(o_ptr, j_ptr, amt);
3706 /* Give it to the player */
3707 item_new = inven_carry(j_ptr);
3709 /* Describe just the result */
3710 object_desc(o_name, &inventory[item_new], 0);
3714 msg_format("%s(%c)¤ò¼è¤Ã¤¿¡£",
3716 msg_format("You have %s (%c).",
3718 o_name, index_to_label(item_new));
3723 /* Take note if we take the last one */
3724 i = st_ptr->stock_num;
3726 /* Remove the items from the home */
3727 store_item_increase(item, -amt);
3728 store_item_optimize(item);
3730 combined_or_reordered = combine_and_reorder_home(STORE_HOME);
3732 /* Hack -- Item is still here */
3733 if (i == st_ptr->stock_num)
3735 /* Redraw everything */
3736 if (combined_or_reordered) display_inventory();
3738 /* Redraw the item */
3739 else display_entry(item);
3742 /* The item is gone */
3746 if (st_ptr->stock_num == 0) store_top = 0;
3748 /* Nothing left on that screen */
3749 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
3751 /* Redraw everything */
3752 display_inventory();
3754 chg_virtue(V_SACRIFICE, 1);
3758 /* Not kicked out */
3764 * Sell an item to the store (or home)
3766 static void store_sell(void)
3772 s32b price, value, dummy;
3781 char o_name[MAX_NLEN];
3784 /* Prepare a prompt */
3785 if (cur_store_num == STORE_HOME)
3787 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÃÖ¤¤Þ¤¹¤«? ";
3789 q = "Drop which item? ";
3792 else if (cur_store_num == STORE_MUSEUM)
3794 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ó£¤·¤Þ¤¹¤«? ";
3796 q = "Give which item? ";
3801 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÇä¤ê¤Þ¤¹¤«? ";
3803 q = "Sell which item? ";
3807 item_tester_no_ryoute = TRUE;
3808 /* Only allow items the store will buy */
3809 item_tester_hook = store_will_buy;
3812 /* ²æ¤¬²È¤Ç¤ª¤«¤·¤Ê¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¥ª¥ê¥¸¥Ê¥ë¤Î¥Ð¥°¤ò½¤Àµ */
3813 if (cur_store_num == STORE_HOME)
3816 s = "ÃÖ¤±¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3818 s = "You don't have any item to drop.";
3821 else if (cur_store_num == STORE_MUSEUM)
3824 s = "´ó£¤Ç¤¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3826 s = "You don't have any item to give.";
3832 s = "Íߤ·¤¤Êª¤¬¤Ê¤¤¤Ç¤¹¤Í¤¨¡£";
3834 s = "You have nothing that I want.";
3838 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3840 /* Get the item (in the pack) */
3843 o_ptr = &inventory[item];
3846 /* Get the item (on the floor) */
3849 o_ptr = &o_list[0 - item];
3853 /* Hack -- Cannot remove cursed items */
3854 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
3858 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¤Í¡£");
3860 msg_print("Hmmm, it seems to be cursed.");
3869 /* Assume one item */
3872 /* Find out how many the player wants (letter means "all") */
3873 if (o_ptr->number > 1)
3875 /* Get a quantity */
3876 amt = get_quantity(NULL, o_ptr->number);
3878 /* Allow user abort */
3879 if (amt <= 0) return;
3882 /* Get local object */
3885 /* Get a copy of the object */
3886 object_copy(q_ptr, o_ptr);
3888 /* Modify quantity */
3889 q_ptr->number = amt;
3892 * Hack -- If a rod or wand, allocate total maximum
3893 * timeouts or charges to those being sold. -LM-
3895 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3897 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3900 /* Get a full description */
3901 object_desc(o_name, q_ptr, 0);
3903 /* Remove any inscription, feeling for stores */
3904 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3906 q_ptr->inscription = 0;
3907 q_ptr->feeling = FEEL_NONE;
3910 /* Is there room in the store (or the home?) */
3911 if (!store_check_num(q_ptr))
3913 if (cur_store_num == STORE_HOME)
3915 msg_print("²æ¤¬²È¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤Ê¤¤¡£");
3917 msg_print("Your home is full.");
3920 else if (cur_store_num == STORE_MUSEUM)
3922 msg_print("Çîʪ´Û¤Ï¤â¤¦ËþÇÕ¤À¡£");
3924 msg_print("Museum is full.");
3929 msg_print("¤¹¤¤¤Þ¤»¤ó¤¬¡¢Å¹¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤¢¤ê¤Þ¤»¤ó¡£");
3931 msg_print("I have not the room in my store to keep it.");
3939 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3941 /* Describe the transaction */
3943 msg_format("%s(%c)¤òÇäµÑ¤¹¤ë¡£", o_name, index_to_label(item));
3945 msg_format("Selling %s (%c).", o_name, index_to_label(item));
3951 choice = sell_haggle(q_ptr, &price);
3954 if (st_ptr->store_open >= turn) return;
3966 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3967 chg_virtue(V_JUSTICE, -1);
3969 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3970 chg_virtue(V_NATURE, 1);
3973 /* Get some money */
3976 /* Update the display */
3979 /* Get the "apparent" value */
3980 dummy = object_value(q_ptr) * q_ptr->number;
3983 identify_item(o_ptr);
3985 /* Get local object */
3988 /* Get a copy of the object */
3989 object_copy(q_ptr, o_ptr);
3991 /* Modify quantity */
3992 q_ptr->number = amt;
3994 /* Make it look like to be known */
3995 q_ptr->ident |= IDENT_STORE;
3998 * Hack -- If a rod or wand, let the shopkeeper know just
3999 * how many charges he really paid for. -LM-
4001 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
4003 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
4006 /* Get the "actual" value */
4007 value = object_value(q_ptr) * q_ptr->number;
4009 /* Get the description all over again */
4010 object_desc(o_name, q_ptr, 0);
4012 /* Describe the result (in message buffer) */
4014 msg_format("%s¤ò $%ld¤ÇÇäµÑ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
4016 msg_format("You sold %s for %ld gold.", o_name, (long)price);
4019 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
4021 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
4023 /* Analyze the prices (and comment verbally) unless a figurine*/
4024 purchase_analyze(price, value, dummy);
4028 * Hack -- Allocate charges between those wands or rods sold
4029 * and retained, unless all are being sold. -LM-
4031 distribute_charges(o_ptr, q_ptr, amt);
4033 /* Reset timeouts of the sold items */
4036 /* Take the item from the player, describe the result */
4037 inven_item_increase(item, -amt);
4038 inven_item_describe(item);
4040 /* If items remain, auto-inscribe before optimizing */
4041 if (o_ptr->number > 0)
4042 autopick_alter_item(item, FALSE);
4044 inven_item_optimize(item);
4049 /* The store gets that (known) item */
4050 item_pos = store_carry(q_ptr);
4052 /* Re-display if item is now in store */
4055 store_top = (item_pos / store_bottom) * store_bottom;
4056 display_inventory();
4061 /* Player is at museum */
4062 else if (cur_store_num == STORE_MUSEUM)
4064 char o2_name[MAX_NLEN];
4065 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
4067 if (-1 == store_check_num(q_ptr))
4070 msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£");
4072 msg_print("The same object as it is already in the Museum.");
4078 msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª¡ª");
4080 msg_print("You cannot take items which is given to the Museum back!!");
4084 if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return;
4086 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
4090 identify_item(q_ptr);
4091 q_ptr->ident |= IDENT_MENTAL;
4093 /* Distribute charges of wands/rods */
4094 distribute_charges(o_ptr, q_ptr, amt);
4098 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
4100 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4105 /* Take it from the players inventory */
4106 inven_item_increase(item, -amt);
4107 inven_item_describe(item);
4108 inven_item_optimize(item);
4113 /* Let the home carry it */
4114 item_pos = home_carry(q_ptr);
4116 /* Update store display */
4119 store_top = (item_pos / store_bottom) * store_bottom;
4120 display_inventory();
4123 /* Player is at home */
4126 /* Distribute charges of wands/rods */
4127 distribute_charges(o_ptr, q_ptr, amt);
4131 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
4133 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4138 /* Take it from the players inventory */
4139 inven_item_increase(item, -amt);
4140 inven_item_describe(item);
4141 inven_item_optimize(item);
4146 /* Let the home carry it */
4147 item_pos = home_carry(q_ptr);
4149 /* Update store display */
4152 store_top = (item_pos / store_bottom) * store_bottom;
4153 display_inventory();
4157 if ((choice == 0) && (item >= INVEN_RARM))
4166 * Examine an item in a store -JDL-
4168 static void store_examine(void)
4173 char o_name[MAX_NLEN];
4178 if (st_ptr->stock_num <= 0)
4180 if (cur_store_num == STORE_HOME)
4182 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4184 msg_print("Your home is empty.");
4187 else if (cur_store_num == STORE_MUSEUM)
4189 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4191 msg_print("Museum is empty.");
4196 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
4198 msg_print("I am currently out of stock.");
4205 /* Find the number of objects on this and following pages */
4206 i = (st_ptr->stock_num - store_top);
4208 /* And then restrict it to the current page */
4209 if (i > store_bottom) i = store_bottom;
4213 sprintf(out_val, "¤É¤ì¤òÄ´¤Ù¤Þ¤¹¤«¡©");
4215 sprintf(out_val, "Which item do you want to examine? ");
4219 /* Get the item number to be examined */
4220 if (!get_stock(&item, out_val, 0, i - 1)) return;
4222 /* Get the actual index */
4223 item = item + store_top;
4225 /* Get the actual item */
4226 o_ptr = &st_ptr->stock[item];
4228 /* Require full knowledge */
4229 if (!(o_ptr->ident & IDENT_MENTAL))
4231 /* This can only happen in the home */
4233 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
4235 msg_print("You have no special knowledge about that item.");
4242 object_desc(o_name, o_ptr, 0);
4246 msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
4248 msg_format("Examining %s...", o_name);
4252 /* Describe it fully */
4253 if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL))
4255 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
4257 msg_print("You see nothing special.");
4266 * Remove an item from museum (Originally from TOband)
4268 static void museum_remove_object(void)
4273 char o_name[MAX_NLEN];
4277 if (st_ptr->stock_num <= 0)
4280 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4282 msg_print("Museum is empty.");
4288 /* Find the number of objects on this and following pages */
4289 i = st_ptr->stock_num - store_top;
4291 /* And then restrict it to the current page */
4292 if (i > store_bottom) i = store_bottom;
4296 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©");
4298 sprintf(out_val, "Which item do you want to order to remove? ");
4301 /* Get the item number to be removed */
4302 if (!get_stock(&item, out_val, 0, i - 1)) return;
4304 /* Get the actual index */
4305 item = item + store_top;
4307 /* Get the actual item */
4308 o_ptr = &st_ptr->stock[item];
4311 object_desc(o_name, o_ptr, 0);
4314 msg_print("Ÿ¼¨¤ò¤ä¤á¤µ¤»¤¿¥¢¥¤¥Æ¥à¤ÏÆóÅ٤ȸ«¤ë¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡ª");
4315 if (!get_check(format("ËÜÅö¤Ë%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤Þ¤¹¤«¡©", o_name))) return;
4317 msg_print("You cannot see items which is removed from the Museum!");
4318 if (!get_check(format("Really order to remove %s from the Museum? ", o_name))) return;
4323 msg_format("%s¤ÎŸ¼¨¤ò¤ä¤á¤µ¤»¤¿¡£", o_name);
4325 msg_format("You ordered to remove %s.", o_name);
4328 /* Remove the items from the home */
4329 store_item_increase(item, -o_ptr->number);
4330 store_item_optimize(item);
4332 (void)combine_and_reorder_home(STORE_MUSEUM);
4334 /* The item is gone */
4337 if (st_ptr->stock_num == 0) store_top = 0;
4339 /* Nothing left on that screen */
4340 else if (store_top >= st_ptr->stock_num) store_top -= store_bottom;
4342 /* Redraw everything */
4343 display_inventory();
4350 * Hack -- set this to leave the store
4352 static bool leave_store = FALSE;
4356 * Process a command in a store
4358 * Note that we must allow the use of a few "special" commands
4359 * in the stores which are not allowed in the dungeon, and we
4360 * must disable some commands which are allowed in the dungeon
4361 * but not in the stores, to prevent chaos.
4363 static void store_process_command(void)
4365 #ifdef ALLOW_REPEAT /* TNB */
4367 /* Handle repeating the last command */
4370 #endif /* ALLOW_REPEAT -- TNB */
4372 if (rogue_like_commands && command_cmd == 'l')
4374 command_cmd = 'x'; /* hack! */
4377 /* Parse the command */
4378 switch (command_cmd)
4388 /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
4391 if (st_ptr->stock_num <= store_bottom) {
4393 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4395 msg_print("Entire inventory is shown.");
4399 store_top -= store_bottom;
4400 if ( store_top < 0 )
4401 store_top = ((st_ptr->stock_num - 1 )/store_bottom) * store_bottom;
4402 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4403 if ( store_top >= store_bottom ) store_top = store_bottom;
4404 display_inventory();
4412 if (st_ptr->stock_num <= store_bottom)
4415 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4417 msg_print("Entire inventory is shown.");
4423 store_top += store_bottom;
4425 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
4426 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
4428 if ((cur_store_num == STORE_HOME) &&
4429 (powerup_home == FALSE) &&
4430 (st_ptr->stock_num >= STORE_INVEN_MAX))
4432 if (store_top >= (STORE_INVEN_MAX - 1))
4439 if (store_top >= st_ptr->stock_num) store_top = 0;
4442 display_inventory();
4455 /* Get (purchase) */
4482 /*** Inventory Commands ***/
4484 /* Wear/wield equipment */
4491 /* Take off equipment */
4498 /* Destroy an item */
4505 /* Equipment list */
4512 /* Inventory list */
4520 /*** Various commands ***/
4522 /* Identify an object */
4529 /* Hack -- toggle windows */
4532 toggle_inven_equip();
4538 /*** Use various objects ***/
4543 if ( (p_ptr->pclass == CLASS_MINDCRAFTER) ||
4544 (p_ptr->pclass == CLASS_BERSERKER) ||
4545 (p_ptr->pclass == CLASS_NINJA) ||
4546 (p_ptr->pclass == CLASS_MIRROR_MASTER)
4547 ) do_cmd_mind_browse();
4548 else if (p_ptr->pclass == CLASS_SMITH)
4550 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4551 do_cmd_magic_eater(TRUE);
4552 else if (p_ptr->pclass == CLASS_SNIPER)
4553 do_cmd_snipe_browse();
4554 else do_cmd_browse();
4558 /* Inscribe an object */
4565 /* Uninscribe an object */
4568 do_cmd_uninscribe();
4574 /*** Help and Such ***/
4583 /* Identify symbol */
4586 do_cmd_query_symbol();
4590 /* Character description */
4593 p_ptr->town_num = old_town_num;
4594 do_cmd_change_name();
4595 p_ptr->town_num = inner_town_num;
4601 /*** System Commands ***/
4603 /* Hack -- User interface */
4610 /* Single line from a pref file */
4613 p_ptr->town_num = old_town_num;
4615 p_ptr->town_num = inner_town_num;
4619 /* Interact with macros */
4622 p_ptr->town_num = old_town_num;
4624 p_ptr->town_num = inner_town_num;
4628 /* Interact with visuals */
4631 p_ptr->town_num = old_town_num;
4633 p_ptr->town_num = inner_town_num;
4637 /* Interact with colors */
4640 p_ptr->town_num = old_town_num;
4642 p_ptr->town_num = inner_town_num;
4646 /* Interact with options */
4650 (void)combine_and_reorder_home(STORE_HOME);
4656 /*** Misc Commands ***/
4672 /* Repeat level feeling */
4679 /* Show previous message */
4682 do_cmd_message_one();
4686 /* Show previous messages */
4699 /* Check artifacts, uniques etc. */
4706 /* Load "screen dump" */
4709 do_cmd_load_screen();
4713 /* Save "screen dump" */
4716 do_cmd_save_screen();
4720 /* Hack -- Unknown command */
4723 if ((cur_store_num == STORE_MUSEUM) && (command_cmd == 'r'))
4725 museum_remove_object();
4730 msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
4732 msg_print("That command does not work in stores.");
4743 * Enter a store, and interact with it.
4745 * Note that we use the standard "request_command()" function
4746 * to get a command, allowing us to use "command_arg" and all
4747 * command macros and other nifty stuff, but we use the special
4748 * "shopping" argument, to force certain commands to be converted
4749 * into other commands, normally, we convert "p" (pray) and "m"
4750 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4752 void do_cmd_store(void)
4758 bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
4762 Term_get_size(&w, &h);
4764 /* Calculate stocks per 1 page */
4765 xtra_stock = MIN(14+26, ((h > 24) ? (h - 24) : 0));
4766 store_bottom = MIN_STOCK + xtra_stock;
4768 /* Access the player grid */
4769 c_ptr = &cave[py][px];
4771 /* Verify a store */
4772 if (!cave_have_flag_grid(c_ptr, FF_STORE))
4775 msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
4777 msg_print("You see no store here.");
4783 /* Extract the store code */
4784 which = f_info[c_ptr->feat].subtype;
4786 old_town_num = p_ptr->town_num;
4787 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4788 if (dun_level) p_ptr->town_num = NO_TOWN;
4789 inner_town_num = p_ptr->town_num;
4791 /* Hack -- Check the "locked doors" */
4792 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4796 msg_print("¥É¥¢¤Ë¸°¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£");
4798 msg_print("The doors are locked.");
4801 p_ptr->town_num = old_town_num;
4805 /* Calculate the number of store maintainances since the last visit */
4806 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4808 /* Maintain the store max. 10 times */
4809 if (maintain_num > 10) maintain_num = 10;
4813 /* Maintain the store */
4814 for (i = 0; i < maintain_num; i++)
4815 store_maint(p_ptr->town_num, which);
4817 /* Save the visit */
4818 town[p_ptr->town_num].store[which].last_visit = turn;
4821 /* Forget the lite */
4824 /* Forget the view */
4828 /* Hack -- Character is in "icky" mode */
4829 character_icky = TRUE;
4832 /* No command argument */
4835 /* No repeated command */
4838 /* No automatic command */
4841 /* Do not expand macros */
4842 get_com_no_macros = TRUE;
4844 /* Save the store number */
4845 cur_store_num = which;
4847 /* Hack -- save the store feature */
4848 cur_store_feat = c_ptr->feat;
4850 /* Save the store and owner pointers */
4851 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4852 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4855 /* Start at the beginning */
4858 /* Display the store */
4862 leave_store = FALSE;
4864 /* Interact with player */
4865 while (!leave_store)
4867 /* Hack -- Clear line 1 */
4871 clear_from(20 + xtra_stock);
4874 /* Basic commands */
4876 prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21 + xtra_stock, 0);
4878 prt(" ESC) Exit from Building.", 21 + xtra_stock, 0);
4882 /* Browse if necessary */
4883 if (st_ptr->stock_num > store_bottom)
4886 prt(" -)Á°¥Ú¡¼¥¸", 22 + xtra_stock, 0);
4887 prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23 + xtra_stock, 0);
4889 prt(" -) Previous page", 22 + xtra_stock, 0);
4890 prt(" SPACE) Next page", 23 + xtra_stock, 0);
4896 if (cur_store_num == STORE_HOME)
4899 prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21 + xtra_stock, 27);
4900 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22 + xtra_stock, 27);
4901 prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
4903 prt("g) Get an item.", 21 + xtra_stock, 27);
4904 prt("d) Drop an item.", 22 + xtra_stock, 27);
4905 prt("x) eXamine an item in the home.", 23 + xtra_stock, 27);
4909 /* Museum commands */
4910 else if (cur_store_num == STORE_MUSEUM)
4913 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21 + xtra_stock, 27);
4914 prt("r) ¥¢¥¤¥Æ¥à¤ÎŸ¼¨¤ò¤ä¤á¤ë", 22 + xtra_stock, 27);
4915 prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23 + xtra_stock, 27);
4917 prt("d) Drop an item.", 21 + xtra_stock, 27);
4918 prt("r) order to Remove an item.", 22 + xtra_stock, 27);
4919 prt("x) eXamine an item in the museum.", 23 + xtra_stock, 27);
4923 /* Shop commands XXX XXX XXX */
4927 prt("p) ¾¦ÉʤòÇ㤦", 21 + xtra_stock, 30);
4928 prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22 + xtra_stock, 30);
4929 prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23 + xtra_stock,30);
4931 prt("p) Purchase an item.", 21 + xtra_stock, 30);
4932 prt("s) Sell an item.", 22 + xtra_stock, 30);
4933 prt("x) eXamine an item in the shop", 23 + xtra_stock,30);
4938 /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
4940 prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21 + xtra_stock, 56);
4942 if (rogue_like_commands)
4944 prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
4948 prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22 + xtra_stock, 56);
4951 prt("i/e) Inventry/Equipment list", 21 + xtra_stock, 56);
4953 if (rogue_like_commands)
4955 prt("w/T) Wear/Take off equipment", 22 + xtra_stock, 56);
4959 prt("w/t) Wear/Take off equipment", 22 + xtra_stock, 56);
4964 prt("¥³¥Þ¥ó¥É:", 20 + xtra_stock, 0);
4966 prt("You may: ", 20 + xtra_stock, 0);
4971 request_command(TRUE);
4973 /* Process the command */
4974 store_process_command();
4977 * Hack -- To redraw missiles damage and prices in store
4978 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
4980 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
4982 /* Hack -- Character is still in "icky" mode */
4983 character_icky = TRUE;
4991 /* XXX XXX XXX Pack Overflow */
4992 if (inventory[INVEN_PACK].k_idx)
4994 int item = INVEN_PACK;
4996 object_type *o_ptr = &inventory[item];
4998 /* Hack -- Flee from the store */
4999 if (cur_store_num != STORE_HOME)
5003 if (cur_store_num == STORE_MUSEUM)
5004 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆÇîʪ´Û¤«¤é½Ð¤¿...");
5006 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆŹ¤«¤é½Ð¤¿...");
5008 if (cur_store_num == STORE_MUSEUM)
5009 msg_print("Your pack is so full that you flee the Museum...");
5011 msg_print("Your pack is so full that you flee the store...");
5019 /* Hack -- Flee from the home */
5020 else if (!store_check_num(o_ptr))
5024 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤Æ²È¤«¤é½Ð¤¿...");
5026 msg_print("Your pack is so full that you flee your home...");
5034 /* Hack -- Drop items into the home */
5042 char o_name[MAX_NLEN];
5045 /* Give a message */
5047 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
5049 msg_print("Your pack overflows!");
5053 /* Get local object */
5056 /* Grab a copy of the item */
5057 object_copy(q_ptr, o_ptr);
5060 object_desc(o_name, q_ptr, 0);
5064 msg_format("%s¤¬Íî¤Á¤¿¡£(%c)", o_name, index_to_label(item));
5066 msg_format("You drop %s (%c).", o_name, index_to_label(item));
5070 /* Remove it from the players inventory */
5071 inven_item_increase(item, -255);
5072 inven_item_describe(item);
5073 inven_item_optimize(item);
5078 /* Let the home carry it */
5079 item_pos = home_carry(q_ptr);
5081 /* Redraw the home */
5084 store_top = (item_pos / store_bottom) * store_bottom;
5085 display_inventory();
5090 /* Hack -- Redisplay store prices if charisma changes */
5091 /* Hack -- Redraw missiles damage if player changes bow */
5092 if (need_redraw_store_inv) display_inventory();
5094 /* Hack -- get kicked out of the store */
5095 if (st_ptr->store_open >= turn) leave_store = TRUE;
5098 p_ptr->town_num = old_town_num;
5100 /* Free turn XXX XXX XXX */
5104 /* Hack -- Character is no longer in "icky" mode */
5105 character_icky = FALSE;
5108 /* Hack -- Cancel automatic command */
5111 /* Hack -- Cancel "see" mode */
5112 command_see = FALSE;
5114 /* Allow expanding macros */
5115 get_com_no_macros = FALSE;
5117 /* Flush messages XXX XXX XXX */
5121 /* Clear the screen */
5125 /* Update everything */
5126 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
5127 p_ptr->update |= (PU_MONSTERS);
5129 /* Redraw entire screen */
5130 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
5133 p_ptr->redraw |= (PR_MAP);
5136 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5142 * Shuffle one of the stores.
5144 void store_shuffle(int which)
5150 if (which == STORE_HOME) return;
5151 if (which == STORE_MUSEUM) return;
5154 /* Save the store index */
5155 cur_store_num = which;
5157 /* Activate that store */
5158 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
5161 /* Pick a new owner */
5164 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5165 if (j == st_ptr->owner) continue;
5166 for (i = 1;i < max_towns; i++)
5168 if (i == p_ptr->town_num) continue;
5169 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
5171 if (i == max_towns) break;
5174 /* Activate the new owner */
5175 ot_ptr = &owners[cur_store_num][st_ptr->owner];
5178 /* Reset the owner data */
5179 st_ptr->insult_cur = 0;
5180 st_ptr->store_open = 0;
5181 st_ptr->good_buy = 0;
5182 st_ptr->bad_buy = 0;
5185 /* Hack -- discount all the items */
5186 for (i = 0; i < st_ptr->stock_num; i++)
5191 o_ptr = &st_ptr->stock[i];
5193 if (!object_is_artifact(o_ptr))
5195 /* Hack -- Sell all non-artifact old items for "half price" */
5196 o_ptr->discount = 50;
5198 /* Hack -- Items are no longer "fixed price" */
5199 o_ptr->ident &= ~(IDENT_FIXED);
5201 /* Mega-Hack -- Note that the item is "on sale" */
5203 o_ptr->inscription = quark_add("Çä½ÐÃæ");
5205 o_ptr->inscription = quark_add("on sale");
5213 * Maintain the inventory at the stores.
5215 void store_maint(int town_num, int store_num)
5219 cur_store_num = store_num;
5222 if (store_num == STORE_HOME) return;
5223 if (store_num == STORE_MUSEUM) return;
5225 /* Activate that store */
5226 st_ptr = &town[town_num].store[store_num];
5228 /* Activate the owner */
5229 ot_ptr = &owners[store_num][st_ptr->owner];
5231 /* Store keeper forgives the player */
5232 st_ptr->insult_cur = 0;
5234 /* Mega-Hack -- prune the black market */
5235 if (store_num == STORE_BLACK)
5237 /* Destroy crappy black market items */
5238 for (j = st_ptr->stock_num - 1; j >= 0; j--)
5240 object_type *o_ptr = &st_ptr->stock[j];
5242 /* Destroy crappy items */
5243 if (black_market_crap(o_ptr))
5245 /* Destroy the item */
5246 store_item_increase(j, 0 - o_ptr->number);
5247 store_item_optimize(j);
5253 /* Choose the number of slots to keep */
5254 j = st_ptr->stock_num;
5256 /* Sell a few items */
5257 j = j - randint1(STORE_TURNOVER);
5259 /* Never keep more than "STORE_MAX_KEEP" slots */
5260 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5262 /* Always "keep" at least "STORE_MIN_KEEP" items */
5263 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5265 /* Hack -- prevent "underflow" */
5268 /* Destroy objects until only "j" slots are left */
5269 while (st_ptr->stock_num > j) store_delete();
5272 /* Choose the number of slots to fill */
5273 j = st_ptr->stock_num;
5275 /* Buy some more items */
5276 j = j + randint1(STORE_TURNOVER);
5278 /* Never keep more than "STORE_MAX_KEEP" slots */
5279 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5281 /* Always "keep" at least "STORE_MIN_KEEP" items */
5282 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5284 /* Hack -- prevent "overflow" */
5285 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
5287 /* Acquire some new items */
5288 while (st_ptr->stock_num < j) store_create();
5293 * Initialize the stores
5295 void store_init(int town_num, int store_num)
5299 cur_store_num = store_num;
5301 /* Activate that store */
5302 st_ptr = &town[town_num].store[store_num];
5310 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5311 for (i = 1;i < max_towns; i++)
5313 if (i == town_num) continue;
5314 if (st_ptr->owner == town[i].store[store_num].owner) break;
5316 if (i == max_towns) break;
5319 /* Activate the new owner */
5320 ot_ptr = &owners[store_num][st_ptr->owner];
5323 /* Initialize the store */
5324 st_ptr->store_open = 0;
5325 st_ptr->insult_cur = 0;
5326 st_ptr->good_buy = 0;
5327 st_ptr->bad_buy = 0;
5329 /* Nothing in stock */
5330 st_ptr->stock_num = 0;
5333 * MEGA-HACK - Last visit to store is
5334 * BEFORE player birth to enable store restocking
5336 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5338 /* Clear any old items */
5339 for (k = 0; k < st_ptr->stock_size; k++)
5341 object_wipe(&st_ptr->stock[k]);
5346 void move_to_black_market(object_type *o_ptr)
5349 if (!p_ptr->town_num) return;
5351 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5353 o_ptr->ident |= IDENT_STORE;
5355 (void)store_carry(o_ptr);
5357 object_wipe(o_ptr); /* Don't leave a bogus object behind... */