-+-+-+-+-+-+-+-+ START OF PART 43 -+-+-+-+-+-+-+-+ X`09`09`09begin X`09`09`09 tbth := py.misc.bthb; X`09`09`09 tpth := tpth + inventory`5B23`5D.tohit; X`09`09`09 tdam := tdam + 4; X`09`09`09 tdis := 35; X`09`09`09end; X`09`09end X`09 end; X`09end; X X procedure drop_throw(y,x : integer); X`09var X`09`09i1,i2,i3,cur_pos`09`09: integer; X`09`09flag`09`09`09`09: boolean; X`09`09out_val`09`09`09`09: vtype; X`09begin X`09 flag := false; X`09 i1 := y; X`09 i2 := x; X`09 i3 := 0; X`09 if (randint(10) > 1) then X`09 repeat X`09 if (in_bounds(i1,i2)) then X`09 with cave`5Bi1,i2`5D do X`09`09 if (fopen) then X`09`09 if (tptr = 0) then X`09`09 flag := true; X`09 if (not(flag)) then X`09`09begin X`09`09 i1 := y + randint(3) - 2; X`09`09 i2 := x + randint(3) - 2; X`09`09 i3 := i3 + 1; X`09`09end; X`09 until((flag) or (i3 > 9)); X`09 if (flag) then X`09 begin X popt(cur_pos); X`09 cave`5Bi1,i2`5D.tptr := cur_pos; X`09 t_list`5Bcur_pos`5D := inventory`5Binven_max`5D; X`09 if (test_light(i1,i2)) then X`09`09lite_spot(i1,i2); X`09 end X`09 else X`09 begin X`09 objdes(out_val,inven_max,false); X`09 msg_print('The ' + out_val + ' dissapears.'); X`09 end; X`09end; X X begin X`09redraw := false; X`09if (inven_ctr = 0) then X`09 msg_print('But you are not carrying anything.') X`09else if (get_item(item_val,'Fire/Throw which one?', X`09`09`09`09`09`09redraw,1,inven_ctr)) then X`09 begin X`09 if (redraw) then X`09 draw_cave; X`09 y_dumy := char_row; X`09 x_dumy := char_col; X`09 if (get_dir('Which direction?',dir,dumy,y_dumy,x_dumy)) then X`09 begin X`09`09desc_remain(item_val); X`09`09if (py.flags.confused > 0) then X`09`09 begin X`09`09 msg_print('You are confused...'); X`09`09 repeat X`09`09 dir := randint(9); X`09`09 until(dir <> 5); X`09`09 end; X`09`09inven_throw(item_val); X`09`09facts(tbth,tpth,tdam,tdis); X`09`09with inventory`5Binven_max`5D do X`09`09 begin X`09`09 flag := false; X`09`09 y := char_row; X`09`09 x := char_col; X`09`09 oldy := char_row; X`09`09 oldx := char_col; X`09`09 cur_dis := 0; X`09`09 repeat X`09`09 move(dir,y,x); X`09`09 cur_dis := cur_dis + 1; X`09`09 if (test_light(oldy,oldx)) then X`09`09 lite_spot(oldy,oldx); X`09`09 if (cur_dis > tdis) then flag := true; X`09`09 with cave`5By,x`5D do X`09`09 begin X`09`09`09 if ((fopen) and (not(flag))) then X`09`09`09 begin X`09`09`09 if (cptr > 1) then X`09`09`09 begin X`09`09`09`09 flag := true; X`09`09`09`09 with m_list`5Bcptr`5D do X`09`09`09`09 begin X`09`09`09`09 tbth := tbth - cur_dis; X`09`09`09`09 if (test_hit(tbth,py.misc.lev,tpth, X`09`09`09`09`09`09`09c_list`5Bmptr`5D.ac)) then X`09`09`09`09 begin X`09`09`09`09 i1 := mptr; X`09`09`09`09`09 objdes(out_val,inven_max,false); X`09msg_print('The ' + out_val + ' hits the ' + c_list`5Bi1`5D.name + '.'); X`09tdam := tot_dam(inventory`5Binven_max`5D,tdam,c_list`5Bi1`5D); X`09with inventory`5Binven_max`5D do X`09 tdam := critical_blow(weight,tpth,tdam); X`09i1 := mon_take_hit(cptr,tdam); X`09if (i1 > 0) then X`09 msg_print('You have killed the ' + c_list`5Bi1`5D.name + '.'); X`09`09`09`09 end X`09`09`09`09 else X`09`09`09`09 drop_throw(oldy,oldx); X`09`09`09`09 end; X`09`09`09 end X`09`09`09 else X`09`09`09 begin X`09`09`09`09 if (panel_contains(y,x)) then X`09`09`09`09 if (test_light(y,x)) then X`09`09`09`09 print(tchar,y,x); X`09`09`09 end; X`09`09`09 end X`09`09`09 else X`09`09`09 begin X`09`09`09 flag := true; X`09`09`09 drop_throw(oldy,oldx); X`09`09`09 end; X`09`09 end; X`09`09 oldy := y; X`09`09 oldx := x; X`09 until (flag); X`09`09 end; X`09 end X`09 end X`09else X`09 if (redraw) then X`09 draw_cave; X end; X X X`09`7B Bash open a door or chest`09`09`09`09-RAK-`09`7D X`09`7B Note: Affected by strength and weight of character`09`09`7D X procedure bash; X var X`09y,x,tmp`09`09`09`09`09: integer; X`09old_ptodam,old_ptohit,old_bth`09`09: integer; X begin X`09y := char_row; X`09x := char_col; X`09if (get_dir('Which direction?',tmp,tmp,y,x)) then X`09 begin X`09 with cave`5By,x`5D do X`09 if (cptr > 1) then X`09`09begin X`09`09 if (py.flags.afraid > 0) then X`09`09 msg_print('You are afraid!') X`09`09 else`20 X`09`09 begin X`09`09`09`7B Save old values of attacking`09`7D X`09`09 inventory`5Binven_max`5D := inventory`5B23`5D; X`09`09 old_ptohit := py.misc.ptohit; X`09`09 old_ptodam := py.misc.ptodam; X`09`09 old_bth := py.misc.bth; X`09`09`09`7B Use these values`09`09`7D X`09`09 inventory`5B23`5D := blank_treasure; X`09`09 with inventory`5B23`5D do X`09`09`09begin X`09`09`09 damage := inventory`5B27`5D.damage; X`09`09`09 weight := py.stat.cstr; X`09`09`09 tval := 1; X`09`09`09end; X`09`09 with py do X`09`09`09begin X`09`09 misc.bth := trunc((stat.cstr+misc.wt)/6.0); X`09`09 misc.ptohit := 0; X`09`09`09 misc.ptodam := trunc(misc.wt/75.0) + 1; X`09`09`09end; X`09`09 if (py_attack(y,x)) then X`09`09`09with m_list`5Bcptr`5D do X`09`09`09 begin X`09`09`09 stuned := randint(2) + 1; X`09`09`09 if (stuned > 24) then stuned := 24; X`09`09`09 msg_print('The ' + c_list`5Bmptr`5D.name X`09`09`09`09`09+ ' appears stunned!'); X`09`09`09end; X`09`09`09`7B Restore old values`09`09`7D X`09`09 inventory`5B23`5D := inventory`5Binven_max`5D; X`09`09 py.misc.ptohit := old_ptohit; X`09`09 py.misc.ptodam := old_ptodam; X`09`09 py.misc.bth := old_bth; X`09`09 if (randint(140) > py.stat.cdex) then X`09`09`09begin X`09`09`09 msg_print('You are off-balance.'); X`09`09`09 py.flags.paralysis := randint(3); X`09`09`09end; X`09`09 end; X`09`09end X`09 else if (tptr > 0) then X`09`09with t_list`5Btptr`5D do X`09 if (tval = 105) then X`09`09 begin X`09`09 msg_print('You smash into the door!'); X`09`09 with py do X`09`09 if (test_hit(misc.wt+stat.cstr,0,0,abs(p1)+150)) then X`09`09`09 begin X`09`09`09 msg_print('The door crashes open!'); X`09`09 t_list`5Btptr`5D := door_list`5B1`5D; X`09`09`09 p1 := 1; X`09`09 fopen := true; X`09`09 lite_spot(y,x); X`09 end X`09`09 else X`09`09`09 begin X`09`09`09 msg_print('The door holds firm.'); X`09`09`09 py.flags.paralysis := 2; X`09`09`09 end; X`09`09 end X`09`09 else if (tval = 2) then X`09`09 begin X`09`09 if (randint(10) = 1) then X`09`09`09begin X`09`09`09 msg_print('You have destroyed the chest...'); X`09`09`09 msg_print('and it''s contents!'); X`09`09`09 name := '& ruined chest'; X`09`09`09 flags := 0; X`09`09`09end X`09`09 else if (uand(%X'00000001',flags) <> 0) then X`09`09`09if (randint(10) = 1) then X`09`09`09 begin X`09`09`09 msg_print('The lock breaks open!'); X`09`09`09 flags := uand(%X'FFFFFFFE',flags); X`09`09`09 end; X`09`09 end X`09 else X`09 msg_print('I do not see anything you can bash there.') X`09 else X`09 msg_print('I do not see anything you can bash there.'); X`09 end; X end; X X X`09`7B Jam a closed door`09`09`09`09`09-RAK-`09`7D X procedure jamdoor; X var X`09`09y,x,tmp`09`09: integer; X begin X`09y := char_row; X`09x := char_col; X`09if (get_dir('Which direction?',tmp,tmp,y,x)) then X`09 begin X`09 with cave`5By,x`5D do X`09 if (tptr > 0) then X`09`09with t_list`5Btptr`5D do X`09 if (tval = 105) then X`09`09 if (cptr = 0) then X`09`09 begin X`09`09`09if (find_range(`5B13`5D,i1,i2)) then X`09`09`09 begin X`09`09`09 msg_print('You jam the door with a spike.'); X`09`09`09 with inventory`5Bi1`5D do X`09`09`09 if (number > 1) then X`09`09`09`09number := number - 1 X`09`09`09 else X`09`09`09`09inven_destroy(i1); X`09`09`09 p1 := -abs(p1) - 20; X`09`09`09 end X`09`09`09else X`09`09`09 msg_print('But you have no spikes...'); X`09`09 end X`09`09 else X`09`09 msg_print('The ' + c_list`5Bm_list`5Bcptr`5D.mptr`5D.name + X`09`09`09`09' is in your way!') X`09 else if (tval = 104) then X`09`09 msg_print('The door must be closed first.') X`09`09 else X`09 msg_print('That isn''t a door!') X`09 else X`09 msg_print('That isn''t a door!'); X`09 end; X end; X X X`09`7B Refill the players lamp`09`09`09`09-RAK-`09`7D X procedure refill_lamp; X var X`09i1,i2,i3`09`09`09: integer; X`09out_val`09`09`09`09: vtype; X begin X`09i3 := inventory`5B33`5D.subval; X`09if ((i3 > 0) and (i3 < 10)) then X`09 if (find_range(`5B77`5D,i1,i2)) then X`09 begin X`09 msg_print('Your lamp is full.'); X`09 with inventory`5B33`5D do X`09`09begin X`09 p1 := p1 + inventory`5Bi1`5D.p1; X`09`09 if (p1 > obj$lamp_max) then p1 := obj$lamp_max; X`09`09end; X`09 desc_remain(i1); X`09 inven_destroy(i1); X`09 end X`09 else X`09 msg_print('You have no oil.') X`09else X`09 msg_print('But you are not using a lamp.'); X end; X X`09`7B General spells and misc routines`09`7D X`09%INCLUDE 'MOR_INCLUDE:SPELLS.INC' X`09`7B Wizard and debug routines`09`09`7D X`09%INCLUDE 'MOR_INCLUDE:WIZARD.INC' X`09`7B Creature movement and attacks`09`09`7D X`09%INCLUDE 'MOR_INCLUDE:CREATURE.INC' X`09`7B Using objects`09`09`09`09`7D X`09%INCLUDE 'MOR_INCLUDE:SCROLLS.INC' X`09%INCLUDE 'MOR_INCLUDE:POTIONS.INC' X`09%INCLUDE 'MOR_INCLUDE:EAT.INC' X`09%INCLUDE 'MOR_INCLUDE:WANDS.INC' X`09%INCLUDE 'MOR_INCLUDE:STAFFS.INC' X`09`7B Spell casting`09`09`09`09`7D X`09%INCLUDE 'MOR_INCLUDE:MAGIC.INC' X`09%INCLUDE 'MOR_INCLUDE:PRAYER.INC' X X`09`7B Main procedure for dungeon...`09`09`09`09-RAK-`09`7D X`09`7B Note: There is a lot of prelinimary magic going on here at first`7D X begin X`09`7B Check light status for setup`09`09`7D X with inventory`5B33`5D do X`09if (p1 > 0) then X`09 player_light := true X`09else X`09 player_light := false; X`09`7B Check for a maximum level`09`09`7D X with py.misc do X`09if (dun_level > max_lev) then max_lev := dun_level; X`09`7B Set up the character co-ords`09`09`7D X if ((char_row = -1) or (char_col = -1)) then X new_spot(char_row,char_col); X`09`7B Reset flags and initialize variables`09`7D X moria_flag := false; X cave_flag := false; X find_flag := false; X search_flag := false; X teleport_flag := false; X mon_tot_mult := 0; X cave`5Bchar_row,char_col`5D.cptr := 1; X old_chp := trunc(py.misc.chp); X old_cmana := trunc(py.misc.cmana); X`09`7B Light up the area around character`09`7D X move_char(5); X`09`7B Light, but do not move critters`09`7D X creatures(false); X`09`7B Print the depth`09`09`09`7D X prt_depth; X X`09`7B Loop until dead, or new level`09`09`09`7D X repeat X X`09`7B Increment turn counter`09`09`09`7D X`09turn := turn + 1; X`09`7B Check for game hours`09`09`09`09`7D X`09if (not(wizard1)) then X`09 if ((turn mod 250) = 1) then X`09 if (not(check_time)) then X`09 if (closing_flag > 4) then X`09`09begin X`09`09 if (search_flag) then X`09`09 search_off; X`09`09 if (py.flags.rest > 0) then X`09`09 rest_off; X`09`09 find_flag := false; X`09`09 msg_print('The gates to Moria are now closed.'); X`09`09 msg_print(''); X`09 repeat X`09 save_char; X`09 until(false); X`09`09end X`09 else X`09`09begin X`09`09 if (search_flag) then X`09`09 search_off; X`09`09 if (py.flags.rest > 0) then X`09`09 rest_off; X`09`09 find_flag := false; X`09`09 move_char(5); X`09 closing_flag := closing_flag + 1; X`09`09 msg_print('The gates to Moria are closing...'); X`09`09 msg_print('Please finish up or save your game.'); X`09`09 msg_print(''); X`09`09end; X X`09`7B Check for creature generation`09`09`09`7D X`09if (randint(max_malloc_chance) = 1) then X`09 alloc_monster(floor_set,1,max_sight,false); X`09`7B Screen may need updating, used mostly for stats`7D X`09if (print_stat > 0) then X`09 begin X`09 if (uand(%X'0001',print_stat) <> 0) then X`09 prt_strength; X`09 if (uand(%X'0002',print_stat) <> 0) then X`09 prt_dexterity; X`09 if (uand(%X'0004',print_stat) <> 0) then X`09 prt_constitution; X`09 if (uand(%X'0008',print_stat) <> 0) then X`09 prt_intelligence; X`09 if (uand(%X'0010',print_stat) <> 0) then X`09 prt_wisdom; X`09 if (uand(%X'0020',print_stat) <> 0) then X`09 prt_charisma; X`09 if (uand(%X'0040',print_stat) <> 0) then X`09 prt_pac; X`09 if (uand(%X'0100',print_stat) <> 0) then X`09 prt_mhp; X`09 if (uand(%X'0200',print_stat) <> 0) then X`09 prt_title; X`09 if (uand(%X'0400',print_stat) <> 0) then X`09 prt_level; X`09 end; X`09`7B Check light status`09`09`09`09`7D X`09with inventory`5B33`5D do X`09 if (player_light) then X`09 if (p1 > 0) then X`09 begin X`09 p1 := p1 - 1; X`09`09if (p1 = 0) then X`09`09 begin X`09`09 msg_print('Your light has gone out!'); X`09 player_light := false; X`09`09 find_flag := false; X`09`09 move_light(char_row,char_col,char_row,char_col); X`09`09 end X`09`09else if (p1 < 40) then X`09`09 if (randint(5) = 1) then X`09`09 begin X`09`09 if (find_flag) then X`09`09`09begin X`09`09`09 find_flag := false; X`09`09`09 move_light(char_row,char_col,char_row,char_col); X`09`09`09end; X`09`09 msg_print('Your light is growing faint.'); X`09`09 end; X`09 end X`09 else X`09 begin X`09 player_light := false; X`09`09find_flag := false; X`09`09move_light(char_row,char_col,char_row,char_col); X`09 end X`09 else if (p1 > 0) then X`09 begin X`09 p1 := p1 - 1; X`09 player_light := true; X`09 move_light(char_row,char_col,char_row,char_col); X`09 end; X X`09`7B Update counters and messages`09`09`09`7D X`09with py.flags do X`09 begin X`09`09`7B Check food status`09`09`7D X`09 regen_amount := player$regen_normal; X`09 if (food < player_food_alert) then X`09 begin X`09 if (food < player_food_weak) then X`09`09 begin +-+-+-+-+-+-+-+- END OF PART 43 +-+-+-+-+-+-+-+-