-+-+-+-+-+-+-+-+ START OF PART 41 -+-+-+-+-+-+-+-+ X`09`09else if ((uand(cdefense,%X'0008') <> 0) and X`09`09`09 (uand(flags,%X'00010000') <> 0)) then X`09`09 tdam := tdam*3 X`09`09`7B Slay Monster `7D X`09`09else if ((uand(cdefense,%X'0002') <> 0) and X`09`09`09 (uand(flags,%X'00004000') <> 0)) then X`09`09 tdam := tdam*2 X`09`09`7B Slay Evil `7D X`09`09else if ((uand(cdefense,%X'0004') <> 0) and X`09`09`09 (uand(flags,%X'00008000') <> 0)) then X`09`09 tdam := tdam*2 X`09`09`7B Frost `7D X`09`09else if ((uand(cdefense,%X'0010') <> 0) and X`09`09`09 (uand(flags,%X'00020000') <> 0)) then X`09`09 tdam := trunc(tdam*1.5) X`09`09`7B Fire `7D X`09`09else if ((uand(cdefense,%X'0020') <> 0) and X`09`09`09 (uand(flags,%X'00040000') <> 0)) then X`09`09 tdam := trunc(tdam*1.5); X`09 end; X`09tot_dam := tdam; X end; X X X`09`7B Player attacks a (poor, defenseless) creature `09-RAK-`09`7D X function py_attack(y,x : integer) : boolean; X var X`09i1,i2,i3,blows,tot_tohit : integer; X`09m_name,out_val : vtype; X begin X`09py_attack := false; X`09i1 := cave`5By,x`5D.cptr; X`09i2 := m_list`5Bi1`5D.mptr; X`09m_list`5Bi1`5D.csleep := 0; X`09`09`7B Does the player know what he's fighting? `7D X`09if ((uand(%X'10000',c_list`5Bi2`5D.cmove) <> 0) and X`09 (not(py.flags.see_inv))) then X`09 m_name := 'it' X`09else if (py.flags.blind > 0) then X`09 m_name := 'it' X`09else if (not(m_list`5Bi1`5D.ml)) then X`09 m_name := 'it' X`09else X`09 m_name := 'the ' + c_list`5Bi2`5D.name; X`09if (inventory`5B23`5D.tval > 0) then `7B Proper weapon `7D X`09 blows := attack_blows(inventory`5B23`5D.weight,tot_tohit) X`09else `7B Bare hands? `7D X`09 begin X`09 blows := 2; X`09 tot_tohit := -3; X`09 end; X`09if (inventory`5B23`5D.tval in `5B10,11,12`5D) then `7B Fix for arrows`7D X`09 blows := 1; X`09tot_tohit := tot_tohit + py.misc.ptohit; X`09`7B Loop for number of blows, trying to hit the critter... `7D X`09with py.misc do X`09 repeat X`09 if (test_hit(bth,lev,tot_tohit,c_list`5Bi2`5D.ac)) then X`09 begin X`09`09writev(out_val,'You hit ',m_name,'.'); X`09`09msg_print(out_val); X`09`09with inventory`5B23`5D do X`09`09 begin X`09`09 if (tval > 0) then `7B Weapon? `7D X`09`09 begin X`09`09`09i3 := damroll(damage); X`09`09`09i3 := tot_dam(inventory`5B23`5D,i3,c_list`5Bi2`5D); X`09`09`09i3 := critical_blow(weight,tot_tohit,i3); X`09`09 end X`09`09 else `7B Bare hands!? `7D X`09`09 begin X`09`09`09i3 := damroll(bare_hands); X`09`09`09i3 := critical_blow(1,0,i3); X`09`09 end; X`09`09 end; X`09`09i3 := i3 + ptodam; X`09`09if (i3 < 0) then i3 := 0; X`09`7B See if we done it in... `7D X`09`09with m_list`5Bi1`5D do X`09`09 if (mon_take_hit(i1,i3) > 0) then X`09`09 begin X`09`09 writev(out_val,'You have slain ',m_name,'.'); X`09`09 msg_print(out_val); X`09`09 blows := 0; X`09`09 py_attack := false; X`09`09 end X`09`09 else X`09`09 py_attack := true; `7B If creature hit, but alive...`7D X`09`09 with inventory`5B23`5D do X`09`09 if (tval in `5B10,11,12`5D) then `7B Use missles up`7D X`09`09 begin X`09`09`09number := number - 1; X`09`09`09if (number <= 0) then X`09`09`09 begin X`09`09`09 inven_weight := inven_weight - weight; X`09`09`09 equip_ctr := equip_ctr - 1; X`09`09`09 inventory`5Binven_max`5D := inventory`5B23`5D; X`09`09`09 inventory`5B23`5D := blank_treasure; X`09`09`09 py_bonuses(inventory`5Binven_max`5D,-1); X`09`09`09 end; X`09`09 end; X`09 end X`09 else X`09 begin X`09`09writev(out_val,'You miss ',m_name,'.'); X`09`09msg_print(out_val); X`09 end; X`09 blows := blows - 1; X`09 until (blows < 1); X end; X X X`09`7B Moves player from one space to another...`09`09-RAK-`09`7D X`09`7B Note: This rountine has been pre-declared; see that for argument`7D X procedure move_char; X var X`09`09test_row,test_col : integer; X`09`09panrow,pancol : integer; X`09`09i1,i2 : integer; X begin X`09test_row := char_row; X`09test_col := char_col; X`09if (py.flags.confused > 0) then `7B Confused? `7D X`09 if (randint(4) > 1) then `7B 75% random movement `7D X`09 if (dir <> 5) then `7B Never random if sitting`7D X`09 begin X`09`09dir := randint(9); X`09`09find_flag := false; X`09 end; X`09if (move(dir,test_row,test_col)) then `7B Legal move? `7D X`09 with cave`5Btest_row,test_col`5D do X`09 if (cptr < 2) then `7B No creature? `7D X`09 begin X`09`09if (fopen) then `7B Open floor spot `7D X`09`09 begin X`09`09`09`7B Move character record (-1) `7D X`09`09 move_rec(char_row,char_col,test_row,test_col); X`09`09`09`7B Check for new panel `7D X`09`09 if (get_panel(test_row,test_col)) then X`09`09 prt_map; X`09`09`09`7B Check to see if he should stop `7D X`09`09 if (find_flag) then X`09`09 area_affect(dir,test_row,test_col); X`09`09`09`7B Check to see if he notices something `7D X`09`09 if (py.flags.blind < 1) then X`09`09 if ((randint(py.misc.fos) = 1) or (search_flag)) then X`09`09`09search(test_row,test_col,py.misc.srh); X`09`09`09`7B An object is beneath him... `7D X`09`09 if (tptr > 0) then X`09`09 carry(test_row,test_col); X`09`09`09`7B Move the light source `7D X`09`09 move_light(char_row,char_col,test_row,test_col); X`09`09`09`7B A room of light should be lit... `7D X`09`09 if (fval = lopen_floor.ftval) then X`09`09 begin X`09`09`09if (py.flags.blind < 1) then X`09`09`09 if (not(pl)) then X`09`09`09 light_room(test_row,test_col); X`09`09 end X`09`09`09`7B In doorway of light-room? `7D X`09`09 else if (fval in `5B5,6`5D) then X`09`09 if (py.flags.blind < 1) then X`09`09`09begin X`09`09`09 for i1 := (test_row - 1) to (test_row + 1) do X`09`09`09 for i2 := (test_col - 1) to (test_col + 1) do X`09`09`09 if (in_bounds(i1,i2)) then X`09`09`09`09with cave`5Bi1,i2`5D do X`09`09`09`09 if (fval = lopen_floor.ftval) then X`09`09`09`09 if (not(pl)) then X`09`09`09`09 light_room(i1,i2); X`09`09`09end; X`09`09`09`7B Make final assignments of char co-ords`7D X`09`09 char_row := test_row; X`09`09 char_col := test_col; X`09`09 end X`09`09else `7BCan't move onto floor space`7D X`09`09`09`7B Try a new direction if in find mode `7D X`09`09 if (not(pick_dir(dir))) then X`09`09 begin X`09`09 if (find_flag) then X`09`09`09begin X`09`09`09 find_flag := false; X`09`09`09 move_char(5); X`09`09`09end X`09`09 else if (tptr > 0) then X`09`09`09begin X`09`09`09 reset_flag := true; X`09`09`09 if (t_list`5Btptr`5D.tval = 103) then X`09`09`09 msg_print('There is rubble blocking your way.') X`09`09`09 else if (t_list`5Btptr`5D.tval = 105) then X`09`09`09 msg_print('There is a closed door blocking your way.'); X`09`09`09end X`09`09 else X`09`09`09reset_flag := true; X`09`09 end X`09 end X`09 else `7B Attacking a creature! `7D X`09 begin X`09`09if (find_flag) then X`09`09 begin X`09`09 find_flag := false; X`09`09 move_light(char_row,char_col,char_row,char_col); X`09`09 end; X`09`09if (py.flags.afraid < 1) then `7B Coward? `7D X`09`09 py_attack(test_row,test_col) X`09`09else `7B Coward! `7D X`09`09 msg_print('You are too afraid!'); X`09 end X end; X X X`09`7B Chests have traps too...`09`09`09`09-RAK-`09`7D X`09`7B Note: Chest traps are based on the FLAGS value `7D X procedure chest_trap(y,x : integer); X var X`09i1,i2,i3 : integer; X begin X`09with t_list`5Bcave`5By,x`5D.tptr`5D do X`09 begin X`09 if (uand(%X'00000010',flags) <> 0) then X`09 begin X`09`09msg_print('A small needle has pricked you!'); X`09`09if (not py.flags.sustain_str) then X`09`09 begin X`09`09 py.stat.cstr := de_statp(py.stat.cstr); X`09`09 take_hit(damroll('1d4'),'a poison needle.'); X`09`09 print_stat := uor(%X'0001',print_stat); X`09`09 msg_print('You feel weakened!'); X`09`09 end X`09`09else X`09`09 msg_print('You are unaffected.'); X`09 end; X`09 if (uand(%X'00000020',flags) <> 0) then X`09 begin X`09`09msg_print('A small needle has pricked you!'); X`09`09take_hit(damroll('1d6'),'a poison needle.'); X`09`09py.flags.poisoned := py.flags.poisoned + 10 + randint(20); X`09 end; X`09 if (uand(%X'00000040',flags) <> 0) then X`09 begin X`09`09msg_print('A puff of yellow gas surrounds you!'); X`09`09if (py.flags.free_act) then X`09`09 msg_print('You are unaffected.') X`09`09else X`09`09 begin X`09`09 msg_print('You choke and pass out.'); X`09`09 py.flags.paralysis := 10 + randint(20); X`09`09 end; X`09 end; X`09 if (uand(%X'00000080',flags) <> 0) then X`09 begin X`09`09msg_print('There is a sudden explosion!'); X`09`09delete_object(y,x); X`09`09take_hit(damroll('5d8'),'an exploding chest.'); X`09 end; X`09 if (uand(%X'00000100',flags) <> 0) then X`09 begin X`09`09for i1 := 1 to 3 do X`09`09 begin X`09`09 i2 := y; X`09`09 i3 := x; X`09`09 summon_monster(i2,i3,false); X`09`09 end; X`09 end; X`09 end; X end; X X X`09`7B Opens a closed door or closed chest...`09`09-RAK-`09`7D X procedure openobject; X var X`09`09y,x,tmp : integer; X`09`09flag : boolean; X begin X`09y := char_row; X`09x := char_col; X`09if (get_dir('Which direction?',tmp,tmp,y,x)) then X`09 begin X`09 with cave`5By,x`5D do X`09 if (tptr > 0) then X`09`09`09`7B Closed door `7D X`09`09if (t_list`5Btptr`5D.tval = 105) then X`09`09 with t_list`5Btptr`5D do X`09`09 begin X`09`09 if (p1 > 0) then `7B It's locked... `7D X`09`09`09begin X`09`09`09 with py.misc do X`09`09`09 tmp := disarm + lev + 2*todis_adj + int_adj; X`09`09`09 if (py.flags.confused > 0) then X`09`09`09 msg_print('You are too confused to pick the lock.') X`09`09`09 else if ((tmp-p1) > randint(100)) then X`09`09`09 begin X`09`09`09 msg_print('You have picked the lock.'); X`09`09`09 py.misc.exp := py.misc.exp + 1; X`09`09`09 prt_experience; X`09`09`09 p1 := 0; X`09`09`09 end X`09`09`09 else X`09`09`09 msg_print('You failed to pick the lock.'); X`09`09`09end X`09`09 else if (p1 < 0) then `7B It's stuck `7D X`09`09`09msg_print('It appears to be stuck.'); X`09`09 if (p1 = 0) then X`09`09`09begin X`09`09`09 t_list`5Btptr`5D := door_list`5B1`5D; X`09`09`09 fopen := true; X`09`09`09 lite_spot(y,x); X`09`09`09end; X`09`09 end X`09`09`09`7B Open a closed chest... `7D X`09`09else if (t_list`5Btptr`5D.tval = 2) then X`09`09 begin X`09`09 with py.misc do X`09`09 tmp := disarm + lev + 2*todis_adj + int_adj; X`09`09 with t_list`5Btptr`5D do X`09`09 begin X`09`09`09flag := false; X`09`09`09if (uand(%X'00000001',flags) <> 0) then X`09`09`09 if (py.flags.confused > 0) then X`09`09`09 msg_print('You are too confused to pick the lock.') X`09`09`09 else if ((tmp-(2*level)) > randint(100)) then X`09`09`09 begin X`09`09`09 msg_print('You have picked the lock.'); X`09`09`09 flag := true; X`09`09`09 py.misc.exp := py.misc.exp + level; X`09`09`09 prt_experience; X`09`09`09 end X`09`09`09 else X`09`09`09 msg_print('You failed to pick the lock.') X`09`09`09else X`09`09`09 flag := true; X`09`09`09if (flag) then X`09`09`09 begin X`09`09`09 flags := uand(%X'FFFFFFFE',flags); X`09`09`09 tmp := index(name,' ('); X`09`09`09 if (tmp > 0) then X`09`09`09 name := substr(name,1,tmp-1); X`09`09`09 name := name + ' (Empty)'; X`09`09`09 known2(name); X`09`09`09 cost := 0; X`09`09`09 end; X`09`09`09flag := false; X`09`09`09`7B Was chest still trapped? (Snicker) `7D X`09`09`09if (uand(%X'00000001',flags) = 0) then X`09`09`09 begin X`09`09`09 chest_trap(y,x); X`09`09`09 if (tptr > 0) then X`09`09`09 flag := true X`09`09`09 end; X`09`09 end; X`09`09`09`7B Chest treasure is allocted as if a creature `7D X`09`09`09`7B had been killed... `7D X`09`09 if (flag) then X`09`09 begin X`09`09`09monster_death(y,x,t_list`5Btptr`5D.flags); X`09`09`09t_list`5Btptr`5D.flags := 0; X`09`09 end; X`09`09 end X`09`09else X`09`09 msg_print('I do not see anything you can open there.') X`09 else X`09`09msg_print('I do not see anything you can open there.') X`09 end; X end; X X X`09`7B Closes an open door...`09`09`09`09-RAK-`09`7D X procedure closeobject; X var X`09`09y,x,tmp : integer; X begin X`09y := char_row; X`09x := char_col; X`09if (get_dir('Which direction?',tmp,tmp,y,x)) then X`09 begin X`09 with cave`5By,x`5D do X`09 if (tptr > 0) then X`09`09if (t_list`5Btptr`5D.tval = 104) then X`09`09 if (cptr = 0) then X`09`09 if (t_list`5Btptr`5D.p1 = 0) then X`09`09 begin X`09`09`09t_list`5Btptr`5D := door_list`5B2`5D; X`09`09`09fopen := false; X`09`09`09lite_spot(y,x); X`09`09 end X`09`09 else X`09`09 msg_print('The door appears to be broken.') X`09`09 else X`09`09 msg_print('The ' + c_list`5Bm_list`5Bcptr`5D.mptr`5D.name + X`09`09`09`09' is in your way!') X`09`09else X`09`09 msg_print('I do not see anything you can close there.') X`09 else X`09`09msg_print('I do not see anything you can close there.') X`09 end; X end; X X X`09`7B Go up one level`09`09`09`09`09-RAK-`09`7D X procedure go_up; X begin X`09with cave`5Bchar_row,char_col`5D do X`09if (tptr > 0) then X`09 if (t_list`5Btptr`5D.tval = 107) then X`09 begin X`09 dun_level := dun_level - 1; X`09 moria_flag := true; X`09 msg_print('You enter a maze of up staircases.'); X`09 msg_print('You pass through a one-way door.'); X`09 end X`09 else X`09 msg_print('I see no up staircase here.') X`09else X`09 msg_print('I see no up staircase here.'); X end; X X X`09`7B Go down one level`09`09`09`09`09-RAK-`09`7D X procedure go_down; X begin X`09with cave`5Bchar_row,char_col`5D do X`09if (tptr > 0) then +-+-+-+-+-+-+-+- END OF PART 41 +-+-+-+-+-+-+-+-