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 /* ²¼¤ÎÊý¤«¤é°ÜÆ°¤·¤Æ¤¤Þ¤·¤¿ */
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 static s16b old_town_num = 0;
24 static s16b inner_town_num = 0;
25 #define RUMOR_CHANCE 8
27 #define MAX_COMMENT_1 6
29 static cptr comment_1[MAX_COMMENT_1] =
50 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÄɲåá¥Ã¥»¡¼¥¸¡Ê¾µÂú¡Ë */
51 static cptr comment_1_B[MAX_COMMENT_1] = {
52 "¤Þ¤¢¡¢¤½¤ì¤Ç¤¤¤¤¤ä¡£",
53 "º£Æü¤Ï¤½¤ì¤Ç´ªÊÛ¤·¤Æ¤ä¤ë¡£",
60 #define MAX_COMMENT_2A 2
62 static cptr comment_2a[MAX_COMMENT_2A] =
65 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
66 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
68 "You try my patience. %s is final.",
69 "My patience grows thin. %s is final."
74 #define MAX_COMMENT_2B 12
76 static cptr comment_2b[MAX_COMMENT_2B] =
79 " $%s ¤°¤é¤¤¤Ï½Ð¤µ¤Ê¤¤ã¥À¥á¤À¤è¡£",
80 " $%s ¤Ê¤é¼õ¤±¼è¤Ã¤Æ¤â¤¤¤¤¤¬¡£",
81 "¥Ï¡ª $%s °Ê²¼¤Ï¤Ê¤¤¤Í¡£",
82 "²¿¤ÆÅÛ¤À¡ª $%s °Ê²¼¤Ï¤¢¤êÆÀ¤Ê¤¤¤¾¡£",
83 "¤½¤ì¤¸¤ã¾¯¤Ê¤¹¤®¤ë¡ª $%s ¤ÏÍߤ·¤¤¤È¤³¤í¤À¡£",
84 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤Ï¤â¤é¤ï¤Ê¤¤¤È¡£",
85 "±³¤À¤í¤¦¡ª $%s ¤Ç¤É¤¦¤À¤¤¡©",
86 "¤ª¤¤¤ª¤¤¡ª $%s ¤ò¹Í¤¨¤Æ¤¯¤ì¤Ê¤¤¤«¡©",
87 "1000ɤ¤Î¥ª¡¼¥¯¤Î¥Î¥ß¤Ë¶ì¤·¤á¤é¤ì¤ë¤¬¤¤¤¤¡ª $%s ¤À¡£",
88 "¤ªÁ°¤ÎÂçÀڤʤâ¤Î¤ËºÒ¤¤¤¢¤ì¡ª $%s ¤Ç¤É¤¦¤À¡£",
89 "¥â¥ë¥´¥¹¤Ë¾ÞÌ£¤µ¤ì¤ë¤¬¤¤¤¤¡ªËÜÅö¤Ï $%s ¤Ê¤ó¤À¤í¤¦¡©",
90 "¤ªÁ°¤ÎÊì¿Æ¤Ï¥ª¡¼¥¬¤«¡ª $%s ¤Ï½Ð¤¹¤Ä¤â¤ê¤Ê¤ó¤À¤í¡©"
92 "I can take no less than %s gold pieces.",
93 "I will accept no less than %s gold pieces.",
94 "Ha! No less than %s gold pieces.",
95 "You knave! No less than %s gold pieces.",
96 "That's a pittance! I want %s gold pieces.",
97 "That's an insult! I want %s gold pieces.",
98 "As if! How about %s gold pieces?",
99 "My arse! How about %s gold pieces?",
100 "May the fleas of 1000 orcs molest you! Try %s gold pieces.",
101 "May your most favourite parts go moldy! Try %s gold pieces.",
102 "May Morgoth find you tasty! Perhaps %s gold pieces?",
103 "Your mother was an Ogre! Perhaps %s gold pieces?"
109 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇä¤ë¤È¤¡Ë */
110 static cptr comment_2b_B[MAX_COMMENT_2B] = {
111 "¤¤¤¯¤é²¶Íͤ¬¤ª¿Í¹¥¤·¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¤Í¡£·ù¤Ê¤éµ¢¤ê¤Ê¡£",
112 "¶â¤¬¤Ê¤¤¤Î¤«¤¤¡¢¤¢¤ó¤¿¡©¤Þ¤º¤Ï²È¤Ëµ¢¤Ã¤Æ $%s ·¤¨¤Æ¤¤Ê¡£",
113 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅÛ¤À¤Ê¡£¤³¤ì¤Ï $%s ¤¬ÉáÄ̤ʤó¤À¤è¡£",
114 "²¶¤ÎÉÕ¤±¤¿ÃÍÃʤËʸ¶ç¤¬¤¢¤ë¤Î¤«¡© $%s ¤¬¸Â³¦¤À¡£",
115 "¤Ò¤ç¤Ã¤È¤·¤Æ¿·¼ê¤Î¾éÃ̤«¤¤¡© $%s »ý¤Ã¤Æ¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£",
116 "¤¦¤Á¤Ï¾¤ÎŹ¤È¤Ï°ã¤¦¤ó¤À¤è¡£$%s ¤°¤é¤¤¤Ï½Ð¤·¤Ê¡£",
117 "Ç㤦µ¤¤¬¤Ê¤¤¤Ê¤éµ¢¤ê¤Ê¡£ $%s ¤À¤È¸À¤Ã¤Æ¤¤¤ë¤ó¤À¡£",
118 "Ïäˤʤé¤Ê¤¤¤Í¡£ $%s ¤¯¤é¤¤»ý¤Ã¤Æ¤¤¤ë¤ó¤À¤í¡©",
119 "¤Ï¡©¤Ê¤ó¤À¤½¤ê¤ã¡© $%s ¤Î´Ö°ã¤¤¤«¡¢¤Ò¤ç¤Ã¤È¤·¤Æ¡©",
120 "½Ð¸ý¤Ï¤¢¤Ã¤Á¤À¤è¡£¤½¤ì¤È¤â $%s ½Ð¤»¤ë¤Î¤«¤¤¡¢¤¢¤ó¤¿¤Ë¡£",
121 "Ì¿ÃΤ餺¤ÊÅÛ¤À¤Ê¡£ $%s ½Ð¤»¤Ðº£Æü¤Î½ê¤Ï´ªÊÛ¤·¤Æ¤ä¤ë¤è¡£",
122 "¤¦¤Á¤ÎŹ¤ÏÉÏ˳¿Í¤ªÃǤê¤À¡£ $%s ¤°¤é¤¤½Ð¤»¤Ê¤¤¤Î¤«¤¤¡©"
125 #define MAX_COMMENT_3A 2
127 static cptr comment_3a[MAX_COMMENT_3A] =
130 "»ä¤ÎǦÂÑÎϤò»î¤·¤Æ¤¤¤ë¤Î¤«¤¤¡© $%s ¤¬ºÇ¸å¤À¡£",
131 "²æËý¤Ë¤â¸ÂÅÙ¤¬¤¢¤ë¤¾¡£ $%s ¤¬ºÇ¸å¤À¡£"
133 "You try my patience. %s is final.",
134 "My patience grows thin. %s is final."
140 #define MAX_COMMENT_3B 12
142 static cptr comment_3b[MAX_COMMENT_3B] =
145 "Ëܲ»¤ò¸À¤¦¤È $%s ¤Ç¤¤¤¤¤ó¤À¤í¡©",
147 " $%s ¤°¤é¤¤¤Ê¤é½Ð¤·¤Æ¤â¤¤¤¤¤¬¡£",
148 " $%s °Ê¾åʧ¤¦¤Ê¤ó¤Æ¹Í¤¨¤é¤ì¤Ê¤¤¤Í¡£",
149 "¤Þ¤¢Íî¤Á¤Ä¤¤¤Æ¡£ $%s ¤Ç¤É¤¦¤À¤¤¡©",
150 "¤½¤Î¥¬¥é¥¯¥¿¤Ê¤é $%s ¤Ç°ú¤¼è¤ë¤è¡£",
151 "¤½¤ì¤¸¤ã¹â¤¹¤®¤ë¡ª $%s ¤¬¤¤¤¤¤È¤³¤À¤í¡£",
152 "¤É¤¦¤»¤¤¤é¤Ê¤¤¤ó¤À¤í¡ª $%s ¤Ç¤¤¤¤¤À¤í¡©",
153 "¤À¤á¤À¤á¡ª $%s ¤¬¤º¤Ã¤È¤ª»÷¹ç¤¤¤À¤è¡£",
154 "¥Ð¥«¤Ë¤·¤Æ¤¤¤ë¡ª $%s ¤¬¤»¤¤¤¼¤¤¤À¡£",
155 " $%s ¤Ê¤é´ò¤·¤¤¤È¤³¤í¤À¤¬¤Ê¤¢¡£",
156 " $%s ¡¢¤½¤ì°Ê¾å¤Ï¥Ó¥¿°ìʸ½Ð¤µ¤Ê¤¤¤è¡ª"
158 "Perhaps %s gold pieces?",
159 "How about %s gold pieces?",
160 "I will pay no more than %s gold pieces.",
161 "I can afford no more than %s gold pieces.",
162 "Be reasonable. How about %s gold pieces?",
163 "I'll buy it as scrap for %s gold pieces.",
164 "That is too much! How about %s gold pieces?",
165 "That looks war surplus! Say %s gold pieces?",
166 "Never! %s is more like it.",
167 "That's an insult! %s is more like it.",
168 "%s gold pieces and be thankful for it!",
169 "%s gold pieces and not a copper more!"
175 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÇ㤤¼è¤ê¡Ë */
176 static cptr comment_3b_B[MAX_COMMENT_3B] = {
177 " $%s ¤Ã¤Æ¤È¤³¤í¤À¤Í¡£¤½¤Î¤É¤¦¤·¤è¤¦¤â¤Ê¤¤¥¬¥é¥¯¥¿¤Ï¡£",
178 "¤³¤Î²¶¤¬ $%s ¤Ã¤Æ¸À¤Ã¤Æ¤¤¤ë¤ó¤À¤«¤é¡¢¤½¤ÎÄ̤ê¤Ë¤·¤¿Êý¤¬¿È¤Î¤¿¤á¤À¤¾¡£",
179 "²¶¤ÎÍ¥¤·¤µ¤Ë´Å¤¨¤ë¤Î¤â¤¤¤¤²Ã¸º¤Ë¤·¤Æ¤ª¤±¡£ $%s ¤À¡£",
180 "¤½¤ÎÉʤʤé $%s ¤ÇÇä¤Ã¤Æ¤¯¤ì¤Æ¤¤¤ë¤¬¤Í¡¢¾ï¼±¤¢¤ë¿Â»Î¤Ï¤ß¤ó¤Ê¡£",
181 "¤³¤ê¤ã¤Þ¤¿¡¢¤¬¤á¤Ä¤¤ÅÛ¤À¤Ê¡£¤¤¤¯¤é²¶¤¬²¹¸ü¤È¤Ï¤¤¤¨ $%s ¤¬¸Â³¦¤À¡£",
182 " $%s ¤À¡£Ê̤˲¶¤Ï¤½¤ó¤Ê¥¬¥é¥¯¥¿Íߤ·¤¯¤Ï¤Ê¤¤¤ó¤À¤«¤é¡£",
183 "²¶¤Î´ÕÄê³Û¤¬µ¤¤ËÆþ¤é¤Ê¤¤¤Î¤«¡© $%s ¡¢·ù¤Ê¤éµ¢¤ê¤Ê¡£",
184 " $%s ¤Ç°ú¤¼è¤Ã¤Æ¤ä¤ë¤è¡£´î¤ó¤Ç¼õ¤±¼è¤ê¤Ê¡¢ÉÏ˳¿Í¡£",
185 "ʪ¤Î²ÁÃͤ¬Ê¬¤«¤é¤óÅۤϻÏËö¤Ë¤ª¤¨¤ó¤Ê¡£¤½¤ì¤Ï $%s ¤Ê¤ó¤À¤è¡£",
186 "¤½¤ó¤Ê¤Ë¶â¤¬Íߤ·¤¤¤Î¤«¡¢¤¢¤ó¤¿¡© $%s ¤ÇËþ¤Ǥ¤ó¤Î¤«¡©",
187 "Æþ¤ëŹ´Ö°ã¤¨¤Æ¤ó¤¸¤ã¤Ê¤¤¤Î¤«¡© $%s ¤Ç·ù¤Ê¤é¾¤ò¤¢¤¿¤Ã¤Æ¤¯¤ì¡£",
188 "²¶¤Î¸À¤¤Ãͤ˥±¥Á¤ò¤Ä¤±¤ëÅÛ¤¬¤¤¤ë¤È¤Ï¡ª ¤½¤ÎÅÙ¶»¤ËÌȤ¸¤Æ $%s ¤À¡£"
191 #define MAX_COMMENT_4A 4
193 static cptr comment_4a[MAX_COMMENT_4A] =
196 "¤â¤¦¤¿¤¯¤µ¤ó¤À¡ª²¿ÅÙ¤â»ä¤ò¤ï¤º¤é¤ï¤»¤Ê¤¤¤Ç¤¯¤ì¡ª",
197 "¤¦¤¬¡¼¡ª°ìÆü¤Î²æËý¤Î¸ÂÅÙ¤òĶ¤¨¤Æ¤¤¤ë¡ª",
198 "¤â¤¦¤¤¤¤¡ª»þ´Ö¤Î̵Â̰ʳ°¤Î¤Ê¤Ë¤â¤Î¤Ç¤â¤Ê¤¤¡ª",
199 "¤â¤¦¤ä¤Ã¤Æ¤é¤ì¤Ê¤¤¤è¡ª´é¤â¸«¤¿¤¯¤Ê¤¤¡ª"
201 "Enough! You have abused me once too often!",
202 "Arghhh! I have had enough abuse for one day!",
203 "That does it! You shall waste my time no more!",
204 "This is getting nowhere! I'm going to Londis!"
210 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¤ÎĺÅÀ¡Ë */
211 static cptr comment_4a_B[MAX_COMMENT_4A] = {
212 "¤Ê¤á¤ä¤¬¤Ã¤Æ¡ª²¹¸ü¤Ê²¶ÍͤǤâ¸Â³¦¤¬¤¢¤ë¤Ã¤Æ¤³¤È¤òÃΤ졪",
213 "²¶¤ò¤³¤³¤Þ¤ÇÅܤ餻¤Æ...Ì¿¤¬¤¢¤ë¤À¤±¤Ç¤â¤¢¤ê¤¬¤¿¤¤¤È»×¤¨¡ª",
214 "¤Õ¤¶¤±¤Æ¤ë¤Î¤«¡ªÎä¤ä¤«¤·¤Ê¤éÁê¼ê¤ò¸«¤Æ¤«¤é¤Ë¤·¤í¡ª",
215 "¤¤¤¤¤«¤²¤ó¤Ë¤·¤í¡ªº£ÅÙ¤³¤ó¤Ê¤Þ¤Í¤·¤¿¤é¤¿¤À¤¸¤ã¤ª¤«¤Í¤¨¤¾¡ª"
218 #define MAX_COMMENT_4B 4
220 static cptr comment_4b[MAX_COMMENT_4B] =
224 "²¶¤ÎÁ°¤«¤é¾Ã¤¨¼º¤»¤í¡ª",
225 "¤É¤Ã¤«¤Ë¹Ô¤Ã¤Á¤Þ¤¨¡ª",
226 "½Ð¤í¡¢½Ð¤í¡¢½Ð¤Æ¹Ô¤±¡ª"
229 "Get out of my sight!",
230 "Begone, you scoundrel!",
237 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÄɤ¤½Ð¤·¡Ë */
238 static cptr comment_4b_B[MAX_COMMENT_4B] = {
239 "ÆóÅ٤Ȥ¦¤Á¤ËÍè¤ë¤ó¤¸¤ã¤Í¤¨¡ª¡ª",
240 "¤È¤Ã¤È¤È¡¢¤É¤Ã¤«¤Ø¼º¤»¤í¡ª¡ª",
241 "º£¤¹¤°¾Ã¤¨¼º¤»¤í¡ª¡ª",
242 "½Ð¤Æ¤¤¤±¡ª½Ð¤Æ¤¤¤±¡ª¡ª"
245 #define MAX_COMMENT_5 8
247 static cptr comment_5[MAX_COMMENT_5] =
252 "¤â¤Ã¤È¿¿ÌÌÌܤ˸À¤Ã¤Æ¤¯¤ì¡ª",
253 "¸ò¾Ä¤¹¤ëµ¤¤¬¤¢¤ë¤Î¤«¤¤¡©",
254 "Îä¤ä¤«¤·¤ËÍ褿¤Î¤«¡ª",
257 "¤Õ¡¼¤à¡¢Îɤ¤Å·µ¤¤À¡£"
261 "You will have to do better than that!",
262 "Do you wish to do business or not?",
263 "You've got to be kidding!",
264 "You'd better be kidding!",
265 "You try my patience.",
266 "Hmmm, nice weather we're having."
272 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥ÈÍÑÄɲåá¥Ã¥»¡¼¥¸¡ÊÅܤê¡Ë */
273 static cptr comment_5_B[MAX_COMMENT_5] = {
274 "»þ´Ö¤Î̵Â̤À¤Ê¡¢¤³¤ì¤Ï¡£",
275 "Ìñ²ð¤Ê¤ªµÒÍͤÀ¤Ê¡ª",
276 "Ïä·¤Æʬ¤«¤ëÁê¼ê¤¸¤ã¤Ê¤µ¤½¤¦¤À¡£",
277 "Äˤ¤Ìܤˤ¢¤¤¤¿¤¤¤é¤·¤¤¤Ê¡ª",
278 "¤Ê¤ó¤Æ¶¯ÍߤÊÅÛ¤À¡ª",
280 "¤É¤¦¤·¤è¤¦¤â¤Ê¤¤ÉÏ˳¿Í¤À¡ª",
281 "·ö²Þ¤òÇä¤Ã¤Æ¤¤¤ë¤Î¤«¡©"
284 #define MAX_COMMENT_6 4
286 static cptr comment_6[MAX_COMMENT_6] =
289 "¤É¤¦¤ä¤éʹ¤´Ö°ã¤¨¤¿¤é¤·¤¤¡£",
290 "¼ºÎé¡¢¤è¤¯Ê¹¤³¤¨¤Ê¤«¤Ã¤¿¤è¡£",
291 "¤¹¤Þ¤Ê¤¤¡¢²¿¤À¤Ã¤Æ¡©",
292 "°¤¤¡¢¤â¤¦°ìÅÙ¸À¤Ã¤Æ¤¯¤ì¤ë¡©"
294 "I must have heard you wrong.",
295 "I'm sorry, I missed that.",
296 "I'm sorry, what was that?",
297 "Sorry, what was that again?"
307 static void say_comment_1(void)
312 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
313 if ( cur_store_num == STORE_BLACK ) {
314 msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
317 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
320 msg_print(comment_1[randint0(MAX_COMMENT_1)]);
324 if (one_in_(RUMOR_CHANCE))
327 msg_print("Ź¼ç¤Ï¼ª¤¦¤Á¤·¤¿:");
329 msg_print("The shopkeeper whispers something into your ear:");
334 if (!get_rnd_line_jonly("rumors_j.txt", 0, rumour, 10))
336 if (!get_rnd_line("rumors.txt", 0, rumour))
345 * Continue haggling (player is buying)
347 static void say_comment_2(s32b value, int annoyed)
351 /* Prepare a string to insert */
352 sprintf(tmp_val, "%ld", (long)value);
357 /* Formatted message */
358 msg_format(comment_2a[randint0(MAX_COMMENT_2A)], tmp_val);
364 /* Formatted message */
366 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
367 if ( cur_store_num == STORE_BLACK ){
368 msg_format(comment_2b_B[randint0(MAX_COMMENT_2B)], tmp_val);
371 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
374 msg_format(comment_2b[randint0(MAX_COMMENT_2B)], tmp_val);
382 * Continue haggling (player is selling)
384 static void say_comment_3(s32b value, int annoyed)
388 /* Prepare a string to insert */
389 sprintf(tmp_val, "%ld", (long)value);
394 /* Formatted message */
395 msg_format(comment_3a[randint0(MAX_COMMENT_3A)], tmp_val);
401 /* Formatted message */
403 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
404 if ( cur_store_num == STORE_BLACK ){
405 msg_format(comment_3b_B[randint0(MAX_COMMENT_3B)], tmp_val);
408 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
411 msg_format(comment_3b[randint0(MAX_COMMENT_3B)], tmp_val);
419 * Kick 'da bum out. -RAK-
421 static void say_comment_4(void)
424 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
425 if ( cur_store_num == STORE_BLACK ){
426 msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
427 msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
430 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
431 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
434 msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
435 msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
442 * You are insulting me
444 static void say_comment_5(void)
447 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
448 if ( cur_store_num == STORE_BLACK ){
449 msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
452 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
455 msg_print(comment_5[randint0(MAX_COMMENT_5)]);
462 * That makes no sense.
464 static void say_comment_6(void)
466 msg_print(comment_6[randint0(MAX_COMMENT_6)]);
472 * Messages for reacting to purchase prices.
475 #define MAX_COMMENT_7A 4
477 static cptr comment_7a[MAX_COMMENT_7A] =
482 "狼¤¬¤à¤»¤Óµã¤¯À¼¤¬Ê¹¤³¤¨¤ë...¡£",
483 "Ź¼ç¤¬²ù¤·¤²¤Ë¤ï¤á¤¤¤Æ¤¤¤ë¡ª"
487 "You hear someone sobbing...",
488 "The shopkeeper howls in agony!"
493 #define MAX_COMMENT_7B 4
495 static cptr comment_7b[MAX_COMMENT_7B] =
500 "Ź¼ç¤¬º¨¤á¤·¤½¤¦¤Ë¸«¤Æ¤¤¤ë¡£",
505 "The shopkeeper curses at you.",
506 "The shopkeeper glares at you."
511 #define MAX_COMMENT_7C 4
513 static cptr comment_7c[MAX_COMMENT_7C] =
517 "·¯¤¬Å·»È¤Ë¸«¤¨¤ë¤è¡ª",
518 "Ź¼ç¤¬¥¯¥¹¥¯¥¹¾Ð¤Ã¤Æ¤¤¤ë¡£",
519 "Ź¼ç¤¬ÂçÀ¼¤Ç¾Ð¤Ã¤Æ¤¤¤ë¡£"
522 "You've made my day!",
523 "The shopkeeper giggles.",
524 "The shopkeeper laughs loudly."
529 #define MAX_COMMENT_7D 4
531 static cptr comment_7d[MAX_COMMENT_7D] =
535 "¤³¤ó¤Ê¤ª¤¤¤·¤¤»×¤¤¤ò¤·¤¿¤é¡¢¿¿ÌÌÌܤËƯ¤±¤Ê¤¯¤Ê¤ë¤Ê¤¡¡£",
536 "Ź¼ç¤Ï´ò¤·¤¯¤ÆÄ·¤Í²ó¤Ã¤Æ¤¤¤ë¡£",
537 "Ź¼ç¤ÏËþÌ̤˾Фߤò¤¿¤¿¤¨¤Æ¤¤¤ë¡£"
540 "I think I'll retire!",
541 "The shopkeeper jumps for joy.",
542 "The shopkeeper smiles gleefully."
549 * Let a shop-keeper React to a purchase
551 * We paid "price", it was worth "value", and we thought it was worth "guess"
553 static void purchase_analyze(s32b price, s32b value, s32b guess)
555 /* Item was worthless, but we bought it */
556 if ((value <= 0) && (price > value))
559 msg_print(comment_7a[randint0(MAX_COMMENT_7A)]);
561 chg_virtue(V_HONOUR, -1);
562 chg_virtue(V_JUSTICE, -1);
568 /* Item was cheaper than we thought, and we paid more than necessary */
569 else if ((value < guess) && (price > value))
572 msg_print(comment_7b[randint0(MAX_COMMENT_7B)]);
574 chg_virtue(V_JUSTICE, -1);
576 chg_virtue(V_HONOUR, -1);
582 /* Item was a good bargain, and we got away with it */
583 else if ((value > guess) && (value < (4 * guess)) && (price < value))
586 msg_print(comment_7c[randint0(MAX_COMMENT_7C)]);
589 chg_virtue(V_HONOUR, -1);
591 chg_virtue(V_HONOUR, 1);
597 /* Item was a great bargain, and we got away with it */
598 else if ((value > guess) && (price < value))
601 msg_print(comment_7d[randint0(MAX_COMMENT_7D)]);
604 chg_virtue(V_HONOUR, -1);
606 chg_virtue(V_HONOUR, 1);
608 if (10 * price < value)
609 chg_virtue(V_SACRIFICE, 1);
621 /* ÆüËܸìÈǤξì¹ç¤Ï¾å¤ÎÊý¤Ë°ÜÆ°¤·¤Æ¤¢¤ê¤Þ¤¹ */
624 * We store the current "store number" here so everyone can access it
626 static int cur_store_num = 7;
629 * We store the current "store page" here so everyone can access it
631 static int store_top = 0;
634 * We store the current "store pointer" here so everyone can access it
636 static store_type *st_ptr = NULL;
639 * We store the current "owner type" here so everyone can access it
641 static owner_type *ot_ptr = NULL;
651 * Buying and selling adjustments for race combinations.
652 * Entry[owner][player] gives the basic "cost inflation".
654 static byte rgold_adj[MAX_RACES][MAX_RACES] =
656 /*Hum, HfE, Elf, Hal, Gno, Dwa, HfO, HfT, Dun, HiE, Barbarian,
657 HfOg, HGn, HTn, Cyc, Yek, Klc, Kbd, Nbl, DkE, Drc, Mind Flayer,
658 Imp, Glm, Skl, Zombie, Vampire, Spectre, Fairy, Beastman, Ent,
662 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
663 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
664 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
665 100, 120, 110, 105 },
668 { 110, 100, 100, 105, 110, 120, 125, 130, 110, 100, 110,
669 120, 115, 108, 115, 110, 110, 120, 120, 115, 115, 110,
670 120, 110, 110, 110, 120, 110, 100, 125, 100, 95, 140,
671 110, 115, 110, 110 },
674 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
675 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
676 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
677 110, 110, 105, 110 },
680 { 115, 110, 105, 95, 105, 110, 115, 130, 115, 105, 115,
681 125, 120, 120, 125, 115, 110, 120, 120, 120, 115, 115,
682 120, 110, 120, 120, 130, 110, 110, 130, 110, 95, 140,
683 115, 120, 105, 115 },
686 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
687 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
688 120, 101, 110, 110, 120, 120, 115, 130, 115, 95, 140,
689 115, 110, 110, 115 },
692 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
693 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
694 120, 105, 115, 115, 115, 115, 120, 130, 120, 95, 140,
695 115, 110, 115, 115 },
698 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
699 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
700 115, 125, 120, 120, 115, 120, 125, 115, 125, 95, 140,
701 115, 110, 115, 115 },
704 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
705 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
706 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
707 110, 110, 115, 110 },
710 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
711 120, 120, 105, 120, 115, 105, 115, 120, 110, 105, 105,
712 120, 105, 120, 120, 125, 120, 105, 135, 105, 95, 140,
713 100, 110, 110, 100 },
716 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
717 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
718 125, 115, 120, 120, 125, 120, 100, 125, 100, 95, 140,
719 110, 110, 105, 110 },
721 /* Human / Barbarian (copied from human) */
722 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
723 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
724 115, 105, 125, 125, 130, 125, 115, 120, 115, 95, 140,
725 100, 120, 110, 100 },
727 /* Half-Ogre: theoretical, copied from half-troll */
728 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
729 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
730 110, 115, 112, 112, 115, 112, 120, 110, 120, 95, 140,
731 110, 110, 115, 110 },
733 /* Half-Giant: theoretical, copied from half-troll */
734 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
735 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
736 110, 115, 112, 112, 115, 112, 130, 120, 130, 95, 140,
737 110, 110, 115, 110 },
739 /* Half-Titan: theoretical, copied from High_Elf */
740 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
741 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
742 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
743 110, 110, 115, 110 },
745 /* Cyclops: theoretical, copied from half-troll */
746 { 110, 115, 115, 110, 110, 130, 110, 110, 110, 115, 110,
747 110, 115, 120, 110, 120, 120, 110, 110, 110, 115, 110,
748 110, 115, 112, 112, 115, 112, 130, 130, 130, 95, 140,
749 110, 110, 115, 110 },
751 /* Yeek: theoretical, copied from Half-Orc */
752 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
753 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
754 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
755 115, 110, 115, 115 },
757 /* Klackon: theoretical, copied from Gnome */
758 { 115, 115, 110, 105, 95, 110, 115, 130, 115, 110, 115,
759 120, 125, 110, 120, 110, 105, 120, 110, 110, 105, 110,
760 120, 101, 110, 110, 120, 120, 130, 130, 130, 95, 140,
761 115, 110, 115, 115 },
763 /* Kobold: theoretical, copied from Half-Orc */
764 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
765 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
766 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
767 115, 110, 115, 115 },
769 /* Nibelung: theoretical, copied from Dwarf */
770 { 115, 120, 120, 110, 110, 95, 125, 135, 115, 120, 115,
771 125, 140, 130, 130, 120, 115, 115, 115, 135, 125, 120,
772 120, 105, 115, 115, 120, 120, 130, 130, 130, 95, 140,
773 115, 135, 115, 115 },
776 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
777 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
778 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
779 110, 101, 115, 110 },
781 /* Draconian: theoretical, copied from High_Elf */
782 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
783 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
784 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
785 110, 110, 115, 110 },
787 /* Mind Flayer: theoretical, copied from High_Elf */
788 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
789 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
790 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
791 110, 110, 115, 110 },
793 /* Imp: theoretical, copied from High_Elf */
794 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
795 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
796 125, 115, 120, 120, 120, 120, 130, 130, 130, 120, 120,
797 110, 110, 115, 110 },
799 /* Golem: theoretical, copied from High_Elf */
800 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
801 125, 125, 101, 120, 115, 110, 115, 125, 110, 110, 110,
802 125, 115, 120, 120, 120, 120, 130, 130, 130, 95, 140,
803 110, 110, 115, 110 },
805 /* Skeleton: theoretical, copied from half-orc */
806 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
807 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
808 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
809 115, 110, 125, 115 },
811 /* Zombie: Theoretical, copied from half-orc */
812 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
813 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
814 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
815 115, 110, 125, 115 },
817 /* Vampire: Theoretical, copied from half-orc */
818 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
819 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
820 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
821 115, 110, 125, 115 },
823 /* Spectre: Theoretical, copied from half-orc */
824 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
825 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
826 115, 125, 120, 120, 120, 120, 130, 130, 130, 120, 120,
827 115, 110, 125, 115 },
829 /* Sprite: Theoretical, copied from half-orc */
830 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
831 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
832 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
833 115, 110, 105, 115 },
835 /* Beastman: Theoretical, copied from half-orc */
836 { 115, 120, 125, 115, 115, 130, 110, 115, 115, 125, 115,
837 110, 110, 120, 110, 120, 125, 115, 115, 110, 120, 110,
838 115, 125, 120, 120, 120, 120, 130, 130, 130, 95, 140,
839 115, 110, 115, 115 },
842 { 110, 105, 100, 105, 110, 120, 125, 130, 110, 100, 110,
843 120, 120, 105, 120, 110, 105, 125, 125, 110, 115, 108,
844 120, 115, 110, 110, 120, 110, 100, 125, 100, 95, 140,
845 110, 110, 105, 110 },
848 { 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
849 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95,
850 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 160,
854 { 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
855 140, 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
856 140, 140, 140, 140, 140, 140, 140, 140, 140, 160, 120,
857 140, 140, 140, 140 },
860 { 100, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
861 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
862 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
863 100, 120, 110, 100 },
866 { 110, 110, 110, 115, 120, 130, 115, 115, 120, 110, 115,
867 115, 115, 116, 115, 120, 120, 115, 115, 101, 110, 110,
868 110, 110, 112, 122, 110, 110, 110, 115, 110, 120, 120,
869 110, 101, 115, 110 },
872 { 110, 110, 105, 105, 110, 115, 115, 115, 110, 105, 110,
873 115, 115, 115, 115, 115, 115, 115, 115, 115, 115, 115,
874 115, 115, 125, 125, 125, 125, 105, 115, 105, 95, 140,
875 110, 115, 100, 110 },
878 { 105, 105, 105, 110, 113, 115, 120, 125, 100, 105, 100,
879 124, 120, 110, 125, 115, 120, 120, 120, 120, 115, 120,
880 115, 105, 125, 125, 125, 125, 105, 120, 105, 95, 140,
881 100, 120, 110, 100 },
888 * Determine the price of an item (qty one) in a store.
890 * This function takes into account the player's charisma, and the
891 * shop-keepers friendliness, and the shop-keeper's base greed, but
892 * never lets a shop-keeper lose money in a transaction.
894 * The "greed" value should exceed 100 when the player is "buying" the
895 * item, and should be less than 100 when the player is "selling" it.
897 * Hack -- the black market always charges twice as much as it should.
899 * Charisma adjustment runs from 80 to 130
900 * Racial adjustment runs from 95 to 130
902 * Since greed/charisma/racial adjustments are centered at 100, we need
903 * to adjust (by 200) to extract a usable multiplier. Note that the
904 * "greed" value is always something (?).
906 static s32b price_item(object_type *o_ptr, int greed, bool flip)
913 /* Get the value of one of the items */
914 price = object_value(o_ptr);
916 /* Worthless items */
917 if (price <= 0) return (0L);
920 /* Compute the racial factor */
921 factor = rgold_adj[ot_ptr->owner_race][p_ptr->prace];
923 /* Add in the charisma factor */
924 factor += adj_chr_gold[p_ptr->stat_ind[A_CHR]];
930 /* Adjust for greed */
931 adjust = 100 + (300 - (greed + factor));
933 /* Never get "silly" */
934 if (adjust > 100) adjust = 100;
936 /* Mega-Hack -- Black market sucks */
937 if (cur_store_num == STORE_BLACK)
941 /* Shop is selling */
944 /* Adjust for greed */
945 adjust = 100 + ((greed + factor) - 300);
947 /* Never get "silly" */
948 if (adjust < 100) adjust = 100;
950 /* Mega-Hack -- Black market sucks */
951 if (cur_store_num == STORE_BLACK)
955 /* Compute the final price (with rounding) */
956 /* Hack -- prevent overflow */
957 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
959 /* Note -- Never become "free" */
960 if (price <= 0L) return (1L);
962 /* Return the price */
968 * Certain "cheap" objects should be created in "piles"
969 * Some objects can be sold at a "discount" (in small piles)
971 static void mass_produce(object_type *o_ptr)
976 s32b cost = object_value(o_ptr);
979 /* Analyze the type */
982 /* Food, Flasks, and Lites */
987 if (cost <= 5L) size += damroll(3, 5);
988 if (cost <= 20L) size += damroll(3, 5);
989 if (cost <= 50L) size += damroll(2, 2);
996 if (cost <= 60L) size += damroll(3, 5);
997 if (cost <= 240L) size += damroll(1, 5);
998 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
999 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
1004 case TV_SORCERY_BOOK:
1005 case TV_NATURE_BOOK:
1009 case TV_ARCANE_BOOK:
1010 case TV_ENCHANT_BOOK:
1011 case TV_DAEMON_BOOK:
1012 case TV_CRUSADE_BOOK:
1014 case TV_HISSATSU_BOOK:
1016 if (cost <= 50L) size += damroll(2, 3);
1017 if (cost <= 500L) size += damroll(1, 3);
1035 if (o_ptr->name2) break;
1036 if (cost <= 10L) size += damroll(3, 5);
1037 if (cost <= 100L) size += damroll(3, 5);
1046 if (cost <= 5L) size += damroll(5, 5);
1047 if (cost <= 50L) size += damroll(5, 5);
1048 if (cost <= 500L) size += damroll(5, 5);
1054 if (cost <= 100L) size += damroll(2, 2);
1055 if (cost <= 1000L) size += damroll(2, 2);
1068 * Because many rods (and a few wands and staffs) are useful mainly
1069 * in quantity, the Black Market will occasionally have a bunch of
1076 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1078 if (cost < 1601L) size += damroll(1, 5);
1079 else if (cost < 3201L) size += damroll(1, 3);
1082 /* Ensure that mass-produced rods and wands get the correct pvals. */
1083 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1085 o_ptr->pval *= size;
1092 /* Pick a discount */
1097 else if (one_in_(25))
1101 else if (one_in_(150))
1105 else if (one_in_(300))
1109 else if (one_in_(500))
1115 if (o_ptr->art_name)
1117 if (cheat_peek && discount)
1120 msg_print("¥é¥ó¥À¥à¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÏÃÍ°ú¤¤Ê¤·¡£");
1122 msg_print("No discount on random artifacts.");
1129 /* Save the discount */
1130 o_ptr->discount = discount;
1132 /* Save the total pile size */
1133 o_ptr->number = size - (size * discount / 100);
1139 * Determine if a store item can "absorb" another item
1141 * See "object_similar()" for the same function for the "player"
1143 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1147 /* Hack -- Identical items cannot be stacked */
1148 if (o_ptr == j_ptr) return (0);
1150 /* Different objects cannot be stacked */
1151 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1153 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1154 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1156 /* Require many identical values */
1157 if (o_ptr->to_h != j_ptr->to_h) return (0);
1158 if (o_ptr->to_d != j_ptr->to_d) return (0);
1159 if (o_ptr->to_a != j_ptr->to_a) return (0);
1161 /* Require identical "artifact" names */
1162 if (o_ptr->name1 != j_ptr->name1) return (0);
1164 /* Require identical "ego-item" names */
1165 if (o_ptr->name2 != j_ptr->name2) return (0);
1167 /* Random artifacts don't stack !*/
1168 if (o_ptr->art_name || j_ptr->art_name) return (0);
1170 /* Hack -- Identical art_flags! */
1171 for (i = 0; i < TR_FLAG_SIZE; i++)
1172 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1174 /* Hack -- Never stack "powerful" items */
1175 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1177 /* Hack -- Never stack recharging items */
1178 if (o_ptr->timeout || j_ptr->timeout) return (0);
1180 /* Require many identical values */
1181 if (o_ptr->ac != j_ptr->ac) return (0);
1182 if (o_ptr->dd != j_ptr->dd) return (0);
1183 if (o_ptr->ds != j_ptr->ds) return (0);
1185 /* Hack -- Never stack chests */
1186 if (o_ptr->tval == TV_CHEST) return (0);
1187 if (o_ptr->tval == TV_STATUE) return (0);
1188 if (o_ptr->tval == TV_CAPTURE) return (0);
1190 /* Require matching discounts */
1191 if (o_ptr->discount != j_ptr->discount) return (0);
1193 /* They match, so they must be similar */
1199 * Allow a store item to absorb another item
1201 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1203 int max_num = (o_ptr->tval == TV_ROD) ?
1204 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1205 int total = o_ptr->number + j_ptr->number;
1206 int diff = (total > max_num) ? total - max_num : 0;
1208 /* Combine quantity, lose excess items */
1209 o_ptr->number = (total > max_num) ? max_num : total;
1211 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1212 if (o_ptr->tval == TV_ROD)
1214 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1217 /* Hack -- if wands are stacking, combine the charges. -LM- */
1218 if (o_ptr->tval == TV_WAND)
1220 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1226 * Check to see if the shop will be carrying too many objects -RAK-
1227 * Note that the shop, just like a player, will not accept things
1228 * it cannot hold. Before, one could "nuke" potions this way.
1230 * Return value is now int:
1232 * -1 : Can be combined to existing slot.
1233 * 1 : Cannot be combined but there are empty spaces.
1235 static int store_check_num(object_type *o_ptr)
1240 /* The "home" acts like the player */
1241 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1243 /* Check all the items */
1244 for (i = 0; i < st_ptr->stock_num; i++)
1246 /* Get the existing item */
1247 j_ptr = &st_ptr->stock[i];
1249 /* Can the new object be combined with the old one? */
1250 if (object_similar(j_ptr, o_ptr)) return -1;
1254 /* Normal stores do special stuff */
1257 /* Check all the items */
1258 for (i = 0; i < st_ptr->stock_num; i++)
1260 /* Get the existing item */
1261 j_ptr = &st_ptr->stock[i];
1263 /* Can the new object be combined with the old one? */
1264 if (store_object_similar(j_ptr, o_ptr)) return -1;
1268 /* Free space is always usable */
1270 * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1271 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1273 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1274 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1279 if (st_ptr->stock_num < st_ptr->stock_size) {
1284 /* But there was no room at the inn... */
1289 static bool is_blessed(object_type *o_ptr)
1291 u32b flgs[TR_FLAG_SIZE];
1292 object_flags(o_ptr, flgs);
1293 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1294 else return (FALSE);
1300 * Determine if the current store will purchase the given item
1302 * Note that a shop-keeper must refuse to buy "worthless" items
1304 static bool store_will_buy(object_type *o_ptr)
1306 /* Hack -- The Home is simple */
1307 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1309 /* Switch on the store */
1310 switch (cur_store_num)
1315 /* Analyze the type */
1316 switch (o_ptr->tval)
1319 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1331 case TV_BOTTLE: /* 'Green', recycling Angband */
1346 /* Analyze the type */
1347 switch (o_ptr->tval)
1368 /* Analyze the type */
1369 switch (o_ptr->tval)
1378 case TV_HISSATSU_BOOK:
1382 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1394 /* Analyze the type */
1395 switch (o_ptr->tval)
1398 case TV_CRUSADE_BOOK:
1408 monster_race *r_ptr = &r_info[o_ptr->pval];
1411 if (!(r_ptr->flags3 & RF3_EVIL))
1414 if (r_ptr->flags3 & RF3_GOOD) break;
1416 /* Accept animals */
1417 if (r_ptr->flags3 & RF3_ANIMAL) break;
1420 if (strchr("?!", r_ptr->d_char)) break;
1426 if (is_blessed(o_ptr)) break;
1435 case STORE_ALCHEMIST:
1437 /* Analyze the type */
1438 switch (o_ptr->tval)
1452 /* Analyze the type */
1453 switch (o_ptr->tval)
1455 case TV_SORCERY_BOOK:
1456 case TV_NATURE_BOOK:
1460 case TV_ARCANE_BOOK:
1461 case TV_ENCHANT_BOOK:
1462 case TV_DAEMON_BOOK:
1475 if(o_ptr->sval == SV_WIZSTAFF) break;
1476 else return (FALSE);
1483 /* Bookstore Shop */
1486 /* Analyze the type */
1487 switch (o_ptr->tval)
1489 case TV_SORCERY_BOOK:
1490 case TV_NATURE_BOOK:
1495 case TV_ARCANE_BOOK:
1496 case TV_ENCHANT_BOOK:
1497 case TV_DAEMON_BOOK:
1498 case TV_CRUSADE_BOOK:
1508 /* XXX XXX XXX Ignore "worthless" items */
1509 if (object_value(o_ptr) <= 0) return (FALSE);
1518 * Add the item "o_ptr" to the inventory of the "Home"
1520 * In all cases, return the slot (or -1) where the object was placed
1522 * Note that this is a hacked up version of "inven_carry()".
1524 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1525 * known, the player may have to pick stuff up and drop it again.
1527 static int home_carry(object_type *o_ptr)
1530 s32b value, j_value;
1535 /* Check each existing item (try to combine) */
1536 for (slot = 0; slot < st_ptr->stock_num; slot++)
1538 /* Get the existing item */
1539 j_ptr = &st_ptr->stock[slot];
1541 /* The home acts just like the player */
1542 if (object_similar(j_ptr, o_ptr))
1544 /* Save the new number of items */
1545 object_absorb(j_ptr, o_ptr);
1554 * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1555 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1558 if ( powerup_home == TRUE) {
1559 if (st_ptr->stock_num >= st_ptr->stock_size) {
1564 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1570 /* Determine the "value" of the item */
1571 value = object_value(o_ptr);
1573 /* Check existing slots to see if we must "slide" */
1574 for (slot = 0; slot < st_ptr->stock_num; slot++)
1577 j_ptr = &st_ptr->stock[slot];
1579 /* Hack -- readable books always come first */
1580 if ((o_ptr->tval == mp_ptr->spell_book) &&
1581 (j_ptr->tval != mp_ptr->spell_book)) break;
1582 if ((j_ptr->tval == mp_ptr->spell_book) &&
1583 (o_ptr->tval != mp_ptr->spell_book)) continue;
1585 /* Objects sort by decreasing type */
1586 if (o_ptr->tval > j_ptr->tval) break;
1587 if (o_ptr->tval < j_ptr->tval) continue;
1589 /* Can happen in the home */
1590 if (!object_aware_p(o_ptr)) continue;
1591 if (!object_aware_p(j_ptr)) break;
1593 /* Objects sort by increasing sval */
1594 if (o_ptr->sval < j_ptr->sval) break;
1595 if (o_ptr->sval > j_ptr->sval) continue;
1597 /* Objects in the home can be unknown */
1598 if (!object_known_p(o_ptr)) continue;
1599 if (!object_known_p(j_ptr)) break;
1602 * Hack: otherwise identical rods sort by
1603 * increasing recharge time --dsb
1605 if (o_ptr->tval == TV_ROD)
1607 if (o_ptr->pval < j_ptr->pval) break;
1608 if (o_ptr->pval > j_ptr->pval) continue;
1610 if ((o_ptr->tval == TV_CORPSE) || (o_ptr->tval == TV_FIGURINE) || (o_ptr->tval == TV_STATUE))
1612 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) break;
1613 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) break;
1616 /* Objects sort by decreasing value */
1617 j_value = object_value(j_ptr);
1618 if (value > j_value) break;
1619 if (value < j_value) continue;
1622 /* Slide the others up */
1623 for (i = st_ptr->stock_num; i > slot; i--)
1625 st_ptr->stock[i] = st_ptr->stock[i-1];
1628 /* More stuff now */
1629 st_ptr->stock_num++;
1631 /* Insert the new item */
1632 st_ptr->stock[slot] = *o_ptr;
1634 chg_virtue(V_SACRIFICE, -1);
1636 /* Return the location */
1642 * Add the item "o_ptr" to a real stores inventory.
1644 * If the item is "worthless", it is thrown away (except in the home).
1646 * If the item cannot be combined with an object already in the inventory,
1647 * make a new slot for it, and calculate its "per item" price. Note that
1648 * this price will be negative, since the price will not be "fixed" yet.
1649 * Adding an item to a "fixed" price stack will not change the fixed price.
1651 * In all cases, return the slot (or -1) where the object was placed
1653 static int store_carry(object_type *o_ptr)
1656 s32b value, j_value;
1660 /* Evaluate the object */
1661 value = object_value(o_ptr);
1663 /* Cursed/Worthless items "disappear" when sold */
1664 if (value <= 0) return (-1);
1666 /* All store items are fully *identified* */
1667 o_ptr->ident |= IDENT_MENTAL;
1669 /* Erase the inscription */
1670 o_ptr->inscription = 0;
1672 /* Erase the "feeling" */
1673 o_ptr->feeling = FEEL_NONE;
1675 /* Check each existing item (try to combine) */
1676 for (slot = 0; slot < st_ptr->stock_num; slot++)
1678 /* Get the existing item */
1679 j_ptr = &st_ptr->stock[slot];
1681 /* Can the existing items be incremented? */
1682 if (store_object_similar(j_ptr, o_ptr))
1684 /* Hack -- extra items disappear */
1685 store_object_absorb(j_ptr, o_ptr);
1693 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1696 /* Check existing slots to see if we must "slide" */
1697 for (slot = 0; slot < st_ptr->stock_num; slot++)
1700 j_ptr = &st_ptr->stock[slot];
1702 /* Objects sort by decreasing type */
1703 if (o_ptr->tval > j_ptr->tval) break;
1704 if (o_ptr->tval < j_ptr->tval) continue;
1706 /* Objects sort by increasing sval */
1707 if (o_ptr->sval < j_ptr->sval) break;
1708 if (o_ptr->sval > j_ptr->sval) continue;
1711 * Hack: otherwise identical rods sort by
1712 * increasing recharge time --dsb
1714 if (o_ptr->tval == TV_ROD)
1716 if (o_ptr->pval < j_ptr->pval) break;
1717 if (o_ptr->pval > j_ptr->pval) continue;
1720 /* Evaluate that slot */
1721 j_value = object_value(j_ptr);
1723 /* Objects sort by decreasing value */
1724 if (value > j_value) break;
1725 if (value < j_value) continue;
1728 /* Slide the others up */
1729 for (i = st_ptr->stock_num; i > slot; i--)
1731 st_ptr->stock[i] = st_ptr->stock[i-1];
1734 /* More stuff now */
1735 st_ptr->stock_num++;
1737 /* Insert the new item */
1738 st_ptr->stock[slot] = *o_ptr;
1740 /* Return the location */
1746 * Increase, by a given amount, the number of a certain item
1747 * in a certain store. This can result in zero items.
1749 static void store_item_increase(int item, int num)
1755 o_ptr = &st_ptr->stock[item];
1757 /* Verify the number */
1758 cnt = o_ptr->number + num;
1759 if (cnt > 255) cnt = 255;
1760 else if (cnt < 0) cnt = 0;
1761 num = cnt - o_ptr->number;
1763 /* Save the new number */
1764 o_ptr->number += num;
1769 * Remove a slot if it is empty
1771 static void store_item_optimize(int item)
1777 o_ptr = &st_ptr->stock[item];
1780 if (!o_ptr->k_idx) return;
1782 /* Must have no items */
1783 if (o_ptr->number) return;
1786 st_ptr->stock_num--;
1788 /* Slide everyone */
1789 for (j = item; j < st_ptr->stock_num; j++)
1791 st_ptr->stock[j] = st_ptr->stock[j + 1];
1794 /* Nuke the final slot */
1795 object_wipe(&st_ptr->stock[j]);
1800 * This function will keep 'crap' out of the black market.
1801 * Crap is defined as any item that is "available" elsewhere
1802 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1804 static bool black_market_crap(object_type *o_ptr)
1808 /* Ego items are never crap */
1809 if (o_ptr->name2) return (FALSE);
1811 /* Good items are never crap */
1812 if (o_ptr->to_a > 0) return (FALSE);
1813 if (o_ptr->to_h > 0) return (FALSE);
1814 if (o_ptr->to_d > 0) return (FALSE);
1816 /* Check all stores */
1817 for (i = 0; i < MAX_STORES; i++)
1819 if (i == STORE_HOME) continue;
1820 if (i == STORE_MUSEUM) continue;
1822 /* Check every item in the store */
1823 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1825 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1827 /* Duplicate item "type", assume crappy */
1828 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
1838 * Attempt to delete (some of) a random item from the store
1839 * Hack -- we attempt to "maintain" piles of items when possible.
1841 static void store_delete(void)
1845 /* Pick a random slot */
1846 what = randint0(st_ptr->stock_num);
1848 /* Determine how many items are here */
1849 num = st_ptr->stock[what].number;
1851 /* Hack -- sometimes, only destroy half the items */
1852 if (randint0(100) < 50) num = (num + 1) / 2;
1854 /* Hack -- sometimes, only destroy a single item */
1855 if (randint0(100) < 50) num = 1;
1857 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
1858 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
1860 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
1863 /* Actually destroy (part of) the item */
1864 store_item_increase(what, -num);
1865 store_item_optimize(what);
1870 * Creates a random item and gives it to a store
1871 * This algorithm needs to be rethought. A lot.
1872 * Currently, "normal" stores use a pre-built array.
1874 * Note -- the "level" given to "obj_get_num()" is a "favored"
1875 * level, that is, there is a much higher chance of getting
1876 * items with a level approaching that of the given level...
1878 * Should we check for "permission" to have the given item?
1880 static void store_create(void)
1882 int i, tries, level;
1888 /* Paranoia -- no room left */
1889 if (st_ptr->stock_num >= st_ptr->stock_size) return;
1892 /* Hack -- consider up to four items */
1893 for (tries = 0; tries < 4; tries++)
1896 if (cur_store_num == STORE_BLACK)
1898 /* Pick a level for object/magic */
1899 level = 25 + randint0(25);
1901 /* Random item (usually of given level) */
1902 i = get_obj_num(level);
1904 /* Handle failure */
1911 /* Hack -- Pick an item to sell */
1912 i = st_ptr->table[randint0(st_ptr->table_num)];
1914 /* Hack -- fake level for apply_magic() */
1915 level = rand_range(1, STORE_OBJ_LEVEL);
1919 /* Get local object */
1922 /* Create a new object of the chosen kind */
1923 object_prep(q_ptr, i);
1925 /* Apply some "low-level" magic (no artifacts) */
1926 apply_magic(q_ptr, level, FALSE, FALSE, FALSE, FALSE);
1928 /* Require valid object */
1929 if (!store_will_buy(q_ptr)) continue;
1931 /* Hack -- Charge lite's */
1932 if (q_ptr->tval == TV_LITE)
1934 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
1935 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
1939 /* The item is "known" */
1940 object_known(q_ptr);
1942 /* Mark it storebought */
1943 q_ptr->ident |= IDENT_STOREB;
1945 /* Mega-Hack -- no chests in stores */
1946 if (q_ptr->tval == TV_CHEST) continue;
1948 /* Prune the black market */
1949 if (cur_store_num == STORE_BLACK)
1951 /* Hack -- No "crappy" items */
1952 if (black_market_crap(q_ptr)) continue;
1954 /* Hack -- No "cheap" items */
1955 if (object_value(q_ptr) < 10) continue;
1957 /* No "worthless" items */
1958 /* if (object_value(q_ptr) <= 0) continue; */
1961 /* Prune normal stores */
1964 /* No "worthless" items */
1965 if (object_value(q_ptr) <= 0) continue;
1969 /* Mass produce and/or Apply discount */
1970 mass_produce(q_ptr);
1972 /* Attempt to carry the (known) item */
1973 (void)store_carry(q_ptr);
1975 /* Definitely done */
1983 * Eliminate need to bargain if player has haggled well in the past
1985 static bool noneedtobargain(s32b minprice)
1987 s32b good = st_ptr->good_buy;
1988 s32b bad = st_ptr->bad_buy;
1990 /* Cheap items are "boring" */
1991 if (minprice < 10L) return (TRUE);
1993 /* Perfect haggling */
1994 if (good == MAX_SHORT) return (TRUE);
1996 /* Reward good haggles, punish bad haggles, notice price */
1997 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
1999 /* Return the flag */
2005 * Update the bargain info
2007 static void updatebargain(s32b price, s32b minprice, int num)
2009 /* Hack -- auto-haggle */
2010 if (!manual_haggle) return;
2012 /* Cheap items are "boring" */
2013 if ((minprice/num) < 10L) return;
2015 /* Count the successful haggles */
2016 if (price == minprice)
2018 /* Just count the good haggles */
2019 if (st_ptr->good_buy < MAX_SHORT)
2025 /* Count the failed haggles */
2028 /* Just count the bad haggles */
2029 if (st_ptr->bad_buy < MAX_SHORT)
2039 * Re-displays a single store entry
2041 static void display_entry(int pos)
2047 char o_name[MAX_NLEN];
2054 o_ptr = &st_ptr->stock[pos];
2056 /* Get the "offset" */
2059 /* Label it, clear the line --(-- */
2060 (void)sprintf(out_val, "%c) ", I2A(i));
2061 prt(out_val, i+6, 0);
2064 if (show_item_graph)
2066 byte a = object_attr(o_ptr);
2067 char c = object_char(o_ptr);
2074 Term_draw(cur_col, i + 6, a, c);
2079 Term_draw(cur_col, i + 6, 255, -1);
2084 /* Describe an item in the home */
2085 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2089 /* Leave room for weights, if necessary -DRS- */
2090 if (show_weights) maxwid -= 10;
2092 /* Describe the object */
2093 object_desc(o_name, o_ptr, TRUE, 3);
2094 o_name[maxwid] = '\0';
2095 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2100 /* Only show the weight of an individual item */
2101 int wgt = o_ptr->weight;
2103 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2104 put_str(out_val, i+6, 67);
2106 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2107 put_str(out_val, i+6, 68);
2113 /* Describe an item (fully) in a store */
2116 /* Must leave room for the "price" */
2119 /* Leave room for weights, if necessary -DRS- */
2120 if (show_weights) maxwid -= 7;
2122 /* Describe the object (fully) */
2123 object_desc_store(o_name, o_ptr, TRUE, 3);
2124 o_name[maxwid] = '\0';
2125 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2130 /* Only show the weight of an individual item */
2131 int wgt = o_ptr->weight;
2133 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2134 put_str(out_val, i+6, 60);
2136 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2137 put_str(out_val, i+6, 61);
2142 /* Display a "fixed" cost */
2143 if (o_ptr->ident & (IDENT_FIXED))
2145 /* Extract the "minimum" price */
2146 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2148 /* Actually draw the price (not fixed) */
2150 (void)sprintf(out_val, "%9ld¸Ç", (long)x);
2152 (void)sprintf(out_val, "%9ld F", (long)x);
2155 put_str(out_val, i+6, 68);
2158 /* Display a "taxed" cost */
2159 else if (!manual_haggle)
2161 /* Extract the "minimum" price */
2162 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2164 /* Hack -- Apply Sales Tax if needed */
2165 if (!noneedtobargain(x)) x += x / 10;
2167 /* Actually draw the price (with tax) */
2168 (void)sprintf(out_val, "%9ld ", (long)x);
2169 put_str(out_val, i+6, 68);
2172 /* Display a "haggle" cost */
2175 /* Extrect the "maximum" price */
2176 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2178 /* Actually draw the price (not fixed) */
2179 (void)sprintf(out_val, "%9ld ", (long)x);
2180 put_str(out_val, i+6, 68);
2187 * Displays a store's inventory -RAK-
2188 * All prices are listed as "per individual object". -BEN-
2190 static void display_inventory(void)
2194 /* Display the next 12 items */
2195 for (k = 0; k < 12; k++)
2197 /* Do not display "dead" items */
2198 if (store_top + k >= st_ptr->stock_num) break;
2200 /* Display that line */
2201 display_entry(store_top + k);
2204 /* Erase the extra lines and the "more" prompt */
2205 for (i = k; i < 13; i++) prt("", i + 6, 0);
2207 /* Assume "no current page" */
2209 put_str(" ", 5, 20);
2211 put_str(" ", 5, 20);
2215 /* Visual reminder of "more items" */
2216 if (st_ptr->stock_num > 12)
2218 /* Show "more" reminder (after the last item) */
2220 prt("-³¤¯-", k + 6, 3);
2222 prt("-more-", k + 6, 3);
2226 /* Indicate the "current page" */
2227 /* Trailing spaces are to display (Page xx) and (Page x) */
2229 put_str(format("(%d¥Ú¡¼¥¸) ", store_top/12 + 1), 5, 20);
2231 put_str(format("(Page %d) ", store_top/12 + 1), 5, 20);
2239 * Displays players gold -RAK-
2241 static void store_prt_gold(void)
2246 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19, 53);
2248 prt("Gold Remaining: ", 19, 53);
2252 sprintf(out_val, "%9ld", (long)p_ptr->au);
2253 prt(out_val, 19, 68);
2258 * Displays store (after clearing screen) -RAK-
2260 static void display_store(void)
2268 /* The "Home" is special */
2269 if (cur_store_num == STORE_HOME)
2271 /* Put the owner name */
2273 put_str("²æ¤¬²È", 3, 31);
2275 put_str("Your Home", 3, 30);
2279 /* Label the item descriptions */
2281 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2283 put_str("Item Description", 5, 3);
2287 /* If showing weights, show label */
2291 put_str("½Å¤µ", 5, 72);
2293 put_str("Weight", 5, 70);
2299 /* The "Home" is special */
2300 else if (cur_store_num == STORE_MUSEUM)
2302 /* Put the owner name */
2304 put_str("Çîʪ´Û", 3, 31);
2306 put_str("Museum", 3, 30);
2310 /* Label the item descriptions */
2312 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2314 put_str("Item Description", 5, 3);
2318 /* If showing weights, show label */
2322 put_str("½Å¤µ", 5, 72);
2324 put_str("Weight", 5, 70);
2333 cptr store_name = (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name);
2334 cptr owner_name = (ot_ptr->owner_name);
2335 cptr race_name = race_info[ot_ptr->owner_race].title;
2337 /* Put the owner name and race */
2338 sprintf(buf, "%s (%s)", owner_name, race_name);
2339 put_str(buf, 3, 10);
2341 /* Show the max price in the store (above prices) */
2342 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2345 /* Label the item descriptions */
2347 put_str("¾¦ÉʤΰìÍ÷", 5, 7);
2349 put_str("Item Description", 5, 3);
2353 /* If showing weights, show label */
2357 put_str("½Å¤µ", 5, 62);
2359 put_str("Weight", 5, 60);
2364 /* Label the asking price (in stores) */
2366 put_str("²Á³Ê", 5, 73);
2368 put_str("Price", 5, 72);
2373 /* Display the current gold */
2376 /* Draw in the inventory */
2377 display_inventory();
2383 * Get the ID of a store item and return its value -RAK-
2385 static int get_stock(int *com_val, cptr pmt, int i, int j)
2391 #ifdef ALLOW_REPEAT /* TNB */
2393 /* Get the item index */
2394 if (repeat_pull(com_val))
2396 /* Verify the item */
2397 if ((*com_val >= i) && (*com_val <= j))
2404 #endif /* ALLOW_REPEAT -- TNB */
2406 /* Paranoia XXX XXX XXX */
2410 /* Assume failure */
2413 /* Build the prompt */
2415 (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
2416 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
2417 I2A(i), I2A(j), pmt);
2419 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2420 I2A(i), I2A(j), pmt);
2424 /* Ask until done */
2430 if (!get_com(out_val, &command, FALSE)) break;
2433 k = (islower(command) ? A2I(command) : -1);
2435 /* Legal responses */
2436 if ((k >= i) && (k <= j))
2446 /* Clear the prompt */
2450 if (command == ESCAPE) return (FALSE);
2452 #ifdef ALLOW_REPEAT /* TNB */
2454 repeat_push(*com_val);
2456 #endif /* ALLOW_REPEAT -- TNB */
2464 * Increase the insult counter and get angry if too many -RAK-
2466 static int increase_insults(void)
2468 /* Increase insults */
2469 st_ptr->insult_cur++;
2471 /* Become insulted */
2472 if (st_ptr->insult_cur > ot_ptr->insult_max)
2478 st_ptr->insult_cur = 0;
2479 st_ptr->good_buy = 0;
2480 st_ptr->bad_buy = 0;
2483 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2495 * Decrease insults -RAK-
2497 static void decrease_insults(void)
2499 /* Decrease insults */
2500 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2505 * Have insulted while haggling -RAK-
2507 static int haggle_insults(void)
2509 /* Increase insults */
2510 if (increase_insults()) return (TRUE);
2512 /* Display and flush insult */
2521 * Mega-Hack -- Enable "increments"
2523 static bool allow_inc = FALSE;
2526 * Mega-Hack -- Last "increment" during haggling
2528 static s32b last_inc = 0L;
2534 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
2544 /* Clear old increment if necessary */
2545 if (!allow_inc) last_inc = 0L;
2552 sprintf(buf, "%s [¾µÂú] ", pmt);
2554 sprintf(buf, "%s [accept] ", pmt);
2559 /* Old (negative) increment, and not final */
2560 else if (last_inc < 0)
2563 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2565 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2570 /* Old (positive) increment, and not final */
2571 else if (last_inc > 0)
2574 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2576 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2584 sprintf(buf, "%s ", pmt);
2588 /* Paranoia XXX XXX XXX */
2592 /* Ask until done */
2596 strcpy(out_val, "");
2598 /* Ask the user for a response */
2599 if (!get_string(buf, out_val, 32)) return (FALSE);
2601 /* Skip leading spaces */
2602 for (p = out_val; *p == ' '; p++) /* loop */;
2604 /* Empty response */
2607 /* Accept current price */
2615 /* Use previous increment */
2616 if (allow_inc && last_inc)
2618 *poffer += last_inc;
2623 /* Normal response */
2626 /* Extract a number */
2629 /* Handle "incremental" number */
2630 if ((*p == '+' || *p == '-'))
2632 /* Allow increments */
2635 /* Use the given "increment" */
2642 /* Handle normal number */
2645 /* Use the given "number" */
2654 msg_print("Ãͤ¬¤ª¤«¤·¤¤¤Ç¤¹¡£");
2656 msg_print("Invalid response.");
2668 * Receive an offer (from the player)
2670 * Return TRUE if offer is NOT okay
2672 static bool receive_offer(cptr pmt, s32b *poffer,
2673 s32b last_offer, int factor,
2674 s32b price, int final)
2676 /* Haggle till done */
2679 /* Get a haggle (or cancel) */
2680 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2682 /* Acceptable offer */
2683 if (((*poffer) * factor) >= (last_offer * factor)) break;
2685 /* Insult, and check for kicked out */
2686 if (haggle_insults()) return (TRUE);
2688 /* Reject offer (correctly) */
2689 (*poffer) = last_offer;
2698 * Haggling routine -RAK-
2700 * Return TRUE if purchase is NOT successful
2702 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2704 s32b cur_ask, final_ask;
2705 s32b last_offer, offer;
2707 s32b min_per, max_per;
2708 int flag, loop_flag, noneed;
2709 int annoyed = 0, final = FALSE;
2711 bool cancel = FALSE;
2714 cptr pmt = "Ä󼨲Á³Ê";
2716 cptr pmt = "Asking";
2726 /* Extract the starting offer and the final offer */
2727 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2728 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2730 /* Determine if haggling is necessary */
2731 noneed = noneedtobargain(final_ask);
2733 /* No need to haggle */
2734 if (noneed || !manual_haggle)
2736 /* No need to haggle */
2739 /* Message summary */
2741 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2743 msg_print("You eventually agree upon the price.");
2749 /* No haggle option */
2752 /* Message summary */
2754 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2756 msg_print("You quickly agree upon the price.");
2761 /* Apply Sales Tax */
2762 final_ask += final_ask / 10;
2766 cur_ask = final_ask;
2768 /* Go to final offer */
2770 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2772 pmt = "Final Offer";
2779 /* Haggle for the whole pile */
2780 cur_ask *= o_ptr->number;
2781 final_ask *= o_ptr->number;
2784 /* Haggle parameters */
2785 min_per = ot_ptr->haggle_per;
2786 max_per = min_per * 3;
2788 /* Mega-Hack -- artificial "last offer" value */
2789 last_offer = object_value(o_ptr) * o_ptr->number;
2790 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
2791 if (last_offer <= 0) last_offer = 1;
2796 /* No incremental haggling yet */
2799 /* Haggle until done */
2800 for (flag = FALSE; !flag; )
2804 while (!flag && loop_flag)
2806 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
2807 put_str(out_val, 1, 0);
2809 cancel = receive_offer("Ä󼨤¹¤ë¶â³Û? ",
2811 cancel = receive_offer("What do you offer? ",
2814 &offer, last_offer, 1, cur_ask, final);
2820 else if (offer > cur_ask)
2825 else if (offer == cur_ask)
2838 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
2841 if (haggle_insults())
2847 else if (x1 > max_per)
2850 if (x1 < max_per) x1 = max_per;
2852 x2 = rand_range(x1-2, x1+2);
2853 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
2854 /* don't let the price go up */
2859 if (cur_ask < final_ask)
2862 cur_ask = final_ask;
2864 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2866 pmt = "Final Offer";
2872 (void)(increase_insults());
2877 else if (offer >= cur_ask)
2889 (void)sprintf(out_val, "Á°²ó¤ÎÄ󼨶â³Û: $%ld",
2891 (void)sprintf(out_val, "Your last offer: %ld",
2895 put_str(out_val, 1, 39);
2896 say_comment_2(cur_ask, annoyed);
2902 if (cancel) return (TRUE);
2904 /* Update bargaining info */
2905 updatebargain(*price, final_ask, o_ptr->number);
2913 * Haggling routine -RAK-
2915 * Return TRUE if purchase is NOT successful
2917 static bool sell_haggle(object_type *o_ptr, s32b *price)
2919 s32b purse, cur_ask, final_ask;
2920 s32b last_offer = 0, offer = 0;
2922 s32b min_per, max_per;
2923 int flag, loop_flag, noneed;
2924 int annoyed = 0, final = FALSE;
2925 bool cancel = FALSE;
2927 cptr pmt = "Ä󼨶â³Û";
2938 /* Obtain the starting offer and the final offer */
2939 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
2940 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
2942 /* Determine if haggling is necessary */
2943 noneed = noneedtobargain(final_ask);
2945 /* Get the owner's payout limit */
2946 purse = (s32b)(ot_ptr->max_cost);
2948 /* No need to haggle */
2949 if (noneed || !manual_haggle || (final_ask >= purse))
2951 /* Apply Sales Tax (if needed) */
2952 if (!manual_haggle && !noneed)
2954 final_ask -= final_ask / 10;
2957 /* No reason to haggle */
2958 if (final_ask >= purse)
2962 msg_print("¨ºÂ¤Ë¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2964 msg_print("You instantly agree upon the price.");
2969 /* Offer full purse */
2973 /* No need to haggle */
2978 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2980 msg_print("You eventually agree upon the price.");
2986 /* No haggle option */
2989 /* Message summary */
2991 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2993 msg_print("You quickly agree upon the price.");
3000 cur_ask = final_ask;
3005 pmt = "ºÇ½ªÄ󼨶â³Û";
3007 pmt = "Final Offer";
3012 /* Haggle for the whole pile */
3013 cur_ask *= o_ptr->number;
3014 final_ask *= o_ptr->number;
3017 /* XXX XXX XXX Display commands */
3019 /* Haggling parameters */
3020 min_per = ot_ptr->haggle_per;
3021 max_per = min_per * 3;
3023 /* Mega-Hack -- artificial "last offer" value */
3024 last_offer = object_value(o_ptr) * o_ptr->number;
3025 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3030 /* No incremental haggling yet */
3034 for (flag = FALSE; !flag; )
3040 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3041 put_str(out_val, 1, 0);
3043 cancel = receive_offer("Ä󼨤¹¤ë²Á³Ê? ",
3045 cancel = receive_offer("What price do you ask? ",
3048 &offer, last_offer, -1, cur_ask, final);
3054 else if (offer < cur_ask)
3057 /* rejected, reset offer for incremental haggling */
3060 else if (offer == cur_ask)
3071 if (flag || !loop_flag) break;
3076 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3079 if (haggle_insults())
3085 else if (x1 > max_per)
3088 if (x1 < max_per) x1 = max_per;
3090 x2 = rand_range(x1-2, x1+2);
3091 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3092 /* don't let the price go down */
3096 if (cur_ask > final_ask)
3098 cur_ask = final_ask;
3101 pmt = "ºÇ½ªÄ󼨶â³Û";
3103 pmt = "Final Offer";
3111 /* Äɲà $0 ¤ÇÇ㤤¼è¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ»ß By FIRST*/
3114 (void)(increase_insults());
3117 else if (offer <= cur_ask)
3128 (void)sprintf(out_val,
3130 "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
3132 "Your last bid %ld", (long)last_offer);
3135 put_str(out_val, 1, 39);
3136 say_comment_3(cur_ask, annoyed);
3142 if (cancel) return (TRUE);
3144 /* Update bargaining info */
3145 updatebargain(*price, final_ask, o_ptr->number);
3153 * Buy an item from a store -RAK-
3155 static void store_purchase(void)
3167 char o_name[MAX_NLEN];
3172 if (cur_store_num == STORE_MUSEUM)
3175 msg_print("Çîʪ´Û¤«¤é¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
3177 msg_print("Museum.");
3183 if (st_ptr->stock_num <= 0)
3185 if (cur_store_num == STORE_HOME)
3187 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3189 msg_print("Your home is empty.");
3194 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
3196 msg_print("I am currently out of stock.");
3203 /* Find the number of objects on this and following pages */
3204 i = (st_ptr->stock_num - store_top);
3206 /* And then restrict it to the current page */
3211 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
3212 switch( cur_store_num ) {
3214 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
3217 sprintf(out_val, "¤É¤ì? ");
3220 sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
3224 if (cur_store_num == STORE_HOME)
3226 sprintf(out_val, "Which item do you want to take? ");
3230 sprintf(out_val, "Which item are you interested in? ");
3235 /* Get the item number to be bought */
3236 if (!get_stock(&item, out_val, 0, i - 1)) return;
3238 /* Get the actual index */
3239 item = item + store_top;
3241 /* Get the actual item */
3242 o_ptr = &st_ptr->stock[item];
3244 /* Assume the player wants just one of them */
3247 /* Get local object */
3250 /* Get a copy of the object */
3251 object_copy(j_ptr, o_ptr);
3254 * If a rod or wand, allocate total maximum timeouts or charges
3255 * between those purchased and left on the shelf.
3257 reduce_charges(j_ptr, o_ptr->number - amt);
3259 /* Modify quantity */
3260 j_ptr->number = amt;
3262 /* Hack -- require room in pack */
3263 if (!inven_carry_okay(j_ptr))
3266 msg_print("¤½¤ó¤Ê¤Ë¥¢¥¤¥Æ¥à¤ò»ý¤Æ¤Ê¤¤¡£");
3268 msg_print("You cannot carry that many different items.");
3274 /* Determine the "best" price (per item) */
3275 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3277 /* Find out how many the player wants */
3278 if (o_ptr->number > 1)
3280 /* Hack -- note cost of "fixed" items */
3281 if ((cur_store_num != STORE_HOME) &&
3282 (o_ptr->ident & IDENT_FIXED))
3285 msg_format("°ì¤Ä¤Ë¤Ä¤ $%ld¤Ç¤¹¡£", (long)(best));
3287 msg_format("That costs %ld gold per item.", (long)(best));
3292 /* Get a quantity */
3293 amt = get_quantity(NULL, o_ptr->number);
3295 /* Allow user abort */
3296 if (amt <= 0) return;
3299 /* Get local object */
3302 /* Get desired object */
3303 object_copy(j_ptr, o_ptr);
3306 * If a rod or wand, allocate total maximum timeouts or charges
3307 * between those purchased and left on the shelf.
3309 reduce_charges(j_ptr, o_ptr->number - amt);
3311 /* Modify quantity */
3312 j_ptr->number = amt;
3314 /* Hack -- require room in pack */
3315 if (!inven_carry_okay(j_ptr))
3318 msg_print("¥¶¥Ã¥¯¤Ë¤½¤Î¥¢¥¤¥Æ¥à¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£");
3320 msg_print("You cannot carry that many items.");
3326 /* Attempt to buy it */
3327 if (cur_store_num != STORE_HOME)
3329 /* Fixed price, quick buy */
3330 if (o_ptr->ident & (IDENT_FIXED))
3335 /* Go directly to the "best" deal */
3336 price = (best * j_ptr->number);
3342 /* Describe the object (fully) */
3343 object_desc_store(o_name, j_ptr, TRUE, 3);
3347 msg_format("%s(%c)¤ò¹ØÆþ¤¹¤ë¡£", o_name, I2A(item));
3349 msg_format("Buying %s (%c).", o_name, I2A(item));
3354 /* Haggle for a final price */
3355 choice = purchase_haggle(j_ptr, &price);
3357 /* Hack -- Got kicked out */
3358 if (st_ptr->store_open >= turn) return;
3361 /* Player wants it */
3364 /* Fix the item price (if "correctly" haggled) */
3365 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3367 /* Player can afford it */
3368 if (p_ptr->au >= price)
3375 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3376 chg_virtue(V_JUSTICE, -1);
3377 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3378 chg_virtue(V_NATURE, -1);
3386 /* Spend the money */
3389 /* Update the display */
3392 /* Hack -- buying an item makes you aware of it */
3393 object_aware(j_ptr);
3395 /* Hack -- clear the "fixed" flag from the item */
3396 j_ptr->ident &= ~(IDENT_FIXED);
3398 /* Describe the transaction */
3399 object_desc(o_name, j_ptr, TRUE, 3);
3403 msg_format("%s¤ò $%ld¤Ç¹ØÆþ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3405 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3408 strcpy(record_o_name, o_name);
3411 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3412 object_desc(o_name, o_ptr, TRUE, 0);
3413 if(record_rand_art && o_ptr->art_name)
3414 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3416 /* Erase the inscription */
3417 j_ptr->inscription = 0;
3419 /* Erase the "feeling" */
3420 j_ptr->feeling = FEEL_NONE;
3421 j_ptr->ident &= ~(IDENT_STOREB);
3422 /* Give it to the player */
3423 item_new = inven_carry(j_ptr);
3425 /* Describe the final result */
3426 object_desc(o_name, &inventory[item_new], TRUE, 3);
3430 msg_format("%s(%c)¤ò¼ê¤ËÆþ¤ì¤¿¡£", o_name, index_to_label(item_new));
3432 msg_format("You have %s (%c).",
3433 o_name, index_to_label(item_new));
3436 /* Auto-inscription */
3437 idx = is_autopick(&inventory[item_new]);
3438 auto_inscribe_item(item_new, idx);
3440 /* Now, reduce the original stack's pval. */
3441 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3443 o_ptr->pval -= j_ptr->pval;
3449 /* Note how many slots the store used to have */
3450 i = st_ptr->stock_num;
3452 /* Remove the bought items from the store */
3453 store_item_increase(item, -amt);
3454 store_item_optimize(item);
3456 /* Store is empty */
3457 if (st_ptr->stock_num == 0)
3460 if (one_in_(STORE_SHUFFLE))
3465 msg_print("Ź¼ç¤Ï°úÂष¤¿¡£");
3467 msg_print("The shopkeeper retires.");
3471 /* Shuffle the store */
3472 store_shuffle(cur_store_num);
3475 sprintf(buf, "%s (%s)",
3476 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3477 put_str(buf, 3, 10);
3478 sprintf(buf, "%s (%ld)",
3479 (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name), (long)(ot_ptr->max_cost));
3488 msg_print("Ź¼ç¤Ï¿·¤¿¤Êºß¸Ë¤ò¼è¤ê½Ð¤·¤¿¡£");
3490 msg_print("The shopkeeper brings out some new stock.");
3496 for (i = 0; i < 10; i++)
3498 /* Maintain the store */
3499 store_maint(p_ptr->town_num, cur_store_num);
3505 /* Redraw everything */
3506 display_inventory();
3509 /* The item is gone */
3510 else if (st_ptr->stock_num != i)
3512 /* Pick the correct screen */
3513 if (store_top >= st_ptr->stock_num) store_top -= 12;
3515 /* Redraw everything */
3516 display_inventory();
3519 /* Item is still here */
3522 /* Redraw the item */
3523 display_entry(item);
3527 /* Player cannot afford it */
3530 /* Simple message (no insult) */
3532 msg_print("¤ª¶â¤¬Â¤ê¤Þ¤»¤ó¡£");
3534 msg_print("You do not have enough gold.");
3541 /* Home is much easier */
3544 /* Distribute charges of wands/rods */
3545 distribute_charges(o_ptr, j_ptr, amt);
3547 /* Give it to the player */
3548 item_new = inven_carry(j_ptr);
3550 /* Describe just the result */
3551 object_desc(o_name, &inventory[item_new], TRUE, 3);
3555 msg_format("%s(%c)¤ò¼è¤Ã¤¿¡£",
3557 msg_format("You have %s (%c).",
3559 o_name, index_to_label(item_new));
3564 /* Take note if we take the last one */
3565 i = st_ptr->stock_num;
3567 /* Remove the items from the home */
3568 store_item_increase(item, -amt);
3569 store_item_optimize(item);
3571 /* Hack -- Item is still here */
3572 if (i == st_ptr->stock_num)
3574 /* Redraw the item */
3575 display_entry(item);
3578 /* The item is gone */
3582 if (st_ptr->stock_num == 0) store_top = 0;
3584 /* Nothing left on that screen */
3585 else if (store_top >= st_ptr->stock_num) store_top -= 12;
3587 /* Redraw everything */
3588 display_inventory();
3590 chg_virtue(V_SACRIFICE, 1);
3594 /* Not kicked out */
3600 * Sell an item to the store (or home)
3602 static void store_sell(void)
3608 s32b price, value, dummy;
3617 char o_name[MAX_NLEN];
3620 /* Prepare a prompt */
3621 if (cur_store_num == STORE_HOME)
3623 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÃÖ¤¤Þ¤¹¤«? ";
3625 q = "Drop which item? ";
3628 else if (cur_store_num == STORE_MUSEUM)
3630 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ó£¤·¤Þ¤¹¤«? ";
3632 q = "Give which item? ";
3637 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÇä¤ê¤Þ¤¹¤«? ";
3639 q = "Sell which item? ";
3643 item_tester_no_ryoute = TRUE;
3644 /* Only allow items the store will buy */
3645 item_tester_hook = store_will_buy;
3648 /* ²æ¤¬²È¤Ç¤ª¤«¤·¤Ê¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¥ª¥ê¥¸¥Ê¥ë¤Î¥Ð¥°¤ò½¤Àµ */
3649 if (cur_store_num == STORE_HOME)
3652 s = "ÃÖ¤±¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3654 s = "You don't have any item to drop.";
3657 else if (cur_store_num == STORE_MUSEUM)
3660 s = "´ó£¤Ç¤¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3662 s = "You don't have any item to give.";
3668 s = "Íߤ·¤¤Êª¤¬¤Ê¤¤¤Ç¤¹¤Í¤¨¡£";
3670 s = "You have nothing that I want.";
3674 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3676 /* Get the item (in the pack) */
3679 o_ptr = &inventory[item];
3682 /* Get the item (on the floor) */
3685 o_ptr = &o_list[0 - item];
3689 /* Hack -- Cannot remove cursed items */
3690 if ((item >= INVEN_RARM) && cursed_p(o_ptr))
3694 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¤Í¡£");
3696 msg_print("Hmmm, it seems to be cursed.");
3705 /* Assume one item */
3708 /* Find out how many the player wants (letter means "all") */
3709 if (o_ptr->number > 1)
3711 /* Get a quantity */
3712 amt = get_quantity(NULL, o_ptr->number);
3714 /* Allow user abort */
3715 if (amt <= 0) return;
3718 /* Get local object */
3721 /* Get a copy of the object */
3722 object_copy(q_ptr, o_ptr);
3724 /* Modify quantity */
3725 q_ptr->number = amt;
3728 * Hack -- If a rod or wand, allocate total maximum
3729 * timeouts or charges to those being sold. -LM-
3731 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3733 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3736 /* Get a full description */
3737 object_desc(o_name, q_ptr, TRUE, 3);
3739 /* Remove any inscription, feeling for stores */
3740 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3742 q_ptr->inscription = 0;
3743 q_ptr->feeling = FEEL_NONE;
3746 /* Is there room in the store (or the home?) */
3747 if (!store_check_num(q_ptr))
3749 if (cur_store_num == STORE_HOME)
3751 msg_print("²æ¤¬²È¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤Ê¤¤¡£");
3753 msg_print("Your home is full.");
3756 else if (cur_store_num == STORE_MUSEUM)
3758 msg_print("Çîʪ´Û¤Ï¤â¤¦ËþÇÕ¤À¡£");
3760 msg_print("Museum is full.");
3765 msg_print("¤¹¤¤¤Þ¤»¤ó¤¬¡¢Å¹¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤¢¤ê¤Þ¤»¤ó¡£");
3767 msg_print("I have not the room in my store to keep it.");
3775 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3777 /* Describe the transaction */
3779 msg_format("%s(%c)¤òÇäµÑ¤¹¤ë¡£", o_name, index_to_label(item));
3781 msg_format("Selling %s (%c).", o_name, index_to_label(item));
3787 choice = sell_haggle(q_ptr, &price);
3790 if (st_ptr->store_open >= turn) return;
3802 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3803 chg_virtue(V_JUSTICE, -1);
3805 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3806 chg_virtue(V_NATURE, 1);
3809 /* Get some money */
3812 /* Update the display */
3815 /* Get the "apparent" value */
3816 dummy = object_value(q_ptr) * q_ptr->number;
3819 identify_item(o_ptr);
3821 /* Get local object */
3824 /* Get a copy of the object */
3825 object_copy(q_ptr, o_ptr);
3827 /* Modify quantity */
3828 q_ptr->number = amt;
3831 * Hack -- If a rod or wand, let the shopkeeper know just
3832 * how many charges he really paid for. -LM-
3834 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3836 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3839 /* Get the "actual" value */
3840 value = object_value(q_ptr) * q_ptr->number;
3842 /* Get the description all over again */
3843 object_desc(o_name, q_ptr, TRUE, 3);
3845 /* Describe the result (in message buffer) */
3847 msg_format("%s¤ò $%ld¤ÇÇäµÑ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3849 msg_format("You sold %s for %ld gold.", o_name, (long)price);
3852 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
3854 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
3856 /* Analyze the prices (and comment verbally) unless a figurine*/
3857 purchase_analyze(price, value, dummy);
3861 * Hack -- Allocate charges between those wands or rods sold
3862 * and retained, unless all are being sold. -LM-
3864 distribute_charges(o_ptr, q_ptr, amt);
3866 /* Reset timeouts of the sold items */
3869 /* Take the item from the player, describe the result */
3870 inven_item_increase(item, -amt);
3871 inven_item_describe(item);
3872 inven_item_optimize(item);
3877 /* The store gets that (known) item */
3878 item_pos = store_carry(q_ptr);
3880 /* Re-display if item is now in store */
3883 store_top = (item_pos / 12) * 12;
3884 display_inventory();
3889 /* Player is at museum */
3890 else if (cur_store_num == STORE_MUSEUM)
3892 char o2_name[MAX_NLEN];
3893 object_desc(o2_name, q_ptr, TRUE, 0);
3895 if (-1 == store_check_num(q_ptr))
3898 msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£");
3900 msg_print("The same object as it is already in the Museum.");
3906 msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª¡ª");
3908 msg_print("You cannot take items which is given to the Museum back!!");
3912 if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return;
3914 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
3918 identify_item(q_ptr);
3919 q_ptr->ident |= IDENT_MENTAL;
3921 /* Distribute charges of wands/rods */
3922 distribute_charges(o_ptr, q_ptr, amt);
3926 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
3928 msg_format("You drop %s (%c).", o_name, index_to_label(item));
3933 /* Take it from the players inventory */
3934 inven_item_increase(item, -amt);
3935 inven_item_describe(item);
3936 inven_item_optimize(item);
3941 /* Let the home carry it */
3942 item_pos = home_carry(q_ptr);
3944 /* Update store display */
3947 store_top = (item_pos / 12) * 12;
3948 display_inventory();
3951 /* Player is at home */
3954 /* Distribute charges of wands/rods */
3955 distribute_charges(o_ptr, q_ptr, amt);
3959 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
3961 msg_format("You drop %s (%c).", o_name, index_to_label(item));
3966 /* Take it from the players inventory */
3967 inven_item_increase(item, -amt);
3968 inven_item_describe(item);
3969 inven_item_optimize(item);
3974 /* Let the home carry it */
3975 item_pos = home_carry(q_ptr);
3977 /* Update store display */
3980 store_top = (item_pos / 12) * 12;
3981 display_inventory();
3984 if (item >= INVEN_RARM) calc_android_exp();
3985 if ((choice == 0) && ((item == INVEN_RARM) || (item == INVEN_LARM))) kamaenaoshi(item);
3990 * Examine an item in a store -JDL-
3992 static void store_examine(void)
3997 char o_name[MAX_NLEN];
4002 if (st_ptr->stock_num <= 0)
4004 if (cur_store_num == STORE_HOME)
4006 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4008 msg_print("Your home is empty.");
4011 else if (cur_store_num == STORE_MUSEUM)
4013 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4015 msg_print("Museum is empty.");
4020 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
4022 msg_print("I am currently out of stock.");
4029 /* Find the number of objects on this and following pages */
4030 i = (st_ptr->stock_num - store_top);
4032 /* And then restrict it to the current page */
4037 sprintf(out_val, "¤É¤ì¤òÄ´¤Ù¤Þ¤¹¤«¡©");
4039 sprintf(out_val, "Which item do you want to examine? ");
4043 /* Get the item number to be examined */
4044 if (!get_stock(&item, out_val, 0, i - 1)) return;
4046 /* Get the actual index */
4047 item = item + store_top;
4049 /* Get the actual item */
4050 o_ptr = &st_ptr->stock[item];
4052 /* Require full knowledge */
4053 if (!(o_ptr->ident & IDENT_MENTAL))
4055 /* This can only happen in the home */
4057 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
4059 msg_print("You have no special knowledge about that item.");
4066 object_desc(o_name, o_ptr, TRUE, 3);
4070 msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
4072 msg_format("Examining %s...", o_name);
4076 /* Describe it fully */
4077 if (!screen_object(o_ptr, TRUE))
4079 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
4081 msg_print("You see nothing special.");
4090 * Hack -- set this to leave the store
4092 static bool leave_store = FALSE;
4096 * Process a command in a store
4098 * Note that we must allow the use of a few "special" commands
4099 * in the stores which are not allowed in the dungeon, and we
4100 * must disable some commands which are allowed in the dungeon
4101 * but not in the stores, to prevent chaos.
4103 static void store_process_command(void)
4105 #ifdef ALLOW_REPEAT /* TNB */
4107 /* Handle repeating the last command */
4110 #endif /* ALLOW_REPEAT -- TNB */
4112 if (rogue_like_commands && command_cmd == 'l')
4114 command_cmd = 'x'; /* hack! */
4117 /* Parse the command */
4118 switch (command_cmd)
4128 /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
4131 if (st_ptr->stock_num <= 12) {
4133 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4135 msg_print("Entire inventory is shown.");
4140 if ( store_top < 0 )
4141 store_top = ((st_ptr->stock_num - 1 )/12) * 12;
4142 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4143 if ( store_top >= 12 ) store_top = 12;
4144 display_inventory();
4152 if (st_ptr->stock_num <= 12)
4155 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4157 msg_print("Entire inventory is shown.");
4165 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
4166 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
4168 if ((cur_store_num == STORE_HOME) &&
4169 (powerup_home == FALSE) &&
4170 (st_ptr->stock_num >= STORE_INVEN_MAX))
4172 if (store_top >= (STORE_INVEN_MAX - 1))
4179 if (store_top >= st_ptr->stock_num) store_top = 0;
4182 display_inventory();
4195 /* Get (purchase) */
4222 /*** Inventory Commands ***/
4224 /* Wear/wield equipment */
4231 /* Take off equipment */
4238 /* Destroy an item */
4245 /* Equipment list */
4252 /* Inventory list */
4260 /*** Various commands ***/
4262 /* Identify an object */
4269 /* Hack -- toggle windows */
4272 toggle_inven_equip();
4278 /*** Use various objects ***/
4287 /* Inscribe an object */
4294 /* Uninscribe an object */
4297 do_cmd_uninscribe();
4303 /*** Help and Such ***/
4312 /* Identify symbol */
4315 do_cmd_query_symbol();
4319 /* Character description */
4322 p_ptr->town_num = old_town_num;
4323 do_cmd_change_name();
4324 p_ptr->town_num = inner_town_num;
4330 /*** System Commands ***/
4332 /* Hack -- User interface */
4339 /* Single line from a pref file */
4346 /* Interact with macros */
4353 /* Interact with visuals */
4360 /* Interact with colors */
4367 /* Interact with options */
4374 /*** Misc Commands ***/
4390 /* Repeat level feeling */
4397 /* Show previous message */
4400 do_cmd_message_one();
4404 /* Show previous messages */
4417 /* Check artifacts, uniques etc. */
4424 /* Load "screen dump" */
4427 do_cmd_load_screen();
4431 /* Save "screen dump" */
4434 do_cmd_save_screen();
4438 /* Hack -- Unknown command */
4442 msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
4444 msg_print("That command does not work in stores.");
4454 * Enter a store, and interact with it.
4456 * Note that we use the standard "request_command()" function
4457 * to get a command, allowing us to use "command_arg" and all
4458 * command macros and other nifty stuff, but we use the special
4459 * "shopping" argument, to force certain commands to be converted
4460 * into other commands, normally, we convert "p" (pray) and "m"
4461 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4463 void do_cmd_store(void)
4472 /* Access the player grid */
4473 c_ptr = &cave[py][px];
4475 /* Verify a store */
4476 if (!((c_ptr->feat >= FEAT_SHOP_HEAD) &&
4477 (c_ptr->feat <= FEAT_SHOP_TAIL)) &&
4478 (c_ptr->feat != FEAT_MUSEUM))
4481 msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
4483 msg_print("You see no store here.");
4489 /* Extract the store code */
4490 if (c_ptr->feat == FEAT_MUSEUM) which = STORE_MUSEUM;
4491 else which = (c_ptr->feat - FEAT_SHOP_HEAD);
4493 old_town_num = p_ptr->town_num;
4494 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4495 if (dun_level) p_ptr->town_num = NO_TOWN;
4496 inner_town_num = p_ptr->town_num;
4498 /* Hack -- Check the "locked doors" */
4499 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4503 msg_print("¥É¥¢¤Ë¸°¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£");
4505 msg_print("The doors are locked.");
4508 p_ptr->town_num = old_town_num;
4512 /* Calculate the number of store maintainances since the last visit */
4513 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4515 /* Maintain the store max. 10 times */
4516 if (maintain_num > 10) maintain_num = 10;
4520 /* Maintain the store */
4521 for (i = 0; i < maintain_num; i++)
4522 store_maint(p_ptr->town_num, which);
4524 /* Save the visit */
4525 town[p_ptr->town_num].store[which].last_visit = turn;
4528 /* Forget the lite */
4531 /* Forget the view */
4535 /* Hack -- Character is in "icky" mode */
4536 character_icky = TRUE;
4539 /* No command argument */
4542 /* No repeated command */
4545 /* No automatic command */
4549 /* Save the store number */
4550 cur_store_num = which;
4552 /* Save the store and owner pointers */
4553 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4554 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4557 /* Start at the beginning */
4560 /* Display the store */
4564 leave_store = FALSE;
4566 /* Interact with player */
4567 while (!leave_store)
4569 /* Hack -- Clear line 1 */
4572 /* Hack -- Check the charisma */
4573 tmp_chr = p_ptr->stat_use[A_CHR];
4579 /* Basic commands */
4581 prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21, 0);
4583 prt(" ESC) Exit from Building.", 21, 0);
4587 /* Browse if necessary */
4588 if (st_ptr->stock_num > 12)
4591 prt(" -)Á°¥Ú¡¼¥¸", 22, 0);
4592 prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23, 0);
4594 prt(" -) Previous page", 22, 0);
4595 prt(" SPACE) Next page", 23, 0);
4601 if (cur_store_num == STORE_HOME)
4604 prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
4605 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
4606 prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
4608 prt("g) Get an item.", 21, 27);
4609 prt("d) Drop an item.", 22, 27);
4610 prt("x) eXamine an item in the home.", 23,27);
4615 /* Museum commands */
4616 else if (cur_store_num == STORE_MUSEUM)
4619 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
4620 prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
4622 prt("d) Drop an item.", 21, 27);
4623 prt("x) eXamine an item in the museum.", 23,27);
4628 /* Shop commands XXX XXX XXX */
4632 prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
4633 prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
4634 prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,30);
4636 prt("p) Purchase an item.", 21, 30);
4637 prt("s) Sell an item.", 22, 30);
4638 prt("x) eXamine an item in the shop", 23,30);
4644 /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
4646 prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56);
4648 if( rogue_like_commands == TRUE )
4650 prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
4654 prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
4657 prt("i/e) Inventry/Equipment list", 21, 56);
4659 if( rogue_like_commands == TRUE )
4661 prt("w/T) Wear/Take off equipment", 22, 56);
4665 prt("w/t) Wear/Take off equipment", 22, 56);
4670 prt("¥³¥Þ¥ó¥É:", 20, 0);
4672 prt("You may: ", 20, 0);
4677 request_command(TRUE);
4679 /* Process the command */
4680 store_process_command();
4682 /* Hack -- Character is still in "icky" mode */
4683 character_icky = TRUE;
4691 /* XXX XXX XXX Pack Overflow */
4692 if (inventory[INVEN_PACK].k_idx)
4694 int item = INVEN_PACK;
4696 object_type *o_ptr = &inventory[item];
4698 /* Hack -- Flee from the store */
4699 if (cur_store_num != STORE_HOME)
4703 if (cur_store_num == STORE_MUSEUM)
4704 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆÇîʪ´Û¤«¤é½Ð¤¿...");
4706 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆŹ¤«¤é½Ð¤¿...");
4708 if (cur_store_num == STORE_MUSEUM)
4709 msg_print("Your pack is so full that you flee the Museum...");
4711 msg_print("Your pack is so full that you flee the store...");
4719 /* Hack -- Flee from the home */
4720 else if (!store_check_num(o_ptr))
4724 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤Æ²È¤«¤é½Ð¤¿...");
4726 msg_print("Your pack is so full that you flee your home...");
4734 /* Hack -- Drop items into the home */
4742 char o_name[MAX_NLEN];
4745 /* Give a message */
4747 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
4749 msg_print("Your pack overflows!");
4753 /* Get local object */
4756 /* Grab a copy of the item */
4757 object_copy(q_ptr, o_ptr);
4760 object_desc(o_name, q_ptr, TRUE, 3);
4764 msg_format("%s¤¬Íî¤Á¤¿¡£(%c)", o_name, index_to_label(item));
4766 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4770 /* Remove it from the players inventory */
4771 inven_item_increase(item, -255);
4772 inven_item_describe(item);
4773 inven_item_optimize(item);
4778 /* Let the home carry it */
4779 item_pos = home_carry(q_ptr);
4781 /* Redraw the home */
4784 store_top = (item_pos / 12) * 12;
4785 display_inventory();
4790 /* Hack -- Redisplay store prices if charisma changes */
4791 if (tmp_chr != p_ptr->stat_use[A_CHR]) display_inventory();
4793 /* Hack -- get kicked out of the store */
4794 if (st_ptr->store_open >= turn) leave_store = TRUE;
4797 p_ptr->town_num = old_town_num;
4799 /* Free turn XXX XXX XXX */
4803 /* Hack -- Character is no longer in "icky" mode */
4804 character_icky = FALSE;
4807 /* Hack -- Cancel automatic command */
4810 /* Hack -- Cancel "see" mode */
4811 command_see = FALSE;
4814 /* Flush messages XXX XXX XXX */
4818 /* Clear the screen */
4822 /* Update everything */
4823 p_ptr->update |= (PU_VIEW | PU_LITE);
4824 p_ptr->update |= (PU_MONSTERS);
4826 /* Redraw entire screen */
4827 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
4830 p_ptr->redraw |= (PR_MAP);
4833 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4839 * Shuffle one of the stores.
4841 void store_shuffle(int which)
4847 if (which == STORE_HOME) return;
4848 if (which == STORE_MUSEUM) return;
4851 /* Save the store index */
4852 cur_store_num = which;
4854 /* Activate that store */
4855 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4858 /* Pick a new owner */
4861 st_ptr->owner = (byte)randint0(MAX_OWNERS);
4862 if (j == st_ptr->owner) continue;
4863 for (i = 1;i < max_towns; i++)
4865 if (i == p_ptr->town_num) continue;
4866 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
4868 if (i == max_towns) break;
4871 /* Activate the new owner */
4872 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4875 /* Reset the owner data */
4876 st_ptr->insult_cur = 0;
4877 st_ptr->store_open = 0;
4878 st_ptr->good_buy = 0;
4879 st_ptr->bad_buy = 0;
4882 /* Hack -- discount all the items */
4883 for (i = 0; i < st_ptr->stock_num; i++)
4888 o_ptr = &st_ptr->stock[i];
4890 /* Hack -- Sell all old items for "half price" */
4891 if (!(o_ptr->art_name))
4892 o_ptr->discount = 50;
4894 /* Hack -- Items are no longer "fixed price" */
4895 o_ptr->ident &= ~(IDENT_FIXED);
4897 /* Mega-Hack -- Note that the item is "on sale" */
4899 o_ptr->inscription = quark_add("Çä½ÐÃæ");
4901 o_ptr->inscription = quark_add("on sale");
4909 * Maintain the inventory at the stores.
4911 void store_maint(int town_num, int store_num)
4915 int old_rating = rating;
4917 cur_store_num = store_num;
4920 if (store_num == STORE_HOME) return;
4921 if (store_num == STORE_MUSEUM) return;
4923 /* Activate that store */
4924 st_ptr = &town[town_num].store[store_num];
4926 /* Activate the owner */
4927 ot_ptr = &owners[store_num][st_ptr->owner];
4929 /* Store keeper forgives the player */
4930 st_ptr->insult_cur = 0;
4932 /* Mega-Hack -- prune the black market */
4933 if (store_num == STORE_BLACK)
4935 /* Destroy crappy black market items */
4936 for (j = st_ptr->stock_num - 1; j >= 0; j--)
4938 object_type *o_ptr = &st_ptr->stock[j];
4940 /* Destroy crappy items */
4941 if (black_market_crap(o_ptr))
4943 /* Destroy the item */
4944 store_item_increase(j, 0 - o_ptr->number);
4945 store_item_optimize(j);
4951 /* Choose the number of slots to keep */
4952 j = st_ptr->stock_num;
4954 /* Sell a few items */
4955 j = j - randint1(STORE_TURNOVER);
4957 /* Never keep more than "STORE_MAX_KEEP" slots */
4958 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
4960 /* Always "keep" at least "STORE_MIN_KEEP" items */
4961 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
4963 /* Hack -- prevent "underflow" */
4966 /* Destroy objects until only "j" slots are left */
4967 while (st_ptr->stock_num > j) store_delete();
4970 /* Choose the number of slots to fill */
4971 j = st_ptr->stock_num;
4973 /* Buy some more items */
4974 j = j + randint1(STORE_TURNOVER);
4976 /* Never keep more than "STORE_MAX_KEEP" slots */
4977 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
4979 /* Always "keep" at least "STORE_MIN_KEEP" items */
4980 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
4982 /* Hack -- prevent "overflow" */
4983 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
4985 /* Acquire some new items */
4986 while (st_ptr->stock_num < j) store_create();
4989 /* Hack -- Restore the rating */
4990 rating = old_rating;
4995 * Initialize the stores
4997 void store_init(int town_num, int store_num)
5001 cur_store_num = store_num;
5003 /* Activate that store */
5004 st_ptr = &town[town_num].store[store_num];
5012 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5013 for (i = 1;i < max_towns; i++)
5015 if (i == town_num) continue;
5016 if (st_ptr->owner == town[i].store[store_num].owner) break;
5018 if (i == max_towns) break;
5021 /* Activate the new owner */
5022 ot_ptr = &owners[store_num][st_ptr->owner];
5025 /* Initialize the store */
5026 st_ptr->store_open = 0;
5027 st_ptr->insult_cur = 0;
5028 st_ptr->good_buy = 0;
5029 st_ptr->bad_buy = 0;
5031 /* Nothing in stock */
5032 st_ptr->stock_num = 0;
5035 * MEGA-HACK - Last visit to store is
5036 * BEFORE player birth to enable store restocking
5038 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5040 /* Clear any old items */
5041 for (k = 0; k < st_ptr->stock_size; k++)
5043 object_wipe(&st_ptr->stock[k]);
5048 void move_to_black_market(object_type *o_ptr)
5051 if (!p_ptr->town_num) return;
5053 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5055 o_ptr->ident |= IDENT_STOREB;
5057 (void)store_carry(o_ptr);
5059 object_wipe(o_ptr); /* Don't leave a bogus object behind... */