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)
940 /* Compute the final price (with rounding) */
941 /* Hack -- prevent underflow */
942 price = (price * adjust + 50L) / 100L;
945 /* Shop is selling */
948 /* Adjust for greed */
949 adjust = 100 + ((greed + factor) - 300);
951 /* Never get "silly" */
952 if (adjust < 100) adjust = 100;
954 /* Mega-Hack -- Black market sucks */
955 if (cur_store_num == STORE_BLACK)
958 /* Compute the final price (with rounding) */
959 /* Hack -- prevent overflow */
960 price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
963 /* Note -- Never become "free" */
964 if (price <= 0L) return (1L);
966 /* Return the price */
972 * Certain "cheap" objects should be created in "piles"
973 * Some objects can be sold at a "discount" (in small piles)
975 static void mass_produce(object_type *o_ptr)
980 s32b cost = object_value(o_ptr);
983 /* Analyze the type */
986 /* Food, Flasks, and Lites */
991 if (cost <= 5L) size += damroll(3, 5);
992 if (cost <= 20L) size += damroll(3, 5);
993 if (cost <= 50L) size += damroll(2, 2);
1000 if (cost <= 60L) size += damroll(3, 5);
1001 if (cost <= 240L) size += damroll(1, 5);
1002 if (o_ptr->sval == SV_SCROLL_STAR_IDENTIFY) size += damroll(3, 5);
1003 if (o_ptr->sval == SV_SCROLL_STAR_REMOVE_CURSE) size += damroll(1, 4);
1008 case TV_SORCERY_BOOK:
1009 case TV_NATURE_BOOK:
1013 case TV_ARCANE_BOOK:
1014 case TV_ENCHANT_BOOK:
1015 case TV_DAEMON_BOOK:
1016 case TV_CRUSADE_BOOK:
1018 case TV_HISSATSU_BOOK:
1020 if (cost <= 50L) size += damroll(2, 3);
1021 if (cost <= 500L) size += damroll(1, 3);
1039 if (o_ptr->art_name) break;
1040 if (o_ptr->name2) break;
1041 if (cost <= 10L) size += damroll(3, 5);
1042 if (cost <= 100L) size += damroll(3, 5);
1051 if (cost <= 5L) size += damroll(5, 5);
1052 if (cost <= 50L) size += damroll(5, 5);
1053 if (cost <= 500L) size += damroll(5, 5);
1059 if (cost <= 100L) size += damroll(2, 2);
1060 if (cost <= 1000L) size += damroll(2, 2);
1073 * Because many rods (and a few wands and staffs) are useful mainly
1074 * in quantity, the Black Market will occasionally have a bunch of
1081 if ((cur_store_num == STORE_BLACK) && one_in_(3))
1083 if (cost < 1601L) size += damroll(1, 5);
1084 else if (cost < 3201L) size += damroll(1, 3);
1087 /* Ensure that mass-produced rods and wands get the correct pvals. */
1088 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
1090 o_ptr->pval *= size;
1097 /* Pick a discount */
1102 else if (one_in_(25))
1106 else if (one_in_(150))
1110 else if (one_in_(300))
1114 else if (one_in_(500))
1120 if (o_ptr->art_name)
1122 if (cheat_peek && discount)
1125 msg_print("¥é¥ó¥À¥à¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤ÏÃÍ°ú¤¤Ê¤·¡£");
1127 msg_print("No discount on random artifacts.");
1134 /* Save the discount */
1135 o_ptr->discount = discount;
1137 /* Save the total pile size */
1138 o_ptr->number = size - (size * discount / 100);
1144 * Determine if a store item can "absorb" another item
1146 * See "object_similar()" for the same function for the "player"
1148 static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
1152 /* Hack -- Identical items cannot be stacked */
1153 if (o_ptr == j_ptr) return (0);
1155 /* Different objects cannot be stacked */
1156 if (o_ptr->k_idx != j_ptr->k_idx) return (0);
1158 /* Different charges (etc) cannot be stacked, unless wands or rods. */
1159 if ((o_ptr->pval != j_ptr->pval) && (o_ptr->tval != TV_WAND) && (o_ptr->tval != TV_ROD)) return (0);
1161 /* Require many identical values */
1162 if (o_ptr->to_h != j_ptr->to_h) return (0);
1163 if (o_ptr->to_d != j_ptr->to_d) return (0);
1164 if (o_ptr->to_a != j_ptr->to_a) return (0);
1166 /* Require identical "artifact" names */
1167 if (o_ptr->name1 != j_ptr->name1) return (0);
1169 /* Require identical "ego-item" names */
1170 if (o_ptr->name2 != j_ptr->name2) return (0);
1172 /* Random artifacts don't stack !*/
1173 if (o_ptr->art_name || j_ptr->art_name) return (0);
1175 /* Hack -- Identical art_flags! */
1176 for (i = 0; i < TR_FLAG_SIZE; i++)
1177 if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
1179 /* Hack -- Never stack "powerful" items */
1180 if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
1182 /* Hack -- Never stack recharging items */
1183 if (o_ptr->timeout || j_ptr->timeout) return (0);
1185 /* Require many identical values */
1186 if (o_ptr->ac != j_ptr->ac) return (0);
1187 if (o_ptr->dd != j_ptr->dd) return (0);
1188 if (o_ptr->ds != j_ptr->ds) return (0);
1190 /* Hack -- Never stack chests */
1191 if (o_ptr->tval == TV_CHEST) return (0);
1192 if (o_ptr->tval == TV_STATUE) return (0);
1193 if (o_ptr->tval == TV_CAPTURE) return (0);
1195 /* Require matching discounts */
1196 if (o_ptr->discount != j_ptr->discount) return (0);
1198 /* They match, so they must be similar */
1204 * Allow a store item to absorb another item
1206 static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
1208 int max_num = (o_ptr->tval == TV_ROD) ?
1209 MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
1210 int total = o_ptr->number + j_ptr->number;
1211 int diff = (total > max_num) ? total - max_num : 0;
1213 /* Combine quantity, lose excess items */
1214 o_ptr->number = (total > max_num) ? max_num : total;
1216 /* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
1217 if (o_ptr->tval == TV_ROD)
1219 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1222 /* Hack -- if wands are stacking, combine the charges. -LM- */
1223 if (o_ptr->tval == TV_WAND)
1225 o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
1231 * Check to see if the shop will be carrying too many objects -RAK-
1232 * Note that the shop, just like a player, will not accept things
1233 * it cannot hold. Before, one could "nuke" potions this way.
1235 * Return value is now int:
1237 * -1 : Can be combined to existing slot.
1238 * 1 : Cannot be combined but there are empty spaces.
1240 static int store_check_num(object_type *o_ptr)
1245 /* The "home" acts like the player */
1246 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
1248 /* Check all the items */
1249 for (i = 0; i < st_ptr->stock_num; i++)
1251 /* Get the existing item */
1252 j_ptr = &st_ptr->stock[i];
1254 /* Can the new object be combined with the old one? */
1255 if (object_similar(j_ptr, o_ptr)) return -1;
1259 /* Normal stores do special stuff */
1262 /* Check all the items */
1263 for (i = 0; i < st_ptr->stock_num; i++)
1265 /* Get the existing item */
1266 j_ptr = &st_ptr->stock[i];
1268 /* Can the new object be combined with the old one? */
1269 if (store_object_similar(j_ptr, o_ptr)) return -1;
1273 /* Free space is always usable */
1275 * ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1276 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1278 if ((cur_store_num == STORE_HOME) && ( powerup_home == FALSE )) {
1279 if (st_ptr->stock_num < ((st_ptr->stock_size) / 10)) {
1284 if (st_ptr->stock_num < st_ptr->stock_size) {
1289 /* But there was no room at the inn... */
1294 static bool is_blessed(object_type *o_ptr)
1296 u32b flgs[TR_FLAG_SIZE];
1297 object_flags(o_ptr, flgs);
1298 if (have_flag(flgs, TR_BLESSED)) return (TRUE);
1299 else return (FALSE);
1305 * Determine if the current store will purchase the given item
1307 * Note that a shop-keeper must refuse to buy "worthless" items
1309 static bool store_will_buy(object_type *o_ptr)
1311 /* Hack -- The Home is simple */
1312 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) return (TRUE);
1314 /* Switch on the store */
1315 switch (cur_store_num)
1320 /* Analyze the type */
1321 switch (o_ptr->tval)
1324 if (o_ptr->sval != SV_POTION_WATER) return FALSE;
1336 case TV_BOTTLE: /* 'Green', recycling Angband */
1351 /* Analyze the type */
1352 switch (o_ptr->tval)
1373 /* Analyze the type */
1374 switch (o_ptr->tval)
1383 case TV_HISSATSU_BOOK:
1387 if(o_ptr->sval == SV_WIZSTAFF) return (FALSE);
1399 /* Analyze the type */
1400 switch (o_ptr->tval)
1403 case TV_CRUSADE_BOOK:
1413 monster_race *r_ptr = &r_info[o_ptr->pval];
1416 if (!(r_ptr->flags3 & RF3_EVIL))
1419 if (r_ptr->flags3 & RF3_GOOD) break;
1421 /* Accept animals */
1422 if (r_ptr->flags3 & RF3_ANIMAL) break;
1425 if (my_strchr("?!", r_ptr->d_char)) break;
1431 if (is_blessed(o_ptr)) break;
1440 case STORE_ALCHEMIST:
1442 /* Analyze the type */
1443 switch (o_ptr->tval)
1457 /* Analyze the type */
1458 switch (o_ptr->tval)
1460 case TV_SORCERY_BOOK:
1461 case TV_NATURE_BOOK:
1465 case TV_ARCANE_BOOK:
1466 case TV_ENCHANT_BOOK:
1467 case TV_DAEMON_BOOK:
1480 if(o_ptr->sval == SV_WIZSTAFF) break;
1481 else return (FALSE);
1488 /* Bookstore Shop */
1491 /* Analyze the type */
1492 switch (o_ptr->tval)
1494 case TV_SORCERY_BOOK:
1495 case TV_NATURE_BOOK:
1500 case TV_ARCANE_BOOK:
1501 case TV_ENCHANT_BOOK:
1502 case TV_DAEMON_BOOK:
1503 case TV_CRUSADE_BOOK:
1513 /* XXX XXX XXX Ignore "worthless" items */
1514 if (object_value(o_ptr) <= 0) return (FALSE);
1523 * Add the item "o_ptr" to the inventory of the "Home"
1525 * In all cases, return the slot (or -1) where the object was placed
1527 * Note that this is a hacked up version of "inven_carry()".
1529 * Also note that it may not correctly "adapt" to "knowledge" bacoming
1530 * known, the player may have to pick stuff up and drop it again.
1532 static int home_carry(object_type *o_ptr)
1535 s32b value, j_value;
1540 /* Check each existing item (try to combine) */
1541 for (slot = 0; slot < st_ptr->stock_num; slot++)
1543 /* Get the existing item */
1544 j_ptr = &st_ptr->stock[slot];
1546 /* The home acts just like the player */
1547 if (object_similar(j_ptr, o_ptr))
1549 /* Save the new number of items */
1550 object_absorb(j_ptr, o_ptr);
1559 * ±£¤·µ¡Ç½: ¥ª¥×¥·¥ç¥ó powerup_home ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È
1560 * ²æ¤¬²È¤¬ 20 ¥Ú¡¼¥¸¤Þ¤Ç»È¤¨¤ë
1563 if ( powerup_home == TRUE) {
1564 if (st_ptr->stock_num >= st_ptr->stock_size) {
1569 if (st_ptr->stock_num >= ((st_ptr->stock_size) / 10)) {
1575 /* Determine the "value" of the item */
1576 value = object_value(o_ptr);
1578 /* Check existing slots to see if we must "slide" */
1579 for (slot = 0; slot < st_ptr->stock_num; slot++)
1582 j_ptr = &st_ptr->stock[slot];
1584 /* Hack -- readable books always come first */
1585 if ((o_ptr->tval == mp_ptr->spell_book) &&
1586 (j_ptr->tval != mp_ptr->spell_book)) break;
1587 if ((j_ptr->tval == mp_ptr->spell_book) &&
1588 (o_ptr->tval != mp_ptr->spell_book)) continue;
1590 /* Objects sort by decreasing type */
1591 if (o_ptr->tval > j_ptr->tval) break;
1592 if (o_ptr->tval < j_ptr->tval) continue;
1594 /* Can happen in the home */
1595 if (!object_aware_p(o_ptr)) continue;
1596 if (!object_aware_p(j_ptr)) break;
1598 /* Objects sort by increasing sval */
1599 if (o_ptr->sval < j_ptr->sval) break;
1600 if (o_ptr->sval > j_ptr->sval) continue;
1602 /* Objects in the home can be unknown */
1603 if (!object_known_p(o_ptr)) continue;
1604 if (!object_known_p(j_ptr)) break;
1607 * Hack: otherwise identical rods sort by
1608 * increasing recharge time --dsb
1610 if (o_ptr->tval == TV_ROD)
1612 if (o_ptr->pval < j_ptr->pval) break;
1613 if (o_ptr->pval > j_ptr->pval) continue;
1615 if ((o_ptr->tval == TV_CORPSE) || (o_ptr->tval == TV_FIGURINE) || (o_ptr->tval == TV_STATUE))
1617 if (r_info[o_ptr->pval].level < r_info[j_ptr->pval].level) break;
1618 if ((r_info[o_ptr->pval].level == r_info[j_ptr->pval].level) && (o_ptr->pval < j_ptr->pval)) break;
1621 /* Objects sort by decreasing value */
1622 j_value = object_value(j_ptr);
1623 if (value > j_value) break;
1624 if (value < j_value) continue;
1627 /* Slide the others up */
1628 for (i = st_ptr->stock_num; i > slot; i--)
1630 st_ptr->stock[i] = st_ptr->stock[i-1];
1633 /* More stuff now */
1634 st_ptr->stock_num++;
1636 /* Insert the new item */
1637 st_ptr->stock[slot] = *o_ptr;
1639 chg_virtue(V_SACRIFICE, -1);
1641 /* Return the location */
1647 * Add the item "o_ptr" to a real stores inventory.
1649 * If the item is "worthless", it is thrown away (except in the home).
1651 * If the item cannot be combined with an object already in the inventory,
1652 * make a new slot for it, and calculate its "per item" price. Note that
1653 * this price will be negative, since the price will not be "fixed" yet.
1654 * Adding an item to a "fixed" price stack will not change the fixed price.
1656 * In all cases, return the slot (or -1) where the object was placed
1658 static int store_carry(object_type *o_ptr)
1661 s32b value, j_value;
1665 /* Evaluate the object */
1666 value = object_value(o_ptr);
1668 /* Cursed/Worthless items "disappear" when sold */
1669 if (value <= 0) return (-1);
1671 /* All store items are fully *identified* */
1672 o_ptr->ident |= IDENT_MENTAL;
1674 /* Erase the inscription */
1675 o_ptr->inscription = 0;
1677 /* Erase the "feeling" */
1678 o_ptr->feeling = FEEL_NONE;
1680 /* Check each existing item (try to combine) */
1681 for (slot = 0; slot < st_ptr->stock_num; slot++)
1683 /* Get the existing item */
1684 j_ptr = &st_ptr->stock[slot];
1686 /* Can the existing items be incremented? */
1687 if (store_object_similar(j_ptr, o_ptr))
1689 /* Hack -- extra items disappear */
1690 store_object_absorb(j_ptr, o_ptr);
1698 if (st_ptr->stock_num >= st_ptr->stock_size) return (-1);
1701 /* Check existing slots to see if we must "slide" */
1702 for (slot = 0; slot < st_ptr->stock_num; slot++)
1705 j_ptr = &st_ptr->stock[slot];
1707 /* Objects sort by decreasing type */
1708 if (o_ptr->tval > j_ptr->tval) break;
1709 if (o_ptr->tval < j_ptr->tval) continue;
1711 /* Objects sort by increasing sval */
1712 if (o_ptr->sval < j_ptr->sval) break;
1713 if (o_ptr->sval > j_ptr->sval) continue;
1716 * Hack: otherwise identical rods sort by
1717 * increasing recharge time --dsb
1719 if (o_ptr->tval == TV_ROD)
1721 if (o_ptr->pval < j_ptr->pval) break;
1722 if (o_ptr->pval > j_ptr->pval) continue;
1725 /* Evaluate that slot */
1726 j_value = object_value(j_ptr);
1728 /* Objects sort by decreasing value */
1729 if (value > j_value) break;
1730 if (value < j_value) continue;
1733 /* Slide the others up */
1734 for (i = st_ptr->stock_num; i > slot; i--)
1736 st_ptr->stock[i] = st_ptr->stock[i-1];
1739 /* More stuff now */
1740 st_ptr->stock_num++;
1742 /* Insert the new item */
1743 st_ptr->stock[slot] = *o_ptr;
1745 /* Return the location */
1751 * Increase, by a given amount, the number of a certain item
1752 * in a certain store. This can result in zero items.
1754 static void store_item_increase(int item, int num)
1760 o_ptr = &st_ptr->stock[item];
1762 /* Verify the number */
1763 cnt = o_ptr->number + num;
1764 if (cnt > 255) cnt = 255;
1765 else if (cnt < 0) cnt = 0;
1766 num = cnt - o_ptr->number;
1768 /* Save the new number */
1769 o_ptr->number += num;
1774 * Remove a slot if it is empty
1776 static void store_item_optimize(int item)
1782 o_ptr = &st_ptr->stock[item];
1785 if (!o_ptr->k_idx) return;
1787 /* Must have no items */
1788 if (o_ptr->number) return;
1791 st_ptr->stock_num--;
1793 /* Slide everyone */
1794 for (j = item; j < st_ptr->stock_num; j++)
1796 st_ptr->stock[j] = st_ptr->stock[j + 1];
1799 /* Nuke the final slot */
1800 object_wipe(&st_ptr->stock[j]);
1805 * This function will keep 'crap' out of the black market.
1806 * Crap is defined as any item that is "available" elsewhere
1807 * Based on a suggestion by "Lee Vogt" <lvogt@cig.mcel.mot.com>
1809 static bool black_market_crap(object_type *o_ptr)
1813 /* Ego items are never crap */
1814 if (o_ptr->name2) return (FALSE);
1816 /* Good items are never crap */
1817 if (o_ptr->to_a > 0) return (FALSE);
1818 if (o_ptr->to_h > 0) return (FALSE);
1819 if (o_ptr->to_d > 0) return (FALSE);
1821 /* Check all stores */
1822 for (i = 0; i < MAX_STORES; i++)
1824 if (i == STORE_HOME) continue;
1825 if (i == STORE_MUSEUM) continue;
1827 /* Check every item in the store */
1828 for (j = 0; j < town[p_ptr->town_num].store[i].stock_num; j++)
1830 object_type *j_ptr = &town[p_ptr->town_num].store[i].stock[j];
1832 /* Duplicate item "type", assume crappy */
1833 if (o_ptr->k_idx == j_ptr->k_idx) return (TRUE);
1843 * Attempt to delete (some of) a random item from the store
1844 * Hack -- we attempt to "maintain" piles of items when possible.
1846 static void store_delete(void)
1850 /* Pick a random slot */
1851 what = randint0(st_ptr->stock_num);
1853 /* Determine how many items are here */
1854 num = st_ptr->stock[what].number;
1856 /* Hack -- sometimes, only destroy half the items */
1857 if (randint0(100) < 50) num = (num + 1) / 2;
1859 /* Hack -- sometimes, only destroy a single item */
1860 if (randint0(100) < 50) num = 1;
1862 /* Hack -- decrement the maximum timeouts and total charges of rods and wands. -LM- */
1863 if ((st_ptr->stock[what].tval == TV_ROD) || (st_ptr->stock[what].tval == TV_WAND))
1865 st_ptr->stock[what].pval -= num * st_ptr->stock[what].pval / st_ptr->stock[what].number;
1868 /* Actually destroy (part of) the item */
1869 store_item_increase(what, -num);
1870 store_item_optimize(what);
1875 * Creates a random item and gives it to a store
1876 * This algorithm needs to be rethought. A lot.
1877 * Currently, "normal" stores use a pre-built array.
1879 * Note -- the "level" given to "obj_get_num()" is a "favored"
1880 * level, that is, there is a much higher chance of getting
1881 * items with a level approaching that of the given level...
1883 * Should we check for "permission" to have the given item?
1885 static void store_create(void)
1887 int i, tries, level;
1893 /* Paranoia -- no room left */
1894 if (st_ptr->stock_num >= st_ptr->stock_size) return;
1897 /* Hack -- consider up to four items */
1898 for (tries = 0; tries < 4; tries++)
1901 if (cur_store_num == STORE_BLACK)
1903 /* Pick a level for object/magic */
1904 level = 25 + randint0(25);
1906 /* Random item (usually of given level) */
1907 i = get_obj_num(level);
1909 /* Handle failure */
1916 /* Hack -- Pick an item to sell */
1917 i = st_ptr->table[randint0(st_ptr->table_num)];
1919 /* Hack -- fake level for apply_magic() */
1920 level = rand_range(1, STORE_OBJ_LEVEL);
1924 /* Get local object */
1927 /* Create a new object of the chosen kind */
1928 object_prep(q_ptr, i);
1930 /* Apply some "low-level" magic (no artifacts) */
1931 apply_magic(q_ptr, level, AM_NO_FIXED_ART);
1933 /* Require valid object */
1934 if (!store_will_buy(q_ptr)) continue;
1936 /* Hack -- Charge lite's */
1937 if (q_ptr->tval == TV_LITE)
1939 if (q_ptr->sval == SV_LITE_TORCH) q_ptr->xtra4 = FUEL_TORCH / 2;
1940 if (q_ptr->sval == SV_LITE_LANTERN) q_ptr->xtra4 = FUEL_LAMP / 2;
1944 /* The item is "known" */
1945 object_known(q_ptr);
1947 /* Mark it storebought */
1948 q_ptr->ident |= IDENT_STORE;
1950 /* Mega-Hack -- no chests in stores */
1951 if (q_ptr->tval == TV_CHEST) continue;
1953 /* Prune the black market */
1954 if (cur_store_num == STORE_BLACK)
1956 /* Hack -- No "crappy" items */
1957 if (black_market_crap(q_ptr)) continue;
1959 /* Hack -- No "cheap" items */
1960 if (object_value(q_ptr) < 10) continue;
1962 /* No "worthless" items */
1963 /* if (object_value(q_ptr) <= 0) continue; */
1966 /* Prune normal stores */
1969 /* No "worthless" items */
1970 if (object_value(q_ptr) <= 0) continue;
1974 /* Mass produce and/or Apply discount */
1975 mass_produce(q_ptr);
1977 /* Attempt to carry the (known) item */
1978 (void)store_carry(q_ptr);
1980 /* Definitely done */
1988 * Eliminate need to bargain if player has haggled well in the past
1990 static bool noneedtobargain(s32b minprice)
1992 s32b good = st_ptr->good_buy;
1993 s32b bad = st_ptr->bad_buy;
1995 /* Cheap items are "boring" */
1996 if (minprice < 10L) return (TRUE);
1998 /* Perfect haggling */
1999 if (good == MAX_SHORT) return (TRUE);
2001 /* Reward good haggles, punish bad haggles, notice price */
2002 if (good > ((3 * bad) + (5 + (minprice/50)))) return (TRUE);
2004 /* Return the flag */
2010 * Update the bargain info
2012 static void updatebargain(s32b price, s32b minprice, int num)
2014 /* Hack -- auto-haggle */
2015 if (!manual_haggle) return;
2017 /* Cheap items are "boring" */
2018 if ((minprice/num) < 10L) return;
2020 /* Count the successful haggles */
2021 if (price == minprice)
2023 /* Just count the good haggles */
2024 if (st_ptr->good_buy < MAX_SHORT)
2030 /* Count the failed haggles */
2033 /* Just count the bad haggles */
2034 if (st_ptr->bad_buy < MAX_SHORT)
2044 * Re-displays a single store entry
2046 static void display_entry(int pos)
2052 char o_name[MAX_NLEN];
2059 o_ptr = &st_ptr->stock[pos];
2061 /* Get the "offset" */
2064 /* Label it, clear the line --(-- */
2065 (void)sprintf(out_val, "%c) ", I2A(i));
2066 prt(out_val, i+6, 0);
2069 if (show_item_graph)
2071 byte a = object_attr(o_ptr);
2072 char c = object_char(o_ptr);
2079 Term_queue_bigchar(cur_col, i + 6, a, c, 0, 0);
2083 /* Describe an item in the home */
2084 if ((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM))
2088 /* Leave room for weights, if necessary -DRS- */
2089 if (show_weights) maxwid -= 10;
2091 /* Describe the object */
2092 object_desc(o_name, o_ptr, 0);
2093 o_name[maxwid] = '\0';
2094 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2099 /* Only show the weight of an individual item */
2100 int wgt = o_ptr->weight;
2102 sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2103 put_str(out_val, i+6, 67);
2105 (void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
2106 put_str(out_val, i+6, 68);
2112 /* Describe an item (fully) in a store */
2115 /* Must leave room for the "price" */
2118 /* Leave room for weights, if necessary -DRS- */
2119 if (show_weights) maxwid -= 7;
2121 /* Describe the object (fully) */
2122 object_desc(o_name, o_ptr, 0);
2123 o_name[maxwid] = '\0';
2124 c_put_str(tval_to_attr[o_ptr->tval], o_name, i+6, cur_col);
2129 /* Only show the weight of an individual item */
2130 int wgt = o_ptr->weight;
2132 sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
2133 put_str(out_val, i+6, 60);
2135 (void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
2136 put_str(out_val, i+6, 61);
2141 /* Display a "fixed" cost */
2142 if (o_ptr->ident & (IDENT_FIXED))
2144 /* Extract the "minimum" price */
2145 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2147 /* Actually draw the price (not fixed) */
2149 (void)sprintf(out_val, "%9ld¸Ç", (long)x);
2151 (void)sprintf(out_val, "%9ld F", (long)x);
2154 put_str(out_val, i+6, 68);
2157 /* Display a "taxed" cost */
2158 else if (!manual_haggle)
2160 /* Extract the "minimum" price */
2161 x = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2163 /* Hack -- Apply Sales Tax if needed */
2164 if (!noneedtobargain(x)) x += x / 10;
2166 /* Actually draw the price (with tax) */
2167 (void)sprintf(out_val, "%9ld ", (long)x);
2168 put_str(out_val, i+6, 68);
2171 /* Display a "haggle" cost */
2174 /* Extrect the "maximum" price */
2175 x = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2177 /* Actually draw the price (not fixed) */
2178 (void)sprintf(out_val, "%9ld ", (long)x);
2179 put_str(out_val, i+6, 68);
2186 * Displays a store's inventory -RAK-
2187 * All prices are listed as "per individual object". -BEN-
2189 static void display_inventory(void)
2193 /* Display the next 12 items */
2194 for (k = 0; k < 12; k++)
2196 /* Do not display "dead" items */
2197 if (store_top + k >= st_ptr->stock_num) break;
2199 /* Display that line */
2200 display_entry(store_top + k);
2203 /* Erase the extra lines and the "more" prompt */
2204 for (i = k; i < 13; i++) prt("", i + 6, 0);
2206 /* Assume "no current page" */
2208 put_str(" ", 5, 20);
2210 put_str(" ", 5, 20);
2214 /* Visual reminder of "more items" */
2215 if (st_ptr->stock_num > 12)
2217 /* Show "more" reminder (after the last item) */
2219 prt("-³¤¯-", k + 6, 3);
2221 prt("-more-", k + 6, 3);
2225 /* Indicate the "current page" */
2226 /* Trailing spaces are to display (Page xx) and (Page x) */
2228 put_str(format("(%d¥Ú¡¼¥¸) ", store_top/12 + 1), 5, 20);
2230 put_str(format("(Page %d) ", store_top/12 + 1), 5, 20);
2238 * Displays players gold -RAK-
2240 static void store_prt_gold(void)
2245 prt("¼ê»ý¤Á¤Î¤ª¶â: ", 19, 53);
2247 prt("Gold Remaining: ", 19, 53);
2251 sprintf(out_val, "%9ld", (long)p_ptr->au);
2252 prt(out_val, 19, 68);
2257 * Displays store (after clearing screen) -RAK-
2259 static void display_store(void)
2267 /* The "Home" is special */
2268 if (cur_store_num == STORE_HOME)
2270 /* Put the owner name */
2272 put_str("²æ¤¬²È", 3, 31);
2274 put_str("Your Home", 3, 30);
2278 /* Label the item descriptions */
2280 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2282 put_str("Item Description", 5, 3);
2286 /* If showing weights, show label */
2290 put_str("½Å¤µ", 5, 72);
2292 put_str("Weight", 5, 70);
2298 /* The "Home" is special */
2299 else if (cur_store_num == STORE_MUSEUM)
2301 /* Put the owner name */
2303 put_str("Çîʪ´Û", 3, 31);
2305 put_str("Museum", 3, 30);
2309 /* Label the item descriptions */
2311 put_str("¥¢¥¤¥Æ¥à¤Î°ìÍ÷", 5, 4);
2313 put_str("Item Description", 5, 3);
2317 /* If showing weights, show label */
2321 put_str("½Å¤µ", 5, 72);
2323 put_str("Weight", 5, 70);
2332 cptr store_name = (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name);
2333 cptr owner_name = (ot_ptr->owner_name);
2334 cptr race_name = race_info[ot_ptr->owner_race].title;
2336 /* Put the owner name and race */
2337 sprintf(buf, "%s (%s)", owner_name, race_name);
2338 put_str(buf, 3, 10);
2340 /* Show the max price in the store (above prices) */
2341 sprintf(buf, "%s (%ld)", store_name, (long)(ot_ptr->max_cost));
2344 /* Label the item descriptions */
2346 put_str("¾¦ÉʤΰìÍ÷", 5, 7);
2348 put_str("Item Description", 5, 3);
2352 /* If showing weights, show label */
2356 put_str("½Å¤µ", 5, 62);
2358 put_str("Weight", 5, 60);
2363 /* Label the asking price (in stores) */
2365 put_str("²Á³Ê", 5, 73);
2367 put_str("Price", 5, 72);
2372 /* Display the current gold */
2375 /* Draw in the inventory */
2376 display_inventory();
2382 * Get the ID of a store item and return its value -RAK-
2384 static int get_stock(int *com_val, cptr pmt, int i, int j)
2390 #ifdef ALLOW_REPEAT /* TNB */
2392 /* Get the item index */
2393 if (repeat_pull(com_val))
2395 /* Verify the item */
2396 if ((*com_val >= i) && (*com_val <= j))
2403 #endif /* ALLOW_REPEAT -- TNB */
2405 /* Paranoia XXX XXX XXX */
2409 /* Assume failure */
2412 /* Build the prompt */
2414 (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
2415 (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
2416 I2A(i), I2A(j), pmt);
2418 (void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
2419 I2A(i), I2A(j), pmt);
2423 /* Ask until done */
2429 if (!get_com(out_val, &command, FALSE)) break;
2432 k = (islower(command) ? A2I(command) : -1);
2434 /* Legal responses */
2435 if ((k >= i) && (k <= j))
2445 /* Clear the prompt */
2449 if (command == ESCAPE) return (FALSE);
2451 #ifdef ALLOW_REPEAT /* TNB */
2453 repeat_push(*com_val);
2455 #endif /* ALLOW_REPEAT -- TNB */
2463 * Increase the insult counter and get angry if too many -RAK-
2465 static int increase_insults(void)
2467 /* Increase insults */
2468 st_ptr->insult_cur++;
2470 /* Become insulted */
2471 if (st_ptr->insult_cur > ot_ptr->insult_max)
2477 st_ptr->insult_cur = 0;
2478 st_ptr->good_buy = 0;
2479 st_ptr->bad_buy = 0;
2482 st_ptr->store_open = turn + TURNS_PER_TICK*TOWN_DAWN/8 + randint1(TURNS_PER_TICK*TOWN_DAWN/8);
2494 * Decrease insults -RAK-
2496 static void decrease_insults(void)
2498 /* Decrease insults */
2499 if (st_ptr->insult_cur) st_ptr->insult_cur--;
2504 * Have insulted while haggling -RAK-
2506 static int haggle_insults(void)
2508 /* Increase insults */
2509 if (increase_insults()) return (TRUE);
2511 /* Display and flush insult */
2520 * Mega-Hack -- Enable "increments"
2522 static bool allow_inc = FALSE;
2525 * Mega-Hack -- Last "increment" during haggling
2527 static s32b last_inc = 0L;
2533 static int get_haggle(cptr pmt, s32b *poffer, s32b price, int final)
2543 /* Clear old increment if necessary */
2544 if (!allow_inc) last_inc = 0L;
2551 sprintf(buf, "%s [¾µÂú] ", pmt);
2553 sprintf(buf, "%s [accept] ", pmt);
2558 /* Old (negative) increment, and not final */
2559 else if (last_inc < 0)
2562 sprintf(buf, "%s [-$%ld] ", pmt, (long)(ABS(last_inc)));
2564 sprintf(buf, "%s [-%ld] ", pmt, (long)(ABS(last_inc)));
2569 /* Old (positive) increment, and not final */
2570 else if (last_inc > 0)
2573 sprintf(buf, "%s [+$%ld] ", pmt, (long)(ABS(last_inc)));
2575 sprintf(buf, "%s [+%ld] ", pmt, (long)(ABS(last_inc)));
2583 sprintf(buf, "%s ", pmt);
2587 /* Paranoia XXX XXX XXX */
2591 /* Ask until done */
2596 /* Display prompt */
2600 strcpy(out_val, "");
2603 * Ask the user for a response.
2604 * Don't allow to use numpad as cursor key.
2606 res = askfor_aux(out_val, 32, FALSE);
2612 if (!res) return FALSE;
2614 /* Skip leading spaces */
2615 for (p = out_val; *p == ' '; p++) /* loop */;
2617 /* Empty response */
2620 /* Accept current price */
2628 /* Use previous increment */
2629 if (allow_inc && last_inc)
2631 *poffer += last_inc;
2636 /* Normal response */
2639 /* Extract a number */
2642 /* Handle "incremental" number */
2643 if ((*p == '+' || *p == '-'))
2645 /* Allow increments */
2648 /* Use the given "increment" */
2655 /* Handle normal number */
2658 /* Use the given "number" */
2667 msg_print("Ãͤ¬¤ª¤«¤·¤¤¤Ç¤¹¡£");
2669 msg_print("Invalid response.");
2681 * Receive an offer (from the player)
2683 * Return TRUE if offer is NOT okay
2685 static bool receive_offer(cptr pmt, s32b *poffer,
2686 s32b last_offer, int factor,
2687 s32b price, int final)
2689 /* Haggle till done */
2692 /* Get a haggle (or cancel) */
2693 if (!get_haggle(pmt, poffer, price, final)) return (TRUE);
2695 /* Acceptable offer */
2696 if (((*poffer) * factor) >= (last_offer * factor)) break;
2698 /* Insult, and check for kicked out */
2699 if (haggle_insults()) return (TRUE);
2701 /* Reject offer (correctly) */
2702 (*poffer) = last_offer;
2711 * Haggling routine -RAK-
2713 * Return TRUE if purchase is NOT successful
2715 static bool purchase_haggle(object_type *o_ptr, s32b *price)
2717 s32b cur_ask, final_ask;
2718 s32b last_offer, offer;
2720 s32b min_per, max_per;
2721 int flag, loop_flag, noneed;
2722 int annoyed = 0, final = FALSE;
2724 bool cancel = FALSE;
2727 cptr pmt = "Ä󼨲Á³Ê";
2729 cptr pmt = "Asking";
2739 /* Extract the starting offer and the final offer */
2740 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, FALSE);
2741 final_ask = price_item(o_ptr, ot_ptr->min_inflate, FALSE);
2743 /* Determine if haggling is necessary */
2744 noneed = noneedtobargain(final_ask);
2746 /* No need to haggle */
2747 if (noneed || !manual_haggle)
2749 /* No need to haggle */
2752 /* Message summary */
2754 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2756 msg_print("You eventually agree upon the price.");
2762 /* No haggle option */
2765 /* Message summary */
2767 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2769 msg_print("You quickly agree upon the price.");
2774 /* Apply Sales Tax */
2775 final_ask += final_ask / 10;
2779 cur_ask = final_ask;
2781 /* Go to final offer */
2783 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2785 pmt = "Final Offer";
2792 /* Haggle for the whole pile */
2793 cur_ask *= o_ptr->number;
2794 final_ask *= o_ptr->number;
2797 /* Haggle parameters */
2798 min_per = ot_ptr->haggle_per;
2799 max_per = min_per * 3;
2801 /* Mega-Hack -- artificial "last offer" value */
2802 last_offer = object_value(o_ptr) * o_ptr->number;
2803 last_offer = last_offer * (200 - (int)(ot_ptr->max_inflate)) / 100L;
2804 if (last_offer <= 0) last_offer = 1;
2809 /* No incremental haggling yet */
2812 /* Haggle until done */
2813 for (flag = FALSE; !flag; )
2817 while (!flag && loop_flag)
2819 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
2820 put_str(out_val, 1, 0);
2822 cancel = receive_offer("Ä󼨤¹¤ë¶â³Û? ",
2824 cancel = receive_offer("What do you offer? ",
2827 &offer, last_offer, 1, cur_ask, final);
2833 else if (offer > cur_ask)
2838 else if (offer == cur_ask)
2851 x1 = 100 * (offer - last_offer) / (cur_ask - last_offer);
2854 if (haggle_insults())
2860 else if (x1 > max_per)
2863 if (x1 < max_per) x1 = max_per;
2865 x2 = rand_range(x1-2, x1+2);
2866 x3 = ((cur_ask - offer) * x2 / 100L) + 1;
2867 /* don't let the price go up */
2872 if (cur_ask < final_ask)
2875 cur_ask = final_ask;
2877 pmt = "ºÇ½ªÄ󼨲Á³Ê";
2879 pmt = "Final Offer";
2885 (void)(increase_insults());
2890 else if (offer >= cur_ask)
2902 (void)sprintf(out_val, "Á°²ó¤ÎÄ󼨶â³Û: $%ld",
2904 (void)sprintf(out_val, "Your last offer: %ld",
2908 put_str(out_val, 1, 39);
2909 say_comment_2(cur_ask, annoyed);
2915 if (cancel) return (TRUE);
2917 /* Update bargaining info */
2918 updatebargain(*price, final_ask, o_ptr->number);
2926 * Haggling routine -RAK-
2928 * Return TRUE if purchase is NOT successful
2930 static bool sell_haggle(object_type *o_ptr, s32b *price)
2932 s32b purse, cur_ask, final_ask;
2933 s32b last_offer = 0, offer = 0;
2935 s32b min_per, max_per;
2936 int flag, loop_flag, noneed;
2937 int annoyed = 0, final = FALSE;
2938 bool cancel = FALSE;
2940 cptr pmt = "Ä󼨶â³Û";
2951 /* Obtain the starting offer and the final offer */
2952 cur_ask = price_item(o_ptr, ot_ptr->max_inflate, TRUE);
2953 final_ask = price_item(o_ptr, ot_ptr->min_inflate, TRUE);
2955 /* Determine if haggling is necessary */
2956 noneed = noneedtobargain(final_ask);
2958 /* Get the owner's payout limit */
2959 purse = (s32b)(ot_ptr->max_cost);
2961 /* No need to haggle */
2962 if (noneed || !manual_haggle || (final_ask >= purse))
2964 /* Apply Sales Tax (if needed) */
2965 if (!manual_haggle && !noneed)
2967 final_ask -= final_ask / 10;
2970 /* No reason to haggle */
2971 if (final_ask >= purse)
2975 msg_print("¨ºÂ¤Ë¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2977 msg_print("You instantly agree upon the price.");
2982 /* Offer full purse */
2986 /* No need to haggle */
2991 msg_print("·ë¶É¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
2993 msg_print("You eventually agree upon the price.");
2999 /* No haggle option */
3002 /* Message summary */
3004 msg_print("¤¹¤ó¤Ê¤ê¤È¤³¤Î¶â³Û¤Ë¤Þ¤È¤Þ¤Ã¤¿¡£");
3006 msg_print("You quickly agree upon the price.");
3013 cur_ask = final_ask;
3018 pmt = "ºÇ½ªÄ󼨶â³Û";
3020 pmt = "Final Offer";
3025 /* Haggle for the whole pile */
3026 cur_ask *= o_ptr->number;
3027 final_ask *= o_ptr->number;
3030 /* XXX XXX XXX Display commands */
3032 /* Haggling parameters */
3033 min_per = ot_ptr->haggle_per;
3034 max_per = min_per * 3;
3036 /* Mega-Hack -- artificial "last offer" value */
3037 last_offer = object_value(o_ptr) * o_ptr->number;
3038 last_offer = last_offer * ot_ptr->max_inflate / 100L;
3043 /* No incremental haggling yet */
3047 for (flag = FALSE; !flag; )
3053 (void)sprintf(out_val, "%s : %ld", pmt, (long)cur_ask);
3054 put_str(out_val, 1, 0);
3056 cancel = receive_offer("Ä󼨤¹¤ë²Á³Ê? ",
3058 cancel = receive_offer("What price do you ask? ",
3061 &offer, last_offer, -1, cur_ask, final);
3067 else if (offer < cur_ask)
3070 /* rejected, reset offer for incremental haggling */
3073 else if (offer == cur_ask)
3084 if (flag || !loop_flag) break;
3089 x1 = 100 * (last_offer - offer) / (last_offer - cur_ask);
3092 if (haggle_insults())
3098 else if (x1 > max_per)
3101 if (x1 < max_per) x1 = max_per;
3103 x2 = rand_range(x1-2, x1+2);
3104 x3 = ((offer - cur_ask) * x2 / 100L) + 1;
3105 /* don't let the price go down */
3109 if (cur_ask > final_ask)
3111 cur_ask = final_ask;
3114 pmt = "ºÇ½ªÄ󼨶â³Û";
3116 pmt = "Final Offer";
3124 /* Äɲà $0 ¤ÇÇ㤤¼è¤é¤ì¤Æ¤·¤Þ¤¦¤Î¤òËÉ»ß By FIRST*/
3127 (void)(increase_insults());
3130 else if (offer <= cur_ask)
3141 (void)sprintf(out_val,
3143 "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
3145 "Your last bid %ld", (long)last_offer);
3148 put_str(out_val, 1, 39);
3149 say_comment_3(cur_ask, annoyed);
3155 if (cancel) return (TRUE);
3157 /* Update bargaining info */
3158 updatebargain(*price, final_ask, o_ptr->number);
3166 * Buy an item from a store -RAK-
3168 static void store_purchase(void)
3180 char o_name[MAX_NLEN];
3185 if (cur_store_num == STORE_MUSEUM)
3188 msg_print("Çîʪ´Û¤«¤é¼è¤ê½Ð¤¹¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£");
3190 msg_print("Museum.");
3196 if (st_ptr->stock_num <= 0)
3198 if (cur_store_num == STORE_HOME)
3200 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
3202 msg_print("Your home is empty.");
3207 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
3209 msg_print("I am currently out of stock.");
3216 /* Find the number of objects on this and following pages */
3217 i = (st_ptr->stock_num - store_top);
3219 /* And then restrict it to the current page */
3224 /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
3225 switch( cur_store_num ) {
3227 sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
3230 sprintf(out_val, "¤É¤ì? ");
3233 sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
3237 if (cur_store_num == STORE_HOME)
3239 sprintf(out_val, "Which item do you want to take? ");
3243 sprintf(out_val, "Which item are you interested in? ");
3248 /* Get the item number to be bought */
3249 if (!get_stock(&item, out_val, 0, i - 1)) return;
3251 /* Get the actual index */
3252 item = item + store_top;
3254 /* Get the actual item */
3255 o_ptr = &st_ptr->stock[item];
3257 /* Assume the player wants just one of them */
3260 /* Get local object */
3263 /* Get a copy of the object */
3264 object_copy(j_ptr, o_ptr);
3267 * If a rod or wand, allocate total maximum timeouts or charges
3268 * between those purchased and left on the shelf.
3270 reduce_charges(j_ptr, o_ptr->number - amt);
3272 /* Modify quantity */
3273 j_ptr->number = amt;
3275 /* Hack -- require room in pack */
3276 if (!inven_carry_okay(j_ptr))
3279 msg_print("¤½¤ó¤Ê¤Ë¥¢¥¤¥Æ¥à¤ò»ý¤Æ¤Ê¤¤¡£");
3281 msg_print("You cannot carry that many different items.");
3287 /* Determine the "best" price (per item) */
3288 best = price_item(j_ptr, ot_ptr->min_inflate, FALSE);
3290 /* Find out how many the player wants */
3291 if (o_ptr->number > 1)
3293 /* Hack -- note cost of "fixed" items */
3294 if ((cur_store_num != STORE_HOME) &&
3295 (o_ptr->ident & IDENT_FIXED))
3298 msg_format("°ì¤Ä¤Ë¤Ä¤ $%ld¤Ç¤¹¡£", (long)(best));
3300 msg_format("That costs %ld gold per item.", (long)(best));
3305 /* Get a quantity */
3306 amt = get_quantity(NULL, o_ptr->number);
3308 /* Allow user abort */
3309 if (amt <= 0) return;
3312 /* Get local object */
3315 /* Get desired object */
3316 object_copy(j_ptr, o_ptr);
3319 * If a rod or wand, allocate total maximum timeouts or charges
3320 * between those purchased and left on the shelf.
3322 reduce_charges(j_ptr, o_ptr->number - amt);
3324 /* Modify quantity */
3325 j_ptr->number = amt;
3327 /* Hack -- require room in pack */
3328 if (!inven_carry_okay(j_ptr))
3331 msg_print("¥¶¥Ã¥¯¤Ë¤½¤Î¥¢¥¤¥Æ¥à¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£");
3333 msg_print("You cannot carry that many items.");
3339 /* Attempt to buy it */
3340 if (cur_store_num != STORE_HOME)
3342 /* Fixed price, quick buy */
3343 if (o_ptr->ident & (IDENT_FIXED))
3348 /* Go directly to the "best" deal */
3349 price = (best * j_ptr->number);
3355 /* Describe the object (fully) */
3356 object_desc(o_name, j_ptr, 0);
3360 msg_format("%s(%c)¤ò¹ØÆþ¤¹¤ë¡£", o_name, I2A(item));
3362 msg_format("Buying %s (%c).", o_name, I2A(item));
3367 /* Haggle for a final price */
3368 choice = purchase_haggle(j_ptr, &price);
3370 /* Hack -- Got kicked out */
3371 if (st_ptr->store_open >= turn) return;
3374 /* Player wants it */
3377 /* Fix the item price (if "correctly" haggled) */
3378 if (price == (best * j_ptr->number)) o_ptr->ident |= (IDENT_FIXED);
3380 /* Player can afford it */
3381 if (p_ptr->au >= price)
3386 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3387 chg_virtue(V_JUSTICE, -1);
3388 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3389 chg_virtue(V_NATURE, -1);
3397 /* Spend the money */
3400 /* Update the display */
3403 /* Hack -- buying an item makes you aware of it */
3404 object_aware(j_ptr);
3406 /* Hack -- clear the "fixed" flag from the item */
3407 j_ptr->ident &= ~(IDENT_FIXED);
3409 /* Describe the transaction */
3410 object_desc(o_name, j_ptr, 0);
3414 msg_format("%s¤ò $%ld¤Ç¹ØÆþ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3416 msg_format("You bought %s for %ld gold.", o_name, (long)price);
3419 strcpy(record_o_name, o_name);
3422 if (record_buy) do_cmd_write_nikki(NIKKI_BUY, 0, o_name);
3423 object_desc(o_name, o_ptr, OD_NAME_ONLY);
3424 if(record_rand_art && o_ptr->art_name)
3425 do_cmd_write_nikki(NIKKI_ART, 0, o_name);
3427 /* Erase the inscription */
3428 j_ptr->inscription = 0;
3430 /* Erase the "feeling" */
3431 j_ptr->feeling = FEEL_NONE;
3432 j_ptr->ident &= ~(IDENT_STORE);
3433 /* Give it to the player */
3434 item_new = inven_carry(j_ptr);
3436 /* Describe the final result */
3437 object_desc(o_name, &inventory[item_new], 0);
3441 msg_format("%s(%c)¤ò¼ê¤ËÆþ¤ì¤¿¡£", o_name, index_to_label(item_new));
3443 msg_format("You have %s (%c).",
3444 o_name, index_to_label(item_new));
3447 /* Auto-inscription */
3448 autopick_alter_item(item_new, FALSE);
3450 /* Now, reduce the original stack's pval. */
3451 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3453 o_ptr->pval -= j_ptr->pval;
3459 /* Note how many slots the store used to have */
3460 i = st_ptr->stock_num;
3462 /* Remove the bought items from the store */
3463 store_item_increase(item, -amt);
3464 store_item_optimize(item);
3466 /* Store is empty */
3467 if (st_ptr->stock_num == 0)
3470 if (one_in_(STORE_SHUFFLE))
3475 msg_print("Ź¼ç¤Ï°úÂष¤¿¡£");
3477 msg_print("The shopkeeper retires.");
3481 /* Shuffle the store */
3482 store_shuffle(cur_store_num);
3485 sprintf(buf, "%s (%s)",
3486 ot_ptr->owner_name, race_info[ot_ptr->owner_race].title);
3487 put_str(buf, 3, 10);
3488 sprintf(buf, "%s (%ld)",
3489 (f_name + f_info[FEAT_SHOP_HEAD + cur_store_num].name), (long)(ot_ptr->max_cost));
3498 msg_print("Ź¼ç¤Ï¿·¤¿¤Êºß¸Ë¤ò¼è¤ê½Ð¤·¤¿¡£");
3500 msg_print("The shopkeeper brings out some new stock.");
3506 for (i = 0; i < 10; i++)
3508 /* Maintain the store */
3509 store_maint(p_ptr->town_num, cur_store_num);
3515 /* Redraw everything */
3516 display_inventory();
3519 /* The item is gone */
3520 else if (st_ptr->stock_num != i)
3522 /* Pick the correct screen */
3523 if (store_top >= st_ptr->stock_num) store_top -= 12;
3525 /* Redraw everything */
3526 display_inventory();
3529 /* Item is still here */
3532 /* Redraw the item */
3533 display_entry(item);
3537 /* Player cannot afford it */
3540 /* Simple message (no insult) */
3542 msg_print("¤ª¶â¤¬Â¤ê¤Þ¤»¤ó¡£");
3544 msg_print("You do not have enough gold.");
3551 /* Home is much easier */
3554 /* Distribute charges of wands/rods */
3555 distribute_charges(o_ptr, j_ptr, amt);
3557 /* Give it to the player */
3558 item_new = inven_carry(j_ptr);
3560 /* Describe just the result */
3561 object_desc(o_name, &inventory[item_new], 0);
3565 msg_format("%s(%c)¤ò¼è¤Ã¤¿¡£",
3567 msg_format("You have %s (%c).",
3569 o_name, index_to_label(item_new));
3574 /* Take note if we take the last one */
3575 i = st_ptr->stock_num;
3577 /* Remove the items from the home */
3578 store_item_increase(item, -amt);
3579 store_item_optimize(item);
3581 /* Hack -- Item is still here */
3582 if (i == st_ptr->stock_num)
3584 /* Redraw the item */
3585 display_entry(item);
3588 /* The item is gone */
3592 if (st_ptr->stock_num == 0) store_top = 0;
3594 /* Nothing left on that screen */
3595 else if (store_top >= st_ptr->stock_num) store_top -= 12;
3597 /* Redraw everything */
3598 display_inventory();
3600 chg_virtue(V_SACRIFICE, 1);
3604 /* Not kicked out */
3610 * Sell an item to the store (or home)
3612 static void store_sell(void)
3618 s32b price, value, dummy;
3627 char o_name[MAX_NLEN];
3630 /* Prepare a prompt */
3631 if (cur_store_num == STORE_HOME)
3633 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÃÖ¤¤Þ¤¹¤«? ";
3635 q = "Drop which item? ";
3638 else if (cur_store_num == STORE_MUSEUM)
3640 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò´ó£¤·¤Þ¤¹¤«? ";
3642 q = "Give which item? ";
3647 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÇä¤ê¤Þ¤¹¤«? ";
3649 q = "Sell which item? ";
3653 item_tester_no_ryoute = TRUE;
3654 /* Only allow items the store will buy */
3655 item_tester_hook = store_will_buy;
3658 /* ²æ¤¬²È¤Ç¤ª¤«¤·¤Ê¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¥ª¥ê¥¸¥Ê¥ë¤Î¥Ð¥°¤ò½¤Àµ */
3659 if (cur_store_num == STORE_HOME)
3662 s = "ÃÖ¤±¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3664 s = "You don't have any item to drop.";
3667 else if (cur_store_num == STORE_MUSEUM)
3670 s = "´ó£¤Ç¤¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Þ¤»¤ó¡£";
3672 s = "You don't have any item to give.";
3678 s = "Íߤ·¤¤Êª¤¬¤Ê¤¤¤Ç¤¹¤Í¤¨¡£";
3680 s = "You have nothing that I want.";
3684 if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
3686 /* Get the item (in the pack) */
3689 o_ptr = &inventory[item];
3692 /* Get the item (on the floor) */
3695 o_ptr = &o_list[0 - item];
3699 /* Hack -- Cannot remove cursed items */
3700 if ((item >= INVEN_RARM) && cursed_p(o_ptr))
3704 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¤Í¡£");
3706 msg_print("Hmmm, it seems to be cursed.");
3715 /* Assume one item */
3718 /* Find out how many the player wants (letter means "all") */
3719 if (o_ptr->number > 1)
3721 /* Get a quantity */
3722 amt = get_quantity(NULL, o_ptr->number);
3724 /* Allow user abort */
3725 if (amt <= 0) return;
3728 /* Get local object */
3731 /* Get a copy of the object */
3732 object_copy(q_ptr, o_ptr);
3734 /* Modify quantity */
3735 q_ptr->number = amt;
3738 * Hack -- If a rod or wand, allocate total maximum
3739 * timeouts or charges to those being sold. -LM-
3741 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3743 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3746 /* Get a full description */
3747 object_desc(o_name, q_ptr, 0);
3749 /* Remove any inscription, feeling for stores */
3750 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3752 q_ptr->inscription = 0;
3753 q_ptr->feeling = FEEL_NONE;
3756 /* Is there room in the store (or the home?) */
3757 if (!store_check_num(q_ptr))
3759 if (cur_store_num == STORE_HOME)
3761 msg_print("²æ¤¬²È¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤Ê¤¤¡£");
3763 msg_print("Your home is full.");
3766 else if (cur_store_num == STORE_MUSEUM)
3768 msg_print("Çîʪ´Û¤Ï¤â¤¦ËþÇÕ¤À¡£");
3770 msg_print("Museum is full.");
3775 msg_print("¤¹¤¤¤Þ¤»¤ó¤¬¡¢Å¹¤Ë¤Ï¤â¤¦ÃÖ¤¯¾ì½ê¤¬¤¢¤ê¤Þ¤»¤ó¡£");
3777 msg_print("I have not the room in my store to keep it.");
3785 if ((cur_store_num != STORE_HOME) && (cur_store_num != STORE_MUSEUM))
3787 /* Describe the transaction */
3789 msg_format("%s(%c)¤òÇäµÑ¤¹¤ë¡£", o_name, index_to_label(item));
3791 msg_format("Selling %s (%c).", o_name, index_to_label(item));
3797 choice = sell_haggle(q_ptr, &price);
3800 if (st_ptr->store_open >= turn) return;
3812 if (cur_store_num == STORE_BLACK) /* The black market is illegal! */
3813 chg_virtue(V_JUSTICE, -1);
3815 if((o_ptr->tval == TV_BOTTLE) && (cur_store_num != STORE_HOME))
3816 chg_virtue(V_NATURE, 1);
3819 /* Get some money */
3822 /* Update the display */
3825 /* Get the "apparent" value */
3826 dummy = object_value(q_ptr) * q_ptr->number;
3829 identify_item(o_ptr);
3831 /* Get local object */
3834 /* Get a copy of the object */
3835 object_copy(q_ptr, o_ptr);
3837 /* Modify quantity */
3838 q_ptr->number = amt;
3840 /* Make it look like to be known */
3841 q_ptr->ident |= IDENT_STORE;
3844 * Hack -- If a rod or wand, let the shopkeeper know just
3845 * how many charges he really paid for. -LM-
3847 if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
3849 q_ptr->pval = o_ptr->pval * amt / o_ptr->number;
3852 /* Get the "actual" value */
3853 value = object_value(q_ptr) * q_ptr->number;
3855 /* Get the description all over again */
3856 object_desc(o_name, q_ptr, 0);
3858 /* Describe the result (in message buffer) */
3860 msg_format("%s¤ò $%ld¤ÇÇäµÑ¤·¤Þ¤·¤¿¡£", o_name, (long)price);
3862 msg_format("You sold %s for %ld gold.", o_name, (long)price);
3865 if (record_sell) do_cmd_write_nikki(NIKKI_SELL, 0, o_name);
3867 if (!((o_ptr->tval == TV_FIGURINE) && (value > 0)))
3869 /* Analyze the prices (and comment verbally) unless a figurine*/
3870 purchase_analyze(price, value, dummy);
3874 * Hack -- Allocate charges between those wands or rods sold
3875 * and retained, unless all are being sold. -LM-
3877 distribute_charges(o_ptr, q_ptr, amt);
3879 /* Reset timeouts of the sold items */
3882 /* Take the item from the player, describe the result */
3883 inven_item_increase(item, -amt);
3884 inven_item_describe(item);
3886 /* If items remain, auto-inscribe before optimizing */
3887 if (o_ptr->number > 0)
3888 autopick_alter_item(item, FALSE);
3890 inven_item_optimize(item);
3895 /* The store gets that (known) item */
3896 item_pos = store_carry(q_ptr);
3898 /* Re-display if item is now in store */
3901 store_top = (item_pos / 12) * 12;
3902 display_inventory();
3907 /* Player is at museum */
3908 else if (cur_store_num == STORE_MUSEUM)
3910 char o2_name[MAX_NLEN];
3911 object_desc(o2_name, q_ptr, OD_NAME_ONLY);
3913 if (-1 == store_check_num(q_ptr))
3916 msg_print("¤½¤ì¤ÈƱ¤¸ÉÊʪ¤Ï´û¤ËÇîʪ´Û¤Ë¤¢¤ë¤è¤¦¤Ç¤¹¡£");
3918 msg_print("The same object as it is already in the Museum.");
3924 msg_print("Çîʪ´Û¤Ë´ó£¤·¤¿¤â¤Î¤Ï¼è¤ê½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤»¤ó¡ª¡ª");
3926 msg_print("You cannot take items which is given to the Museum back!!");
3930 if (!get_check(format("ËÜÅö¤Ë%s¤ò´ó£¤·¤Þ¤¹¤«¡©", o2_name))) return;
3932 if (!get_check(format("Really give %s to the Museum? ", o2_name))) return;
3936 identify_item(q_ptr);
3937 q_ptr->ident |= IDENT_MENTAL;
3939 /* Distribute charges of wands/rods */
3940 distribute_charges(o_ptr, q_ptr, amt);
3944 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
3946 msg_format("You drop %s (%c).", o_name, index_to_label(item));
3951 /* Take it from the players inventory */
3952 inven_item_increase(item, -amt);
3953 inven_item_describe(item);
3954 inven_item_optimize(item);
3959 /* Let the home carry it */
3960 item_pos = home_carry(q_ptr);
3962 /* Update store display */
3965 store_top = (item_pos / 12) * 12;
3966 display_inventory();
3969 /* Player is at home */
3972 /* Distribute charges of wands/rods */
3973 distribute_charges(o_ptr, q_ptr, amt);
3977 msg_format("%s¤òÃÖ¤¤¤¿¡£(%c)", o_name, index_to_label(item));
3979 msg_format("You drop %s (%c).", o_name, index_to_label(item));
3984 /* Take it from the players inventory */
3985 inven_item_increase(item, -amt);
3986 inven_item_describe(item);
3987 inven_item_optimize(item);
3992 /* Let the home carry it */
3993 item_pos = home_carry(q_ptr);
3995 /* Update store display */
3998 store_top = (item_pos / 12) * 12;
3999 display_inventory();
4002 if (item >= INVEN_RARM) calc_android_exp();
4003 if ((choice == 0) && ((item == INVEN_RARM) || (item == INVEN_LARM))) kamaenaoshi(item);
4008 * Examine an item in a store -JDL-
4010 static void store_examine(void)
4015 char o_name[MAX_NLEN];
4020 if (st_ptr->stock_num <= 0)
4022 if (cur_store_num == STORE_HOME)
4024 msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4026 msg_print("Your home is empty.");
4029 else if (cur_store_num == STORE_MUSEUM)
4031 msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
4033 msg_print("Museum is empty.");
4038 msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
4040 msg_print("I am currently out of stock.");
4047 /* Find the number of objects on this and following pages */
4048 i = (st_ptr->stock_num - store_top);
4050 /* And then restrict it to the current page */
4055 sprintf(out_val, "¤É¤ì¤òÄ´¤Ù¤Þ¤¹¤«¡©");
4057 sprintf(out_val, "Which item do you want to examine? ");
4061 /* Get the item number to be examined */
4062 if (!get_stock(&item, out_val, 0, i - 1)) return;
4064 /* Get the actual index */
4065 item = item + store_top;
4067 /* Get the actual item */
4068 o_ptr = &st_ptr->stock[item];
4070 /* Require full knowledge */
4071 if (!(o_ptr->ident & IDENT_MENTAL))
4073 /* This can only happen in the home */
4075 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
4077 msg_print("You have no special knowledge about that item.");
4084 object_desc(o_name, o_ptr, 0);
4088 msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
4090 msg_format("Examining %s...", o_name);
4094 /* Describe it fully */
4095 if (!screen_object(o_ptr, TRUE))
4097 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
4099 msg_print("You see nothing special.");
4108 * Hack -- set this to leave the store
4110 static bool leave_store = FALSE;
4114 * Process a command in a store
4116 * Note that we must allow the use of a few "special" commands
4117 * in the stores which are not allowed in the dungeon, and we
4118 * must disable some commands which are allowed in the dungeon
4119 * but not in the stores, to prevent chaos.
4121 static void store_process_command(void)
4123 #ifdef ALLOW_REPEAT /* TNB */
4125 /* Handle repeating the last command */
4128 #endif /* ALLOW_REPEAT -- TNB */
4130 if (rogue_like_commands && command_cmd == 'l')
4132 command_cmd = 'x'; /* hack! */
4135 /* Parse the command */
4136 switch (command_cmd)
4146 /* 1 ¥Ú¡¼¥¸Ìá¤ë¥³¥Þ¥ó¥É: ²æ¤¬²È¤Î¥Ú¡¼¥¸¿ô¤¬Â¿¤¤¤Î¤Ç½ÅÊõ¤¹¤ë¤Ï¤º By BUG */
4149 if (st_ptr->stock_num <= 12) {
4151 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4153 msg_print("Entire inventory is shown.");
4158 if ( store_top < 0 )
4159 store_top = ((st_ptr->stock_num - 1 )/12) * 12;
4160 if ( (cur_store_num == STORE_HOME) && (powerup_home == FALSE) )
4161 if ( store_top >= 12 ) store_top = 12;
4162 display_inventory();
4170 if (st_ptr->stock_num <= 12)
4173 msg_print("¤³¤ì¤ÇÁ´Éô¤Ç¤¹¡£");
4175 msg_print("Entire inventory is shown.");
4183 * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
4184 * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
4186 if ((cur_store_num == STORE_HOME) &&
4187 (powerup_home == FALSE) &&
4188 (st_ptr->stock_num >= STORE_INVEN_MAX))
4190 if (store_top >= (STORE_INVEN_MAX - 1))
4197 if (store_top >= st_ptr->stock_num) store_top = 0;
4200 display_inventory();
4213 /* Get (purchase) */
4240 /*** Inventory Commands ***/
4242 /* Wear/wield equipment */
4249 /* Take off equipment */
4256 /* Destroy an item */
4263 /* Equipment list */
4270 /* Inventory list */
4278 /*** Various commands ***/
4280 /* Identify an object */
4287 /* Hack -- toggle windows */
4290 toggle_inven_equip();
4296 /*** Use various objects ***/
4305 /* Inscribe an object */
4312 /* Uninscribe an object */
4315 do_cmd_uninscribe();
4321 /*** Help and Such ***/
4330 /* Identify symbol */
4333 do_cmd_query_symbol();
4337 /* Character description */
4340 p_ptr->town_num = old_town_num;
4341 do_cmd_change_name();
4342 p_ptr->town_num = inner_town_num;
4348 /*** System Commands ***/
4350 /* Hack -- User interface */
4357 /* Single line from a pref file */
4360 p_ptr->town_num = old_town_num;
4362 p_ptr->town_num = inner_town_num;
4366 /* Interact with macros */
4369 p_ptr->town_num = old_town_num;
4371 p_ptr->town_num = inner_town_num;
4375 /* Interact with visuals */
4378 p_ptr->town_num = old_town_num;
4380 p_ptr->town_num = inner_town_num;
4384 /* Interact with colors */
4387 p_ptr->town_num = old_town_num;
4389 p_ptr->town_num = inner_town_num;
4393 /* Interact with options */
4400 /*** Misc Commands ***/
4416 /* Repeat level feeling */
4423 /* Show previous message */
4426 do_cmd_message_one();
4430 /* Show previous messages */
4443 /* Check artifacts, uniques etc. */
4450 /* Load "screen dump" */
4453 do_cmd_load_screen();
4457 /* Save "screen dump" */
4460 do_cmd_save_screen();
4464 /* Hack -- Unknown command */
4468 msg_print("¤½¤Î¥³¥Þ¥ó¥É¤ÏŹ¤ÎÃæ¤Ç¤Ï»È¤¨¤Þ¤»¤ó¡£");
4470 msg_print("That command does not work in stores.");
4480 * Enter a store, and interact with it.
4482 * Note that we use the standard "request_command()" function
4483 * to get a command, allowing us to use "command_arg" and all
4484 * command macros and other nifty stuff, but we use the special
4485 * "shopping" argument, to force certain commands to be converted
4486 * into other commands, normally, we convert "p" (pray) and "m"
4487 * (cast magic) into "g" (get), and "s" (search) into "d" (drop).
4489 void do_cmd_store(void)
4495 bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
4498 /* Access the player grid */
4499 c_ptr = &cave[py][px];
4501 /* Verify a store */
4502 if (!((c_ptr->feat >= FEAT_SHOP_HEAD) &&
4503 (c_ptr->feat <= FEAT_SHOP_TAIL)) &&
4504 (c_ptr->feat != FEAT_MUSEUM))
4507 msg_print("¤³¤³¤Ë¤ÏŹ¤¬¤¢¤ê¤Þ¤»¤ó¡£");
4509 msg_print("You see no store here.");
4515 /* Extract the store code */
4516 if (c_ptr->feat == FEAT_MUSEUM) which = STORE_MUSEUM;
4517 else which = (c_ptr->feat - FEAT_SHOP_HEAD);
4519 old_town_num = p_ptr->town_num;
4520 if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
4521 if (dun_level) p_ptr->town_num = NO_TOWN;
4522 inner_town_num = p_ptr->town_num;
4524 /* Hack -- Check the "locked doors" */
4525 if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
4529 msg_print("¥É¥¢¤Ë¸°¤¬¤«¤«¤Ã¤Æ¤¤¤ë¡£");
4531 msg_print("The doors are locked.");
4534 p_ptr->town_num = old_town_num;
4538 /* Calculate the number of store maintainances since the last visit */
4539 maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
4541 /* Maintain the store max. 10 times */
4542 if (maintain_num > 10) maintain_num = 10;
4546 /* Maintain the store */
4547 for (i = 0; i < maintain_num; i++)
4548 store_maint(p_ptr->town_num, which);
4550 /* Save the visit */
4551 town[p_ptr->town_num].store[which].last_visit = turn;
4554 /* Forget the lite */
4557 /* Forget the view */
4561 /* Hack -- Character is in "icky" mode */
4562 character_icky = TRUE;
4565 /* No command argument */
4568 /* No repeated command */
4571 /* No automatic command */
4575 /* Save the store number */
4576 cur_store_num = which;
4578 /* Save the store and owner pointers */
4579 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4580 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4583 /* Start at the beginning */
4586 /* Display the store */
4590 leave_store = FALSE;
4592 /* Interact with player */
4593 while (!leave_store)
4595 /* Hack -- Clear line 1 */
4602 /* Basic commands */
4604 prt(" ESC) ·úʪ¤«¤é½Ð¤ë", 21, 0);
4606 prt(" ESC) Exit from Building.", 21, 0);
4610 /* Browse if necessary */
4611 if (st_ptr->stock_num > 12)
4614 prt(" -)Á°¥Ú¡¼¥¸", 22, 0);
4615 prt(" ¥¹¥Ú¡¼¥¹) ¼¡¥Ú¡¼¥¸", 23, 0);
4617 prt(" -) Previous page", 22, 0);
4618 prt(" SPACE) Next page", 23, 0);
4624 if (cur_store_num == STORE_HOME)
4627 prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
4628 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
4629 prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
4631 prt("g) Get an item.", 21, 27);
4632 prt("d) Drop an item.", 22, 27);
4633 prt("x) eXamine an item in the home.", 23,27);
4638 /* Museum commands */
4639 else if (cur_store_num == STORE_MUSEUM)
4642 prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
4643 prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
4645 prt("d) Drop an item.", 21, 27);
4646 prt("x) eXamine an item in the museum.", 23,27);
4651 /* Shop commands XXX XXX XXX */
4655 prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
4656 prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
4657 prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,30);
4659 prt("p) Purchase an item.", 21, 30);
4660 prt("s) Sell an item.", 22, 30);
4661 prt("x) eXamine an item in the shop", 23,30);
4667 /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
4669 prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56);
4671 if( rogue_like_commands == TRUE )
4673 prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
4677 prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
4680 prt("i/e) Inventry/Equipment list", 21, 56);
4682 if( rogue_like_commands == TRUE )
4684 prt("w/T) Wear/Take off equipment", 22, 56);
4688 prt("w/t) Wear/Take off equipment", 22, 56);
4693 prt("¥³¥Þ¥ó¥É:", 20, 0);
4695 prt("You may: ", 20, 0);
4700 request_command(TRUE);
4702 /* Process the command */
4703 store_process_command();
4706 * Hack -- To redraw missiles damage and prices in store
4707 * If player's charisma changes, or if player changes a bow, PU_BONUS is set
4709 need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
4711 /* Hack -- Character is still in "icky" mode */
4712 character_icky = TRUE;
4720 /* XXX XXX XXX Pack Overflow */
4721 if (inventory[INVEN_PACK].k_idx)
4723 int item = INVEN_PACK;
4725 object_type *o_ptr = &inventory[item];
4727 /* Hack -- Flee from the store */
4728 if (cur_store_num != STORE_HOME)
4732 if (cur_store_num == STORE_MUSEUM)
4733 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆÇîʪ´Û¤«¤é½Ð¤¿...");
4735 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤ÆŹ¤«¤é½Ð¤¿...");
4737 if (cur_store_num == STORE_MUSEUM)
4738 msg_print("Your pack is so full that you flee the Museum...");
4740 msg_print("Your pack is so full that you flee the store...");
4748 /* Hack -- Flee from the home */
4749 else if (!store_check_num(o_ptr))
4753 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤½¤¦¤Ê¤Î¤Ç¡¢¤¢¤ï¤Æ¤Æ²È¤«¤é½Ð¤¿...");
4755 msg_print("Your pack is so full that you flee your home...");
4763 /* Hack -- Drop items into the home */
4771 char o_name[MAX_NLEN];
4774 /* Give a message */
4776 msg_print("¥¶¥Ã¥¯¤«¤é¥¢¥¤¥Æ¥à¤¬¤¢¤Õ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
4778 msg_print("Your pack overflows!");
4782 /* Get local object */
4785 /* Grab a copy of the item */
4786 object_copy(q_ptr, o_ptr);
4789 object_desc(o_name, q_ptr, 0);
4793 msg_format("%s¤¬Íî¤Á¤¿¡£(%c)", o_name, index_to_label(item));
4795 msg_format("You drop %s (%c).", o_name, index_to_label(item));
4799 /* Remove it from the players inventory */
4800 inven_item_increase(item, -255);
4801 inven_item_describe(item);
4802 inven_item_optimize(item);
4807 /* Let the home carry it */
4808 item_pos = home_carry(q_ptr);
4810 /* Redraw the home */
4813 store_top = (item_pos / 12) * 12;
4814 display_inventory();
4819 /* Hack -- Redisplay store prices if charisma changes */
4820 /* Hack -- Redraw missiles damage if player changes bow */
4821 if (need_redraw_store_inv) display_inventory();
4823 /* Hack -- get kicked out of the store */
4824 if (st_ptr->store_open >= turn) leave_store = TRUE;
4827 p_ptr->town_num = old_town_num;
4829 /* Free turn XXX XXX XXX */
4833 /* Hack -- Character is no longer in "icky" mode */
4834 character_icky = FALSE;
4837 /* Hack -- Cancel automatic command */
4840 /* Hack -- Cancel "see" mode */
4841 command_see = FALSE;
4844 /* Flush messages XXX XXX XXX */
4848 /* Clear the screen */
4852 /* Update everything */
4853 p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
4854 p_ptr->update |= (PU_MONSTERS);
4856 /* Redraw entire screen */
4857 p_ptr->redraw |= (PR_BASIC | PR_EXTRA | PR_EQUIPPY);
4860 p_ptr->redraw |= (PR_MAP);
4863 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4869 * Shuffle one of the stores.
4871 void store_shuffle(int which)
4877 if (which == STORE_HOME) return;
4878 if (which == STORE_MUSEUM) return;
4881 /* Save the store index */
4882 cur_store_num = which;
4884 /* Activate that store */
4885 st_ptr = &town[p_ptr->town_num].store[cur_store_num];
4888 /* Pick a new owner */
4891 st_ptr->owner = (byte)randint0(MAX_OWNERS);
4892 if (j == st_ptr->owner) continue;
4893 for (i = 1;i < max_towns; i++)
4895 if (i == p_ptr->town_num) continue;
4896 if (st_ptr->owner == town[i].store[cur_store_num].owner) break;
4898 if (i == max_towns) break;
4901 /* Activate the new owner */
4902 ot_ptr = &owners[cur_store_num][st_ptr->owner];
4905 /* Reset the owner data */
4906 st_ptr->insult_cur = 0;
4907 st_ptr->store_open = 0;
4908 st_ptr->good_buy = 0;
4909 st_ptr->bad_buy = 0;
4912 /* Hack -- discount all the items */
4913 for (i = 0; i < st_ptr->stock_num; i++)
4918 o_ptr = &st_ptr->stock[i];
4920 if (!(artifact_p(o_ptr) || o_ptr->art_name))
4922 /* Hack -- Sell all non-artifact old items for "half price" */
4923 o_ptr->discount = 50;
4925 /* Hack -- Items are no longer "fixed price" */
4926 o_ptr->ident &= ~(IDENT_FIXED);
4928 /* Mega-Hack -- Note that the item is "on sale" */
4930 o_ptr->inscription = quark_add("Çä½ÐÃæ");
4932 o_ptr->inscription = quark_add("on sale");
4940 * Maintain the inventory at the stores.
4942 void store_maint(int town_num, int store_num)
4946 int old_rating = rating;
4948 cur_store_num = store_num;
4951 if (store_num == STORE_HOME) return;
4952 if (store_num == STORE_MUSEUM) return;
4954 /* Activate that store */
4955 st_ptr = &town[town_num].store[store_num];
4957 /* Activate the owner */
4958 ot_ptr = &owners[store_num][st_ptr->owner];
4960 /* Store keeper forgives the player */
4961 st_ptr->insult_cur = 0;
4963 /* Mega-Hack -- prune the black market */
4964 if (store_num == STORE_BLACK)
4966 /* Destroy crappy black market items */
4967 for (j = st_ptr->stock_num - 1; j >= 0; j--)
4969 object_type *o_ptr = &st_ptr->stock[j];
4971 /* Destroy crappy items */
4972 if (black_market_crap(o_ptr))
4974 /* Destroy the item */
4975 store_item_increase(j, 0 - o_ptr->number);
4976 store_item_optimize(j);
4982 /* Choose the number of slots to keep */
4983 j = st_ptr->stock_num;
4985 /* Sell a few items */
4986 j = j - randint1(STORE_TURNOVER);
4988 /* Never keep more than "STORE_MAX_KEEP" slots */
4989 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
4991 /* Always "keep" at least "STORE_MIN_KEEP" items */
4992 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
4994 /* Hack -- prevent "underflow" */
4997 /* Destroy objects until only "j" slots are left */
4998 while (st_ptr->stock_num > j) store_delete();
5001 /* Choose the number of slots to fill */
5002 j = st_ptr->stock_num;
5004 /* Buy some more items */
5005 j = j + randint1(STORE_TURNOVER);
5007 /* Never keep more than "STORE_MAX_KEEP" slots */
5008 if (j > STORE_MAX_KEEP) j = STORE_MAX_KEEP;
5010 /* Always "keep" at least "STORE_MIN_KEEP" items */
5011 if (j < STORE_MIN_KEEP) j = STORE_MIN_KEEP;
5013 /* Hack -- prevent "overflow" */
5014 if (j >= st_ptr->stock_size) j = st_ptr->stock_size - 1;
5016 /* Acquire some new items */
5017 while (st_ptr->stock_num < j) store_create();
5020 /* Hack -- Restore the rating */
5021 rating = old_rating;
5026 * Initialize the stores
5028 void store_init(int town_num, int store_num)
5032 cur_store_num = store_num;
5034 /* Activate that store */
5035 st_ptr = &town[town_num].store[store_num];
5043 st_ptr->owner = (byte)randint0(MAX_OWNERS);
5044 for (i = 1;i < max_towns; i++)
5046 if (i == town_num) continue;
5047 if (st_ptr->owner == town[i].store[store_num].owner) break;
5049 if (i == max_towns) break;
5052 /* Activate the new owner */
5053 ot_ptr = &owners[store_num][st_ptr->owner];
5056 /* Initialize the store */
5057 st_ptr->store_open = 0;
5058 st_ptr->insult_cur = 0;
5059 st_ptr->good_buy = 0;
5060 st_ptr->bad_buy = 0;
5062 /* Nothing in stock */
5063 st_ptr->stock_num = 0;
5066 * MEGA-HACK - Last visit to store is
5067 * BEFORE player birth to enable store restocking
5069 st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
5071 /* Clear any old items */
5072 for (k = 0; k < st_ptr->stock_size; k++)
5074 object_wipe(&st_ptr->stock[k]);
5079 void move_to_black_market(object_type *o_ptr)
5082 if (!p_ptr->town_num) return;
5084 st_ptr = &town[p_ptr->town_num].store[STORE_BLACK];
5086 o_ptr->ident |= IDENT_STORE;
5088 (void)store_carry(o_ptr);
5090 object_wipe(o_ptr); /* Don't leave a bogus object behind... */