-+-+-+-+-+-+-+-+ START OF PART 46 -+-+-+-+-+-+-+-+
X                  tdam := trunc(tdam*1.5);
X            END;
X        tot_dam := tdam;
X      END;
X`20
X`20
X`7B Player attacks a (poor, defenseless) creature `7D
X    function py_attack(y,x : integer) : boolean;
X      var
X        i1,i2,i3,i7,blows,tot_tohit  : integer;
X        m_name,out_val: vtype;
X      BEGIN
X        py_attack := false;
X        i1 := cave`5By,x`5D.cptr;
X        i2 := m_list`5Bi1`5D.mptr;
X        m_list`5Bi1`5D.csleep := 0;
X`7B Does the player know what he's fighting? `7D
X        if ((uand(%X'10000',c_list`5Bi2`5D.cmove) <> 0) and
X            (not(py.flags.see_inv))) then
X          m_name := 'it'
X        else if (py.flags.blind > 0) then
X          m_name := 'it'
X        else if (not(m_list`5Bi1`5D.ml)) then
X          m_name := 'it'
X        else
X          m_name := 'the ' + c_list`5Bi2`5D.name;
X        if (equipment`5B23`5D.tval > 0) then  `7B Proper weapon `7D
X          blows := attack_blows(equipment`5B23`5D.weight,tot_tohit)
X        else               `7B Bare hands? `7D
X          BEGIN
X            blows := 2;
X            tot_tohit := -3;
X          END;
X`7B Loop for number of blows, trying to hit the critter.`7D
X        with py.misc do
X          repeat
X            if (test_hit(bth,lev,ptohit,c_list`5Bi2`5D.ac)) then
X`09      if (randint(52-c_list`5Bi2`5D.intel) = 1) then
X                begin
X                  writev(out_val,'The ',m_name,' dodges your blow.');
X                  msg_print(out_val);
X                end
X`09      else `09     `20
X                BEGIN
X                  with equipment`5B23`5D do
X`09`09    BEGIN
X`7B Gun? `7D`09      if (tval in `5B19,20`5D) then
X`09`09        i3 := randint(weight div 10)
X`7B Weapon? `7D           else if (tval > 0) then
X                        BEGIN
X                          i3 := damroll(damage);
X                          i3 := tot_dam(equipment`5B23`5D,i3,c_list`5Bi2`5D)
V;
X                          i3 := critical_blow(weight,tot_tohit,i3);
X                        END
X`7B Bare hands!?`7D       else
X                        BEGIN
X                          i3 := damroll(bare_hands);
X                          i3 := critical_blow(1,0,i3);
X                        END;
X                    END;
X                  i3 := i3 + ptodam*dam_plus_adj;
X`09          i7 := randint(max_hit_desc);
X`09`09  if (wizard) then
X                    writev(out_val,
X                      'You inflicted the ',m_name,' with ',i3:1,' hps damage
V.')
X`09`09  else
X                    writev(out_val,'You ',hit_desc`5Bi7`5D,' ',m_name,'. ');
X                  msg_print(out_val);
X                  if (i3 < 0) then i3 := 0;
X`7B See if we done it in.`7D
X                  with m_list`5Bi1`5D do
X                    if (mon_take_hit(i1,i3) > 0) then
X                      BEGIN
X                        writev(out_val,'You have slain ',m_name,'. ');
X                        msg_print(out_val);
X                        blows := 0;
X                        py_attack := false;
X                      END
X                    else
X                      py_attack := true;  `7B If creature hit, but alive...`
V7D
X                END
X            else
X              BEGIN
X                writev(out_val,'You miss ',m_name,'. ');
X                msg_print(out_val);
X              END;
X            blows := blows - 1;
X          until (blows < 1);
X      END;
X`20
X`20
X`7B Moves player from one space to another.
X  Note: This rountine has been pre-declared; see that for argument`7D
X    procedure move_char;
X      var
X                test_row,test_col : integer;
X                panrow,pancol  : integer;
X                i1,i2 : integer;
X      BEGIN
X        test_row := char_row;
X        test_col := char_col;
X        if (py.flags.confused > 0) then   `7B Confused? `7D
X          if (randint(4) > 1) then  `7B 75% random movement `7D
X            if (dir <> 5) then   `7B Never random if sitting`7D
X              BEGIN
X                dir := randint(9);
X                find_flag := false;
X              END;
X        if (move(dir,test_row,test_col)) then   `7B Legal move? `7D
X          with cave`5Btest_row,test_col`5D do
X            if (cptr < 2) then   `7B No creature? `7D
X              BEGIN
X                if (fopen) then  `7B Open floor spot `7D
X                  BEGIN
X`7B Move character record (-1) `7D
X                    move_rec(char_row,char_col,test_row,test_col);
X`7B Check for new panel `7D
X                    if (get_panel(test_row,test_col)) then
X                      prt_map;
X`7B Check to see if he should stop `7D
X                    if (find_flag) then
X                      area_affect(dir,test_row,test_col);
X`7BCheck to see if he notices something`7D
X                    if (py.flags.blind < 1) then
X                      if ((randint(200) < xperc) or (search_flag)) then
X                        search(test_row,test_col,py.misc.srh);
X`7B An object is beneath him.`7D
X                    if (tptr > 0) then
X                      carry(test_row,test_col);
X`7B Move the light source `7D
X                    move_light(char_row,char_col,test_row,test_col);
X`7B A room of light should be lit.`7D
X                    if (fval = lopen_floor.ftval) then
X                      BEGIN
X                        if (py.flags.blind < 1) then
X                          if (not(pl)) then
X                            light_room(test_row,test_col);
X                      END
X`7B In doorway of light-room? `7D
X                    else if (fval in `5B5,6`5D) then
X                      if (py.flags.blind < 1) then
X                        BEGIN
X                          for i1 := (test_row - 1) to (test_row + 1) do
X                            for i2 := (test_col - 1) to (test_col + 1) do
X                              if (in_bounds(i1,i2)) then
X                                with cave`5Bi1,i2`5D do
X                                  if (fval = lopen_floor.ftval) then
X                                    if (not(pl)) then
X                                      light_room(i1,i2);
X                        END;
X`7B Make final assignments of char co-ords`7D
X                    char_row := test_row;
X                    char_col := test_col;
X                  END
X                else `7BCan't move onto floor space`7D
X`7B Try a new direction if in find mode `7D
X                  if (not(pick_dir(dir))) then
X                    BEGIN
X                      if (find_flag) then
X                        BEGIN
X                          find_flag := false;
X                          move_char(5);
X                        END
X                      else if (tptr > 0) then
X                        BEGIN
X                          reset_flag := true;
X                          if (t_list`5Btptr`5D.tval = 103) then
X                            msg_print('There is rubble blocking your way.')
X                          else if (t_list`5Btptr`5D.tval = 105) then
X                        msg_print('There is a closed door blocking your way.
V');
X                        END
X                      else
X                        reset_flag := true;
X                    END
X              END
X            else  `7B Attacking a creature! `7D
X              BEGIN
X                if (find_flag) then
X                  BEGIN
X                    find_flag := false;
X                    move_light(char_row,char_col,char_row,char_col);
X                  END;
X                if (py.flags.afraid < 1) then   `7B Coward? `7D
X                  py_attack(test_row,test_col)
X                else       `7B Coward! `7D
X                  msg_print('Help!  A Monster!!!!!');
X              END
X      END;
X
X
X`7B Move about in slower than normal motion - RLG `7D
Xprocedure stagger(num : integer);
Xbegin
X  move_char(num);
X  tiny_sleep(10);
Xend;
X
X
X`7BWrestler Berzerk`7D function  berzerk : boolean;
X `20
XVAR
X`09y,x,i3,i5,num_attacks`09: integer;
X`09tmp`09`09`09: boolean;
XBEGIN
X    berzerk := false;
X    if (py.flags.afraid > 0) then`20
X      msg_print('Your mind is too full of fear!')
X    else if (py.flags.special > 0) then
X      msg_print('You are too fatigued from your last fury!')
X    else
X      Begin
X        tmp := false;
X        num_attacks := (py.misc.lev + 2) div 3;
X        for i3 := 1 to num_attacks do
X          for i5 := 1 to 8 do
X`09      begin           `20
X  `09        y := char_row + berz_y`5Bi5`5D;
X`09        x := char_col + berz_x`5Bi5`5D;
X`09`09if (cave`5By,x`5D.cptr > 1) then
X`09`09  begin
X`09`09    py_attack(y,x); `7BAttack Creature`7D
X`09`09    tmp := true;
X`09`09  end;
X   `09      end;
X        if (tmp) then
X`09  begin
X  `09    berzerk := true;
X`09    py.flags.special := 100;
X`09  end;
X      End;
XEND;   `20
X
X`7B Chests have traps too.
X  Note: Chest traps are based on the FLAGS value `7D
X    procedure chest_trap(y,x : integer);
X      var
X        i1,i2,i3 : integer;
X      BEGIN
X        with t_list`5Bcave`5By,x`5D.tptr`5D do
X          BEGIN
X            if (uand(%X'00000010',flags) <> 0) then
X              BEGIN
X                msg_print('A small needle has pricked you!');
X                if (not py.flags.sustain_str) then
X                  BEGIN
X                    py.stat.cstr := de_statp(py.stat.cstr);
X                    take_hit(damroll('1d4'),'a poison needle.');
X                    print_stat := uor(%X'0001',print_stat);
X                    msg_print('You feel weakened!');
X                  END
X                else
X                  msg_print('You are unaffected.');
X              END;
X            if (uand(%X'00000020',flags) <> 0) then
X              BEGIN
X                msg_print('A small needle has pricked you!');
X                take_hit(damroll('1d6'),'a poison needle.');
X                py.flags.poisoned := py.flags.poisoned + 10 + randint(20);
X                Opusii_vomit(20);
X              END;
X            if (uand(%X'00000040',flags) <> 0) then
X              BEGIN
X                msg_print('A puff of yellow gas surrounds you!');
X                if (py.flags.free_act) then
X                  msg_print('You are unaffected.')
X                else
X                  BEGIN
X                    msg_print('You choke and pass out.');
X                    py.flags.paralysis := 10 + randint(20);
X                  END;
X              END;
X            if (uand(%X'00000080',flags) <> 0) then
X              BEGIN
X                msg_print('There is a sudden explosion!');
X`09`09explosion(0,y,x,damroll('3d8'),3,true,'an exploding chest.');
X                delete_object(y,x);
X              END;
X            if (uand(%X'00000100',flags) <> 0) then
X              BEGIN
X                for i1 := 1 to 3 do
X                  BEGIN
X                    i2 := y;
X                    i3 := x;
X                    summon_monster(i2,i3,false)
X                  END
X              END
X          END
X      END;
X`20
X`20
X`7B Opens a closed door or closed chest.`7D
X    procedure openobject;
X      var
X                y,x,tmp: integer;
X                flag: boolean;
X      BEGIN
X        y := char_row;
X        x := char_col;
X        if (get_dir('Which direction?',tmp,tmp,y,x)) then
X          BEGIN
X            with cave`5By,x`5D do
X              if (tptr > 0) then
X`7B Closed door `7D
X                if (t_list`5Btptr`5D.tval = 105) then
X                  with t_list`5Btptr`5D do
X                    BEGIN
X                      if (p1 > 0) then  `7B It's locked.`7D
X                        BEGIN
X                          with py.misc do
X                            tmp := disarm + lev + 2*todis_adj + int_adj;
X                          if (py.flags.confused > 0) then
X                            msg_print('You are too confused to pick the lock
V.')
X                          else if ((tmp-p1) > randint(100)) then
X                            BEGIN
X                              py.misc.exp := py.misc.exp + 5;
X                              prt_experience;
X                              p1 := 0;
X                            END
X                          else
X                            msg_print('You have not convinced the door to op
Ven.');
X                        END
X                      else if (p1 < 0) then  `7B It's stuck `7D
X                        msg_print('It appears to be stuck.');
X                      if (p1 = 0) then
X                        BEGIN
X                          t_list`5Btptr`5D := door_list`5B1`5D;
X                          fopen := true;
X                          lite_spot(y,x);
X                          case randint(2) of
X                            1: msg_print('Glad to be of service...');
X                     2: msg_print('Please enjoy your trip through this door.
V');
X                          end;
X                        END;
X                    END
X`7B Open a closed chest.`7D
X                else if (t_list`5Btptr`5D.tval = 2) then
X                  BEGIN
X                    with py.misc do
X                      tmp := disarm + lev + 2*todis_adj + int_adj;
X                    with t_list`5Btptr`5D do
X                      BEGIN
X                        flag := false;
X                        if (uand(%X'00000001',flags) <> 0) then
X                          if (py.flags.confused > 0) then
X                            msg_print('You are too confused to pick the lock
V.')
X                          else if ((tmp-(2*level)) > randint(100)) then
X                            BEGIN
X                              msg_print('You have picked the lock.');
X                              flag := true;
X                              py.misc.exp := py.misc.exp + level;
X                              prt_experience;
X                            END
X                          else
X                            msg_print('You failed to pick the lock.')
X                        else
X                          flag := true;
X                        if (flag) then
X                          BEGIN
X                            flags := uand(%X'FFFFFFFE',flags);
X                            tmp := index(name,' (');
X                            if (tmp > 0) then
X                              name := substr(name,1,tmp-1);
X                            name := name + ' (Empty)';
X                            known2(name);
X                            cost := 0;
+-+-+-+-+-+-+-+-  END  OF PART 46 +-+-+-+-+-+-+-+-
