-+-+-+-+-+-+-+-+ START OF PART 69 -+-+-+-+-+-+-+-+ X`09`09`09 Clear it because it is useless. */ X`09`09 if (last_offer + last_store_inc < cur_ask) X`09`09`09last_store_inc = 0; X`09`09 `7D X`09`09 else if (new_offer == cur_ask) X`09`09 `7B X`09`09 flag = TRUE; X`09`09 *price = new_offer; X`09`09 `7D X`09`09 else X`09`09 loop_flag = FALSE; X`09`09`7D X`09 `7D X`09 while (!flag && loop_flag); X`09 if (!flag) X`09 `7B X`09 x1 = (last_offer - new_offer) * 100 / (last_offer - cur_ask); X`09 if (x1 < min_per) X`09`09`7B X`09`09 flag = haggle_insults(store_num); X`09`09 if (flag) sell = 2; X`09`09`7D X`09 else if (x1 > max_per) X`09`09`7B X`09`09 x1 = x1 * 75 / 100; X`09`09 if (x1 < max_per) x1 = max_per; X`09`09`7D X`09 x2 = x1 + randint(5) - 3; X`09 x3 = ((new_offer - cur_ask) * x2 / 100) + 1; X`09 /* don't let the price go down */ X`09 if (x3 < 0) X`09`09x3 = 0; X`09 cur_ask += x3; X`09 if (cur_ask > final_ask) X`09`09`7B X`09`09 cur_ask = final_ask; X`09`09 comment = "Final Offer"; X`09`09 /* Set the automatic haggle increment so that RET will give X`09`09 a new_offer equal to the final_ask price. */ X`09`09 last_store_inc = final_ask - new_offer; X`09`09 final_flag++; X`09`09 if (final_flag > 3) X`09`09 `7B X`09`09 if (increase_insults(store_num)) X`09`09`09sell = 2; X`09`09 else X`09`09`09sell = 1; X`09`09 flag = TRUE; X`09`09 `7D X`09`09`7D X`09 else if (new_offer <= cur_ask) X`09`09`7B X`09`09 flag = TRUE; X`09`09 *price = new_offer; X`09`09`7D X`09 if (!flag) X`09`09`7B X`09`09 last_offer = new_offer; X`09`09 num_offer++; /* enable incremental haggling */ X`09`09 erase_line (1, 0); X`09`09 (void) sprintf(out_val, "Your last bid %ld", last_offer); X`09`09 put_buffer(out_val, 1, 39); X`09`09 prt_comment3(cur_ask, last_offer, final_flag); X X`09`09 /* If the current decrement would take you under the store's X`09`09 price, then increase it to an exact match. */ X`09`09 if (cur_ask - last_offer > last_store_inc) X`09`09 last_store_inc = cur_ask - last_offer; X`09`09`7D X`09 `7D X`09`7D X while (!flag); X `7D X X /* update bargaining info */ X if ((sell == 0) && (!didnt_haggle)) X updatebargain(store_num, *price, final_ask); X X return(sell); X`7D X X X/* Buy an item from a store`09`09`09`09-RAK-`09*/ Xstatic int store_purchase(store_num, cur_top) Xint store_num; Xint *cur_top; X`7B X int32 price; X register int i, choice; X bigvtype out_val, tmp_str; X register store_type *s_ptr; X inven_type sell_obj; X register inven_record *r_ptr; X int item_val, item_new, purchase; X X purchase = FALSE; X s_ptr = &store`5Bstore_num`5D; X /* i == number of objects shown on screen`09*/ X if (*cur_top == 12) X i = s_ptr->store_ctr - 1 - 12; X else if (s_ptr->store_ctr > 11) X i = 11; X else X i = s_ptr->store_ctr - 1; X if (s_ptr->store_ctr < 1) X msg_print("I am currently out of stock."); X /* Get the item number to be bought`09`09*/ X else if (get_store_item(&item_val, X`09`09`09 "Which item are you interested in? ", 0, i)) X `7B X item_val = item_val + *cur_top;`09/* TRUE item_val`09*/ X take_one_item(&sell_obj, &s_ptr->store_inven`5Bitem_val`5D.sitem); X if (inven_check_num(&sell_obj)) X`09`7B X`09 if (s_ptr->store_inven`5Bitem_val`5D.scost > 0) X`09 `7B X`09 price = s_ptr->store_inven`5Bitem_val`5D.scost; X`09 choice = 0; X`09 `7D X`09 else X`09 choice = purchase_haggle(store_num, &price, &sell_obj); X`09 if (choice == 0) X`09 `7B X`09 if (py.misc.au >= price) X`09`09`7B X`09`09 prt_comment1(); X`09`09 decrease_insults(store_num); X`09`09 py.misc.au -= price; X`09`09 item_new = inven_carry(&sell_obj); X`09`09 i = s_ptr->store_ctr; X`09`09 store_destroy(store_num, item_val, TRUE); X`09`09 objdes(tmp_str, &inventory`5Bitem_new`5D, TRUE); X`09`09 (void) sprintf(out_val, "You have %s (%c)", X`09`09`09`09 tmp_str, item_new+'a'); X`09`09 prt(out_val, 0, 0); X`09`09 check_strength(); X`09`09 if (*cur_top >= s_ptr->store_ctr) X`09`09 `7B X`09`09 *cur_top = 0; X`09`09 display_inventory(store_num, *cur_top); X`09`09 `7D X`09`09 else X`09`09 `7B X`09`09 r_ptr = &s_ptr->store_inven`5Bitem_val`5D; X`09`09 if (i == s_ptr->store_ctr) X`09`09`09`7B X`09`09`09 if (r_ptr->scost < 0) X`09`09`09 `7B X`09`09`09 r_ptr->scost = price; X`09`09`09 display_cost(store_num, item_val); X`09`09`09 `7D X`09`09`09`7D X`09`09 else X`09`09`09display_inventory(store_num, item_val); X`09`09 `7D X`09`09 store_prt_gold(); X`09`09`7D X`09 else X`09`09`7B X`09`09 if (increase_insults(store_num)) X`09`09 purchase = TRUE; X`09`09 else X`09`09 `7B X`09`09 prt_comment1(); X`09`09 msg_print("Liar! You have not the gold!"); X`09`09 `7D X`09`09`7D X`09 `7D X`09 else if (choice == 2) X`09 purchase = TRUE; X X`09 /* Less intuitive, but looks better here than in purchase_haggle. */ X`09 display_commands(); X`09 erase_line (1, 0); X`09`7D X else X`09prt("You cannot carry that many different items.", 0, 0); X `7D X return(purchase); X`7D X X X/* Sell an item to the store`09`09`09`09-RAK-`09*/ Xstatic int store_sell(store_num, cur_top) Xint store_num, *cur_top; X`7B X int item_val, item_pos; X int32 price; X bigvtype out_val, tmp_str; X inven_type sold_obj; X register int sell, choice, flag; X char mask`5BINVEN_WIELD`5D; X int counter, first_item, last_item; X X sell = FALSE; X first_item = inven_ctr; X last_item = -1; X for (counter = 0; counter < inven_ctr; counter++) X `7B X#ifdef MAC X flag = store_buy(store_num, (inventory`5Bcounter`5D.tval)); X#else X flag = (*store_buy`5Bstore_num`5D)(inventory`5Bcounter`5D.tval); X#endif X mask`5Bcounter`5D = flag; X if (flag) X`09`7B X`09 if (counter < first_item) X`09 first_item = counter; X`09 if (counter > last_item) X`09 last_item = counter; X`09`7D /* end of if (flag) */ X `7D /* end of for (counter) */ X if (last_item == -1) X msg_print("You have nothing to sell to this store!"); X else if (get_item(&item_val, "Which one? ", first_item, last_item, mask, X`09`09 "I do not buy such items.")) X `7B X take_one_item(&sold_obj, &inventory`5Bitem_val`5D); X objdes(tmp_str, &sold_obj, TRUE); X (void) sprintf(out_val, "Selling %s (%c)", tmp_str, item_val+'a'); X msg_print(out_val); X if (store_check_num(&sold_obj, store_num)) X`09`7B X`09 choice = sell_haggle(store_num, &price, &sold_obj); X`09 if (choice == 0) X`09 `7B X`09 prt_comment1(); X`09 decrease_insults(store_num); X`09 py.misc.au += price; X`09 /* identify object in inventory to set object_ident */ X`09 identify(&item_val); X`09 /* retake sold_obj so that it will be identified */ X`09 take_one_item(&sold_obj, &inventory`5Bitem_val`5D); X`09 /* call known2 for store item, so charges/pluses are known */ X`09 known2(&sold_obj); X`09 inven_destroy(item_val); X`09 objdes(tmp_str, &sold_obj, TRUE); X`09 (void) sprintf(out_val, "You've sold %s", tmp_str); X`09 msg_print(out_val); X`09 store_carry(store_num, &item_pos, &sold_obj); X`09 check_strength(); X`09 if (item_pos >= 0) X`09`09`7B X`09`09 if (item_pos < 12) X`09`09 if (*cur_top < 12) X`09`09 display_inventory(store_num, item_pos); X`09`09 else X`09`09 `7B X`09`09`09*cur_top = 0; X`09`09`09display_inventory(store_num, *cur_top); X`09`09 `7D X`09`09 else if (*cur_top > 11) X`09`09 display_inventory(store_num, item_pos); X`09`09 else X`09`09 `7B X`09`09 *cur_top = 12; X`09`09 display_inventory(store_num, *cur_top); X`09`09 `7D X`09`09`7D X`09 store_prt_gold(); X`09 `7D X`09 else if (choice == 2) X`09 sell = TRUE; X`09 else if (choice == 3) X`09 `7B X`09 msg_print("How dare you!"); X`09 msg_print("I will not buy that!"); X`09 sell = increase_insults(store_num); X`09 `7D X`09 /* Less intuitive, but looks better here than in sell_haggle. */ X`09 erase_line (1, 0); X`09 display_commands(); X`09`7D X else X`09msg_print("I have not the room in my store to keep it."); X `7D X return(sell); X`7D X X X/* Entering a store`09`09`09`09`09-RAK-`09*/ Xvoid enter_store(store_num) Xint store_num; X`7B X int cur_top, tmp_chr; X char command; X register int exit_flag; X register store_type *s_ptr; X X s_ptr = &store`5Bstore_num`5D; X if (s_ptr->store_open < turn) X `7B X exit_flag = FALSE; X cur_top = 0; X display_store(store_num, cur_top); X do X`09`7B X`09 move_cursor (20, 9); X`09 /* clear the msg flag just like we do in dungeon.c */ X`09 msg_flag = FALSE; X`09 if (get_com(CNIL, &command)) X`09 `7B X`09 switch(command) X`09`09`7B X`09`09case 'b': X`09`09 if (cur_top == 0) X`09`09 if (s_ptr->store_ctr > 12) X`09`09 `7B X`09`09`09cur_top = 12; X`09`09`09display_inventory(store_num, cur_top); X`09`09 `7D X`09`09 else X`09`09 msg_print("Entire inventory is shown."); X`09`09 else X`09`09 `7B X`09`09 cur_top = 0; X`09`09 display_inventory(store_num, cur_top); X`09`09 `7D X`09`09 break; X`09`09case 'E': case 'e':`09 /* Equipment List`09*/ X`09`09case 'I': case 'i':`09 /* Inventory`09`09*/ X`09`09case 'T': case 't':`09 /* Take off`09`09*/ X`09`09case 'W': case 'w':`09/* Wear`09`09`09*/ X`09`09case 'X': case 'x':`09/* Switch weapon`09`09*/ X`09`09 tmp_chr = py.stats.use_stat`5BA_CHR`5D; X`09`09 do X`09`09 `7B X`09`09 inven_command(command); X`09`09 command = doing_inven; X`09`09 `7D X`09`09 while (command); X`09`09 /* redisplay store prices if charisma changes */ X`09`09 if (tmp_chr != py.stats.use_stat`5BA_CHR`5D) X`09`09 display_inventory(store_num, cur_top); X`09`09 free_turn_flag = FALSE;`09/* No free moves here. -CJS- */ X`09`09 break; X`09`09case 'p': X`09`09 exit_flag = store_purchase(store_num, &cur_top); X`09`09 break; X`09`09case 's': X`09`09 exit_flag = store_sell(store_num, &cur_top); X`09`09 break; X`09`09default: X`09`09 bell(); X`09`09 break; X`09`09`7D X`09 `7D X`09 else X`09 exit_flag = TRUE; X`09`7D X while (!exit_flag); X /* Can't save and restore the screen because inven_command does that. V */ X draw_cave(); X `7D X else X msg_print("The doors are locked."); X`7D $ CALL UNPACK STORE2.C;1 1030582163 $ create 'f' X/* source/tables.c: store/attack/RNG/etc tables and variables X X Copyright (c) 1989-92 James E. Wilson, Robert A. Koeneke X X This software may be copied and distributed for educational, research, an Vd X not for profit purposes provided that this copyright and statement are X included in all such copies. */ X X#include "config.h" X#include "constant.h" X#include "types.h" X X#ifdef MORIA_HOU X/* Operating hours for Moria`09`09`09`09-RAK-`09*/ X/*`09 X = Open; . = Closed`09`09`09`09`09*/ Xchar days`5B7`5D`5B29`5D = `7B "SUN:XXXXXXXXXXXXXXXXXXXXXXXX", X`09`09 "MON:XXXXXXXX.........XXXXXXX", X`09`09 "TUE:XXXXXXXX.........XXXXXXX", X`09`09 "WED:XXXXXXXX.........XXXXXXX", X`09`09 "THU:XXXXXXXX.........XXXXXXX", X`09`09 "FRI:XXXXXXXX.........XXXXXXX", X`09`09 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX" `7D; X#endif X X#ifdef MAC Xstore_type *store; X#else Xstore_type store`5BMAX_STORES`5D; X#endif X X/* Store owners have different characteristics for pricing and haggling*/ X/* Note: Store owners should be added in groups, one for each store */ X#ifdef MACGAME Xowner_type *owners; X#else Xowner_type owners`5BMAX_OWNERS`5D = `7B X`7B"Erick the Honest (Human) General Store", X`09 250,`09175, 108, 4, 0, 12`7D, X`7B"Mauglin the Grumpy (Dwarf) Armory"`09 , X`0932000,`09200, 112, 4, 5, 5`7D, X`7B"Arndal Beast-Slayer (Half-Elf) Weaponsmith" , X`0910000,`09185, 110, 5, 1, 8`7D, X`7B"Hardblow the Humble (Human) Temple"`09 , X`09 3500,`09175, 109, 6, 0, 15`7D, X`7B"Ga-nat the Greedy (Gnome) Alchemist" , X`0912000,`09220, 115, 4, 4, 9`7D, X`7B"Valeria Starshine (Elf) Magic Shop" , X`0932000,`09175, 110, 5, 2, 11`7D, X`7B"Andy the Friendly (Halfling) General Store", X`09 200,`09170, 108, 5, 3, 15`7D, X`7B"Darg-Low the Grim (Human) Armory"`09 , X`0910000,`09190, 111, 4, 0, 9`7D, X`7B"Oglign Dragon-Slayer (Dwarf) Weaponsmith" , X`0932000,`09195, 112, 4, 5, 8`7D, X`7B"Gunnar the Paladin (Human) Temple"`09 , X`09 5000,`09185, 110, 5, 0, 23`7D, X`7B"Mauser the Chemist (Half-Elf) Alchemist" , X`0910000,`09190, 111, 5, 1, 8`7D, X`7B"Gopher the Great! (Gnome) Magic Shop" , X`0920000,`09215, 113, 6, 4, 10`7D, X`7B"Lyar-el the Comely (Elf) General Store", X`09 300,`09165, 107, 6, 2, 18`7D, X`7B"Mauglim the Horrible (Half-Orc) Armory"`09 , X`09 3000,`09200, 113, 5, 6, 9`7D, X`7B"Ithyl-Mak the Beastly (Half-Troll) Weaponsmith" , X`09 3000,`09210, 115, 6, 7, 8`7D, X`7B"Delilah the Pure (Half-Elf) Temple"`09 , X`0925000,`09180, 107, 6, 1, 20`7D, X`7B"Wizzle the Chaotic (Halfling) Alchemist" , X`0910000,`09190, 110, 6, 3, 8`7D, X`7B"Inglorian the Mage (Human?) Magic Shop" , X`0932000,`09200, 110, 7, 0, 10`7D X`7D; X#endif X X/* Buying and selling adjustments for character race VS store`09*/ X/* owner race`09`09`09`09`09`09`09 */ Xint8u rgold_adj`5BMAX_RACES`5D`5BMAX_RACES`5D = `7B X`09`09`09/* Hum, HfE,`09Elf, Hal, Gno, Dwa,`09HfO, HfT*/ X/*Human`09`09 */`09 `7B 100, 105,`09 105, 110, 113, 115,`09 120, 125` V7D, X/*Half-Elf`09 */`09 `7B 110, 100,`09 100, 105, 110, 120,`09 125, 130` V7D, X/*Elf`09`09 */`09 `7B 110, 105,`09 100, 105, 110, 120,`09 125, 130`7D V, X/*Halfling`09 */`09 `7B 115, 110,`09 105,`0995, 105, 110,`09 115, 130` V7D, X/*Gnome`09`09 */`09 `7B 115, 115,`09 110, 105, 95, 110,`09 115, 130` V7D, X/*Dwarf`09`09 */`09 `7B 115, 120,`09 120, 110, 110, 95,`09 125, 135` V7D, X/*Half-Orc`09 */`09 `7B 115, 120,`09 125, 115, 115, 130,`09 110, 115` V7D, +-+-+-+-+-+-+-+- END OF PART 69 +-+-+-+-+-+-+-+-