-+-+-+-+-+-+-+-+ START OF PART 79 -+-+-+-+-+-+-+-+ X`09`09`09lite_spot(i1,i2) X`09`09 else if (cptr = 1) then X`09`09`09lite_spot(i1,i2) X`09`09 else if (cptr > 1) then X`09`09`09if (m_list`5Bcptr`5D.ml) then X`09`09`09 lite_spot(i1,i2) X`09`09`09else X`09`09`09 unlite_spot(i1,i2) X`09`09 else X`09`09`09unlite_spot(i1,i2); X`09`09 end; X end; X X X X`09`7B Recharge a wand, staff, or rod. Sometimes the item breaks. -RAK-`7D X`5Bglobal,psect(misc6$code)`5D function recharge(num : integer) : boolean; X var X`09`09item_ptr`09: treas_ptr; X`09`09redraw`09`09: boolean; X begin X`09recharge := false; X`09redraw := false; X`09change_all_ok_stats(true,true); X`09if (get_item(item_ptr,'Recharge which item?',redraw,inven_ctr,trash_char, Vfalse)) then X`09 with item_ptr`5E.data do X`09 if (tval in `5Bstaff,rod,wand,chime,horn`5D) then X`09 if (randint(8) = 1) then X`09`09begin X`09`09 recharge := true; X`09`09 msg_print('There is a bright flash of light...'); X`09`09 inven_destroy(item_ptr); X`09`09end X`09 else X`09`09begin X`09`09 recharge := true; X`09`09 num := trunc(num/(level+2)); X`09`09 p1 := p1 + 2 + randint(num); X`09`09 if (index(name,'`5E') = 0) then X`09`09 insert_str(name,' (%P1','`5E (%P1'); X`09`09end X`09 else if ((tval in `5Blamp_or_torch`5D) and (subval = 17)) then X`09 if (randint(50) = 1) then X`09`09begin X`09`09 recharge := true; X`09`09 msg_print('There is a bright flash of light...'); X`09`09 inven_destroy(item_ptr); X`09`09end X`09 else X`09`09begin X`09`09 recharge := true; X`09`09 num := num * 100; X`09`09 p1 := p1 + num div 3 + randint(num); X`09`09 if (index(name,'`5E') = 0) then X`09`09 insert_str(name,' (%P1','`5E (%P1'); X`09`09end X`09 else if ((tval in `5Blamp_or_torch`5D) and (subval=15)) then X`09 if (randint(15)=1) then X`09`09begin X`09`09 recharge:=true; X`09`09 msg_print('There is a bright flash of light...'); X`09`09 inven_destroy(item_ptr); X`09`09end X`09 else X`09`09begin X`09`09 recharge:=true; X`09`09 num := num * 80; X`09`09 p1 := p1 + num div 3 + randint(num); X`09`09 if (index(name,'`5E') = 0) then X`09`09 insert_str(name,' (%P1','`5E (%P1'); X`09`09end; X`09if (redraw) then X`09 begin X`09 msg_print(' '); X`09 draw_cave; X`09 end X`09else X`09 prt_weight; X end; X X X X X`7B Contains all aimed spell effects that stop at first victim. New X spell effects should be put into constants.inc. Aux is used for damage X or speed change if used.`7D X`5Bglobal,psect(misc6$code)`5D function zap_monster(dir,y,x, X`09`09`09`09aux,zaptype:integer) : boolean; X var X`09i1 : integer; X`09str1,str2 : vtype; X X function did_it_work : boolean; X`09begin X`09with cave`5By,x`5D do X`09with c_list`5Bm_list`5Bcptr`5D.mptr`5D do X`09 case (zaptype) of X`09 c_sleep,c_confuse : did_it_work := (not mon_save(cptr,0,c_sc_mental)) X`09`09`09`09and (not mon_resists(cptr)); X`09 c_drain : did_it_work := (uand(cdefense,%X'0008')=0) X`09`09`09`09and (not mon_resists(cptr)); X`09 c_speed : did_it_work := ((not mon_save(cptr,0,c_null)) X`09`09`09and (not mon_resists(cptr))) or (aux>0); X`09 c_hold : did_it_work := (not mon_save(cptr,0,c_hold)) X`09`09`09`09and (not mon_resists(cptr)); X`09 otherwise did_it_work := true; X`09 end; X`09end; X X procedure yes_it_did; X`09begin X`09with cave`5By,x`5D do X`09 with m_list`5Bcptr`5D do X`09 case zaptype of X`09 c_probe : begin X`09`09msg_print('The mysterious ray strikes '+str2+'.'); X`09`09writev(str2,hp:1); X`09`09msg_print('A voice booms down from above! It says..'); X`09`09msg_print('This monster has '+str2+' hp left.'); X`09 end;`09`09`09 X`09 c_sleep : begin X`09`09csleep := 500; X`09`09msg_print(str1+' falls asleep.'); X`09 end; X`09 c_confuse : begin X`09`09confused := true; X`09`09csleep := 0; X`09`09msg_print(str1+' appears confused.'); X`09 end; X`09 c_hp,c_drain : if (mon_take_hit(cptr,aux) > 0) then X`09`09msg_print(str1+' dies in a fit of agony.') X`09 else X`09`09msg_print(str1+' screams in agony.'); X`09 c_speed : begin X`09`09cspeed := cspeed+aux; X`09`09csleep := 0; X`09 end; X`09 c_hold : begin X`09`09msg_print(str1+' appears frozen!'); X`09`09i1 := stunned + aux; X`09`09if (i1>31) then i1 := 31; X`09`09stunned := i1; X`09 end; X`09 otherwise ; X`09 end; X`09end; X X`7B returns true for item idents `7D X function no_it_didnt : boolean; X`09begin X`09 no_it_didnt := zaptype in `5Bc_sleep,c_confuse,c_illusion`5D; X`09 if (not (zaptype in `5Bc_drain`5D)) then X`09 msg_print(str1+' is unaffected.'); X`09end; X X X begin X`09zap_monster := false; X`09if move_to_creature(dir,y,x) then X`09 with cave`5By,x`5D do X`09 with m_list`5Bcptr`5D do X`09 with c_list`5Bmptr`5D do X`09`09begin X`09`09 find_monster_name(str1,cptr,true); X`09`09 find_monster_name(str2,cptr,false); X`09`09 if (did_it_work) then X`09`09 begin X`09`09 yes_it_did; X`09`09 zap_monster := true X`09`09 end X`09`09 else if (no_it_didnt) then X`09`09 zap_monster := true; X`09`09end; X end; X X X X`09`7B Turn stone to mud, delete wall....`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function wall_to_mud(dir,y,x : integer) : boo Vlean; X var X`09`09i1`09`09`09: integer; X`09`09out_val`09`09`09: vtype; X`09`09flag`09`09`09: boolean; X begin X`09wall_to_mud := false; X`09flag := false; X`09repeat X`09 move(dir,y,x); X`09 with cave`5By,x`5D do X`09 if (in_bounds(y,x)) then X`09 begin X`09`09if (fval in wall_set) then X`09`09 begin X`09`09 flag := true; X`09`09 twall(y,x,1,0); X`09`09 if (test_light(y,x)) then X`09`09 begin X`09`09`09msg_print('The wall turns into mud.'); X`09`09`09wall_to_mud := true; X`09`09 end; X`09`09 end X`09`09else if ((tptr > 0) and (not(fopen))) then X`09`09 begin X`09`09 flag := true; X`09`09 if (panel_contains(y,x)) then X`09`09 if (test_light(y,x)) then X`09`09`09begin X`09`09`09 inven_temp`5E.data := t_list`5Btptr`5D; X`09`09`09 objdes(out_val,inven_temp,false); X`09`09`09 msg_print('The ' + out_val + ' turns into mud.'); X`09`09`09 wall_to_mud := true; X`09`09`09end; X`09`09 delete_object(y,x); X`09`09 end; X`09`09if (cptr > 1) then X`09`09 with m_list`5Bcptr`5D do X`09`09 with c_list`5Bmptr`5D do X`09`09 if (uand(%X'0200',cdefense) <> 0) then X`09`09`09begin X`09`09`09 i1 := mon_take_hit(cptr,100); X`09`09`09 flag := true; X`09`09`09 if (ml) then X`09`09`09 if (i1 > 0) then X`09`09`09msg_print('The ' + name + ' dies in a fit of agony.') X`09`09`09 else X`09`09`09 msg_print('The ' + name + ' wails out in pain!'); X`09`09`09end; X`09 end X`09 else X`09 flag := true; X`09until (flag); X end; X X X`09`7B Destroy all traps and doors in a given direction`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function td_destroy2(dir,y,x : integer) : boo Vlean; X begin X`09td_destroy2 := false; X`09repeat X`09 move(dir,y,x); X`09 with cave`5By,x`5D do X`09 if (tptr > 0) then X`09 with t_list`5Btptr`5D do X`09`09if (tval in `5BChest,Unseen_trap,Seen_trap,Closed_door, X`09`09`09 Secret_door`5D) then X`09`09 begin X`09`09 if (delete_object(y,x)) then X`09`09 begin X`09`09`09msg_print('There is a bright flash of light!'); X`09`09`09fopen := true; X`09`09`09td_destroy2 := true; X`09`09 end; X`09`09 end; X`09until (not(cave`5By,x`5D.fopen)); X end; X X`09`7B Polymorph a monster`09`09`09`09`09-RAK-`09`7D X`09`7B NOTE: cannot polymorph a winning creature (BALROG)`09`09`7D X`5Bglobal,psect(misc6$code)`5D function poly_monster(dir,y,x : integer) : bo Volean; X var X`09`09dist`09`09`09: integer; X`09`09flag`09`09`09: boolean; X begin X`09poly_monster := false; X`09flag := false; X`09dist := 0; X`09repeat X`09 if bolt_to_creature(dir,y,x,dist,obj$bolt_range,false) then X`09 with cave`5By,x`5D do X`09 if (not mon_save(cptr,0,c_null)) then X`09 begin`09`09 `20 X`09`09if (not mon_resists(cptr)) then X`09`09begin X`09`09 flag := true; X`09`09 delete_monster(cptr); X`09`09 place_monster(y,x, X`09`09`09randint(m_level`5Bmax_mons_level`5D)+ m_level`5B0`5D,false); X`09`09 if (panel_contains(y,x)) then X`09`09 if (test_light(y,x)) then poly_monster := true; X`09`09end; X`09 end X`09 else X`09msg_print('The '+c_list`5Bm_list`5Bcptr`5D.mptr`5D.name+' is unaffected.' V) X`09 else X`09 flag := true; X`09until (flag); X end; X X X`09`7B Create a wall...`09`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function build_wall(dir,y,x : integer) : bool Vean; X var X`09`09i1`09`09: integer; X begin X`09build_wall := false; X`09i1 := 0; X`09move(dir,y,x); X`09while ((cave`5By,x`5D.fopen) and (i1 < 10)) do X`09 with cave`5By,x`5D do X`09 begin X`09 if (tptr > 0) then X`09`09delete_object(y,x); X`09 if (cptr > 1) and (not mon_resists(cptr)) then X`09`09mon_take_hit(cptr,damroll('2d8')); X`09 fval := rock_wall2.ftval; X`09 fopen := rock_wall2.ftopen; X`09 fm := false; X`09 if (test_light(y,x)) then X`09`09lite_spot(y,x); X`09 i1 := i1 + 1; X`09 build_wall := true; X`09 move(dir,y,x); X`09 end; X end; X X`09`7B Replicate a creature`09`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function clone_monster(dir,y,x : integer) : b Voolean; X begin X`09clone_monster := false; X`09if move_to_creature(dir,y,x) then X`09 with cave`5By,x`5D do X`09 if (not mon_resists(cptr)) then X`09 begin X`09 multiply_monster(y,x,m_list`5Bcptr`5D.mptr,false); X`09 if (panel_contains(y,x)) then X`09 if (m_list`5Bcptr`5D.ml) then X`09 clone_monster := true; X`09 end X end; X X`09`7B Move the creature record to a new location`09`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function teleport_away(monptr,dis : integer) V : boolean; X var X`09`09yn,xn,ctr`09`09: integer; X begin X`09with m_list`5Bmonptr`5D do X if (not mon_resists(monptr)) then X`09 begin X`09 ctr := 0; X`09 repeat X`09 repeat X`09`09yn := fy + (randint(2*dis+1) - (dis + 1)); X`09`09xn := fx + (randint(2*dis+1) - (dis + 1)); X`09 until(in_bounds(yn,xn)); X`09 ctr := ctr + 1; X`09 if (ctr > 9) then X`09`09begin X`09`09 ctr := 0; X`09`09 dis := dis + 5; X`09`09end; X`09 until ((cave`5Byn,xn`5D.fopen) and (cave`5Byn,xn`5D.cptr = 0)); X`09 move_rec(fy,fx,yn,xn); X`09 if (test_light(fy,fx)) then X`09 lite_spot(fy,fx); X`09 fy := yn; X`09 fx := xn; X`09 ml := false; X`09 teleport_away := true; X`09 end; X end; X X`09`7B Teleport player to spell casting creature`09`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function teleport_to(ny,nx : integer) : boole Van; X var X`09dis,ctr,y,x,i1,i2`09`09: integer; X begin X`09teleport_to := true; X`09dis := 1; X`09ctr := 0; X`09repeat X`09 repeat X`09 y := ny + (randint(2*dis+1) - (dis + 1)); X`09 x := nx + (randint(2*dis+1) - (dis + 1)); X`09 until in_bounds(y,x); X`09 ctr := ctr + 1; X`09 if (ctr > 9) then X`09 begin X`09 ctr := 0; X`09 dis := dis + 1; X`09 end; X`09until ((cave`5By,x`5D.fopen) and (cave`5By,x`5D.cptr < 2)); X`09move_rec(char_row,char_col,y,x); X`09for i1 := char_row-1 to char_row+1 do X`09 for i2 := char_col-1 to char_col+1 do X`09 with cave`5Bi1,i2`5D do X`09 begin X`09`09tl := false; X`09`09if (not(test_light(i1,i2))) then X`09`09 unlite_spot(i1,i2); X`09 end; X`09if (test_light(char_row,char_col)) then X`09 lite_spot(char_row,char_col); X`09char_row := y; X`09char_col := x; X`09move_char(5); X`09creatures(false); X end; X X X`09`7B Teleport all creatures in a given direction away`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function teleport_monster(dir,y,x : integer) V : boolean; X var X`09`09yn,xn`09`09`09: integer; X begin X`09teleport_monster := false; X`09while move_to_creature(dir,y,x) do X`09 begin X`09 teleport_away(cave`5By,x`5D.cptr,max_sight); X`09 teleport_monster := true; X`09 end; X end; X X`09`7B Delete all creatures within MAX_SIGHT distance`09-RAK-`09`7D X`09`7B NOTE : Winning creatures cannot be genocided`09`09`09`7D X`5Bglobal,psect(misc6$code)`5D function mass_genocide : boolean; X var X`09`09i1,i2`09`09: integer; X begin X`09mass_genocide := false; X`09i1 := muptr; X`09repeat X`09 with m_list`5Bi1`5D do X`09 with c_list`5Bmptr`5D do X`09 begin X`09`09i2 := nptr; X`09`09if (cdis <= max_sight) then X`09`09 if (uand(cmove,%X'80000000') = 0) and X`09`09 (not mon_resists(i1)) then X`09`09 begin X`09`09 delete_monster(i1); X`09`09 mass_genocide := true; X`09`09 end; X`09 end; X`09 i1 := i2; X`09until(i1 = 0); X end; X X`09`7B Delete all creatures of a given type from level.`09-RAK-`09`7D X`09`7B This does not keep creatures of type from appearing later.`09`7D X`5Bglobal,psect(misc6$code)`5D function genocide : boolean; X var X`09`09i1,i2`09`09: integer; X`09`09typ`09`09: char; X begin X`09genocide := true; X`09i1 := muptr; X`09if (get_com('Which type of creature do wish exterminated?',typ)) then X`09 repeat X`09 with m_list`5Bi1`5D do X`09 with c_list`5Bmptr`5D do X`09`09begin X`09`09 i2 := nptr; X`09`09 if (typ = c_list`5Bmptr`5D.cchar) then X`09`09 if (uand(cmove,%X'80000000') = 0) and X`09`09 (not mon_resists(i1)) then X`09`09 delete_monster(i1) X`09`09 else X`09`09 msg_print('The ' + name + ' is unaffected.'); X`09`09end; X`09 i1 := i2; X`09 until(i1 = 0); X end; X X X`09`7B Polymorph any creature that player can see...`09`09-RAK-`09`7D X`09`7B NOTE: cannot polymorph a winning creature (BALROG)`09`09`7D X`5Bglobal,psect(misc6$code)`5D function mass_poly : boolean; X var X`09`09i1,i2,y,x`09: integer; X begin X`09i1 := muptr; X`09mass_poly := false; X`09repeat X`09 with m_list`5Bi1`5D do X`09 begin X`09 i2 := nptr; X`09 if (cdis < max_sight) then X`09`09with c_list`5Bmptr`5D do X`09`09 if (uand(cdefense,%X'80000000') = 0) and X`09`09 (not mon_resists(i1)) then X`09`09 begin X`09`09 y := fy; X`09`09 x := fx; +-+-+-+-+-+-+-+- END OF PART 79 +-+-+-+-+-+-+-+-