-+-+-+-+-+-+-+-+ START OF PART 37 -+-+-+-+-+-+-+-+ X`09 if (start = nil) then`09next_start := inventory_list X`09 else next_start := start; X`09 out_val := prompt; X`09 writev(out_val2,chr(count+96)); X`09 insert_str(out_val,'%N',out_val2); X`09 prt(out_val,1,1); X`09 display_inv := count; X`09end; X X X`09`7B Displays inventory items, returns chosen item if want_back.`20 X`09 boolean returns if chosen `7D X function show_inven(var ret_ptr : treas_ptr; X`09`09`09 want_back : boolean; X`09`09`09 clean_flag : boolean) : boolean; X`09var X`09`09command`09`09`09`09: char; X`09`09com_val,which,num_choices`09: integer; X`09`09exit_flag`09`09`09: boolean; X`09`09next_inven`09`09`09: treas_ptr; X`09`09temp_ptr`09`09`09: treas_ptr; X`09`09wgt`09`09`09`09: integer; X`09`09count, count2`09`09`09: integer; X`09`09caps_flag`09`09`09: boolean; X`09begin X`09 show_inven := false; X`09 exit_flag := false; X`09 num_choices := display_inv(cur_inven,next_inven); X`09 repeat X`09 if (get_com('',command)) then X`09 begin X`09`09com_val := ord(command); X`09 caps_flag := false; X`09`09case com_val of X`09`0922,32 : begin X`09`09`09if (cur_inven = next_inven) then X`09`09`09 begin X`09`09`09 prt('Entire inventory displayed.',1,1); X`09`09`09 num_choices := 0; X`09`09`09 end X`09`09`09else X`09`09`09 begin X`09`09`09 cur_inven := next_inven; X`09`09`09 num_choices := display_inv(cur_inven,next_inven); X`09`09`09 end; X`09`09 end; X 3,25,26,27 : begin X`09`09`09valid_flag := false; X`09`09`09exit_flag := true; X`09`09 end; X`0949,50,51,52,53,54,55,56,57: X`09`09begin X`09`09 cur_inven := inventory_list; X`09`09 count := 0; X`09`09 if (not ((cur_inven`5E.next=nil)or(count>=(com_val-49)*20))) then X`09`09 repeat X`09`09 count := count + 1; X`09`09 cur_inven := cur_inven`5E.next; X`09`09 if (cur_inven`5E.next = nil) then exit_flag := true X`09`09 until ((cur_inven`5E.next = nil)or(count>=(com_val-49)*20)); X`09`09 if ((cur_inven`5E.next = nil) and (count <> (com_val-49)*20)) then X`09`09 begin X`09`09 prt('Entire inventory displayed.',1,1); X`09`09 cur_inven := inventory_list; X`09`09 end X`09`09 else X`09`09 begin X`09`09 next_inven := cur_inven; X`09`09 num_choices := display_inv(cur_inven,next_inven); X`09`09 end; X`09`09 prt(': '+chr(com_val),1,75); X`09`09end; X`09`09 otherwise begin X`09`09`09if (want_back) then X`09`09`09 begin X`09`09`09 if (clean_flag) then X`09`09`09 begin X`09`09`09 if ((com_val <= ord('Z')) and (com_val >= ord('A'))) X`09`09`09 then caps_flag := true; X`09`09`09 if (caps_flag) then com_val := com_val - 64 X`09`09`09 else com_val := com_val - 96; X`09`09`09 end X`09`09`09 else X`09`09`09 com_val := com_val - 96; X`09`09`09 if ((com_val < 1) or (com_val > num_choices)) then X`09`09`09 begin X`09`09`09 prt('Invalid selection.',1,1); X`09`09`09 valid_flag := false; X`09`09`09 exit_flag := true; X`09`09`09 end X`09`09`09 else X`09`09`09 begin X`09`09`09`09if (clean_flag = true) then X`09`09`09`09 begin X`09`09`09`09`09ret_ptr := cur_display`5Bcom_val`5D; X`09`09`09`09`09 temp_ptr := ret_ptr`5E.next; X`09`09`09`09`09 wgt := 0; X`09`09 if (uand(ret_ptr`5E.data.flags2,holding_bit) <> 0) then X `09`09 begin X`09`09 while ((temp_ptr <> nil) and (temp_ptr`5E.is_in)) do X`09`09 begin X`09`09`09 wgt := wgt + temp_ptr`5E.data.weight * temp_ptr`5E.data.number; X`09`09`09 temp_ptr := temp_ptr`5E.next; X`09`09`09end; X`09`09 end; X`09`09`09 if ((ret_ptr`5E.is_in = false) and (wgt = 0)) then X`09`09`09`09 begin X`09`09`09`09 if ((caps_flag) and (not( ret_ptr`5E.data.tval in `5B10,11,1 V2`5D))) then X`09`09`09`09 count := ret_ptr`5E.data.number X`09`09`09`09 else X`09`09`09`09 count := 1; X`09`09`09`09 for count2 := 1 to count do X`09`09`09`09`09 inven_destroy (ret_ptr); X`09`09`09`09`09 clear_display; X`09`09`09`09`09 num_choices := display_inv (cur_inven, next_inven); X`09`09`09`09 end X`09`09`09 else X`09`09`09`09msg_print('You must empty the bag of holding first.'); X`09`09`09`09`09if (num_choices = 0) then`20 X`09`09`09`09`09 begin X`09`09`09`09`09 prt('No items in inventory.',1,1); X`09`09`09`09`09 valid_flag := false; X`09`09`09`09`09 exit_flag := true; X`09`09`09`09`09 end; X`09`09`09`09 end X`09`09`09`09else X`09`09`09`09 begin X`09`09`09`09`09ret_ptr := cur_display`5Bcom_val`5D; X`09`09`09`09`09cur_display`5Bcom_val`5D := nil; X`09`09`09`09 `09exit_flag := true; X`09`09`09`09 `09show_inven := true; X`09`09`09`09 end; X`09`09`09`09end; X`09`09`09 end X`09`09 else X`09`09`09begin X`09`09`09 valid_flag := false; X`09`09`09 exit_flag := true; X`09`09`09end; X`09`09 end; `7B otherwise `7D X`09`09end; `7B case `7D X`09 end `7B command `7D X`09 else X`09 begin X`09`09valid_flag := false; X`09`09exit_flag := true; X`09 end; X`09 until (exit_flag); X`09 scr_state := 1; X`09end; X X`09`7B Displays equipment items from r1 to end`09-RAK-`09`7D X procedure show_equip(r1 : integer); X`09var X`09 i1,i2 : integer; X`09 prt1,prt2,out_val : vtype; X`09begin X`09 if (r1 > equip_ctr) then `7B Last item gone `7D X`09 prt('',equip_ctr+3,1) X`09 else if (r1 > 0) then `7B R1 = 0 dummy call `7D X`09 begin X`09 i2 := 0; X`09 for i1 := equipment_min to equip_max-1 do `7B Range of equipment `7 VD X`09`09begin X`09`09 with equipment`5Bi1`5D do X`09`09 if (tval > 0) then X`09`09 begin X`09`09`09i2 := i2 + 1; X`09`09`09if (i2 >= r1) then`7B Display only given range `7D X`09`09`09 begin X`09case i1 of `7B Get position `7D X`09`09Equipment_primary`09: prt1 := ' You are wielding : '; X`09`09Equipment_helm`09`09: prt1 := ' Worn on head : '; X`09`09Equipment_amulet`09: prt1 := ' Worn around neck : '; X`09`09Equipment_armor`09`09: prt1 := ' Worn on body : '; X`09`09Equipment_belt`09`09: prt1 := ' Worn at waist : '; X`09`09Equipment_shield`09: prt1 := ' Worn on arm : '; X`09`09Equipment_gloves`09: prt1 := ' Worn on hands : '; X`09`09Equipment_bracers`09: prt1 := ' Worn on wrists : '; X`09`09Equipment_right_ring`09: prt1 := ' Worn on right hand : '; X`09`09Equipment_left_ring`09: prt1 := ' Worn on left hand : '; X`09`09Equipment_boots`09`09: prt1 := ' Worn on feet : '; X`09`09Equipment_cloak`09`09: prt1 := ' Worn about body : '; X`09`09Equipment_light`09`09: prt1 := ' Light source : '; X`09`09Equipment_secondary`09: prt1 := ' Secondary weapon : '; X`09`09otherwise`09`09 prt1 := ' Unknown value : '; X`09end; X`09`09`09 inven_temp`5E.data := equipment`5Bi1`5D; X`09`09`09 objdes(prt2,inven_temp,true); X`09`09`09 writev(out_val,cur_insure,chr(i2+96),cur_char2,prt1,prt2); X`09`09`09 prt(out_val,i2+2,1); X`09`09`09 end; X`09`09 end; X`09`09end; X`09 prt('',i2+3,1); `7B Clear last line `7D X`09 scr_state := 2; `7B Set state of screen `7D X`09 end; X`09end; X X`09`7B Remove item from equipment list`09`09-RAK-`09`7D X function remove(item_val : integer) : treas_ptr; X`09var X`09 i2,typ`09`09`09`09: integer; X`09 out_val,prt1,prt2 : vtype; X`09begin X`09 typ := equipment`5Bitem_val`5D.tval; X`09 inven_temp`5E.data := equipment`5Bitem_val`5D; X`09 add_inven_item(equipment`5Bitem_val`5D); X`09 inven_weight := inven_weight - inven_temp`5E.data.number * X`09`09`09`09`09 inven_temp`5E.data.weight; X`09 equipment`5Bitem_val`5D := blank_treasure; X`09 equip_ctr := equip_ctr - 1; X`09 case typ of X`09 sling_ammo,bolt,arrow,bow_crossbow_or_sling,hafted_weapon, X`09`09pole_arm,sword,dagger,maul,pick_or_shovel X`09`09`09: prt1 := 'Was wielding '; X`09 Lamp_or_Torch X`09`09`09: prt1 := 'Light source was '; X`09 otherwise X`09`09`09 prt1 := 'Was wearing '; X`09 end; X`09 objdes(prt2,inven_temp,true); X`09 out_val := prt1 + prt2; X`09 msg_print(out_val); X`09 if (item_val <> equip_max-1) then `7B For secondary weapon `7D X`09 py_bonuses(inven_temp`5E.data,-1); X`09 remove := inven_temp; X`09end; X X`09`7B Unwear routine, remove a piece of equipment`09-RAK-`09`7D X procedure unwear; X`09var X`09 i1,i2,com_val : integer; X`09 exit_flag,test_flag : boolean; X`09 command : char; X`09 out_val : vtype; X`09begin X`09 if (scr_state = 1) then X`09 begin X`09 clear(1,1); X`09 show_equip(1); X`09 end; X`09 exit_flag := false; X`09 repeat X`09 writev(out_val,'(a-',chr(equip_ctr+96),', *, for equipment lis Vt,', X`09`09' `5EZ to exit) ','Take off which one ?'); X`09 test_flag := false; X`09 msg_print(out_val); X`09 repeat X`09 inkey(command); X`09 com_val := ord(command); X`09 case com_val of X`09`090,3,25,26,27 : begin X`09`09`09`09 test_flag := true; X`09`09`09`09 exit_flag := true; X`09`09`09`09end; X`09`0942,32 : begin X`09`09`09`09 clear(2,1); X`09`09`09`09 show_equip(1); X`09`09`09`09end; X`09`09otherwise begin X`09`09`09`09 com_val := com_val - 96; X`09`09`09`09 if ((com_val >= 1) and X`09`09`09`09 (com_val <= equip_ctr)) then X`09`09`09`09 test_flag := true; X`09`09`09`09end; X`09 end; X`09 until (test_flag); X`09 if (not(exit_flag)) then X`09 begin X`09`09reset_flag := false; `7B Player turn `7D X`09`09i1 := 0; X`09`09i2 := equipment_min-1; X`09`09repeat X`09`09 i2 := i2 + 1; X`09`09 if (equipment`5Bi2`5D.tval > 0) then X`09`09 i1 := i1 + 1; X`09`09until (i1 = com_val); X`09`09if (uand(cursed_worn_bit,equipment`5Bi2`5D.flags) <> 0) then X`09`09 begin X`09`09 msg_print('Hmmm, it seems to be cursed...'); X`09`09 com_val := 0; X`09`09 end X`09`09else X`09`09 remove(i2); X`09 end; X`09 if (scr_state = 0) then X`09 exit_flag := true X`09 else if (equip_ctr = 0) then X`09 exit_flag := true X`09 else if (inven_ctr >= Equipment_min-1) then X`09 begin X`09`09show_equip(com_val); X`09`09exit_flag := true X`09 end X`09 else if (not(exit_flag)) then X`09 show_equip(com_val); X`09 until(exit_flag); X`09 if (scr_state <> 0) then X`09 if (equip_ctr = 0) then X`09 clear(1,1) X`09 else X`09 prt('You are currently using -',1,1); X`09end; X X`09`7B Wear routine, wear or wield an item`09`09-RAK-`09`7D X procedure wear; X`09var X`09 com_val,i1,i2,i3,i4,tmp : integer; X`09 out_val,prt1,prt2 : vtype; X`09 unwear_obj : treasure_type; X`09 exit_flag,test_flag,listed`09`09: boolean; X`09 count,factor`09`09`09`09: integer; X`09 ptr,item_ptr`09`09`09`09: treas_ptr; X X`09begin X`09 exit_flag := false; X`09 listed := false; X`09 cur_inven := inventory_list; X`09 repeat X`09 clear_display; X`09 change_all_ok_stats(true,false); X`09find_range(`5Blamp_or_torch,bow_crossbow_or_sling, X`09hafted_weapon,pole_arm,sword,dagger,maul,pick_or_shovel,boots, X`09gloves_and_gauntlets,cloak,helm,gem_helm,shield,hard_armor,soft_armor, X`09amulet,bracers,belt,ring,valuable_gems_wear`5D,false,ptr,count); X`09 item_ptr := inventory_list; X`09 test_flag := false; X`09 writev(prompt,'(Items a-%N, space for next page, `5EZ to exit) Wear/W Vield which one?'); X`09 clear(2,1); X`09 test_flag := show_inven(item_ptr,true,false); X `7B Somewhere among the pointers is a bug. ` V7D X`09`09`09`09`7B The above is a STUPID comment. `7D X`09 exit_flag := not test_flag; X`09 if (not(exit_flag)) then `7B Main logic for wearing `7D X`09 begin X`09`09reset_flag := false; `7B Player turn `7D X`09`09test_flag := true; X`09`09case item_ptr`5E.data.tval of `7B Slot for equipment `7D X`09`09 Lamp_or_Torch`09`09: i1 := Equipment_light; X`09`09 bow_crossbow_or_sling : i1 := Equipment_primary; X`09`09 hafted_weapon`09`09: i1 := Equipment_primary; X`09`09 pole_arm`09`09: i1 := Equipment_primary; X`09`09 sword`09`09`09: i1 := Equipment_primary; X`09`09 dagger`09`09: i1 := Equipment_primary; X`09`09 maul`09`09`09: i1 := Equipment_primary; X`09`09 pick_or_shovel`09: i1 := Equipment_primary; X`09`09 boots`09`09`09: i1 := Equipment_boots; X`09`09 gloves_and_gauntlets`09: i1 := Equipment_gloves; X`09`09 Cloak`09`09`09: i1 := Equipment_cloak; X`09`09 helm,gem_helm`09`09: i1 := Equipment_helm; X`09`09 shield`09`09: i1 := Equipment_shield; X`09`09 hard_armor`09`09: i1 := Equipment_armor; X`09`09 soft_armor`09`09: i1 := Equipment_armor; X`09`09 amulet`09`09: i1 := Equipment_amulet; X`09`09 bracers`09`09: i1 := Equipment_bracers; X`09`09 belt`09`09`09: i1 := Equipment_belt; X`09`09 ring`09: if (equipment`5BEquipment_right_ring`5D.tval = 0) then X`09`09`09 i1 := Equipment_right_ring X`09`09`09 else X`09`09`09 i1 := Equipment_left_ring; X`09`09 valuable_gems_wear : X`09`09 begin X`09`09 if (equipment`5Bequipment_helm`5D.tval = gem_helm) then X`09`09 with equipment`5Bequipment_helm`5D do X`09`09`09 begin X`09`09`09 if (p1 > 0) then X`09`09`09 begin X`09`09`09`09msg_print('The gem adheres itself to your helm!'); X`09`09`09`09py_bonuses(equipment`5Bequipment_helm`5D,-1); X`09`09`09`09if (uand(item_ptr`5E.data.flags2, X`09`09`09`09`09 negative_gem_bit) <> 0) then X`09`09`09`09 begin X`09`09`09`09 item_ptr`5E.data.flags2:= uand(%X'FF7FFFFF', X`09`09`09`09`09`09item_ptr`5E.data.flags2); X`09`09`09`09 flags := uxor(flags,item_ptr`5E.data.flags); X`09`09`09`09 flags2 := uxor(flags2,item_ptr`5E.data.flags2); X`09`09`09`09 factor := -1; X`09`09`09`09 end X`09`09`09`09else X`09`09`09`09 begin X`09`09`09`09 flags := uor(flags,item_ptr`5E.data.flags); X`09`09`09`09 flags2 := uor(flags2,item_ptr`5E.data.flags2); X`09`09`09`09 factor := 1; X`09`09`09`09 end; X`09`09`09`09cost := cost+factor*item_ptr`5E.data.cost; X`09`09`09`09weight := weight+factor*item_ptr`5E.data.weight; X`09`09`09`09tohit := tohit+factor*item_ptr`5E.data.tohit; X`09`09`09`09todam := todam+factor*item_ptr`5E.data.todam; X`09`09`09`09ac := ac+factor*item_ptr`5E.data.ac; X`09`09`09`09toac := toac+factor*item_ptr`5E.data.toac; X`09`09`09`09p1 := p1 - 1; X`09`09`09`09inven_destroy(item_ptr); +-+-+-+-+-+-+-+- END OF PART 37 +-+-+-+-+-+-+-+-