-+-+-+-+-+-+-+-+ START OF PART 83 -+-+-+-+-+-+-+-+ X`09flag := false; X`09sell_haggle := 0; X`09price := 0; X`09final_flag := 0; X`09msg_flag := false; X`09with store`5Bstore_num`5D do X`09 begin X`09 cost := item_value(item); X`09 if (cost < 1) then X`09 begin X`09`09sell_haggle := 3; X`09`09flag := true; X`09 end X`09 else X`09 with owners`5Bowner`5D do X`09 begin X`09`09 cost := cost - trunc(cost*chr_adj) - X`09`09`09 trunc(cost*rgold_adj`5Bowner_race,py.misc.prace`5D); X`09`09 if (cost < 1) then cost := 1; X`09 max_sell := trunc(cost*(1+max_inflate)); X`09 max_buy := trunc(cost*(1-max_inflate)); X`09 min_buy := trunc(cost*(1-min_inflate)); X`09`09 if (min_buy < max_buy) then min_buy := max_buy; X`09 min_per := haggle_per; X`09 max_per := min_per*3.0; X`09`09 max_gold := max_cost; X`09 end; X`09 end; X`09if (blitz) then X`09 begin X`09 delta := (min_buy - max_buy); X`09 last_offer := min_buy - (delta div 7); X`09 with store`5Bstore_num`5D do Xprice := last_offer - ((insult_cur * delta) DIV owners`5Bowner`5D.insult_max V); X`09 comment := 'Need cash quick? I''ll pay you '; X`09 writev(out_val,comment,price:1); X`09 msg_print(out_val); X`09 msg_print(' '); X`09 end X`09else `7Bhaggling`7D X`09if (not(flag)) then X`09 begin X`09 haggle_commands(-1); X`09 if (max_buy > max_gold) then X`09 begin X`09`09final_flag:= 1; X`09`09comment := 'Final offer : '; X`09 cur_ask := max_gold; X`09`09final_ask := max_gold; Xmsg_print('I am sorry, but I have not the money to afford such a fine item.' V); Xmsg_print(' '); X`09 end X`09 else X`09 begin X`09`09cur_ask := max_buy; X`09 final_ask := min_buy; X`09`09if (final_ask > max_gold) then X`09`09 final_ask := max_gold; X`09 comment := 'Offer : '; X`09 end; X`09 min_offer := max_sell; X`09 last_offer := min_offer; X`09 if (cur_ask < 1) then cur_ask := 1; X`09 repeat X`09 repeat X`09 loop_flag := true; X`09 writev(out_val,comment,cur_ask:1); X`09 put_buffer(out_val,2,1); X`09 case receive_offer(store_num,'What price do you ask? ', X`09`09`09`09 new_offer,last_offer,-1) of X`09 1 : begin X`09`09 sell_haggle := 1; X`09`09 flag := true; X`09`09 end; X`09 2 : begin X`09`09 sell_haggle := 2; X`09`09 flag := true; X`09`09 end; X`09 otherwise if (new_offer < cur_ask) then X`09 begin X`09`09`09`09prt_comment6; X`09`09`09`09loop_flag := false; X`09`09`09 end X`09`09`09 else if (new_offer = cur_ask) then X`09`09`09 begin X`09`09`09 flag := true; X`09`09`09 price := new_offer; X`09`09`09 end; X`09 end; X`09 until ((flag) or (loop_flag)); X`09 if (not(flag)) then X`09 begin X`09`09 msg_flag := false; X`09 x1 := (last_offer - new_offer)/(last_offer - cur_ask); X`09 if (x1 < min_per) then X`09`09 begin X`09`09 flag := haggle_insults(store_num); X`09`09 if (flag) then sell_haggle := 2; X`09`09 end X`09 else X`09`09 begin X`09`09 if (x1 > max_per) then`20 X`09`09 begin X`09`09 x1 := x1*0.75; X`09`09 if (x1 < max_per) then x1 := max_per; X`09`09 end; X`09 x2 := (x1 + (randint(5) - 3)/100.0); X`09 x3 := trunc((new_offer-cur_ask)*x2) + 1; X`09`09 cur_ask := cur_ask + x3; X`09`09 if (cur_ask > final_ask) then X`09`09 begin X`09`09 cur_ask := final_ask; X`09`09 comment := 'Final Offer : '; X`09`09 final_flag := final_flag + 1; X`09`09 if (final_flag > 3) then X`09`09`09 begin X`09`09`09 if (increase_insults(store_num)) then X`09`09`09 sell_haggle := 2 X`09`09`09 else X`09`09`09 sell_haggle := 1; X`09`09`09 flag := true; X`09`09`09 end; X`09`09 end X`09`09 else if (new_offer <= cur_ask) then X`09`09`09begin X`09`09`09 flag := true; X`09`09`09 price := new_offer; X`09`09`09end; X X`09`09 if (not(flag)) then X`09`09 begin X`09 last_offer := new_offer; X`09`09 prt('',2,1); X`09 writev(out_val,'Your last bid : ',last_offer:1); X`09 put_buffer(out_val,2,40); X`09`09`09 prt_comment3(cur_ask,last_offer,final_flag); X`09`09 end; X`09 end; X`09 end; X`09 until (flag); X`09 prt('',2,1); X`09 display_commands; X`09 end; X end; X X`7B if not whole_days then actually turns... `7D X`5Bglobal,psect(store$code)`5D procedure spend_time (days_spent : integer; X`09`09place : vtype; whole_days : boolean); X X var X`09mornings,time_spent,turns_today : integer; X`09regen_percent : real; X`09new_screen : boolean; X X procedure reset_flag (VAR flag : integer); X begin X`09if flag > 1 then X`09 begin X`09 flag := flag - time_spent; X`09 if flag < 1 then X`09 flag := 1; X`09 end; X end; `7B reset_flag `7D X X begin X with py.misc.cur_age do X begin X`09turns_today := hour*400 + secs; X`09if (not whole_days) then X`09 begin X`09 time_spent := days_spent; X`09`09`09`09 `7Bif a 6:00 threshold is passed`7D X`09 new_screen := (turns_today + time_spent + 2400) div 4800 > X`09`09 (turns_today + 2400) div 4800; X`09 mornings := (turns_today + time_spent - 2400) div 9600 - X`09`09`09(turns_today - 2400) div 9600; X`09 days_spent := 0; X`09 end X`09else X`09 begin X`09 time_spent := day_length * days_spent - turns_today; X`09 new_screen := true; X`09 mornings := days_spent; X`09 end; X`09case days_spent of X`09 0 : begin X`09`09 secs := secs + time_spent; X`09`09 hour := hour + secs div 400; X`09`09 secs := secs mod 400; X`09`09 add_days(py.misc.cur_age,hour div 24); X`09`09 hour := hour mod 24; X`09`09end; X`09 1 : if (hour < 6) then X`09`09 begin X`09`09 msg_print('You spend the remainder of the night '+place); X`09`09 hour := 8; `7Bwhy get up before shops open?`7D X`09`09 secs := randint(400) - 1; X`09`09 time_spent := time_spent - day_length + 400*hour + secs; X`09`09 end X`09`09else`20 X`09`09 begin X`09`09 msg_print('You spend the night '+place); X`09`09 hour := 8; X`09`09 add_days(py.misc.cur_age,1); X`09`09 secs := randint(400) - 1; X`09`09 time_spent := time_spent + 400*hour + secs; X`09`09 end; X`09 7 : begin X`09`09msg_print('You spend the week in the inn.'); X`09`09add_days(py.misc.cur_age,7); X`09`09hour := 8 + randint(4); X`09`09secs := randint(400) - 1; X`09`09time_spent := time_spent + 400*hour + secs; X`09 end; X`09 3 : begin X`09`09msg_print('You spend three days in the inn.'); X`09`09add_days(py.misc.cur_age,28+randint(3)); X`09`09hour := 8 + randint(4); X`09`09secs := randint(400) - 1; X`09`09time_spent := time_spent + 400*hour + secs; X`09 end; X`09end; X`09put_qio; X`09turn := turn + time_spent; X`09turn_counter := turn_counter + quest_delay; X X`09if new_screen then X`09 sleep(1); X X`09with py.flags do X`09 begin X`09 while (poisoned > 0) and (time_spent > 0) do X`09 begin X`09`09poisoned`09:= poisoned`09- 1; X`09`09time_spent`09:= time_spent`09- 1; X`09`09case con_adj of X`09`09 -4`09: take_hit(4,'poison.'); X`09`09 -3,-2`09: take_hit(3,'poison.'); X`09`09 -1`09: take_hit(1,'poison.'); X`09`09 0`09: take_hit(1,'poison.'); X`09`09 1,2,3`09: if ((turn mod 2) = 0) then take_hit(1,'poison.'); X`09`09 4,5`09: if ((turn mod 3) = 0) then take_hit(1,'poison.'); X`09`09 6`09: if ((turn mod 4) = 0) then take_hit(1,'poison.'); X`09`09end;`09 X`09`09if (poisoned = 0) then X`09`09 begin X`09`09 status := uand(%X'FFFFFFDF',status); X`09`09 msg_print('You feel better.'); X`09`09 put_qio; X`09`09 end; X`09 end; X`09 reset_flag ( blind ) ; X`09 reset_flag ( confused ) ; X`09 reset_flag ( protection ) ; X`09 reset_flag ( fast ) ; X`09 reset_flag ( slow ) ; X`09 reset_flag ( afraid ) ; X`09 reset_flag ( image ) ; X`09 reset_flag ( protevil ) ; X`09 reset_flag ( invuln ) ; X`09 reset_flag ( hero ) ; X`09 reset_flag ( shero ) ; X`09 reset_flag ( blessed ) ; X`09 reset_flag ( resist_heat ) ; X`09 reset_flag ( resist_cold`09) ; X`09 reset_flag ( detect_inv ) ; X`09 reset_flag ( word_recall ) ; X`09 reset_flag ( tim_infra ) ; X`09 reset_flag ( resist_lght ) ; X`09 reset_flag ( free_time ) ; X`09 reset_flag ( ring_fire ) ; X`09 reset_flag ( protmon ) ; X`09 reset_flag ( hoarse ) ; X`09 reset_flag ( magic_prot ) ; X`09 reset_flag ( ring_ice ) ; X`09 reset_flag ( temp_stealth ) ; X`09 reset_flag ( resist_petri ) ; X`09 reset_flag ( blade_ring ) ; X`09 case days_spent of X`09 0,1 : begin X`09`09 food := food - time_spent; X`09`09 if (food <= player_food_alert) then X`09`09`09food := player_food_alert + 1; X`09`09 end; X`09 otherwise food := player_food_full - 1; X`09 end; X`09 confuse_monster := false; X`09 for i1 := 1 to mornings do X`09 store_maint; X`09 end; X X`09with py.misc do X`09 begin X`09 regen_percent := regen_amount*2*time_spent; X if regen_percent > 1.00 then regen_percent := 1.00; X`09 if (chp < mhp) then regenhp(regen_percent); X`09 if (chp > mhp) then chp := mhp; X`09 if (cmana < mana) then regenmana(regen_percent); X`09 if (cmana > mana) then cmana := mana; X`09 end; X`09if new_screen then X`09 begin X`09 moria_flag := true; X`09 msg_print(''); X`09 end; X end; X end; X X`09`7B Buy an item from a store`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(store$code)`5D function store_purchase( X`09`09`09store_num `09: integer; X`09`09`09var cur_top `09: integer; X`09`09`09blitz`09`09: boolean) : boolean; X var X`09i1,item_val,price,i3,to_bank,from_bank`09: integer; X`09choice`09`09`09`09`09: integer; X`09item_new`09`09`09`09: treas_ptr; X`09save_number`09`09`09`09: integer; X`09out_val,foo`09`09`09`09: vtype; X`09flag `09`09`09`09: boolean; X begin X`09store_purchase := false; X`09item_new := nil; X`09with store`5Bstore_num`5D do X`09 begin X`09 if (blitz) X`09 then foo := 'BLITZ-PURCHASE item? ' X`09 else foo := 'Purchase which item? '; X`09`09`7B i1 = number of objects shown on screen`09`7D X`09 if (cur_top = 13) then X`09 i1 := store_ctr - 12 X`09 else if (store_ctr > 12) then X`09 i1 := 12 X`09 else X`09 i1 := store_ctr; X`09 if (store_ctr < 1) then X`09 msg_print('I am currently out of stock.') X`09`09`7B Get the item number to be bought`09`09`7D X`09 else if (get_store_item(item_val, X`09`09`09`7B'Which item are you interested in? ',1,i1)) then`7D X`09`09`09foo,1,i1)) then X`09 begin X`09`09item_val := item_val + cur_top - 1;`09`7B true item_val`09`7D X`09`09inven_temp`5E.data := store_inven`5Bitem_val`5D.sitem; X`09`09with inven_temp`5E.data do X`09`09 if ((subval > 255) and (subval < 512)) then X`09`09 begin X`09`09 save_number := number; X`09`09 number := 1; X`09`09 end X`09`09 else X`09`09 save_number := 1; X`09`09if (inven_check_weight or (store_num = 7)) then X`09`09 if (inven_check_num or (store_num = 7)) then X`09`09 begin X`09`09 if (store_inven`5Bitem_val`5D.scost > 0) then X`09`09`09begin X`09`09`09 price := store_inven`5Bitem_val`5D.scost div gold$value; X`09`09`09 choice := 0; X`09`09`09end X`09`09 else X`09choice := purchase_haggle(store_num,price,inven_temp`5E.data,blitz); X`09`09 case choice of X`09`09`090 : with py.misc do X`09`09`09 begin X`09`09`09`09flag := false; X`09`09`09`09if (money`5Btotal$`5D >= price) then X`09`09`09`09 begin X`09`09`09`09 subtract_money(price*gold$value,true); X`09`09`09`09 flag := true; X`09`09`09`09 end X`09`09`09`09else X`09`09`09`09 begin X`09`09`09`09 to_bank := price - money`5Btotal$`5D; X`09`09`09`09 flag := send_page(to_bank); X`09`09`09`09 end; X`09`09`09`09if (flag) then begin X`09`09`09`09prt_comment1; X`09`09`09`09decrease_insults(store_num); X`09`09`09`09if (store_num = 7) X`09`09`09`09 then X`09`09`09`09 with store_inven`5Bitem_val`5D do X`09`09`09`09 begin X`09`09`09`09`09if (scost < 0) then scost := price * gold$value; X`09`09`09`09`09spend_time(sitem.p1,'at the Inn.',true); X`09`09`09`09`09if (sitem.subval=303) then X`09`09`09`09`09 begin X`09`09`09`09`09 spend_time(600,'eating.',false); X`09`09`09`09`09 msg_print('You eat a leisurely meal of buckwheat cakes an Vd bacon.'); X`09`09`09`09`09 py.flags.food := player_food_full; X`09`09`09`09`09 py.flags.status := uand(%X'FFFFFFFC',py.flags.status); X`09`09`09`09`09 msg_print(' '); X`09`09`09`09`09 end; X`09`09`09`09`09store_purchase := true; X`09`09`09`09 end X`09`09`09`09 else X`09`09`09`09 begin X`09`09`09`09 store_destroy(store_num,item_val,true); X`09`09`09`09 item_new := inven_carry; X`09`09`09`09 objdes(out_val,item_new,true); X`09`09`09`09 out_val := 'You have ' + out_val; X`09`09`09`09 msg_print(out_val); X`09`09`09`09 if (cur_top > store_ctr) then 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`09 else X`09`09`09`09 with store_inven`5Bitem_val`5D do X`09`09`09`09 if (save_number > 1) then X`09`09`09`09 begin X`09`09`09`09`09 if (scost < 0) then X`09`09`09`09`09 begin X`09`09`09`09 scost := price * gold$value; X`09`09`09`09`09 display_cost(store_num,item_val); X`09`09`09`09`09 end; X`09`09`09`09 end X`09`09`09`09 else X`09`09`09`09 display_inventory(store_num,item_val); X`09`09`09`09 store_prt_gold; X`09`09`09`09 end X`09`09`09`09 end X`09`09`09 else X`09`09`09`09 begin X`09`09`09`09 if (increase_insults(store_num)) then X`09`09`09`09 store_purchase := true X`09`09`09`09 else X`09`09`09`09 begin X`09`09`09`09`09prt_comment1; X`09`09`09`09`09msg_print('Liar! You have not the gold!'); X`09`09`09`09 end; X`09`09`09`09 end X`09`09`09 end; X`09`09`092 : store_purchase := true; X`09`09`09otherwise ; X`09`09 end; +-+-+-+-+-+-+-+- END OF PART 83 +-+-+-+-+-+-+-+-