-+-+-+-+-+-+-+-+ START OF PART 16 -+-+-+-+-+-+-+-+
X    `5Bglobal,psect(moria$code)`5D function pick_dir(dir : integer) : boolea
Vn;
X      var
X`09`09z               : array `5B1..2`5D of integer;
X`09`09i1,y,x,heading`09: integer;
X      begin
X`09if ((find_flag) and (next_to4(char_row,char_col,corr_set) = 2)) then
X`09  begin
X`09    case dir of
X`09`091,3,7,9 : begin
X`09`09`09    z`5B1`5D := rotate_dir(dir,-1);
X`09`09`09    z`5B2`5D := rotate_dir(dir,1);
X`09`09`09  end;
X`09`092,4,6,8 : begin
X`09`09`09    z`5B1`5D := rotate_dir(dir,-2);
X`09`09`09    z`5B2`5D := rotate_dir(dir,2);
X`09`09`09end;
X`09    end;
X`09    pick_dir := false;
X`09    for i1 := 1 to 2 do
X`09      begin
X`09`09y := char_row;
X`09`09x := char_col;
X`09`09if (move(z`5Bi1`5D,y,x)) then
X`09`09  if (cave`5By,x`5D.fopen) then
X`09`09    begin
X`09`09      pick_dir := true;
X`09`09      com_val := z`5Bi1`5D + 48
X`09`09    end
X`09      end
X`09  end
X`09else
X`09  begin
X`09    pick_dir := false;
X`09  end;
X      end;
X
X
X`09`7B Calculates current boundries`09`09`09`09-RAK-`09`7D
X    `5Bglobal,psect(moria$code)`5D procedure panel_bounds;
X      begin
X`09panel_row_min := (trunc(panel_row*(screen_height/2)) + 1);
X`09panel_row_max := panel_row_min + screen_height - 1;
X`09panel_row_prt := panel_row_min - 2;
X`09panel_col_min := (trunc(panel_col*(screen_width/2)) + 1);
X`09panel_col_max := panel_col_min + screen_width - 1;
X`09panel_col_prt := panel_col_min - 15;
X      end;
X
X
X`09`7B Tests a given point to see if it is within the screen -RAK-`09`7D
X`09`7B boundries.                                                    `7D
X    `5Bglobal,psect(moria$code)`5D function panel_contains(y,x : integer) :
V boolean;
X      begin
X`09if ((y >= panel_row_min) and (y <= panel_row_max)) then
X`09  if ((x >= panel_col_min) and (x <= panel_col_max)) then
X`09    panel_contains := true
X`09  else
X`09    panel_contains := false
X`09else
X`09  panel_contains := false;
X      end;
X
X
X`09`7B Returns true if player has no light`09`09`09-RAK-`09`7D
X    `5Bglobal,psect(moria$code)`5D function no_light : boolean;
X      begin
X`09no_light := false;
X`09with cave`5Bchar_row,char_col`5D do
X`09  if (not(tl)) then
X`09    if (not(pl)) then
X`09      no_light := true;
X      end;
X
X
X`09`7B Change a trap from invisible to visible`09`09-RAK-`09`7D
X`09`7B Note: Secret doors are handled here                           `7D
X    `5Bglobal,psect(moria$code)`5D procedure change_trap(y,x : integer);
X      var
X`09`09i3              : integer;
X      begin
X`09with cave`5By,x`5D do
X`09  if (t_list`5Btptr`5D.tval in `5BUnseen_trap,Secret_door`5D) then
X`09    begin
X`09      i3 := tptr;
X`09      place_trap(y,x,2,t_list`5Bi3`5D.subval);
X`09      pusht(i3);
X`09      lite_spot(y,x);
X`09    end;
X      end;
X
X
X
X
X`09`7B Here's a bunch of otherwise worthless procedures that are     `7D
X`09`7B used to give the peasant's houses a bit of variety.   -RAD-   `7D
X`09     `20
X
X     `5Bglobal,psect(moria$code)`5D procedure kicked_out;
X       begin                                        `20
X`09 msg_print('The owner kicks you out...');
X       end;`20
X
X     `5Bglobal,psect(moria$code)`5D procedure call_guards(who : vtype);
X       begin
X`09 msg_print('The '+who+' call(s) for the Town Guards!');
X`09 monster_summon_by_name(char_row,char_col,'Town Guard',true,false);
X         monster_summon_by_name(char_row,char_col,'Town Guard',true,false);
X       end;
X
X     `5Bglobal,psect(moria$code)`5D procedure call_wizards;
X       begin
X`09 msg_print('The mage calls for a Town Wizard to remove you.');
X`09 monster_summon_by_name(char_row,char_col,'Town Wizard',true,false);
X       end;
X
X     `5Bglobal,psect(moria$code)`5D procedure beg_food;          `7BUnfinish
Ved`7D
X       var`09i2`09`09: integer;
X`09`09item_ptr`09: treas_ptr;
X       begin
X`09if (find_range(`5Bfood`5D,false,item_ptr,i2)) then
X`09  begin
X`09    msg_print('The occupants beg you for food.');
X`09    if get_yes_no('Will you feed them?') then
X`09      begin
X`09`09spend_time(200,'feeding people',false);
X`09`09msg_print('How kind of you!');
X`09`09inven_destroy(item_ptr);
X`09`09change_rep(5);
X`09`09prt_weight;
X`09      end
X`09    else
X`09      begin
X`09`09msg_print('What a jerk!');
X`09`09change_rep(-10);
X`09      end;
X`09  end
X`09else
X`09  beg_money;
X       end;
X                                                    `20
X     `5Bglobal,psect(moria$code)`5D procedure beg_money;         `7BUnfinish
Ved`7D
X`09var`09i1 : integer;
X`09begin
X`09  msg_print('The occupants beg you for money.');
X`09  if get_yes_no('Will you give them some?') then
X`09    with py.misc do
X`09      begin
X`09`09if (money`5Btotal$`5D > 0) then
X`09`09begin
X`09`09  msg_print('How kind of you!');
X`09`09  spend_time(100,'giving handouts',false);
X`09`09  i1 := ((randint(12)*money`5Btotal$`5D) div 1000 + 20)*gold$value;
X                  if (i1 > money`5Btotal$`5D*gold$value div 2) then
X`09`09    i1 := money`5Btotal$`5D*gold$value div 2;
X`09`09  subtract_money(i1,false);
X`09`09  prt_weight;
X`09`09  prt_gold;
X`09`09  if (i1 > 20*gold$value) then
X`09`09    change_rep(5)
X`09`09  else
X`09`09    change_rep((i1+5*gold$value-1) div (5*gold$value));
X`09`09  prt_weight;
X`09`09  prt_gold;
X`09`09end
X`09      else
X`09        msg_print('They are disappointed because you have no money.');
X`09    end
X`09  else
X`09    begin
X`09      msg_print('What a jerk!');
X`09      change_rep(-10); `7Bbug fixed here; used to be 10 -- MAV `7D
X`09    end;
X       end;
X
X  procedure eat_the_meal;
X    var yummers,old_food : integer;
X    begin
X      yummers := react(randint(8)-2);
X      old_food := py.flags.food;
X      if ((yummers=10) and (randint(2)=1)) then yummers := 15;
X      spend_time(50 + 50 * yummers,'eating like a pig',false);
X      case yummers of
X`0915 : begin
X`09`09msg_print('It is a sumptuous banquet, and you feel quite stuffed.');
X`09`09py.flags.food := player_food_max;
X`09`09py.flags.status := uand(%X'FFFFFFFC',py.flags.status);
X`09`09prt_hunger;
X`09`09change_rep(3);
X`09       end;
X`096..10 : begin
X`09`09msg_print('It is an ample meal, and you feel full.');
X`09`09py.flags.food := player_food_full;
X`09`09py.flags.status := uand(%X'FFFFFFFC',py.flags.status);
X`09`09prt_hunger;
X`09`09change_rep(1);
X`09       end;
X`09otherwise
X`09     if ((yummers>0) or player_saves(py.misc.lev+5*spell_adj(cn))) then
X`09`09begin
X`09`09  msg_print('It was a boring meal, and you eat very little.');
X`09`09  py.flags.food := old_food;
X`09`09  prt_hunger;
X`09        end
X`09       else
X`09`09begin
X`09`09  msg_print('Yuk!  That meal was AWFUL!');
X`09`09  msg_print('You throw up!');
X`09`09  if (py.flags.food > 150) then py.flags.food := 150;
X`09`09  msg_print('You get food poisoning.');
X`09`09  py.flags.poisoned := py.flags.poisoned + randint(10) + 5;
X`09`09  change_rep(-2);
X `09        end;
X      end; `7Bcase`7D
X    end;
X
X
X    `5Bglobal,psect(moria$code)`5D procedure invite_for_meal;
X      begin
X`09msg_print('The occupants invite you in for a meal.');
X`09if get_yes_no('Do you accept?') then
X`09  eat_the_meal;
X      end;
X
X    `5Bglobal,psect(moria$code)`5D procedure party;
X      begin
X        msg_print('The owner invites you to join the party!');
X`09if get_yes_no('Do you accept?') then
X`09begin
X`09  spend_time(400+randint(1600),'at a party',false);
X          case randint(6) of
X`09  1 : begin
X`09`09msg_print('Someone must have spiked the punch!');
X`09       `09msg_print('Oh, your aching head!');
X`09`09py.flags.confused := py.flags.confused + 25 + randint(25);
X`09      end;
X`09  2 : begin
X`09`09msg_print('Gee, those brownies were awfully unusual....');
X`09`09msg_print('You feel a little strange now.');
X`09`09py.flags.image := py.flags.image + 200 + randint(100);
X`09      end;
X`09  3 : begin
X`09`09msg_print('You smoked something strange at the party.');
X`09`09case (randint(2)) of
X`09`09  1 : py.flags.hero := py.flags.hero + 25 + randint(25);
X`09`09  2 : py.flags.afraid := py.flags.afraid + 25 + randint(25);
X`09`09end;
X`09      end;
X      4,5,6 : msg_print('It is an interesting party, and you enjoy yourself.
V');
X          end; `7Bcase`7D
X`09end;
X      end; `7Bparty`7D
X
X
X    `5Bglobal,psect(moria$code)`5D procedure spend_the_night(who : vtype);
X      begin
X`09msg_print('The occupant(s) invite you to rest in his house.');
X`09if get_yes_no('Do you accept?') then
X`09 begin
X`09  spend_time(1,'at the home of the '+who+'.',true);
X`09  change_rep(2);
X`09 end
X`09else if get_yes_no('Okay, how about staying for a meal?') then
X`09  eat_the_meal;
X      end;
X
X     `5Bglobal,psect(moria$code)`5D procedure worship;
X      var preachy,i1 : integer;
X      begin
X`09msg_print('The priest invites you to participate in the service.');
X`09if get_yes_no('Do you accept?') then
X`09  begin
X`09     preachy := randint(4);
X`09     case preachy of
X`09      1`09: msg_print('You sit through a fascinating church service.');
X`09      2`09: msg_print('You sit through an interesting church service.');
X`09      3 : msg_print('You sit through a boring church service.');
X`09      4 : msg_print('You sit through a long, boring church service.');
X`09     end;
X`09   spend_time(100*(randint(7)+preachy*preachy),'at the Church',false);
X`09    msg_print('The priest asks for donations for a new church.');
X`09    if get_yes_no('Will you give him some money?') then
X`09      with py.misc do
X`09`09if (money`5Btotal$`5D > 0) then
X`09`09  begin
X`09`09    msg_print('Bless you, dude!');
X`09`09    i1:=((randint(12)*money`5Btotal$`5D) div 1000 + 20)*gold$value;
X                    if (i1 > money`5Btotal$`5D*gold$value div 2) then
X`09`09`09i1 := money`5Btotal$`5D*gold$value div 2;
X`09`09    subtract_money(i1,false);
X`09`09    prt_weight;
X`09`09    prt_gold;
X`09`09    if (i1 > 20*gold$value) then
X`09`09`09change_rep(5)
X`09`09    else
X`09`09`09change_rep((i1+5*gold$value-1) div (5*gold$value));
X`09`09  end
X`09`09else`20
X`09`09  begin
X`09`09    msg_print('He says ''It is the thought that counts, my child.');
X                    msg_print('Thank you for being willing to give.');
X`09`09  end
X`09    else
X`09      msg_print('Syo problem, man?');
X`09    change_rep(-5);
X`09  end
X`09else if (react(6)=0) then
X`09  begin
X`09    msg_print('You heathen!  Get out of my temple!');
X`09    change_rep(-5);
X`09  end;
X      end;
X
X    `5Bglobal,psect(moria$code)`5D procedure battle_game(plus : integer; kb_
Vstr : vtype);
X      var score,i1,time : integer;
X      begin
X`09if get_yes_no('Do you accept their invitation?') then
X`09  begin
X`09    msg_print('Good for you!');
X`09    score := 0;
X`09    time := 10;
X`09    with py.misc do
X`09      begin
X`09`09for i1 := 1 to 7 do
X`09`09  if player_test_hit(bth,lev,plus,20*i1,false) then
X`09`09    begin
X`09`09      score := score + 1;
X`09`09      time := time * 2 + 10;
X`09`09    end;
X`09      end;
X`09    spend_time(time,'with some '+kb_str,false);
X`09    case score of
X`09      1 : begin
X`09`09    msg_print('They ridicule your clumsy performance...');
X`09`09    msg_print('"Come back when you are more experienced!!"');
X`09`09    change_rep(-2);
X`09`09  end;
X`09      2 : msg_print('You do not do well...');
X`09      3 : msg_print('"Pretty good for a beginner!"');
X`09      4 : msg_print('They are quite impressed!');
X`09      5 : begin
X`09`09    msg_print('They are amazed by your incredible prowess!');
X`09`09    change_rep(2);
X`09`09  end;
X`09      6,7 : begin
X`09`09   msg_print('You handle them all with ease!');
X`09`09   msg_print('"Thanks for the workout! Come back anytime!!"');
X`09`09   py.misc.exp := py.misc.exp + 10;
X`09`09   change_rep(5);
X`09`09 end;
X`09      otherwise`20
X`09`09begin
X`09`09 msg_print('"Boy that was quick!! What a little wimp!"');
X`09`09 msg_print('They pummel you senseless and toss you out into the street
V!');
X`09`09 take_hit(damroll('2d4'),kb_str);
X`09`09 change_rep(-5);
X`09`09 py.flags.confused := py.flags.confused + 5 + randint(5);
X`09`09end;
X`09    end;
X`09  end;
X      end;
X
X    procedure brothel_game;
X      begin
X`09if get_yes_no('Do you accept?') then
X`09  begin
X`09    change_rep(-3);
X`09    with py.misc do
X`09      if (disarm + lev + 2*todis_adj + spell_adj(iq) > randint(100)) then
X`09`09begin
X`09`09  msg_print('Good! You are invited to join the house!');
X`09`09  exp := exp + 5;
X`09`09  spend_time(600,'putting out for peasants',false);
X`09`09end
X`09      else
X`09`09begin
X`09`09  msg_print('You fail to please your customers.');
X`09`09  spend_time(400,'imitating a pine board',false);
X`09`09end;
X`09  end;
X      end;
X
X    procedure guild_or_not(passed : boolean);
X     begin
X      if (passed) then
X       begin
X`09spend_time(600,'showing off your skills',false);
X`09msg_print('Good! You are invited to join the guild!');
X`09py.misc.exp := py.misc.exp + 5;
X`09change_rep(-3);
X       end
X     else`20
X`09begin
X`09  spend_time(400,'or lack thereof',false);
X`09  msg_print('You fail to impress them.');
X`09  if (randint(3) = 1) then
X`09    begin
X`09      msg_print('They think you are with the guard!');
X`09      msg_print('You are stabbed by one of them before you escape');
X`09      take_hit(randint(randint(16)),'Thieves Guild Member');
X`09      prt_hp;
X`09    end;
X`09end;
X     end;
X
X    `5Bglobal,psect(moria$code)`5D procedure thief_games;
X      begin
X`09if (randint(2) = 1) then
X`09  begin
Xmsg_print('The thieves invite you to prove your ability to pick locks.');
X`09    if get_yes_no('Do you accept?') then
X`09      with py.misc do
X`09guild_or_not(disarm+lev+2*todis_adj+spell_adj(iq) > randint(100));
X`09  end
X`09else
X`09  begin                                                 `20
X`09    msg_print('The thieves invite you to show your stealthiness.');
X`09    if get_yes_no('Do you accept?') then
X`09`09guild_or_not(py.misc.stl > randint(12));
X`09  end
X      end;
X
X`7Breturns 0 to 10 -- SD 2.4; x is average reaction for a 0 SC ugly half-tro
Vll`7D
X    `5Bglobal,psect(moria$code)`5D function react(x : integer) : integer;
X      var   ans  : integer;
X      begin
X`09ans := (py.stat.c`5Bca`5D+py.misc.rep*2+randint(200)+randint(200)
X`09`09+randint(200)) div 50 + x - 4;
X`09if (ans < 0) then ans := 0
+-+-+-+-+-+-+-+-  END  OF PART 16 +-+-+-+-+-+-+-+-
