! use .stack 5100 %externalroutine gollum(%string (255) s) %externalroutinespec time(%stringname s) %externalstringfnspec interrupt %externalroutinespec prompt(%string(15) s) !%externalstring(255) %fnspec uinfs(%integer i) !%externalintegerfnspec dpermission(%string(11) o,u,d,f, %c ! %integer fs,t,p) !%systemroutinespec connect(%string(31) f,%integer m,h,p,%record(*)%name r, %c ! %integername flag) !%externalroutinespec disconnect(%string(255) s) !%externalintegerfnspec exist(%string(31) f) !%externalroutinespec list(%string(255) s) !%externalroutinespec run(%string(255) s) !%externalstring(255) %fnspec interrupt !%externalstring(255) %fnspec ucstring(%string(255) s) %externallongrealfnspec cputime !%externalroutinespec call(%string(31)command,%string(255)param) !%systemroutinespec load(%string (31) name, %integer type, %integername flag) !%externalintegerfnspec uinfi(%integer i) ! !====== ! %constinteger cave = 9 %constinteger amax = 14 %constinteger bmax = amax + 13 %constinteger cmax = bmax + 11 %constinteger maxthings = cmax + 6 %conststring(9) %array thingnamear(1:maxthings) = %c "tower", "river", "tree", "dwarf", "cave", "forest", "woods", "gallery", "hole", "river", "pit" (2), "manacles", "rubbish", "door", "boulder", "stairs", "grate", "bed", "telescope", "table", "chair", "throne", "cloth", "frank", "lp41", "piano", "key", "torch", "water", "food", "battery", "plant", "broom", "hat", "dagger", "rock", "poison", "jewel", "picture", "ring", "gold", "wine", "diamond" %constintegerarray thingposar(1:maxthings) = %c 12, 2, 3, 0 (4),26, 5,45,42,49,66,63, 12, 5,13, 5,28,30,29,29,37,41,60,52,70, 9, 9, 9, 9,46,58,65,63, 0,47,51, 5,27,37,43,67,70 %constintegerarray thingfar(1:maxthings) = %c 0 (bmax), 1 (8), 0 (3), 2 (6) %constintegerarray thingcar(1:maxthings) = %c 0 (cmax), 2, 3 (5) %constinteger maxrooms = 80 %constintegerarray roomar(-11:maxrooms*6) = %c 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15,14, 2, 6, 0, 0, 16, 3, 4, 1, 0, 0, 2,17,18,14, 0, 0, 0,18, 5, 2, 0, 0, 4,19,20,21, 0, 0, 22,10, 1, 7, 0, 0, 8, 7, 7, 6, 0, 0, 7, 7, 7, 7, 0, 0, 0, 8, 0, 0, 0, 0, 6,11,19,20, 0, 0, 23,12,24,10, 0, 0, 11, 7,21,19, 0, 0, 0, 0, 0, 0,25,50, 15,15, 1,15, 0, 0, 1,14,14,14, 0, 0, 16, 2,16,16, 0, 0, 17, 3,17,17, 0, 0, 18, 3,18, 4, 0, 0, 5,19,20,18, 0, 0, 19, 5,20,20, 0, 0, 20,21, 5,21, 0, 0, 15, 7,22,22, 0, 0, 14,11,23,23, 0, 0, 24, 7,24,23, 0, 0, 26, 0,27, 0,28,13, 0, 0,25, 0, 0, 0, 0,25, 0, 0, 0, 0, 0, 0, 0, 0,29,25, 0,30, 0, 0, 0,28, 0, 0,29, 0, 0, 0, 31,32,33,34,35,36, 36,31,35,32,34,49, 34,36,32,35,31,33, 35,39,31,33,36,32, 32,33,36,31,37,35, 33,35,34,36,32,31, 32,31,33,34,35,33, 31,39, 0, 0, 0,41, 38, 0,40, 0, 0, 0, 39,59, 0, 0, 0, 0, 42, 0, 0,45,38, 0, 0, 0,43, 0,44, 0, 0,42, 0, 0, 0, 0, 0, 0,42,45, 0,46, 41,44, 0, 0, 0, 0, 47,44, 0, 0, 0, 0, 61,49, 0,46, 0, 0, 0, 0, 0,50, 0,73, 0,50,47, 0, 0, 0, 49,33,13,48, 0, 0, 0, 0,57, 0, 0, 0, 0,53, 0,56,54, 0, 52, 0, 0,59, 0,57, 52, 0, 0,58, 0, 0, 60,58, 0, 0, 0, 0, 0, 0,52, 0, 0,57, 56,60,51, 0, 0,53, 0,54, 0, 0,55, 0, 53, 0, 0,40,60, 0, 0, 0,57,59, 0,55, 0, 0,47,62, 0, 0, 61, 0,68, 0, 0, 0, 0,69, 0, 0, 0, 0, 0, 0,67,68, 0, 0, 0, 0, 0, 0,66, 0, 0,65, 0, 0, 0,68, 0,70, 0, 0,64, 0, 62,64, 0, 0,69,66, 68, 0,63, 0, 0, 0, 67, 0, 0, 0, 0, 0, 72,74,76,78,80,71, 73,75,79,72,74,76, 78,80,71,73,75,77, 79,72,74,76,78,80, 71,73,75,77,79,72, 74,76,78,80,71,73, 75,77,79,72,74,76, 78,80,71,73,77,75, 80,80,73,74,48,71, 78,77,76,75,74,73 %conststring(20) %array shortdescrip(-1:maxrooms) = %c "No exit room.", "No such room.", "Dusty track.", "Dusty track.", "Tree clearing.", "Dusty track.", "Boulder clearing.", "Dusty track.", "Woods.", "Outside cave.", "Gollum`s cave.", "Dusty track.", "Clearing.", "Tall tower.", "Inside tower.", "Forest." (11), "Small room.", "Gallery.", "Picture room.", "Bedroom.", "Large chamber.", "Observatory.", "Twisty passages.", "Little a passages.", "Twisted passages.", "Little b passages.", "Twisting passages.", "Little tunnels.", "Throne room.", "Oval chamber.", "Narrow passage.", "Low cavern.", "Purple chamber.", "Top of pit.", "Square room.", "T junction.", "River bank [East].", "Bell room.", "Rock room.", "Curved passage.", "Bottom of pit.", "Cross roads.", "Dank cell.", "Large hall [North].", "Large hall [South].", "Dim tunnel.", "River bank [West].", "Smooth room.", "Low junction.", "Yellow room.", "Pitted room.", "stinking junction.", "Dark tunnel.", "High chamber.", "Filthy room.", "Echoing passage.", "Cupboard.", "Bloodstained room.", "Wine cellar.", "Sloping junction.", "Dusty passage.", "Piano room.", "Twisty maze." (10) %ownstring(150) %array lngdes(-1:maxrooms) = %c "A small room with no apparent exit. On the wall is written: piano playing can damage your health.", "This room does not exist.", "Dusty track going East and West surrounded by impenetrable forest.", "Dusty track going East and West, North is more forest, South is a clearing with a single tree.", "Clearing surrounded by forest, there is a single tree with the word ""PLUNK"" written on it. Track to the North.", "Dusty track, river to the North, forest to South, clearing to East, track to West.", "Clearing surrounded by forest, opening in forest to North. There is a boulder in the clearing.", "Dusty track going South and East. Forest to the North and woods to the West.", "Variagated woodland and scrub.", "Rocky outcrop with a cave in it surrounded by woods.", "Gollum`s cave. Any treasure that is left here gains points. There is a light to the South.", "Dusty track with dense forest to the East and West. There is a clearing to the South.", "Clearing surrounded by forest with an opening to the West. There is a tall tower to the South in the clea ring.", "Tall tower with no windows and one door. There is forest on all sides except the North.", "Inside the tower. There are stairs going Up and Down, there is a door in the wall.", "Dense dark forest." (11), "A small room with other rooms to North and East. There are stairs going Up and Down.", "Musicians gallery overlooking a long empty hall, there is a door to the East.", "A small ornately decorated room, there are several dark patches on the walls, there is a door to the Sou th.", "Modestly sized room with a large four poster-bed in one corner. The ceiling is damp. There are stairs go ing Up and Down.", "A large hall with lots of chairs and tables scattered around. There are stairs going Down and a doorway t o the South.", "There is a large telescope in the middle of the floor. There is no roof but the walls are too high to see over. The only exit is to the East.", "A maze of twisty little passages going in all directions.", "A maze of little twisty passages going in all directions.", "A maze of twisted little passages going in all directions.", "A maze of little twisted passages going in all directions.", "A maze of twisting little passages going in all directions.", "A maze of little twisting passages going in all directions.", "A large domed room with ancient designs on the walls and a large throne in the centre. There are passages off in all directions.", "A small oval chamber hewen out of the rock. Far above is a dim light. A broad passage leads North and Sou th. There is a ramp sloping down.", "Very narrow passage opening out to the North, getting even smaller to the East.", "A low cavernous hall with entrances North, South. The walls are covered with ancient drawings a nd runes. One of these seems to say QwASzX.", "A large chamber lit by a glowing rock high in the ceiling. The walls are hung with dark purple cloth. A passage North, a corridor Up, a doorway West.", "Below is a pit full of thick sluggishly moving green mist. There is a passage to the East and a dim narro w crawlway going Up.", "A medium sized square room with its only exit to the South. Written on the wall is ""MORTAL MEN SHOULD FE AR TO GO WHERE ONLY WIZZARDS TREAD"".", "Wide T-junction going East, West and Down.", "There is a wide and fast flowing river ahead with no way to cross. The river bank goes South and North.", "A large bell shaped room with marks of excavation still on the walls. The passage to the South is littere d withe rubble, that to the North is older.", "Open room with a large stone in the middle. Small passages to the North, South and West.", "Narrow curving path going Westwards and Downwards.", "Bottom of the pit. A narrow passage leads to the East a wider one leads off to the South.", "Cross roads. You can go North, South, East or West.", "Small dank cell with srcribling on the walls. The only door is to the East.", "The North end of a large cavernous hall which echoes. There are passages off to the South and West, plus a narrow staircase going up.", "The Southern end of a large echoing hall. There are passages going North, West and Down.", "A dim tunnel going North and West. The air is very bad here.", "The West bank of a wide and fast flowing river. The path goes North and South.", "A room where the walls have been smoothed by the passing of water over the years. There are tunnels going Eastwards and Downwards.", "A low junction with passages going North, East and South. There is a ramp leading Down.", "A large room with bright yellow walls. The only exits lead Up and South.", "A very old room the walls and floor of which are pock marked. There are exits going North, Up and West.", "A junction going East, West and Down. There is a very rancid smell in the air. Frank is chained to the w all here.", "Long dark tunnel leading East and West. There is a breeze blowing along the tunnel.", "Very high roofed chamber. The doorway to the East is very ornate. there is also a small crawlway to the North.", "Cave filled with the rubbish of a previous owner. All the exits except that to the South are blocked with the rubbish.", "A long high passage that echoes as you walk along. The passage leads East and West.", "A small but fortunately empty broom cupboard. The only way out is through the roof.", "The walls are blood stained and there are manacles hanging from the ceiling. The exits go South and Down.", "A large and dusty Wine cellar. Most of the wine has gone. The exit goes South, there is a staircase wind ing up.", "A sloping junction. The main passage way goes North and South, but there are also passages leading Upwar ds and Downwards.", "A narrow, twisty and dusty passage that has not seen anyone for many years. The exits are to the North an d East.", "A piano room with a very posh piano that has seen better days. The room is lit by a sufused glow. The do orway is in the North wall.", "A complex maze of twisty passages going in all directions." (10) %conststring(125) newdes = %c "Clearing surrounded by forest, opening in forest to North. There is a boulder beside a grate over a hole in the clearing." %constinteger maxcom = 53 %conststring(4) %array comar(1:maxcom) = %c "take", "nort", "n", "sout", "s", "east", "e", "west", "w", "up", "u", "down", "d", "inve", "clim", "look", "drop", "leav", "scor", "info", "help", "drin", "eat", "open", "clos", "ente", "kill", "lock", "unlo", "plun", "say", "ligh", "quit", "go", "stop", "qwas", "bell", "jump", "thro", "burn", "chan", "snuf", "exti", "quen", "play", "wave", "emas", "free", "rele", "goto", "swee", "pois", "get" %conststring(65) %array deathmesar(1:3) = %c "Gollum does not appreciate dying so he has returned to the start.", "I have told you before about dying, this is your final warning.", "Gollum is sick of messing about. Bye bye." ! !====== ! %recordformat rf(%integer c,t,s,e) %record(rf) r %recordformat inf(%string(6) u,%integer l,b,g) !%record(inf)%arrayformat inaf(1:200) %record(inf)%arrayname inn %recordformat thingsrecf(%string(11) name,%integer pos,found,cave) %record(thingsrecf)%array thingsrec(1:maxthings) %string(11) %array posar(1:5) %integer boulder %integer deathnum %integer torch,warning %integer ratpos,deadrat %integer thisroom %integer possesions %integer tree %integer opengrate %integer open12,locked12 %integer key %string(160) par,com %integerarray newroomar(-1:maxrooms) %integer goes,best %integer lamplife %integer dwarfpres %integer deadfrank %owninteger points = 0 %integer bell %integer still ! !====== ! %string(160) %fn fromstring(%string(160) %name s, %integer x, y) %integer i %string (160) r r = "" %cycle i = x, 1, y r = r.tostring(charno(s, i)) %repeat %result = r %end %routine ps(%string(160) s) %string(160) a,b %integer width,i,j width = 80 a = s %cycle i = 1,1,length(a) charno(a,i) = 0 %if charno(a,i) = 10 %repeat start: %if length(a) > width %start %cycle i = width,-1,1 %exitif charno(a,i) = ' ' %repeat b = fromstring(a,1,i - 1) a = fromstring(a,i + 1,length(a)) printstring(b) newline -> start %finishelsestart printstring(a) newline %finish %end ! !====== ! %integerfn stoi(%string(160) s) %integer i,j,neg j = 0 neg = 0 neg = -1 %if fromstring(s,1,1) = "-" %cycle i = 1 - neg,1,length(s) j = j * 10 + charno(s,i) - '0' %repeat j = j * neg %if neg < 0 %result = j %end ! !====== ! %string(160) %fn lcstring(%string(160) s) %integer j %string(160) ans ans = s %cycle j = 1,1,length(ans) charno(ans,j) = charno(ans,j) + 'a' - 'A' %if 'A'<=charno(ans,j)<='Z' %repeat %result = ans %end ! !====== ! %routine delay %integer j,i j = 0 %cycle j = j + 1 i = 0 %cycle i = i + 1 %exitif i = 5000 %repeat %exitif j = 5000 %repeat %end ! !====== ! %integerfn confil !%integer j,flag,perm ! j = dpermission(boss,uinfs(1),"",bossfile,-1,10,addr(perm)) ! %if perm = 7 %and j = 0 %start ! con: ! connect(boss.".".bossfile,3,0,0,r,flag) ! %if flag # 0 %start ! ps("Gollum is busy at the moment. He will be with you soon.") ! ps("Try again in a moment.") ! disconnect(boss.".".bossfile) ! %stop ! -> con ! %finishelsestart ! inn == array(r_c + 32,inaf) ! %result = 0 ! %finish ! %finishelsestart ! %result = 1 ! disconnect(boss.".".bossfile) ! %finish %result = 1 %end ! !====== ! %routine runfil ! run(boss.".".infil."_".rfil) %if exist(boss.".".infil."_".rfil) = 1 %end ! !====== ! %routine trojan !%integer good,j ! j = confil ! %if j = 0 %start ! good = 0 ! %cycle j = 1,1,200 ! %if inn(j)_u = uinfs(1) %start ! points = inn(j)_l ! inn(j)_b = points %if points > inn(j)_b ! best = inn(j)_b ! goes = inn(j)_g ! inn(j)_g =inn(j)_g + 1 ! good = 1 ! %finish ! %exitif inn(j)_u = "" ! %repeat ! %if good = 0 %start ! inn(j)_u = uinfs(1) ! inn(j)_l = 0 ! inn(j)_b = 0 ! goes = 0 ! inn(j)_g = 1 ! points = inn(j)_l ! best = inn(j)_b ! points = 0 ! %finish ! %finish ! disconnect(boss.".".bossfile) %end ! !====== ! %integerfn readcom(%string(160) %name com,param) %string(160) com2 %string(15) pstr %integer sym,comno,i comno = 0 com = "" param = "" pstr = ": " pstr = tostring(7).pstr %if bell = 0 prompt(pstr) skipsymbol %while nextsymbol = ' ' %cycle readsymbol(sym) %exitif (sym = 10) %or (sym = 32) com = com.tostring(sym) %repeat com = lcstring(com) com2 = com %if sym # 10 %start skipsymbol %while nextsymbol = ' ' %cycle readsymbol(sym) %exitif sym = 10 param = param.tostring(sym) %repeat param = lcstring(param) %finish length(com2) = 4 %if length(com2) > 4 %cycle i = 1,1,maxcom comno = i %if comar(i) = com2 %repeat %result = comno %end ! !====== ! %integerfn randomize(%integer range) %owninteger keep=0,init=0 %longreal res,last res = cputime last = fracpt(res*100000) last = fracpt(last*100000) %result = intpt(last * range + 1) %end ! !====== ! %routine rat %integer i,j,k,nbp,objno,good %if ratpos # -1 %start nbp = 0 good = 0 j = 0 %cycle i = 1,1,ratpos j = randomize(6) + j %repeat j = j - 6 %while j > 6 %cycle nbp=roomar((ratpos-1)*6+j) %exitif nbp # 0 %and nbp # ratpos j = J + randomize(6) j = j - 6 %if j > 6 %repeat ratpos = nbp %if ratpos = thisroom %start %cycle j = 1,1,possesions deadrat = 1 %if posar(j) = "poison" objno = 0 %cycle i = cmax + 1,1,maxthings good = 1 %and objno = i %if thingsrec(i)_name = posar(j) %repeat %if objno > 0 %start %if j < possesions %start %cycle k=j,1,possesions-1 posar(k) = posar(k+1) %repeat %finish posar(possesions) = "" possesions = possesions-1 %finish %repeat %finishelsestart %cycle j=1,1,6 %if roomar((ratpos-1)*6+j) = thisroom %start ps("I hear snuffling.") %exit %finish %repeat %finish %if good = 1 %start ps("Gollum was attacked by a giant RAT which took all your treasure.") %finish %finish ratpos = -1 %if deadrat = 1 %end ! !====== ! %routine describe %integer j,good,count,perm perm = 0 count = 0 perm = 1 %if thisroom > 24 %and torch = 0 %if newroomar(thisroom) > 0 %and perm = 0 %start ps(lngdes(thisroom)) newroomar(thisroom) = newroomar(thisroom) - 1 points = points + 1 %if newroomar(thisroom) = 1 %finishelsestart ps(shortdescrip(thisroom)) %finish good = 0 %cycle j = bmax + 1,1,maxthings good = good + 1 %if thingsrec(j)_pos = thisroom %repeat %if good >= 1 %start printstring("Lying here ") %if good = 1 %then printstring("is") %else printstring("are") %cycle j=bmax + 1,1,maxthings %if thingsrec(j)_pos = thisroom %start printstring(", ") %if count # 0 printstring(" ".thingsrec(j)_name) count = 1 %finish %repeat ps(".") %finish %end ! !====== ! %routine move(%string(1) where) %conststring(1) %array dir(1:6) = %c "N","S","E","W","U","D" %integer i,indir,newroom %cycle i=1,1,6 indir = i %if dir(i) = where %repeat newroom = roomar((thisroom-1)*6+indir) %if tree = 1 %start %if indir = 6 %start tree = 0 %finishelsestart ps("I am up a tree, remember !") %finish %finishelsestart %if newroom > 0 %start thisroom = newroom rat %finishelsestart ps("I can`t go in that direction.") %finish %finish %end ! !====== ! %routine inventory %integer i %if possesions # 0 %start ps("Gollum is carrying the following....") %cycle i = 1,1,possesions write(i,3) ps(". ".posar(i)) %repeat %finishelsestart ps("Gollum is carrying nothing.") %finish still = still + 1 %end ! !====== ! %routine climb(%string(160) what) %integer sym,found %if what = "" %start prompt("Climb what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish found = 0 %if roomar((thisroom-1)*6+5) # 0 %start move("U") %finish %if what = "tree" %start found = 1 ps("So we are up a tree, now what ?") tree = 1 %finish %if what = "tower" %start found = 1 ps("It is too smooth to climb.") %finish %if what = "pit" %start found = 1 ps("That probably is not a good idea.") %finish %if found = 0 %start ps("I don`t think I can do that.") %finish %end ! !====== ! %routine score printstring("If you were to quit now you would score") write(points,1) ps(".") still = still + 1 %end ! !====== ! %routine quit %string(160) ans %integer sym,goodans,j ps("Do you really wish to quit ?") prompt("Yes/No: ") goodans = 0 %while goodans = 0 %cycle skipsymbol %while nextsymbol = ' ' ans = "" %cycle readsymbol(sym) %exitif sym = 10 ans = ans.tostring(sym) %repeat ans = lcstring(ans) %if ans = "yes" %start printstring("Your score was") write(points,1) ps(".") ps("See you soon. Better luck next time !!") ! j = confil ! %if j = 0 %start ! %cycle j = 1,1,200 ! %if inn(j)_u = uinfs(1) %start ! inn(j)_l = points %andexit ! %finish ! %repeat ! %finishelse still = still + 1 ! disconnect(boss.".".bossfile) %stop %finish %if ans = "no" %then goodans = 1 %if goodans = 0 %start ps("Answer the question [scum]. Yes or no.") %finish %repeat %end ! !====== ! %routine take(%string(160) what) %integer sym,inroom,i,objno %if what = "" %start prompt("Take what ? ") skipsymbol %while nextsymbol = ' ' %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish inroom = 0 %cycle i = 1,1,maxthings objno = i %and inroom = thingsrec(i)_pos %if what = thingsrec(i)_name %repeat %if inroom = thisroom %start %if 1 <= objno <= amax %start ps("That isn`t possible.") %finish %if amax + 1 <= objno <= bmax %start ps("Why ?") %finish %if bmax + 1 <= objno %start %if possesions < 5 %start possesions = possesions + 1 points = points + thingsrec(objno)_found thingsrec(objno)_found = 0 thingsrec(objno)_pos = 0 posar(possesions) = what key = 1 %if what = "key" ps("Taken.") %finishelsestart ps("Gollum will have to drop something first.") %finish %finish %finishelsestart ps("Gollum can see no ".what.".") %finish %end ! !====== ! %routine drop(%string(160) what) %integer sym,i,j,good,k %if what = "" %start prompt("Drop what ? ") skipsymbol %while nextsymbol = ' ' %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish good = 0 %if possesions = 0 %start ps("Gollum isn`t carrying anything.") good = 1 %finishelsestart %cycle i = 1,1,possesions %if posar(i) = what %start %cycle j = i,1,possesions - 1 k = j+1; ! compiler error if j+1 used below posar(j) = posar(k) %repeat posar(possesions) = "" possesions = possesions -1 good = 1 ps("Dropped.") %cycle j = bmax + 1,1,maxthings %if thingsrec(j)_name = what %start thingsrec(j)_pos = thisroom %if thisroom = cave %then points = points + thingsrec(j)_cave %c %and thingsrec(j)_cave = 0 key = 0 %if what = "key" torch = 0 %if what = "torch" %finish %repeat %finish %repeat %finish %if good = 0 %start ps("Gollum isn`t carrying ".what) %finish still = still + 1 %end ! !====== ! %routine enter(%string(160) what) %integer sym,found %if what = "" %start prompt("Enter what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish found = 0 %if what = "cave" %start found = 1 %if thisroom = 8 %start ps("O.K.") thisroom = 9 %finishelsestart ps("Gollum can`t find a cave here.") still = still + 1 %finish %finish %if what = "hole" %and thisroom = 5 %start found = 1 %if boulder = 0 %and opengrate = 1 %start ps("O.K") thisroom = 38 %finishelsestart %if boulder = 1 %or this room # 5 %start ps("Gollum sees no hole.") still = still + 1 %finish %if boulder = 0 %and opengrate = 0 %and thisroom = 5 %start ps("The grate is closed.") still = still + 1 %finish %finish %finish %if what = "tower" %start found = 1 %if thisroom = 12 %start %if open12 = 1 %start ps("O.K.") thisroom = 13 %finishelsestart ps("The door is closed.") %finish %finishelsestart ps("Where is the tower ?") still = still + 1 %finish %finish %if what = "pit" %start found = 1 %if thisroom = 42 %or thisroom = 49 %start ps("That probably is not a good idea.") %finishelsestart ps("There is not a pit in sight.") %finish %finish %if found = 0 %start ps("Gollum doesn`t seem to be able to do that.") still = still + 1 %finish %end ! !====== ! %routine openclose(%integer i,%string(160) what) %integer sym %if what = "" %start %if i = 1 %then prompt("Open what ? ") %else prompt("Close what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish %if what = "door" %start %if thisroom = 12 %or thisroom = 13 %start %if locked12 = 1 %start %if i # open12 %start ps("O.K.") open12 = i %finishelsestart %if i = 1 %then ps("The door is already open.") %elsec ps("The door is already closed.") %finish %finishelsestart %if i = 1 %then ps("The door is locked.") %finish %finishelsestart ps("Gollum can see no door.") %finish %finish %if what = "grate" %start %if i = 1 %and thisroom = 5 %and boulder = 0 %start ps("O.K.") opengrate = 1 %finishelsestart ps("There is no grate here.") %finish %finish %if "door" # what # "grate" %start ps("Gollum can`t do that.") %finish still = still + 1 %end ! !====== ! %routine lockunlock(%integer i,%string(160) what) %integer sym %if what = "" %start %if i = 1 %then prompt("Lock what ? ") %else prompt("Unlock what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish %if what = "door" %start %if thisroom = 12 %or thisroom =13 %start %if key = 1 %start %if i = 1 %start %if locked12 = 1 %and open12 = 1 %start ps("O.K.") locked12 = 0 %finishelsestart %if locked12 = 0 %then ps("It is already locked.") %c %else ps("The door is open.") %finish %finishelsestart %if locked12 = 0 %and open12 = 0 %start ps("O.K.") locked12 = 1 %finishelsestart %if locked12 = 1 %then ps("It is already unlocked.") %c %else ps("The door is open.") %finish %finish %finishelsestart ps("Gollum has no keys.") %finish %finishelsestart ps("Gollum can`t find any doors here.") %finish %finishelsestart ps("Gollum doesn`t seem to be able to do that.") %finish still = still + 1 %end ! !====== ! %routine qwaszx %if thisroom = 40 %start ps("Dense clouds of choking smoke wrap themselves around you.") ps("When they clear you find yourself in the forest.") thisroom = 13 + randomize(11) %finishelsestart ps("Nothing happens.") still = still + 1 %finish %end ! !====== ! %routine plunk %if thisroom = 5 %and boulder = 1 %start ps("The boulder rolls to one side revealing a grate in the ground over a dark hole.") points = points + 2 lngdes(5) = newdes boulder = 0 %finishelsestart ps("Nothing happens.") %finish still = still + 1 %end ! !====== ! %routine light(%string(160) what) %integer sym,j,good %if what = "" %start prompt("Light what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish %if what = "torch" %start good = 0 %cycle j = 1,1,possesions good = 1 %if posar(j) = "torch" %repeat %if lamplife <= 0 %then good = 2 %if good = 2 %start ps("The batteries are flat.") %finish %if good = 1 %start %if torch = 0 %then ps("The torch is now on.") %c %else ps("It is already on.") torch = 1 warning = 0 %finish %if good = 0 %start ps("Gollum has no torch.") %finish %finishelsestart ps("Gollum has no ".what.".") %finish still = still + 1 %end ! !====== ! %routine look %integer j,good,count,perm perm = 0 count = 0 perm = 1 %if thisroom > 24 %and torch = 0 %if perm = 0 %then ps(lngdes(thisroom)) %c %else ps(shortdescrip(thisroom)) good = 0 %cycle j = bmax + 1,1,maxthings good = good + 1 %if thingsrec(j)_pos = thisroom %repeat %if good >= 1 %start printstring("Lying here ") %if good = 1 %then printstring("is") %else printstring("are") %cycle j=bmax + 1,1,maxthings %if thingsrec(j)_pos = thisroom %start printstring(", ") %if count # 0 printstring(" ".thingsrec(j)_name) count = 1 %finish %repeat ps(".") %finish still = still + 1 %end ! !====== ! %routine eat(%string(160) what) %integer sym,i,good,j %if what = "" %start prompt("Eat what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish %if what # "food" %start ps("Gollum does not think so.") %finishelsestart good = 0 %cycle j = 1,1,possesions %if posar(j) = "food" %start good = 1 %if j # possesions %then %start %cycle i = j,1,possesions-1 posar(i) = posar(i+1) %repeat %finish posar(possesions) = "" possesions = possesions - 1 %finish %repeat %cycle j = 1,1,maxthings %if thingsrec(j)_pos = thisroom %and thingsrec(j)_name = "food" %start points = points + thingsrec(j)_found thingsrec(j)_pos = 0 good = 1 %finish %repeat %if good = 1 %start ps("Thankyou it was scrumptious.") %finishelsestart ps("Where is the food for Gollum ??") %finish %finish still = still + 1 %end ! !====== ! %routine die %integer j,k torch = 0 still = 0 dwarfpres = 0 key = 0 tree = 0 %if possesions # 0 %start %cycle j = 1,1,possesions %cycle k = 1,1,maxthings thingsrec(k)_pos = thisroom %if thingsrec(k)_name = posar(j) thingsrec(k)_pos = cave %if thingsrec(k)_name = "torch" %repeat posar(j) = "" %repeat %finish possesions = 0 thisroom = 1 deathnum = deathnum + 1 ps(deathmesar(deathnum)) points = points - 5 warning = 0 %if deathnum = 3 %start ! j = confil ! %if j = 0 %start ! %cycle j = 1,1,200 ! inn(j)_l = points %if inn(j)_u = uinfs(1) ! %repeat ! %finish ! disconnect(boss.".".bossfile) %stop %finish %end ! !====== ! %routine dwarf %integer j,good good = 0 %cycle j = 1,1,possesions good = 1 %if posar(j) = "dagger" %repeat dwarfpres = 0 %if thisroom < 25 dwarfpres = 1 %if still > 8 %and thisroom > 24 %if dwarfpres = 1 %start still = 0 printstring("A dwarf appears in the room with you . He throws a dagger at you.") %if randomize(20) < 19 %start ps(" It misses.") %cycle j = 1,1,maxthings %if thingsrec(j)_name = "dagger" %and good = 0 %thenc thingsrec(j)_pos = thisroom thingsrec(j)_pos = thisroom %if thingsrec(j)_name = "dwarf" %repeat %finishelsestart ps(" It hits you and you die.") die %finish %finish %end ! !====== ! %routine kill(%string(160) what) %if what = "gollum" %or what = "yourself" %then die %elsestart %if what = "frank" %and thisroom = 60 %start %if deadfrank = 0 %start ps("It will be a pleasure.") points = points + 10 deadfrank = 1 %finishelsestart %if what = "frank" %and thisroom = 60 %thenc ps("He is already dead.") %finish %finishelsestart ps("There is no need for Gollum to kill anything. All problems can be overcome by other means.") %finish %finish still = still + 1 %end ! !====== ! %routine drink(%string(160) what) %integer sym,i,good,j %if what = "" %start prompt("Drink what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish %if "wine" # what # "water" %start ps("Gollum does not think so.") %finishelsestart good = 0 %cycle j = 1,1,possesions %if posar(j) = what %start good = 1 %if j # possesions %then %start %cycle i = j,1,possesions-1 posar(i) = posar(i+1) %repeat %finish posar(possesions) = "" possesions = possesions - 1 %finish %repeat %cycle j = 1,1,maxthings %if thingsrec(j)_pos = thisroom %and thingsrec(j)_name = what %start points = points + thingsrec(j)_found thingsrec(j)_pos = 0 good = 1 %finish %repeat %if good = 1 %start ps("Thankyou it was cool and refreshing.") %finishelsestart ps("Where is the ".what." for Gollum ??") %finish %finish still = still + 1 %end ! !====== ! %routine help ps(" The objective of this game is to move arround a maze and gain points.") ps("Points are scored by finding new rooms and collecting objects. Extra") ps("points can be scored by leaving treasure in Gollum`s cave. The commands") ps("that Gollum recognises are of the ""verb noun"" type, i.e. TAKE TREE.") ps("Either upper or lower case is recognised. To move just the direction") ps("is needed, i.e. EAST or E will move east. A list of your possesions") ps("can be obtained by the command INVENTORY.") ps(" Gollum sometimes makes suggestions these are ignored at your own") ps("risk. For more help try INFO. Gollum is so clever that only the first ") ps("four letters of a verb need be typed in for him to recognize it.") still = still + 1 %end ! !====== ! %routine info ps("Gollum recognises 6 directions i.e. UP,DOWN,EAST,WEST,NORTH AND SOUTH.") ps("Directions can be given on there own with no verb. All other nouns") ps("recquire verbs. Gollum recognises such verbs as ENTER,LEAVE,TAKE,") ps("DROP,CLIMB...etc,etc further verbs can be found by experiment.") ps("INVENTORY gives a list of the objects in your possesion.") ps("STOP or QUIT ends the game.") ps("If a magic word is typed in at the correct place then it will change") ps("the maze or your position in it.") still = still + 1 %end ! !====== ! %integerfn checkobj(%string(160) what) %integer j,good good = 1 %cycle j = 1,1,maxthings %if thingsrec(j)_name = what %and thingsrec(j)_pos = thisroom %start ps("What do you want Gollum to do with the ".what) good = 0 %finish %repeat %result = good %end ! !====== ! %integerfn getdir(%string(160) what) %integer j,good %conststring(1) %array dirs(1:6) = "N","S","E","W","U","D" good = 1 %cycle j = 2,1,13 move(dirs((j-1)//2)) %and good = 0 %if comar(j) = what %repeat %result = good %end ! !====== ! %routine go(%string(160) where) %integer sym,j %if where = "" %start prompt("Go where ? ") %cycle readsymbol(sym) %exitif sym = 10 where = where.tostring(sym) %repeat where = lcstring(where) %finish j = getdir(where) %if j = 1 %start ps("Gollum cannot find that direction.") %finish %end ! !====== ! %routine leave(%string(160) what) %integer sym,found %if what = "" %start prompt("Leave what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish found = 0 %if what = "tower" %start found = 1 %if thisroom = 13 %start %if open12 = 1 %start ps("O.K.") thisroom = 12 %finishelsestart ps("The door is closed.") %finish %finishelsestart ps("Where is the tower ?") %finish %finish %if what = "cave" %start found = 1 %if thisroom = 9 %start ps("O.K.") thisroom = 8 %finishelsestart ps("There is no cave here.") still = still + 1 %finish %finish %if found = 0 %start ps("Gollum doesn`t seem to be able to do that.") %finish %end ! !====== ! %routine bellon %if interrupt = "bell" %start %if bell = 1 %then bell = 0 %else bell = 1 %finishelsestart ps("That is for wizzards only.") %finish %end ! !====== ! %routine jump(%string(160) where) %if tree = 1 %then die %elsestart ps("Gollum is not an athlete.") still = still + 1 %finish %end ! !====== ! %routine throw(%string(160) what) %integer sym,i,good,j %if what = "" %start prompt("Throw what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish good = 0 %cycle j = 1,1,possesions %if posar(j) = what %start good = 1 %if j # possesions %start %cycle i = j,1,possesions - 1 posar(i) = posar(i+1) %repeat %finish possesions = possesions - 1 posar(possesions + 1) = "" %cycle i = 1,1,maxthings thingsrec(i)_pos = thisroom %if thingsrec(i)_name = what %if what = "dagger" %or what = "rock" %start %if thingsrec(i)_name = "dwarf" %and thingsrec(i)_pos = thisroom %c %then good = 2 %finish %repeat %finish %repeat %if good = 1 %start ps("Thrown.") %finish %if good = 2 %start %if randomize(10) > 9 %then ps("Nothing happens.") %elsestart ps("The ".what." strikes the dwarf who runs off howling.") dwarfpres = 0 %cycle j = 1,1,maxthings thingsrec(j)_pos = 0 %if thingsrec(j)_name = "DWARF" %repeat %finish %finish %if good = 0 %start ps("Gollum has no ".what) %finish %end ! !====== ! %routine haunt %owninteger told = 0 %if told = 0 %and points > 90 %start ps("Gollum hears a hollow voice behind him saying....") ps("To turn off the bell try Int 'N' followed by bell") ps("Gollum turns round, but only a wisp of smoke is there a") ps("sudden gust of wind blows this away.") told = 1 %finish %end ! !====== ! %routine change(%string(160) what) %integer sym,i,good,j good = 0 %if what = "" %start prompt("Change what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish %if what = "battery" %start %cycle j = 1,1,possesions %if posar(j) = "battery" %start %if j # possesions %start %cycle i = j,1,possesions-1 posar(i) = posar(i+1) %repeat %finish posar(possesions) = "" possesions = possesions - 1 good = 1 %finish %repeat %if good = 1 %start ps("Changed.") lamplife = 200 %finishelsestart ps("Gollum has no battery.") %finish %finishelsestart ps("Gollum does not understaand.") %finish %end ! !====== ! %routine snuff(%string(160) what) %integer sym %if what = "" %start prompt("Snuff what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish %if what = "torch" %start %if torch = 1 %start ps("Snuffed.") torch = 0 %finishelsestart ps("Gollum has no torch.") %finish %finishelsestart ps("Gollum does not understand that.") %finish still = still + 1 %end ! !====== ! %routine play(%string(160) what) %integer sym %if what = "" %start prompt("Play what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish %if what = "piano" %start %if thisroom # 70 %start ps("There are no pianos here.") %finishelsestart ps("Clouds of shocking pink mist swirl about you and the air ") ps("grows cold. The room starts to spin.") ps("When the spinning stops and the mist clears you look about.") %if randomize(10) > 5 %then thisroom = -1 %else thisroom = cave %if thisroom = -1 %then deathnum = 2 ps(lngdes(thisroom)) %finish %finishelsestart ps("Gollum does not understand.") %finish %end ! !====== ! %routine wave(%string(160) what) %integer sym,j,hat,broom %if what = "" %start prompt("Wave what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish hat = 0 broom = 0 %cycle j = 1,1,possesions hat = 1 %if posar(j) = "hat" broom = 1 %if posar(j) = "broom" %repeat %if what = "broom" %and broom + hat = 2 %start %if thisroom = 45 %or thisroom = 55 %start ps("Gollum is magically transported accross the river.") %if thisroom = 45 %then thisroom = 55 %else thisroom = 45 %finishelsestart ps("Nothing happens.") %finish %finishelsestart %if broom = 1 %then ps("Nothing happens.") %else ps("Gollum has no broom.") still = still + 1 %finish %end ! !====== ! %routine emas !%string(160) com,param !%integer sym,flag ! com = "" ! param = "" ! prompt("Command:") ! %cycle ! readsymbol(sym) ! %exitif sym = 10 %or sym = ' ' ! com = com.tostring(sym) ! %repeat ! com = ucstring(com) ! %if sym # 10 %start ! skipsymbol %while nextsymbol = ' ' ! %cycle ! readsymbol(sym) ! %exitif sym = 10 ! param = param.tostring(sym) ! %repeat ! param = ucstring(param) ! %finish ! load(com,0,flag) ! %if flag = 0 %then call(com,param) %elsestart ! ps("Gollum is unable to find that command.") ! %finish %end ! !====== ! %routine free(%string(160) what) %integer sym,i,good,j %if what = "" %start prompt("Free what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish good = 0 %cycle j = 1,1,possesions good = 1 %if posar(j) = what %repeat %if good = 1 %start ps("Free ".what." ?") %finishelsestart %if what = "frank" %start %if thisroom = 60 %start ps("You must be joking !!") points = points - 5 good = 1 %finishelsestart ps("Where is frank ???") good = 1 %finish %finish %finish %if good = 0 %start ps("Gollum does not understand that.") %finish %end ! !====== ! %routine goto(%string(160) where) %integer room,sym %if interrupt # "bell" %start ps("Gollum does not know that.") %finishelsestart %if where = "" %start prompt("Room number ? ") %cycle readsymbol(sym) %exitif sym = 10 where = where.tostring(sym) %repeat %finish room = stoi(where) %if -1 <= room <= maxrooms %then thisroom = room %finish %end ! !====== ! %routine sweep(%string(160) what) %integer sym,broom,found,i %if what = "" %start prompt("Sweep what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish broom = 0 found = 0 %cycle i = 1,1,possesions broom = 1 %if posar(i) = "broom" %repeat %if broom = 1 %start %if what = "rubbish" %or what = "floor" %start found = 1 %if thisroom = 63 %start ps("Gollum is not an ordinary menial !!") %finishelsestart ps("There is no rubbish here.") %finish %finish %if found = 0 %start ps("Gollum does not understand that.") %finish %finishelsestart ps("Gollum has no broom.") %finish still = still + 1 %end ! !====== ! %routine poison(%string(160) what) %integer i,sym,found,poison %if what = "" %start prompt("Poison what ? ") %cycle readsymbol(sym) %exitif sym = 10 what = what.tostring(sym) %repeat what = lcstring(what) %finish poison = 0 found = 0 %cycle i = 1,1,possesions poison = 1 %if posar(i) = "poison" %repeat %if poison = 1 %start %if what = "rat" %start ps("You will have to be more subtle than that.") %finishelsestart ps("Gollum does not understand that.") %finish %finishelsestart ps("Gollum has no poison.") %finish still = still + 1 %end ! !====== ! %routine interface %switch comsw(0:maxcom) start: %if warning = 2 %then die %else describe %if torch = 0 %and thisroom > 24 %start ps("If you go any further in this gloom you may fall to your death.") warning = warning + 1 %finish start1: haunt dwarf lamplife = lamplife - 1 %if torch = 1 %if lamplife = 10 %and torch = 1 %start ps("The torch starts to flicker and fade.") %finish torch = 0 %if lamplife <= 0 -> comsw(readcom(com,par)) comsw(0): %if checkobj(com) = 1 %and com # "" %start ps("Gollum does not know that.") %finish -> start1 comsw(53): comsw(1): take(par) %and -> start1 comsw(2): comsw(3): move("N") %and -> start comsw(4): comsw(5): move("S") %and -> start comsw(6): comsw(7): move("E") %and -> start comsw(8): comsw(9): move("W") %and -> start comsw(10): comsw(11): move("U") %and -> start comsw(12): comsw(13): move("D") %and -> start comsw(14): inventory %and -> start1 comsw(15): climb(par) %and -> start comsw(16): look %and -> start1 comsw(17): drop(par) %and -> start comsw(18): leave(par) %and -> start comsw(19): score %and -> start comsw(20): info %and -> start comsw(21): help %and -> start comsw(22): drink(par) %and -> start1 comsw(23): eat(par) %and -> start1 comsw(24): openclose(1,par) %and -> start1 comsw(25): openclose(0,par) %and -> start1 comsw(26): enter(par) %and -> start comsw(27): kill(par) %and -> start1 comsw(28): lockunlock(1,par) %and -> start1 comsw(29): lockunlock(0,par) %and -> start1 comsw(30): plunk %and -> start1 comsw(31): ps("Okay """.par."""") %and -> start1 comsw(32): light(par) %and -> start comsw(33): quit %and -> start1 comsw(34): go(par) %and -> start comsw(35): quit %and -> start1 comsw(36): qwaszx %and -> start comsw(37): bellon %and -> start1 comsw(38): jump(par) %and -> start1 comsw(39): throw(par) %and -> start1 comsw(40): ps("Burring is for pyromaniacs only.") %and -> start1 comsw(41): change(par) %and -> start1 comsw(42): comsw(43): comsw(44): snuff(par) %and -> start1 comsw(45): play(par) %and -> start1 comsw(46): wave(par) %and -> start comsw(47): emas %and -> start1 comsw(48): comsw(49): free(par) %and -> start1 comsw(50): goto(par) %and -> start comsw(51): sweep(par) %and -> start comsw(52): poison(par) %and -> start %end ! !====== ! %routine inity %integer j %cycle j=1,1,maxthings thingsrec(j)_name = thingnamear(j) thingsrec(j)_pos = thingposar(j) thingsrec(j)_found = thingfar(j) thingsrec(j)_cave = thingcar(j) %repeat %cycle j = -1,1,maxrooms newroomar(j) = 2 %repeat deadrat = 0 dwarfpres = 0 deadfrank = 0 deathnum = 0 torch = 0 warning = 0 lamplife = 200 opengrate = 0 open12 = 0 locked12 = 0 boulder = 1 tree = 0 thisroom = 1 possesions = 0 key = 0 ratpos = 3 bell = 0 still = 0 %end ! !====== ! inity trojan ps("Wellcome to Gollum. ") %if points # 0 %start printstring("On your last go you scored ") write(points,1) points = 0 printstring(" your best go was ") write(best,1) printstring(" in your") write(goes,1) ps(" previous goes.") %finish !%if exist(boss.".".infil."_".alertfile) = 1 %start ! list(boss.".".infil."_".alertfile) ! disconnect(boss.".".infil) !%finish runfil interface ! !====== ! %end %endoffile