-+-+-+-+-+-+-+-+ START OF PART 17 -+-+-+-+-+-+-+-+ X cdesc := cdesc + 'casts a spell.'; X msg_print(cdesc); X if (py.flags.free_act) then X msg_print('You are unaffected...') X else if (player_saves(wis_adj+py.misc.lev)) then X msg_print('You resist the affects of the spell.' V) X else if (py.flags.paralysis > 0) then X py.flags.paralysis:=py.flags.paralysis+2 X else X py.flags.paralysis:=randint(5)+4 X END; X`7BCause Blindnes`7D11 : BEGIN X cdesc := cdesc + 'casts a spell.'; X msg_print(cdesc); X if (player_saves(wis_adj+py.misc.lev)) then X msg_print('You resist the affects of the spell.' V) X else if (py.flags.blind > 0) then X py.flags.blind := py.flags.blind + 6 X else X BEGIN X py.flags.blind := py.flags.blind+12+randint(3) V; X msg_print(' ') X END X END; X`7BCause Confuse `7D12 : BEGIN X cdesc := cdesc + 'casts a spell.'; X msg_print(cdesc); X if (player_saves(wis_adj+py.misc.lev)) then X msg_print('You resist the affects of the spell.' V) X else if (py.flags.confused > 0) then X py.flags.confused := py.flags.confused + 2 X else X py.flags.confused := randint(5) + 3 X END; X`7BCause Fear`7D 13 : BEGIN X cdesc := cdesc + 'casts a spell.'; X msg_print(cdesc); X if (player_saves(wis_adj+py.misc.lev)) then X msg_print('You resist the affects of the spell.' V) X else if (py.flags.afraid > 0) then X py.flags.afraid := py.flags.afraid + 2 X else X py.flags.afraid := randint(5) + 3 X END; X`7BSummon Monster`7D14 : BEGIN X cdesc := cdesc + 'magically summons a monster!'; X msg_print(cdesc); X y := char_row; X x := char_col; X summon_monster(y,x,false); X check_mon_lite(y,x) X END; X`7BSummon Undead`7D 15 : BEGIN X cdesc := cdesc + 'magically summons an undead!'; X msg_print(cdesc); X y := char_row; X x := char_col; X summon_undead(y,x); X check_mon_lite(y,x) X END; X`7BSlow Person `7D 16 : BEGIN X cdesc := cdesc + 'casts a spell.'; X msg_print(cdesc); X if (py.flags.free_act) then X msg_print('You are unaffected...') X else if (player_saves(wis_adj+py.misc.lev)) then X msg_print('You resist the affects of the spell.' V) X else if (py.flags.slow > 0) then X py.flags.slow := py.flags.slow + 2 X else X py.flags.slow := randint(5) + 3 X END; X`7BDrain Mana `7D 17 : if (trunc(py.misc.cmana) > 0) then X BEGIN X outval := cdesc+'draws psychic energy from you!' V; X msg_print(outval); X outval := cdesc+'appears stronger...'; X msg_print(outval); X r1 := randint(level); X if (r1 > py.misc.cmana) then r1 := py.misc.cmana V; X py.misc.cmana := py.misc.cmana - r1; X hp := hp + 5*trunc(r1) X END; X`7BBreath Light `7D 20 : BEGIN X cdesc := cdesc + 'breathes lightning.'; X msg_print(cdesc); X breath(1,char_row,char_col,trunc(hp/3.0),ddesc) X END; X`7BBreath Gas `7D 21 : BEGIN X cdesc := cdesc + 'breathes gas.'; X msg_print(cdesc); X breath(2,char_row,char_col,trunc(hp/3.0),ddesc) X END; X`7BBreath Acid `7D 22 : BEGIN X cdesc := cdesc + 'breathes acid.'; X msg_print(cdesc); X breath(3,char_row,char_col,trunc(hp/3.0),ddesc) X END; X`7BBreath Frost `7D 23 : BEGIN X cdesc := cdesc + 'breathes frost.'; X msg_print(cdesc); X breath(4,char_row,char_col,trunc(hp/3.0),ddesc) X END; X`7BBreath Fire `7D 24 : BEGIN X cdesc := cdesc + 'breathes fire.'; X msg_print(cdesc); X breath(5,char_row,char_col,trunc(hp/3.0),ddesc) X END; X OTHERWISE BEGIN X msg_print('Creature cast unknown spell.'); X cdesc := '' X END X END X`7B End of spells `7D X END X END X END; X`20 X`20 X`7B Main procedure for monster movement (MON_MOVE) `7D X BEGIN X mon_move := false; X with c_list`5Bm_list`5Bmonptr`5D.mptr`5D do X BEGIN X`7B Does the critter multiply? `7D X if (uand(cmove,%X'00200000') <> 0) then X if (max_mon_mult >= mon_tot_mult) then X if ((py.flags.rest mod mon_mult_adj) = 0) then X with m_list`5Bmonptr`5D do X BEGIN X i3 := 0; X for i1 := fy-1 to fy+1 do X for i2 := fx-1 to fx+1 do X if (in_bounds(i1,i2)) then X if (cave`5Bi1,i2`5D.cptr > 1) then X i3 := i3 + 1; X if (i3 < 4) then X if (randint(i3*mon_mult_adj) = 1) then X multiply_monster(fy,fx,mptr,false) X END; X`7B Creature is confused? Chance it becomes un-confused `7D X move_test := false; X if (m_list`5Bmonptr`5D.confused) then X BEGIN X mm`5B1`5D := randint(9); X mm`5B2`5D := randint(9); X mm`5B3`5D := randint(9); X mm`5B4`5D := randint(9); X mm`5B5`5D := randint(9); X mon_move := make_move(monptr,mm); X if (randint(8) = 1) then X m_list`5Bmonptr`5D.confused := false; X move_test := true X END X`7B Creature may cast a spell `7D X else if (spells > 0) then X mon_move := cast_spell(monptr,move_test); X if (not(move_test)) then X BEGIN X`7B 75% random movement `7D X if ((randint(100) < 75) and X (uand(cmove,%X'00000020') <> 0)) then X BEGIN X mm`5B1`5D := randint(9); X mm`5B2`5D := randint(9); X mm`5B3`5D := randint(9); X mm`5B4`5D := randint(9); X mm`5B5`5D := randint(9); X mon_move := make_move(monptr,mm) X END X`7B 40% random movement `7D X else if ((randint(100) < 40) and X (uand(cmove,%X'00000010') <> 0)) then X BEGIN X mm`5B1`5D := randint(9); X mm`5B2`5D := randint(9); X mm`5B3`5D := randint(9); X mm`5B4`5D := randint(9); X mm`5B5`5D := randint(9); X mon_move := make_move(monptr,mm) X END X`7B 20% random movement `7D X else if ((randint(100) < 20) and X (uand(cmove,%X'00000008') <> 0)) then X BEGIN X mm`5B1`5D := randint(9); X mm`5B2`5D := randint(9); X mm`5B3`5D := randint(9); X mm`5B4`5D := randint(9); X mm`5B5`5D := randint(9); X mon_move := make_move(monptr,mm) X END X`7B Normal movement `7D X else if (uand(cmove,%X'00000002') <> 0) then X BEGIN X if (randint(200) = 1) then X BEGIN X mm`5B1`5D := randint(9); X mm`5B2`5D := randint(9); X mm`5B3`5D := randint(9); X mm`5B4`5D := randint(9); X mm`5B5`5D := randint(9) X END X else X get_moves(monptr,mm); X mon_move := make_move(monptr,mm); X END X`7B Attack, but don't move `7D X else if (uand(cmove,%X'00000001') <> 0) then X if (m_list`5Bmonptr`5D.cdis < 2) then X BEGIN X get_moves(monptr,mm); X mon_move := make_move(monptr,mm) X END X END X END X END; X`20 X`20 X`7B Main procedure for creatures `7D X BEGIN X if (muptr > 0) then X BEGIN X`7B Process the monsters `7D X i1 := muptr; X repeat X with m_list`5Bi1`5D do X BEGIN X cdis := distance(char_row,char_col,fy,fx); X if (attack) then `7B Attack is argument passed to CREATURE`7D X BEGIN X i3 := movement_rate(cspeed); X if (i3 > 0) then X for i2 := 1 to movement_rate(cspeed) do X BEGIN X if ((cdis <= c_list`5Bmptr`5D.aaf) or (ml)) then X BEGIN X if (csleep > 0) then X if (py.flags.aggravate) then X csleep := 0 X else if (py.flags.rest < 1) then X if (randint(10) > py.misc.stl) then X csleep := csleep - trunc(75.0/cdis); X if (stuned > 0) then X stuned := stuned - 1; X if ((csleep <= 0) and (stuned <= 0)) then X BEGIN X moldy := fy; X moldx := fx; X if (mon_move(i1)) then X if (ml) then X BEGIN X ml := false; X if (test_light(moldy,moldx)) then X lite_spot(moldy,moldx) X else X unlite_spot(moldy,moldx) X END X END X END; X update_mon(i1) X END X else X update_mon(i1) X END X else X update_mon(i1) X END; X i1 := m_list`5Bi1`5D.nptr; X until ((i1 = 0) or (moria_flag)) X`7B End processing monsters `7D X END X END; X `20 $ CALL UNPACK [.SOURCE.INCLUDE]CREATURE.INC;1 1180676259 $ create 'f' X`20 X`7B Initialize, restore, and get the ball rolling. X Read in the critters' flags and convert them. -Opusii`7D X `20 XPROCEDURE gethex(var num:unsigned); Xconst mult=7; Xvar i,chnum,jindex,qcntr:integer; X ch:char; X number : packed array `5B1..12`5D of char; XBEGIN Xnum:=0; Xqcntr := 0; Xjindex := 1; Xreadln(opusii,number); Xrepeat X if((number`5Bjindex`5D>='A')and(number`5Bjindex`5D<='F')) X then X chnum:=ord(number`5Bjindex`5D)-ord('A')+10 X else X chnum:=ord(number`5Bjindex`5D)-ord('0'); Xif (number`5Bjindex`5D='''') then X qcntr := qcntr + 1; X if(qcntr>0)and(((jindex-4)>=0)and((jindex-4)<=7))then X num:=num+(16**(mult-(jindex-4)))*chnum; X jindex := jindex + 1; Xuntil(qcntr=2) Xend; X X `20 X Xprocedure read_creatures ; `20 X `20 XBEGIN X`7Bread creatures from external file`7D X open (Opusii,MORIA_MON,readonly); X reset(Opusii); X readln(Opusii,max_creatures); X for Opusii_cnt := 1 to max_creatures do X with c_list`5BOpusii_cnt`5D do X BEGIN X readln(Opusii,name); X for indx := 1 to 3 do X BEGIN X gethex(hexnum); X CASE indx OF X 1 : cmove := hexnum; X 2 : spells := hexnum; X 3 : cdefense := hexnum X END `20 X END; X readln(Opusii,sleep,mexp,aaf,ac,speed); X readln(Opusii,cchar); X readln(Opusii,hd); X readln(Opusii,damage); X readln(Opusii,level); X END; X close(Opusii); XEND; X X Xprocedure read_data; X XBEGIN Xread_creatures; XEND; X $ CALL UNPACK [.SOURCE.INCLUDE]DATAFILES.INC;1 946081987 $ create 'f' X`7B Handles the gravestone and top-twenty routines `7D X`5Bpsect(death$code)`5D procedure upon_death; X type X word = 0..65535; +-+-+-+-+-+-+-+- END OF PART 17 +-+-+-+-+-+-+-+-