-+-+-+-+-+-+-+-+ START OF PART 44 -+-+-+-+-+-+-+-+ X`09 fy := y; X`09 fx := x; X`09 mptr := z; X`09 nptr := muptr; X`09 muptr := cur_pos; X`09 if (uand(c_list`5Bz`5D.cdefense,%X'4000') <> 0) then X`09 hp := max_hp(c_list`5Bz`5D.hd) X`09 else X`09 hp := damroll(c_list`5Bz`5D.hd); X`09 cspeed := c_list`5Bz`5D.speed + py.flags.speed; X`09 stunned := 0; X`09 cdis := distance(char_row,char_col,y,x); X`09 cave`5By,x`5D.cptr := cur_pos; X`09 if (slp) then X`09 begin X`09 csleep := trunc(c_list`5Bz`5D.sleep/5.0) + randint(c_list`5Bz`5D.sl Veep); X`09 end X`09 else X`09 csleep := 0; X`09end; X end; X X X`09`7B Places a monster at given location`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc3$code)`5D procedure place_win_monster; X var X`09cur_pos`09`09`09: integer; X`09y,x`09`09`09: integer; X begin X if (not(total_winner)) then X`09begin X`09 popm(cur_pos); X`09 with m_list`5Bcur_pos`5D do X`09 begin X`09 repeat X`09`09y := randint(cur_height-2)+1; X`09`09x := randint(cur_width-2)+1; X`09 until ((cave`5By,x`5D.fval in `5B1,2,4`5D)`09and X`09`09 (cave`5By,x`5D.cptr = 0)`09`09and X`09`09 (cave`5By,x`5D.tptr = 0)`09`09and X`09`09 (distance(y,x,char_row,char_col) > max_sight)); X`09 fy := y; X`09 fx := x; X`09 mptr := randint(win_mon_tot) + X`09`09`09`09m_level`5Bmax_mons_level`5D + m_level`5B0`5D; X`09 nptr := muptr; X`09 muptr := cur_pos; X`09 if (uand(c_list`5Bmptr`5D.cdefense,%X'4000') <> 0) then X`09`09hp := max_hp(c_list`5Bmptr`5D.hd) X`09 else X`09`09hp := damroll(c_list`5Bmptr`5D.hd); X`09 cspeed := c_list`5Bmptr`5D.speed + py.flags.speed; X`09 stunned := 0; X`09 cdis := distance(char_row,char_col,y,x); X`09 cave`5By,x`5D.cptr := cur_pos; X`09 csleep := 0; X`09 end; X`09end; X end; X X X`09`7B Allocates a random land monster`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc3$code)`5D procedure alloc_land_monster(alloc_set : obj_ Vset; X`09`09`09 num,dis : integer; X`09`09`09 slp : boolean; X`09`09`09 water : boolean); X var X`09y,x,a,b,i1,i2,i3,count`09: integer; X`09count2`09`09`09: integer; X`09flag, flag2`09`09: boolean; X begin X for i1 := 1 to num do X`09begin X`09 flag := false; X`09 count := 0; X`09 count2 := 0; X`09 repeat X`09 y := randint(cur_height-2)+1; X`09 x := randint(cur_width-2)+1; X`09 count2 := count2 + 1; X`09 until ((cave`5By,x`5D.fval in alloc_set)`09and X`09`09 (cave`5By,x`5D.cptr = 0)`09`09and X`09`09 (cave`5By,x`5D.fopen)`09`09and X`09`09 (distance(y,x,char_row,char_col) > dis) or (count2 > 7500)); X`09 repeat X`09 if (dun_level = 0) then X`09 i2 := randint(m_level`5B0`5D) X`09 else if (dun_level > max_mons_level) then X`09 i2 := randint(m_level`5Bmax_mons_level`5D) + m_level`5B0`5D X`09 else if (randint(mon_nasty) = 1) then X`09 begin X`09 i2 := dun_level + abs(randnor(0,4)) + 1; X`09 if (i2 > max_mons_level) then i2 := max_mons_level; X`09 i3 := m_level`5Bi2`5D - m_level`5Bi2-1`5D; X`09 i2 := randint(i3) + m_level`5Bi2-1`5D; X`09 end X`09 else X`09 i2 := randint(m_level`5Bdun_level`5D) + m_level`5B0`5D; X`09 if (not water) then X`09 flag := (uand(c_list`5Bi2`5D.cmove,%X'00008000') = 0) and X`09 ((uand(c_list`5Bi2`5D.cmove,%X'00000010') = 0) or X`09`09(uand(c_list`5Bi2`5D.cmove,%X'00000040') = 0) or X`09`09(uand(c_list`5Bi2`5D.cmove,%X'00800000') <> 0))`20 X`09 else X`09 flag := (uand(c_list`5Bi2`5D.cmove,%X'00008000') = 0) and X`09 (uand(c_list`5Bi2`5D.cmove,%X'00000010') <> 0); X`09 if (flag) then X`09 begin X`09`09if (count2 < 7500) then X`09`09begin X`09`09 place_monster(y,x,i2,slp); X`09`09 flag := true; X`09`09end; X`09 end; X`09 count := count + 1; X`09 until (flag) or (count > 10); X`09end X end; X X X`09`7B Places land creature adjacent to given location`09-RAK-`09`7D X`5Bglobal,psect(misc3$code)`5D function summon_land_monster( X`09`09`09`09var y,x :`09integer; X`09`09`09`09slp`09:`09boolean X`09`09`09`09`09) : boolean; X var X`09i1,i2,i3,i4,i5,count`09: integer; X`09flag`09`09`09: boolean; X begin X i1 := 0; X i5 := dun_level + mon$summon_adj; X summon_land_monster := false; X repeat X`09i2 := y - 2 + randint(3); X`09i3 := x - 2 + randint(3); X`09if (in_bounds(i2,i3)) then X`09 with cave`5Bi2,i3`5D do X`09 if (fval in earth_set) then X`09 if (cptr = 0) then X`09`09if (fopen) then X`09`09 begin X`09`09 flag := false; X`09`09 count := 0; X`09`09 repeat X`09`09 if (i5 > max_mons_level) then X`09`09`09i4 := max_mons_level X`09`09 else X`09`09`09i4 := i5; X`09`09 if (dun_level = 0) then X`09`09`09i4 := randint(m_level`5B0`5D) X`09`09 else X`09`09`09i4 := randint(m_level`5Bi4`5D) + m_level`5B0`5D; X`09`09 if (uand(c_list`5Bi4`5D.cmove,%X'00008000') = 0) and X`09`09`09 ((uand(c_list`5Bi4`5D.cmove,%X'00000010') = 0) or X`09`09`09 (uand(c_list`5Bi4`5D.cmove,%X'00000040') = 0) or X`09`09`09 (uand(c_list`5Bi4`5D.cmove,%X'00800000') <> 0)) then X`09`09`09begin X`09`09`09 place_monster(i2,i3,i4,slp); X`09`09`09 summon_land_monster := true; X`09`09`09 flag := true; X`09`09`09end; X`09`09 count := count + 1; X`09`09 until (flag) or (count > 10); X`09`09 i1 := 9; X`09`09 y := i2; X`09`09 x := i3; X`09`09 end; X`09i1 := i1 + 1; X until (i1 > 9); X end; X X X`09`7B Places water creature adjacent to given location`09-DMF-`09`7D X`5Bglobal,psect(misc3$code)`5D function summon_water_monster( X`09`09`09`09var y,x :`09integer; X`09`09`09`09slp`09:`09boolean X`09`09`09`09`09) : boolean; X var X`09i1,i2,i3,i4,i5,count`09: integer; X`09flag`09`09`09: boolean; X begin X i1 := 0; X i5 := dun_level + mon$summon_adj; X summon_water_monster := false; X repeat X`09i2 := y - 2 + randint(3); X`09i3 := x - 2 + randint(3); X`09if (in_bounds(i2,i3)) then X`09 with cave`5Bi2,i3`5D do X`09 if (fval in water_set) then X`09 if (cptr = 0) then X`09`09if (fopen) then X`09`09 begin X`09`09 flag := false; X`09`09 count := 0; X`09`09 repeat X`09`09 if (i5 > max_mons_level) then X`09`09`09i4 := max_mons_level X`09`09 else X`09`09`09i4 := i5; X`09`09 if (dun_level = 0) then X`09`09`09i4 := randint(m_level`5B0`5D) X`09`09 else X`09`09`09i4 := randint(m_level`5Bi4`5D) + m_level`5B0`5D; X`09`09 if (uand(c_list`5Bi4`5D.cmove,%X'00008000') = 0) and X`09`09`09 ((uand(c_list`5Bi4`5D.cmove,%X'00000010') <> 0) or X`09`09`09 (uand(c_list`5Bi4`5D.cmove,%X'00000040') = 0) or X`09`09`09 (uand(c_list`5Bi4`5D.cmove,%X'00800000') <> 0)) then X`09`09`09begin X`09`09`09 place_monster(i2,i3,i4,slp); X`09`09`09 summon_water_monster := true; X`09`09`09 flag := true; X`09`09`09end; X`09`09 count := count + 1; X`09`09 until (flag) or (count > 10); X`09`09 i1 := 9; X`09`09 y := i2; X`09`09 x := i3; X`09`09 end; X`09i1 := i1 + 1; X until (i1 > 9); X end; X X X`09`7B Places undead adjacent to given location`09`09-RAK-`09`7D X`5Bglobal,psect(misc3$code)`5D function summon_undead(var y,x : integer) : b Voolean; X var X`09i1,i2,i3,i4,i5,ctr`09: integer; X begin X i1 := 0; X summon_undead := false; X i4 := m_level`5Bmax_mons_level`5D + m_level`5B0`5D; X repeat X`09i5 := randint(i4); X`09ctr := 0; X`09repeat X`09 if (uand(c_list`5Bi5`5D.cdefense,%X'0008') <> 0) then X`09 begin X`09 ctr := 20; X`09 i4 := 0; X`09 end X`09 else X`09 begin X`09 i5 := i5 + 1; X`09 if (i5 > i4) then X`09`09ctr := 20 X`09 else X`09`09ctr := ctr + 1; X`09 end; X`09until(ctr > 19) X until(i4 = 0); X repeat X`09i2 := y - 2 + randint(3); X`09i3 := x - 2 + randint(3); X`09if (in_bounds(i2,i3)) then X`09 with cave`5Bi2,i3`5D do X`09 if (fval in `5B1,2,4,5`5D) then X`09 if ((cptr = 0) and (fopen)) then X`09`09begin X`09`09 place_monster(i2,i3,i5,false); X`09`09 summon_undead := true; X`09`09 i1 := 9; X`09`09 y := i2; X`09`09 x := i3; X`09`09end; X`09i1 := i1 + 1; X until (i1 > 9); X end; X X`09`7B Places breeding monster adjacent to given location `7D X`5Bglobal,psect(misc3$code)`5D function summon_breed(var y,x : integer) : bo Volean; X var X`09i1,i2,i3,i4,i5,ctr`09: integer; X begin X summon_breed := false; X i1 := 0; X repeat X`09i2 := y - 2 + randint(3); X`09i3 := x - 2 + randint(3); X`09if (in_bounds(i2,i3)) then X`09 with cave`5Bi2,i3`5D do X`09 if (fval in earth_set) or (fval in water_set) then X`09 if ((cptr = 0) and (fopen)) then X`09`09begin X`09`09 i4 := m_level`5Bmax_mons_level`5D + m_level`5B0`5D; X`09`09 repeat X`09`09 i5 := randint(i4); X`09`09 ctr := 0; X`09`09 repeat X`09`09 if (uand(c_list`5Bi5`5D.cmove,%X'00200000') <> 0) and X`09`09`09 (((fval in earth_set) and X`09`09`09 (uand(c_list`5Bi5`5D.cmove,%X'00000010') = 0) or X`09`09`09 (uand(c_list`5Bi5`5D.cmove,%X'00000040') = 0) or X`09`09`09 (uand(c_list`5Bi5`5D.cmove,%X'00800000') <> 0)) or X`09`09`09 ((fval in water_set) and X`09`09`09 (uand(c_list`5Bi5`5D.cmove,%X'00000010') <> 0) or X`09`09`09 (uand(c_list`5Bi5`5D.cmove,%X'00000040') = 0) or X`09`09`09 (uand(c_list`5Bi5`5D.cmove,%X'00800000') <> 0))) then X`09`09`09begin X`09`09`09 ctr := 20; X`09`09`09 i4 := 0; X`09`09`09end X`09`09 else X`09`09`09begin X`09`09`09 i5 := i5 + 1; X`09`09`09 if (i5 > i4) then X`09`09`09 ctr := 20 X `09`09`09 else X`09`09`09 ctr := ctr + 1; X`09`09`09end; X`09`09 until(ctr > 19) X`09`09 until(i4 = 0); X`09`09 place_monster(i2,i3,i5,false); X`09`09 summon_breed := true; X`09`09 i1 := 9; X`09`09 y := i2; X`09`09 x := i3; X`09`09end; X`09i1 := i1 + 1; X until (i1 > 9); X end; X X`09`7B Places demon adjacent to given location`09`09-RAK-`09`7D X`5Bglobal,psect(misc3$code)`5D function summon_demon(var y,x : integer) : bo Volean; X var X`09i1,i2,i3,i4,i5,ctr`09: integer; X begin X i1 := 0; X summon_demon := false; X i4 := m_level`5Bmax_mons_level`5D + m_level`5B0`5D; X repeat X`09i5 := randint(i4); X`09ctr := 0; X`09repeat X`7B`09 Check monsters for demon `7D X`09 if (uand(c_list`5Bi5`5D.cdefense,%X'0400') <> 0) then X`09 begin X`09 ctr := 20; X`09 i4 := 0; X`09 end X`09 else X`09 begin X`09 i5 := i5 + 1; X`09 if (i5 > i4) then X`09`09ctr := 20 X`09 else X`09`09ctr := ctr + 1; X`09 end; X`09until(ctr > 19) X until(i4 = 0); X repeat X`09repeat X`09 i2 := y - 2 + randint(3); X`09 i3 := x - 2 + randint(3); X`09until ((i2 <> y)or(i3 <> x)); X`09if (in_bounds(i2,i3)) then X`09 with cave`5Bi2,i3`5D do X`09 if (fval in `5B1,2,4,5`5D) then X`09 if ((cptr = 0) and (fopen)) then X`09`09begin X`09`09 place_monster(i2,i3,i5,false); X`09`09 summon_demon := true; X`09`09 i1 := 9; X`09`09 y := i2; X`09`09 x := i3; X`09`09end; X`09i1 := i1 + 1; X until (i1 > 9); X end; X X`5Bglobal,psect(misc3$code)`5D procedure petrify(amt : integer); X begin X with py.flags do X`09begin X`09 petrification := petrification + randint(amt); X`09 if (petrification < 100) then X`09 msg_print('You feel your joints stiffening.') X`09 else if (petrification < 150) then X`09 msg_print('Your feet are beginning to feel heavy.') X`09 else if (petrification < 200) then X`09 msg_print('Your knees are no longer able to bend.') X`09 else if (petrification < 250) then X`09 msg_print('Your legs feel like blocks of stone.') X`09 else if (petrification < 300) then X`09 msg_print('You are finding it difficult to breathe.') X`09 else X`09 begin X`09 msg_print('You have turned to stone.'); X`09 died_from := 'petrification'; X`09 upon_death; X`09 end; X end; X end; X X`09`7B If too many objects on floor level, delete some of them-RAK-`09`7D X`5Bglobal,psect(misc2$code)`5D procedure compact_objects; X var X`09i1,i2,ctr,cur_dis`09`09: integer; X`09flag`09`09`09`09: boolean; X begin X ctr := 0; X cur_dis := 66; X repeat X`09for i1 := 1 to cur_height do X`09 for i2 := 1 to cur_width do X`09 with cave`5Bi1,i2`5D do X`09 if (tptr > 0) then X`09`09if (distance(i1,i2,char_row,char_col) > cur_dis) then X`09`09 begin X`09`09 flag := false; X`09`09 with t_list`5Btptr`5D do X`09`09 case tval of X`09`09`09Seen_Trap : if (subval in `5B1,6,9`5D) then X`09`09`09`09 flag := true X`09`09`09`09 else if (randint(4) = 1) then X`09`09`09`09 flag := true; X`09`09`09rubble`09 : flag := true; X`09`09`09open_door, closed_door X`09`09`09`09 : if (randint(8) = 1) then flag := true; X`09`09`09up_staircase, down_staircase, X`09`09`09up_steep_staircase, down_steep_staircase, X`09`09`09entrance_to_store : ; X`09`09`09otherwise if (randint(8) = 1) then flag := true; X`09`09 end; X`09`09 if (flag) then X`09`09 begin X`09`09`09fopen := true; X`09`09`09t_list`5Btptr`5D := blank_treasure; X`09`09`09t_list`5Btptr`5D.p1 := tcptr; X`09`09`09tcptr := tptr; X`09`09`09tptr := 0; X`09`09`09ctr := ctr + 1; X`09`09 end; X`09`09 end; X`09 if (ctr = 0) then cur_dis := cur_dis - 6; X`09until (ctr > 0); X`09if (cur_dis < 66) then prt_map; X end; X X X`09`7B Gives pointer to next free space`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure popt(var x : integer); X var X`09i1`09`09`09: integer; X begin X if (tcptr < 1) then compact_objects; X x := tcptr; X tcptr := t_list`5Bx`5D.p1; X end; X X X`09`7B Pushs a record back onto free space list`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure pusht(x : integer); X begin X t_list`5Bx`5D := blank_treasure; X t_list`5Bx`5D.p1 := tcptr; X tcptr := x; X end; X X X`09`7B Order the treasure list by level`09`09`09-RAK-`09`7D X`5Bglobal,psect(setup$code)`5D procedure sort_objects; X var X`09i1,i2,i3,gap`09`09: integer; X`09tmp`09`09`09: treasure_type; X begin X gap := max_objects div 2; X while (gap > 0) do X`09begin X`09 for i1 := gap+1 to max_objects do X`09 begin X`09 i2 := i1 - gap; X`09 while (i2 > 0) do X`09`09begin X`09`09 i3 := i2 + gap; X`09`09 if (object_list`5Bi2`5D.level > object_list`5Bi3`5D.level) then +-+-+-+-+-+-+-+- END OF PART 44 +-+-+-+-+-+-+-+-