-+-+-+-+-+-+-+-+ START OF PART 42 -+-+-+-+-+-+-+-+
X`09`09%immed`09p5`09: integer := %immed 0;
X`09`09%immed`09p6`09: integer := %immed 0) : integer;
X`09`09external;
X
X      begin
X`09with jpirec do
X`09  begin
X`09    pathinfo.pathlen`09`09:= 128;`09`09`7B Image length`09`7D
X`09    pathinfo.jpi$_imagname`09:= %x207;`09`7B Image path`09`7D
X`09    new (ptr_path);
X`09    ptr_path`5E := pad(ptr_path`5E,' ',128);
X`09    new (ptr_pathlen);
X`09    ptr_pathlen`5E`09`09:= 0;
X`09    endlist`09`09`09:= 0;
X`09  end;
X`09status := $getjpi(itmlst:=jpirec);
X`09if (not(odd(status))) then
X`09  begin
X`09    clear(1,1);
X  `09    put_buffer('Error in retrieving image path.',1,1);
X`09    exit;
X`09  end
X`09else
X`09  get_jpi_path := jpirec.ptr_path`5E;
X      end;
X
X    begin
X`7Bcmh
X      uw$id := uw_id;
X      tmp_str := get_jpi_path;
X      flag := false;
X      image_path := '';
X      i1 := 127;
X      repeat
X`09i1 := i1 - 1;
X      until(tmp_str`5Bi1`5D = '`5D');
X      for i1 := 1 to i1 do
X`09image_path := image_path + tmp_str`5Bi1`5D;
X      MORIA_HOU := 'hours.dat';
X      MORIA_MOR := 'moria.dat';
X      MORIA_MAS := 'moriachr.dat';
X      MORIA_TOP := 'moriatop.dat';
X      MORIA_HLP := 'moriahlp.hlb';
X      MORIA_TRD := 'moriatrd.dat';
X      MORIA_LCK := 'morialock.lock';
X      MORIA_DTH := 'death.log';
X      MORIA_MON := 'monsters.dat';
X      MORIA_CST := 'moria_custom.mst';
X`09Note:
X`09`09Change this back to the former code after Ken gets
X`09`09the new cover program installed and the games.dat file
X`09`09modified to point to the source in this account
X`7D
X`7Bcmh, took out up there, put in down there`7D
X`7Bcmh took out whole if section`7D
X`7B      if uw$id then
X`09begin
X`09  if (index(image_path,'2:`5BGM99.`5D') = 0) then exit;
X`09  MORIA_HOU := 'HOURS.DAT';
X`09  MORIA_MOR := 'MORIA.DAT';
X`09  MORIA_MAS := 'MORIACHR.DAT';
X`09  MORIA_TOP := 'IMORIATOP.DAT';
X`09  MORIA_HLP := 'UW$D2:`5BGM99.DATA.MORIA`5DIMORIAHLP.HLB';
X`09  MORIA_TRD := 'IMORIATRD.DAT';
X`09  MORIA_LCK := 'MORIALOCK.LOCK';
X`09  MORIA_DTH := 'DEATH.LOG';
X`09end
X      else`7D
X`09begin
X          image_path := 'MORIA_DIR:'; `7Bcmh`7D
X`7Bcmh`7D     MORIA_MON := image_path + 'MONSTERS.DAT';
X`7Bcmh`7D     MORIA_CST := image_path + 'MORIA_CUSTOM.MST';
X`09  MORIA_HOU := image_path + 'HOURS.DAT';
X`09  MORIA_MOR := image_path + 'MORIA.DAT';
X`09  MORIA_MAS := image_path + 'MORIACHR.DAT';
X`09  MORIA_TOP := image_path + 'MORIATOP.DAT';
X`09  MORIA_TRD := image_path + 'MORIATRD.DAT';
X`09  MORIA_HLP := image_path + 'MORIAHLP.HLB';
X`09  MORIA_LCK := image_path + 'MORIALOCK.LOCK';
X`09  MORIA_DTH := image_path + 'DEATH.LOG';
X        end;
X     end;
X
XEnd.
$ CALL UNPACK IO.PAS;1 1124115905
$ create 'f'
X`09`7B Throw a magic spell`09`09`09`09`09-RAK-`09`7D
X`5Bpsect(misc2$code)`5D procedure cast;
X      var
X`09`09i2,dir`09`09`09`09: integer;
X`09`09i1,item_ptr`09`09`09: treas_ptr;
X`09`09choice,chance`09`09`09: integer;
X`09`09dumy,y_dumy,x_dumy`09`09: integer;
X`09`09redraw`09`09`09`09: boolean;
X`09`09ident`09`09`09`09: boolean;
X      begin
X`09reset_flag := true;
X`09if (py.flags.blind > 0) then
X`09  msg_print('You can''t see to read your spell book!')
X`09else if (no_light) then
X`09  msg_print('You have no light to read by.')
X`09else if (py.flags.confused > 0) then
X`09  msg_print('You are too confused...')
X`09else if (class`5Bpy.misc.pclass`5D.mspell) then
X`09  if (inven_ctr > 0) then
X`09    begin
X`09      if (find_range(`5BMagic_Book`5D,false,i1,i2)) then
X`09`09begin
X`09`09  redraw := false;
X`09`09  if (get_item(item_ptr,'Use which spell-book?',redraw,
X`09`09`09`09`09`09i2,trash_char,false)) then
X`09`09    begin
X`09`09      if (cast_spell('Cast which spell?',item_ptr,
X`09`09`09`09`09`09choice,chance,redraw)) then
X`09`09`09with magic_spell`5Bpy.misc.pclass,choice`5D do
X`09`09`09  begin
X`09`09`09    reset_flag := false;
X`09`09`09    if (randint(100) < chance) then
X`09`09`09      msg_print('You failed to get the spell off!')
X`09`09`09    else
X`09`09`09      begin
X`09`09`09`09y_dumy := char_row;
X`09`09`09`09x_dumy := char_col;
X`09`7B Spells...`09`09`09`09`09`7D
X`09case choice of
X`7B Magic Missile `7D
X`09  1  :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_bolt(0,dir,char_row,char_col,
X`09`09`09`09`09damroll('2d6')+1,'Magic Missile');
X`7B Detect Monster `7D
X`09  2  :`09detect_creatures(c_monster);
X`7B Phase Door `7D
X`09  3  :`09teleport(10);
X`7B Light `7D
X`09  4  :`09light_area(char_row,char_col);
X`7B Cure Light `7D
X`09  5  :`09hp_player(damroll('4d4'),'a magic spell.');
X`7B Find Hidden Traps/Door `7D
X`09  6  :`09begin
X`09`09  detect_sdoor;
X`09`09  detect_trap;
X`09`09end;
X`7B Stinking Cloud `7D
X`09  7  :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_ball(c_gas,dir,char_row,char_col,9,'Stinking Cloud');
X`7B Confuse Monster `7D
X`09  8  :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  zap_monster(dir,char_row,char_col,0,c_confuse);
X`7B Lightning Bolt `7D
X`09  9 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_bolt(c_lightning,dir,char_row,char_col,
X`09`09`09`09`09damroll('3d8')+1,'Lightning Bolt');
X`7B Trap/Door Destruction `7D
X`09  10 :`09td_destroy;
X`7B Sleep I `7D
X`09  11 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  zap_monster(dir,char_row,char_col,0,c_sleep);
X`7B Cure Poison `7D
X`09  12 :`09cure_me(py.flags.poisoned);
X`7B Shadow Door `7D
X`09  13 :`09teleport(py.misc.lev*5);
X`7B Remove Curse `7D
X`09  14 :`09for i2 := Equipment_min to equip_max-1 do
X`09`09  with equipment`5Bi2`5D do
X`09`09    flags := uand(flags,%X'7FFFFFFF');
X`7B Frost Bolt `7D
X`09  15 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_bolt(c_cold,dir,char_row,char_col,
X`09`09`09`09`09damroll('4d8')+1,'Frost Bolt');
X
X`7B Create Food `7D
X`09  16 :`09create_food(7,7,0,0,0);
X`7B Infravision `7D
X`09  17 : py.flags.tim_infra := py.flags.tim_infra + 50 + randint(50);
X`7B Invisibility `7D
X`09  18 : py.flags.temp_stealth := py.flags.temp_stealth+randint(15)+10;
X`7B Turn Stone to Mud `7D
X`09  19 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  wall_to_mud(dir,char_row,char_col);
X`7B Recharge Item I `7D
X`09  20 :`09recharge(20);
X`7B Sleep II `7D
X`09  21 :`09sleep_monsters1(char_row,char_col);
X`7B Phantasmal Force `7D
X`09  22 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_bolt(c_illusion,dir,char_row,char_col,damroll('8d4'),
X`09`09`09'phantasmal force');
X`7B Polymorph Other `7D
X`09  23 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  poly_monster(dir,char_row,char_col);
X`7B Identify `7D
X`09  24 :`09ident_spell;
X`7B Ring of Frost `7D
X`09  25 : py.flags.ring_ice := py.flags.ring_ice + 3 + randint(3);
X`7B Sleep III `7D
X`09  26 :`09zap_area(0,0,c_sleep);
X`7B Hold Monster `7D
X`09  27 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  zap_monster(dir,char_row,char_col,4+randint(4),c_hold);
X`7B Fire Bolt `7D
X`09  28 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_bolt(c_fire,dir,char_row,char_col,
X`09`09`09`09`09damroll('6d8')+1,'Fire Bolt');
X`7B Slow Creature `7D
X`09  29 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  zap_monster(dir,char_row,char_col,-1,c_speed);
X`7B Protection From Magic `7D
X`09  30 : py.flags.magic_prot := py.flags.magic_prot + 20 + randint(20);
X`7B Frost Ball `7D
X`09  31 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_ball(c_cold,dir,char_row,char_col,40,'Frost Ball');
X`7B Death Spell `7D
X`09  32 :`09zap_area(0,py.misc.lev div 2+damroll('4d8'),c_drain);
X`7B Ring of Fire `7D
X`09  33 :`09py.flags.ring_fire := py.flags.ring_fire + 3 + randint(3);
X`7B Recharge Item II `7D
X`09  34 :`09recharge(50);
X`7B Teleport Other `7D
X`09  35 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  teleport_monster(dir,char_row,char_col);
X`7B Haste Self `7D
X`09  36 :`09with py.flags do
X`09`09  fast := fast + randint(20) + py.misc.lev;
X`7B Fire Ball `7D
X`09  37 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_ball(c_fire,dir,char_row,char_col,59,'Fire Ball');
X`7B Power Word: Destruction `7D
X`09  38 :`09destroy_area(char_row,char_col);
X`7B Power Word: Kill `7D
X`09  39 :`09if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then
X`09`09  fire_bolt(0,dir,char_row,char_col,
X`09`09`09`09`09damroll('24d8'),'Black Bolt');
X`7B Genocide `7D
X`09  40 :`09genocide;
X`09  otherwise ;
X`09end;
X`09`7B End of spells...`09`09`09`09`7D
X`09`09`09`09if (not(reset_flag)) then
X`09`09`09`09  with py.misc do
X`09`09`09`09    begin
X`09`09`09`09      exp := exp + sexp;
X`09`09`09`09      prt_experience;
X`09`09`09`09      sexp := 0;
X`09`09`09`09    end
X`09`09`09      end;
X`09`09`09    with py.misc do
X`09`09`09      if (not(reset_flag)) then
X`09`09`09`09begin
X`09`09`09`09  if (smana > cmana) then
X`09`09`09`09    begin
X`09`09`09`09      msg_print('You faint from the effort!');
X`09`09`09`09      py.flags.paralysis :=
X`09`09`09`09`09randint(5*trunc(smana-cmana));
X`09`09`09`09      cmana := 0;
X`09`09`09`09      if (randint(3) = 1) then
X`09`09`7Blower_stat == no sustain`7D
X`09`09`09`09lower_stat(cn,'You have damaged your health!');
X`09`09`09`09    end
X`09`09`09`09  else
X`09`09`09`09    cmana := cmana - smana;
X`09`09`09`09  prt_mana;
X`09`09`09`09end
X`09`09`09  end
X`09`09    end
X`09`09  else
X`09`09    if (redraw) then draw_cave;
X`09`09end
X`09      else
X`09`09msg_print('But you are not carrying any spell-books!');
X`09    end
X`09  else
X`09    msg_print('But you are not carrying any spell-books!')
X`09else
X`09  msg_print('You can''t cast spells!');
X      end;
$ CALL UNPACK MAGIC.INC;1 1963012305
$ create 'f'
X`09;
X`09;  Robert Koeneke
X`09;  September 1, 1984
X`09;  MORIA subroutine
X`09;  Macro function for :
X`09;
X`09;`09MAX( MIN( x , y ) - 1 , z )
X`09;`09Arguments in order x, y, z
X`09;
X`09.title`09MAXMIN`09Retruns the max of a min and number.
X`09.ident`09/maxmin/
X`09.psect  misc1$code,pic,con,rel,lcl,shr,exe,rd,nowrt,2
X`09.entry`09maxmin,`5EM<>
X`09movl`094(ap),r0
X`09movl`098(ap),r1
X`09cmpl`09r1,r0
X`09bgeq`091$
X`09movl`09r1,r0
X1$:`09decl`09r0
X`09cmpl`0912(ap),r0
X`09bgtr`092$
X`09ret
X2$:`09movl`0912(ap),r0
X`09ret
X`09.end
$ CALL UNPACK MAXMIN.MAR;1 2117230657
$ create 'f'
X`09;
X`09;  Robert Koeneke
X`09;  September 1, 1984
X`09;  MORIA subroutine
X`09;  Macro function for :
X`09;
X`09;`09MIN( MAX( y , x ) + 1 , z )
X`09;
X`09.title`09MINMAX`09`09Returns the min of a max and a number.
X`09.ident`09/minmax/
X`09.psect  misc1$code,pic,con,rel,lcl,shr,exe,rd,nowrt,2
X`09.entry`09minmax,`5EM<>
X`09movl`094(ap),r0
X`09movl`098(ap),r1
X`09cmpl`09r0,r1
X`09bgeq`091$
X`09movl`09r1,r0
X1$:`09incl`09r0
X`09cmpl`09r0,12(ap)
X`09bgtr`092$
X`09ret
X2$:`09movl`0912(ap),r0
X`09ret
X`09.end
$ CALL UNPACK MINMAX.MAR;1 1163418226
$ create 'f'
X`5BInherit('Moria.Env')`5D Module Misc;
X
X`09`7B Use date and time to produce random seed`09`09-RAK-`09`7D
X`5Bglobal,psect(setup$code)`5D function get_seed : unsigned;
X    type
X`09$quad = `5Bquad,unsafe`5D record
X`09`09l0`09: unsigned;
X`09`09l1`09: unsigned;
X`09end;
X    var
X`09time`09`09: $quad;
X`09seed_val`09: unsigned;
X
X    `5Basynchronous,external (SYS$GETTIM)`5D function get_time(
X`09`09var time : $quad) : integer;
X`09`09external;
X
X    begin
X      get_time(time);`09`09`09`09`7B Current time`09`7D
X      seed_val := uor(time.l0,time.l1);`09`09`7B Random number `7D
X      get_seed := uor(seed_val,%X'00000001');`09`7B Odd number`09`7D
X    end;
X
X
X`09`7B Returns the day number; 1=Sunday...7=Saturday`09`09-RAK-`09`7D
X`5Bglobal,psect(setup$code)`5D function day_num : integer;
X    var
X`09i1`09`09: integer;
X    `5Bexternal(LIB$DAY)`5D function day(
X`09var daynum`09`09: integer;
X`09dum1`09`09`09: integer := %immed 0;
X`09dum2`09`09`09: integer := %immed 0) : integer;
X`09external;
X    begin
X      day(i1);
X      day_num := ((i1+3) mod 7) + 1;
X    end;
X
X
X`09`7B Returns the hour number; 0=midnight...23=11 PM`09-RAK-`09`7D
X`5Bglobal,psect(setup$code)`5D function hour_num : integer;
X    var
X`09hour`09`09: integer;
X`09time_str`09: packed array `5B1..11`5D of char;
X    begin
X      time(time_str);
X      readv(substr(time_str,1,2),hour,error:=continue);
X      hour_num := hour;
X    end;
X
X
X`09`7B Set up the variables that depend upon the difficulty of
X`09  game chosen.`09`09`09`09`09`09-DMF-`09`7D
X`5Bglobal,psect(setup$code)`5D procedure set_difficulty(diff : integer);
X    begin
X      case diff of
X`091 : begin`09`09`09`09`7B Brain-dead`09`7D
X`09`09dun_str_mc`09:= 75;
X`09`09dun_str_qc`09:= 30;
X`09`09dun_unusual`09:= 250;
X`09`09obj_great`09:= 50;
X`09`09treas_room_alloc:= 3;
X`09`09treas_any_alloc`09:= 1;
X`09`09treas_gold_alloc:= 4;
X`09`09obj_std_adj`09:= 0.9;
X`09`09obj_std_min`09:= 3;
X`09`09obj_town_level`09:= 5;
X`09`09obj_base_magic`09:= 6;
X`09`09obj_base_max`09:= 70;
X`09`09obj_div_special`09:= 20;
X`09`09obj_div_cursed`09:= 1.2;
X`09`09mon_nasty`09:= 150;
X`09`09mon_mult_adj`09:= 15;
X`09    end;
X`092 : begin`09`09`09`09`7B Easy`09`09`7D
X`09`09dun_str_mc`09:= 85;
X`09`09dun_str_qc`09:= 45;
X`09`09dun_unusual`09:= 175;
X`09`09obj_great`09:= 42;
X`09`09treas_room_alloc:= 5;
X`09`09treas_any_alloc`09:= 1;
X`09`09treas_gold_alloc:= 3;
X`09`09treas_gold_alloc:= 3;
X`09`09obj_std_adj`09:= 1.05;
X`09`09obj_std_min`09:= 5;
X`09`09obj_town_level`09:= 6;`09
X`09`09obj_base_magic`09:= 9;
X`09`09obj_base_max`09:= 85;
X`09`09obj_div_special`09:= 15;
X`09`09obj_div_cursed`09:= 1.2;
X`09`09mon_nasty`09:= 100;
X`09`09mon_mult_adj`09:= 10;
X`09    end;
X`093 : begin`09`09`09`09`7B Normal`09`7D
X`09`09dun_str_mc`09:= 95;
X`09`09dun_str_qc`09:= 55;
X`09`09dun_unusual`09:= 100;
X`09`09obj_great`09:= 30;
X`09`09treas_room_alloc:= 7;
X`09`09treas_any_alloc`09:= 2;
X`09`09treas_gold_alloc:= 2;
X`09`09obj_std_adj`09:= 1.25;
X`09`09obj_std_min`09:= 7;
X`09`09obj_town_level`09:= 7;
X`09`09obj_base_magic`09:= 12;
X`09`09obj_base_max`09:= 100;
X`09`09obj_div_special`09:= 11;
X`09`09obj_div_cursed`09:= 1.2;
X`09`09mon_nasty`09:= 50;
X`09`09mon_mult_adj`09:= 7;
+-+-+-+-+-+-+-+-  END  OF PART 42 +-+-+-+-+-+-+-+-
