-+-+-+-+-+-+-+-+ START OF PART 9 -+-+-+-+-+-+-+-+ X`09if is_object then X`09begin X`09 if object_location(x,y,true) 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_get; X`09 end; X`09end; X end; X end; X end; X X procedure make_enemy; X var X i,count:integer := 0; X begin X repeat X count := count + 1; X i := rnum(maxplayers); X until (person`5Bi`5D.here and (i <> plr`5Bnow`5D.log)) or (count > 500); X if person`5Bi`5D.here then X begin X act_out(plr`5Bnow`5D.log,e_challenge,pl`5Bnow`5D.where.x,pl`5Bnow`5D.w Vhere.y,i); X remember_attack(i,1); X end; X end; X X procedure be_yourself; X var X saying:array`5B1..5`5D of string := ( X`09'Hello', X`09'This is cool', X`09'Greetings, mortal.', X`09'What''s new?', X`09'Booga'); X begin X if low_health then do_mission(mission_hide) X else if pl`5Bnow`5D.attrib`5Bat_points`5D > 0 then do_mission(mission_pr Vay) X else if plr`5Bnow`5D.dest.mission <> 0 then do_mission(plr`5Bnow`5D.dest V.mission) X else X case rnum(10000) of X 1..50:do_mission(mission_hide); X 51..55:say_prime('roars',saying`5Brnum(5)`5D,snd_normal); X 56..150:make_enemy; X 151..2000:do_go(rnum(8)); X2001..4000:if plr`5Bnow`5D.hands then do_mission(mission_get); X end; X end; X Xbegin X repeat X if monsters_active > 0 then X begin X if (monsters_active < maxmonsters - 3) then possess_someone; X now := now + 1; X if now > maxmonsters then X begin X`09now := 1; X`09wait((2+maxmonsters-monsters_active)/10); X end; X if (not frozen) and not pl`5Bnow`5D.sts`5Bps_dead`5D.on then X begin X allacts; X`09if low_health then do_mission(mission_hide) X`09else if find_enemy(slot) then attack_enemy X`09else if find_friend then be_nice X`09else be_yourself; X end; X end X else monitor_room; X until all_done; Xend; X Xprocedure setup_randoms; Xvar X i:integer; Xbegin X writeln('setup_randoms'); X for i := 1 to maxmonsters do X begin X pl`5Bi`5D.sts`5Bps_dead`5D.on := true; X plr`5Bi`5D.awake := 0; X end; X for i := 1 to maxplayers do X if (indx`5Bi_npc`5D.on`5Bi`5D) and (indx`5Bi_ingame`5D.on`5Bi`5D) and X (an_int`5Bn_location`5D.int`5Bi`5D = here.valid) and X (monsters_active <= maxmonsters) then possess_someone(i); X check_room; X set_mbx_ast; Xend; X Xprocedure save_randoms; Xbegin X for now := 1 to maxmonsters do X if not pl`5Bnow`5D.sts`5Bps_dead`5D.on then save_player; Xend; X Xprocedure delete_outfile; Xvar X s:string; Xbegin X writev(s,'sys$scratch:out_',room_number:0,'.sr'); X lib$delete_file(s); Xend; X Xprocedure set_protection; Xvar X s:string; Xbegin X writev(s,'sys$scratch:out_',room_number:0,'.sr'); X add_acl(s,'(identifier=`5Bmas`5D,access=read+write+execute+delete)'); X add_acl(s,'(identifier=`5B'+srop+'`5D,access=read+write+execute+delete)'); X add_acl(s,'(identifier=`5Bmas$user7`5D,access=read+write+execute+delete)') V; Xend; X Xbegin X debug := false; X set_protection; X if create_mymbx('MASTERBOX') then X if setup_things then X begin X set_protection; X setup_randoms; X writeln('Control'); X control; X deassign_channel(mychannel); X save_randoms; X writeln('Save_randoms'); X end X else writeln('Could not create mailbox'); X delete_outfile; Xend. $ CALL UNPACK SRGOD.PAS;1 709474576 $ create 'f' X`5Binherit ('srinit','srsys','srother','srmove','srmisc','srio'), X environment('srgodact')`5D X Xmodule srgodact; X Xconst X path_unknown`09= 0; X path_right`09= 1; X path_left`09= 2; Xtype X mazerec = record; X path:integer; X steps:integer; X direction:integer; X end; Xvar X maze:array`5B1..maxmonsters`5D of mazerec; X pathname:array`5B0..2`5D of shortstring := ('unknown','right','left'); X asynch_possess:`5Bvolatile`5D boolean := false; X X`5Bhidden,external,asynchronous`5D Xprocedure possess_someone(log:integer := 0); Xexternal; X X`5Bhidden,external,asynchronous`5D Xprocedure forget_mission(x,y:integer); Xexternal; X X`5Basynchronous`5D Xprocedure remember(sendlog,x,y,base,head,mask:integer); Xbegin X person`5Bsendlog`5D.alive := unmask(mask,m_alive); X person`5Bsendlog`5D.here := true; X person`5Bsendlog`5D.loc.x := x; X person`5Bsendlog`5D.loc.y := y; X person`5Bsendlog`5D.feet := base; X person`5Bsendlog`5D.head := head; Xend; X Xprocedure follow(x,y:integer); X X function choose(a,b:integer):integer; X begin X case rnum(2) of X 1:choose := a; X 2:choose := b; X end; X end; X X procedure try(a,b,c,d,e,f,g:integer := 0); X var X dd:array`5B1..7`5D of integer; X max_try,tempx,tempy:integer; X i:integer := 1; X moved:boolean := false; X begin X dd`5B1`5D := a; X if d = 0 then X begin X dd`5B2`5D := choose(b,c); X if dd`5B2`5D = b then dd`5B3`5D := c X else dd`5B3`5D := b; X max_try := 3; X end X else X begin X dd`5B2`5D := b; X dd`5B3`5D := c; X dd`5B4`5D := d; X dd`5B5`5D := e; X dd`5B6`5D := f; X dd`5B7`5D := g; X max_try := 7; X end; X while (i <= max_try) and not moved do X begin X new_coords(pl`5Bnow`5D.where.x,pl`5Bnow`5D.where.y,tempx,tempy,dd`5Bi` V5D); X if can_move(tempx,tempy,dd`5Bi`5D,false) then X begin X moved := true; X do_go(dd`5Bi`5D); X`09if maze`5Bnow`5D.path <> 0 then X`09begin X`09 maze`5Bnow`5D.direction := dd`5Bi`5D; X`09 maze`5Bnow`5D.steps := maze`5Bnow`5D.steps - 1; X`09 if maze`5Bnow`5D.steps = 0 then maze`5Bnow`5D.path := path_unknown; X`09end; X end; X i := i + 1; X end; X if not moved and (maze`5Bnow`5D.path <> 0) then X begin X if maze`5Bnow`5D.path = path_right then maze`5Bnow`5D.path := path_lef Vt X else maze`5Bnow`5D.path := path_right; X end X else if not moved then X begin X maze`5Bnow`5D.path := rnum(2);`09`7Bright/left`7D X case maze`5Bnow`5D.path of Xpath_right: X`09case dd`5B1`5D of X`091:maze`5Bnow`5D.direction := 3; X`092:maze`5Bnow`5D.direction := 6; X`093:maze`5Bnow`5D.direction := 9; X`094:maze`5Bnow`5D.direction := 2; X`096:maze`5Bnow`5D.direction := 8; X`097:maze`5Bnow`5D.direction := 1; X`098:maze`5Bnow`5D.direction := 4; X`099:maze`5Bnow`5D.direction := 7; X`09end; Xpath_left: X`09case dd`5B1`5D of X`091:maze`5Bnow`5D.direction := 7; X`092:maze`5Bnow`5D.direction := 4; X`093:maze`5Bnow`5D.direction := 1; X`094:maze`5Bnow`5D.direction := 8; X`096:maze`5Bnow`5D.direction := 2; X`097:maze`5Bnow`5D.direction := 9; X`098:maze`5Bnow`5D.direction := 6; X`099:maze`5Bnow`5D.direction := 3; X`09end; X end; X if rnum(4) = 1 then maze`5Bnow`5D.steps := bell(40,2) X else maze`5Bnow`5D.steps := rnum(4); X end; X end; X Xbegin X if maze`5Bnow`5D.path = path_unknown then X begin X if (x < pl`5Bnow`5D.where.x) then X begin X if (y < pl`5Bnow`5D.where.y) then try(7,8,4) X else if (y > pl`5Bnow`5D.where.y) then try(1,2,4) X else try(4,1,7); X end X else if (x > pl`5Bnow`5D.where.x) then X begin X if (y < pl`5Bnow`5D.where.y) then try(9,6,8) X else if (y > pl`5Bnow`5D.where.y) then try(3,2,6) X else try(6,3,9); X end X else if y < pl`5Bnow`5D.where.y then try(8,7,9) X else if y > pl`5Bnow`5D.where.y then try(2,1,3); X end X else X case maze`5Bnow`5D.path of Xpath_right: X case maze`5Bnow`5D.direction of X`091:try(7,4,1,2,3,6,9); X`092:try(4,1,2,3,6,9,8); X`093:try(1,2,3,6,9,8,7); X`094:try(8,7,4,1,2,3,6); X`096:try(2,3,6,9,8,7,4); X`097:try(9,8,7,4,1,2,3); X`098:try(6,9,8,7,4,1,2); X`099:try(3,6,9,8,7,4,1); X end; Xpath_left: X case maze`5Bnow`5D.direction of X`091:try(3,2,1,4,7,8,7); X`092:try(6,3,2,1,4,7,8); X`093:try(9,6,3,2,1,4,7); X`094:try(2,1,4,7,8,9,6); X`096:try(8,9,6,3,2,1,4); X`097:try(1,4,7,8,9,6,3); X`098:try(4,7,8,9,6,3,2); X`099:try(7,8,9,6,3,2,1); X end; X end; Xend; X X`5Basynchronous`5D Xprocedure plot_player(theirlog,x,y,p1,p2:integer); Xbegin X people_map`5Bx,y`5D := theirlog; X person`5Btheirlog`5D.loc.x := x; X person`5Btheirlog`5D.loc.y := y; X person`5Btheirlog`5D.feet := p1; X person`5Btheirlog`5D.head := p2; Xend; X X`5Basynchronous,global`5D Xprocedure unplot_player(theirlog:integer); Xbegin X with person`5Btheirlog`5D.loc do X begin X people_map`5Bx,y`5D := 0; X fix_scenery(x,y); X end; Xend; X X`5Basynchronous`5D Xprocedure bump_me(s:string); Xbegin X wl(s+' bumps into you.'); X do_go(1+rnd mod 9); Xend; X X`5Basynchronous`5D Xfunction soundfrom(x,y:integer):string; Xvar X slope:real; Xbegin X slope := (y-pl`5Bnow`5D.where.y)/(0.1+x-pl`5Bnow`5D.where.x); X if y-pl`5Bnow`5D.where.y < 0 then X begin X if abs(slope) > 1 then soundfrom := dir`5Bd_north`5D X else if x-pl`5Bnow`5D.where.x > 0 then soundfrom := dir`5Bd_east`5D X else soundfrom := dir`5Bd_west`5D; X end X else X begin X if abs(slope) > 1 then soundfrom := dir`5Bd_south`5D X else if x-pl`5Bnow`5D.where.x > 0 then soundfrom := dir`5Bd_east`5D X else soundfrom := dir`5Bd_west`5D; X end; Xend; X X`5Bglobal,asynchronous`5D Xprocedure handle_act; Xvar X i,j,loop,moron,n,old_now,sendlog,theact,x,y,p1,p2,p3,p4:integer; X a_loc:loc; X sendname:shortstring; X s,ss:$udata; X dummy_channel:$uword; X X procedure remember_coords; X begin X person`5Bsendlog`5D.loc.x := x; X person`5Bsendlog`5D.loc.y := y; X end; X Xprocedure handle_prime(room_process:boolean := false); Xbegin X now := loop; X case theact of X Xe_attack:`7Bx,y,target,compress(damage,randomness),element,radius`7D Xif not room_process then Xif p1 = plr`5Bnow`5D.log then Xbegin X decompress(p2,i,j,moron); X if not pl`5Bnow`5D.sts`5Bps_dead`5D.on then X if in_range(x,y,p4) then X begin X remember_attack(sendlog,bell(i,j)); X get_attack(sendlog,x,y,i,j,p3,s) X end X else if not pl`5Bnow`5D.sts`5Bps_dead`5D.on then act_out(plr`5Bnow`5D.log, Ve_msg,pl`5Bnow`5D.where.x, X`09pl`5Bnow`5D.where.y,0,sendlog,,,name`5Bna_player`5D.id`5Bplr`5Bnow`5D.log V`5D+ X`09' dances outside your range.') X else act_out(plr`5Bnow`5D.log,e_msg,pl`5Bnow`5D.where.x,pl`5Bnow`5D.where. Vy,0,sendlog X`09,,,name`5Bna_player`5D.id`5Bplr`5Bnow`5D.log`5D+' says, "I''m already dea Vd!"'); Xend; X Xe_activate: Xif room_process then Xbegin X act_out(0,e_msg,,,,,,,'No no no.'); Xend; X Xe_assign: Xif room_process then Xbegin X if unmask(p1,m_first_in) then readnames; X begin X indx`5Bi_ingame`5D.on`5Bsendlog`5D := true; X assign_channel(s,person`5Bsendlog`5D.channel); X person`5Bsendlog`5D.here := true; X act_out(0,e_ack,,,,,,,,,,sendlog); X end; Xend; X Xe_booga: Xif room_process then Xremember(sendlog,x,y,p1,p2,p4); X Xe_bump: Xif not room_process then Xif (x = pl`5Bnow`5D.where.x) and (y = pl`5Bnow`5D.where.y) and not pl`5Bnow` V5D.sts`5Bps_dead`5D.on Xthen get_bump(sendlog,p1,p2,sendname,s); X Xe_challenge: Xif p1 = plr`5Bnow`5D.log then Xbegin X if find_enemy(moron) then act_out(plr`5Bnow`5D.log,e_refuse,,,sendlog) X else remember_attack(sendlog,1); Xend; X Xe_refuse: Xif p1 = plr`5Bnow`5D.log then forget_attack(p1); X Xe_deassign: Xif room_process then Xbegin X deassign_channel(person`5Bsendlog`5D.channel); X indx`5Bi_ingame`5D.on`5Bsendlog`5D := false; X person`5Bsendlog`5D.here := false; Xend; X Xe_reborn: Xif room_process then person`5Bsendlog`5D.alive := true; X Xe_died: Xif not room_process then Xbegin X person`5Bsendlog`5D.alive := false; X forget_attack(sendlog); X if x = plr`5Bnow`5D.log then X begin X act_out(plr`5Bnow`5D.log,e_msg,,,,,,,name`5Bna_player`5D.id`5Bplr`5Bnow` V5D.log`5D+ X`09' says, "Ha ha, '+ss+'"'); X if y > 0 then n := trunc((ln(y) + p1)*p2/p3) X else n := trunc(p1*p2/p3); X change_stat_ex(st_experience,pl`5Bnow`5D.attrib_ex`5Bst_experience`5D + V n); X change_stat_ex(st_kills,pl`5Bnow`5D.attrib_ex`5Bst_kills`5D + 1); X change_stat(at_points,pl`5Bnow`5D.attrib`5Bat_points`5D + n); X save_player; X end; Xend; X Xe_drop: Xif room_process then Xbegin X fg.object`5Bp2`5D.object.num := p1; X fg.object`5Bp2`5D.loc.x := x; X fg.object`5Bp2`5D.loc.y := y; Xend; X Xe_get: Xif room_process then Xbegin X forget_foreground_object(p1); X forget_mission(x,y); Xend; X Xe_halt: Xif room_process then halt; X Xe_kill:if x = plr`5Bnow`5D.log then do_die(sendlog); X Xe_listen: Xact_out(plr`5Bnow`5D.log,e_noise,pl`5Bnow`5D.where.x,pl`5Bnow`5D.where.y, Xpl`5Bnow`5D.attrib`5Bat_noise`5D,sendlog,,,plr`5Bnow`5D.sound); X Xe_move: Xif not room_process then Xbegin X if person`5Bsendlog`5D.here then X begin X unplot_player(sendlog); X plot_player(sendlog,x,y,p1,p2); X remember_coords; X if (x = pl`5Bnow`5D.where.x) and (y = pl`5Bnow`5D.where.y) and not pl`5B Vnow`5D.sts`5Bps_dead`5D.on then bump_me(sendname); X end; Xend; X Xe_msg:; X Xe_open: Xif room_process then toggle_door(x,y,p1); X Xe_place: Xbegin X with fg.object`5Bp1`5D do X begin X loc.x := x; X loc.y := y; X object.num := p2; X icon := s`5B1`5D; X decompress(p3,base,altitude,moron); X decompress(p4,object.condition,rendition,moron); X end; X map_objects(p1); X fix_scenery(x,y); Xend; X Xe_status:if p1 = plr`5Bnow`5D.log then Xbegin X writev(s,sendname,':',stat`5Bp2`5D,' ',p3:0,' of ',p4:0,'.'); X wl(s); Xend; X Xe_req_status:if p1 = plr`5Bnow`5D.log then Xact_out(plr`5Bnow`5D.log,e_status,,,sendlog,p2,pl`5Bnow`5D.attrib`5Bp2`5D, Xpl`5Bnow`5D.attrib_max`5Bp2`5D); X Xe_remotepoof: Xif p2 = plr`5Bnow`5D.log then Xbegin X a_loc.x := x; X a_loc.y := y; X a_loc.r := p1; X poof_prime(a_loc); Xend; X Xe_pong: Xif room_process then person`5Bsendlog`5D.here := true; X Xe_possess: Xif room_process and (monsters_active <= maxmonsters) then possess_someone(x) Xelse Xbegin X if assign_channel(s,dummy_channel) then X act_out(0,e_possess_not,x,,,,,,,,,dummy_channel); Xend; X Xe_possess_not: Xif room_process and (monsters_active <= maxmonsters) then possess_someone(x) V; X Xe_spell: Xif not room_process then handle_spell(act); X Xe_walkin: Xif not room_process then Xbegin +-+-+-+-+-+-+-+- END OF PART 9 +-+-+-+-+-+-+-+-