-+-+-+-+-+-+-+-+ START OF PART 15 -+-+-+-+-+-+-+-+ X`09`09`7B Secret door? `7D X`09`09`09else if (tval = Secret_door) then X`09`09`09 begin X`09`09`09 msg_print('You have found a secret door.'); X`09`09`09 fval := corr_floor2.ftval; X`09`09`09 change_trap(i1,i2); X`09`09`09 find_flag := false; X`09`09`09 end X`09`09`7B Chest is trapped? `7D X`09`09`09else if (tval = chest) then X`09`09`09 begin X`09`09`09 if (flags > 1) then X`09`09`09 if (index(name,'`5E') > 0) then X`09`09`09`09begin X`09`09`09`09 known2(name); X`09`09msg_print('You have discovered a trap on the chest!'); X`09`09`09`09end; X`09`09`09 end; X end; X X X`09`7B Turns off Find_flag if something interesting appears`09-RAK-`09`7D X`09`7B BUG: Does not handle corridor/room corners, but I didn't want `7D X`09`7B to add a lot of checking for such a minor detail `7D X `5Bglobal,psect(moria$code)`5D procedure area_affect(dir,y,x : integer); X var X`09`09z : array `5B1..3`5D of integer; X`09`09i1,row,col : integer; X begin X`09if (cave`5By,x`5D.fval = 4) then X`09 begin X`09 i1 := 0; X`09 if (next_to4(y,x,`5B4,5,6`5D) > 2) then X`09 find_flag := false; X`09 end; X`09if ((find_flag) and (py.flags.blind < 1)) then X`09 begin X`09 case dir of X`09 1,3,7,9 : begin X`09`09`09 z`5B1`5D := rotate_dir(dir,-1); X`09`09`09 z`5B2`5D := dir; X`09`09`09 z`5B3`5D := rotate_dir(dir,1); X`09`09`09end; X`09 2,4,6,8 : begin X`09`09`09 z`5B1`5D := rotate_dir(dir,-2); X`09`09`09 z`5B2`5D := dir; X`09`09`09 z`5B3`5D := rotate_dir(dir,2); X`09`09`09end; X`09 end; X`09 for i1 := 1 to 3 do X`09 begin X`09`09row := y; X`09`09col := x; X`09`09if (move(z`5Bi1`5D,row,col)) then X`09`09 with cave`5Brow,col`5D do X`09`09 begin X`09`09`09`7B Empty doorways `7D X`09`09 if (fval = 5) then X`09`09`09find_flag := false; X`09`09`09`7B Objects player can see`7D X`09`09`09`7B Including doors `7D X`09`09 if (find_flag) then X`09`09`09if (player_light) then X`09`09`09 begin X`09`09`09 if (tptr > 0) then X`09`09`09 if (not(t_list`5Btptr`5D.tval in `5BUnseen_trap,Secret_door`5 VD)) then X`09`09`09`09find_flag := false; X`09`09`09 end X`09`09`09else if ((tl) or (pl) or (fm)) then X`09`09`09 if (tptr > 0) then X`09`09`09 if (not(t_list`5Btptr`5D.tval in `5BUnseen_trap,Secret_door`5D) V) then X`09`09`09 find_flag := false; X`09`09`09`7B Creatures `7D X`09`09 if (find_flag) then X`09`09`09if ((tl) or (pl) or (player_light)) then X`09`09`09 if (cptr > 1) then X`09`09`09 with m_list`5Bcptr`5D do X`09`09`09 if (ml) then X`09`09`09`09find_flag := false; X`09`09 end X`09 end X`09 end; X end; X X X`09`7B Player is on an object. Many things can happen BASED -RAK-`09`7D X`09`7B on the TVAL of the object. Traps are set off, money and most `7D X`09`7B objects are picked up. Some objects, such as open doors, just`7D X`09`7B sit there... `7D X `5Bglobal,psect(moria$code)`5D procedure carry(y,x : integer); X var X`09item_ptr`09`09`09: treas_ptr; X`09out_val : vtype; X`09page_char`09`09`09: char; X`09inv_char`09`09`09: char; X`09tmp_ptr`09`09`09`09: treas_ptr; X`09count`09`09`09`09: integer; X`09money_flag`09`09`09: boolean; X X begin X`09money_flag := false; X`09find_flag := false; X`09with cave`5By,x`5D do X`09 begin X`09 inven_temp`5E.data := t_list`5Btptr`5D; X`09`09`7B There's GOLD in them thar hills! `7D X`09`09`7B OPPS! `7D X`09 if (t_list`5Btptr`5D.tval in trap_set) then X`09 hit_trap(y,x) X`09`09`7B Attempt to pick up an object. `7D X`09 else if (t_list`5Btptr`5D.tval <= valuable_metal) then X`09 begin X`09`09if (inven_check_num) then`09`7B Too many objects? `7D X`09`09 if (inven_check_weight) then `7B Weight limit check `7D X`09`09 begin`09`09`09`7B Okay, pick it up `7D X`09`09 pusht(tptr); X`09`09 tptr := 0; X`09`09 if (inven_temp`5E.data.tval = valuable_metal) then X`09`09`09begin X`09`09`09 item_ptr := money_carry; X`09`09`09 money_flag := true; X`09`09`09end X`09`09 else X`09`09`09item_ptr := inven_carry; X`09`09 prt_weight; X`09`09 objdes(out_val,item_ptr,true); X`09`09 if (money_flag) then X`09`09`09begin X`09`09`09 page_char := '$'; X`09`09`09 inv_char := '$'; X`09`09`09end X`09`09 else X`09`09 begin X`09`09`09count := 0; X`09`09`09tmp_ptr := inventory_list; X`09`09`09if (tmp_ptr`5E.next = item_ptr`5E.next) then X`09`09`09 count := 0 X`09`09`09else`09 X`09`09`09repeat X`09`09`09 count := count + 1; X`09`09`09 tmp_ptr := tmp_ptr`5E.next; X`09`09`09until (tmp_ptr`5E.next = item_ptr`5E.next); X`09`09`09if ((count div 20) > 9) then X`09`09`09 begin X`09`09`09 page_char := '*'; X`09`09`09 inv_char:= '*'; X`09`09 end X`09`09`09else`09 X`09`09`09begin`09 X`09`09`09 page_char := chr((count div 20)+49); X`09`09`09 inv_char := chr(count - (count div 20)*20 + 97); X`09`09`09end; X`09`09 end; X`09`09 out_val := 'You have ' + out_val+'. '+'('+page_char+inv_char+')' V; X`09`09 msg_print(out_val); X`09`09 end X`09`09 else X`09`09 msg_print('You can''t carry that much weight.') X`09`09else X`09`09 msg_print('You can''t carry that many items.'); X`09 end; X`09 end; X end; X X X`09`7B Package for moving the character's light about the screen `7D X`09`7B Three cases : Normal, Finding, and Blind -RAK- `7D X `5Bglobal,psect(moria$code)`5D procedure move_light(y1,x1,y2,x2 : intege Vr); X X`09`7B Given two sets of points, draw the block`09`09`7D X procedure draw_block(y1,x1,y2,x2 : integer); X var X`09i1,i2,xpos,xmax`09`09`09`09: integer; X`09topp,bott,left,righ`09`09`09: integer; X`09new_topp,new_bott,new_left,new_righ`09: integer; X`09floor_str,save_str`09`09`09: vtype; X`09tmp_char`09`09`09`09: char; X`09flag`09`09`09`09`09: boolean; X begin X`09`7B From uppermost to bottom most lines player was on... `7D X`09`7B Points are guaranteed to be on the screen (I hope...) `7D X`09topp := maxmin(y1,y2,panel_row_min); X`09bott := minmax(y1,y2,panel_row_max); X`09left := maxmin(x1,x2,panel_col_min); X`09righ := minmax(x1,x2,panel_col_max); X`09new_topp := y2 - 1; `7B Margins for new things to appear`7D X`09new_bott := y2 + 1; X`09new_left := x2 - 1; X`09new_righ := x2 + 1; X`09for i1 := topp to bott do X`09 begin X`09 floor_str := ''; `7B Null out print string `7D X`09 xpos := 0; X`09 save_str := ''; X`09 for i2 := left to righ do `7B Leftmost to rightmost do`7D X`09 begin X`09`09with cave`5Bi1,i2`5D do X`09`09 begin X`09`09 if ((pl) or (fm)) then X`09`09 flag := (((i1=y1) and (i2=x1)) or ((i1=y2) and (i2=x2))) X`09`09 else X`09`09 begin X`09`09`09flag := true; X`09`09`09if (((i1 >= new_topp) and (i1 <= new_bott)) and X`09`09`09 ((i2 >= new_left) and (i2 <= new_righ))) then X`09`09`09 begin X`09`09`09 if (tl) then X`09`09`09 if (fval in pwall_set) then X`09`09`09`09pl := true X`09`09`09 else if (tptr > 0) then X`09`09`09`09if (t_list`5Btptr`5D.tval in light_set) then X`09`09`09`09 if (not(fm)) then X`09`09`09`09 fm := true; X`09`09`09 end X`09`09 end; X`09`09 if ((pl) or (tl) or (fm)) then X`09`09 loc_symbol(i1,i2,tmp_char) X`09`09 else X`09`09 tmp_char := ' '; X`09`09 if (py.flags.image > 0) then X`09`09 if (randint(12) = 1) then X`09`09`09tmp_char := chr(randint(95) + 31); X`09`09 if (flag) then X`09`09 begin X`09`09`09if (xpos = 0) then xpos := i2; X`09`09`09xmax := i2; X`09`09 end; X`09`09 if (xpos > 0) then floor_str := floor_str + tmp_char; X`09`09 end; X`09 end; X`09 if (xpos > 0) then X`09 begin X`09`09i2 := i1; `7B Var for PRINT cannot be loop index`7D X`09`09print(substr(floor_str,1,1+xmax-xpos),i2,xpos); X`09 end; X`09 end; X end; X X X`09`7B Normal movement`09`09`09`09`09`7D X procedure sub1_move_light; X var X`09i1,i2 : integer; X begin X`09light_flag := true; X`09for i1 := y1-1 to y1+1 do `7B Turn off lamp light `7D X`09 for i2 := x1-1 to x1+1 do X`09 cave`5Bi1,i2`5D.tl := false; X`09for i1 := y2-1 to y2+1 do X`09 for i2 := x2-1 to x2+1 do X`09 cave`5Bi1,i2`5D.tl := true; X`09draw_block(y1,x1,y2,x2); `7B Redraw area `7D X end; X X`09`7B When FIND_FLAG, light only permanent features `09`7D X procedure sub2_move_light; X var X`09i1,i2,xpos : integer; X`09floor_str,save_str : vtype; X`09tmp_char : char; X`09flag : boolean; X begin X`09if (light_flag) then X`09 begin X`09 for i1 := y1-1 to y1+1 do X`09 for i2 := x1-1 to x1+1 do X`09`09cave`5Bi1,i2`5D.tl := false; X`09 draw_block(y1,x1,y1,x1); X`09 light_flag := false; X`09 end; X`09for i1 := y2-1 to y2+1 do X`09 begin X`09 floor_str := ''; X`09 save_str := ''; X`09 xpos := 0; X`09 for i2 := x2-1 to x2+1 do X`09 with cave`5Bi1,i2`5D do X`09`09begin X`09`09 flag := false; X`09`09 if (not((fm) or (pl))) then X`09`09 begin X`09`09 tmp_char := ' '; X`09`09 if (player_light) then X`09`09`09if (fval in pwall_set) then X`09`09`09 begin X`09`09`09 pl := true; `7B Turn on perm light `7D X`09`09`09 loc_symbol(i1,i2,tmp_char); X`09`09`09 flag := true; X`09`09`09 end X`09`09`09else X`09`09`09 if (tptr > 0) then X`09`09`09 if (t_list`5Btptr`5D.tval in light_set) then X`09`09`09 begin X`09`09`09`09fm := true; `7B Turn on field marker `7D X`09`09`09`09loc_symbol(i1,i2,tmp_char); X`09`09`09`09flag := true; X`09`09`09 end; X`09`09 end X`09`09 else X`09`09 loc_symbol(i1,i2,tmp_char); X`09`09 if (flag) then X`09`09 begin X`09`09 if (xpos = 0) then xpos := i2; X`09`09 if (length(save_str) > 0) then X`09`09`09begin X`09`09`09 floor_str := floor_str + save_str; X`09`09`09 save_str := ''; X`09`09`09end; X`09`09 floor_str := floor_str + tmp_char; X`09`09 end X`09`09 else if (xpos > 0) then X`09`09 save_str := save_str + tmp_char; X`09`09end; X`09 if (xpos > 0) then X`09 begin X`09`09i2 := i1; X`09`09print(floor_str,i2,xpos); X`09 end; X`09 end; X end; X X`09`7B When blinded, move only the player symbol...`09`09`7D X procedure sub3_move_light; X var X`09i1,i2 : integer; X begin X`09if (light_flag) then X`09 begin X`09 for i1 := y1-1 to y1+1 do X`09 for i2 := x1-1 to x1+1 do X`09`09cave`5Bi1,i2`5D.tl := false; X`09 light_flag := false; X`09 end; X`09print(' ',y1,x1); X`09print('@',y2,x2); X end; X X`09`7B With no light, movement becomes involved...`09`09`7D X procedure sub4_move_light; X var X`09i1,i2 : integer; X begin X`09light_flag := true; X`09if (cave`5By1,x1`5D.tl) then X`09 begin X`09 for i1 := y1-1 to y1+1 do X`09 for i2 := x1-1 to x1+1 do X`09`09begin X`09`09 cave`5Bi1,i2`5D.tl := false; X`09`09 if (test_light(i1,i2)) then X`09`09 lite_spot(i1,i2) X`09`09 else X`09`09 unlite_spot(i1,i2); X`09`09end; X`09 end X`09else if (test_light(y1,x1)) then X`09 lite_spot(y1,x1) X`09else X`09 unlite_spot(y1,x1); X`09print('@',y2,x2); X end; X X`09`7B Begin move_light procedure`09`09`09`09`7D X begin X if (py.flags.blind > 0) then X`09sub3_move_light X else if (find_flag) then X`09sub2_move_light X else if (not(player_light)) then X`09sub4_move_light X else X`09sub1_move_light; X end; X X X`09`7B Room is lit, make it appear`09`09`09`09-RAK-`09`7D X `5Bglobal,psect(moria$code)`5D procedure light_room(y,x : integer); X var X`09tmp1,tmp2 : integer; X`09start_row,start_col : integer; X`09end_row,end_col : integer; X`09i1,i2 : integer; X`09ypos,xpos : integer; X`09floor_str : vtype; X`09tmp_char : char; X X X procedure find_light(y1,x1,y2,x2 : integer); X var X`09i1,i2,i3,i4 : integer; X begin X`09for i1 := y1 to y2 do X`09 for i2 := x1 to x2 do X`09 if (cave`5Bi1,i2`5D.fval in `5B1,2,17`5D) then X`09 begin X`09`09for i3 := i1-1 to i1+1 do X`09`09 for i4 := i2-1 to i2+1 do X`09`09 cave`5Bi3,i4`5D.pl := true; X`09`09if (cave`5Bi1,i2`5D.fval = 17) then X`09`09 cave`5Bi1,i2`5D.fval := 18 X`09`09else X`09`09 cave`5Bi1,i2`5D.fval := 2; X`09 end; X end; X X begin X tmp1 := trunc(screen_height/2); X tmp2 := trunc(screen_width /2); X start_row := trunc(y/tmp1)*tmp1 + 1; X start_col := trunc(x/tmp2)*tmp2 + 1; X end_row := start_row + tmp1 - 1; X end_col := start_col + tmp2 - 1; X find_light(start_row,start_col,end_row,end_col); X for i1 := start_row to end_row do X`09begin X`09 floor_str := ''; X`09 ypos := i1; X`09 for i2 := start_col to end_col do X`09 with cave`5Bi1,i2`5D do X`09 begin X`09`09if ((pl) or (fm)) then X`09`09 begin X`09`09 if (length(floor_str) = 0) then X`09`09 xpos := i2; X`09`09 loc_symbol(i1,i2,tmp_char); X`09`09 floor_str := floor_str + tmp_char X`09`09 end X`09`09else X`09`09 if (length(floor_str) > 0) then X`09`09 begin X`09`09 print(floor_str,ypos,xpos); X`09`09 floor_str := '' X`09`09 end X`09 end; X`09 if (length(floor_str) > 0) then X`09 print(floor_str,ypos,xpos) X`09end; X end; X X X`09`7B Lights up given location`09`09`09`09-RAK-`09`7D X `5Bglobal,psect(moria$code)`5D procedure lite_spot(y,x : integer); X var X`09`09spot_char : vtype; X`09`09temp : char; X begin X`09if (panel_contains(y,x)) then X`09 begin X`09 loc_symbol(y,x,temp); X`09 spot_char := temp; X`09 print(spot_char,y,x) X`09 end X end; X X X`09`7B Blanks out given location`09`09`09`09-RAK-`09`7D X `5Bglobal,psect(moria$code)`5D procedure unlite_spot(y,x : integer); X begin X`09if (panel_contains(y,x)) then X`09 print(' ',y,x); X end; X X X`09`7B Picks new direction when in find mode `09`09-RAK-`09`7D +-+-+-+-+-+-+-+- END OF PART 15 +-+-+-+-+-+-+-+-