/* File: store.c */
-/* Purpose: Store commands */
-
/*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
*
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies. Other copyrights may also apply.
*/
+/* Purpose: Store commands */
+
#include "angband.h"
static store_type *st_ptr = NULL;
static owner_type *ot_ptr = NULL;
#endif
+static s16b old_town_num = 0;
+static s16b inner_town_num = 0;
#define RUMOR_CHANCE 8
#define MAX_COMMENT_1 6
char rumour[1024];
#ifdef JP
- /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
- if ( cur_store_num == STORE_BLACK ) {
- msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
- }
- else{
- msg_print(comment_1[randint0(MAX_COMMENT_1)]);
- }
+ /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î¤È¤¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
+ if ( cur_store_num == STORE_BLACK ) {
+ msg_print(comment_1_B[randint0(MAX_COMMENT_1)]);
+ }
+ else{
+ msg_print(comment_1[randint0(MAX_COMMENT_1)]);
+ }
#else
msg_print(comment_1[randint0(MAX_COMMENT_1)]);
#endif
static void say_comment_4(void)
{
#ifdef JP
- /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
- if ( cur_store_num == STORE_BLACK ){
- msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
- msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
- }
- else{
- msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
- msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
- }
+ /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
+ if ( cur_store_num == STORE_BLACK ){
+ msg_print(comment_4a_B[randint0(MAX_COMMENT_4A)]);
+ msg_print(comment_4b_B[randint0(MAX_COMMENT_4B)]);
+ }
+ else{
+ msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
+ msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
+ }
#else
msg_print(comment_4a[randint0(MAX_COMMENT_4A)]);
msg_print(comment_4b[randint0(MAX_COMMENT_4B)]);
static void say_comment_5(void)
{
#ifdef JP
- /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
- if ( cur_store_num == STORE_BLACK ){
- msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
- }
- else{
- msg_print(comment_5[randint0(MAX_COMMENT_5)]);
- }
+ /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸¤ò½Ð¤¹ */
+ if ( cur_store_num == STORE_BLACK ){
+ msg_print(comment_5_B[randint0(MAX_COMMENT_5)]);
+ }
+ else{
+ msg_print(comment_5[randint0(MAX_COMMENT_5)]);
+ }
#else
msg_print(comment_5[randint0(MAX_COMMENT_5)]);
#endif
/* Mega-Hack -- Black market sucks */
if (cur_store_num == STORE_BLACK)
price = price / 2;
+
+ /* Compute the final price (with rounding) */
+ /* Hack -- prevent underflow */
+ price = (price * adjust + 50L) / 100L;
}
/* Shop is selling */
/* Mega-Hack -- Black market sucks */
if (cur_store_num == STORE_BLACK)
price = price * 2;
- }
- /* Compute the final price (with rounding) */
- price = (price * adjust + 50L) / 100L;
+ /* Compute the final price (with rounding) */
+ /* Hack -- prevent overflow */
+ price = (s32b)(((u32b)price * (u32b)adjust + 50UL) / 100UL);
+ }
/* Note -- Never become "free" */
if (price <= 0L) return (1L);
{
if (cost <= 5L) size += damroll(3, 5);
if (cost <= 20L) size += damroll(3, 5);
+ if (cost <= 50L) size += damroll(2, 2);
break;
}
case TV_ARCANE_BOOK:
case TV_ENCHANT_BOOK:
case TV_DAEMON_BOOK:
+ case TV_CRUSADE_BOOK:
case TV_MUSIC_BOOK:
case TV_HISSATSU_BOOK:
{
*/
static bool store_object_similar(object_type *o_ptr, object_type *j_ptr)
{
+ int i;
+
/* Hack -- Identical items cannot be stacked */
if (o_ptr == j_ptr) return (0);
if (o_ptr->art_name || j_ptr->art_name) return (0);
/* Hack -- Identical art_flags! */
- if ((o_ptr->art_flags1 != j_ptr->art_flags1) ||
- (o_ptr->art_flags2 != j_ptr->art_flags2) ||
- (o_ptr->art_flags3 != j_ptr->art_flags3))
- return (0);
+ for (i = 0; i < TR_FLAG_SIZE; i++)
+ if (o_ptr->art_flags[i] != j_ptr->art_flags[i]) return (0);
/* Hack -- Never stack "powerful" items */
if (o_ptr->xtra1 || j_ptr->xtra1) return (0);
*/
static void store_object_absorb(object_type *o_ptr, object_type *j_ptr)
{
+ int max_num = (o_ptr->tval == TV_ROD) ?
+ MIN(99, MAX_SHORT / k_info[o_ptr->k_idx].pval) : 99;
int total = o_ptr->number + j_ptr->number;
+ int diff = (total > max_num) ? total - max_num : 0;
/* Combine quantity, lose excess items */
- o_ptr->number = (total > 99) ? 99 : total;
+ o_ptr->number = (total > max_num) ? max_num : total;
/* Hack -- if rods are stacking, add the pvals (maximum timeouts) together. -LM- */
if (o_ptr->tval == TV_ROD)
{
- o_ptr->pval += j_ptr->pval;
+ o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
}
/* Hack -- if wands are stacking, combine the charges. -LM- */
if (o_ptr->tval == TV_WAND)
{
- o_ptr->pval += j_ptr->pval;
+ o_ptr->pval += j_ptr->pval * (j_ptr->number - diff) / j_ptr->number;
}
}
static bool is_blessed(object_type *o_ptr)
{
- u32b f1, f2, f3;
- object_flags(o_ptr, &f1, &f2, &f3);
- if (f3 & TR3_BLESSED) return (TRUE);
+ u32b flgs[TR_FLAG_SIZE];
+ object_flags(o_ptr, flgs);
+ if (have_flag(flgs, TR_BLESSED)) return (TRUE);
else return (FALSE);
}
/* Analyze the type */
switch (o_ptr->tval)
{
+ case TV_POTION:
+ if (o_ptr->sval != SV_POTION_WATER) return FALSE;
+
case TV_WHISTLE:
case TV_FOOD:
case TV_LITE:
switch (o_ptr->tval)
{
case TV_LIFE_BOOK:
+ case TV_CRUSADE_BOOK:
case TV_SCROLL:
case TV_POTION:
case TV_HAFTED:
case TV_ARCANE_BOOK:
case TV_ENCHANT_BOOK:
case TV_DAEMON_BOOK:
+ case TV_CRUSADE_BOOK:
case TV_MUSIC_BOOK:
break;
default:
object_prep(q_ptr, i);
/* Apply some "low-level" magic (no artifacts) */
- apply_magic(q_ptr, level, FALSE, FALSE, FALSE, FALSE);
+ apply_magic(q_ptr, level, AM_NO_FIXED_ART);
/* Require valid object */
if (!store_will_buy(q_ptr)) continue;
{
cur_col++;
if (a & 0x80)
- Term_draw(cur_col, i + 6, 255, 255);
+ Term_draw(cur_col, i + 6, 255, -1);
}
cur_col += 2;
}
/* Only show the weight of an individual item */
int wgt = o_ptr->weight;
#ifdef JP
- sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
- put_str(out_val, i+6, 67);
+ sprintf(out_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
+ put_str(out_val, i+6, 67);
#else
(void)sprintf(out_val, "%3d.%d lb", wgt / 10, wgt % 10);
put_str(out_val, i+6, 68);
/* Only show the weight of an individual item */
int wgt = o_ptr->weight;
#ifdef JP
- sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
- put_str(out_val, i+6, 60);
+ sprintf(out_val, "%3d.%1d", lbtokg1(wgt) , lbtokg2(wgt) );
+ put_str(out_val, i+6, 60);
#else
(void)sprintf(out_val, "%3d.%d", wgt / 10, wgt % 10);
put_str(out_val, i+6, 61);
/* Indicate the "current page" */
+ /* Trailing spaces are to display (Page xx) and (Page x) */
#ifdef JP
- put_str(format("(%d¥Ú¡¼¥¸)", store_top/12 + 1), 5, 20);
+ put_str(format("(%d¥Ú¡¼¥¸) ", store_top/12 + 1), 5, 20);
#else
- put_str(format("(Page %d)", store_top/12 + 1), 5, 20);
+ put_str(format("(Page %d) ", store_top/12 + 1), 5, 20);
#endif
}
/* Build the prompt */
#ifdef JP
- (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
- (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
+ (void)sprintf(out_val, "(%s:%c-%c, ESC¤ÇÃæÃÇ) %s",
+ (((cur_store_num == STORE_HOME) || (cur_store_num == STORE_MUSEUM)) ? "¥¢¥¤¥Æ¥à" : "¾¦ÉÊ"),
I2A(i), I2A(j), pmt);
#else
(void)sprintf(out_val, "(Items %c-%c, ESC to exit) %s",
* Return TRUE if offer is NOT okay
*/
static bool receive_offer(cptr pmt, s32b *poffer,
- s32b last_offer, int factor,
- s32b price, int final)
+ s32b last_offer, int factor,
+ s32b price, int final)
{
/* Haggle till done */
while (TRUE)
cancel = receive_offer("What do you offer? ",
#endif
- &offer, last_offer, 1, cur_ask, final);
+ &offer, last_offer, 1, cur_ask, final);
if (cancel)
{
/* No need to haggle */
if (noneed || !manual_haggle || (final_ask >= purse))
{
+ /* Apply Sales Tax (if needed) */
+ if (!manual_haggle && !noneed)
+ {
+ final_ask -= final_ask / 10;
+ }
+
/* No reason to haggle */
if (final_ask >= purse)
{
#endif
msg_print(NULL);
-
- /* Apply Sales Tax */
- final_ask -= final_ask / 10;
}
/* Final price */
prt("", 1, 0);
(void)sprintf(out_val,
#ifdef JP
- "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
+ "Á°²ó¤ÎÄ󼨲Á³Ê $%ld", (long)last_offer);
#else
"Your last bid %ld", (long)last_offer);
#endif
/* Prompt */
#ifdef JP
- /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
- switch( cur_store_num ) {
- case 7:
- sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
- break;
- case 6:
- sprintf(out_val, "¤É¤ì? ");
- break;
- default:
- sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
- break;
- }
+ /* ¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤Î»þ¤ÏÊ̤Υá¥Ã¥»¡¼¥¸ */
+ switch( cur_store_num ) {
+ case 7:
+ sprintf(out_val, "¤É¤Î¥¢¥¤¥Æ¥à¤ò¼è¤ê¤Þ¤¹¤«? ");
+ break;
+ case 6:
+ sprintf(out_val, "¤É¤ì? ");
+ break;
+ default:
+ sprintf(out_val, "¤É¤ÎÉÊʪ¤¬Íߤ·¤¤¤ó¤À¤¤? ");
+ break;
+ }
#else
if (cur_store_num == STORE_HOME)
{
/* Player can afford it */
if (p_ptr->au >= price)
{
+ int idx;
+
/* Say "okay" */
say_comment_1();
o_name, index_to_label(item_new));
#endif
+ /* Auto-inscription */
+ idx = is_autopick(&inventory[item_new]);
+ auto_inscribe_item(item_new, idx);
/* Now, reduce the original stack's pval. */
if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
{
if (cur_store_num == STORE_HOME)
#ifdef JP
-msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
+ msg_print("²æ¤¬²È¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
#else
msg_print("Your home is empty.");
#endif
- if (cur_store_num == STORE_MUSEUM)
+ else if (cur_store_num == STORE_MUSEUM)
#ifdef JP
-msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
+ msg_print("Çîʪ´Û¤Ë¤Ï²¿¤âÃÖ¤¤¤Æ¤¢¤ê¤Þ¤»¤ó¡£");
#else
msg_print("Museum is empty.");
#endif
else
#ifdef JP
-msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
+ msg_print("¸½ºß¾¦Éʤκ߸ˤòÀڤ餷¤Æ¤¤¤Þ¤¹¡£");
#else
msg_print("I am currently out of stock.");
#endif
/* Describe it fully */
- if (!identify_fully_aux(o_ptr))
+ if (!screen_object(o_ptr, TRUE))
#ifdef JP
msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
#else
else
{
store_top += 12;
- /*
- * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
- * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
- */
- if ((cur_store_num == STORE_HOME) &&
- (powerup_home == FALSE) &&
- (st_ptr->stock_num >= STORE_INVEN_MAX))
- {
- if (store_top >= (STORE_INVEN_MAX - 1))
- {
- store_top = 0;
- }
- }
- else
- {
- if (store_top >= st_ptr->stock_num) store_top = 0;
- }
+ /*
+ * ±£¤·¥ª¥×¥·¥ç¥ó(powerup_home)¤¬¥»¥Ã¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¤È¤¤Ï
+ * ²æ¤¬²È¤Ç¤Ï 2 ¥Ú¡¼¥¸¤Þ¤Ç¤·¤«É½¼¨¤·¤Ê¤¤
+ */
+ if ((cur_store_num == STORE_HOME) &&
+ (powerup_home == FALSE) &&
+ (st_ptr->stock_num >= STORE_INVEN_MAX))
+ {
+ if (store_top >= (STORE_INVEN_MAX - 1))
+ {
+ store_top = 0;
+ }
+ }
+ else
+ {
+ if (store_top >= st_ptr->stock_num) store_top = 0;
+ }
display_inventory();
}
/* Character description */
case 'C':
{
+ p_ptr->town_num = old_town_num;
do_cmd_change_name();
+ p_ptr->town_num = inner_town_num;
display_store();
break;
}
/* Single line from a pref file */
case '"':
{
+ p_ptr->town_num = old_town_num;
do_cmd_pref();
+ p_ptr->town_num = inner_town_num;
break;
}
/* Interact with macros */
case '@':
{
+ p_ptr->town_num = old_town_num;
do_cmd_macros();
+ p_ptr->town_num = inner_town_num;
break;
}
/* Interact with visuals */
case '%':
{
+ p_ptr->town_num = old_town_num;
do_cmd_visuals();
+ p_ptr->town_num = inner_town_num;
break;
}
/* Interact with colors */
case '&':
{
+ p_ptr->town_num = old_town_num;
do_cmd_colors();
+ p_ptr->town_num = inner_town_num;
break;
}
{
int which;
int maintain_num;
- int tmp_chr;
int i;
cave_type *c_ptr;
- s16b old_town_num;
+ bool need_redraw_store_inv; /* To redraw missiles damage and prices in store */
/* Access the player grid */
old_town_num = p_ptr->town_num;
if ((which == STORE_HOME) || (which == STORE_MUSEUM)) p_ptr->town_num = 1;
if (dun_level) p_ptr->town_num = NO_TOWN;
+ inner_town_num = p_ptr->town_num;
/* Hack -- Check the "locked doors" */
if ((town[p_ptr->town_num].store[which].store_open >= turn) ||
}
/* Calculate the number of store maintainances since the last visit */
- maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TURNS);
+ maintain_num = (turn - town[p_ptr->town_num].store[which].last_visit) / (TURNS_PER_TICK * STORE_TICKS);
/* Maintain the store max. 10 times */
if (maintain_num > 10) maintain_num = 10;
/* Hack -- Clear line 1 */
prt("", 1, 0);
- /* Hack -- Check the charisma */
- tmp_chr = p_ptr->stat_use[A_CHR];
-
/* Clear */
clear_from(20);
if (cur_store_num == STORE_HOME)
{
#ifdef JP
- prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
- prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
+ prt("g) ¥¢¥¤¥Æ¥à¤ò¼è¤ë", 21, 27);
+ prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 22, 27);
prt("x) ²È¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
#else
prt("g) Get an item.", 21, 27);
else if (cur_store_num == STORE_MUSEUM)
{
#ifdef JP
- prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
+ prt("d) ¥¢¥¤¥Æ¥à¤òÃÖ¤¯", 21, 27);
prt("x) Çîʪ´Û¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤ë", 23,27);
#else
prt("d) Drop an item.", 21, 27);
else
{
#ifdef JP
- prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
- prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
+ prt("p) ¾¦ÉʤòÇ㤦", 21, 30);
+ prt("s) ¥¢¥¤¥Æ¥à¤òÇä¤ë", 22, 30);
prt("x) ¾¦ÉʤòÄ´¤Ù¤ë", 23,30);
#else
prt("p) Purchase an item.", 21, 30);
}
#ifdef JP
- /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
-
- prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56);
-
- if( rogue_like_commands == TRUE )
- {
- prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
- }
- else
- {
- prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
- }
+ /* ´ðËÜŪ¤Ê¥³¥Þ¥ó¥É¤ÎÄɲÃɽ¼¨ */
+
+ prt("i/e) »ý¤Áʪ/ÁõÈ÷¤Î°ìÍ÷", 21, 56);
+
+ if( rogue_like_commands == TRUE )
+ {
+ prt("w/T) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
+ }
+ else
+ {
+ prt("w/t) ÁõÈ÷¤¹¤ë/¤Ï¤º¤¹", 22, 56);
+ }
#else
- prt("i/e) Inventry/Equipment list", 21, 56);
-
- if( rogue_like_commands == TRUE )
- {
- prt("w/T) Wear/Take off equipment", 22, 56);
- }
- else
- {
- prt("w/t) Wear/Take off equipment", 22, 56);
- }
+ prt("i/e) Inventry/Equipment list", 21, 56);
+
+ if( rogue_like_commands == TRUE )
+ {
+ prt("w/T) Wear/Take off equipment", 22, 56);
+ }
+ else
+ {
+ prt("w/t) Wear/Take off equipment", 22, 56);
+ }
#endif
/* Prompt */
#ifdef JP
/* Process the command */
store_process_command();
+ /*
+ * Hack -- To redraw missiles damage and prices in store
+ * If player's charisma changes, or if player changes a bow, PU_BONUS is set
+ */
+ need_redraw_store_inv = (p_ptr->update & PU_BONUS) ? TRUE : FALSE;
+
/* Hack -- Character is still in "icky" mode */
character_icky = TRUE;
}
/* Hack -- Redisplay store prices if charisma changes */
- if (tmp_chr != p_ptr->stat_use[A_CHR]) display_inventory();
+ /* Hack -- Redraw missiles damage if player changes bow */
+ if (need_redraw_store_inv) display_inventory();
/* Hack -- get kicked out of the store */
if (st_ptr->store_open >= turn) leave_store = TRUE;
/* Update everything */
- p_ptr->update |= (PU_VIEW | PU_LITE);
+ p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
p_ptr->update |= (PU_MONSTERS);
/* Redraw entire screen */
* MEGA-HACK - Last visit to store is
* BEFORE player birth to enable store restocking
*/
- st_ptr->last_visit = -200L * STORE_TURNS;
+ st_ptr->last_visit = -10L * TURNS_PER_TICK * STORE_TICKS;
/* Clear any old items */
for (k = 0; k < st_ptr->stock_size; k++)