-+-+-+-+-+-+-+-+ START OF PART 38 -+-+-+-+-+-+-+-+ X END; X if (uand(%X'00000100',tobj.flags) <> 0) then X py.misc.stl := py.misc.stl + 2*factor; X if (uand(%X'00001000',tobj.flags) <> 0) then X BEGIN X i1 := tobj.p1*factor; X change_speed(-i1); X END; X if (uand(%X'08000000',tobj.flags) <> 0) then X if (factor > 0) then X py.flags.blind := py.flags.blind + 1000; X if (uand(%X'10000000',tobj.flags) <> 0) then X if (factor > 0) then X py.flags.afraid := py.flags.afraid + 50; X if (uand(%X'40000000',tobj.flags) <> 0) then X py.flags.see_infra := py.flags.see_infra + (tobj.p1 * factor); X with py.misc do X BEGIN X old_dis_ac := dis_ac; X ptohit := tohit_adj; `7B Real To Hit `7D X ptodam := todam_adj; `7B Real To Dam `7D X ptoac:= toac_adj; `7B Real To AC `7D X pac := 0; `7B Real AC `7D X dis_th := ptohit; `7B Display To Hit `7D X dis_td := ptodam; `7B Display To Dam `7D X dis_ac := 0; `7B Display To AC `7D X dis_tac := ptoac; `7B Display AC `7D X for i1 := 23 to inven_max-2 do X with inventory`5Bi1`5D do X if (tval > 0) then X BEGIN X if (uand(%X'80000000',flags) = 0) then X BEGIN X pac := pac + ac; X dis_ac := dis_ac + ac; X END; X ptohit := ptohit + tohit; X ptodam := ptodam + todam; X ptoac := ptoac + toac; X if (index(name,'`5E') = 0) then X BEGIN X dis_th := dis_th + tohit; X dis_td := dis_td + todam; X dis_tac := dis_tac + toac; X END; X END; X dis_ac := dis_ac + dis_tac; X`20 X`7B Add in temporary spell increases `7D X with py.flags do X BEGIN X if (invuln > 0) then X BEGIN X pac := pac + 100; X dis_ac := dis_ac + 100; X END; X if (blessed > 0) then X BEGIN X pac := pac + 2; X dis_ac := dis_ac + 2; X END; X if (detect_inv > 0) then X see_inv := true; X END; X`20 X if (old_dis_ac <> dis_ac) then X print_stat := uor(%X'0040',print_stat); X`20 X item_flags := 0; X for i1 := 23 to inven_max-2 do X with inventory`5Bi1`5D do X item_flags := uor(item_flags,flags); X if (uand(%X'00000080',item_flags) <> 0) then X py.flags.slow_digest := true; X if (uand(%X'00000200',item_flags) <> 0) then X py.flags.aggravate := true; X if (uand(%X'00000400',item_flags) <> 0) then X py.flags.teleport := true; X if (uand(%X'00000800',item_flags) <> 0) then X py.flags.regenerate := true; X if (uand(%X'00080000',item_flags) <> 0) then X py.flags.fire_resist := true; X if (uand(%X'00100000',item_flags) <> 0) then X py.flags.acid_resist := true; X if (uand(%X'00200000',item_flags) <> 0) then X py.flags.cold_resist := true; X if (uand(%X'00800000',item_flags) <> 0) then X py.flags.free_act := true; X if (uand(%X'01000000',item_flags) <> 0) then X py.flags.see_inv := true; X if (uand(%X'02000000',item_flags) <> 0) then X py.flags.lght_resist := true; X if (uand(%X'04000000',item_flags) <> 0) then X py.flags.ffall := true; X`20 X for i1 := 23 to inven_max-2 do X with inventory`5Bi1`5D do X if (uand(%X'00400000',flags) <> 0) then X CASE p1 of X 1 : py.flags.sustain_str := true; X 2 : py.flags.sustain_int := true; X 3 : py.flags.sustain_wis := true; X 4 : py.flags.sustain_con := true; X 5 : py.flags.sustain_dex := true; X 6 : py.flags.sustain_chr := true; X otherwise ; X END; X`20 X with py.flags do X BEGIN X if (slow_digest) then X food_digested := food_digested - 1; X if (regenerate) then X food_digested := food_digested + 3; X END; X END; X END; X`20 X`20 X`7B Returns a '*' for cursed items, a ')' for normal ones X NOTE: '*' returned only if item has been identified.`7D X function cur_char1(item_val : integer) : char; X BEGIN X with inventory`5Bitem_val`5D do X if (uand(%X'80000000',flags) = 0) then X cur_char1 := ')' `7B Not cursed.`7D X else if (index(name,'`5E') > 0) then X cur_char1 := ')' `7B Cursed, but not identified `7D X else X cur_char1 := '*'; `7B Cursed and identified.`7D X END; X`20 X`20 X`7B Returns a '*' for cursed items, a ')' for normal ones `7D X function cur_char2(item_val : integer) : char; X BEGIN X with inventory`5Bitem_val`5D do X if (uand(%X'80000000',flags) = 0) then X cur_char2 := ')' `7B Not cursed.`7D X else X cur_char2 := '*'; `7B Cursed.`7D X END; X`20 X`20 X`7B Comprehensive function block to handle all inventory X and equipment routines. Five kinds of calls can take place. X Note that '?' is a special call for other routines to display X only a portion of the inventory, and take no other action. `7D X function inven_command(command : char; r1,r2 : integer) : boolean; X var X com_val,scr_state: integer; `20 X exit_flag,test_flag : boolean; X`20 X`20 X`7B Displays inventory items from r1 to r2 `7D X procedure show_inven(r1,r2 : integer); X var X i1 : integer; X tmp_val,out_val : vtype; X BEGIN X if (r1 > 0) then `7B R1 = 0 dummy call `7D X BEGIN X for i1 := r1 to r2 do `7B Print the items `7D X BEGIN X objdes(tmp_val,i1,true); X writev(out_val,chr(i1+96),cur_char1(i1),' ',tmp_val); X prt(out_val,i1+1,1); X END; X if (r2 < 22) then prt('',r2+2,1); `7B Clear line after `7D X scr_state := 1; `7B Set state to 1 `7D X END; X END; X`20 X`7B Displays equipment items from r1 to end `7D X procedure show_equip(r1 : integer); X var X i1,i2 : integer; X prt1,prt2,out_val : vtype; X BEGIN X if (r1 > equip_ctr) then `7B Last item gone `7D X prt('',equip_ctr+3,1) X else if (r1 > 0) then `7B R1 = 0 dummy call `7D X BEGIN X i2 := 0; X for i1 := 23 to inven_max-1 do`7B Range of equipment `7D X BEGIN X with inventory`5Bi1`5D do X if (tval > 0) then X BEGIN X i2 := i2 + 1; X if (i2 >= r1) then`7B Display only given range `7D X BEGIN X CASE i1 of `7B Get position `7D X 23 : prt1 := ' You are wielding : '; X 24 : prt1 := ' Worn on head : '; X 25 : prt1 := ' Worn around neck : '; X 26 : prt1 := ' Worn on body : '; X 27 : prt1 := ' Worn on arm : '; X 28 : prt1 := ' Worn on hands : '; X 29 : prt1 := ' Worn on right hand : '; X 30 : prt1 := ' Worn on left hand : '; X 31 : prt1 := ' Worn on feet : '; X 32 : prt1 := ' Worn about body : '; X 33 : prt1 := ' Light source : '; X 34 : prt1 := ' Secondary weapon : '; X otherwise prt1 := ' Unknown value: '; X END; X objdes(prt2,i1,true); X writev(out_val,chr(i2+96),cur_char2(i1), X prt1,prt2); X prt(out_val,i2+2,1); X END; X END; X END; X prt('',i2+3,1); `7B Clear last line `7D X scr_state := 2; `7B Set state of screen `7D X END; X END; X`20 X`7B Remove item from equipment list `7D X function remove(item_val : integer) : integer; X var X i1,i2,typ : integer; X out_val,prt1,prt2: vtype; X flag : boolean; `20 X BEGIN X i1 := 0; X flag := false; X typ := inventory`5Bitem_val`5D.tval; X repeat X i1 := i1 + 1; X with inventory`5Bi1`5D do X if (typ > tval) then X BEGIN X for i2 := inven_ctr downto i1 do X inventory`5Bi2+1`5D := inventory`5Bi2`5D; X inventory`5Bi1`5D := inventory`5Bitem_val`5D; X inven_ctr:= inven_ctr + 1; X equip_ctr:= equip_ctr - 1; X flag := true; X END; X until (flag); X CASE typ of X 10,11,12,20,21,22,23,25 : prt1 := 'Was wielding '; X 15 : prt1 := 'Light source was '; X otherwise prt1 := 'Was wearing '; X END; X objdes(prt2,i1,true); X out_val := prt1 + prt2 + ' (' + chr(i1+96) + ')'; X msg_print(out_val); X inventory`5Bitem_val`5D := blank_treasure; X if (item_val <> inven_max-1) then `7B For secondary weapon`7D X py_bonuses(inventory`5Bi1`5D,-1); X remove := i1; X END; X`20 X`7B Unwear routine, remove a piece of equipment `7D X procedure unwear; X var X i1,i2,com_val : integer; X exit_flag,test_flag : boolean; X command : char; X out_val : vtype; X BEGIN X if (scr_state = 1) then X BEGIN X clear(1,1); X show_equip(1); X END; X exit_flag := false; X repeat X writev(out_val,'(a-',chr(equip_ctr+96),', * for equipment list,' V, X ' `5EZ to exit) ','Take off which one ?'); X test_flag := false; X msg_print(out_val); X repeat X inkey(command); X com_val := ord(command); X CASE com_val of X 0,3,25,26,27 : BEGIN X test_flag := true; X exit_flag := true; X END; X 42 : BEGIN X clear(2,1); X show_equip(1); X END; X otherwise BEGIN X com_val := com_val - 96; X if ((com_val >= 1) and X (com_val <= equip_ctr)) then X test_flag := true; X END; X END; X until (test_flag); X if (not(exit_flag)) then X BEGIN X reset_flag := false; `7B Player turn `7D X i1 := 0; X i2 := 22; X repeat X i2 := i2 + 1; X if (inventory`5Bi2`5D.tval > 0) then X i1 := i1 + 1; X until (i1 = com_val); X if (uand(%X'80000000',inventory`5Bi2`5D.flags) <> 0) then X BEGIN X msg_print('Hmmm, it seems to be cursed...'); X com_val := 0; X END X else X remove(i2); X END; X if (scr_state = 0) then X exit_flag := true X else if (equip_ctr = 0) then X exit_flag := true X else if (inven_ctr > 21) then X exit_flag := true X else if (not(exit_flag)) then X show_equip(com_val); X until(exit_flag); X if (scr_state <> 0) then X if (equip_ctr = 0) then X clear(1,1) X else X prt('You are currently using -',1,1); X END; X`20 X`7B Wear routine, wear or wield an item `7D X procedure wear; X var X com_val,i1,i2,i3,tmp: integer; X out_val,prt1,prt2: vtype; X unwear_obj : treasure_type; X exit_flag,test_flag : boolean; X BEGIN X if (scr_state = 2) then X BEGIN X clear(1,1); X show_inven(1,inven_ctr); X END; X exit_flag := false; X repeat X writev(out_val,'(a-',chr(inven_ctr+96),', * for equipment list,' V, X ' `5EZ to exit) ','Wear/Wield which one ?'); X test_flag := false; X msg_print(out_val); X repeat X inkey(command); X com_val := ord(command); X CASE com_val of X 0,3,25,26,27 : BEGIN X test_flag := true; X exit_flag := true; X END; X 42 : BEGIN X clear(2,1); X show_inven(1,inven_ctr); X END; X otherwise BEGIN X com_val := com_val - 96; +-+-+-+-+-+-+-+- END OF PART 38 +-+-+-+-+-+-+-+-