[net.sources.games] advgen - a compiler for Chris Torek's "adv": Part 1 of 3

chris@hwcs.UUCP (Chris Miller) (09/26/85)

#!/bin/sh
#
# This is a distribution of "advgen", a compiler for adventures to be
# run by Chris Torek's "adv".  To unpack the distribution, give each
# part as input to the (Bourne) shell.
# Then look at READ_ME.
#
echo 'Start of Advdist, part 01 of 03:'
echo 'x - Dist.hdr'
sed 's/^X//' > Dist.hdr << '/'
XThis is a distribution of "advgen", a compiler for adventures to be
Xrun by Chris Torek's "adv".  To unpack the distribution, give each
Xpart as input to the (Bourne) shell.
XThen look at READ_ME.
/
echo 'x - Pirate.adv'
sed 's/^X//' > Pirate.adv << '/'
XGreeting	"* Welcome to -PIRATE'S ADVENTURE- by Alexis Adams *$n";
XHellroom	never;
XLamp		torch;
XStartroom	apt;
XTreasury	apt;
XInventorysize	5;
XLamplife	200;
XLampwarn	25;
XGoverb		go=climb=walk=enter=pace=follow;
XGetverb		get=take=catch=pick=remove=pull;
XDropverb	drop=release=throw=leave=give;
X
XNoun
X	stairs=stamp=stamps	passage	hall	book	bottle=rum=bottles
X	window=wings	mongoose=monastery	pirate	bag=duffel
X	torch=light	off	matches	yoho
X	^30	lumber	rug	keys	inventory
X	dubloons	sail=sails	fish	anchor
X	plans	cave	door	chest	parrot	path
X	hammer	nails	boat=ship	shed
X	crack	water=salt	lagoon=tide
X	pit	shore=beach=shovel	map	pace
X	bones	hole	sand	box	sneakers
X	snakes	shack;
X
XVerb
X	say	sail	fly	eat=drink
X	inventory=i	look=show	wait
X	read	yoho	score	kill=attack=hit
X	light	open=smash	unlock=unlight	help
X	away=bunyon	quit	build=make
X	wake	set	cast	dig	burn
X	find	jump	empty	weigh;
X
XVar
X	gotkeys		bagchecked	gotmap	anchorfreed
X	tidechange	sailed	gotplans	paced30
X	paced;
X
XRoom
X	apt	"*I'm in an apartment in London";
X	alcove 	(D:apt) "*I'm in an alcove";
X	pas 	(E:attic w:alcove) "secret passageway";
X	attic	(W:pas) "musty attic";
X	window	"*I'm outside an open window on a ledge on the side of a very tall building";
X	beach	(E:meadow) "sandy beach on a tropical isle";
X	maze1	Dark (s:maze2 e:maze3 w:hill d:pit) "maze of caves";
X	meadow	(e:hill w:beach) "meadow";
X	shack	(w:meadow) "grass shack";
X	ocean	(n:ocean s:lagoon e:ocean w:ocean) "*I'm in the ocean";
X	pit	Dark (u:maze1) "pit";
X	maze2	Dark (n:maze1 e:hill w:maze3) "maze of caves";
X	maze3	Dark (n:maze1 s:hill e:maze2 w:maze4) "maze of caves";
X	hill    (w:meadow) "*I'm at the foot of a cave ridden hill.  A path leads to the top";
X	shed	Dark (n:cavern) "tool shed";
X	hall	Dark (e:cavern) "long hallway";
X	cavern	Dark (w:hall) "large cavern";
X	hilltop	(d:hill) "*I'm on top of a hill.  Below is Pirate Island.  Across the sea off in the distance I see *TREASURE* ISLAND";
X	maze4	Dark (s:maze3 e:maze3 w:maze2) "maze of caves";
X	ship	"*I'm aboard a pirate ship anchored off shore";
X	tbeach	(s:graves) "*I'm on the beach at Treasure Island";
X	graves	(n:tbeach e:field) "spooky old graveyard filled with piles of empty and broken rum bottles";
X	field	(w:graves) "large barren field";
X	lagoon	(n:ocean s:beach e:beach w:beach) "shallow lagoon.  To the north is the ocean";
X	monast	(w:field) "sacked and deserted monastery";
X	never	"*Welcome to Never Never Land!";
X
XItem
X	win @ alcove "Open window";
X	case @ alcove "Bookcase";
X	book=book "Large leather-bound book";
X	ocase "Bookcase with secret passage behind it";
X	bag=bag @ attic "Pirate's duffel bag";
X	sign @ apt "Sign on wall -RETURN TREASURES HERE.  SAY SCORE-.$nSign by stairs -ANTONYM OF LIGHT IS UNLIGHT-";
X	ebottle=bottle "Empty bottle";
X	utorch=torch @ attic "Unlit torch";
X	torch=torch "Lit torch";
X	matches=matches "Matches";
X	keel @ beach "Small ship's keel and mast";
X	pirate @ shack "Wicked looking pirate";
X	chest=chest @ meadow "Treasure Chest";
X	mongoose=mongoose @meadow "Mongoose";
X	anchor=anchor @lagoon "Rusty anchor";
X	gshack@meadow "Grass shack";
X	crocs @pit "Mean and hungry looking CROCODILES";
X	ldoor @pit "Locked door";
X	odoor "Open door with hall beyond";
X	sails=sails @cavern "Pile of sails";
X	fish=fish @ocean "Fish";
X	dubloons=dubloons @monast "*DUBLOONS*";
X	snakes=snakes @monast "Deadly Mamba snakes";
X	parrot=parrot@shack "Parrot";
X	rbottle=bottle @ apt "Bottle of Rum";
X	rug=rug "Rug";
X	keys=keys "Ring of keys";
X	ochest=chest "Open treasure chest";
X	plans=plans "Set of plans";
X	fixrug @apt "Rug";
X	hammer=hammer @shed "Claw hammer";
X	nails=nails "Nails";
X	lumber=lumber @ cavern "Pile of precut lumber";
X	tshed @ cavern "Tool shed";
X	lhdoor @ hall "Locked door";
X	ohdoor "Open door with pit beyond";
X	pship "Pirate ship";
X	wall @ hilltop "Rock wall with narrow crack in it";
X	crack @ cavern "Narrow crack in the rock";
X	water @ ocean "Salt water";
X	spirate "Sleeping pirate";
X	wbottle=bottle "Bottle of salt water";
X	pieces @ attic "Pieces of broken rum bottles";
X	sneakers=sneakers @apt "Non-skid sneakers";
X	map=map "Map";
X	shovel=shovel @ hall "Shovel";
X	bones=bones "Mouldy old bones";
X	sand=sand @beach "Sand";
X	rbottles=bottles "Bottles of rum";
X	stamps=stamps "*RARE OLD PRICELESS STAMPS*";
X	ilagoon @ beach "Lagoon";
X	tideout @ lagoon "The tide is out";
X	tidein "The tide is coming in";
X	wings=wings @shed "Water wings";
X	flotsam "Flotsam and Jetsam";
X	mon @field "Monastery";
X	box=box "Plain wooden box";
X	squirrel "Dead squirrel";
X	stairs @apt "Flight of stairs";
X
XMessage
X	parcry "The parrot cries:    ";
X	piece8 "-- PIECES OF EIGHT --$n";
X	chortle "Pirate grabs rum and scuttles off chortling$n";
X	underwater "I'm underwater.  I CAN'T SWIM!!!!  BLUB BLUB...$n";
X	spin "Everything spins around and suddenly you are elsewhere...$n";
X	somethingthere "There's something there all right.  Maybe I should ";
X	piratestops "Pirate won't let me$n";
X	locked "It's locked$n";
X	itsopen "It's open$n";
X	empty "It's empty$n";
X	carrying "Not while I'm carrying it!$n";
X	cant "Sorry, I can't$n";
X	crocsstop "Crocs stop me.$n";
X	strangesound "There's a strange sound.$n";
X	openit "open it.$n";
X	wronggame "Wrong game you silly goose!$n";
X	nothing "Nothing happens.$n";
X	wontfit "Something won't fit$n";
X	gothere "go there?$n";
X	tight "It was a tight squeeze!$n";
X	unsafe "That's not very safe$n";
X	soaks "It soaks into the ground$n";
X	pfollows "Pirate follows you ashore as if he is waiting for something.$n";
X	setanchor "After two days at sea we set anchor off of a sandy beach.ALL ASHORE WHO'S GOING ASHORE...$n";
X	weighanchor "Try -WEIGH ANCHOR-$n";
X	pacedok "OK.  I walked off 30 paces.$n";
X	foundit "I found something!$n";
X	fallsout "Something falls out$n";
X	multexit "There's multiple exits here!$n";
X	tidechanges "--TIDES A CHANGING MATEY--$n";
X	tidesout "The tide is out.$n";
X	tidesin "The tide is coming in.$n";
X	foundnothing "I didn't find anything.$n";
X
XDaemon
X
X 80%	Sameroom(fish) & Sameroom(crocs) =>
X		Say "Crocs eat fish and leave.$n",
X		Zap(fish),
X		Zap(crocs);
X 80%	Sameroom(snakes) & Sameroom(parrot) =>
X		Say parcry,
X		Say piece8,
X		"Parrot attacks snakes and drives them off.$n",
X		Zap(snakes);
X	Carrying(rug) & !Nearto(keys) & !gotkeys =>
X		Say strangesound,
X		Fetch(keys),
X		++gotkeys;
X 2%	Nearto(parrot) =>
X		Say parcry,
X		Say piece8;
X 24%	Inroom(never) =>
X		"Since nothing is happening,$n",
X		Quit;
X 40%	Inroom(window) & !Carrying(sneakers) =>
X		"I slipped and fell...$n",
X		Die;
X 80%	Sameroom(pirate) & Sameroom(rbottle) =>
X		Location(spirate) = attic,
X		Say chortle,
X		Location(ebottle) = attic,
X		Zap(pirate),
X		Zap(rbottle);
X 34%	Carrying(fish) & !Carrying(wbottle) =>
X		"Too dry.  Fish vanish.$n",
X		Location(fish) = ocean;
X 49%	Sameroom(pirate) & Sameroom(rbottles) =>
X		Say chortle,
X		Location(spirate) = graves,
X		Zap(pirate);
X 34%	Nearto(parrot) & !bagchecked =>
X		Say parcry,
X		"-CHECK THE BAG MATEY$n";
X 9%	Nearto(parrot) & !gotmap =>
X		Say parcry,
X		"-CHECK THE CHEST MATEY-$n";
X 49%	Inroom(lagoon) & !Inlimbo(tidein) & !Carrying(wings) =>
X		Say tidesin,
X		Say underwater,
X		Die;
X 49%	Inroom(ocean) & !Carrying(wings) =>
X		Say underwater,
X		Die;
X 9%	!anchorfreed =>
X		tidein <-> tideout,
X		anchor <-> flotsam,
X		tidechange = True;
X 9%	anchorfreed & !sailed =>
X		tidein <-> tideout,
X		tidechange = 1;
X 84%	Nearto(parrot) & tidechange =>
X		Say parcry,
X		Say tidechanges,
X		tidechange = False;
X	tidechange =>
X		tidechange = False;
X 80%	(Sameroom(snakes)) & (Sameroom(mongoose)) =>
X		"I was wrong.  I guess it's not a mongoose 'cause the snakes bit it.$n",
X		mongoose <-> squirrel;
X
XAction
X
Xgo passage:
X	(Sameroom(ocase)) =>
X		Moveto(pas);
Xread book:
X	(Carrying(book)) =>
X		"The name of the book is -TREASURE ISLAND-.$n",
X		"There's a word engraved in the flyleaf -YOHO-$nand a message:",
X		" -LONG JOHN SILVER LEFT 2 TREASURES ON TREASURE ISLAND!-$n"
X|	!(Carrying(book)) =>
X		Say cant,
X			# This is an obvious typo in the original!
X		Say wontfit;
Xgo window:
X	(Sameroom(win)) =>
X		Moveto(window)
X|	(Inroom(window)) =>
X		Moveto(alcove);
Xfind *:
X	=>
X		"Open the book!$n";
Xyoho *:
X	(Inroom(window)) & (Carrying(book)) =>
X		Say spin,
X		Moveto(beach)
X|	!(Inroom(window)) & (Carrying(book)) & !sailed =>
X		Say spin,
X		Moveto(window)
X|	=>
X		Say nothing;
Xlook window:
X	(Sameroom(win)) =>
X		Say somethingthere,
X		"go there?$n";
Xlight torch:
X	(Carrying(utorch)) & (Nearto(matches)) =>
X		utorch <-> torch,
X		"Torch is lit.$n",
X		Lighten;
Xunlight torch:
X	(Carrying(torch)) =>
X		utorch <-> torch;
Xhelp *:
X	Inroom(window) =>
X		"You may need magic here.$n"
X|	(Inroom(alcove)) =>
X		"READING EXPANDS THE MIND.$n"
X|	(Inroom(hill)) =>
X		Say multexit
X|
X	(Inroom(pit)) =>
X		Say tidesout,
X		Say tidesin,
X		Say tidechanges
X|	(Inroom(beach)) =>
X		Say multexit
X|	(Inroom(shack)) & (Sameroom(pirate)) =>
X		"-MAGIC WORD-  HO AND A ...           (Work on it.  You'll get it.)$n"
X|	=>
X		Say nothing;
Xget dubloons:
X	!(Sameroom(snakes)) =>
X		Get(dubloons)
X|	(Sameroom(dubloons)) & (Sameroom(snakes)) =>
X		"That's not very safe.$n",
X		"I'm snake bit.$n",
X		Die;
Xgo shack:
X	(Sameroom(gshack)) =>
X		Moveto(shack);
Xget chest:
X	(Sameroom(chest)) & (Sameroom(pirate)) =>
X		Say piratestops
X|	!(Sameroom(pirate)) =>
X			# BUG: should add Sameroom(chest)!
X		Get(chest);
Xopen chest:
X	(Sameroom(chest)) & (Sameroom(pirate)) =>
X		Say piratestops
X|	(Sameroom(chest)) & !(Sameroom(pirate)) =>
X		Say locked
X|	(Carrying(chest)) =>
X		Say carrying;
Xunlock chest:
X	(Sameroom(chest)) & !(Sameroom(pirate)) & (Carrying(keys)) =>
X		Say itsopen,
X		chest <-> ochest;
Xlook chest:
X	(Carrying(ochest)) =>
X		Say carrying
X|	(Nearto(chest)) =>
X		Say cant,
X		Say locked
X|	(Sameroom(ochest)) & !gotplans & !gotmap =>
X		"There is a set of plans in it.$n",
X		Fetch(plans),
X		gotplans = True
X|	!gotmap & (Sameroom(ochest)) & gotplans =>
X		"There's a map in it!$n",
X		Fetch(map),
X		gotmap = True
X|	gotmap & (Sameroom(ochest)) =>
X		Say empty;
Xlook bag:
X	(Nearto(bag)) & !bagchecked =>
X		Say somethingthere,
X		"open it?$n"
X|	(Nearto(bag)) & bagchecked =>
X		Say empty;
Xopen bag:
X	(Nearto(bag)) & !bagchecked =>
X		Say fallsout,
X		Fetch(matches),
X		bagchecked = True
X|	bagchecked =>
X		Say nothing,
X		Say empty;
Xopen door:
X	(Sameroom(crocs)) =>
X		Say crocsstop
X|	(Sameroom(lhdoor)) =>
X		Say cant,
X		Say locked
X|	(Sameroom(odoor)) =>
X		Say itsopen
X|	(Sameroom(lhdoor)) =>
X		Say cant,
X		Say locked
X|	(Sameroom(ohdoor)) =>
X		Say itsopen;
Xgo hall:
X	(Sameroom(odoor)) =>
X		Moveto(hall);
Xunlock door:
X	(Sameroom(crocs)) & (Sameroom(ldoor)) =>
X		Say crocsstop
X|	!(Sameroom(crocs)) & (Sameroom(ldoor)) & (Carrying(keys)) =>
X		Zap(ldoor),
X		Fetch(odoor),
X		lhdoor <-> ohdoor
X|	(Sameroom(lhdoor)) & (Carrying(keys)) =>
X		"Sorry, I can't -- it's locked from the other side!$n";
Xdrink bottle:
X	(Nearto(rbottle)) =>
X		Say strangesound,
X		" ... I think it's me.  HEE HEE.$n";
Xinventory *:
X	=>
X		Inventory;
Xlook box:
X	(Nearto(box)) & !(Nearto(stamps)) =>
X		Say somethingthere,
X		Say openit;
Xaway *:
X	=>
X		Say wronggame,
X		Say nothing;
Xscore *:
X	=>
X		Score;
Xgo cave:
X	(Inroom(hill)) =>
X		Moveto(maze1);
Xlook lagoon:
X	Inlimbo(tideout) =>
X		Say somethingthere,
X		Say gothere,
X		Say tidesin
X|	!(Inlimbo(tideout)) =>
X		Say somethingthere,
X		Say gothere,
X		Say tidesout;
Xlook shack:
X	(Sameroom(gshack)) =>
X		Say somethingthere,
X		Say gothere;
Xlook crack:
X	(Sameroom(wall)) =>
X		Say somethingthere,
X		Say gothere;
Xgo crack:
X	(Sameroom(crack)) & (Carrying(shovel)) =>
X		Say cant,
X		Say wontfit
X|	(Sameroom(wall)) & (Carrying(chest)) =>
X		Say cant,
X		Say wontfit
X|	(Sameroom(crack)) & (Carrying(lumber)) =>
X		Say cant,
X		Say wontfit
X|	(Sameroom(wall)) & (Carrying(book)) =>
X		Say cant,
X		Say wontfit
X|	(Sameroom(wall)) =>
X		Moveto(cavern),
X		Say tight
X|	(Sameroom(crack)) =>
X		Moveto(hilltop);
Xget rug:
X	(Sameroom(fixrug)) =>
X		Say cant,
X		"It's nailed to the floor!$n"
X|	(Nearto(rug)) =>
X		Get(rug);
Xget nails:
X	(Carrying(hammer)) & (Sameroom(fixrug)) =>
X		Get(nails),
X		Fetch(rug),
X		Zap(fixrug)
X|	(Nearto(nails)) =>
X		Get(nails);
Xbuild boat:
X	!(Nearto(plans)) =>
X		Say cant,
X		"I've no plans!$n"
X|	(Nearto(hammer)) & (Nearto(plans)) & (Nearto(anchor))
X	   & (Nearto(nails)) & (Nearto(lumber)) & (Nearto(sails)) =>
X		Zap(lumber),
X		pship <-> keel,
X		"CONGRATULATIONS !!!$nBut your adventure is not over yet...$n",
X		Zap(nails),
X		Zap(sails),
X		Zap(anchor)
X|	=>
X		"No.  Something is missing!$n";
Xgo pit:
X	(Sameroom(ohdoor)) =>
X		Moveto(pit);
Xlook *:
X	;
Xset sail:
X	(Inroom(ship)) & (Sameroom(pirate)) & !(Inlimbo(tideout)) & !sailed =>
X		"Pirate says -AYE MATEY WE BE WAITING FOR THE TIDE TO COME IN-$n"
X|	(Inroom(ship)) & !(Sameroom(pirate)) =>
X		Say cant,
X		"I've no crew."
X|	(Inroom(ship)) & !(Sameroom(map)) =>
X		Say cant,
X		"Pirate says -AYE MATEY WE BE NEEDING A MAP FIRST-"
X|	(Inroom(ship)) & !sailed =>
X		Say setanchor,
X		sailed = True,
X		Location(pship) = tbeach
X|	(Inroom(ship)) & sailed =>
X		Say setanchor,
X		sailed = False,
X		Location(pship) = beach;
Xget water:
X	!(Carrying(ebottle)) =>
X		"I've no container.$n"
X|	(Sameroom(water)) & (Carrying(ebottle)) =>
X		Zap(ebottle),
X		Get(wbottle);
Xdrop water:
X	(Carrying(wbottle)) =>
X		Zap(wbottle),
X		Get(ebottle),
X		Say soaks;
Xdrink water:
X	(Sameroom(water)) =>
X		Say unsafe,
X		Die
X|	(Carrying(wbottle)) =>
X		Say unsafe,
X		Zap(wbottle),
X		Get(ebottle),
X		Die;
Xget pirate:
X	(Sameroom(spirate)) =>
X		"Pirate awakens.  Says -AYE MATEY WE BE CASTING OFF SOON-$nHe then vanishes.$n",
X		Zap(spirate),
X		Location(pirate) = ship;
Xopen bottle:
X	(Nearto(rbottle)) =>
X		Say itsopen;
Xempty bottle:
X	(Carrying(rbottle)) =>
X		"What a waste...",
X		Zap(rbottle),
X		Get(ebottle),
X		Say soaks
X|	(Carrying(wbottle)) =>
X		ebottle <-> wbottle;
Xgo boat:
X	(Sameroom(pship)) =>
X		Moveto(ship);
Xgo shore:
X	(Inroom(ship)) & sailed & (Sameroom(pirate)) =>
X		Moveto(tbeach),
X		Fetch(pirate),
X		Say pfollows
X|	(Inroom(ship)) & !sailed =>
X		Moveto(beach)
X|	(Inroom(ship)) & sailed =>
X		Moveto(tbeach);
Xcast off:
X	=>
X		Say weighanchor;
Xread map:
X	(Nearto(map)) =>
X		"It's a map to Treasure Island.  At the bottom it says$n                 -30 PACES AND THEN DIG!-$n";
Xsail *:
X	=>
X		Say weighanchor;
Xget book:
X	(Sameroom(book)) =>
X		Get(book)
X|	(Inroom(alcove)) & !(Sameroom(ocase)) =>
X		Get(book),
X		Say strangesound,
X		case <-> ocase;
Xopen book:
X	(Nearto(book)) =>
X		"Note here -I BE LIKING PARROTS.  THEY BE SMART MATEY-$n";
Xgo path:
X	(Inroom(hill)) =>
X		Moveto(hilltop);
Xget parrot:
X	(Sameroom(parrot)) & (Sameroom(pirate)) =>
X		Say piratestops
X|	(Sameroom(parrot)) =>
X		Get(parrot),
X		Say parcry,
X		Say piece8;
Xgo shed:
X	(Sameroom(tshed)) =>
X		Moveto(shed);
Xgo ^30:
X	!paced30 & (Inroom(field)) =>
X		paced30 = True,
X		Say pacedok
X|	=>
X		paced = True,
X		Say pacedok;
Xdig *:
X	(Inroom(graves)) & (Carrying(shovel)) & !(Nearto(bones)) =>
X		Say foundit,
X		Fetch(bones)
X|	(Inroom(beach)) & (Carrying(shovel)) =>
X		Say foundnothing
X|	(Inroom(tbeach)) & !(Nearto(rbottles)) & (Carrying(shovel)) =>
X		Fetch(rbottles),
X		Say foundit
X|	(Inroom(field)) & paced30 & (Carrying(shovel)) & !(Nearto(box)) =>
X		Fetch(box),
X		Say foundit
X|	(Carrying(shovel)) & !anchorfreed & (Sameroom(anchor)) =>
X		anchorfreed = True
X|	(Carrying(shovel)) =>
X		Say foundnothing,
X		paced = False,
X		paced30 = False;
Xjump *:
X	(Inroom(window)) =>
X		Say unsafe;
Xread plans:
X	(Nearto(plans)) =>
X		"They're plans to build Jolly Roger (a PIRATE SHIP!)$nYou'll need HAMMER NAILS LUMBER ANCHOR SAILS and KEEL.$n";
Xgo lagoon:
X	(Sameroom(ilagoon)) =>
X		Moveto(lagoon);
Xgo stairs:
X	(Inroom(apt)) =>
X		Moveto(alcove);
Xget anchor:
X	(Sameroom(anchor)) & anchorfreed =>
X		Get(anchor)
X|	(Sameroom(anchor)) & !anchorfreed =>
X		Say cant,
X		"It's stuck in the sand.$n"
X|	!(Sameroom(anchor)) =>
X		Say cant,
X		"I don't see it here.$n";
Xgo monastery:
X	(Sameroom(mon)) =>
X		Moveto(monast);
Xsail boat:
X	=>
X		Say weighanchor;
Xweigh anchor:
X	=>
X		"About 20 pounds.  Try -SET SAIL-$n";
Xburn *:
X	=>
X		Say cant;
Xopen box:
X	(Carrying(hammer)) & (Nearto(box)) =>
X		Say fallsout,
X		Fetch(stamps);
Xkill pirate:
X	=>
X		Say piratestops;
Xsay *:
X	=>
X		"Use 1 word.$n";
Xwait *:
X	anchorfreed =>
X		tidein <-> tideout,
X		Say tidechanges;
/
echo 'x - advgen.man'
sed 's/^X//' > advgen.man << '/'
X.TH ADVGEN 6 Heriot-Watt
X.SH NAME
Xadvgen \- compile an adventure definition
X.SH SYNOPSIS
X.B advgen
X[
X.B -w
X] [
X.B -o
Xoutput ] [ definitionfile ]
X.SH DESCRIPTION
X.I Advgen
Xreads an adventure
Xdefinition file (default standard input) and generates an output file
X(default
X.IR adv.out )
Xwhich can be used by
X.IR adv (6)
Xto run the adventure.
XThe
X.I -w
Xflag causes warning message about variables undeclared before use to
Xbe suppressed (useful for recompiling "decompiled" output files).
X.LP
XOn BSD-derived systems, the adventure file will be directly executable;
Xthe full pathname of the interpreter to be used can be specified by the
Xenvironment variable
X.IR ADVINT ,
Xbut the correct default for your system should have been set up when
X.I advgen
Xwas installed.
X.LP
XThe last section of this document describes the adventure definition
Xlanguage.
X.SH "SEE ALSO"
Xadv(6)
X.SH FILES
Xadv.out \- default output file
X.SH "DEFINITION LANGUAGE"
X.SH "Keywords, Identifiers, Strings, etc."
XAll keywords are reserved, and are distinguished by being lower-case
Xwith an initial capital letter.
XIdentifiers in general consist of
Xstrings of letters, digits and the characters '_' and '$', starting
Xwith a non-digit; the case of letters is significant, so that for
Xexample "START" is different from "start".
XAn identifier starting with a digit can be prefixed by "^", e.g. "^30".
X.LP
XStrings consist of any sequence of characters surrounded by matching
Xsingle-, double- or back-quotes.
XNewlines are not permitted in strings.
XThe escape sequences $n and $t represent newline and tab respectively,
Xand $XX, where XX is a pair of hex digits, stands for the character with
Xthe corresponding internal representation.
X.LP
XNumbers are unsigned integers.
X.LP
XWhite space may be used freely, except in strings.
X.LP
XComments are introduced by '#' and terminated by the end of the line.
X.SH "Sections"
XThe definition consists of 9 sections, any of which may be left empty.
XThey are:
X.nf
X.in +4
XMiscellaneous special definitions
XNouns
XVerbs
XVariables
XRooms
XItems
XMessages
XDaemons
XRules
X.fi
X.in -4
XThese are described in the following sections.
XIn the informal grammar specifications, square brackets enclose optional
Xitems, and angle-brackets enclose symbols which should be replaced by
Xany appropriate item (e.g. <identifier> could be replaced by any valid
Xidentifier). Ellipses ("...") mean that the previous item can be repeated
Xas often as required.
X.SH "Special Definitions"
XThis consists of one or more of the following (terminated by semi-colon,
Xwhich is used as a statement-terminator throughout the definition file).
X.IP "Hellroom <identifier>;"
XNames the room to which dead characters are transported.
XThe default is the last room to be declared.
X.IP "Directions <identifier> .... <identifier>;"
X(Exactly 6 identifiers).
XNames the 6 directions in which movement is possible; these are
Xdeclared as nouns in the vocabulary, and the initial letter of each
Xdirection is declared as a synonym for it.
XThe default directions are North, South, East, West, Up, Down.
X.IP "Lamp <identifier>;"
XNames the item which is a source of light.
XDark rooms are only visible if this item is present and lit.
XBy default no item is a lamp.
X.IP "Lamplife <number>;"
XGives the number of turns that the lamp will remain lit before dying
X(default 240).
X[This feature is ignored in the current version of
X.I adv
X- light is controlled by the Lighten and Darken actions, and a daemon
Xcan be set up to implement the lamp running out, etc.].
X.IP "Lampwarn <number>;"
XA warning is issued this number of turns before the lamp expires (default
X25).
X.IP "Wordsize <number>;"
XSpecifies how many characters will be significant in words input by
Xthe user when the adventure is run (default 3).
X.IP "Startroom <identifier>;"
XNames the room where the adventure begins (default is the first room
Xdeclared).
X.IP "Treasury <identifer>;"
XNames the room where treasure is to be dropped; the game is won when
Xall treasure has been dropped there and a Score action is executed.
X.IP "Inventorysize <number>;"
XGives the maximum number of items which a player can carry (default 5).
X.IP "Greeting <string>;"
XProvides a message displayed at the start of the adventure.
XThe default is "Enjoy your adventure!".
X.IP "Goverb <synonyms>;"
X.IP "Getverb <synonyms>;"
X.IP "Dropverb <synonyms>;"
XThree classes of verb are treated specially by
X.IR adv ,
Xthose for moving, picking up items, and dropping them;
Xthese verbs can be declared here.
X<synonyms> is a list of identifiers separated by "=", e.g.
X"go = run = walk = move".
XThe defaults are "go=run=walk=move=enter", "get=take=pick=remove" and
X"drop=release=leave" respectively.
X.SH Verbs
X.IP "Noun <synonyms> ...;"
XAll input by the player is parsed as a verb-noun pair.
XThis section declares the nouns which are available to the player.
X<synonyms> is a list of "="-separated words, as above.
X.SH Verb
X.IP "Verb <synonyms> ...;"
XSimilar to the noun list.
X.SH Variables
X.IP "Var <identifier> ...;"
XDeclares a collection of variables which can be tested and set in the
Xaction rules.
XVariables are unsigned, and take values in the range 0 to 255.
XThe most frequently-referenced variable should appear first (it is
Xhandled slightly more efficiently than the others).
X.SH Rooms
X.IP "Room <room-definition> ..."
XDeclares the locations where the player may move.
XEach definition has the form:
X.IP "<identifier> [ Dark ] [ (<dir>:<identifier> ...) ] <string>;"
X<identifier> is used as a name for the room elsewhere in the definition.
XIf "Dark" is specified, the room will be dark.
XA list of neighbours can be given in parentheses; each neighbour is
Xspecified by a direction (one of N,S,E,W,U,D even if different direction
Xnames are declared using "Directions", above) and a room name.
XThe <string> will be displayed whenever the player is in the room unless
Xit is dark and unlit.
XIf the first character of the string is NOT '*', the description will be
Xprefixed by "I'm in a ".
X.IP
XExample: maze1 Dark (n:maze1 s:maze2 d:entrance) '*You are lost in a maze'.
X.IP
XThe name "Limbo" refers to limbo, where all items with no declared
Xinitial location live; under normal circumstances there should be no
Xneed to use it.
X.SH Items
X.IP "Item <item-description> ..."
XItems are objects, movable and otherwise, which occur in the adventure.
XThey may be nameable by a noun, in which case the player can pick them
Xup and carry them.
XUnless otherwise specified, items are initially in limbo (a special room).
XEach item description has the form:
X.IP "<identifier> [ =<noun> ] [ @<room> ] <string>;"
X<identifier> is used to refer to the item elsewhere in
Xthe definition, <noun> is the name by which the player can
Xrefer to it, if any, <room> specifies where the item starts off, and
X<string> is the description displayed to the player.
XBy convention, descriptions beginning with "*" are used for treasures;
Xthe object of most games is to bring all such items to the treasury.
X.SH Messages
X.IP "Message <message-definition> ..."
XIt is often convenient if a message is to be used in more than one
Xaction to be able to refer to it by a symbolic name.
XA message definition names a message, as follows:
X.IP "<identifier> <string>;"
XThe identifier can be used to refer to the message in "Say" actions.
X.SH Daemons
X.IP "Daemon <daemon> ..."
XDaemons are rules which are fired before each turn.
XThey consist of a percentage chance of firing (optional, default 100%),
Xa set of conditions, and a set of actions.
XThe format is
X.IP "[ <number>% ] [ <conditions> ] [ => <actions> ];"
Xwhere <conditions> has the form "<cond> & <cond> ...." and
X<actions> has the form "<act>, <act>, ...". Possible <cond>s and <act>s
Xare described below.
X.SH Rules
X.IP "Rule <rule> ..."
XA rule consists of a verb-noun pair, a set of
Xconditions, and a set of actions; if the player types such a pair
Xand the other conditions are satisfied then the actions take place.
XOnly the first rule whose conditions are satisfied is executed on any
Xgiven turn.
XThe format is:
X.IP "<word> [ <word> ] : [ <conditions> ] => [ <actions> ];"
XIf <word> is "*" it will match anything; if only one <word> is present
Xit is equivalent either to "<word> *" or "* <word>" depending upon
Xwhether <word> is a valid verb.
XThe <conditions> and <actions> are as for daemons.
XAs an abbreviation, the final semicolon and next verb-noun pair and colon
Xcan be replaced by a vertical bar, meaning "repeat the previous verb and
Xnoun", e.g.
X.nf
X.in +8
Xlight lamp: Carrying(lamp) => Lighten
X          | => "You don't have a lamp.$n";
X.in -8
X.fi
X.SH Conditions
XThe possible conditions which may be tested are:
X.IP Emptyhanded
XThe player is carring nothing.
X.IP Isdark
XThe current room is unlighted.
X.IP "<variable> == <value>"
X.IP "<variable> > <value>"
XThe obvious meaning; <value> is either a number or one of the
Xwords True or False (synonyms for 1 and 0 respectively).
X.IP <variable>
XA synonym for "<variable> == True".
X.IP "Carrying(<item>"
XTrue if the item is being carried.
X.IP "Sameroom(<item>)"
XTrue if the item is in the current room, but not carried.
X.IP "Nearto(<item>)"
XTrue if the item is carried or in the current room.
X.IP "Inroom(<room>)"
XTrue when <room> is the curren location.
X.IP "Inlimbo(<item>)"
XTrue if the item is in limbo.
X.IP "Location(<item>) == <room>"
XTrue when the item is in the specified room.
X.LP
XAny of the above may be parenthesised for ease of reading, and can be negated
Xby a prefixed "!" (double negatives not allowed).
X.SH Actions
XThe possible actions are:
X.IP Win
XEnd the game with jubilation.
X.IP Die
XPrint a suitable message and transfer the player to the Hellroom.
X.IP Quit
XTerminate the adventure.
X.IP Inventory
XList the items currently carried out.
X.IP Darken
XTurn out the lamp.
X.IP Lighten
XTurn on the lamp.
X.IP Refill
XRestore the lamp to maximum life and add it to the player's pack.
X.IP Score
XTell the player how many treasures he has found, and Win if they are
Xall in the treasury.
X.IP "<variable> = <value>"
XAssigns the value (a number, True or False) to the variable.
X.IP "++<variable>"
XIncrements the variable.
X.IP "--<variable>"
XDecrements the variable.
X.IP "<variable> += <value>"
XAdds <value> to the variable.
X.IP "Print(<variable>)"
XPrints the current value of the variable.
X.IP "Say <message>"
XPrints the message, which can either be a string or the name of a
Xmessage.
XIf the same string is "Said" in several actions, only one copy
Xwill appear in the output file.
X.IP <message>
XAn abbreviation for "Say <message>".
X.IP Moveto(<room>)
XMakes <room> become the current location.
X.IP Get(<item>)
XMoves <item> into the player's pack.
X.IP Drop(<item>)
XDrop the <item> if it is being carried.
X.IP Fetch(<item>)
XBring the item to the current location.
X.IP Zap(<item>)
XSend <item> to limbo.
X.IP "Location(<item>) = <room>"
XMoves the item to the specified room.
X.IP "<item> <-> <item>"
X[The <-> stands for itself, i.e. a double-headed arrow, in this rule!]
XExchange the current locations of the two named items.
X.SH Example
XThere follows a short illustrative example;
Xit is mindlessly futile even by the standard of computer games, of
Xcourse.
X.sp 1
X.in +4
X.nf
X# Any resemblance to other adventures is no accident!
XHellroom	hell;
XGreeting	"This is a very futile adventure!$n";
XStartroom	start;
XTreasury	start;
XLamp		litlamp;
XNoun
X    emerald platinum=pyramid lamp plover;
XVerb
X    say light=on score help inventory;
XVar
X    helltime helped;
XRoom
X    hell	"*You are burning in hell!";
X    start	"*You are lost!";
X    plover	(w:darkroom) "*You are in a green room";
X    darkroom	Dark (e:plover) "*You are in a very murky small room";
XItem
X    litlamp =lamp "A brass lamp, burning brightly";
X    lamp =lamp @start "A brass lamp";
X    pyramid =pyramid @darkroom "*A platinum pyramid";
X    emerald =emerald @plover "*An emerald as big as a plover's egg";
XMessage
X    voicesays "A hollow voice says ";
XDaemon
X    Inroom(hell) & helltime == 5 =>
X	"You are fried to a crisp!$n", Quit;
X    Inroom(hell) & !(helltime == 5) =>
X	++helltime;
X10% !Inroom(hell) =>
X	"The Gods punish you for playing silly games$n", Die;
X50% Inroom(start) =>
X	Say voicesays, '"PLOVER"$n';
XAction
X    light lamp: Carrying(lamp) =>
X	"Your lamp is lit$n", Lighten, lamp<->litlamp;
X    light lamp: Carrying(litlamp) =>
X	"It's aready lit!$n";
X    light lamp: =>
X	"You don't have one$n";
X    light: =>
X	"Don't be silly, it won't burn$n";
X    help *: Inroom(hell) & !helped =>
X	helped = True, "A miracle saves you$n", Moveto(start);
X    help *: Inroom(hell) & helped =>
X	"No more miracles.$n";
X    help *: =>
X	voicesays, '"The Gods help those who help themselves."$n';
X    score: => Score;
X    inventory: => Inventory;
X    say plover: Inroom(start) =>
X	Moveto(plover);
X    say plover: Inroom(plover) =>
X	Moveto(start);
/
echo 'x - str.c'
sed 's/^X//' > str.c << '/'
X#include	"advgen.h"
X
Xchar *
Xstrsave(s)
X    char	*s;
X{
X    char	*result;
X
X    if ((result = malloc((unsigned) (strlen(s)+1))) == CNULL)
X    {
X	fatal("out of memory");
X    }
X    return	strcpy(result, s);
X}
/
echo 'x - vars.c'
sed 's/^X//' > vars.c << '/'
X#include	"advgen.h"
X
Xstatic int	nvars = 0;
X
Xvoid
Xdecl_var(s)
X    symbol	*s;
X{
X    switch (s->s_type)
X    {
X	case S_VAR:
X	    muldecl(s->s_sym, "variable");
X	    break;
X	case S_UNKNOWN:
X	    s->s_type = S_VAR;
X	    s->s_value = nvars++;
X	    break;
X	default:
X	    confdecl(s->s_sym, "variable", s->s_type);
X	    break;
X    }
X}
/
echo 'Part 01 of Advdist complete.'
exit
-- 
	Chris Miller, Heriot-Watt University, Edinburgh
	...!ukc!hwcs!chris   chris@hwcs.uucp	chris@cs.hw.ac.uk