-+-+-+-+-+-+-+-+ START OF PART 48 -+-+-+-+-+-+-+-+ X`09`09`09`09 name := name + ' of Slay Monster'; X`09`09`09`09 cost := cost + 3000; X`09`09`09`09 end; X`09`09`09 10`09 :begin X`09`09`09`09 flags := uor(flags,slay_dragon_worn_bit); X`09`09`09`09 tohit := tohit + 10; X`09`09`09`09 todam := todam + 10; X`09`09`09`09 name := name + ' of Dragon Slaying'; X`09`09`09`09 cost := cost + 3500; X`09`09`09`09 end; X`09`09`09`09 end; `7BCASE 2`7D X`09`09 otherwise ; X`09`09`09 end;`09`7BCASE 1`7D X`09`09 end X`09`09 else if (magik(cursed)) then X`09`09 begin X`09`09`09tohit := -m_bonus(5,55,level); X`09`09`09todam := -m_bonus(5,55,level); X`09`09`09flags := uor(cursed_worn_bit,flags); X`09`09`09cost := 0; X`09`09 end; X`09`09 number := 0; X`09`09 for i1 := 1 to 7 do number := number + randint(6); X`09`09 missle_ctr := missle_ctr + 1; X`09`09 if (missle_ctr > 65534) then X`09`09 missle_ctr := 1; X`09`09 subval := missle_ctr + 512; X`09`09 end; X`09 otherwise ; X`09 end X end; X X X`09`7B Places a particular trap at location y,x`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure place_trap(y,x,typ,subval : integer V); X var X`09cur_pos`09`09`09: integer; X`09cur_trap`09`09: treasure_type; X begin X if (typ = 1) then X`09cur_trap := trap_lista`5Bsubval`5D X else X`09cur_trap := trap_listb`5Bsubval`5D; X popt(cur_pos); X cave`5By,x`5D.tptr := cur_pos; X t_list`5Bcur_pos`5D := cur_trap; X end; X X X`09`7B Places rubble at location y,x`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure place_rubble(y,x : integer); X var X`09cur_pos`09`09`09: integer; X begin X popt(cur_pos); X with cave`5By,x`5D do X`09begin X`09 tptr := cur_pos; X`09 fopen := false; X`09end; X t_list`5Bcur_pos`5D := some_rubble; X end; X X X`5Bglobal,psect(misc4$code)`5D procedure place_open_door(y,x : integer); X var X`09cur_pos`09`09`09: integer; X begin X popt(cur_pos); X with cave`5By,x`5D do X begin X`09tptr := cur_pos; X`09t_list`5Bcur_pos`5D := door_list`5B1`5D; X`09fval := corr_floor3.ftval; X`09fopen := true; X end; X end; X X X`5Bglobal,psect(misc4$code)`5D procedure place_broken_door(y,x : integer); X var X`09cur_pos`09`09`09: integer; X begin X popt(cur_pos); X with cave`5By,x`5D do X begin X`09tptr := cur_pos; X`09t_list`5Bcur_pos`5D := door_list`5B1`5D; X`09fval := corr_floor3.ftval; X`09fopen := true; X`09t_list`5Bcur_pos`5D.p1 := 1; X end; X end; X X X`5Bglobal,psect(misc4$code)`5D procedure place_closed_door(y,x : integer); X var X`09cur_pos`09`09`09: integer; X begin X popt(cur_pos); X with cave`5By,x`5D do X begin X`09tptr := cur_pos; X`09t_list`5Bcur_pos`5D := door_list`5B2`5D; X`09fval := corr_floor3.ftval; X`09fopen := false; X end; X end; X X X`5Bglobal,psect(misc4$code)`5D procedure place_locked_door(y,x : integer); X var X`09cur_pos`09`09`09: integer; X begin X popt(cur_pos); X with cave`5By,x`5D do X begin X`09tptr := cur_pos; X`09t_list`5Bcur_pos`5D := door_list`5B2`5D; X`09fval := corr_floor3.ftval; X`09fopen := false; X`09t_list`5Bcur_pos`5D.p1 := randint(10) + 10; X end; X end; X X X`5Bglobal,psect(misc4$code)`5D procedure place_stuck_door(y,x : integer); X var X`09cur_pos`09`09`09: integer; X begin X popt(cur_pos); X with cave`5By,x`5D do X begin X`09tptr := cur_pos; X`09t_list`5Bcur_pos`5D := door_list`5B2`5D; X`09fval := corr_floor3.ftval; X`09fopen := false; X`09t_list`5Bcur_pos`5D.p1 := -randint(10) - 10; X end; X end; X X X`5Bglobal,psect(misc4$code)`5D procedure place_secret_door(y,x : integer); X var X`09cur_pos`09`09`09: integer; X begin X popt(cur_pos); X with cave`5By,x`5D do X begin X`09tptr := cur_pos; X`09t_list`5Bcur_pos`5D := door_list`5B3`5D; X`09fval := corr_floor4.ftval; X`09fopen := false; X end; X end; X X X`5Bglobal,psect(misc4$code)`5D procedure place_door(y,x : integer); X var X`09cur_pos`09`09`09: integer; X begin X case randint(3) of X 1 : case randint(4) of X`09 1`09`09: place_broken_door(y,x); X`09 otherwise`09 place_open_door(y,x); X`09 end; X 2 : case randint(12) of X`09 1,2`09`09: place_locked_door(y,x); X`09 3`09`09: place_stuck_door(y,x); X`09 otherwise`09 place_closed_door(y,x); X`09 end; X 3 : place_secret_door(y,x); X end; X end; X X X`09`7B Place an up staircase at given y,x`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure place_a_staircase(y,x,typ : integer V); X var X`09cur_pos`09`09`09`09: integer; X begin X with cave`5By,x`5D do X`09if (tptr <> 0) then X`09 begin X`09 pusht(tptr); X`09 tptr := 0; X`09 fopen := true; X`09 end; X popt(cur_pos); X cave`5By,x`5D.tptr := cur_pos; X case (typ) of X`09up_staircase : t_list`5Bcur_pos`5D := up_stair; X`09down_staircase : t_list`5Bcur_pos`5D := down_stair; X`09up_steep_staircase : t_list`5Bcur_pos`5D := up_steep; X`09down_steep_staircase : t_list`5Bcur_pos`5D := down_steep; X end; X end; X X`09`7B Places a staircase 1=up, 2=down`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure place_stairs(typ,num,walls : intege Vr); X var X`09i1,i2,y1,x1,y2,x2`09`09: integer; X`09flag`09`09`09`09: boolean; X begin X for i1 := 1 to num do X`09 begin X`09 flag := false; X`09 repeat X`09 i2 := 0; X`09 repeat X`09`09y1 := randint(cur_height - 12); X`09`09x1 := randint(cur_width`09 - 12); X`09`09y2 := y1 + 12; X`09`09x2 := x1 + 12; X`09`09repeat X`09`09 repeat X`09`09 with cave`5By1,x1`5D do X`09`09 if (fval in `5B1,2,4`5D) then X`09`09`09if (tptr = 0) then X`09`09`09 if (next_to4(y1,x1,wall_set) >= walls) then X`09`09`09 begin X`09`09`09 flag := true; X`09`09`09 place_a_staircase(y1,x1,typ); X`09`09`09 end; X`09`09 x1 := x1 + 1; X`09`09 until ((x1 = x2) or (flag)); X`09`09 x1 := x2 - 12; X`09`09 y1 := y1 + 1; X`09`09until ((y1 = y2) or (flag)); X`09`09i2 := i2 + 1; X`09 until ((flag) or (i2 > 30)); X`09 walls := walls - 1; X`09 until(flag); X`09 end; X end; X X X`09`7B Places a treasure (Gold or Gems) at given row, column -RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure place_gold(y,x : integer); X var X`09cur_pos,i1`09`09: integer; X begin X popt(cur_pos); X i1 := (2+randint(dun_level+4)+randint(dun_level+4)) div 4; X if (randint(obj_great) = 1) then X`09i1 := i1 + randint(dun_level); X if (i1 > max_gold) then X`09i1 := max_gold + 1 - randint(randint(3)); X cave`5By,x`5D.tptr := cur_pos; X t_list`5Bcur_pos`5D := gold_list`5Bi1`5D; X with t_list`5Bcur_pos`5D do X`09if (tval = valuable_metal) then X`09 number := randint(number) + number div 2; X end; X X X`09`7B Returns the array number of a random object`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D function get_obj_num(level : integer) : integ Ver; X var X`09i1`09: integer; X begin X if (level > max_obj_level) then level := max_obj_level; X if (randint(obj_great) = 1) then level := max_obj_level; X if (level = 0) then X`09i1 := randint(t_level`5B0`5D) X else X`09i1 := randint(t_level`5Blevel`5D); X get_obj_num := i1; X end; X X X X`09`7B Places an object at given row, column co-ordinate`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure place_object(y,x : integer); X var X`09cur_pos`09`09`09`09: integer; X`09mag1,mag2`09`09`09: integer; X begin X popt(cur_pos); X cave`5By,x`5D.tptr := cur_pos; X t_list`5Bcur_pos`5D := object_list`5Bget_obj_num(dun_level)`5D; X magic_treasure(cur_pos,dun_level); X end; X X X`09`7B Allocates an object for tunnels and rooms`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure alloc_object ( X`09`09`09alloc_set`09:`09obj_set; X`09`09`09typ,num`09`09:`09integer X`09`09`09`09`09`09); X var X`09i1,i2,i3`09`09: integer; X begin X for i3 := 1 to num do X`09begin X`09 repeat X`09 i1 := randint(cur_height); X`09 i2 := randint(cur_width); X`09 until ((cave`5Bi1,i2`5D.fval in alloc_set) and X`09`09 (cave`5Bi1,i2`5D.tptr = 0)); X`09 case typ of X`09 1 : place_trap(i1,i2,1,randint(max_trapa)); X`09 2 : place_trap(i1,i2,2,randint(max_trapb)); X`09 3 : place_rubble(i1,i2); X`09 4 : place_gold(i1,i2); X`09 5 : place_object(i1,i2); X`09 end X`09end X end; X X X`09`7B Creates objects nearby the coordinates given`09`09-RAK-`09`7D X`5Bglobal,psect(misc4$code)`5D procedure random_object(y,x,num : integer); X var X`09i1,i2,i3`09`09: integer; X begin X repeat X`09i1 := 0; X`09repeat X`09 i2 := y - 3 + randint(5); X`09 i3 := x - 4 + randint(7); X`09 with cave`5Bi2,i3`5D do X`09 if (fval in floor_set) then X`09 if (tptr = 0) then X`09`09begin X`09`09 if (randint(100) < 75) then X`09`09 place_object(i2,i3) X`09`09 else X`09`09 place_gold(i2,i3); X`09`09 i1 := 9; X`09`09end; X`09 i1 := i1 + 1; X`09until (i1 > 10); X`09num := num - 1; X until (num = 0); X end; X X X`09`7B Converts stat num into string`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc5$code)`5D procedure cnv_stat ( X`09`09`09stat`09`09:`09byteint; X`09`09`09var out_val`09:`09stat_type X`09`09`09`09`09); X var X`09tmp_str`09`09`09`09: vtype; X`09part1,part2`09`09`09: integer; X begin X if (stat > 150) then X`09begin X`09 part1 := 18; X`09 part2 := stat - 150; X`09 writev(tmp_str,part1:2,'/',part2:1); X`09end X else X`09writev(tmp_str,(3+(stat div 10)):2); X if (length(tmp_str) < 6) then tmp_str := pad(tmp_str,' ',6); X out_val := tmp_str; X end; X X`5Bglobal,psect(misc5$code)`5D function spell_adj(attr : stat_set) : integer V; X begin X with py.stat do X`09if (c`5Battr`5D >249) then spell_adj := 7 X`09else if (c`5Battr`5D > 239) then spell_adj := 6 X`09else if (c`5Battr`5D > 219) then spell_adj := 5 X`09else if (c`5Battr`5D > 199) then spell_adj := 4 X`09else if (c`5Battr`5D > 149) then spell_adj := 3 X`09else if (c`5Battr`5D > 109) then spell_adj := 2 X`09else if (c`5Battr`5D > 39) then spell_adj := 1 X`09else spell_adj := 0 X end; X X`5Bglobal,psect(misc2$code)`5D function bard_adj : integer; X begin X`09bard_adj := (spell_adj(ca) +spell_adj(dx) + 1) div 2; X end; X X`5Bglobal,psect(misc2$code)`5D function druid_adj : integer; X begin X`09druid_adj := (spell_adj(ca) + spell_adj(ws) + 1) div 2; X end; X X`5Bglobal,psect(misc2$code)`5D function monk_adj : integer; X begin X`09monk_adj := (spell_adj(iq) + spell_adj(ws) + 1) div 2; X end; X X`09`7B Adjustment for charisma`09`09`09`09-RAK-`09`7D X`09`7B Percent decrease or increase in price of goods`09`09`7D X`5Bglobal,psect(misc2$code)`5D function chr_adj : real; X`09var i1 : integer; X begin X with py.stat do X`09if (c`5Bca`5D > 249) then chr_adj := -0.10 X`09else if (c`5Bca`5D > 239) then chr_adj := -0.08 X`09else if (c`5Bca`5D > 219) then chr_adj := -0.06 X`09else if (c`5Bca`5D > 199) then chr_adj := -0.04 X`09else if (c`5Bca`5D > 150) then chr_adj := -0.02 X`09else if (c`5Bca`5D >= 100) then chr_adj := 0.15 - (c`5Bca`5D div 10)/100 X`09else chr_adj := 0.25 - (c`5Bca`5D div 10)/50; X end; X X`09`7B Returns a character's adjustment to hit points`09-JWT-`09`7D X`5Bglobal,psect(misc2$code)`5D function con_adj : integer; X begin X with py.stat do X if (c`5Bcn`5D <`0910) then con_adj := -4 X else if (c`5Bcn`5D <`0920) then con_adj := -3 X else if (c`5Bcn`5D <`0930) then con_adj := -2 X else if (c`5Bcn`5D <`0940) then con_adj := -1 X else if (c`5Bcn`5D < 140) then con_adj := 0 X else if (c`5Bcn`5D < 150) then con_adj := 1 X else if (c`5Bcn`5D < 226) then con_adj := 2 X else if (c`5Bcn`5D < 299) then con_adj := 3 X else`09`09`09con_adj := 4 X end; X X`09`7B Calculates hit points for each level that is gained.`09-RAK-`09`7D X`5Bglobal,psect(misc2$code)`5D function get_hitdie : integer; X var X`09i1`09: integer; X begin X get_hitdie := randint(py.misc.hitdie) + con_adj; X end; X X`09`7B Return the ending to a number string (1st, 2nd, etc)`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function place_string(num : integer) : string V; X var X`09out`09: string; X begin X case num of X`091 : writev(out,num:1,'st'); X`092 : writev(out,num:1,'nd'); X`093 : writev(out,num:1,'rd'); X`09otherwise X`09 begin X`09 if (num < 20) X`09 then writev(out,num:1,'th') X`09 else case num mod 10 of X`09`09 1 : writev(out,num:1,'st'); X`09`09 2 : writev(out,num:1,'nd'); X`09`09 3 : writev(out,num:1,'rd'); X`09`09 otherwise writev(out,num:1,'th'); X`09`09 end; X`09 end; X end; X place_string := out; X end; X X X`09`7B Return first X characters of day of week`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function day_of_week_string( X`09day`09: integer; X`09wid`09: integer) : string; X begin X case (day mod 7) of X`090 : day_of_week_string := substr('Saturday ',1,wid); X`091 : day_of_week_string := substr('Sunday ',1,wid); X`092 : day_of_week_string := substr('Monday ',1,wid); X`093 : day_of_week_string := substr('Tuesday ',1,wid); X`094 : day_of_week_string := substr('Wednesday ',1,wid); X`095 : day_of_week_string := substr('Thursday ',1,wid); X`096 : day_of_week_string := substr('Friday ',1,wid); X end; X end; X X X`09`7B Return the name of a numbered month`09`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function month_string(mon : integer) : string V; X begin X case mon of X`091 : month_string := 'January'; X`092 : month_string := 'February'; X`093 : month_string := 'March'; X`094 : month_string := 'April'; X`095 : month_string := 'May'; X`096 : month_string := 'June'; X`097 : month_string := 'July'; X`098 : month_string := 'August'; X`099 : month_string := 'September'; X`0910 : month_string := 'October'; X`0911 : month_string := 'November'; X`0912 : month_string := 'December'; X`0913 : month_string := 'Moria'; X end; X end; X X X`09`7B Return the time in the format HH:MM`09`09`09-DMF-`09`7D X`5Bglobal,psect(misc5$code)`5D function time_string( +-+-+-+-+-+-+-+- END OF PART 48 +-+-+-+-+-+-+-+-