-+-+-+-+-+-+-+-+ START OF PART 78 -+-+-+-+-+-+-+-+ X`09`09weapon_type := %X'00000000'; X`09`09harm_type := %X'0000'; X`09`09destroy`09 := `5Bpotion1,potion2,soft_armor,boots,food`5D; X`09 end; X`09c_sunray : begin `7B9`7D X`09`09weapon_type := %X'00000000'; X`09`09harm_type := %X'0108'; X`09`09destroy`09 := `5Bpotion1,potion2,scroll1,scroll2,cloak`5D; X`09 end; X`09otherwise begin X`09`09 weapon_type := 0; X`09`09 harm_type`09:= 0; X`09`09 destroy`09:= `5B`5D; X`09`09 end; X`09end; X end; X Xfunction bolt_to_creature(dir : integer; var y,x,dist : integer; X`09`09max_dist : integer; visable : boolean) : boolean; X var X`09`09hit_creature : boolean; X`09`09oldx,oldy`09: integer; X begin X`09hit_creature := false; X`09repeat X`09 oldy := y; X`09 oldx := x; X`09 move(dir,y,x); X`09 dist := dist + 1; X`09 if visable then`09`7B erase bolt `7D X`09 if test_light(oldy,oldx) then X`09 lite_spot(oldy,oldx) X`09 else X`09 unlite_spot(oldy,oldx); X`09 if (dist <= max_dist) then X`09 with cave`5By,x`5D do X`09 if (fopen) then X`09`09begin X`09`09 hit_creature := (cptr > 1); X`09`09 if (visable and (not hit_creature)) then X`09`09 if panel_contains(y,x) then X`09`09 print('*',y,x);`09`7B draw bolt `7D X`09`09end;`20 X`09until ((not cave`5By,x`5D.fopen) or (dist > max_dist) or hit_creature); X`09bolt_to_creature := hit_creature; X end; X Xfunction move_to_creature(dir : integer; var y,x : integer) : boolean; X var X`09`09hit_creature`09: boolean; X`09`09dist`09`09: integer; X begin X`09dist := 0; X`09move_to_creature := bolt_to_creature(dir,y,x,dist,999,false); X end; X X`09`7B Determine whether an item is magical or not`09`09-Cap'n-`09`7D X`5Bglobal,psect(misc6$code)`5D function detect_magic : boolean; X var X`09`09item_ptr`09`09: treas_ptr; X`09`09redraw,dumb,dumber`09: boolean; X begin X`09detect_magic := false; X`09redraw := false; X`09dumb := am_i_dumb; X`09dumber := dumb and am_i_dumb; X`09change_all_ok_stats(true,true); X`09if (get_item(item_ptr,'Item you wish to examine?', X`09`09`09redraw,inven_ctr,trash_char,false)) then X`09 begin X`09 with item_ptr`5E.data do X`09 if ((((flags<>0) or (tohit>0) or (todam>0) or (toac>0)) and X`09`09 not dumb) or dumber) then X`09`09msg_print('The item seems magical!') X`09 else X`09`09msg_print('The item does not seem to be magical...'); X`09 detect_magic := true; X`09 end; X`09if (redraw) then X`09 begin X`09 msg_print(' '); X`09 draw_cave; X`09 end; X end; X X X`7B Give name for most items in inventory`09`09`09`09-Cap'n-`09`7D X`5Bglobal,psect(misc6$code)`5D function lore_spell : boolean; X var X`09`09redraw`09`09`09: boolean; X`09`09thingy`09`09`09: treas_ptr; X begin X`09lore_spell := true; X`09thingy := inventory_list; X`09while (thingy <> nil) do X`09 begin X`09 if (not am_i_dumb) then`20 X`09 begin X`09`09identify(thingy`5E.data); X`09`09known2(thingy`5E.data.name); X`09 end; X `09 thingy := thingy`5E.next; X`09 end; X end; X X X`09`7B Shoot a bolt in a given direction`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function fire_bolt`09( X`09`09`09typ,dir,y,x,dam : integer; X`09`09`09bolt_typ`09: ctype X`09`09`09`09`09) : boolean; X var X`09i1,oldy,oldx,dist`09`09: integer; X`09weapon_type,harm_type`09`09: integer; X`09dummy`09`09`09`09: obj_set; X`09str,str2`09`09`09: vtype; X X function ill_joke(a_cptr : integer) : boolean; X var i2 : integer; X begin X`09ill_joke := true; X`09find_monster_name(str,a_cptr,false); X`09find_monster_name(str2,a_cptr,true); X`09with m_list`5Ba_cptr`5D do X`09 with c_list`5Bmptr`5D do X`09 if (not mon_save(a_cptr,0,c_sc_mental)) then X`09 begin X`09`09confused := true; X`09`09i2 := mon_take_hit(a_cptr,dam); X`09`09if (typ=c_illusion) then X`09`09 begin X`09`09 msg_print(str2+' seems to believe the illusion...'); X`09`09 if (i2>0) then X`09`09`09msg_print('and dies from fright!') X`09`09 else X`09`09`09msg_print('and appears quite shaken.'); X`09`09 end X`09`09else X`09`09 begin X`09`09 msg_print('The punch line strikes '+str+'...'); X`09`09 if (i2>0) then X`09`09`09msg_print('who dies in a fit of laughter!') X`09`09 else X`09`09`09msg_print('who becomes weak from laughter!'); X`09`09 end; X`09 end X`09 else X`09 if (typ=c_illusion) then X`09`09msg_print(str2+' is unaffected.') X`09 else X`09`09begin X`09`09 find_monster_name(str,a_cptr,true); X`09`09 msg_print(str+' appears offended...'); X`09`09 if (mon_take_hit(a_cptr,dam div 4)>0) then X`09`09 msg_print('but your joke still knocks it dead!'); X`09`09end; X end; X X begin X`09fire_bolt := true; X`09get_flags(typ,weapon_type,harm_type,dummy); X`09dist := 0; X`09if bolt_to_creature(dir,y,x,dist,obj$bolt_range,true) then X`09 with cave`5By,x`5D do X`09 if (typ in `5Bc_illusion,c_joke`5D) then X`09 ill_joke(cptr) X`09 else X`09 with m_list`5Bcptr`5D do X`09 with c_list`5Bmptr`5D do X`09`09if (not mon_resists(cptr)) then X`09`09begin X`09`09 find_monster_name(str,cptr,false); X`09`09 find_monster_name(str2,cptr,true); X`09`09 msg_print('The ' + bolt_typ + ' strikes '+str+'.'); X`09`09 if (uand(harm_type,cdefense) <> 0) then X`09`09`09dam := dam*2 X`09`09 else if (uand(weapon_type,spells) <> 0) then X`09`09`09dam := trunc(dam/4.0); X`09`09 if (mon_take_hit(cptr,dam) > 0) then X`09`09 msg_print(str2 + ' dies in a fit of agony.') X`09`09 else X`09`09 if (panel_contains(y,x)) then X`09`09`09begin X`09`09`09 print(cchar,y,x); X`09`09`09 ml := true; X`09`09`09end; X`09`09end X end; X X X X`5Bglobal,psect(misc6$code)`5D function explode`09 ( X`09`09`09typ,y,x,dam_hp`09 :`09 integer; X`09`09`09descrip`09`09`09:`09ctype X`09`09`09`09`09`09) : boolean; X var X`09i1,i2,i3`09`09`09: integer; X`09dam,max_dis,thit,tkill`09`09: integer; X`09weapon_type,harm_type`09`09: integer; X`09destroy`09`09`09`09: obj_set; Xbegin X explode := true; X thit`09 := 0; X tkill`09 := 0; X max_dis := 2; X get_flags(typ,weapon_type,harm_type,destroy); X for i1 := y-max_dis to y+max_dis do X for i2 := x-max_dis to x+max_dis do X if (in_bounds(i1,i2)) then X`09if (distance(y,x,i1,i2) <= max_dis) then X`09 if (los(y,x,i1,i2)) then`09 `7B FIXED BUG V4.5`09 `7D X`09 with cave`5Bi1,i2`5D do X`09 begin X`09`09if (tptr > 0) then X`09`09 if (t_list`5Btptr`5D.tval in destroy) then delete_object(i1,i2); X`09`09 if (fopen) then X`09`09 begin X`09`09 if (panel_contains(i1,i2)) then print('*',i1,i2); X`09`09 if (cptr > 1) then X`09`09 with m_list`5Bcptr`5D do X`09`09`09with c_list`5Bmptr`5D do X`09`09`09begin X`09`09`09 dam := dam_hp; X`09`09`09 if (typ in `5Bc_illusion,c_joke`5D) then X`09`09`09 if (mon_save(cptr,0,c_sc_mental)) then X`09`09`09 if (typ=c_illusion) then X`09`09`09`09dam := 0 X`09`09`09 else X`09`09`09`09dam := dam div 4 X`09`09`09 else X`09`09`09 confused := true; X`09`09`09 if (uand(harm_type,cdefense) <> 0) then X`09`09`09 dam := dam*2 X`09`09`09 else if (uand(weapon_type,spells) <> 0) then X`09`09`09 dam := dam div 4; X`09`09`09 dam := trunc(dam/(distance(i1,i2,y,x)+1)); X`09`09`09 if ((dam > 0) and (not mon_resists(cptr))) then X`09`09`09 begin X`09`09`09 thit := thit + 1; X`09`09`09 if (mon_take_hit(cptr,dam) > 0) then X`09`09`09`09tkill := tkill + 1 X`09`09`09 else X`09`09`09`09begin X`09`09`09`09 if (panel_contains(i1,i2)) then X`09`09`09`09 begin X`09`09`09`09 print(cchar,i1,i2); X`09`09`09`09 ml := true; X`09`09`09`09 end X`09`09`09`09end; X`09`09`09 end; X`09`09`09end; X`09`09 end; X`09 end; X for i1 := y-max_dis to y+max_dis do X for i2 := x-max_dis to x+max_dis do X if (in_bounds(i1,i2)) then X`09if (panel_contains(i1,i2)) then X`09 if (distance(y,x,i1,i2) <= max_dis) then X`09 begin X`09 with cave`5Bi1,i2`5D do X`09 if (test_light(i1,i2)) then X`09`09lite_spot(i1,i2) X`09 else if (cptr = 1) then X`09`09lite_spot(i1,i2) X`09 else if (cptr > 1) then X`09`09if (m_list`5Bcptr`5D.ml) then X`09`09 lite_spot(i1,i2) X`09`09else X`09`09 unlite_spot(i1,i2) X`09 else X`09`09unlite_spot(i1,i2); X`09 end; X`09`7B End explosion...`09`09`09`7D X`09 if (thit = 1) then X`09 msg_print('The ' + descrip + ' envelopes a creature!') X`09 else if (thit > 1) then X`09 msg_print('The ' + descrip + ' envelopes several creatures!'); X`09 if (tkill = 1) then X`09 if (typ=c_joke) then X`09 msg_print('There is a scream of side-splitting laughter!') X`09 else X`09 msg_print('There is a scream of agony!') X`09 else if (tkill > 1) then X`09 if (typ=c_joke) then X`09 msg_print('There are several screams of agonized laughter!') X`09 else X`09 msg_print('There are several screams of agony!'); X`09`7B End ball hitting...`09`09`09`7D X end; X X`09`7B Shoot a ball in a given direction. Note that balls have an`09`7D X`09`7B area affect....`09`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function fire_ball (`09 X`09`09`09typ,dir,y,x,dam_hp`09:`09integer; X`09`09`09descrip`09`09 `09:`09ctype X`09`09`09`09`09`09) : boolean; X var X`09dist`09`09`09: integer; X begin X`09dist := 0; X`09fire_ball := false; X`09if bolt_to_creature(dir,y,x,dist,obj$bolt_range,true) then X`09 explode(typ,y,x,dam_hp,descrip) X`09else if (dist <= obj$bolt_range) then X`09 begin X`09 move(10-dir,y,x); X`09 fire_ball := explode(typ,y,x,dam_hp,descrip); X`09 end; X end; X X X`09`7B Creeping doom type spells, a missile, but with a set range`09`7D X`5Bglobal,psect(misc6$code)`5D function creeping_doom`09( X`09`09`09dir,y,x,dam_hp,range`09: integer; X`09`09`09ddesc`09`09`09: ctype X`09`09`09`09`09`09) : boolean; X var X`09i1,oldy,oldx,dist`09`09: integer; X`09flag`09`09`09`09: boolean; X`09dummy`09`09`09`09: obj_set; X begin X`09dist := 0; X`09creeping_doom := true; X`09if bolt_to_creature(dir,y,x,dist,range,true) 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 if (not mon_resists(cptr)) then X`09 begin X`09`09msg_print('The '+ddesc+' hits the '+c_list`5Bmptr`5D.name+'.'); X`09`09if (mon_take_hit(cptr,dam_hp) > 0) then X`09`09 msg_print('The '+c_list`5Bi1`5D.name+' dies in a fit of agony.') X`09 else X`09`09 if (panel_contains(y,x)) then X`09`09 begin X`09`09 print(c_list`5Bmptr`5D.cchar,y,x); X`09`09 m_list`5Bcptr`5D.ml := true; X`09`09 end; X`09 end X end; X X X`09`7B Fire a spell that affects a line of monsters`09`09`09`7D X`5Bglobal,psect(misc6$code)`5D function fire_line`09`09( X`09`09`09typ,dir,y,x,dam_hp`09: integer; X`09`09`09descrip`09`09`09: ctype X`09`09`09`09`09`09) : boolean; X var X`09i1,oldy,oldx,dist`09`09: integer; X`09weapon_type,harm_type`09`09: integer; X`09flag`09`09`09`09: boolean; X`09dummy`09`09`09`09: obj_set; X begin X`09fire_line := true; X`09get_flags(typ,weapon_type,harm_type,dummy); X`09dist := 0; X`09while bolt_to_creature(dir,y,x,dist,obj$bolt_range,true) do 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 if (not mon_resists(cptr)) then X`09 begin X`09msg_print('The '+descrip+' strikes the '+c_list`5Bmptr`5D.name+'.'); X`09`09if (uand(harm_type,cdefense) <> 0) then X`09`09 dam_hp := dam_hp * 2 X`09`09else if (uand(weapon_type,spells) <> 0) then X`09`09 dam_hp := trunc(dam_hp/4.0); X`09`09if (mon_take_hit(cptr,dam_hp) > 0) then X`09`09 msg_print('The '+c_list`5Bi1`5D.name+' dies in a fit of agony.') X`09`09else X`09`09 begin X`09`09 if (panel_contains(y,x)) then X`09`09 begin X`09`09`09print(c_list`5Bmptr`5D.cchar,y,x); X`09`09`09m_list`5Bcptr`5D.ml := true; X`09`09 end; X`09`09 end X`09 end X end; X X X`09`7B Breath weapon works like a fire_ball, but affects the player. `7D X`09`7B Note the area affect....`09`09`09`09-RAK-`09`7D X`5Bglobal,psect(misc6$code)`5D function breath`09`09( X`09`09`09typ,y,x,dam_hp`09`09:`09integer; X`09`09`09ddesc`09`09`09:`09vtype X`09`09`09`09`09`09) : boolean; X var X`09i1,i2,i3`09`09`09: integer; X`09dam,max_dis`09`09`09: integer; X`09weapon_type,harm_type`09`09: integer; X`09flag`09`09`09`09: boolean; X`09destroy`09`09`09`09: obj_set; X begin X`09breath := true; X`09max_dis := 2; X`09get_flags(typ,weapon_type,harm_type,destroy); X`09for i1 := y-2 to y+2 do X`09 for i2 := x-2 to x+2 do X`09 if (in_bounds(i1,i2)) then X`09 if (distance(y,x,i1,i2) <= max_dis) then X`09`09with cave`5Bi1,i2`5D do X`09`09 begin X`09`09 if (tptr > 0) then X`09`09 if (t_list`5Btptr`5D.tval in destroy) then X`09`09`09delete_object(i1,i2); X`09`09 if (fopen) then X`09`09 begin X`09`09`09if (panel_contains(i1,i2)) then X`09`09`09 print('*',i1,i2); X`09`09`09if (cptr > 1) then X`09`09`09 with m_list`5Bcptr`5D do X`09`09`09 with c_list`5Bmptr`5D do X`09`09`09 begin X`09`09`09`09dam := dam_hp; X`09`09`09`09if (uand(harm_type,cdefense) <> 0) then X`09`09`09`09 dam := dam*2 X`09`09`09`09else if (uand(weapon_type,spells) <> 0) then X`09`09`09`09 dam := trunc(dam/4.0); X`09`09`09`09dam := trunc(dam/(distance(i1,i2,y,x)+1)); X`09`09`09`09if (not mon_resists(cptr)) then X`09`09`09`09 hp := hp - dam; X`09`09`09`09csleep := 0; X`09`09`09`09if (hp < 0) then X`09`09`09`09 begin X`09`09`09`09 monster_death(fy,fx,cmove); X`09`09`09`09 delete_monster(cptr); X`09`09`09`09 end; X`09`09`09 end X`09`09`09else if (cptr = 1) then X`09`09`09 begin X`09`09`09 dam := trunc(dam_hp/(distance(i1,i2,y,x)+1)); X`09`09`09 case typ of X`09`09`09`091 :`09light_dam(dam,ddesc); X`09`09`09`092 :`09poison_gas(dam,ddesc); X`09`09`09`093 :`09acid_dam(dam,ddesc); X`09`09`09`094 :`09cold_dam(dam,ddesc); X`09`09`09`095 :`09fire_dam(dam,ddesc); X`09`09`09`097 :`09xp_loss(dam); X`09`09`09 end; X`09`09`09 end; X`09`09 end; X`09`09 end; X`09for i1 := (y - 2) to (y + 2) do X`09 for i2 := (x - 2) to (x + 2) do X`09 if (in_bounds(i1,i2)) then X`09 if (panel_contains(i1,i2)) then X`09`09if (distance(y,x,i1,i2) <= max_dis) then X`09`09 begin X`09`09 with cave`5Bi1,i2`5D do X`09`09 if (test_light(i1,i2)) then +-+-+-+-+-+-+-+- END OF PART 78 +-+-+-+-+-+-+-+-