-+-+-+-+-+-+-+-+ START OF PART 67 -+-+-+-+-+-+-+-+ X`09 i_ptr = &s_ptr->store_inven`5Bitem_val`5D.sitem; X`09 if (typ == i_ptr->tval) X`09 `7B X`09 if (subt == i_ptr->subval && /* Adds to other item`09*/ X`09`09 subt >= ITEM_SINGLE_STACK_MIN X`09`09 && (subt < ITEM_GROUP_MIN `7C`7C i_ptr->p1 == t_ptr->p1)) X`09`09`7B X`09`09 *ipos = item_val; X`09`09 i_ptr->number += item_num; X`09`09 /* must set new scost for group items, do this only for items X`09`09 strictly greater than group_min, not for torches, this X`09`09 must be recalculated for entire group */ X`09`09 if (subt > ITEM_GROUP_MIN) X`09`09 `7B X`09`09 (void) sell_price (store_num, &icost, &dummy, i_ptr); X`09`09 s_ptr->store_inven`5Bitem_val`5D.scost = -icost; X`09`09 `7D X`09`09 /* must let group objects (except torches) stack over 24 X`09`09 since there may be more than 24 in the group */ X`09`09 else if (i_ptr->number > 24) X`09`09 i_ptr->number = 24; X`09`09 flag = TRUE; X`09`09`7D X`09 `7D X`09 else if (typ > i_ptr->tval) X`09 `7B`09`09/* Insert into list`09`09*/ X`09 insert_store(store_num, item_val, icost, t_ptr); X`09 flag = TRUE; X`09 *ipos = item_val; X`09 `7D X`09 item_val++; X`09`7D X while ((item_val < s_ptr->store_ctr) && (!flag)); X if (!flag)`09/* Becomes last item in list`09*/ X`09`7B X`09 insert_store(store_num, (int)s_ptr->store_ctr, icost, t_ptr); X`09 *ipos = s_ptr->store_ctr - 1; X`09`7D X `7D X`7D X X/* Destroy an item in the stores inventory. Note that if`09*/ X/* "one_of" is false, an entire slot is destroyed`09-RAK-`09*/ Xvoid store_destroy(store_num, item_val, one_of) Xint store_num, item_val; Xint one_of; X`7B X register int j, number; X register store_type *s_ptr; X register inven_type *i_ptr; X X s_ptr = &store`5Bstore_num`5D; X i_ptr = &s_ptr->store_inven`5Bitem_val`5D.sitem; X X /* for single stackable objects, only destroy one half on average, X this will help ensure that general store and alchemist have X reasonable selection of objects */ X if ((i_ptr->subval >= ITEM_SINGLE_STACK_MIN) && X (i_ptr->subval <= ITEM_SINGLE_STACK_MAX)) X `7B X if (one_of) X`09number = 1; X else X`09number = randint((int)i_ptr->number); X `7D X else X number = i_ptr->number; X X if (number != i_ptr->number) X i_ptr->number -= number; X else X `7B X for (j = item_val; j < s_ptr->store_ctr-1; j++) X`09s_ptr->store_inven`5Bj`5D = s_ptr->store_inven`5Bj+1`5D; X invcopy(&s_ptr->store_inven`5Bs_ptr->store_ctr-1`5D.sitem, OBJ_NOTHING V); X s_ptr->store_inven`5Bs_ptr->store_ctr-1`5D.scost = 0; X s_ptr->store_ctr--; X `7D X`7D X X X/* Initializes the stores with owners`09`09`09-RAK-`09*/ Xvoid store_init() X`7B X register int i, j, k; X register store_type *s_ptr; X X i = MAX_OWNERS / MAX_STORES; X for (j = 0; j < MAX_STORES; j++) X `7B X s_ptr = &store`5Bj`5D; X s_ptr->owner = MAX_STORES*(randint(i)-1) + j; X s_ptr->insult_cur = 0; X s_ptr->store_open = 0; X s_ptr->store_ctr`09= 0; X s_ptr->good_buy = 0; X s_ptr->bad_buy = 0; X for (k = 0; k < STORE_INVEN_MAX; k++) X`09`7B X`09 invcopy(&s_ptr->store_inven`5Bk`5D.sitem, OBJ_NOTHING); X`09 s_ptr->store_inven`5Bk`5D.scost = 0; X`09`7D X `7D X`7D X X X/* Creates an item and inserts it into store's inven`09-RAK-`09*/ Xstatic void store_create(store_num) Xint store_num; X`7B X register int i, tries; X int cur_pos, dummy; X register store_type *s_ptr; X register inven_type *t_ptr; X X tries = 0; X cur_pos = popt(); X s_ptr = &store`5Bstore_num`5D; X do X `7B X i = store_choice`5Bstore_num`5D`5Brandint(STORE_CHOICES)-1`5D; X invcopy(&t_list`5Bcur_pos`5D, i); X magic_treasure(cur_pos, OBJ_TOWN_LEVEL); X t_ptr = &t_list`5Bcur_pos`5D; X if (store_check_num(t_ptr, store_num)) X`09`7B X`09 if ((t_ptr->cost > 0) &&`09/* Item must be good`09*/ X`09 (t_ptr->cost < owners`5Bs_ptr->owner`5D.max_cost)) X`09 `7B X`09 /* equivalent to calling ident_spell(), except will not X`09`09 change the object_ident array */ X`09 store_bought(t_ptr); X`09 store_carry(store_num, &dummy, t_ptr); X`09 tries = 10; X`09 `7D X`09`7D X tries++; X `7D X while (tries <= 3); X pusht((int8u)cur_pos); X`7D X X X/* Initialize and up-keep the store's inventory.`09`09-RAK-`09*/ Xvoid store_maint() X`7B X register int i, j; X register store_type *s_ptr; X X for (i = 0; i < MAX_STORES; i++) X `7B X s_ptr = &store`5Bi`5D; X s_ptr->insult_cur = 0; X if (s_ptr->store_ctr >= STORE_MIN_INVEN) X`09`7B X`09 j = randint(STORE_TURN_AROUND); X`09 if (s_ptr->store_ctr >= STORE_MAX_INVEN) X`09 j += 1 + s_ptr->store_ctr - STORE_MAX_INVEN; X`09 while (--j >= 0) X`09 store_destroy(i, randint((int)s_ptr->store_ctr)-1, FALSE); X`09`7D X X if (s_ptr->store_ctr <= STORE_MAX_INVEN) X`09`7B X`09 j = randint(STORE_TURN_AROUND); X`09 if (s_ptr->store_ctr < STORE_MIN_INVEN) X`09 j += STORE_MIN_INVEN - s_ptr->store_ctr; X`09 while (--j >= 0) X`09 store_create(i); X`09`7D X `7D X`7D X X/* eliminate need to bargain if player has haggled well in the past -DJB- V */ Xint noneedtobargain(store_num, minprice) Xint store_num; Xint32 minprice; X`7B X register int flagnoneed; X register store_type *s_ptr; X X s_ptr = &store`5Bstore_num`5D; X flagnoneed = ((s_ptr->good_buy == MAX_SHORT) X`09`09`7C`7C (s_ptr->good_buy > 3 * s_ptr->bad_buy + 5 + minprice/50)); X return (flagnoneed); X`7D X X X/* update the bargin info`09`09`09`09`09-DJB- */ Xvoid updatebargain(store_num, price, minprice) Xint store_num; Xint32 price, minprice; X`7B X register store_type *s_ptr; X X s_ptr = &store`5Bstore_num`5D; X if (minprice > 9) X if (price == minprice) X `7B X`09if (s_ptr->good_buy < MAX_SHORT) X`09 s_ptr->good_buy++; X `7D X else X `7B X`09if (s_ptr->bad_buy < MAX_SHORT) X`09 s_ptr->bad_buy++; X `7D X`7D $ CALL UNPACK STORE1.C;1 289080234 $ create 'f' X/* source/store2.c: store code, entering, command interpreter, buying, selli Vng 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#ifdef __TURBOC__ X#include`09 X#include`09 X#endif /* __TURBOC__ */ X`20 X#include "config.h" X#include "constant.h" X#include "types.h" X#include "externs.h" X X#ifdef USG X#ifndef ATARIST_MWC X#include X#endif X#else X#include X#endif X X#if defined(LINT_ARGS) Xstatic void prt_comment1(void); Xstatic void prt_comment2(int32, int32, int); Xstatic void prt_comment3(int32, int32, int); Xstatic void prt_comment4(void); Xstatic void prt_comment5(void); Xstatic void prt_comment6(void); Xstatic void display_commands(void); Xstatic void haggle_commands(int); Xstatic void display_inventory(int, int); Xstatic void display_cost(int, int); Xstatic void store_prt_gold(void); Xstatic void display_store(int, int); Xstatic int get_store_item(int *, char *, int, int); Xstatic int increase_insults(int); Xstatic void decrease_insults(int); Xstatic int haggle_insults(int); Xstatic int get_haggle(char *, int32 *, int); Xstatic int receive_offer(int, char *, int32 *, int32, int, int); Xstatic int purchase_haggle(int, int32 *, struct inven_type *); Xstatic int sell_haggle(int, int32 *, struct inven_type *); Xstatic int store_purchase(int, int *); Xstatic int store_sell(int, int *); X#endif X X#ifdef ATARIST_TC X/* Include this to get prototypes for standard library functions. */ X#include X#endif X Xlong atol(); X Xstatic char *comment1`5B14`5D = `7B X "Done!", "Accepted!", "Fine.", "Agreed!", "Ok.", "Taken!", X "You drive a hard bargain, but taken.", X "You'll force me bankrupt, but it's a deal.", "Sigh. I'll take it.", X "My poor sick children may starve, but done!", "Finally! I accept.", X "Robbed again.", "A pleasure to do business with you!", X "My spouse will skin me, but accepted." X `7D; X Xstatic char *comment2a`5B3`5D = `7B X "%A2 is my final offer; take it or leave it.", X "I'll give you no more than %A2.", X "My patience grows thin. %A2 is final." X `7D; X Xstatic char *comment2b`5B16`5D = `7B X "%A1 for such a fine item? HA! No less than %A2.", X "%A1 is an insult! Try %A2 gold pieces.", X "%A1?!? You would rob my poor starving children?", X "Why, I'll take no less than %A2 gold pieces.", X "Ha! No less than %A2 gold pieces.", X "Thou knave! No less than %A2 gold pieces.", X "%A1 is far too little, how about %A2?", X "I paid more than %A1 for it myself, try %A2.", X "%A1? Are you mad?!? How about %A2 gold pieces?", X "As scrap this would bring %A1. Try %A2 in gold.", X "May the fleas of 1000 orcs molest you. I want %A2.", X "My mother you can get for %A1, this costs %A2.", X "May your chickens grow lips. I want %A2 in gold!", X "Sell this for such a pittance? Give me %A2 gold.", X "May the Balrog find you tasty! %A2 gold pieces?", X "Your mother was a Troll! %A2 or I'll tell." X `7D; X Xstatic char *comment3a`5B3`5D = `7B X "I'll pay no more than %A1; take it or leave it.", X "You'll get no more than %A1 from me.", X "%A1 and that's final." X `7D; X Xstatic char *comment3b`5B15`5D = `7B X "%A2 for that piece of junk? No more than %A1.", X "For %A2 I could own ten of those. Try %A1.", X "%A2? NEVER! %A1 is more like it.", X "Let's be reasonable. How about %A1 gold pieces?", X "%A1 gold for that junk, no more.", X "%A1 gold pieces and be thankful for it!", X "%A1 gold pieces and not a copper more.", X "%A2 gold? HA! %A1 is more like it.", "Try about %A1 gold.", X "I wouldn't pay %A2 for your children, try %A1.", X "*CHOKE* For that!? Let's say %A1.", "How about %A1?", X "That looks war surplus! Say %A1 gold.", X "I'll buy it as scrap for %A1.", X "%A2 is too much, let us say %A1 gold." X `7D; X Xstatic char *comment4a`5B5`5D = `7B X "ENOUGH! You have abused me once too often!", X "THAT DOES IT! You shall waste my time no more!", X "This is getting nowhere. I'm going home!", X "BAH! No more shall you insult me!", X "Begone! I have had enough abuse for one day." X `7D; X Xstatic char *comment4b`5B5`5D = `7B X "Out of my place!", "out... Out... OUT!!!", "Come back tomorrow.", X "Leave my place. Begone!", "Come back when thou art richer." X `7D; X Xstatic char *comment5`5B10`5D = `7B X "You will have to do better than that!", "That's an insult!", X "Do you wish to do business or not?", "Hah! Try again.", X "Ridiculous!", "You've got to be kidding!", "You'd better be kidding!", X "You try my patience.", "I don't hear you.", X "Hmmm, nice weather we're having." X `7D; X Xstatic char *comment6`5B5`5D = `7B X "I must have heard you wrong.", "What was that?", X "I'm sorry, say that again.", "What did you say?", X "Sorry, what was that again?" X `7D; X X Xextern int16 last_store_inc; X X/* Comments vary.`09`09`09`09`09-RAK-`09*/ X/* Comment one : Finished haggling`09`09`09`09*/ Xstatic void prt_comment1() X`7B X msg_print(comment1`5Brandint(14)-1`5D); X`7D X X X/* %A1 is offer, %A2 is asking.`09`09*/ Xstatic void prt_comment2(offer, asking, final) Xint32 offer, asking; int final; X`7B X vtype comment; X X if (final > 0) X (void) strcpy(comment, comment2a`5Brandint(3)-1`5D); X else X (void) strcpy(comment, comment2b`5Brandint(16)-1`5D); X X insert_lnum(comment, "%A1", offer, FALSE); X insert_lnum(comment, "%A2", asking, FALSE); X msg_print(comment); X`7D X X Xstatic void prt_comment3(offer, asking, final) Xint32 offer, asking; int final; X`7B X vtype comment; X X if (final > 0) X (void) strcpy (comment, comment3a`5Brandint(3)-1`5D); X else X (void) strcpy (comment, comment3b`5Brandint(15)-1`5D); X X insert_lnum(comment, "%A1", offer, FALSE); X insert_lnum(comment, "%A2", asking, FALSE); X msg_print(comment); X`7D X X X/* Kick 'da bum out.`09`09`09`09`09-RAK-`09*/ Xstatic void prt_comment4() X`7B X register int tmp; X X tmp = randint(5) - 1; X msg_print(comment4a`5Btmp`5D); X msg_print(comment4b`5Btmp`5D); X`7D X X Xstatic void prt_comment5() X`7B X msg_print(comment5`5Brandint(10)-1`5D); X`7D X X Xstatic void prt_comment6() X`7B X msg_print (comment6`5Brandint(5)-1`5D); X`7D X X X/* Displays the set of commands`09`09`09`09-RAK-`09*/ Xstatic void display_commands() X`7B X prt("You may:", 20, 0); X prt(" p) Purchase an item. b) Browse store's inventory.", 21, 0) V; X prt(" s) Sell an item. i/e/t/w/x) Inventory/Equipment Lists. V", X 22, 0); X prt("ESC) Exit from Building. `5ER) Redraw the screen.", 23, 0); X`7D X X X/* Displays the set of commands`09`09`09`09-RAK-`09*/ Xstatic void haggle_commands(typ) Xint typ; X`7B X if (typ == -1) X prt("Specify an asking-price in gold pieces.", 21, 0); X else X prt("Specify an offer in gold pieces.", 21, 0); X prt("ESC) Quit Haggling.", 22, 0); X erase_line (23, 0);`09/* clear last line */ X`7D X X X/* Displays a store's inventory`09`09`09`09-RAK-`09*/ Xstatic void display_inventory(store_num, start) Xint store_num, start; X`7B X register store_type *s_ptr; X register inven_type *i_ptr; X register int i, j, stop; X bigvtype out_val1, out_val2; X int32 x; X X s_ptr = &store`5Bstore_num`5D; X i = (start % 12); X stop = ((start / 12) + 1) * 12; X if (stop > s_ptr->store_ctr)`09stop = s_ptr->store_ctr; X while (start < stop) X `7B X i_ptr = &s_ptr->store_inven`5Bstart`5D.sitem; X x = i_ptr->number; X if ((i_ptr->subval >= ITEM_SINGLE_STACK_MIN) X`09 && (i_ptr->subval <= ITEM_SINGLE_STACK_MAX)) X`09i_ptr->number = 1; X objdes(out_val1, i_ptr, TRUE); X i_ptr->number = x; X (void) sprintf(out_val2, "%c) %s", 'a'+i, out_val1); X prt(out_val2, i+5, 0); X x = s_ptr->store_inven`5Bstart`5D.scost; X if (x <= 0) X`09`7B X`09 int32 value = -x; X`09 value = value * chr_adj() / 100; X`09 if (value <= 0) X`09 value = 1; X`09 (void) sprintf(out_val2, "%9ld", value); X`09`7D X else +-+-+-+-+-+-+-+- END OF PART 67 +-+-+-+-+-+-+-+-