-+-+-+-+-+-+-+-+ START OF PART 42 -+-+-+-+-+-+-+-+ X 1 : take_hit(trunc(dam*0.75),kb_str); X 2 : take_hit(trunc(dam*0.5),kb_str); X 3 : take_hit(trunc(dam*0.25),kb_str); X END; X print_stat := uor(%X'00C0',print_stat); X if (inven_damage(`5B1,2,11,12,20,21,22,30,31,32,36`5D,3) > 0) then X msg_print('There is an acrid smell coming from your pack!'); X END; X`20 X`20 X`7B Teleport the player to a new location `7D X procedure teleport(dis : integer); X var X y,x : integer; X BEGIN X repeat X y := randint(cur_height); X x := randint(cur_width); X while (distance(y,x,char_row,char_col) > dis) do X BEGIN X y := y + trunc((char_row-y)/2); X x := x + trunc((char_col-x)/2); X END; X until ((cave`5By,x`5D.fopen) and (cave`5By,x`5D.cptr < 2)); X move_rec(char_row,char_col,y,x); X for i1 := char_row-1 to char_row+1 do X for i2 := char_col-1 to char_col+1 do X with cave`5Bi1,i2`5D do X BEGIN X tl := false; X if (not(test_light(i1,i2))) then X unlite_spot(i1,i2); X END; X if (test_light(char_row,char_col)) then X lite_spot(char_row,char_col); X char_row := y; X char_col := x; X move_char(5); X creatures(false); X teleport_flag := false; X END; X `20 X`20 X`7B Player hit a trap... (Chuckle)`7D X procedure hit_trap(var y,x : integer); X var X alloc_level,i1,i2,ty,tx,dam : integer; X X BEGIN X change_trap(y,x); X lite_spot(char_row,char_col); X find_flag := false; X with cave`5By,x`5D do X with py.misc do X BEGIN X dam := damroll(t_list`5Btptr`5D.damage); X CASE t_list`5Btptr`5D.subval of X`7B Open pit`7D 1 : BEGIN X msg_print('You fell into a pit!'); X if (py.flags.ffall) then X msg_print('You gently float down.') X else X take_hit(dam,'an open pit.'); X END; X`7B Arrow trap`7D 2 : BEGIN X if (test_hit(125,0,0,pac+ptoac)) then X BEGIN X take_hit(dam,'an arrow trap.'); X msg_print('An arrow hits you.'); X END X else X msg_print('An arrow barely misses you.'); X END; X`7B Covered pit`7D3 : BEGIN X msg_print('You fell into a covered pit.'); X if (py.flags.ffall) then X msg_print('You gently float down.') X else X take_hit(dam,'a covered pit.'); X place_trap(y,x,2,1); X END; X`7B Trap door`7D 4 : BEGIN X msg_print('You fell through a trap door!'); X msg_print(' '); X moria_flag := true; X dun_level := dun_level + 1; X if (dun_level > 1200) then dun_level := 1200; X if (py.flags.ffall) then X msg_print('You gently float down.') X else X take_hit(dam,'a trap door.'); X END; X`7B Sleep gas`7D 5 : if (py.flags.paralysis = 0) then X BEGIN X msg_print('A strange white mist surrounds you!'); X if (py.flags.free_act) then X msg_print('You are unaffected.') X else X BEGIN X msg_print('You fall asleep.'); X py.flags.paralysis := py.flags.paralysis + X randint(10) + 4; X END X END; X`7B Hid Obj`7D 6 : BEGIN X fm := false; X pusht(tptr); X place_object(y,x); X msg_print('Hmmm, there was something under this rock.'); X END; X `7B STR Dart`7D 7 : BEGIN X if (test_hit(125,0,0,pac+ptoac)) then X BEGIN X if (not py.flags.sustain_str) then X BEGIN X py.stat.cstr := de_statp(py.stat.cstr); X take_hit(dam,'a dart trap.'); X print_stat := uor(%X'0001',print_stat); X msg_print('A small dart weakens you!'); X END X else X msg_print('A small dart hits you.'); X END X else X msg_print('A small dart barely misses you.'); X END; X`7B Teleport`7D 8 : BEGIN X teleport_flag := true; X msg_print('You hit a teleport trap!'); X END; X`7B Rockfall`7D 9 : BEGIN X take_hit(dam,'falling rock.'); X pusht(tptr); X place_rubble(y,x); X msg_print('You are hit by falling rock'); X END; X`7B Corrode gas`7D10: BEGIN X corrode_gas('corrosion gas.'); X msg_print('A strange red gas surrounds you.'); X END; X`7B Summon mon`7D 11: BEGIN X fm := false; `7B Rune disappears...`7D X pusht(tptr); X tptr := 0; X for i1 := 1 to (2+randint(3)) do X BEGIN X ty := char_row; X tx := char_col; X summon_monster(ty,tx,false); X END; X END; X`7B Fire trap`7D 12: BEGIN X fire_dam(dam,'a fire trap.'); X msg_print('You are enveloped in flames!'); X END; X`7B Acid trap`7D 13: BEGIN X acid_dam(dam,'an acid trap.'); X msg_print('You are splashed with acid!'); X END; X`7B Poison gas`7D 14: BEGIN X poison_gas(dam,'a poison gas trap.'); X msg_print('A pungent green gas surrounds you!'); X Opusii_vomit(5); X END; X`7B Blind Gas `7D 15: BEGIN X msg_print('A black gas surrounds you!'); X with py.flags do X blind := blind + randint(50) + 50; X END; X`7B H-Bomb `7D 16: begin `20 X take_hit(dam,'a bomb.'); X msg_print('You have set off a bomb!'); X msg_print('The Earth shakes ...'); X msg_print('Rocks fly all around you ...'); X with py.flags do X begin X blind := 1 + randint(10); X confused := 5 + randint(10); X end X end; X`7B Slow Dart`7D 17: BEGIN X if (test_hit(125,0,0,pac+ptoac)) then X BEGIN X take_hit(dam,'a dart trap.'); X msg_print('A small dart hits you!'); X with py.flags do X slow := slow + randint(20) + 10; X END X else X msg_print('A small dart barely misses you.'); X END; X`7B CON Dart`7D 18: BEGIN X if (test_hit(125,0,0,pac+ptoac)) then X BEGIN X if (not py.flags.sustain_con) then X BEGIN X py.stat.ccon := de_statp(py.stat.ccon); X take_hit(dam,'a dart trap.'); X print_stat := uor(%X'0004',print_stat); X msg_print('A small dart weakens you!'); X END X else X msg_print('A small dart hits you.'); X END X else X msg_print('A small dart barely misses you.'); X END; X X`7BSecret Door`7D 19: ; `20 X X`7BTeleport levels`7D20: begin X msg_print('You have a strange feeling...'); X msg_print('You slip into unconsciousness...'); X py.flags.paralysis := py.flags.paralysis+4+randint(4) V; X msg_print('You wake up confused.'); X py.flags.confused := py.flags.confused+10+randint(20) V; X case randint(2) of X 1: dun_level := dun_level + 5; X 2: dun_level := dun_level - 5; X end; X if (dun_level<0) then dun_level := 0; X if (dun_level>1200) then dun_level := 1200; X moria_flag := true; X end; X X X X`7BScare Mon`7D 99: ;`20 X X`20 X`7BTown level traps are special, the stores.`7D X`7BGeneral `7D 101: enter_store(1); X`7BArmory `7D 102: enter_store(2); X`7BWeaponsmith`7D 103: enter_store(3); X`7BTemple `7D 104: enter_store(4); X`7BAlchemy`7D 105: enter_store(5); X`7BMagic-User `7D 106: enter_store(6); X`7BBlack Market`7D 107: enter_store(7); X X otherwise msg_print('Unknown trap value'); X END X END X END; X`20 X `20 X`7B Return spell number and failure chance `7D X function cast_spell(prompt : vtype; X item_val : integer; X var sn,sc : integer; X var redraw: boolean) : boolean; X var X i2 : unsigned; X i1,i3 : integer; X spell : spl_type; X BEGIN `20 X i1 := 0; X i2 := inventory`5Bitem_val`5D.flags; X repeat X`09 i3 := bit_pos (i2); X if (class`5Bpy.misc.pclass`5D.mspell) then X if (i3 > 0) then X with mage_spell`5Bpy.misc.pclass,i3`5D do X if (slevel <= py.misc.lev) then X if (learned) then X BEGIN X i1 := i1 + 1; X spell`5Bi1`5D.splnum := i3; X END; X if (class`5Bpy.misc.pclass`5D.pspell) then X if (i3 > 0) then X with priest_spell`5Bpy.misc.pclass,i3`5D do X if (slevel <= py.misc.lev) then X if (learned) then X BEGIN X i1 := i1 + 1; X spell`5Bi1`5D.splnum := i3; X END; X if (class`5Bpy.misc.pclass`5D.espell) then X if (i3 > 0) then X with extra_spell`5Bpy.misc.pclass,i3`5D do X if (slevel <= py.misc.lev) then X if (learned) then X BEGIN X i1 := i1 + 1; X spell`5Bi1`5D.splnum := i3; X END; X X until(i2 = 0); X if (i1 > 0) then X cast_spell := get_spell(spell,i1,sn,sc,prompt,redraw); X if (redraw) then X draw_cave; X END; X`20 X`20 X`7B Finds range of item in inventory list `7D X function find_range(item_val : obj_set; var i2,i3 : integer) : boolean; X var X i1 : integer; X flag: boolean; X BEGIN X i1 := 0; X i2 := 0; X i3 := 0; X flag := false; X while(i1 < inven_ctr) do X BEGIN X i1 := i1 + 1; X if ((inventory`5Bi1`5D.tval in item_val) and (not (flag))) then X BEGIN X flag := true; X i2 := i1; X END; X if ((not(inventory`5Bi1`5D.tval in item_val)) and (flag) and X (i3 = 0)) th Ven X i3 := i1 - 1; X END; X if ((flag) and (i3 = 0)) then X i3 := inven_ctr; X find_range := flag; X END; X`20 X`20 X`7B Examine a Book `7D X procedure examine_book; X var X i2 : unsigned; X i1,i3,item_val : integer; X redraw,flag : boolean; X dummy : char; X out_val : vtype; X BEGIN X redraw := false; X if (not(find_range(`5B90,91,92`5D,i1,i3))) then X msg_print('You are not carrying any books.') X else if (get_item(item_val,'Which Book?',redraw,i1,i3)) then X BEGIN X flag := true; X with inventory`5Bitem_val`5D do X if (class`5Bpy.misc.pclass`5D.mspell) then X BEGIN X if (tval <> 90) then X BEGIN X msg_print('You do not understand the language.'); X flag := false; X END; X END X else if (class`5Bpy.misc.pclass`5D.pspell) then X BEGIN X if (tval <> 91) then X BEGIN X msg_print('You do not understand the language.'); X flag := false; X END;`20 X END X else if (class`5Bpy.misc.pclass`5D.espell) then X BEGIN X if (tval <> 92) then X BEGIN X msg_print('You do not understand the language.'); X flag := false; X END; X END X else X BEGIN X msg_print('You do not understand the language.'); X flag := false; X END; X X X if (flag) then X BEGIN X redraw := true; X i1 := 0; X i2 := inventory`5Bitem_val`5D.flags; X clear(1,1); X writev(out_val,' Name Level Mana Known' V); X prt(out_val,1,1); +-+-+-+-+-+-+-+- END OF PART 42 +-+-+-+-+-+-+-+-