-+-+-+-+-+-+-+-+ START OF PART 45 -+-+-+-+-+-+-+-+ X for i3 := inventory`5Bitem_val`5D.ac to inventory`5Bitem_val V`5D.toac do X`09`09 Begin `20 X with skill_list`5Bi3`5D do X BEGIN X i1 := i1 + 1; X if (slevel < 99) then X BEGIN X writev(out_val,chr(96+i1),') ',pad(sname,' ',30) V, X slevel:2,' ',smana:2,' ',learned); X prt(out_val,i1+1,1); X END X else X prt('',i1+1,1); X END; X`09`09 End; X`09 End; X pause(pause_line); X END; X END; X if (redraw) then draw_cave; X END; X`20 X`20 X`7B Player is on an object. Many things can happen BASED X on the TVAL of the object. Traps are set off, money and most X objects are picked up. Some objects, such as open doors, just X sit there.`7D X procedure carry(y,x : integer); X var X item_val: integer; X out_val : vtype; X BEGIN X find_flag := false; X with cave`5By,x`5D do X BEGIN X temporary_slot := t_list`5Btptr`5D; X`7B There's GOLD in them thar hills! `7D X if (t_list`5Btptr`5D.tval = 100) then X BEGIN X pusht(tptr); X tptr := 0; X with temporary_slot do X BEGIN X py.misc.au := py.misc.au + cost; X writev(out_val,'You have found $',cost:1, X ' worth of ',name,'. '); X END; X prt_gold; X msg_print(out_val); X END X`7B OOPS! `7D else X if (t_list`5Btptr`5D.tval in trap_set) then X hit_trap(y,x) X else `7BAttempt to pick up an object`7D X if (t_list`5Btptr`5D.tval < 100) then X BEGIN X`7B Wgt lim check `7D if (inven_check_weight) then X`7B Too many objects? `7D if (inven_check_num) then X`7B Okay, pick it up `7D BEGIN X pusht(tptr); X tptr := 0; X inven_carry(item_val); X objdes(out_val,item_val,true,'i'); X out_val := 'You have ' + out_val + ' (' + X raoul_label(item_val) + cur_char1(item_val); X prt_cur_weight; X msg_print(out_val); X END X else X msg_print('You can''t carry that many items.') X else X msg_print('You can''t carry that much weight.') X END X END X END; X`20 X`20 X`7B Drop an object being carried Note: Only one object per floor spot.`7D X procedure drop; X var X com_val,i1,i2: integer; X redraw : boolean; X out_val: vtype; X BEGIN X if (inven_ctr > 0) then X BEGIN X if (get_item(com_val,'Drop which item?',redraw,1,inven_ctr)) then X BEGIN X if (redraw) then draw_cave; X with cave`5Bchar_row,char_col`5D do X if (tptr > 0) then X msg_print('There is something there already.') X else X BEGIN X inven_drop(com_val,char_row,char_col); X objdes(out_val,1,true,'t'); X out_val := 'Dropped ' + out_val; X prt_cur_weight; X msg_print(out_val); X END X END X else if (redraw) then X draw_cave; X END X else X msg_print('You are not carrying anything.'); X END; X`20 X`20 X`7B Deletes a monster entry from the level `7D X procedure delete_monster(i2 : integer); X var X i1,i3 : integer; X BEGIN X i1 := muptr; X i3 := m_list`5Bi2`5D.nptr; X if (i1 = i2) then X muptr := i3 X else X BEGIN X while (m_list`5Bi1`5D.nptr <> i2) do X i1 := m_list`5Bi1`5D.nptr; X m_list`5Bi1`5D.nptr := i3; X END; X with m_list`5Bi2`5D do X BEGIN X cave`5Bfy,fx`5D.cptr := 0; X if (ml) then X with cave`5Bfy,fx`5D do X if ((pl) or (tl)) then X lite_spot(fy,fx) X else X unlite_spot(fy,fx); X pushm(i2); X END; X mon_tot_mult := mon_tot_mult - 1; X END; X`20 X`20 X`7B Makes sure new creature gets lit up `7D X procedure check_mon_lite(y,x : integer); X BEGIN X with cave`5By,x`5D do X if (cptr > 1) then X if (not(m_list`5Bcptr`5D.ml)) then X if ((tl) or (pl)) then X if (los(char_row,char_col,y,x)) then X BEGIN X m_list`5Bcptr`5D.ml := true; X lite_spot(y,x); X END; X END; X`20 X`20 X`7B Places creature adjacent to given location X Rats and Flys are fun! `7D X procedure multiply_monster(y,x,z,repro: integer; slp : boolean); X var X i1,i2,i3 : integer; X BEGIN X i1 := 0; X repeat X i2 := y - 2 + randint(3); X i3 := x - 2 + randint(3); X if (in_bounds(i2,i3)) then X with cave`5Bi2,i3`5D do X if (fval in floor_set) then X if ((tptr = 0) and (cptr <> 1)) then X BEGIN X if (cptr > 1) then `7B Creature there already? `7D X BEGIN X`7B Some critters are cannibalistic! `7D X if (uand(c_list`5Bz`5D.cmove,%X'00080000') <> 0) then X BEGIN X delete_monster(cptr); X place_mult_monster(i2,i3,z,repro,slp); X check_mon_lite(i2,i3); X mon_tot_mult := mon_tot_mult + 1; X END; X END X else X`7B All clear, place a monster `7D X BEGIN X place_mult_monster(i2,i3,z,repro,slp); X check_mon_lite(i2,i3); X mon_tot_mult := mon_tot_mult + 1; X END; X i1 := 18; X END; X i1 := i1 + 1; X until (i1 > 18); X END; X`20 X`20 X`7B Creates objects nearby the coordinates given X BUG: Because of the range, objects can actually be placed into X areas closed off to the player, this is rarely noticable, X and never a problem to the game.`7D X procedure summon_object(y,x,num,typ : integer); X var X i1,i2,i3 : integer; X BEGIN X repeat X i1 := 0; X repeat X i2 := y - 3 + randint(5); X i3 := x - 3 + randint(5); X if (in_bounds(i2,i3)) then X with cave`5Bi2,i3`5D do X if (fval in floor_set) then X if (tptr = 0) then X BEGIN X CASE typ of `7B Select type of object `7D X 1 : place_object(i2,i3); X 2 : place_gold(i2,i3); X 3 : if (randint(100) < 50) then X place_object(i2,i3) X else X place_gold(i2,i3); X otherwise ; X END; X if (test_light(i2,i3)) then X lite_spot(i2,i3); X i1 := 10; X END; X i1 := i1 + 1; X until (i1 > 10); X num := num - 1; X until (num = 0); X END; X`20 X`20 X`7B Deletes object from given location `7D X function delete_object(y,x : integer) : boolean; X BEGIN X delete_object := false; X with cave`5By,x`5D do X BEGIN X if (t_list`5Btptr`5D.tval = 109) then X fval := corr_floor3.ftval; X fopen := true; X pusht(tptr); X tptr := 0; X fm := false; X if (test_light(y,x)) then X BEGIN X lite_spot(y,x); X delete_object := true; X END X else X unlite_spot(y,x); X END; X END; X X`7B Place a corpse of the creature just killed. - RLG`7D X procedure place_corpse(y,x,cnum:integer); X var X corpse : treasure_type; X cur_pos : integer; X begin X corpse := blank_treasure; X corpse.name := '& ' + c_list`5Bcnum`5D.name + ' Corpse`7E'; X corpse.cost := c_list`5Bcnum`5D.size; X with corpse do X begin X`09 tval := 4 ; `7Boh no, a new tval`7D X`09 subval := 600 + cnum ; `7Bcnum is the array index of c_list`7D X`09 weight := cost * 20 ; X`09 number := 1 ; X`09 tchar := ';' ; X end; X popt(cur_pos);`20 X cave`5By,x`5D.tptr := cur_pos; X t_list`5Bcur_pos`5D := corpse; X end;`20 X X`7B Allocates objects upon a creatures death X Oh well, another creature bites the dust... Reward the victor X based on flags set in the creature record `7D X procedure monster_death(y,x : integer; flags : unsigned); X var X i1 : integer; X BEGIN X if (uand(flags,%X'01000000') <> 0) then X i1 := 1 X else X i1 := 0; X if (uand(flags,%X'02000000') <> 0) then X i1 := i1 + 2; X if (uand(flags,%X'04000000') <> 0) then X if (randint(100) < 60) then X summon_object(y,x,1,i1); X if (uand(flags,%X'08000000') <> 0) then X if (randint(100) < 90) then X summon_object(y,x,1,i1); X if (uand(flags,%X'10000000') <> 0) then X summon_object(y,x,randint(2),i1); X if (uand(flags,%X'20000000') <> 0) then X summon_object(y,x,damroll('2d2'),i1); X if (uand(flags,%X'40000000') <> 0) then X summon_object(y,x,damroll('4d3'),i1); X if ((uand(flags,%X'80000000') <> 0) and (not is_boss_dead)) then X if(dun_power = win_mon_appear) then X Begin X total_winner_num := total_winner_num + 1; X`09 is_boss_dead := true; X prt_winner; X msg_print('*** CONGRATULATIONS *** You have won the game...'); X msg_print('Use -Y when you are ready to quit.'); X`09 End X else X`09 Begin X msg_print('Congratulations! You have defeated the mob boss of this city.') V; X msg_print('The Boss will be angry that you have killed one of his henchmen. V'); X msg_print('You can now take the bus from the hotel to the next city.'); X`09 defeated_badguy := true; X`09 End; X END; X`20 X`7B Decreases monsters hit points and deletes monster if needed. X (Picking on my babies...) `7D X function mon_take_hit(monptr,dam : integer) : integer; X var X acc_tmp : real; X BEGIN X with m_list`5Bmonptr`5D do X BEGIN X hp := hp - dam; X csleep := 0; X if (hp < 0) then X BEGIN X `09 if ((randint(10)=1) and (cave`5Bfy,fx`5D.tptr = 0)) then X`09`09 place_corpse(fy,fx,mptr); X monster_death(fy,fx,c_list`5Bmptr`5D.cmove); X with c_list`5Bmptr`5D do X with py.misc do X BEGIN X`09`09 kill_list`5Bmptr`5D := kill_list`5Bmptr`5D + 1; X acc_tmp := mexp*((level+0.1)/lev); X i1 := trunc(acc_tmp); X acc_exp := acc_exp + (acc_tmp - i1); X if (acc_exp > 1) then X BEGIN X i1 := i1 + 1; X acc_exp := acc_exp - 1.0 X END; X `7BPenalize player - subtract experience`7D X if (uand(cdefense,%X'00000800') <> 0) then X begin X exp := exp - 2*lev; X sc := sc - lev; X if (exp < 0) then exp:=0; X if (sc < 0) then sc := 0; X`09`09`09 if (randint(2)=2) then`20 X`09`09`09 begin X`09`09 msg_print('Halt evil-doer!! You are under arrest!'); X`09`09 if (py.misc.lev < 15) then X`09`09`09 place_policeman(fy,fx,1) X`09`09`09 else X`09`09`09 place_policeman(fy,fx,2); `7Btough guy`7D X end; X`09`09 end X else X exp := exp + i1; X if (i1 > 0) then prt_experience; X END; X mon_take_hit := mptr; X delete_monster(monptr); X END X else X mon_take_hit := 0; X END X END; X`20 X`20 X`7B Special damage due to magical abilities of object `7D X function tot_dam(item : treasure_type; tdam : integer; X monster : creature_type) : integer; X BEGIN X with item do X if (tval in `5B9,10,11,12,21,22,23,82`5D) then X with monster do X BEGIN X`7B Slay Alien `7D if ((uand(cdefense,%X'0001') <> 0) and X (uand(flags,%X'00002000') <> 0)) then X tdam := tdam*4 X`7B Slay Mutant`7D else if ((uand(cdefense,%X'0008') <> 0) and X (uand(flags,%X'00010000') <> 0)) then X tdam := tdam*3 X`7BSlay Creature`7D else if ((uand(cdefense,%X'0002') <> 0) and X (uand(flags,%X'00004000') <> 0)) then X tdam := tdam*2 X`7B Slay Scum `7D else if ((uand(cdefense,%X'0004') <> 0) and X (uand(flags,%X'00008000') <> 0)) then X tdam := tdam*2 X`7B Slay Robot `7D else if ((uand(cdefense,%X'0400') <> 0) and X (uand(flags,%X'00080000') <> 0)) then X tdam := tdam*2 X`7B Frost `7D else if ((uand(cdefense,%X'0010') <> 0) and X (uand(flags,%X'00020000') <> 0)) then X tdam := trunc(tdam*1.5) X`7B Fire `7D else if ((uand(cdefense,%X'0020') <> 0) and X (uand(flags,%X'00040000') <> 0)) then +-+-+-+-+-+-+-+- END OF PART 45 +-+-+-+-+-+-+-+-