-+-+-+-+-+-+-+-+ START OF PART 84 -+-+-+-+-+-+-+-+ X`09`09 prt('',2,1); X`09`09 end X`09`09 else X`09`09 prt('You cannot carry that many different items.',1,1) X`09`09else X`09`09 prt('You can not carry that much weight.',1,1); X`09 end; X`09 end; X end; X X X`09`7B Sell an item to the store`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(store$code)`5D function store_sell( X`09`09store_num`09: integer; X`09`09cur_top`09`09: integer; X`09`09blitz`09`09: boolean) : boolean; X var X`09i1,count`09`09`09: integer; X`09item_ptr`09`09`09: treas_ptr; X`09item_pos,price`09`09`09: integer; X`09redraw`09`09`09`09: boolean; X`09out_val,foo`09`09`09: vtype; X begin X`09if (blitz) X`09 then foo := 'BLITZ-SELLING item? ' X`09 else foo := 'Which one? '; X`09store_sell := false; X`09with store`5Bstore_num`5D do X`09 begin X`09 redraw := false; X`09 if (not(find_range(store_buy`5Bstore_num`5D,false,item_ptr,count))) t Vhen X`09 msg_print('You have nothing the store wishes to buy.') X`7B`09 else if (get_item(item_ptr,'Which one? ',redraw,count,trash_char,f Valse)) then`7D X`09 else if (get_item(item_ptr,foo,redraw,count,trash_char,false)) then X`09 begin X`09`09if (redraw) then display_store(store_num,cur_top); X`09`09inven_temp`5E.data := item_ptr`5E.data; X`09`09with inven_temp`5E.data do X`09`09 if ((subval > 255) and (subval < 512)) then X`09`09 number := 1;`09`09`7BBut why????`7D X`09`09objdes(out_val,inven_temp,true); X`09`09out_val := 'Selling ' +out_val; X`09`09msg_print(out_val); X`09`09msg_print(' '); X`09`09if (inven_temp`5E.data.tval in store_buy`5Bstore_num`5D) then X`09`09 if (store_check_num(store_num)) then X`09`09 case sell_haggle(store_num,price,inven_temp`5E.data,blitz) of X`09`09 0 : begin X`09`09 prt_comment1; X`09`09`09 add_money(price*gold$value); X`09`09 inven_destroy(item_ptr); X`09`09 store_carry(store_num,item_pos); X`09`09`09 if (item_pos > 0) then X`09`09`09 if (item_pos < 13) then X`09`09`09 if (cur_top < 13) then X`09`09`09`09 display_inventory(store_num,item_pos) X`09`09`09 else X`09`09`09`09 display_inventory(store_num,cur_top) X`09`09`09 else if (cur_top > 12) then X`09`09`09 display_inventory(store_num,item_pos); X`09`09`09 store_prt_gold; X`09`09`09 end; X`09`09 2 : store_sell := true; X`09`09 3 : begin X`09`09`09 msg_print('How dare you!'); X`09`09`09 msg_print('I will not buy that!'); X`09`09`09 store_sell := increase_insults(store_num); X`09`09 end; X`09`09 otherwise ; X`09`09 end X`09`09 else X`09`09 prt('I have not the room in my store to keep it...',1,1) X`09`09else X`09`09 prt('I do not buy such items.',1,1); X`09 end X`09 else if (redraw) then X`09 display_store(store_num,cur_top); X`09 end; X end; X X X`09`7B Entering a store`09`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(store$code)`5D procedure enter_store(store_num : integer); X var X`09com_val,cur_top,tics`09`09: integer; X`09command`09`09`09`09: char; X`09exit_flag`09`09`09: boolean; X begin X`09tics := 1; X`09with store`5Bstore_num`5D do X`09 begin X`09 exit_flag := false; X`09 cur_top := 1; X`09 display_store(store_num,cur_top); X`09 repeat X`09 if (get_com('',command)) then X`09`09begin X`09`09 msg_flag := false; X`09`09 com_val := ord(command); X`09`09 case com_val of X`09`09 18 : display_store(store_num,cur_top); X`09`09 73`09 : begin`09`7B Selective Inventory`09`7D X`09`09`09`09if (inven_command('I',trash_ptr,'')) then X`09`09`09`09 display_store(store_num,cur_top); X`09`09`09 end; X`09`09 32 : begin X`09`09`09`09if (cur_top = 1) then X`09`09`09`09 if (store_ctr > 12) then X`09`09`09`09 begin X`09`09`09`09 cur_top := 13; X`09`09`09`09 display_inventory(store_num,cur_top); X`09`09`09`09 end X`09`09`09`09 else X`09`09`09`09 prt('Entire inventory is shown.',1,1) X`09`09`09`09else X`09`09`09`09 begin X`09`09`09`09 cur_top := 1; X`09`09`09`09 display_inventory(store_num,cur_top); X`09`09`09`09 end X`09`09`09 end; X`09`09 101 : begin`09`7B Equipment List`09`7D X`09`09`09`09if (inven_command('e',trash_ptr,'')) then X`09`09`09`09 display_store(store_num,cur_top); X`09`09`09 end; X`09`09 105 : begin`09`7B Inventory`09`09`7D X`09`09`09`09if (inven_command('i',trash_ptr,'')) then X`09`09`09`09 display_store(store_num,cur_top); X`09`09`09 end; X`09`09 116 : begin`09`7B Take off`09`09`7D X`09`09`09`09if (inven_command('t',trash_ptr,'')) then X`09`09`09`09 display_store(store_num,cur_top); X`09`09`09 end; X`09`09 119 : begin`09`7B Wear`09`09`09`7D X`09`09`09`09if (inven_command('w',trash_ptr,'')) then X`09`09`09`09 display_store(store_num,cur_top); X`09`09`09 end; X`09`09 120 : begin`09`7B Switch weapon`09`09`7D X`09`09`09`09if (inven_command('x',trash_ptr,'')) then X`09`09`09`09 display_store(store_num,cur_top); X`09`09`09 end; X`09`09 112 : exit_flag := store_purchase(store_num,cur_top,false); X`09`09 80`09 : exit_flag := store_purchase(store_num,cur_top,true); X`09`09 115 : exit_flag := store_sell(store_num,cur_top,false); X`09`09 83`09 : exit_flag := store_sell(store_num,cur_top,true); X`09`09 otherwise prt('Invalid Command.',1,1); X`09`09 end; X`09`09end X`09 else X`09`09exit_flag := true; X`09 adv_time(false); X`09 tics := tics + 1; X`09 check_kickout_time(tics,2); X`09 until(exit_flag); X`09 if moria_flag then X`09 begin X`09`09clear(1,1); X`09`09prt_stat_block X`09 end X`09 else X`09 draw_cave; X`09 end X end; X X`09`7B Returns the value for any given object`09`09-RAK-`09`7D X`5Bglobal,psect(store$code)`5D function item_value(item : treasure_type) : i Vnteger; X X function search_list(x1,x2 : integer) : integer; X`09var X`09 i1,i2`09`09: integer; X`09begin X`09 i1 := 0; X`09 i2 := 0; X`09 repeat X`09 i1 := i1 + 1; X`09 with object_list`5Bi1`5D do X`09 if ((tval = x1) and (subval = x2)) then X`09`09i2 := cost; X`09 until ((i1 = max_objects) or (i2 > 0)); X`09 search_list := i2 div gold$value; X`09end; X X begin X`09with item do X`09 begin X`09 item_value := cost div gold$value; X`09 if (tval in `5Bbow_crossbow_or_sling,hafted_weapon,pole_arm, X`09`09`09 sword,dagger,maul,boots,gloves_and_gauntlets,gem_helm, X`09`09`09 Cloak,helm,shield,hard_armor,soft_armor`5D) then X`09 begin`09`7B Weapons and armor`09`7D X`09`09if (index(name,'`5E') > 0) then X`09`09 item_value := search_list(tval,subval)*number X`09`09else if (tval in `5Bbow_crossbow_or_sling,hafted_weapon, X`09`09`09`09 pole_arm,sword,dagger,maul`5D) then X`09`09 begin X`09`09 if (tohit < 0) then X`09`09 item_value := 0 X`09`09 else if (todam < 0) then X`09`09 item_value := 0 X`09`09 else if (toac < 0) then X`09`09 item_value := 0 X`09`09 else X`09`09 item_value := (cost div gold$value +(tohit+todam+toac)*100)*numb Ver; X`09`09 end X`09`09else X`09`09 begin X`09`09 if (toac < 0) then X`09`09 item_value := 0 X`09`09 else X`09`09 item_value := (cost div gold$value +toac*100)*number; X`09`09 end; X`09 end X`09 else if (tval in `5Bsling_ammo,bolt,arrow,spike`5D) then X`09 begin`09`7B Ammo`09`09`09`7D X`09`09if (index(name,'`5E') > 0) then X`09`09 item_value := search_list(tval,1)*number X`09`09else X`09`09 begin X`09`09 if (tohit < 0) then X`09`09 item_value := 0 X`09`09 else if (todam < 0) then X`09`09 item_value := 0 X`09`09 else if (toac < 0) then X`09`09 item_value := 0 X`09`09 else X`09`09 item_value := (cost div gold$value +(tohit+todam+toac)*10)*numbe Vr; X`09`09 end; X`09 end X`09 else if (tval in `5Bscroll1,scroll2,potion1,potion2,food`5D) then X`09 begin`09`7B Potions, Scrolls, and Food`09`7D X`09`09if (index(name,'`7C') > 0) then X`09`09 case tval of X`09`09`09scroll1,scroll2`09: item_value := 20; X`09`09`09potion1,potion2`09: item_value := 20; X`09`09`09food`09`09: item_value := 1; X`09`09 otherwise ; X`09`09 end X`09 end X`09 else if (tval in `5Bamulet,ring`5D) then X`09 begin`09`7B Rings and amulets`09`7D X`09`09if (index(name,'`7C') > 0) then X`09`09 case tval of X`09`09`09amulet`09: item_value := 45; X`09`09`09ring`09: item_value := 45; X`09`09 otherwise ; X`09`09 end X`09`09else if (index(name,'`5E') > 0) then X`09`09 item_value := (cost div gold$value) * ord(cost > 0); X`09 end X`09 else if (tval in `5Bchime,horn`5D) then X`09 begin`09`7B Horns and Chimes`09`7D X`09`09if (index(name,'`7C') > 0) then X`09`09 case tval of X`09`09`09chime`09: item_value := 50; X`09`09`09horn`09: item_value := 80; X`09`09`09otherwise ; X`09`09 end X`09`09else if (index(name,'`5E') = 0) then X`09`09 begin X`09`09 item_value := (cost div gold$value) + trunc(cost/cost_adj/20.0)*p1 V; X`09`09 end; X`09 end X`09 else if (tval in `5Bstaff,rod,wand`5D) then X`09 begin`09`7B Wands rods, and staffs`7D X`09`09if (index(name,'`7C') > 0) then X`09`09 case tval of X`09`09`09staff`09: item_value := 70; X`09`09`09rod`09: item_value := 60; X`09`09`09wand`09: item_value := 50; X`09`09 otherwise ; X`09`09 end X`09`09else if (index(name,'`5E') = 0) then X`09`09 begin X`09`09 item_value := (cost div gold$value) + trunc(cost/cost_adj/20.0)*p1 V; X`09`09 end; X`09 end X`09 else if (tval in `5Bvaluable_jewelry,valuable_gems`5D) then X`09 begin `7BGems and jewelry of all types`7D X`09`09if (index(name,'`7C') > 0) then X`09`09 case tval of`20 X`09`09`09valuable_jewelry : item_value := 20; X`09`09`09valuable_gems`09 : item_value := 20; X`09`09 otherwise ; X`09`09end X`09`09else if (index(name,'`5E') = 0) then X`09`09 begin X`09`09`09item_value := (cost div gold$value); X`09`09 end; X `09end; X`09 end; X end; X X X`09`7B Asking price for an item`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(store$code)`5D function sell_price (snum `09: integer; X`09`09`09 var max_sell,min_sell `09: integer; X`09`09`09 item `09`09`09: treasure_type X`09`09`09`09`09) : integer; X var X`09i1`09`09`09: integer; X begin X`09with store`5Bsnum`5D do X`09 begin X`09 i1 := item_value(item); X`09 if (item.cost > 0) then X`09 begin X`09 i1 := i1 + X`09`09 trunc(i1*rgold_adj`5Bowners`5Bowner`5D.owner_race,py.misc.prace`5D) V; X`09 if (i1 < 1) then i1 := 1; X`09 max_sell := trunc(i1*(1+owners`5Bowner`5D.max_inflate)); X`09 min_sell := trunc(i1*(1+owners`5Bowner`5D.min_inflate)); X`09 if (min_sell > max_sell) then min_sell := max_sell; X`09 sell_price := i1; X`09 end X`09 else `7Bquack`7D X`09 begin X`09`09max_sell := 0; X`09`09min_sell := 0; X`09`09sell_price := 0; X`09 end; X`09 end; X end; X X X`09`7B Check to see if he will be carrying too many objects`09-RAK-`09`7D X`5Bglobal,psect(store$code)`5D function store_check_num(store_num : integer) V : boolean; X var X`09item_num,i1`09`09`09: integer; X`09flag`09`09`09`09: boolean; X begin X`09store_check_num := false; X`09with store`5Bstore_num`5D do X`09 if (store_ctr < store_inven_max) then X`09 store_check_num := true X`09 else if ((inven_temp`5E.data.subval > 255) and`20 X`09`09 (inven_temp`5E.data.subval < 512)) then X`09 for i1 := 1 to store_ctr do X`09 with store_inven`5Bi1`5D.sitem do X`09 if (tval = inven_temp`5E.data.tval) then X`09`09 if (subval = inven_temp`5E.data.subval) then X`09`09 store_check_num := true; X end; X X X`09`7B Add the item in INVEN_MAX to stores inventory.`09-RAK-`09`7D X`5Bglobal,psect(store$code)`5D procedure store_carry( store_num : integer V; X`09`09`09`09`09 var ipos `09: integer); X var X`09item_num,item_val`09`09: integer; X`09typ,subt,icost,dummy`09`09: integer; X`09flag`09`09`09`09: boolean; X X`09`7B Insert INVEN_MAX at given location`09`7D X procedure insert(store_num,pos,icost : integer); X var X`09`09i1`09: integer; X begin X`09 with store`5Bstore_num`5D do X`09 begin X`09 for i1 := store_ctr downto pos do X`09 store_inven`5Bi1+1`5D := store_inven`5Bi1`5D; X`09 store_inven`5Bpos`5D.sitem := inven_temp`5E.data; X`09 store_inven`5Bpos`5D.scost := -icost * gold$value; X`09 store_ctr := store_ctr + 1; X`09 end; X end; X X`09`7B Store_carry routine`09`09`09`7D X begin X`09ipos := 0; X`09identify(inven_temp`5E.data); X`09unquote(inven_temp`5E.data.name); X`09known1(inven_temp`5E.data.name); X`09known2(inven_temp`5E.data.name); X`09sell_price(store_num,icost,dummy,inven_temp`5E.data); X`09if (icost > 0) then X`09 begin X`09 with inven_temp`5E.data do X`09 with store`5Bstore_num`5D do X`09 begin X`09 item_val := 0; X`09 item_num := number; X`09 flag := false; X`09 typ := tval; X`09 subt := subval; X`09 repeat X`09 item_val := item_val + 1; X`09 with store_inven`5Bitem_val`5D.sitem do X`09`09 if (typ = tval) then X`09`09 begin X`09`09 if (subt = subval) then`7B Adds to other item`09`7D X`09`09 if (subt > 255) then X`09`09`09 begin X`09`09`09`09if (number < 24) then`20 X`09`09`09`09 number := number + item_num; X`09`09`09 flag := true; X`09`09`09 end X`09`09 end X`09`09 else if (typ > tval) then X`09`09 begin`09`09`7B Insert into list`09`09`7D X`09`09 insert(store_num,item_val,icost); X`09`09 flag := true; X`09`09`09 ipos := item_val; X`09`09 end; X`09 until ((item_val >= store_ctr) or (flag)); X`09 if (not(flag)) then`09`7B Becomes last item in list`09`7D X`09`09 begin X`09`09 insert(store_num,store_ctr+1,icost); X`09`09 ipos := store_ctr; X`09`09 end; X`09 end; X`09 end; X end; X X X X`09`7B Destroy an item in the stores inventory. Note that if`09`7D X`09`7B 'one_of' is false, an entire slot is destroyed`09-RAK-`09`7D X`5Bglobal,psect(store$code)`5D procedure store_destroy( X`09`09`09store_num,item_val `09: integer;`20 X`09`09`09one_of `09`09`09: boolean); X var X`09`09i2 `09: integer; X begin +-+-+-+-+-+-+-+- END OF PART 84 +-+-+-+-+-+-+-+-