-+-+-+-+-+-+-+-+ START OF PART 8 -+-+-+-+-+-+-+-+ X'Chadwik','Chuck','Chimlick','Cheuk','Chumliz','Carbanor','Canawok', X'Cordread','Cirith','Claus', X'Droog','Dirk','Daldy','Denowet','Draka','Dum dum','Dimwit','Dumbo','Dan', X'Elvis','Ecthel','Eneroth','Elethil','Eugumoot','Eleduin','Egor', X'Feanor','Farglatz','Farging','Fletch','Friggit', X'Gothmog','Grondin','Gagleous','Grog','Gerland','Ginreth', X'Gruziha', X'Herbruk','Halwath','Helmut','Hercimer','Howarmuk','Henkhelm','Krunk', X'Ingwe','Ingrish', X'Jerluk','Jabbalop','Jocko','Jeth','Junga','Jinga','Jimba','Jill', X'Krotche','Kunta','Killroy','Kaputa','Kuch','Kumquat','Kurgan','Khadaffy', X'Krazool', X'Lenin','Leonard','Leo','Lear','Louie','Lister','Larendil','Loketary', X'Muarasah','Morgoth','Mugwump','Melmen','Masnads','Mrokbut', X'Milknrou','Mybalon','Mordy', X'Nadien','Nupit', X'Opie','Orgrond','Orville','Ogden','Orion','Oloof', X'Pharelen','Pogo','Pfzarrak','Poofley','Proklmt', X'Rellinger','Rhunwik','Rugrat','Retred','Rocky','Rhygon','Rejuon', X'Rogundin','Roxanne', X'Scarythe','Smegma','Spunk','Sindar','Sarek','Swatme','Swishme', X'Telemcus','Talyrand','Turin','Tymeup', X'Vethrax','Vermouth','Whacker','Wonkme','Wog','Whipme'); X X`5BASYNCHRONOUS`5D FUNCTION lib$getjpi ( X`09item_code : INTEGER; X`09VAR process_id : `5BVOLATILE`5D UNSIGNED := %IMMED 0; X`09process_name : `5BCLASS_S`5D PACKED ARRAY `5B$l3..$u3:INTEGER`5D OF CHAR V := %IMMED 0; X`09%REF resultant_value : `5BVOLATILE,UNSAFE`5D ARRAY `5B$l4..$u4:INTEGER`5D V OF $UBYTE := %IMMED 0; X`09VAR resultant_string : `5BCLASS_S,VOLATILE`5D PACKED ARRAY `5B$l5..$u5:IN VTEGER`5D OF CHAR := %IMMED 0; X`09VAR resultant_length : `5BVOLATILE`5D $UWORD := %IMMED 0) : INTEGER; EXTE VRNAL; X X`5BASYNCHRONOUS`5D FUNCTION lib$init_timer ( X`09VAR context : `5BVOLATILE`5D UNSIGNED := %IMMED 0) : INTEGER; EXTERNAL; X X`5BASYNCHRONOUS`5D FUNCTION lib$delete_file ( X`09filespec : `5BCLASS_S`5D PACKED ARRAY `5B$l1..$u1:INTEGER`5D OF CHAR; X`09default_filespec : `5BCLASS_S`5D PACKED ARRAY `5B$l2..$u2:INTEGER`5D OF C VHAR := %IMMED 0; X`09related_filespec : `5BCLASS_S`5D PACKED ARRAY `5B$l3..$u3:INTEGER`5D OF C VHAR := %IMMED 0; X`09%IMMED `5BUNBOUND, ASYNCHRONOUS`5D PROCEDURE user_success_procedure := %I VMMED 0; X`09%IMMED `5BUNBOUND, ASYNCHRONOUS`5D PROCEDURE user_error_procedure := %IMM VED 0; X`09%IMMED `5BUNBOUND, ASYNCHRONOUS`5D PROCEDURE user_confirm_procedure := %I VMMED 0; X`09%IMMED user_specified_argument : `5BUNSAFE`5D INTEGER := %IMMED 0; X`09VAR resultant_name : `5BCLASS_S,VOLATILE`5D PACKED ARRAY `5B$l8..$u8:INTE VGER`5D OF CHAR := %IMMED 0; X`09VAR file_scan_context : `5BVOLATILE`5D UNSIGNED := %IMMED 0) : INTEGER; E VXTERNAL; X X`5Bexternal,asynchronous`5D Xprocedure cli$get_value(entity_desc:string; retdesc:string; len:unsigned); Xexternal; X X`5Bglobal`5D Xfunction getkey(key_mode:integer := 0):char; Xbegin X getkey := '.'; Xend; X Xfunction room_number:integer; Xvar X process_name:packed array`5B1..15`5D of char; X len:$uword := 0; `20 Xbegin X sysstatus := lib$getjpi(jpi$_prcnam,,,,process_name,len); X room_number := number(substr(process_name,1,index(process_name,' '))); Xend; X Xfunction setup_things:boolean; Xvar X dummy_channel:$uword; Xbegin X here.valid := room_number; X seed := clock; X human := false; X lib$init_timer(timercontext);`20 X openfiles; X if debug then rewrite(outfile); X %include 'root:srclass.pas'; X tickerquick := getticks; X tickernormal := getticks; X tickerslow := getticks; X privlevel := 0; X forget_all; X readnames; X readindexes; X readints; X interactive := true; X getroom(here.valid); X if assign_channel(here.mbx,dummy_channel) then X begin Xwriteln('Did assign channel to this room''s mailbox!!!'); X freeroom; X setup_things := false X end X else X begin X bug_out('Could not assign channel to this room :)'); X setup_things := true; X here.mbx := substr(mymbx,1,20); X putroom; Xwriteln('Did not assign channel to this room. Assigning channels to other.' V); X assign_channels; X end; Xend; X X`5Basynchronous,global`5D Xprocedure possess_someone(log:integer := 0); Xvar X i,j:integer := 1; X found:boolean := false; X new_monster:boolean; X s:string; X X function free_slot:boolean; X var X ii:integer := 1; X found:boolean := false; X begin X while (ii <= maxmonsters) and (not found) do X if pl`5Bii`5D.sts`5Bps_dead`5D.on then X begin X now := ii; X found := true; X end X else ii := ii + 1; X free_slot := found; X end; X X procedure select_race; X var X i,j:integer := 0; X ok:boolean := false; X begin X repeat X j := j + 1; X i := rnum(indx`5Bi_race`5D.top); X getrace(i); X freerace; X if (race.attrib`5Bat_points`5D <= here.level) and X`09(indx`5Bi_race`5D.on`5Bi`5D) then ok := true; X until ok or (j > 50); X player.attrib_ex`5Bst_race`5D := i; X end; X X procedure select_class; X var X i,j:integer := 0; X ok:boolean := false; X begin X repeat X j := j + 1; X i := rnum(maxclass); X if (class`5Bi`5D.attrib`5Bat_points`5D <= here.level) and X`09 (class_name`5Bi`5D <> '') then ok := true; X until ok or (j > 50); X player.attrib_ex`5Bst_class`5D := i; X end; X X procedure possess_prime; X var X ii:integer; X begin X found := true; X monsters_active := monsters_active + 1; X getindex(i_ingame); X indx`5Bi_ingame`5D.on`5Blog`5D := true; X putindex(i_ingame); X getint(n_location); X an_int`5Bn_location`5D.int`5Blog`5D := here.valid; X putint(n_location); X getplayer(log); X if new_monster then X begin X select_race; X select_class; X getname(na_player); X i := 1; X repeat X i := i + 1; X`09s := silly_name`5Brnum(silly_name_max)`5D + ' the ' + X`09name`5Bna_race`5D.id`5Bplayer.attrib_ex`5Bst_race`5D`5D; X until (length(s) <= shortlen) or (i = 200); X if length(s) <= shortlen then name`5Bna_player`5D.id`5Blog`5D := s X else name`5Bna_player`5D.id`5Blog`5D := name`5Bna_race`5D.id`5Bplayer. Vattrib_ex`5Bst_race`5D`5D; X putname(na_player); X for ii := 1 to at_max do player.attrib`5Bii`5D := 0; X for ii := 1 to maxspell do X if (rnum(100) < ln(here.level)) and (indx`5Bi_spell`5D.on`5Bii`5D) the Vn X begin X getspell(ii); X freespell; X if not (spell.element in `5Bel_self,el_weapon,el_missile`5D) then X`09player.spell`5Bii`5D := true X else player.spell`5Bii`5D := false; X end X else player.spell`5Bii`5D := false; X for ii := 1 to el_max do player.proficiency`5Bii`5D := round(ln(here.l Vevel)); X`7B---here add special bonus stats to monsters based on dungeon level---`7D X player.attrib`5Bat_health`5D := here.level; X player.attrib_max`5Bat_health`5D := here.level; X if rnum(4) = 1 then player.attrib`5Bat_points`5D := round(10*ln(here.l Vevel)) X else player.attrib`5Bat_points`5D := 0; X`7B---------------------------------------------------------------------`7D X player.attrib_ex`5Bst_kills`5D := 1; X player.attrib_ex`5Bst_experience`5D := 7; X player.attrib_ex`5Bst_killed`5D := 1; X end; X player.sts`5Bps_dead`5D.on := false; X player.where.r := here.valid; X free_space(player.where.x,player.where.y); X putplayer; X pl`5Bnow`5D := player; X plr`5Bnow`5D.log := log; X plr`5Bnow`5D.npc := true; X plr`5Bnow`5D.awake := 0; X plr`5Bnow`5D.dest.mission := mission_none; X plr`5Bnow`5D.dest.x := 0; X plr`5Bnow`5D.dest.y := 0; X for ii := 1 to maxthoughts do X begin X plr`5Bnow`5D.friend`5Bii`5D := 0; X with plr`5Bnow`5D.target`5Bii`5D do X begin X`09log := 0; X`09hits := 0; X`09damage := 0; X end; X end; X person`5Blog`5D.here := true; X person`5Blog`5D.alive := true; X stats; X for ii := 1 to maxnaturalweapon do X if plr`5Bnow`5D.n_weapon`5Bii`5D <> 0 then X begin X getspell(plr`5Bnow`5D.n_weapon`5Bii`5D); X freespell; X range`5Bnow,ii`5D := (pl`5Bnow`5D.proficiency`5Bspell.element`5D * spe Vll.parm`5B4`5D) div X 100; X end X else range`5Bnow,ii`5D := 0; X if new_monster then pl`5Bnow`5D.attrib`5Bat_health`5D := pl`5Bnow`5D.att Vrib_max`5Bat_health`5D; X if monsters_active > 1 then enter_room(pl`5Bnow`5D.where,,,true,true) X else enter_room(pl`5Bnow`5D.where); X end; X Xbegin X new_monster := (log = 0); X if free_slot then X begin X if (log <> 0) then X begin X if indx`5Bi_npc`5D.on`5Blog`5D then possess_prime; X end X else X begin X log := 1; X getindex(i_ingame); X freeindex; X while (log <= maxplayers) and (not found) do X if (not indx`5Bi_ingame`5D.on`5Blog`5D) and X`09(indx`5Bi_player`5D.on`5Blog`5D) and X`09(indx`5Bi_npc`5D.on`5Blog`5D) then possess_prime X else log := log + 1; X end; X end X else act_out(0,e_msg,,,,,,,'There are no free npc slots left.') Xend; X Xprocedure ping_all; Xvar X dummy:array`5B1..maxplayers`5D of boolean; X i:integer; Xbegin X`7BIf we get a e_pong before we're through setting person`5B`5D.here := fals Ve, X it's gonna ping 'em...`7D X act_out(0,e_ping,0,mychannel); X for i := 1 to maxplayers do X begin X if person`5Bi`5D.here then writeln('People here: ',name`5Bna_player`5D.i Vd`5Bi`5D,'.'); X dummy`5Bi`5D := person`5Bi`5D.here; X person`5Bi`5D.here := false; X end; X wait(10); X for i := 1 to maxplayers do X if (not person`5Bi`5D.here) and dummy`5Bi`5D then X begin X writeln('Removing player ',name`5Bna_player`5D.id`5Bi`5D,'.'); X remove_player(i,,false); X end; Xend; X Xprocedure monitor_room; Xbegin X ping_all; X possess_someone; X if empty_room then X begin X writeln('Empty room in monitor_room'); X all_done := true; X end; Xend; X Xprocedure control; Xvar X i,slot:integer; X X function find_friend:boolean; X var X i:integer; X begin X slot := 0; X for i := 1 to maxthoughts do X if plr`5Bnow`5D.friend`5Bi`5D <> 0 then slot := i; X find_friend := (slot <> 0); X end; X X function know_spell(var spellnum:integer; offensive:boolean := true):boole Van; X var X i:integer := 1; X done:boolean := false; X begin X while (i < maxspell * 5) and (not done) do X begin X spellnum := rnum(maxspell); X if pl`5Bnow`5D.spell`5Bspellnum`5D and X (indx`5Bi_offense`5D.on`5Bspellnum`5D = offensive) then done := true X else i := i + 1; X end; X know_spell := done; X end; X X procedure npc_equip; X var X i,obj_slot:integer := 0; X begin X for i := 1 to maxhold do X if (not pl`5Bnow`5D.equipped`5Bi`5D) and (pl`5Bnow`5D.equipment`5Bi`5D.n Vum <> 0) then X obj_slot := i; X do_equip(obj_slot); X end; X X procedure attack_enemy; X X function npc_attack:boolean; X var X weapon_slot:integer; X begin X npc_attack := false; X if (plr`5Bnow`5D.weapon <> 0) and X`09(plr`5Bnow`5D.range > 0) and X`09in_range( X`09person`5Bplr`5Bnow`5D.target`5Bslot`5D.log`5D.loc.x, X`09person`5Bplr`5Bnow`5D.target`5Bslot`5D.log`5D.loc.y, X`09plr`5Bnow`5D.range) then X`09npc_attack := do_cast(plr`5Bnow`5D.weapon,true) X else X begin X`09weapon_slot := select_weapon; X`09if weapon_slot <> 0 then X`09if in_range(person`5Bplr`5Bnow`5D.target`5Bslot`5D.log`5D.loc.x, X`09person`5Bplr`5Bnow`5D.target`5Bslot`5D.log`5D.loc.y, X`09range`5Bnow,weapon_slot`5D) and (range`5Bnow,weapon_slot`5D > 0) then X`09npc_attack := do_attack; X end; X end; X X function npc_spell:boolean; X var X sn:integer; X begin X if know_spell(sn,true) then npc_spell := do_cast(sn) X else npc_spell := false; X end; X X begin X if not npc_attack then X if not npc_spell then X follow(person`5Bplr`5Bnow`5D.target`5Bslot`5D.log`5D.loc.x, X`09person`5Bplr`5Bnow`5D.target`5Bslot`5D.log`5D.loc.y); X end; X X procedure be_nice; X begin X follow(person`5Bplr`5Bnow`5D.friend`5Bslot`5D`5D.loc.x, X person`5Bplr`5Bnow`5D.friend`5Bslot`5D`5D.loc.y); X end; X X function valid_destination(proper_mission:integer):boolean; X begin X with plr`5Bnow`5D.dest do X if (x <> 0) and (y <> 0) and (mission = proper_mission) then X valid_destination := true X else valid_destination := false; X end; X X function low_health:boolean; X begin X low_health := false; X if pl`5Bnow`5D.attrib_max`5Bat_health`5D <> 0 then X if pl`5Bnow`5D.attrib`5Bat_health`5D/pl`5Bnow`5D.attrib_max`5Bat_health` V5D < 0.5 then X low_health := true; X end; X X procedure do_mission(mymission:integer); X var X fg_slot,x,y:integer; X begin X if valid_destination(mymission) then X begin X if (plr`5Bnow`5D.dest.x = pl`5Bnow`5D.where.x) and X`09 (plr`5Bnow`5D.dest.y = pl`5Bnow`5D.where.y) then X case plr`5Bnow`5D.dest.mission of Xmission_pray:begin X`09 do_pray; X`09 plr`5Bnow`5D.dest.mission := mission_none; X`09 check_room; X`09 end; Xmission_hide:; Xmission_get:begin X`09 plr`5Bnow`5D.dest.mission := mission_none; X`09 do_get; X`09 npc_equip; X`09 check_room; X`09 end; X end X else follow(plr`5Bnow`5D.dest.x,plr`5Bnow`5D.dest.y); X end X else X begin X case mymission of Xmission_pray: X`09if is_college then X`09begin X`09 if foreground_location(fg_college,x,y) then X`09 begin X`09 plr`5Bnow`5D.dest.x := x; X`09 plr`5Bnow`5D.dest.y := y; X`09 plr`5Bnow`5D.dest.mission := mission_pray; X`09 say_prime('Proudly announces','I am going to college!',snd_audible); X`09 end; X`09end; Xmission_hide: X`09if is_hiding then X`09begin X`09 if foreground_location(fg_normal,x,y) then X`09 begin X`09 if foreground_found(x,y,0,pl`5Bnow`5D.attrib`5Bat_size`5D+1,fg_normal V,fg_slot) then X`09 if fg.effect`5Bfg_slot`5D.walk_through then X`09 begin X`09 plr`5Bnow`5D.dest.x := x; X`09 plr`5Bnow`5D.dest.y := y; X`09 plr`5Bnow`5D.dest.mission := mission_hide; X`09 if low_health then say_prime('Screams', X`09 'Help! Help! I''m being repressed!',snd_loud) X`09 else say_prime('Whispers','Let''s scram.',snd_normal); X`09 end X`09 else do_go(rnum(8)); X`09 end; X`09end; Xmission_get: +-+-+-+-+-+-+-+- END OF PART 8 +-+-+-+-+-+-+-+-