-+-+-+-+-+-+-+-+ START OF PART 39 -+-+-+-+-+-+-+-+ X if ((com_val >= 1) and X (com_val <= inven_ctr)) then X test_flag := true; X END; X END; X until (test_flag); X if (not(exit_flag)) then `7B Main logic for wearing `7D X BEGIN X reset_flag := false; `7B Player turn `7D X test_flag := true; X CASE inventory`5Bcom_val`5D.tval of `7B Slot for equipment ` V7D X 10 : i1 := 23; X 11 : i1 := 23; X 12 : i1 := 23; X 15 : i1 := 33; X 20 : i1 := 23; X 21 : i1 := 23; X 22 : i1 := 23; X 23 : i1 := 23; X 25 : i1 := 23; X 30 : i1 := 31; X 31 : i1 := 28; X 32 : i1 := 32; X 33 : i1 := 24; X 34 : i1 := 27; X 35 : i1 := 26; X 36 : i1 := 26; X 40 : i1 := 25; X 45 : if (inventory`5B29`5D.tval = 0) then `7B Rings `7D X i1 := 29 X else X i1 := 30; X otherwise X BEGIN X msg_print('I don''t see how you can use that.'); X test_flag := false; X com_val := 0; X END; X END; X if (test_flag) then X if (inventory`5Bi1`5D.tval > 0) then X BEGIN X if (uand(%X'80000000',inventory`5Bi1`5D.flags) <> 0) t Vhen X BEGIN X objdes(out_val,i1,false); X out_val := 'The ' + out_val + ' you are '; X CASE i1 of X 23 : out_val := out_val + 'wielding '; X otherwise out_val := out_val + 'wearing '; X END; X msg_print(out_val + 'appears to be cursed.'); X test_flag := false; X com_val := 0; X END X else if (inven_ctr > 21) then X if (inventory`5Bcom_val`5D.number > 1) then X if (inventory`5Bcom_val`5D.subval < 512) then X BEGIN X msg_print('You will have to drop something first.'); X test_flag := false; X com_val := 0; X END; X END; X if (test_flag) then X BEGIN X unwear_obj := inventory`5Bi1`5D; X inventory`5Bi1`5D := inventory`5Bcom_val`5D; X with inventory`5Bi1`5D do X`7B Fix for torches `7D BEGIN X if ((subval > 255) and (subval < 512)) then X BEGIN X number := 1; X subval := subval - 255; X END; X`7B Fix for weight `7D inven_weight := inven_weight + weight*number; X `7Bprt_cur_weight;`7D X END; X inven_destroy(com_val); `7B Subtracts weight `7D X equip_ctr := equip_ctr + 1; X py_bonuses(inventory`5Bi1`5D,1); X if (unwear_obj.tval > 0) then X BEGIN X inventory`5Binven_max`5D := unwear_obj; X tmp := remove(inven_max); X if (tmp < com_val) then X com_val := tmp; X END; X CASE i1 of X 23 : prt1 := 'You are wielding '; X 33 : prt1 := 'Your light source is '; X otherwise prt1 := 'You are wearing '; X END; X objdes(prt2,i1,true); X i2 := 0; X i3 := 22; X repeat `7B Get the right letter of equipment `7D X i3 := i3 + 1; X if (inventory`5Bi3`5D.tval > 0) then X i2 := i2 + 1; X until (i3 = i1); X out_val := prt1 + prt2 + ' (' + chr(i2+96)+cur_char2(i1) V; X msg_print(out_val); X END; X END; X if (scr_state = 0) then X exit_flag := true X else if (inven_ctr = 0) then X exit_flag := true X else if (not(exit_flag)) then X show_inven(com_val,inven_ctr); X until(exit_flag); X if (scr_state <> 0) then prt('You are currently carrying -',1,1); X END; X`20 X`7B Switch primary and secondary weapons `7D X procedure switch_weapon; X var X prt1,prt2 : vtype; X tmp_obj : treasure_type; X BEGIN X if (uand(%X'80000000',inventory`5B23`5D.flags) <> 0) then X BEGIN X objdes(prt1,23,false); X msg_print('The ' + prt1 + X ' you are wielding appears to be cursed.'); X END X else X BEGIN `7B Switch weapons `7D X reset_flag := false; X tmp_obj := inventory`5B34`5D; X inventory`5B34`5D := inventory`5B23`5D; X inventory`5B23`5D := tmp_obj; X py_bonuses(inventory`5B34`5D,-1); `7B Subtract bonuses `7D X py_bonuses(inventory`5B23`5D,1); `7B Add bonuses `7D X if (inventory`5B23`5D.tval > 0) then X BEGIN X prt1 := 'Primary weapon: '; X objdes(prt2,23,true); X msg_print(prt1 + prt2); X END; X if (inventory`5B34`5D.tval > 0) then X BEGIN X prt1 := 'Secondary weapon : '; X objdes(prt2,34,true); X msg_print(prt1 + prt2); X END; X END; X if (scr_state <> 0) then X BEGIN X msg_print(''); X clear(1,1); X prt('You are currently using -',1,1); X show_equip(1); X END; X END; X`20 X`7B Main logic for INVEN_COMMAND `7D X BEGIN X inven_command := false; X exit_flag := false; X scr_state := 0; X repeat X CASE command of X 'i' : BEGIN `7B Inventory `7D X if (inven_ctr = 0) then X msg_print('You are not carrying anything.') X else if (scr_state <> 1) then X BEGIN `7B Sets scr_state to 1 `7D X clear(1,1); X prt('You are currently carrying -',1,1); X show_inven(1,inven_ctr); X END; X END; X 'e' : BEGIN `7B Equipment `7D X if (equip_ctr = 0) then X msg_print('You are not using any equipment.') X else if (scr_state <> 2) then X BEGIN `7B Sets scr_state to 2 `7D X clear(1,1); X prt('You are currently using -',1,1); X show_equip(1); X END; X END; X 't' : BEGIN `7B Take off `7D X if (equip_ctr = 0) then X msg_print('You are not using any equipment.') X else if (inven_ctr > 21) then X msg_print('You will have to drop something first.') X else X unwear; `7B May set scr_state to 2 `7D X END; X 'w' : BEGIN `7B Wear/wield `7D X if (inven_ctr = 0) then X msg_print('You are not carrying anything.') X else X wear; `7B May set scr_state to 1 `7D X END; X 'x' : BEGIN X if (inventory`5B23`5D.tval <> 0) then X switch_weapon X else if (inventory`5B34`5D.tval <> 0) then X switch_weapon X else X msg_print('But you are wielding no weapons.'); X END; X`7B Special function for other routines `7D X '?' : BEGIN `7B Displays part inven, returns`7D X show_inven(r1,r2); X scr_state := 0; `7B Clear screen state `7D X END; X`7B Nonsense command `7D X otherwise ; X END; X if (scr_state > 0) then X BEGIN Xprt('quip, inven, ake-off, ear/wield, echange, `5EZ to exit.' V,24,2); X test_flag := false; X repeat X inkey(command); X com_val := ord(command); X CASE com_val of X 0,3,25,26,27,32 : BEGIN `7B Exit from module `7D X exit_flag := true; X test_flag := true; X END; X otherwise X CASE command of `7B Module commands `7D X 'e' : test_flag := true; X 'i' : test_flag := true; X 't' : test_flag := true; X 'w' : test_flag := true; X 'x' : test_flag := true; X '?' : ; `7B Trap special feature`7D X otherwise ; `7B Nonsense command `7D X END; X END; X until (test_flag); X prt('',24,1); `20 X END X else X exit_flag := true; X until(exit_flag); X if (scr_state > 0) then `7B If true, must redraw screen `7D X inven_command := true; X END; X`20 X`20 X`7B Get the ID of an item and return the CTR value of it `7D X function get_item( var com_val : integer; X pmt : vtype; X var redraw: boolean; X i1,i2 : integer) : boolean; X var X command: char; X out_val: vtype; X test_flag : boolean; X BEGIN X get_item := false; X com_val := 0; X if (inven_ctr > 0) then X BEGIN X writev(out_val,'(Items ',chr(i1+96),'-',chr(i2+96), X ', * for inventory list, `5EZ to exit) ',pmt); X test_flag := false; X prt(out_val,1,1); 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 reset_flag := true; X END; X 42 : BEGIN X clear(2,1); X inven_command('?',i1,i2); X redraw := true; X END; X otherwise BEGIN X com_val := com_val - 96; X if ((com_val >= i1) and X (com_val <= i2)) then X BEGIN X test_flag := true; X get_item := true; X END; X END; X END; X until (test_flag); X erase_line(msg_line,msg_line); X END X else X msg_print('You are not carrying anything.'); X END; `20 X`20 X`7B I may have written the town level code, but I'm not exactly X proud of it. Adding the stores required some real slucky X hooks which I have not had time to re-think. `7D X %INCLUDE 'MOR_INCLUDE:STORE2.INC' X`20 X`20 X`7B Calculates current boundries `7D X procedure panel_bounds; X BEGIN X panel_row_min := (trunc(panel_row*(screen_height/2)) + 1); X panel_row_max := panel_row_min + screen_height - 1; X panel_row_prt := panel_row_min - 2; X panel_col_min := (trunc(panel_col*(screen_width/2)) + 1); X panel_col_max := panel_col_min + screen_width - 1; X panel_col_prt := panel_col_min - 15; X END; X`20 X`20 X`7B Given an row (y) and col (x), this routine detects X when a move off the screen has occurred and figures new borders`7D X function get_panel(y,x : integer) : boolean; X var X prow,pcol : integer; X BEGIN X prow := panel_row; X pcol := panel_col; X if ((y < panel_row_min + 2) or (y > panel_row_max - 2)) then X BEGIN X prow := trunc((y - 2)/(screen_height/2)); X if (prow > max_panel_rows) then X prow := max_panel_rows; X END; X if ((x < panel_col_min + 3) or (x > panel_col_max - 3)) then X BEGIN X pcol := trunc((x - 3)/(screen_width/2)); X if (pcol > max_panel_cols) then X pcol := max_panel_cols; X END; X if ((prow <> panel_row) or (pcol <> panel_col) or not(cave_flag)) th Ven X BEGIN X panel_row := prow; X panel_col := pcol; X panel_bounds; X get_panel := true; X cave_flag := true; X END X else X get_panel := false; X END; X`20 X`20 X`7B Tests a given point to see if it is within the screen X boundries. `7D X function panel_contains(y,x : integer) : boolean; X BEGIN X if ((y >= panel_row_min) and (y <= panel_row_max)) then X if ((x >= panel_col_min) and (x <= panel_col_max)) then X panel_contains := true X else X panel_contains := false X else X panel_contains := false; X END; X`20 X`20 X`7B Returns true if player has no light `7D +-+-+-+-+-+-+-+- END OF PART 39 +-+-+-+-+-+-+-+-