3 /* Purpose: Store commands */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
17 /* ²¼¤ÎÊý¤«¤é°ÜÆ°¤·¤Æ¤¤Þ¤·¤¿ */
18 static int cur_store_num = 0;
19 static int store_top = 0;
20 static store_type *st_ptr = NULL;
21 static owner_type *ot_ptr = NULL;
23 #define RUMOR_CHANCE 8
25 #define MAX_COMMENT_1 6
27 static cptr comment_1[MAX_COMMENT_1] =
48 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÄɲåá¥Ã¥»¡¼¥¸¡Ê¾µÂú¡Ë */
49 static cptr comment_1_B[MAX_COMMENT_1] = {
50 "¤Þ¤¢¡¢¤½¤ì¤Ç¤¤¤¤¤ä¡£",
51 "º£Æü¤Ï¤½¤ì¤Ç´ªÊÛ¤·¤Æ¤ä¤ë¡£",
58 #define MAX_COMMENT_2A 2
60 static cptr comment_2a[MAX_COMMENT_2A] =
63 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
64 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
66 "You try my patience. %s is final.",
67 "My patience grows thin. %s is final."
72 #define MAX_COMMENT_2B 12
74 static cptr comment_2b[MAX_COMMENT_2B] =
77 " $%s ¤°¤é¤¤¤Ï½Ð¤µ¤Ê¤¤ã¥À¥á¤À¤è¡£",
78 " $%s ¤Ê¤é¼õ¤±¼è¤Ã¤Æ¤â¤¤¤¤¤¬¡£",
79 "¥Ï¡ª $%s °Ê²¼¤Ï¤Ê¤¤¤Í¡£",
80 "²¿¤ÆÅÛ¤À¡ª $%s °Ê²¼¤Ï¤¢¤êÆÀ¤Ê¤¤¤¾¡£",
81 "¤½¤ì¤¸¤ã¾¯¤Ê¤¹¤®¤ë¡ª $%s ¤ÏÍߤ·¤¤¤È¤³¤í¤À¡£",
82 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤Ï¤â¤é¤ï¤Ê¤¤¤È¡£",
83 "±³¤À¤í¤¦¡ª $%s ¤Ç¤É¤¦¤À¤¤¡©",
84 "¤ª¤¤¤ª¤¤¡ª $%s ¤ò¹Í¤¨¤Æ¤¯¤ì¤Ê¤¤¤«¡©",
85 "1000ɤ¤Î¥ª¡¼¥¯¤Î¥Î¥ß¤Ë¶ì¤·¤á¤é¤ì¤ë¤¬¤¤¤¤¡ª $%s ¤À¡£",
86 "¤ªÁ°¤ÎÂçÀڤʤâ¤Î¤ËºÒ¤¤¤¢¤ì¡ª $%s ¤Ç¤É¤¦¤À¡£",
87 "¥â¥ë¥´¥¹¤Ë¾ÞÌ£¤µ¤ì¤ë¤¬¤¤¤¤¡ªËÜÅö¤Ï $%s ¤Ê¤ó¤À¤í¤¦¡©",
88 "¤ªÁ°¤ÎÊì¿Æ¤Ï¥ª¡¼¥¬¤«¡ª $%s ¤Ï½Ð¤¹¤Ä¤â¤ê¤Ê¤ó¤À¤í¡©"
90 "I can take no less than %s gold pieces.",
91 "I will accept no less than %s gold pieces.",
92 "Ha! No less than %s gold pieces.",
93 "You knave! No less than %s gold pieces.",
94 "That's a pittance! I want %s gold pieces.",
95 "That's an insult! I want %s gold pieces.",
96 "As if! How about %s gold pieces?",
97 "My arse! How about %s gold pieces?",
98 "May the fleas of 1000 orcs molest you! Try %s gold pieces.",
99 "May your most favourite parts go moldy! Try %s gold pieces.",
100 "May Morgoth find you tasty! Perhaps %s gold pieces?",
101 "Your mother was an Ogre! Perhaps %s gold pieces?"
107 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇä¤ë¤È¤¡Ë */
108 static cptr comment_2b_B[MAX_COMMENT_2B] = {
109 "¤¤¤¯¤é²¶Íͤ¬¤ª¿Í¹¥¤·¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¤Í¡£·ù¤Ê¤éµ¢¤ê¤Ê¡£",
110 "¶â¤¬¤Ê¤¤¤Î¤«¤¤¡¢¤¢¤ó¤¿¡©¤Þ¤º¤Ï²È¤Ëµ¢¤Ã¤Æ $%s ·¤¨¤Æ¤¤Ê¡£",
111 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅÛ¤À¤Ê¡£¤³¤ì¤Ï $%s ¤¬ÉáÄ̤ʤó¤À¤è¡£",
112 "²¶¤ÎÉÕ¤±¤¿ÃÍÃʤËʸ¶ç¤¬¤¢¤ë¤Î¤«¡© $%s ¤¬¸Â³¦¤À¡£",
113 "¤Ò¤ç¤Ã¤È¤·¤Æ¿·¼ê¤Î¾éÃ̤«¤¤¡© $%s »ý¤Ã¤Æ¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£",
114 "¤¦¤Á¤Ï¾¤ÎŹ¤È¤Ï°ã¤¦¤ó¤À¤è¡£$%s ¤°¤é¤¤¤Ï½Ð¤·¤Ê¡£",
115 "Ç㤦µ¤¤¬¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£ $%s ¤À¤È¸À¤Ã¤Æ¤¤¤ë¤ó¤À¡£",
116 "Ïäˤʤé¤Ê¤¤¤Í¡£ $%s ¤¯¤é¤¤»ý¤Ã¤Æ¤¤¤ë¤ó¤À¤í¡©",
117 "¤Ï¡©¤Ê¤ó¤À¤½¤ê¤ã¡© $%s ¤Î´Ö°ã¤¤¤«¡¢¤Ò¤ç¤Ã¤È¤·¤Æ¡©",
118 "½Ð¸ý¤Ï¤¢¤Ã¤Á¤À¤è¡£¤½¤ì¤È¤â $%s ½Ð¤»¤ë¤Î¤«¤¤¡¢¤¢¤ó¤¿¤Ë¡£",
119 "Ì¿ÃΤ餺¤ÊÅÛ¤À¤Ê¡£ $%s ½Ð¤»¤Ðº£Æü¤Î½ê¤Ï´ªÊÛ¤·¤Æ¤ä¤ë¤è¡£",
120 "¤¦¤Á¤ÎŹ¤ÏÉÏ˳¿Í¤ªÃǤê¤À¡£ $%s ¤°¤é¤¤½Ð¤»¤Ê¤¤¤Î¤«¤¤¡©"
123 #define MAX_COMMENT_3A 2
125 static cptr comment_3a[MAX_COMMENT_3A] =
128 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
129 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
131 "You try my patience. %s is final.",
132 "My patience grows thin. %s is final."
138 #define MAX_COMMENT_3B 12
140 static cptr comment_3b[MAX_COMMENT_3B] =
143 "Ëܲ»¤ò¸À¤¦¤È $%s ¤Ç¤¤¤¤¤ó¤À¤í¡©",
145 " $%s ¤°¤é¤¤¤Ê¤é½Ð¤·¤Æ¤â¤¤¤¤¤¬¡£",
146 " $%s °Ê¾åʧ¤¦¤Ê¤ó¤Æ¹Í¤¨¤é¤ì¤Ê¤¤¤Í¡£",
147 "¤Þ¤¢Íî¤Á¤Ä¤¤¤Æ¡£ $%s ¤Ç¤É¤¦¤À¤¤¡©",
148 "¤½¤Î¥¬¥é¥¯¥¿¤Ê¤é $%s ¤Ç°ú¤¼è¤ë¤è¡£",
149 "¤½¤ì¤¸¤ã¹â¤¹¤®¤ë¡ª $%s ¤¬¤¤¤¤¤È¤³¤À¤í¡£",
150 "¤É¤¦¤»¤¤¤é¤Ê¤¤¤ó¤À¤í¡ª $%s ¤Ç¤¤¤¤¤À¤í¡©",
151 "¤À¤á¤À¤á¡ª $%s ¤¬¤º¤Ã¤È¤ª»÷¹ç¤¤¤À¤è¡£",
152 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤¬¤»¤¤¤¼¤¤¤À¡£",
153 " $%s ¤Ê¤é´ò¤·¤¤¤È¤³¤í¤À¤¬¤Ê¤¢¡£",
154 " $%s ¡¢¤½¤ì°Ê¾å¤Ï¥Ó¥¿°ìʸ½Ð¤µ¤Ê¤¤¤è¡ª"
156 "Perhaps %s gold pieces?",
157 "How about %s gold pieces?",
158 "I will pay no more than %s gold pieces.",
159 "I can afford no more than %s gold pieces.",
160 "Be reasonable. How about %s gold pieces?",
161 "I'll buy it as scrap for %s gold pieces.",
162 "That is too much! How about %s gold pieces?",
163 "That looks war surplus! Say %s gold pieces?",
164 "Never! %s is more like it.",
165 "That's an insult! %s is more like it.",
166 "%s gold pieces and be thankful for it!",
167 "%s gold pieces and not a copper more!"
173 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇ㤤¼è¤ê¡Ë */
174 static cptr comment_3b_B[MAX_COMMENT_3B] = {
175 " $%s ¤Ã¤Æ¤È¤³¤í¤À¤Í¡£¤½¤Î¤É¤¦¤·¤è¤¦¤â¤Ê¤¤¥¬¥é¥¯¥¿¤Ï¡£",
176 "¤³¤Î²¶¤¬ $%s ¤Ã¤Æ¸À¤Ã¤Æ¤¤¤ë¤ó¤À¤«¤é¡¢¤½¤ÎÄ̤ê¤Ë¤·¤¿Êý¤¬¿È¤Î¤¿¤á¤À¤¾¡£",
177 "²¶¤ÎÍ¥¤·¤µ¤Ë´Å¤¨¤ë¤Î¤â¤¤¤¤²Ã¸º¤Ë¤·¤Æ¤ª¤±¡£ $%s ¤À¡£",
178 "¤½¤ÎÉʤʤé $%s ¤ÇÇä¤Ã¤Æ¤¯¤ì¤Æ¤¤¤ë¤¬¤Í¡¢¾ï¼±¤¢¤ë¿Â»Î¤Ï¤ß¤ó¤Ê¡£",
179 "¤³¤ê¤ã¤Þ¤¿¡¢¤¬¤á¤Ä¤¤ÅÛ¤À¤Ê¡£¤¤¤¯¤é²¶¤¬²¹¸ü¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¡£",
180 " $%s ¤À¡£Ê̤˲¶¤Ï¤½¤ó¤Ê¥¬¥é¥¯¥¿Íߤ·¤¯¤Ï¤Ê¤¤¤ó¤À¤«¤é¡£",
181 "²¶¤Î´ÕÄê³Û¤¬µ¤¤ËÆþ¤é¤Ê¤¤¤Î¤«¡© $%s ¡¢·ù¤Ê¤éµ¢¤ê¤Ê¡£",
182 " $%s ¤Ç°ú¤¼è¤Ã¤Æ¤ä¤ë¤è¡£´î¤ó¤Ç¼õ¤±¼è¤ê¤Ê¡¢ÉÏ˳¿Í¡£",
183 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅۤϻÏËö¤Ë¤ª¤¨¤ó¤Ê¡£¤½¤ì¤Ï $%s ¤Ê¤ó¤À¤è¡£",
184 "¤½¤ó¤Ê¤Ë¶â¤¬Íߤ·¤¤¤Î¤«¡¢¤¢¤ó¤¿¡© $%s ¤ÇËþ¤Ǥ¤ó¤Î¤«¡©",
185 "Æþ¤ëŹ´Ö°ã¤¨¤Æ¤ó¤¸¤ã¤Ê¤¤¤Î¤«¡© $%s ¤Ç·ù¤Ê¤é¾¤ò¤¢¤¿¤Ã¤Æ¤¯¤ì¡£",
186 "²¶¤Î¸À¤¤Ãͤ˥±¥Á¤ò¤Ä¤±¤ëÅÛ¤¬¤¤¤ë¤È¤Ï¡ª ¤½¤ÎÅÙ¶»¤ËÌȤ¸¤Æ $%s ¤À¡£"
189 #define MAX_COMMENT_4A 4
191 static cptr comment_4a[MAX_COMMENT_4A] =
194 "¤â¤¦¤¿¤¯¤µ¤ó¤À¡ª²¿ÅÙ¤â»ä¤ò¤ï¤º¤é¤ï¤»¤Ê¤¤¤Ç¤¯¤ì¡ª",
195 "¤¦¤¬¡¼¡ª°ìÆü¤Î²æËý¤Î¸ÂÅÙ¤òĶ¤¨¤Æ¤¤¤ë¡ª",
196 "¤â¤¦¤¤¤¤¡ª»þ´Ö¤Î̵Â̰ʳ°¤Î¤Ê¤Ë¤â¤Î¤Ç¤â¤Ê¤¤¡ª",
197 "¤â¤¦¤ä¤Ã¤Æ¤é¤ì¤Ê¤¤¤è¡ª´é¤â¸«¤¿¤¯¤Ê¤¤¡ª"
199 "Enough! You have abused me once too often!",
200 "Arghhh! I have had enough abuse for one day!",
201 "That does it! You shall waste my time no more!",
202 "This is getting nowhere! I'm going to Londis!"
208 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¤ÎĺÅÀ¡Ë */
209 static cptr comment_4a_B[MAX_COMMENT_4A] = {
210 "¤Ê¤á¤ä¤¬¤Ã¤Æ¡ª²¹¸ü¤Ê²¶ÍͤǤâ¸Â³¦¤¬¤¢¤ë¤Ã¤Æ¤³¤È¤òÃΤ졪",
211 "²¶¤ò¤³¤³¤Þ¤ÇÅܤ餻¤Æ...Ì¿¤¬¤¢¤ë¤À¤±¤Ç¤â¤¢¤ê¤¬¤¿¤¤¤È»×¤¨¡ª",
212 "¤Õ¤¶¤±¤Æ¤ë¤Î¤«¡ªÎä¤ä¤«¤·¤Ê¤éÁê¼ê¤ò¸«¤Æ¤«¤é¤Ë¤·¤í¡ª",
213 "¤¤¤¤¤«¤²¤ó¤Ë¤·¤í¡ªº£ÅÙ¤³¤ó¤Ê¤Þ¤Í¤·¤¿¤é¤¿¤À¤¸¤ã¤ª¤«¤Í¤¨¤¾¡ª"
216 #define MAX_COMMENT_4B 4
218 static cptr comment_4b[MAX_COMMENT_4B] =
222 "²¶¤ÎÁ°¤«¤é¾Ã¤¨¼º¤»¤í¡ª",
223 "¤É¤Ã¤«¤Ë¹Ô¤Ã¤Á¤Þ¤¨¡ª",
224 "½Ð¤í¡¢½Ð¤í¡¢½Ð¤Æ¹Ô¤±¡ª"
227 "Get out of my sight!",
228 "Begone, you scoundrel!",
235 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÄɤ¤½Ð¤·¡Ë */
236 static cptr comment_4b_B[MAX_COMMENT_4B] = {
237 "ÆóÅ٤Ȥ¦¤Á¤ËÍè¤ë¤ó¤¸¤ã¤Í¤¨¡ª¡ª",
238 "¤È¤Ã¤È¤È¡¢¤É¤Ã¤«¤Ø¼º¤»¤í¡ª¡ª",
239 "º£¤¹¤°¾Ã¤¨¼º¤»¤í¡ª¡ª",
240 "½Ð¤Æ¤¤¤±¡ª½Ð¤Æ¤¤¤±¡ª¡ª"
243 #define MAX_COMMENT_5 8
245 static cptr comment_5[MAX_COMMENT_5] =
250 "¤â¤Ã¤È¿¿ÌÌÌܤ˸À¤Ã¤Æ¤¯¤ì¡ª",
251 "¸ò¾Ä¤¹¤ëµ¤¤¬¤¢¤ë¤Î¤«¤¤¡©",
252 "Îä¤ä¤«¤·¤ËÍ褿¤Î¤«¡ª",
255 "¤Õ¡¼¤à¡¢Îɤ¤Å·µ¤¤À¡£"
259 "You will have to do better than that!",
260 "Do you wish to do business or not?",
261 "You've got to be kidding!",
262 "You'd better be kidding!",
263 "You try my patience.",
264 "Hmmm, nice weather we're having."
270 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¡Ë */
271 static cptr comment_5_B[MAX_COMMENT_5] = {
272 "»þ´Ö¤Î̵Â̤À¤Ê¡¢¤³¤ì¤Ï¡£",
273 "Ìñ²ð¤Ê¤ªµÒÍͤÀ¤Ê¡ª",
274 "Ïä·¤Æʬ¤«¤ëÁê¼ê¤¸¤ã¤Ê¤µ¤½¤¦¤À¡£",
275 "Äˤ¤Ìܤˤ¢¤¤¤¿¤¤¤é¤·¤¤¤Ê¡ª",
276 "¤Ê¤ó¤Æ¶¯ÍߤÊÅÛ¤À¡ª",
278 "¤É¤¦¤·¤è¤¦¤â¤Ê¤¤ÉÏ˳¿Í¤À¡ª",
279 "·ö²Þ¤òÇä¤Ã¤Æ¤¤¤ë¤Î¤«¡©"
282 #define MAX_COMMENT_6 4
284 static cptr comment_6[MAX_COMMENT_6] =
287 "¤É¤¦¤ä¤éʹ¤´Ö°ã¤¨¤¿¤é¤·¤¤¡£",
288 "¼ºÎé¡¢¤è¤¯Ê¹¤³¤¨¤Ê¤«¤Ã¤¿¤è¡£",
289 "¤¹¤Þ¤Ê¤¤¡¢²¿¤À¤Ã¤Æ¡©",
290 "°¤¤¡¢¤â¤¦°ìÅÙ¸À¤Ã¤Æ¤¯¤ì¤ë¡©"
292 "I must have heard you wrong.",
293 "I'm sorry, I missed that.",
294 "I'm sorry, what was that?",
295 "Sorry, what was that again?"
305 static void say_comment_1(void)
310 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
311 if ( cur_store_num == STORE_BLACK ) {
312 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
315 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
318 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
322 if (one_in_(RUMOR_CHANCE))
325 msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
327 msg_print("The shopkeeper whispers something into your ear:");
332 if (!get_rnd_line_jonly("rumors_j.txt", 0, rumour, 10))
334 if (!get_rnd_line("rumors.txt", 0, rumour))
343 * Continue haggling (player is buying)
345 static void say_comment_2(s32b value, int annoyed)
349 /* Prepare a string to insert */
350 sprintf(tmp_val, "%ld", (long)value);
355 /* Formatted message */
356 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
362 /* Formatted message */
364 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
365 if ( cur_store_num == STORE_BLACK ){
366 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
369 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
372 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
380 * Continue haggling (player is selling)
382 static void say_comment_3(s32b value, int annoyed)
386 /* Prepare a string to insert */
387 sprintf(tmp_val, "%ld", (long)value);
392 /* Formatted message */
393 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
399 /* Formatted message */
401 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
402 if ( cur_store_num == STORE_BLACK ){
403 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
406 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
409 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
417 * Kick 'da bum out. -RAK-
419 static void say_comment_4(void)
422 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
423 if ( cur_store_num == STORE_BLACK ){
424 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
425 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
428 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
429 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
432 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
433 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
440 * You are insulting me
442 static void say_comment_5(void)
445 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
446 if ( cur_store_num == STORE_BLACK ){
447 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
450 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
453 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
460 * That makes no sense.
462 static void say_comment_6(void)
464 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
470 * Messages for reacting to purchase prices.
473 #define MAX_COMMENT_7A 4
475 static cptr comment_7a[MAX_COMMENT_7A] =
480 "狼¤¬¤à¤»¤Óµã¤¯À¼¤¬Ê¹¤³¤¨¤ë...¡£",
481 "Ź¼ç¤¬²ù¤·¤²¤Ë¤ï¤á¤¤¤Æ¤¤¤ë¡ª"
485 "You hear someone sobbing...",
486 "The shopkeeper howls in agony!"
491 #define MAX_COMMENT_7B 4
493 static cptr comment_7b[MAX_COMMENT_7B] =
498 "Ź¼ç¤¬º¨¤á¤·¤½¤¦¤Ë¸«¤Æ¤¤¤ë¡£",
503 "The shopkeeper curses at you.",
504 "The shopkeeper glares at you."
509 #define MAX_COMMENT_7C 4
511 static cptr comment_7c[MAX_COMMENT_7C] =
515 "·¯¤¬Å·»È¤Ë¸«¤¨¤ë¤è¡ª",
516 "Ź¼ç¤¬¥¯¥¹¥¯¥¹¾Ð¤Ã¤Æ¤¤¤ë¡£",
517 "Ź¼ç¤¬ÂçÀ¼¤Ç¾Ð¤Ã¤Æ¤¤¤ë¡£"
520 "You've made my day!",
521 "The shopkeeper giggles.",
522 "The shopkeeper laughs loudly."
527 #define MAX_COMMENT_7D 4
529 static cptr comment_7d[MAX_COMMENT_7D] =
533 "¤³¤ó¤Ê¤ª¤¤¤·¤¤»×¤¤¤ò¤·¤¿¤é¡¢¿¿ÌÌÌܤËƯ¤±¤Ê¤¯¤Ê¤ë¤Ê¤¡¡£",
534 "Ź¼ç¤Ï´ò¤·¤¯¤ÆÄ·¤Í²ó¤Ã¤Æ¤¤¤ë¡£",
535 "Ź¼ç¤ÏËþÌ̤˾Фߤò¤¿¤¿¤¨¤Æ¤¤¤ë¡£"
538 "I think I'll retire!",
539 "The shopkeeper jumps for joy.",
540 "The shopkeeper smiles gleefully."
547 * Let a shop-keeper React to a purchase
549 * We paid "price", it was worth "value", and we thought it was worth "guess"
551 static void purchase_analyze(s32b price, s32b value, s32b guess)
553 /* Item was worthless, but we bought it */
554 if ((value <= 0) && (price > value))
557 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
559 chg_virtue(V_HONOUR, -1);
560 chg_virtue(V_JUSTICE, -1);
566 /* Item was cheaper than we thought, and we paid more than necessary */
567 else if ((value < guess) && (price > value))
570 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
572 chg_virtue(V_JUSTICE, -1);
574 chg_virtue(V_HONOUR, -1);
580 /* Item was a good bargain, and we got away with it */
581 else if ((value > guess) && (value < (4 * guess)) && (price < value))
584 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
587 chg_virtue(V_HONOUR, -1);
589 chg_virtue(V_HONOUR, 1);
595 /* Item was a great bargain, and we got away with it */
596 else if ((value > guess) && (price < value))
599 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
602 chg_virtue(V_HONOUR, -1);
604 chg_virtue(V_HONOUR, 1);
606 if (10 * price < value)
607 chg_virtue(V_SACRIFICE, 1);
619 /* ÆüËܸìÈǤξì¹ç¤Ï¾å¤ÎÊý¤Ë°ÜÆ°¤·¤Æ¤¢¤ê¤Þ¤¹ */
622 * We store the current "store number" here so everyone can access it
624 static int cur_store_num = 7;
627 * We store the current "store page" here so everyone can access it
629 static int store_top = 0;
632 * We store the current "store pointer" here so everyone can access it
634 static store_type *st_ptr = NULL;
637 * We store the current "owner type" here so everyone can access it
639 static owner_type *ot_ptr = NULL;
649 * Buying and selling adjustments for race combinations.
650 * Entry[owner][player] gives the basic "cost inflation".
652 static byte rgold_adj[MAX_RACES][MAX_RACES] =
654 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
655 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
656 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
660 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
661 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
662 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
663 100, 120, 110, 105 },
666 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
667 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
668 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
669 110, 115, 110, 110 },
672 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
673 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
674 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
675 110, 110, 105, 110 },
678 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
679 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
680 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
681 115, 120, 105, 115 },
684 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
685 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
686 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
687 115, 110, 110, 115 },
690 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
691 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
692 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
693 115, 110, 115, 115 },
696 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
697 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
698 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
699 115, 110, 115, 115 },
702 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
703 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
704 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
705 110, 110, 115, 110 },
708 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
709 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
710 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
711 100, 110, 110, 100 },
714 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
715 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
716 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
717 110, 110, 105, 110 },
719 /* Human / Barbarian (copied from human) */
720 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
721 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
722 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
723 100, 120, 110, 100 },
725 /* Half-Ogre: theoretical, copied from half-troll */
726 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
727 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
728 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
729 110, 110, 115, 110 },
731 /* Half-Giant: theoretical, copied from half-troll */
732 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
733 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
734 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
735 110, 110, 115, 110 },
737 /* Half-Titan: theoretical, copied from High_Elf */
738 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
739 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
740 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
741 110, 110, 115, 110 },
743 /* Cyclops: theoretical, copied from half-troll */
744 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
745 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
746 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
747 110, 110, 115, 110 },
749 /* Yeek: theoretical, copied from Half-Orc */
750 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
751 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
752 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
753 115, 110, 115, 115 },
755 /* Klackon: theoretical, copied from Gnome */
756 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
757 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
758 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
759 115, 110, 115, 115 },
761 /* Kobold: theoretical, copied from Half-Orc */
762 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
763 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
764 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
765 115, 110, 115, 115 },
767 /* Nibelung: theoretical, copied from Dwarf */
768 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
769 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
770 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
771 115, 135, 115, 115 },
774 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
775 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
776 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
777 110, 101, 115, 110 },
779 /* Draconian: theoretical, copied from High_Elf */
780 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
781 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
782 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
783 110, 110, 115, 110 },
785 /* Mind Flayer: theoretical, copied from High_Elf */
786 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
787 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
788 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
789 110, 110, 115, 110 },
791 /* Imp: theoretical, copied from High_Elf */
792 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
793 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
794 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
795 110, 110, 115, 110 },
797 /* Golem: theoretical, copied from High_Elf */
798 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
799 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
800 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
801 110, 110, 115, 110 },
803 /* Skeleton: theoretical, copied from half-orc */
804 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
805 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
806 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
807 115, 110, 125, 115 },
809 /* Zombie: Theoretical, copied from half-orc */
810 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
811 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
812 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
813 115, 110, 125, 115 },
815 /* Vampire: Theoretical, copied from half-orc */
816 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
817 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
818 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
819 115, 110, 125, 115 },
821 /* Spectre: Theoretical, copied from half-orc */
822 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
823 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
824 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
825 115, 110, 125, 115 },
827 /* Sprite: Theoretical, copied from half-orc */
828 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
829 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
830 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
831 115, 110, 105, 115 },
833 /* Beastman: Theoretical, copied from half-orc */
834 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
835 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
836 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
837 115, 110, 115, 115 },
840 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
841 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
842 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
843 110, 110, 105, 110 },
846 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
847 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
848 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
852 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
853 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
854 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
855 140, 140, 140, 140 },
858 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
859 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
860 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
861 100, 120, 110, 100 },
864 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
865 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
866 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
867 110, 101, 115, 110 },
870 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
871 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
872 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
873 110, 115, 100, 110 },
876 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
877 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
878 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
879 100, 120, 110, 100 },
886 * Determine the price of an item (qty one) in a store.
888 * This function takes into account the player's charisma, and the
889 * shop-keepers friendliness, and the shop-keeper's base greed, but
890 * never lets a shop-keeper lose money in a transaction.
892 * The "greed" value should exceed 100 when the player is "buying" the
893 * item, and should be less than 100 when the player is "selling" it.
895 * Hack -- the black market always charges twice as much as it should.
897 * Charisma adjustment runs from 80 to 130
898 * Racial adjustment runs from 95 to 130
900 * Since greed/charisma/racial adjustments are centered at 100, we need
901 * to adjust (by 200) to extract a usable multiplier. Note that the
902 * "greed" value is always something (?).
904 static s32b price_item(object_type *o_ptr, int greed, bool flip)
911 /* Get the value of one of the items */
912 price = object_value(o_ptr);
914 /* Worthless items */
915 if (price <= 0) return (0L);
918 /* Compute the racial factor */
919 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
921 /* Add in the charisma factor */
922 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
928 /* Adjust for greed */
929 adjust = 100 + (300 - (greed + factor));
931 /* Never get "silly" */
932 if (adjust > 100) adjust = 100;
934 /* Mega-Hack -- Black market sucks */
935 if (cur_store_num == STORE_BLACK)
939 /* Shop is selling */
942 /* Adjust for greed */
943 adjust = 100 + ((greed + factor) - 300);
945 /* Never get "silly" */
946 if (adjust < 100) adjust = 100;
948 /* Mega-Hack -- Black market sucks */
949 if (cur_store_num == STORE_BLACK)
953 /* Compute the final price (with rounding) */
954 price = (price * adjust + 50L) / 100L;
956 /* Note -- Never become "free" */
957 if (price <= 0L) return (1L);
959 /* Return the price */
965 * Certain "cheap" objects should be created in "piles"
966 * Some objects can be sold at a "discount" (in small piles)
968 static void mass_produce(object_type *o_ptr)
973 s32b cost = object_value(o_ptr);
976 /* Analyze the type */
979 /* Food, Flasks, and Lites */
984 if (cost <= 5L) size += damroll(3, 5);
985 if (cost <= 20L) size += damroll(3, 5);
992 if (cost <= 60L) size += damroll(3, 5);
993 if (cost <= 240L) size += damroll(1, 5);
994 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
995 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
1000 case TV_SORCERY_BOOK:
1001 case TV_NATURE_BOOK:
1005 case TV_ARCANE_BOOK:
1006 case TV_ENCHANT_BOOK:
1007 case TV_DAEMON_BOOK:
1009 case TV_HISSATSU_BOOK:
1011 if (cost <= 50L) size += damroll(2, 3);
1012 if (cost <= 500L) size += damroll(1, 3);
1030 if (o_ptr->name2) break;
1031 if (cost <= 10L) size += damroll(3, 5);
1032 if (cost <= 100L) size += damroll(3, 5);
1041 if (cost <= 5L) size += damroll(5, 5);
1042 if (cost <= 50L) size += damroll(5, 5);
1043 if (cost <= 500L) size += damroll(5, 5);
1049 if (cost <= 100L) size += damroll(2, 2);
1050 if (cost <= 1000L) size += damroll(2, 2);
1063 * Because many rods (and a few wands and staffs) are useful mainly
1064 * in quantity, the Black Market will occasionally have a bunch of
1071 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1073 if (cost < 1601L) size += damroll(1, 5);
1074 else if (cost < 3201L) size += damroll(1, 3);
1077 /* Ensure that mass-produced rods and wands get the correct pvals. */
1078 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1080 o_ptr->pval *= size;
1087 /* Pick a discount */
1092 else if (one_in_(25))
1096 else if (one_in_(150))
1100 else if (one_in_(300))
1104 else if (one_in_(500))
1110 if (o_ptr->art_name)
1112 if (cheat_peek && discount)
1115 msg_print("¥é¥ó¥À¥à¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÏÃÍ°ú¤¤Ê¤·¡£");
1117 msg_print("No discount on random artifacts.");
1124 /* Save the discount */
1125 o_ptr->discount = discount;
1127 /* Save the total pile size */
1128 o_ptr->number = size - (size * discount / 100);
1134 * Determine if a store item can "absorb" another item
1136 * See "object_similar()" for the same function for the "player"
1138 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1140 /* Hack -- Identical items cannot be stacked */
1141 if (o_ptr == j_ptr) return (0);
1143 /* Different objects cannot be stacked */
1144 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1146 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1147 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1149 /* Require many identical values */
1150 if (o_ptr->to_h != j_ptr->to_h) return (0);
1151 if (o_ptr->to_d != j_ptr->to_d) return (0);
1152 if (o_ptr->to_a != j_ptr->to_a) return (0);
1154 /* Require identical "artifact" names */
1155 if (o_ptr->name1 != j_ptr->name1) return (0);
1157 /* Require identical "ego-item" names */
1158 if (o_ptr->name2 != j_ptr->name2) return (0);
1160 /* Random artifacts don't stack !*/
1161 if (o_ptr->art_name || j_ptr->art_name) return (0);
1163 /* Hack -- Identical art_flags! */
1164 if ((o_ptr->art_flags1 != j_ptr->art_flags1) ||
1165 (o_ptr->art_flags2 != j_ptr->art_flags2) ||
1166 (o_ptr->art_flags3 != j_ptr->art_flags3))
1169 /* Hack -- Never stack "powerful" items */
1170 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1172 /* Hack -- Never stack recharging items */
1173 if (o_ptr->timeout || j_ptr->timeout) return (0);
1175 /* Require many identical values */
1176 if (o_ptr->ac != j_ptr->ac) return (0);
1177 if (o_ptr->dd != j_ptr->dd) return (0);
1178 if (o_ptr->ds != j_ptr->ds) return (0);
1180 /* Hack -- Never stack chests */
1181 if (o_ptr->tval == TV_CHEST) return (0);
1182 if (o_ptr->tval == TV_STATUE) return (0);
1183 if (o_ptr->tval == TV_CAPTURE) return (0);
1185 /* Require matching discounts */
1186 if (o_ptr->discount != j_ptr->discount) return (0);
1188 /* They match, so they must be similar */
1194 * Allow a store item to absorb another item
1196 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1198 int total = o_ptr->number + j_ptr->number;
1200 /* Combine quantity, lose excess items */
1201 o_ptr->number = (total > 99) ? 99 : total;
1203 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1204 if (o_ptr->tval == TV_ROD)
1206 o_ptr->pval += j_ptr->pval;
1209 /* Hack -- if wands are stacking, combine the charges. -LM- */
1210 if (o_ptr->tval == TV_WAND)
1212 o_ptr->pval += j_ptr->pval;
1218 * Check to see if the shop will be carrying too many objects -RAK-
1219 * Note that the shop, just like a player, will not accept things
1220 * it cannot hold. Before, one could "nuke" potions this way.
1222 * Return value is now int:
1224 * -1 : Can be combined to existing slot.
1225 * 1 : Cannot be combined but there are empty spaces.
1227 static int store_check_num(object_type *o_ptr)
1232 /* The "home" acts like the player */
1233 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1235 /* Check all the items */
1236 for (i = 0; i < st_ptr->stock_num; i++)
1238 /* Get the existing item */
1239 j_ptr = &st_ptr->stock[i];
1241 /* Can the new object be combined with the old one? */
1242 if (object_similar(j_ptr, o_ptr)) return -1;
1246 /* Normal stores do special stuff */
1249 /* Check all the items */
1250 for (i = 0; i < st_ptr->stock_num; i++)
1252 /* Get the existing item */
1253 j_ptr = &st_ptr->stock[i];
1255 /* Can the new object be combined with the old one? */
1256 if (store_object_similar(j_ptr, o_ptr)) return -1;
1260 /* Free space is always usable */
1262 * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1263 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1265 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1266 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1271 if (st_ptr->stock_num < st_ptr->stock_size) {
1276 /* But there was no room at the inn... */
1281 static bool is_blessed(object_type *o_ptr)
1284 object_flags(o_ptr, &f1, &f2, &f3);
1285 if (f3 & TR3_BLESSED) return (TRUE);
1286 else return (FALSE);
1292 * Determine if the current store will purchase the given item
1294 * Note that a shop-keeper must refuse to buy "worthless" items
1296 static bool store_will_buy(object_type *o_ptr)
1298 /* Hack -- The Home is simple */
1299 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1301 /* Switch on the store */
1302 switch (cur_store_num)
1307 /* Analyze the type */
1308 switch (o_ptr->tval)
1320 case TV_BOTTLE: /* 'Green', recycling Angband */
1335 /* Analyze the type */
1336 switch (o_ptr->tval)
1357 /* Analyze the type */
1358 switch (o_ptr->tval)
1367 case TV_HISSATSU_BOOK:
1371 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1383 /* Analyze the type */
1384 switch (o_ptr->tval)
1396 monster_race *r_ptr = &r_info[o_ptr->pval];
1399 if (!(r_ptr->flags3 & RF3_EVIL))
1402 if (r_ptr->flags3 & RF3_GOOD) break;
1404 /* Accept animals */
1405 if (r_ptr->flags3 & RF3_ANIMAL) break;
1408 if (strchr("?!", r_ptr->d_char)) break;
1414 if (is_blessed(o_ptr)) break;
1423 case STORE_ALCHEMIST:
1425 /* Analyze the type */
1426 switch (o_ptr->tval)
1440 /* Analyze the type */
1441 switch (o_ptr->tval)
1443 case TV_SORCERY_BOOK:
1444 case TV_NATURE_BOOK:
1448 case TV_ARCANE_BOOK:
1449 case TV_ENCHANT_BOOK:
1450 case TV_DAEMON_BOOK:
1463 if(o_ptr->sval == SV_WIZSTAFF) break;
1464 else return (FALSE);
1471 /* Bookstore Shop */
1474 /* Analyze the type */
1475 switch (o_ptr->tval)
1477 case TV_SORCERY_BOOK:
1478 case TV_NATURE_BOOK:
1483 case TV_ARCANE_BOOK:
1484 case TV_ENCHANT_BOOK:
1485 case TV_DAEMON_BOOK:
1495 /* XXX XXX XXX Ignore "worthless" items */
1496 if (object_value(o_ptr) <= 0) return (FALSE);
1505 * Add the item "o_ptr" to the inventory of the "Home"
1507 * In all cases, return the slot (or -1) where the object was placed
1509 * Note that this is a hacked up version of "inven_carry()".
1511 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1512 * known, the player may have to pick stuff up and drop it again.
1514 static int home_carry(object_type *o_ptr)
1517 s32b value, j_value;
1522 /* Check each existing item (try to combine) */
1523 for (slot = 0; slot < st_ptr->stock_num; slot++)
1525 /* Get the existing item */
1526 j_ptr = &st_ptr->stock[slot];
1528 /* The home acts just like the player */
1529 if (object_similar(j_ptr, o_ptr))
1531 /* Save the new number of items */
1532 object_absorb(j_ptr, o_ptr);
1541 * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1542 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1545 if ( powerup_home == TRUE) {
1546 if (st_ptr->stock_num >= st_ptr->stock_size) {
1551 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1557 /* Determine the "value" of the item */
1558 value = object_value(o_ptr);
1560 /* Check existing slots to see if we must "slide" */
1561 for (slot = 0; slot < st_ptr->stock_num; slot++)
1564 j_ptr = &st_ptr->stock[slot];
1566 /* Hack -- readable books always come first */
1567 if ((o_ptr->tval == mp_ptr->spell_book) &&
1568 (j_ptr->tval != mp_ptr->spell_book)) break;
1569 if ((j_ptr->tval == mp_ptr->spell_book) &&
1570 (o_ptr->tval != mp_ptr->spell_book)) continue;
1572 /* Objects sort by decreasing type */
1573 if (o_ptr->tval > j_ptr->tval) break;
1574 if (o_ptr->tval < j_ptr->tval) continue;
1576 /* Can happen in the home */
1577 if (!object_aware_p(o_ptr)) continue;
1578 if (!object_aware_p(j_ptr)) break;
1580 /* Objects sort by increasing sval */
1581 if (o_ptr->sval < j_ptr->sval) break;
1582 if (o_ptr->sval > j_ptr->sval) continue;
1584 /* Objects in the home can be unknown */
1585 if (!object_known_p(o_ptr)) continue;
1586 if (!object_known_p(j_ptr)) break;
1589 * Hack: otherwise identical rods sort by
1590 * increasing recharge time --dsb
1592 if (o_ptr->tval == TV_ROD)
1594 if (o_ptr->pval < j_ptr->pval) break;
1595 if (o_ptr->pval > j_ptr->pval) continue;
1597 if ((o_ptr->tval == TV_CORPSE) || (o_ptr->tval == TV_FIGURINE) || (o_ptr->tval == TV_STATUE))
1599 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) break;
1600 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) break;
1603 /* Objects sort by decreasing value */
1604 j_value = object_value(j_ptr);
1605 if (value > j_value) break;
1606 if (value < j_value) continue;
1609 /* Slide the others up */
1610 for (i = st_ptr->stock_num; i > slot; i--)
1612 st_ptr->stock[i] = st_ptr->stock[i-1];
1615 /* More stuff now */
1616 st_ptr->stock_num++;
1618 /* Insert the new item */
1619 st_ptr->stock[slot] = *o_ptr;
1621 chg_virtue(V_SACRIFICE, -1);
1623 /* Return the location */
1629 * Add the item "o_ptr" to a real stores inventory.
1631 * If the item is "worthless", it is thrown away (except in the home).
1633 * If the item cannot be combined with an object already in the inventory,
1634 * make a new slot for it, and calculate its "per item" price. Note that
1635 * this price will be negative, since the price will not be "fixed" yet.
1636 * Adding an item to a "fixed" price stack will not change the fixed price.
1638 * In all cases, return the slot (or -1) where the object was placed
1640 static int store_carry(object_type *o_ptr)
1643 s32b value, j_value;
1647 /* Evaluate the object */
1648 value = object_value(o_ptr);
1650 /* Cursed/Worthless items "disappear" when sold */
1651 if (value <= 0) return (-1);
1653 /* All store items are fully *identified* */
1654 o_ptr->ident |= IDENT_MENTAL;
1656 /* Erase the inscription */
1657 o_ptr->inscription = 0;
1659 /* Erase the "feeling" */
1660 o_ptr->feeling = FEEL_NONE;
1662 /* Check each existing item (try to combine) */
1663 for (slot = 0; slot < st_ptr->stock_num; slot++)
1665 /* Get the existing item */
1666 j_ptr = &st_ptr->stock[slot];
1668 /* Can the existing items be incremented? */
1669 if (store_object_similar(j_ptr, o_ptr))
1671 /* Hack -- extra items disappear */
1672 store_object_absorb(j_ptr, o_ptr);
1680 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1683 /* Check existing slots to see if we must "slide" */
1684 for (slot = 0; slot < st_ptr->stock_num; slot++)
1687 j_ptr = &st_ptr->stock[slot];
1689 /* Objects sort by decreasing type */
1690 if (o_ptr->tval > j_ptr->tval) break;
1691 if (o_ptr->tval < j_ptr->tval) continue;
1693 /* Objects sort by increasing sval */
1694 if (o_ptr->sval < j_ptr->sval) break;
1695 if (o_ptr->sval > j_ptr->sval) continue;
1698 * Hack: otherwise identical rods sort by
1699 * increasing recharge time --dsb
1701 if (o_ptr->tval == TV_ROD)
1703 if (o_ptr->pval < j_ptr->pval) break;
1704 if (o_ptr->pval > j_ptr->pval) continue;
1707 /* Evaluate that slot */
1708 j_value = object_value(j_ptr);
1710 /* Objects sort by decreasing value */
1711 if (value > j_value) break;
1712 if (value < j_value) continue;
1715 /* Slide the others up */
1716 for (i = st_ptr->stock_num; i > slot; i--)
1718 st_ptr->stock[i] = st_ptr->stock[i-1];
1721 /* More stuff now */
1722 st_ptr->stock_num++;
1724 /* Insert the new item */
1725 st_ptr->stock[slot] = *o_ptr;
1727 /* Return the location */
1733 * Increase, by a given amount, the number of a certain item
1734 * in a certain store. This can result in zero items.
1736 static void store_item_increase(int item, int num)
1742 o_ptr = &st_ptr->stock[item];
1744 /* Verify the number */
1745 cnt = o_ptr->number + num;
1746 if (cnt > 255) cnt = 255;
1747 else if (cnt < 0) cnt = 0;
1748 num = cnt - o_ptr->number;
1750 /* Save the new number */
1751 o_ptr->number += num;
1756 * Remove a slot if it is empty
1758 static void store_item_optimize(int item)
1764 o_ptr = &st_ptr->stock[item];
1767 if (!o_ptr->k_idx) return;
1769 /* Must have no items */
1770 if (o_ptr->number) return;
1773 st_ptr->stock_num--;
1775 /* Slide everyone */
1776 for (j = item; j < st_ptr->stock_num; j++)
1778 st_ptr->stock[j] = st_ptr->stock[j + 1];
1781 /* Nuke the final slot */
1782 object_wipe(&st_ptr->stock[j]);
1787 * This function will keep 'crap' out of the black market.
1788 * Crap is defined as any item that is "available" elsewhere
1789 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1791 static bool black_market_crap(object_type *o_ptr)
1795 /* Ego items are never crap */
1796 if (o_ptr->name2) return (FALSE);
1798 /* Good items are never crap */
1799 if (o_ptr->to_a > 0) return (FALSE);
1800 if (o_ptr->to_h > 0) return (FALSE);
1801 if (o_ptr->to_d > 0) return (FALSE);
1803 /* Check all stores */
1804 for (i = 0; i < MAX_STORES; i++)
1806 if (i == STORE_HOME) continue;
1807 if (i == STORE_MUSEUM) continue;
1809 /* Check every item in the store */
1810 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1812 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1814 /* Duplicate item "type", assume crappy */
1815 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
1825 * Attempt to delete (some of) a random item from the store
1826 * Hack -- we attempt to "maintain" piles of items when possible.
1828 static void store_delete(void)
1832 /* Pick a random slot */
1833 what = randint0(st_ptr->stock_num);
1835 /* Determine how many items are here */
1836 num = st_ptr->stock[what].number;
1838 /* Hack -- sometimes, only destroy half the items */
1839 if (randint0(100) < 50) num = (num + 1) / 2;
1841 /* Hack -- sometimes, only destroy a single item */
1842 if (randint0(100) < 50) num = 1;
1844 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
1845 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
1847 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
1850 /* Actually destroy (part of) the item */
1851 store_item_increase(what, -num);
1852 store_item_optimize(what);
1857 * Creates a random item and gives it to a store
1858 * This algorithm needs to be rethought. A lot.
1859 * Currently, "normal" stores use a pre-built array.
1861 * Note -- the "level" given to "obj_get_num()" is a "favored"
1862 * level, that is, there is a much higher chance of getting
1863 * items with a level approaching that of the given level...
1865 * Should we check for "permission" to have the given item?
1867 static void store_create(void)
1869 int i, tries, level;
1875 /* Paranoia -- no room left */
1876 if (st_ptr->stock_num >= st_ptr->stock_size) return;
1879 /* Hack -- consider up to four items */
1880 for (tries = 0; tries < 4; tries++)
1883 if (cur_store_num == STORE_BLACK)
1885 /* Pick a level for object/magic */
1886 level = 25 + randint0(25);
1888 /* Random item (usually of given level) */
1889 i = get_obj_num(level);
1891 /* Handle failure */
1898 /* Hack -- Pick an item to sell */
1899 i = st_ptr->table[randint0(st_ptr->table_num)];
1901 /* Hack -- fake level for apply_magic() */
1902 level = rand_range(1, STORE_OBJ_LEVEL);
1906 /* Get local object */
1909 /* Create a new object of the chosen kind */
1910 object_prep(q_ptr, i);
1912 /* Apply some "low-level" magic (no artifacts) */
1913 apply_magic(q_ptr, level, FALSE, FALSE, FALSE, FALSE);
1915 /* Require valid object */
1916 if (!store_will_buy(q_ptr)) continue;
1918 /* Hack -- Charge lite's */
1919 if (q_ptr->tval == TV_LITE)
1921 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
1922 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
1926 /* The item is "known" */
1927 object_known(q_ptr);
1929 /* Mark it storebought */
1930 q_ptr->ident |= IDENT_STOREB;
1932 /* Mega-Hack -- no chests in stores */
1933 if (q_ptr->tval == TV_CHEST) continue;
1935 /* Prune the black market */
1936 if (cur_store_num == STORE_BLACK)
1938 /* Hack -- No "crappy" items */
1939 if (black_market_crap(q_ptr)) continue;
1941 /* Hack -- No "cheap" items */
1942 if (object_value(q_ptr) < 10) continue;
1944 /* No "worthless" items */
1945 /* if (object_value(q_ptr) <= 0) continue; */
1948 /* Prune normal stores */
1951 /* No "worthless" items */
1952 if (object_value(q_ptr) <= 0) continue;
1956 /* Mass produce and/or Apply discount */
1957 mass_produce(q_ptr);
1959 /* Attempt to carry the (known) item */
1960 (void)store_carry(q_ptr);
1962 /* Definitely done */
1970 * Eliminate need to bargain if player has haggled well in the past
1972 static bool noneedtobargain(s32b minprice)
1974 s32b good = st_ptr->good_buy;
1975 s32b bad = st_ptr->bad_buy;
1977 /* Cheap items are "boring" */
1978 if (minprice < 10L) return (TRUE);
1980 /* Perfect haggling */
1981 if (good == MAX_SHORT) return (TRUE);
1983 /* Reward good haggles, punish bad haggles, notice price */
1984 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
1986 /* Return the flag */
1992 * Update the bargain info
1994 static void updatebargain(s32b price, s32b minprice, int num)
1996 /* Hack -- auto-haggle */
1997 if (!manual_haggle) return;
1999 /* Cheap items are "boring" */
2000 if ((minprice/num) < 10L) return;
2002 /* Count the successful haggles */
2003 if (price == minprice)
2005 /* Just count the good haggles */
2006 if (st_ptr->good_buy < MAX_SHORT)
2012 /* Count the failed haggles */
2015 /* Just count the bad haggles */
2016 if (st_ptr->bad_buy < MAX_SHORT)
2026 * Re-displays a single store entry
2028 static void display_entry(int pos)
2034 char o_name[MAX_NLEN];
2041 o_ptr = &st_ptr->stock[pos];
2043 /* Get the "offset" */
2046 /* Label it, clear the line --(-- */
2047 (void)sprintf(out_val, "%c) ", I2A(i));
2048 prt(out_val, i+6, 0);
2051 if (show_item_graph)
2053 byte a = object_attr(o_ptr);
2054 char c = object_char(o_ptr);
2061 Term_draw(cur_col, i + 6, a, c);
2066 Term_draw(cur_col, i + 6, 255, 255);
2071 /* Describe an item in the home */
2072 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2076 /* Leave room for weights, if necessary -DRS- */
2077 if (show_weights) maxwid -= 10;
2079 /* Describe the object */
2080 object_desc(o_name, o_ptr, TRUE, 3);
2081 o_name[maxwid] = '\0';
2082 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2087 /* Only show the weight of an individual item */
2088 int wgt = o_ptr->weight;
2090 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2091 put_str(out_val, i+6, 67);
2093 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2094 put_str(out_val, i+6, 68);
2100 /* Describe an item (fully) in a store */
2103 /* Must leave room for the "price" */
2106 /* Leave room for weights, if necessary -DRS- */
2107 if (show_weights) maxwid -= 7;
2109 /* Describe the object (fully) */
2110 object_desc_store(o_name, o_ptr, TRUE, 3);
2111 o_name[maxwid] = '\0';
2112 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2117 /* Only show the weight of an individual item */
2118 int wgt = o_ptr->weight;
2120 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2121 put_str(out_val, i+6, 60);
2123 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2124 put_str(out_val, i+6, 61);
2129 /* Display a "fixed" cost */
2130 if (o_ptr->ident & (IDENT_FIXED))
2132 /* Extract the "minimum" price */
2133 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2135 /* Actually draw the price (not fixed) */
2137 (void)sprintf(out_val, "%9ld¸Ç", (long)x);
2139 (void)sprintf(out_val, "%9ld F", (long)x);
2142 put_str(out_val, i+6, 68);
2145 /* Display a "taxed" cost */
2146 else if (!manual_haggle)
2148 /* Extract the "minimum" price */
2149 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2151 /* Hack -- Apply Sales Tax if needed */
2152 if (!noneedtobargain(x)) x += x / 10;
2154 /* Actually draw the price (with tax) */
2155 (void)sprintf(out_val, "%9ld ", (long)x);
2156 put_str(out_val, i+6, 68);
2159 /* Display a "haggle" cost */
2162 /* Extrect the "maximum" price */
2163 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2165 /* Actually draw the price (not fixed) */
2166 (void)sprintf(out_val, "%9ld ", (long)x);
2167 put_str(out_val, i+6, 68);
2174 * Displays a store's inventory -RAK-
2175 * All prices are listed as "per individual object". -BEN-
2177 static void display_inventory(void)
2181 /* Display the next 12 items */
2182 for (k = 0; k < 12; k++)
2184 /* Do not display "dead" items */
2185 if (store_top + k >= st_ptr->stock_num) break;
2187 /* Display that line */
2188 display_entry(store_top + k);
2191 /* Erase the extra lines and the "more" prompt */
2192 for (i = k; i < 13; i++) prt("", i + 6, 0);
2194 /* Assume "no current page" */
2196 put_str(" ", 5, 20);
2198 put_str(" ", 5, 20);
2202 /* Visual reminder of "more items" */
2203 if (st_ptr->stock_num > 12)
2205 /* Show "more" reminder (after the last item) */
2207 prt("-³¤¯-", k + 6, 3);
2209 prt("-more-", k + 6, 3);
2213 /* Indicate the "current page" */
2215 put_str(format("(%d¥Ú¡¼¥¸)", store_top/12 + 1), 5, 20);
2217 put_str(format("(Page %d)", store_top/12 + 1), 5, 20);
2225 * Displays players gold -RAK-
2227 static void store_prt_gold(void)
2232 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19, 53);
2234 prt("Gold Remaining: ", 19, 53);
2238 sprintf(out_val, "%9ld", (long)p_ptr->au);
2239 prt(out_val, 19, 68);
2244 * Displays store (after clearing screen) -RAK-
2246 static void display_store(void)
2254 /* The "Home" is special */
2255 if (cur_store_num == STORE_HOME)
2257 /* Put the owner name */
2259 put_str("²æ¤¬²È", 3, 31);
2261 put_str("Your Home", 3, 30);
2265 /* Label the item descriptions */
2267 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2269 put_str("Item Description", 5, 3);
2273 /* If showing weights, show label */
2277 put_str("½Å¤µ", 5, 72);
2279 put_str("Weight", 5, 70);
2285 /* The "Home" is special */
2286 else if (cur_store_num == STORE_MUSEUM)
2288 /* Put the owner name */
2290 put_str("Çîʪ´Û", 3, 31);
2292 put_str("Museum", 3, 30);
2296 /* Label the item descriptions */
2298 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2300 put_str("Item Description", 5, 3);
2304 /* If showing weights, show label */
2308 put_str("½Å¤µ", 5, 72);
2310 put_str("Weight", 5, 70);
2319 cptr store_name = (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name);
2320 cptr owner_name = (ot_ptr->owner_name);
2321 cptr race_name = race_info[ot_ptr->owner_race].title;
2323 /* Put the owner name and race */
2324 sprintf(buf, "%s (%s)", owner_name, race_name);
2325 put_str(buf, 3, 10);
2327 /* Show the max price in the store (above prices) */
2328 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2331 /* Label the item descriptions */
2333 put_str("¾¦ÉʤΰìÍ÷", 5, 7);
2335 put_str("Item Description", 5, 3);
2339 /* If showing weights, show label */
2343 put_str("½Å¤µ", 5, 62);
2345 put_str("Weight", 5, 60);
2350 /* Label the asking price (in stores) */
2352 put_str("²Á³Ê", 5, 73);
2354 put_str("Price", 5, 72);
2359 /* Display the current gold */
2362 /* Draw in the inventory */
2363 display_inventory();
2369 * Get the ID of a store item and return its value -RAK-
2371 static int get_stock(int *com_val, cptr pmt, int i, int j)
2377 #ifdef ALLOW_REPEAT /* TNB */
2379 /* Get the item index */
2380 if (repeat_pull(com_val))
2382 /* Verify the item */
2383 if ((*com_val >= i) && (*com_val <= j))
2390 #endif /* ALLOW_REPEAT -- TNB */
2392 /* Paranoia XXX XXX XXX */
2396 /* Assume failure */
2399 /* Build the prompt */
2401 (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
2402 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
2403 I2A(i), I2A(j), pmt);
2405 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2406 I2A(i), I2A(j), pmt);
2410 /* Ask until done */
2416 if (!get_com(out_val, &command, FALSE)) break;
2419 k = (islower(command) ? A2I(command) : -1);
2421 /* Legal responses */
2422 if ((k >= i) && (k <= j))
2432 /* Clear the prompt */
2436 if (command == ESCAPE) return (FALSE);
2438 #ifdef ALLOW_REPEAT /* TNB */
2440 repeat_push(*com_val);
2442 #endif /* ALLOW_REPEAT -- TNB */
2450 * Increase the insult counter and get angry if too many -RAK-
2452 static int increase_insults(void)
2454 /* Increase insults */
2455 st_ptr->insult_cur++;
2457 /* Become insulted */
2458 if (st_ptr->insult_cur > ot_ptr->insult_max)
2464 st_ptr->insult_cur = 0;
2465 st_ptr->good_buy = 0;
2466 st_ptr->bad_buy = 0;
2469 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2481 * Decrease insults -RAK-
2483 static void decrease_insults(void)
2485 /* Decrease insults */
2486 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2491 * Have insulted while haggling -RAK-
2493 static int haggle_insults(void)
2495 /* Increase insults */
2496 if (increase_insults()) return (TRUE);
2498 /* Display and flush insult */
2507 * Mega-Hack -- Enable "increments"
2509 static bool allow_inc = FALSE;
2512 * Mega-Hack -- Last "increment" during haggling
2514 static s32b last_inc = 0L;
2520 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
2530 /* Clear old increment if necessary */
2531 if (!allow_inc) last_inc = 0L;
2538 sprintf(buf, "%s [¾µÂú] ", pmt);
2540 sprintf(buf, "%s [accept] ", pmt);
2545 /* Old (negative) increment, and not final */
2546 else if (last_inc < 0)
2549 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2551 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2556 /* Old (positive) increment, and not final */
2557 else if (last_inc > 0)
2560 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2562 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2570 sprintf(buf, "%s ", pmt);
2574 /* Paranoia XXX XXX XXX */
2578 /* Ask until done */
2582 strcpy(out_val, "");
2584 /* Ask the user for a response */
2585 if (!get_string(buf, out_val, 32)) return (FALSE);
2587 /* Skip leading spaces */
2588 for (p = out_val; *p == ' '; p++) /* loop */;
2590 /* Empty response */
2593 /* Accept current price */
2601 /* Use previous increment */
2602 if (allow_inc && last_inc)
2604 *poffer += last_inc;
2609 /* Normal response */
2612 /* Extract a number */
2615 /* Handle "incremental" number */
2616 if ((*p == '+' || *p == '-'))
2618 /* Allow increments */
2621 /* Use the given "increment" */
2628 /* Handle normal number */
2631 /* Use the given "number" */
2640 msg_print("Ãͤ¬¤ª¤«¤·¤¤¤Ç¤¹¡£");
2642 msg_print("Invalid response.");
2654 * Receive an offer (from the player)
2656 * Return TRUE if offer is NOT okay
2658 static bool receive_offer(cptr pmt, s32b *poffer,
2659 s32b last_offer, int factor,
2660 s32b price, int final)
2662 /* Haggle till done */
2665 /* Get a haggle (or cancel) */
2666 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2668 /* Acceptable offer */
2669 if (((*poffer) * factor) >= (last_offer * factor)) break;
2671 /* Insult, and check for kicked out */
2672 if (haggle_insults()) return (TRUE);
2674 /* Reject offer (correctly) */
2675 (*poffer) = last_offer;
2684 * Haggling routine -RAK-
2686 * Return TRUE if purchase is NOT successful
2688 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2690 s32b cur_ask, final_ask;
2691 s32b last_offer, offer;
2693 s32b min_per, max_per;
2694 int flag, loop_flag, noneed;
2695 int annoyed = 0, final = FALSE;
2697 bool cancel = FALSE;
2700 cptr pmt = "Ä󼨲Á³Ê";
2702 cptr pmt = "Asking";
2712 /* Extract the starting offer and the final offer */
2713 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2714 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2716 /* Determine if haggling is necessary */
2717 noneed = noneedtobargain(final_ask);
2719 /* No need to haggle */
2720 if (noneed || !manual_haggle)
2722 /* No need to haggle */
2725 /* Message summary */
2727 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2729 msg_print("You eventually agree upon the price.");
2735 /* No haggle option */
2738 /* Message summary */
2740 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2742 msg_print("You quickly agree upon the price.");
2747 /* Apply Sales Tax */
2748 final_ask += final_ask / 10;
2752 cur_ask = final_ask;
2754 /* Go to final offer */
2756 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2758 pmt = "Final Offer";
2765 /* Haggle for the whole pile */
2766 cur_ask *= o_ptr->number;
2767 final_ask *= o_ptr->number;
2770 /* Haggle parameters */
2771 min_per = ot_ptr->haggle_per;
2772 max_per = min_per * 3;
2774 /* Mega-Hack -- artificial "last offer" value */
2775 last_offer = object_value(o_ptr) * o_ptr->number;
2776 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
2777 if (last_offer <= 0) last_offer = 1;
2782 /* No incremental haggling yet */
2785 /* Haggle until done */
2786 for (flag = FALSE; !flag; )
2790 while (!flag && loop_flag)
2792 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
2793 put_str(out_val, 1, 0);
2795 cancel = receive_offer("Ä󼨤¹¤ë¶â³Û? ",
2797 cancel = receive_offer("What do you offer? ",
2800 &offer, last_offer, 1, cur_ask, final);
2806 else if (offer > cur_ask)
2811 else if (offer == cur_ask)
2824 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
2827 if (haggle_insults())
2833 else if (x1 > max_per)
2836 if (x1 < max_per) x1 = max_per;
2838 x2 = rand_range(x1-2, x1+2);
2839 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
2840 /* don't let the price go up */
2845 if (cur_ask < final_ask)
2848 cur_ask = final_ask;
2850 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2852 pmt = "Final Offer";
2858 (void)(increase_insults());
2863 else if (offer >= cur_ask)
2875 (void)sprintf(out_val, "Á°²ó¤ÎÄ󼨶â³Û: $%ld",
2877 (void)sprintf(out_val, "Your last offer: %ld",
2881 put_str(out_val, 1, 39);
2882 say_comment_2(cur_ask, annoyed);
2888 if (cancel) return (TRUE);
2890 /* Update bargaining info */
2891 updatebargain(*price, final_ask, o_ptr->number);
2899 * Haggling routine -RAK-
2901 * Return TRUE if purchase is NOT successful
2903 static bool sell_haggle(object_type *o_ptr, s32b *price)
2905 s32b purse, cur_ask, final_ask;
2906 s32b last_offer = 0, offer = 0;
2908 s32b min_per, max_per;
2909 int flag, loop_flag, noneed;
2910 int annoyed = 0, final = FALSE;
2911 bool cancel = FALSE;
2913 cptr pmt = "Ä󼨶â³Û";
2924 /* Obtain the starting offer and the final offer */
2925 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
2926 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
2928 /* Determine if haggling is necessary */
2929 noneed = noneedtobargain(final_ask);
2931 /* Get the owner's payout limit */
2932 purse = (s32b)(ot_ptr->max_cost);
2934 /* No need to haggle */
2935 if (noneed || !manual_haggle || (final_ask >= purse))
2937 /* No reason to haggle */
2938 if (final_ask >= purse)
2942 msg_print("¨ºÂ¤Ë¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2944 msg_print("You instantly agree upon the price.");
2949 /* Offer full purse */
2953 /* No need to haggle */
2958 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2960 msg_print("You eventually agree upon the price.");
2966 /* No haggle option */
2969 /* Message summary */
2971 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2973 msg_print("You quickly agree upon the price.");
2978 /* Apply Sales Tax */
2979 final_ask -= final_ask / 10;
2983 cur_ask = final_ask;
2988 pmt = "ºÇ½ªÄ󼨶â³Û";
2990 pmt = "Final Offer";
2995 /* Haggle for the whole pile */
2996 cur_ask *= o_ptr->number;
2997 final_ask *= o_ptr->number;
3000 /* XXX XXX XXX Display commands */
3002 /* Haggling parameters */
3003 min_per = ot_ptr->haggle_per;
3004 max_per = min_per * 3;
3006 /* Mega-Hack -- artificial "last offer" value */
3007 last_offer = object_value(o_ptr) * o_ptr->number;
3008 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3013 /* No incremental haggling yet */
3017 for (flag = FALSE; !flag; )
3023 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3024 put_str(out_val, 1, 0);
3026 cancel = receive_offer("Ä󼨤¹¤ë²Á³Ê? ",
3028 cancel = receive_offer("What price do you ask? ",
3031 &offer, last_offer, -1, cur_ask, final);
3037 else if (offer < cur_ask)
3040 /* rejected, reset offer for incremental haggling */
3043 else if (offer == cur_ask)
3054 if (flag || !loop_flag) break;
3059 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3062 if (haggle_insults())
3068 else if (x1 > max_per)
3071 if (x1 < max_per) x1 = max_per;
3073 x2 = rand_range(x1-2, x1+2);
3074 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3075 /* don't let the price go down */
3079 if (cur_ask > final_ask)
3081 cur_ask = final_ask;
3084 pmt = "ºÇ½ªÄ󼨶â³Û";
3086 pmt = "Final Offer";
3094 /* Äɲà $0 ¤ÇÇ㤤¼è¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ»ß By FIRST*/
3097 (void)(increase_insults());
3100 else if (offer <= cur_ask)
3111 (void)sprintf(out_val,
3113 "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
3115 "Your last bid %ld", (long)last_offer);
3118 put_str(out_val, 1, 39);
3119 say_comment_3(cur_ask, annoyed);
3125 if (cancel) return (TRUE);
3127 /* Update bargaining info */
3128 updatebargain(*price, final_ask, o_ptr->number);
3136 * Buy an item from a store -RAK-
3138 static void store_purchase(void)
3150 char o_name[MAX_NLEN];
3155 if (cur_store_num == STORE_MUSEUM)
3158 msg_print("Çîʪ´Û¤«¤é¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
3160 msg_print("Museum.");
3166 if (st_ptr->stock_num <= 0)
3168 if (cur_store_num == STORE_HOME)
3170 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3172 msg_print("Your home is empty.");
3177 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
3179 msg_print("I am currently out of stock.");
3186 /* Find the number of objects on this and following pages */
3187 i = (st_ptr->stock_num - store_top);
3189 /* And then restrict it to the current page */
3194 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
3195 switch( cur_store_num ) {
3197 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
3200 sprintf(out_val, "¤É¤ì? ");
3203 sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
3207 if (cur_store_num == STORE_HOME)
3209 sprintf(out_val, "Which item do you want to take? ");
3213 sprintf(out_val, "Which item are you interested in? ");
3218 /* Get the item number to be bought */
3219 if (!get_stock(&item, out_val, 0, i - 1)) return;
3221 /* Get the actual index */
3222 item = item + store_top;
3224 /* Get the actual item */
3225 o_ptr = &st_ptr->stock[item];
3227 /* Assume the player wants just one of them */
3230 /* Get local object */
3233 /* Get a copy of the object */
3234 object_copy(j_ptr, o_ptr);
3237 * If a rod or wand, allocate total maximum timeouts or charges
3238 * between those purchased and left on the shelf.
3240 reduce_charges(j_ptr, o_ptr->number - amt);
3242 /* Modify quantity */
3243 j_ptr->number = amt;
3245 /* Hack -- require room in pack */
3246 if (!inven_carry_okay(j_ptr))
3249 msg_print("¤½¤ó¤Ê¤Ë¥¢¥¤¥Æ¥à¤ò»ý¤Æ¤Ê¤¤¡£");
3251 msg_print("You cannot carry that many different items.");
3257 /* Determine the "best" price (per item) */
3258 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3260 /* Find out how many the player wants */
3261 if (o_ptr->number > 1)
3263 /* Hack -- note cost of "fixed" items */
3264 if ((cur_store_num != STORE_HOME) &&
3265 (o_ptr->ident & IDENT_FIXED))
3268 msg_format("°ì¤Ä¤Ë¤Ä¤ $%ld¤Ç¤¹¡£", (long)(best));
3270 msg_format("That costs %ld gold per item.", (long)(best));
3275 /* Get a quantity */
3276 amt = get_quantity(NULL, o_ptr->number);
3278 /* Allow user abort */
3279 if (amt <= 0) return;
3282 /* Get local object */
3285 /* Get desired object */
3286 object_copy(j_ptr, o_ptr);
3289 * If a rod or wand, allocate total maximum timeouts or charges
3290 * between those purchased and left on the shelf.
3292 reduce_charges(j_ptr, o_ptr->number - amt);
3294 /* Modify quantity */
3295 j_ptr->number = amt;
3297 /* Hack -- require room in pack */
3298 if (!inven_carry_okay(j_ptr))
3301 msg_print("¥¶¥Ã¥¯¤Ë¤½¤Î¥¢¥¤¥Æ¥à¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£");
3303 msg_print("You cannot carry that many items.");
3309 /* Attempt to buy it */
3310 if (cur_store_num != STORE_HOME)
3312 /* Fixed price, quick buy */
3313 if (o_ptr->ident & (IDENT_FIXED))
3318 /* Go directly to the "best" deal */
3319 price = (best * j_ptr->number);
3325 /* Describe the object (fully) */
3326 object_desc_store(o_name, j_ptr, TRUE, 3);
3330 msg_format("%s(%c)¤ò¹ØÆþ¤¹¤ë¡£", o_name, I2A(item));
3332 msg_format("Buying %s (%c).", o_name, I2A(item));
3337 /* Haggle for a final price */
3338 choice = purchase_haggle(j_ptr, &price);
3340 /* Hack -- Got kicked out */
3341 if (st_ptr->store_open >= turn) return;
3344 /* Player wants it */
3347 /* Fix the item price (if "correctly" haggled) */
3348 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3350 /* Player can afford it */
3351 if (p_ptr->au >= price)
3356 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3357 chg_virtue(V_JUSTICE, -1);
3358 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3359 chg_virtue(V_NATURE, -1);
3367 /* Spend the money */
3370 /* Update the display */
3373 /* Hack -- buying an item makes you aware of it */
3374 object_aware(j_ptr);
3376 /* Hack -- clear the "fixed" flag from the item */
3377 j_ptr->ident &= ~(IDENT_FIXED);
3379 /* Describe the transaction */
3380 object_desc(o_name, j_ptr, TRUE, 3);
3384 msg_format("%s¤ò $%ld¤Ç¹ØÆþ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3386 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3389 strcpy(record_o_name, o_name);
3392 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3393 object_desc(o_name, o_ptr, TRUE, 0);
3394 if(record_rand_art && o_ptr->art_name)
3395 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3397 /* Erase the inscription */
3398 j_ptr->inscription = 0;
3400 /* Erase the "feeling" */
3401 j_ptr->feeling = FEEL_NONE;
3402 j_ptr->ident &= ~(IDENT_STOREB);
3403 /* Give it to the player */
3404 item_new = inven_carry(j_ptr);
3406 /* Describe the final result */
3407 object_desc(o_name, &inventory[item_new], TRUE, 3);
3411 msg_format("%s(%c)¤ò¼ê¤ËÆþ¤ì¤¿¡£", o_name, index_to_label(item_new));
3413 msg_format("You have %s (%c).",
3414 o_name, index_to_label(item_new));
3418 /* Now, reduce the original stack's pval. */
3419 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3421 o_ptr->pval -= j_ptr->pval;
3427 /* Note how many slots the store used to have */
3428 i = st_ptr->stock_num;
3430 /* Remove the bought items from the store */
3431 store_item_increase(item, -amt);
3432 store_item_optimize(item);
3434 /* Store is empty */
3435 if (st_ptr->stock_num == 0)
3438 if (one_in_(STORE_SHUFFLE))
3443 msg_print("Ź¼ç¤Ï°úÂष¤¿¡£");
3445 msg_print("The shopkeeper retires.");
3449 /* Shuffle the store */
3450 store_shuffle(cur_store_num);
3453 sprintf(buf, "%s (%s)",
3454 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3455 put_str(buf, 3, 10);
3456 sprintf(buf, "%s (%ld)",
3457 (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name), (long)(ot_ptr->max_cost));
3466 msg_print("Ź¼ç¤Ï¿·¤¿¤Êºß¸Ë¤ò¼è¤ê½Ð¤·¤¿¡£");
3468 msg_print("The shopkeeper brings out some new stock.");
3474 for (i = 0; i < 10; i++)
3476 /* Maintain the store */
3477 store_maint(p_ptr->town_num, cur_store_num);
3483 /* Redraw everything */
3484 display_inventory();
3487 /* The item is gone */
3488 else if (st_ptr->stock_num != i)
3490 /* Pick the correct screen */
3491 if (store_top >= st_ptr->stock_num) store_top -= 12;
3493 /* Redraw everything */
3494 display_inventory();
3497 /* Item is still here */
3500 /* Redraw the item */
3501 display_entry(item);
3505 /* Player cannot afford it */
3508 /* Simple message (no insult) */
3510 msg_print("¤ª¶â¤¬Â¤ê¤Þ¤»¤ó¡£");
3512 msg_print("You do not have enough gold.");
3519 /* Home is much easier */
3522 /* Distribute charges of wands/rods */
3523 distribute_charges(o_ptr, j_ptr, amt);
3525 /* Give it to the player */
3526 item_new = inven_carry(j_ptr);
3528 /* Describe just the result */
3529 object_desc(o_name, &inventory[item_new], TRUE, 3);
3533 msg_format("%s(%c)¤ò¼è¤Ã¤¿¡£",
3535 msg_format("You have %s (%c).",
3537 o_name, index_to_label(item_new));
3542 /* Take note if we take the last one */
3543 i = st_ptr->stock_num;
3545 /* Remove the items from the home */
3546 store_item_increase(item, -amt);
3547 store_item_optimize(item);
3549 /* Hack -- Item is still here */
3550 if (i == st_ptr->stock_num)
3552 /* Redraw the item */
3553 display_entry(item);
3556 /* The item is gone */
3560 if (st_ptr->stock_num == 0) store_top = 0;
3562 /* Nothing left on that screen */
3563 else if (store_top >= st_ptr->stock_num) store_top -= 12;
3565 /* Redraw everything */
3566 display_inventory();
3568 chg_virtue(V_SACRIFICE, 1);
3572 /* Not kicked out */
3578 * Sell an item to the store (or home)
3580 static void store_sell(void)
3586 s32b price, value, dummy;
3595 char o_name[MAX_NLEN];
3598 /* Prepare a prompt */
3599 if (cur_store_num == STORE_HOME)
3601 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÃÖ¤¤Þ¤¹¤«? ";
3603 q = "Drop which item? ";
3606 else if (cur_store_num == STORE_MUSEUM)
3608 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ó£¤·¤Þ¤¹¤«? ";
3610 q = "Give which item? ";
3615 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÇä¤ê¤Þ¤¹¤«? ";
3617 q = "Sell which item? ";
3621 item_tester_no_ryoute = TRUE;
3622 /* Only allow items the store will buy */
3623 item_tester_hook = store_will_buy;
3626 /* ²æ¤¬²È¤Ç¤ª¤«¤·¤Ê¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¥ª¥ê¥¸¥Ê¥ë¤Î¥Ð¥°¤ò½¤Àµ */
3627 if (cur_store_num == STORE_HOME)
3630 s = "ÃÖ¤±¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3632 s = "You don't have any item to drop.";
3635 else if (cur_store_num == STORE_MUSEUM)
3638 s = "´ó£¤Ç¤¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3640 s = "You don't have any item to give.";
3646 s = "Íߤ·¤¤Êª¤¬¤Ê¤¤¤Ç¤¹¤Í¤¨¡£";
3648 s = "You have nothing that I want.";
3652 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3654 /* Get the item (in the pack) */
3657 o_ptr = &inventory[item];
3660 /* Get the item (on the floor) */
3663 o_ptr = &o_list[0 - item];
3667 /* Hack -- Cannot remove cursed items */
3668 if ((item >= INVEN_RARM) && cursed_p(o_ptr))
3672 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¤Í¡£");
3674 msg_print("Hmmm, it seems to be cursed.");
3683 /* Assume one item */
3686 /* Find out how many the player wants (letter means "all") */
3687 if (o_ptr->number > 1)
3689 /* Get a quantity */
3690 amt = get_quantity(NULL, o_ptr->number);
3692 /* Allow user abort */
3693 if (amt <= 0) return;
3696 /* Get local object */
3699 /* Get a copy of the object */
3700 object_copy(q_ptr, o_ptr);
3702 /* Modify quantity */
3703 q_ptr->number = amt;
3706 * Hack -- If a rod or wand, allocate total maximum
3707 * timeouts or charges to those being sold. -LM-
3709 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3711 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3714 /* Get a full description */
3715 object_desc(o_name, q_ptr, TRUE, 3);
3717 /* Remove any inscription, feeling for stores */
3718 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3720 q_ptr->inscription = 0;
3721 q_ptr->feeling = FEEL_NONE;
3724 /* Is there room in the store (or the home?) */
3725 if (!store_check_num(q_ptr))
3727 if (cur_store_num == STORE_HOME)
3729 msg_print("²æ¤¬²È¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤Ê¤¤¡£");
3731 msg_print("Your home is full.");
3734 else if (cur_store_num == STORE_MUSEUM)
3736 msg_print("Çîʪ´Û¤Ï¤â¤¦ËþÇÕ¤À¡£");
3738 msg_print("Museum is full.");
3743 msg_print("¤¹¤¤¤Þ¤»¤ó¤¬¡¢Å¹¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤¢¤ê¤Þ¤»¤ó¡£");
3745 msg_print("I have not the room in my store to keep it.");
3753 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3755 /* Describe the transaction */
3757 msg_format("%s(%c)¤òÇäµÑ¤¹¤ë¡£", o_name, index_to_label(item));
3759 msg_format("Selling %s (%c).", o_name, index_to_label(item));
3765 choice = sell_haggle(q_ptr, &price);
3768 if (st_ptr->store_open >= turn) return;
3780 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3781 chg_virtue(V_JUSTICE, -1);
3783 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3784 chg_virtue(V_NATURE, 1);
3787 /* Get some money */
3790 /* Update the display */
3793 /* Get the "apparent" value */
3794 dummy = object_value(q_ptr) * q_ptr->number;
3797 identify_item(o_ptr);
3799 /* Get local object */
3802 /* Get a copy of the object */
3803 object_copy(q_ptr, o_ptr);
3805 /* Modify quantity */
3806 q_ptr->number = amt;
3809 * Hack -- If a rod or wand, let the shopkeeper know just
3810 * how many charges he really paid for. -LM-
3812 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3814 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3817 /* Get the "actual" value */
3818 value = object_value(q_ptr) * q_ptr->number;
3820 /* Get the description all over again */
3821 object_desc(o_name, q_ptr, TRUE, 3);
3823 /* Describe the result (in message buffer) */
3825 msg_format("%s¤ò $%ld¤ÇÇäµÑ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3827 msg_format("You sold %s for %ld gold.", o_name, (long)price);
3830 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
3832 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
3834 /* Analyze the prices (and comment verbally) unless a figurine*/
3835 purchase_analyze(price, value, dummy);
3839 * Hack -- Allocate charges between those wands or rods sold
3840 * and retained, unless all are being sold. -LM-
3842 distribute_charges(o_ptr, q_ptr, amt);
3844 /* Reset timeouts of the sold items */
3847 /* Take the item from the player, describe the result */
3848 inven_item_increase(item, -amt);
3849 inven_item_describe(item);
3850 inven_item_optimize(item);
3855 /* The store gets that (known) item */
3856 item_pos = store_carry(q_ptr);
3858 /* Re-display if item is now in store */
3861 store_top = (item_pos / 12) * 12;
3862 display_inventory();
3867 /* Player is at museum */
3868 else if (cur_store_num == STORE_MUSEUM)
3870 char o2_name[MAX_NLEN];
3871 object_desc(o2_name, q_ptr, TRUE, 0);
3873 if (-1 == store_check_num(q_ptr))
3876 msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£");
3878 msg_print("The same object as it is already in the Museum.");
3884 msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª¡ª");
3886 msg_print("You cannot take items which is given to the Museum back!!");
3890 if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return;
3892 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
3896 identify_item(q_ptr);
3897 q_ptr->ident |= IDENT_MENTAL;
3899 /* Distribute charges of wands/rods */
3900 distribute_charges(o_ptr, q_ptr, amt);
3904 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
3906 msg_format("You drop %s (%c).", o_name, index_to_label(item));
3911 /* Take it from the players inventory */
3912 inven_item_increase(item, -amt);
3913 inven_item_describe(item);
3914 inven_item_optimize(item);
3919 /* Let the home carry it */
3920 item_pos = home_carry(q_ptr);
3922 /* Update store display */
3925 store_top = (item_pos / 12) * 12;
3926 display_inventory();
3929 /* Player is at home */
3932 /* Distribute charges of wands/rods */
3933 distribute_charges(o_ptr, q_ptr, amt);
3937 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
3939 msg_format("You drop %s (%c).", o_name, index_to_label(item));
3944 /* Take it from the players inventory */
3945 inven_item_increase(item, -amt);
3946 inven_item_describe(item);
3947 inven_item_optimize(item);
3952 /* Let the home carry it */
3953 item_pos = home_carry(q_ptr);
3955 /* Update store display */
3958 store_top = (item_pos / 12) * 12;
3959 display_inventory();
3962 if (item >= INVEN_RARM) calc_android_exp();
3963 if ((choice == 0) && ((item == INVEN_RARM) || (item == INVEN_LARM))) kamaenaoshi(item);
3968 * Examine an item in a store -JDL-
3970 static void store_examine(void)
3975 char o_name[MAX_NLEN];
3980 if (st_ptr->stock_num <= 0)
3982 if (cur_store_num == STORE_HOME)
3984 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3986 msg_print("Your home is empty.");
3989 if (cur_store_num == STORE_MUSEUM)
3991 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3993 msg_print("Museum is empty.");
3998 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
4000 msg_print("I am currently out of stock.");
4007 /* Find the number of objects on this and following pages */
4008 i = (st_ptr->stock_num - store_top);
4010 /* And then restrict it to the current page */
4015 sprintf(out_val, "¤É¤ì¤òÄ´¤Ù¤Þ¤¹¤«¡©");
4017 sprintf(out_val, "Which item do you want to examine? ");
4021 /* Get the item number to be examined */
4022 if (!get_stock(&item, out_val, 0, i - 1)) return;
4024 /* Get the actual index */
4025 item = item + store_top;
4027 /* Get the actual item */
4028 o_ptr = &st_ptr->stock[item];
4030 /* Require full knowledge */
4031 if (!(o_ptr->ident & IDENT_MENTAL))
4033 /* This can only happen in the home */
4035 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
4037 msg_print("You have no special knowledge about that item.");
4044 object_desc(o_name, o_ptr, TRUE, 3);
4048 msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
4050 msg_format("Examining %s...", o_name);
4054 /* Describe it fully */
4055 if (!identify_fully_aux(o_ptr))
4057 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
4059 msg_print("You see nothing special.");
4068 * Hack -- set this to leave the store
4070 static bool leave_store = FALSE;
4074 * Process a command in a store
4076 * Note that we must allow the use of a few "special" commands
4077 * in the stores which are not allowed in the dungeon, and we
4078 * must disable some commands which are allowed in the dungeon
4079 * but not in the stores, to prevent chaos.
4081 static void store_process_command(void)
4083 #ifdef ALLOW_REPEAT /* TNB */
4085 /* Handle repeating the last command */
4088 #endif /* ALLOW_REPEAT -- TNB */
4090 if (rogue_like_commands && command_cmd == 'l')
4092 command_cmd = 'x'; /* hack! */
4095 /* Parse the command */
4096 switch (command_cmd)
4106 /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
4109 if (st_ptr->stock_num <= 12) {
4111 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4113 msg_print("Entire inventory is shown.");
4118 if ( store_top < 0 )
4119 store_top = ((st_ptr->stock_num - 1 )/12) * 12;
4120 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4121 if ( store_top >= 12 ) store_top = 12;
4122 display_inventory();
4130 if (st_ptr->stock_num <= 12)
4133 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4135 msg_print("Entire inventory is shown.");
4143 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
4144 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
4146 if ((cur_store_num == STORE_HOME) &&
4147 (powerup_home == FALSE) &&
4148 (st_ptr->stock_num >= STORE_INVEN_MAX))
4150 if (store_top >= (STORE_INVEN_MAX - 1))
4157 if (store_top >= st_ptr->stock_num) store_top = 0;
4160 display_inventory();
4173 /* Get (purchase) */
4200 /*** Inventory Commands ***/
4202 /* Wear/wield equipment */
4209 /* Take off equipment */
4216 /* Destroy an item */
4223 /* Equipment list */
4230 /* Inventory list */
4238 /*** Various commands ***/
4240 /* Identify an object */
4247 /* Hack -- toggle windows */
4250 toggle_inven_equip();
4256 /*** Use various objects ***/
4265 /* Inscribe an object */
4272 /* Uninscribe an object */
4275 do_cmd_uninscribe();
4281 /*** Help and Such ***/
4290 /* Identify symbol */
4293 do_cmd_query_symbol();
4297 /* Character description */
4300 do_cmd_change_name();
4306 /*** System Commands ***/
4308 /* Hack -- User interface */
4315 /* Single line from a pref file */
4322 /* Interact with macros */
4329 /* Interact with visuals */
4336 /* Interact with colors */
4343 /* Interact with options */
4350 /*** Misc Commands ***/
4366 /* Repeat level feeling */
4373 /* Show previous message */
4376 do_cmd_message_one();
4380 /* Show previous messages */
4393 /* Check artifacts, uniques etc. */
4400 /* Load "screen dump" */
4403 do_cmd_load_screen();
4407 /* Save "screen dump" */
4410 do_cmd_save_screen();
4414 /* Hack -- Unknown command */
4418 msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
4420 msg_print("That command does not work in stores.");
4430 * Enter a store, and interact with it.
4432 * Note that we use the standard "request_command()" function
4433 * to get a command, allowing us to use "command_arg" and all
4434 * command macros and other nifty stuff, but we use the special
4435 * "shopping" argument, to force certain commands to be converted
4436 * into other commands, normally, we convert "p" (pray) and "m"
4437 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4439 void do_cmd_store(void)
4449 /* Access the player grid */
4450 c_ptr = &cave[py][px];
4452 /* Verify a store */
4453 if (!((c_ptr->feat >= FEAT_SHOP_HEAD) &&
4454 (c_ptr->feat <= FEAT_SHOP_TAIL)) &&
4455 (c_ptr->feat != FEAT_MUSEUM))
4458 msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
4460 msg_print("You see no store here.");
4466 /* Extract the store code */
4467 if (c_ptr->feat == FEAT_MUSEUM) which = STORE_MUSEUM;
4468 else which = (c_ptr->feat - FEAT_SHOP_HEAD);
4470 old_town_num = p_ptr->town_num;
4471 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4472 if (dun_level) p_ptr->town_num = NO_TOWN;
4474 /* Hack -- Check the "locked doors" */
4475 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4479 msg_print("¥É¥¢¤Ë¸°¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£");
4481 msg_print("The doors are locked.");
4484 p_ptr->town_num = old_town_num;
4488 /* Calculate the number of store maintainances since the last visit */
4489 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TURNS);
4491 /* Maintain the store max. 10 times */
4492 if (maintain_num > 10) maintain_num = 10;
4496 /* Maintain the store */
4497 for (i = 0; i < maintain_num; i++)
4498 store_maint(p_ptr->town_num, which);
4500 /* Save the visit */
4501 town[p_ptr->town_num].store[which].last_visit = turn;
4504 /* Forget the lite */
4507 /* Forget the view */
4511 /* Hack -- Character is in "icky" mode */
4512 character_icky = TRUE;
4515 /* No command argument */
4518 /* No repeated command */
4521 /* No automatic command */
4525 /* Save the store number */
4526 cur_store_num = which;
4528 /* Save the store and owner pointers */
4529 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4530 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4533 /* Start at the beginning */
4536 /* Display the store */
4540 leave_store = FALSE;
4542 /* Interact with player */
4543 while (!leave_store)
4545 /* Hack -- Clear line 1 */
4548 /* Hack -- Check the charisma */
4549 tmp_chr = p_ptr->stat_use[A_CHR];
4555 /* Basic commands */
4557 prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21, 0);
4559 prt(" ESC) Exit from Building.", 21, 0);
4563 /* Browse if necessary */
4564 if (st_ptr->stock_num > 12)
4567 prt(" -)Á°¥Ú¡¼¥¸", 22, 0);
4568 prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23, 0);
4570 prt(" -) Previous page", 22, 0);
4571 prt(" SPACE) Next page", 23, 0);
4577 if (cur_store_num == STORE_HOME)
4580 prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
4581 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
4582 prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
4584 prt("g) Get an item.", 21, 27);
4585 prt("d) Drop an item.", 22, 27);
4586 prt("x) eXamine an item in the home.", 23,27);
4591 /* Museum commands */
4592 else if (cur_store_num == STORE_MUSEUM)
4595 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
4596 prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
4598 prt("d) Drop an item.", 21, 27);
4599 prt("x) eXamine an item in the museum.", 23,27);
4604 /* Shop commands XXX XXX XXX */
4608 prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
4609 prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
4610 prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,30);
4612 prt("p) Purchase an item.", 21, 30);
4613 prt("s) Sell an item.", 22, 30);
4614 prt("x) eXamine an item in the shop", 23,30);
4620 /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
4622 prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56);
4624 if( rogue_like_commands == TRUE )
4626 prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
4630 prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
4633 prt("i/e) Inventry/Equipment list", 21, 56);
4635 if( rogue_like_commands == TRUE )
4637 prt("w/T) Wear/Take off equipment", 22, 56);
4641 prt("w/t) Wear/Take off equipment", 22, 56);
4646 prt("¥³¥Þ¥ó¥É:", 20, 0);
4648 prt("You may: ", 20, 0);
4653 request_command(TRUE);
4655 /* Process the command */
4656 store_process_command();
4658 /* Hack -- Character is still in "icky" mode */
4659 character_icky = TRUE;
4667 /* XXX XXX XXX Pack Overflow */
4668 if (inventory[INVEN_PACK].k_idx)
4670 int item = INVEN_PACK;
4672 object_type *o_ptr = &inventory[item];
4674 /* Hack -- Flee from the store */
4675 if (cur_store_num != STORE_HOME)
4679 if (cur_store_num == STORE_MUSEUM)
4680 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆÇîʪ´Û¤«¤é½Ð¤¿...");
4682 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆŹ¤«¤é½Ð¤¿...");
4684 if (cur_store_num == STORE_MUSEUM)
4685 msg_print("Your pack is so full that you flee the Museum...");
4687 msg_print("Your pack is so full that you flee the store...");
4695 /* Hack -- Flee from the home */
4696 else if (!store_check_num(o_ptr))
4700 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤Æ²È¤«¤é½Ð¤¿...");
4702 msg_print("Your pack is so full that you flee your home...");
4710 /* Hack -- Drop items into the home */
4718 char o_name[MAX_NLEN];
4721 /* Give a message */
4723 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
4725 msg_print("Your pack overflows!");
4729 /* Get local object */
4732 /* Grab a copy of the item */
4733 object_copy(q_ptr, o_ptr);
4736 object_desc(o_name, q_ptr, TRUE, 3);
4740 msg_format("%s¤¬Íî¤Á¤¿¡£(%c)", o_name, index_to_label(item));
4742 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4746 /* Remove it from the players inventory */
4747 inven_item_increase(item, -255);
4748 inven_item_describe(item);
4749 inven_item_optimize(item);
4754 /* Let the home carry it */
4755 item_pos = home_carry(q_ptr);
4757 /* Redraw the home */
4760 store_top = (item_pos / 12) * 12;
4761 display_inventory();
4766 /* Hack -- Redisplay store prices if charisma changes */
4767 if (tmp_chr != p_ptr->stat_use[A_CHR]) display_inventory();
4769 /* Hack -- get kicked out of the store */
4770 if (st_ptr->store_open >= turn) leave_store = TRUE;
4773 p_ptr->town_num = old_town_num;
4775 /* Free turn XXX XXX XXX */
4779 /* Hack -- Character is no longer in "icky" mode */
4780 character_icky = FALSE;
4783 /* Hack -- Cancel automatic command */
4786 /* Hack -- Cancel "see" mode */
4787 command_see = FALSE;
4790 /* Flush messages XXX XXX XXX */
4794 /* Clear the screen */
4798 /* Update everything */
4799 p_ptr->update |= (PU_VIEW | PU_LITE);
4800 p_ptr->update |= (PU_MONSTERS);
4802 /* Redraw entire screen */
4803 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
4806 p_ptr->redraw |= (PR_MAP);
4809 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4815 * Shuffle one of the stores.
4817 void store_shuffle(int which)
4823 if (which == STORE_HOME) return;
4824 if (which == STORE_MUSEUM) return;
4827 /* Save the store index */
4828 cur_store_num = which;
4830 /* Activate that store */
4831 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4834 /* Pick a new owner */
4837 st_ptr->owner = (byte)randint0(MAX_OWNERS);
4838 if (j == st_ptr->owner) continue;
4839 for (i = 1;i < max_towns; i++)
4841 if (i == p_ptr->town_num) continue;
4842 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
4844 if (i == max_towns) break;
4847 /* Activate the new owner */
4848 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4851 /* Reset the owner data */
4852 st_ptr->insult_cur = 0;
4853 st_ptr->store_open = 0;
4854 st_ptr->good_buy = 0;
4855 st_ptr->bad_buy = 0;
4858 /* Hack -- discount all the items */
4859 for (i = 0; i < st_ptr->stock_num; i++)
4864 o_ptr = &st_ptr->stock[i];
4866 /* Hack -- Sell all old items for "half price" */
4867 if (!(o_ptr->art_name))
4868 o_ptr->discount = 50;
4870 /* Hack -- Items are no longer "fixed price" */
4871 o_ptr->ident &= ~(IDENT_FIXED);
4873 /* Mega-Hack -- Note that the item is "on sale" */
4875 o_ptr->inscription = quark_add("Çä½ÐÃæ");
4877 o_ptr->inscription = quark_add("on sale");
4885 * Maintain the inventory at the stores.
4887 void store_maint(int town_num, int store_num)
4891 int old_rating = rating;
4893 cur_store_num = store_num;
4896 if (store_num == STORE_HOME) return;
4897 if (store_num == STORE_MUSEUM) return;
4899 /* Activate that store */
4900 st_ptr = &town[town_num].store[store_num];
4902 /* Activate the owner */
4903 ot_ptr = &owners[store_num][st_ptr->owner];
4905 /* Store keeper forgives the player */
4906 st_ptr->insult_cur = 0;
4908 /* Mega-Hack -- prune the black market */
4909 if (store_num == STORE_BLACK)
4911 /* Destroy crappy black market items */
4912 for (j = st_ptr->stock_num - 1; j >= 0; j--)
4914 object_type *o_ptr = &st_ptr->stock[j];
4916 /* Destroy crappy items */
4917 if (black_market_crap(o_ptr))
4919 /* Destroy the item */
4920 store_item_increase(j, 0 - o_ptr->number);
4921 store_item_optimize(j);
4927 /* Choose the number of slots to keep */
4928 j = st_ptr->stock_num;
4930 /* Sell a few items */
4931 j = j - randint1(STORE_TURNOVER);
4933 /* Never keep more than "STORE_MAX_KEEP" slots */
4934 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
4936 /* Always "keep" at least "STORE_MIN_KEEP" items */
4937 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
4939 /* Hack -- prevent "underflow" */
4942 /* Destroy objects until only "j" slots are left */
4943 while (st_ptr->stock_num > j) store_delete();
4946 /* Choose the number of slots to fill */
4947 j = st_ptr->stock_num;
4949 /* Buy some more items */
4950 j = j + randint1(STORE_TURNOVER);
4952 /* Never keep more than "STORE_MAX_KEEP" slots */
4953 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
4955 /* Always "keep" at least "STORE_MIN_KEEP" items */
4956 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
4958 /* Hack -- prevent "overflow" */
4959 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
4961 /* Acquire some new items */
4962 while (st_ptr->stock_num < j) store_create();
4965 /* Hack -- Restore the rating */
4966 rating = old_rating;
4971 * Initialize the stores
4973 void store_init(int town_num, int store_num)
4977 cur_store_num = store_num;
4979 /* Activate that store */
4980 st_ptr = &town[town_num].store[store_num];
4988 st_ptr->owner = (byte)randint0(MAX_OWNERS);
4989 for (i = 1;i < max_towns; i++)
4991 if (i == town_num) continue;
4992 if (st_ptr->owner == town[i].store[store_num].owner) break;
4994 if (i == max_towns) break;
4997 /* Activate the new owner */
4998 ot_ptr = &owners[store_num][st_ptr->owner];
5001 /* Initialize the store */
5002 st_ptr->store_open = 0;
5003 st_ptr->insult_cur = 0;
5004 st_ptr->good_buy = 0;
5005 st_ptr->bad_buy = 0;
5007 /* Nothing in stock */
5008 st_ptr->stock_num = 0;
5011 * MEGA-HACK - Last visit to store is
5012 * BEFORE player birth to enable store restocking
5014 st_ptr->last_visit = -200L * STORE_TURNS;
5016 /* Clear any old items */
5017 for (k = 0; k < st_ptr->stock_size; k++)
5019 object_wipe(&st_ptr->stock[k]);
5024 void move_to_black_market(object_type *o_ptr)
5027 if (!p_ptr->town_num) return;
5029 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5031 o_ptr->ident |= IDENT_STOREB;
5033 (void)store_carry(o_ptr);
5035 object_wipe(o_ptr); /* Don't leave a bogus object behind... */