From: Glenn Hutchings Date: Sun, 3 Apr 2016 13:39:20 +0000 (+0100) Subject: Add the complete example files. X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=20e7eefa72ab3605b911912abf122d03f216470f;p=ibg.git Add the complete example files. --- diff --git a/.gitignore b/.gitignore index a6d48fe..7ff90f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ output/* *.pyc +*.z5 diff --git a/.hgignore b/.hgignore index aac1488..7bb5feb 100644 --- a/.hgignore +++ b/.hgignore @@ -3,3 +3,4 @@ syntax: glob output/ *.pyc +*.z5 diff --git a/examples/Fate.inf b/examples/Fate.inf new file mode 100644 index 0000000..71d600a --- /dev/null +++ b/examples/Fate.inf @@ -0,0 +1,741 @@ +!% -SD + +!============================================================================ +Constant Story "Captain Fate"; +Constant Headline + "^A simple Inform example + ^by Roger Firth and Sonja Kesserich.^"; +!Release 1; Serial "020428"; ! IBG first edition (public beta) +!Release 2; Serial "020827"; ! IBG second edition +Release 3; Serial "040804"; ! for keeping track of public releases + +Constant MANUAL_PRONOUNS; +Constant MAX_SCORE 2; +Constant OBJECT_SCORE 1; +Constant ROOM_SCORE 1; + +Replace MakeMatch; ! required by pname.h +Replace Identical; +Replace NounDomain; +Replace TryGivenObject; + +Include "Parser"; +Include "pname"; ! pname.h is from the Archive + +Object LibraryMessages ! must be defined between Parser and VerbLib + with before [; + Buy: "Petty commerce interests you only on COUNTED occasions."; + Dig: "Your keen senses detect NOTHING underground worth your + immediate attention."; + Pray: "You won't need to bother almighty DIVINITIES to save + the day."; + Sing: "Alas! That is not one of your many superpowers."; + Sleep: "A hero is ALWAYS on the watch."; + Sorry: "Captain FATE prefers ACTION over apologies."; + Strong: "An unlikely vocabulary for a HERO like you."; + Swim: "You quickly turn all your ATTENTION towards locating a + suitable place to EXERCISE your superior strokes, + but alas! you find none."; + Miscellany: + if (lm_n == 19) + if (clothes has worn) + "In your secret identity's outfit, you manage most + efficaciously to look like a two-cent loser, a + good-for-nothing wimp."; + else + "Now that you are wearing your costume, you project + the image of power UNBOUND, of ballooned, + multicoloured MUSCLE, of DASHING yet MODEST chic."; + if (lm_n == 38) + "That's not a verb you need to SUCCESSFULLY save the day."; + if (lm_n == 39) + "That's not something you need to refer to in order to + SAVE the day."; + ]; + +Include "VerbLib"; + +!============================================================================ +! Object classes + +Class Room + with description "UNDER CONSTRUCTION", + has light; + +Class Appliance + with before [; + Take,Pull,Push,PushDir: + "Even though your SCULPTED adamantine muscles are up to the task, + you don't favour property damage."; + ], + has scenery; + +!============================================================================ +! The game objects + +Room street "On the street" + with name 'city' 'buildings' 'skyscrapers' 'shops' 'apartments' 'cars', + description [; + if (player in booth) + "From this VANTAGE point, you are rewarded with a broad view + of the sidewalk and the entrance to Benny's cafe."; + else + "On one side -- which your HEIGHTENED sense of direction + indicates is NORTH -- there's an open cafe now serving + lunch. To the south, you can see a phone booth."; + ], + before [; + Go: + if (player in booth && noun == n_obj) <>; + ], + n_to [; <>; ], + s_to [; <>; ], + in_to "But which way?", + cant_go + "No time now for exploring! You'll move much faster in your + Captain FATE costume."; + +Object "pedestrians" street + with name 'passing' 'people' 'pedestrians', + description + "They're just PEOPLE going about their daily HONEST business.", + before [; + Examine: + return false; + default: + "The passing pedestrians are of NO concern to you."; + ], + has animate pluralname scenery; + +Appliance booth "phone booth" street + with name 'old' 'red' 'picturesque' 'phone' 'booth' 'cabin' + 'telephone' 'box', + description + "It's one of the old picturesque models, a red cabin with room + for one caller.", + before [; + Open: + "The booth is already open."; + Close: + "There's no way to close this booth."; + ], + after [; + Enter: + "With implausible celerity, you dive inside the phone booth."; + ], + has enterable container open; + +Appliance "sidewalk" street + with name 'sidewalk' 'pavement' 'street', + article "the", + description + "You make a quick surveillance of the sidewalk and discover much + to your surprise that it looks JUST like any other sidewalk in + the CITY!"; + +Appliance outside_of_cafe "Benny's cafe" street + with name 'benny^s' 'cafe' 'entrance', + description + "The town's favourite for a quick snack, Benny's cafe has a 50's + ROCKETSHIP look.", + before [; + Enter: + print "With an impressive mixture of hurry and nonchalance you + step into the open cafe.^"; + PlayerTo(cafe); + return true; + ], + has enterable proper; + +!---------------------------------------------------------------------------- + +Room cafe "Inside Benny's cafe" + with description + "Benny's offers the FINEST selection of pastries and sandwiches. + Customers clog the counter, where Benny himself manages to + serve, cook and charge without missing a step. At the north side + of the cafe you can see a red door connecting with the toilet.", + before [; + Go: ! The player is about to depart. Is he making for the street? + if (noun ~= s_obj) return false; + if (benny.coffee_not_paid == true || + benny.key_not_returned == true) { + print "Just as you are stepping into the street, the big hand + of Benny falls on your shoulder."; + if (benny.coffee_not_paid == true && + benny.key_not_returned == true) + "^^~Hey! You've got my key and haven't paid for the + coffee. Do I look like a chump?~ You apologise as only a + HERO knows how to do and return inside."; + if (benny.coffee_not_paid == true) + "^^~Just waidda minute here, Mister,~ he says. + ~Sneaking out without paying, are you?~ You quickly + mumble an excuse and go back into the cafe. Benny + returns to his chores with a mistrusting eye."; + if (benny.key_not_returned == true) + "^^~Just where you think you're going with the toilet + key?~ he says. ~You a thief?~ As Benny forces you back + into the cafe, you quickly assure him that it was only + a STUPEFYING mistake."; + } + if (costume has worn) { + deadflag = 5; ! you win! + "You step onto the sidewalk, where the passing pedestrians + recognise the rainbow EXTRAVAGANZA of Captain FATE's costume + and cry your name in awe as you JUMP with sensational + momentum into the BLUE morning skies!"; + } + ], + first_time_out false, ! Captain Fate's first appearance? + after [; + Go: ! The player has just arrived. Did he come from the toilet? + if (noun ~= s_obj) return false; + if (costume has worn && self.first_time_out == false) { + self.first_time_out = true; + StartDaemon(customers); + } + ], + s_to street, + n_to toilet_door; + +Appliance counter "counter" cafe + with name 'counter' 'bar', + article "the", + description + "The counter is made of an astonishing ALLOY of metals, + STAIN-PROOF, SPILL-RESISTANT and VERY EASY to clean. Customers + enjoy their snacks with UTTER tranquillity, safe in the notion + that the counter can take it all.", + before [; + Receive: + <>; + ], + has supporter; + +Object food "Benny's snacks" cafe + with name 'food' 'pastry' 'pastries' 'sandwich' 'sandwiches' 'snack' + 'snacks' 'doughnut', + before [; "There is no time for FOOD right now."; ], + has scenery proper; + +Object menu "menu" cafe + with name 'informative' 'menu' 'board' 'picture' 'writing', + description + "The menu board lists Benny's food and drinks, along with their + prices. Too bad you've never learnt how to read, but luckily + there is a picture of a big cup of coffee among the + incomprehensible writing.", + before [; + Take: + "The board is mounted on the wall behind Benny. Besides, it's + useless WRITING."; + ], + has scenery; + +Object customers "customers" cafe + with name 'customers' 'people' 'customer' 'men' 'women', + description [; + if (costume has worn) + "Most seem to be concentrating on their food, but some do + look at you quite blatantly. Must be the MIND-BEFUDDLING + colours of your costume."; + else + "A group of HELPLESS and UNSUSPECTING mortals, the kind + Captain FATE swore to DEFEND the day his parents choked on a + DEVIOUS slice of RASPBERRY PIE."; + ], + life [; + Ask,Tell,Answer: + if (costume has worn) + "People seem to MISTRUST the look of your FABULOUS costume."; + else + "As John Covarth, you attract LESS interest than Benny's + food."; + Kiss: + "There's no telling what sorts of MUTANT bacteria these + STRANGERS may be carrying around."; + Attack: + "Mindless massacre of civilians is the qualification for + VILLAINS. You are SUPPOSED to protect the likes of these + people."; + ], + orders [; + "These people don't appear to be of the cooperative sort."; + ], + number_of_comments 0, ! for counting the customer comments + daemon [; + if (location ~= cafe) return; + if (self.number_of_comments == 0) { + self.number_of_comments = 1; + print "^Nearby customers glance at your costume with open + curiosity.^"; + } + if (random(2) == 1) { ! do this 50% of the time + self.number_of_comments = self.number_of_comments + 1; + switch (self.number_of_comments) { + 2: "^~Didn't know there was a circus in town,~ comments one + customer to another. ~Seems like the clowns have the + day off.~"; + 3: "^~These fashion designers don't know what to do to show + off,~ snorts a fat gentleman, looking your way. Those + within earshot try to conceal their smiles."; + 4: "^~Must be carnival again,~ says a man to his wife, who + giggles, stealing a peek at you. ~Time sure flies.~"; + 5: "^~Bad thing about big towns~, comments someone to his + table companion, ~is you get the damnedest bugs coming + out from toilets.~"; + 6: "^~I sure WISH I could go to work in my pyjamas,~ says a + girl in an office suit to some colleagues. ~It looks SO + comfortable.~"; + default: StopDaemon(self); + } + } + ], + has scenery animate pluralname; + +Object benny "Benny" cafe + with name 'benny', + description + "A deceptively FAT man of uncanny agility, Benny entertains his + customers crushing coconuts against his forehead when the mood + strikes him.", + coffee_asked_for false, ! has player asked for a coffee? + coffee_not_paid false, ! is Benny waiting to be paid? + key_not_returned false, ! is Benny waiting for the key? + life [; + Give: + switch (noun) { + clothes: + "You NEED your unpretentious John Covarth clothes."; + costume: + "You NEED your stupendous ACID-PROTECTIVE suit."; + toilet_key: + self.key_not_returned = false; + move toilet_key to benny; + "Benny nods as you ADMIRABLY return his key."; + coin: + remove coin; + self.coffee_not_paid = false; + print "With marvellous ILLUSIONIST gestures, you produce the + coin from the depths of your "; + if (costume has worn) print "BULLET-PROOF costume"; + else print "ordinary street clothes"; + " as if it had dropped on the counter from Benny's ear! + People around you clap politely. Benny takes the coin + and gives it a SUSPICIOUS bite. ~Thank you, sir. Come + back anytime,~ he says."; + } + Attack: + if (costume has worn) { + deadflag = 4; + print "Before the horror-stricken eyes of the surrounding + people, you MAGNIFICENTLY jump OVER the counter and + attack Benny with REMARKABLE, albeit NOT sufficient, + speed. Benny receives you with a TREACHEROUS upper-cut + that sends your GRANITE JAW flying through the cafe.^^ + ~These guys in pyjamas think they can bully innocent + folk,~ snorts Benny, as the EERIE hands of DARKNESS + engulf your vision and you lose consciousness."; + } + else + "That would be an unlikely act for MEEK John Covarth."; + Kiss: + "This is no time for MINDLESS infatuation."; + Ask,Tell,Answer: + "Benny is too busy for idle chit-chat."; + ], + orders [; ! handles ASK BENNY FOR X and BENNY, GIVE ME XXX + Give: + if (second ~= player or nothing) "Benny looks at you strangely."; + switch (noun) { + toilet_key: + if (toilet_key in player) "But you DO have the key already."; + if (self.coffee_asked_for == true) + if (toilet_key in self) { + move toilet_key to player; + self.key_not_returned = true; + "Benny tosses the key to the rest rooms on the + counter, where you grab it with a dextrous and + precise movement of your HYPER-AGILE hand."; + } + else + "~Last place I saw that key, it was in YOUR + possession,~ grumbles Benny. ~Be sure to return it + before you leave.~"; + else + "~Toilet is only fer customers,~ he grumbles, looking + pointedly at a menu board behind him."; + coffee: + if (self.coffee_asked_for == true) + "One coffee should be enough."; + move coffee to counter; + self.coffee_asked_for = self.coffee_not_paid = true; + "With two gracious steps, Benny places his world-famous + Cappuccino in front of you."; + food: + "Food will take too much time, and you must change NOW."; + menu: + "With only the smallest sigh, Benny nods towards the menu + on the wall behind him."; + default: + "~I don't think that's on the menu, sir.~"; + } + ], + has scenery animate male proper transparent; + +Object coffee "cup of coffee" benny + with name 'cup' 'of' 'coffee' 'steaming' 'cappuccino' + 'cappucino' 'capuccino' 'capucino', + description [; + if (self in benny) + "The picture on the menu board SURE looks good."; + else + "It smells delicious."; + ], + before [; + Take,Drink,Taste: + if (self in benny) "You should ask Benny for one first."; + else { + move self to benny; + print "You pick up the cup and swallow a mouthful. Benny's + WORLDWIDE REPUTATION is well deserved. Just as you + finish, Benny takes away the empty cup."; + if (benny.coffee_not_paid == true) + " ~That will be one quidbuck, sir.~"; + else + ""; + } + Buy: + if (coin in player) <>; + else "You have no money."; + Smell: + "If your HYPERACTIVE pituitary glands are to be trusted, + it's Colombian."; + ]; + +Object outside_of_toilet "toilet" cafe + with name 'toilet' 'bath' 'rest' 'room' 'bathroom' 'restroom', + before [; + Enter: + if (toilet_door has open) { + PlayerTo(toilet); + return true; + } + else + "Your SUPERB deductive mind detects that the DOOR is + CLOSED."; + Examine: + if (toilet_door has open) + "A brilliant thought flashes through your SUPERLATIVE + brain: detailed examination of the toilet would be + EXTREMELY facilitated if you entered it."; + else + "With a TREMENDOUS effort of will, you summon your + unfathomable ASTRAL VISION and project it FORWARD towards + the closed door... until you remember that it's + Dr Mystere who's the one with mystic powers."; + Open: + <>; + Close: + <>; + Take,Push,Pull: + "That would be PART of the building."; + ], + has scenery openable enterable; + +Object toilet_door + with pname '.x' 'red' '.x' 'toilet' 'door', + short_name [; + if (location == cafe) print "door to the toilet"; + else print "door to the cafe"; + return true; + ], + description [; + if (location == cafe) + "A red door with the unequivocal black man-woman silhouettes + marking the entrance to hygienic facilities. There is a + scribbled note stuck on its surface."; + else + "A red door with no OUTSTANDING features."; + ], + found_in cafe toilet, + before [ ks; + Open: + if (self hasnt locked || toilet_key notin player) return false; + ks = keep_silent; keep_silent = true; + ; keep_silent = ks; + return true; + Lock: + if (self hasnt open) return false; + print "(first closing ", (the) self, ")^"; + ks = keep_silent; keep_silent = true; + ; keep_silent = ks; + return false; + ], + after [ ks; + Unlock: + if (self has locked) return false; + print "You unlock ", (the) self, " and open it.^"; + ks = keep_silent; keep_silent = true; + ; keep_silent = ks; + return true; + Open: + give toilet light; + Close: + give toilet ~light; + ], + door_dir [; + if (location == cafe) return n_to; + else return s_to; + ], + door_to [; + if (location == cafe) return toilet; + else return cafe; + ], + with_key toilet_key, + has scenery door openable lockable locked; + +Object toilet_key "toilet key" benny + with pname '.x' 'toilet' 'key', + article "the", + invent [; + if (clothes has worn) print "the CRUCIAL key"; + else print "the used and IRRELEVANT key"; + return true; + ], + description + "Your SUPRA PERCEPTIVE senses detect nothing of consequence + about the toilet key.", + before [; + if (self in benny) + "You SCAN your surroundings with ENHANCED AWARENESS, + but fail to detect any key."; + Drop: + "Benny is trusting you to look after that key."; + ]; + +Object "scribbled note" cafe + with name 'scribbled' 'note', + description [; + if (self.read_once == false) { + self.read_once = true; + "You apply your ENHANCED ULTRAFREQUENCY vision to the note + and squint in concentration, giving up only when you see the + borders of the note begin to blacken under the incredible + intensity of your burning stare. You reflect once more how + helpful it would've been if you'd ever learnt to read. + ^^A kind old lady passes by and explains: + ~You have to ask Benny for the key, at the counter.~^^ + You turn quickly and begin, ~Oh, I KNOW that, but...~^^ + ~My pleasure, son,~ says the lady, as she exits the cafe."; + } + else + "The scorched undecipherable note holds no SECRETS from + you NOW! Ha!"; + ], + read_once false, ! has the player read the note once? + before [; + Take: + "No reason to start collecting UNDECIPHERABLE notes."; + ], + has scenery; + +!---------------------------------------------------------------------------- + +Room toilet "Unisex toilet" + with description + "A surprisingly CLEAN square room covered with glazed-ceramic + tiles, featuring little more than a lavatory and a light switch. + The only exit is south, through the door and into the cafe.", + s_to toilet_door, + has ~light scored; + +Appliance light_switch "light switch" toilet + with name 'light' 'switch', + description + "A notorious ACHIEVEMENT of technological SCIENCE, elegant yet + EASY to use.", + before [; + Push: + if (self has on) <>; + else <>; + ], + after [; + SwitchOn: + give self light; + "You turn on the light in the toilet."; + SwitchOff: + give self ~light; + "You turn off the light in the toilet."; + ], + has switchable ~on; + +Appliance lavatory "lavatory" toilet + with name 'lavatory' 'wc' 'toilet' 'loo' 'bowl' 'can' 'john' 'bog', + before [; + Examine,Search,LookUnder: + if (coin in self) { + move coin to parent(self); + "The latest user CIVILLY flushed it after use, but failed to + pick up the VALUABLE coin that fell from his pants."; + } + Receive: + "While any other MORTALS might unwittingly throw just about + ANYTHING into ", (the) self, ", you remember the WISE teachings + of your mentor, Duke ELEGANT, about elderly plumbing and rising + waters."; + ]; + +Object coin "valuable coin" lavatory + with name 'valuable' 'coin' 'silver' 'quidbuck', + description "It's a genuine SILVER QUIDBUCK.", + before [; + Drop: + if (self notin player) return false; + "Such a valuable coin? Har, har! This must be a demonstration of + your ULTRA-FLIPPANT jesting!"; + ], + after [; + Take: + "You crouch into the SLEEPING DRAGON position and deftly, with + PARAMOUNT STEALTH, you pocket the lost coin."; + ], + has scored; + +!============================================================================ +! The player's possessions + +Object clothes "your clothes" + with name 'ordinary' 'street' 'clothes' 'clothing', + description + "Perfectly ORDINARY-LOOKING street clothes for a NOBODY like + John Covarth.", + before [; + Wear: + if (self has worn) + "You are already dressed as John Covarth."; + else + "The town NEEDS the power of Captain FATE, not the anonymity + of John Covarth."; + Change,Disrobe: + if (self hasnt worn) + "Your KEEN eye detects that you're no longer wearing them."; + switch (location) { + street: + if (player in booth) + "Lacking Superman's super-speed, you realise that it + would be awkward to change in plain view of the passing + pedestrians."; + else + "In the middle of the street? That would be a PUBLIC + SCANDAL, to say nothing of revealing your secret + identity."; + cafe: + "Benny allows no monkey business in his establishment."; + toilet: + if (toilet_door has open) + "The door to the bar stands OPEN at tens of curious eyes. + You'd be forced to arrest yourself for LEWD conduct."; + print "You quickly remove your street clothes and bundle them + up together into an INFRA MINUSCULE pack ready for easy + transportation. "; + if (toilet_door has locked) { + give clothes ~worn; give costume worn; + "Then you unfold your INVULNERABLE-COTTON costume and + turn into Captain FATE, defender of free will, adversary + of tyranny!"; + } + else { + deadflag = 3; + "Just as you are slipping into Captain FATE's costume, + the door opens and a young woman enters. She looks at + you and starts screaming, ~RAPIST! NAKED RAPIST IN THE + TOILET!!!~^^ + Everybody in the cafe quickly comes to the rescue, only + to find you ridiculously jumping on one leg while trying + to get dressed. Their laughter brings a QUICK END to + your crime-fighting career!"; + } + thedark: + "Last time you changed in the dark, you wore the suit inside + out!"; + default: ! this _should_ never happen... + "There must be better places to change your clothes!"; + } + ], + has clothing proper pluralname; + +Object costume "your costume" + with name 'captain' 'captain^s' 'fate' 'fate^s' 'costume' 'suit', + description + "STATE OF THE ART manufacture, from chemically reinforced 100% + COTTON-lastic(tm).", + before [; + Wear: + if (self has worn) + "You are already dressed as Captain FATE."; + else + "First you'd have to take off your commonplace unassuming + John Covarth INCOGNITO street clothes."; + Change,Disrobe: + if (self has worn) + "You need to wear your costume to FIGHT crime!"; + else + "But you're not yet wearing it!"; + Drop: + "Your UNIQUE Captain FATE multi-coloured costume? The most + coveted clothing ITEM in the whole city? Certainly NOT!"; + ], + has clothing proper; + +!============================================================================ +! Entry point routines + +[ Initialise; + #Ifdef DEBUG; pname_verify(); #Endif; ! suggested by pname.h + location = street; + move costume to player; + move clothes to player; give clothes worn; + lookmode = 2; + "^^Impersonating mild mannered John Covarth, assistant help boy at an + insignificant drugstore, you suddenly STOP when your acute hearing + deciphers a stray radio call from the POLICE. There's some MADMAN + attacking the population in Granary Park! You must change into your + Captain FATE costume fast...!^^"; +]; + +[ DeathMessage; + if (deadflag == 3) print "Your secret identity has been revealed"; + if (deadflag == 4) print "You have been SHAMEFULLY defeated"; + if (deadflag == 5) print "You fly away to SAVE the DAY"; +]; + +[ InScope person item; + if (person == player && location == thedark && real_location == toilet) { + PlaceInScope(light_switch); + PlaceInScope(toilet_door); + } + if (person == player && location == thedark) + objectloop (item in parent(player)) + if (item has moved) PlaceInScope(item); + return false; +]; + +!============================================================================ +! Standard and extended grammar + +Include "Grammar"; + +[ ChangeSub; + if (noun has pluralname) print "They're"; + else print "That's"; + " not something you must change to save the day."; +]; + +Verb 'change' 'exchange' 'swap' 'swop' + * noun -> Change; + +Extend 'ask' + * creature 'for' topic -> AskFor; + +!============================================================================ diff --git a/examples/Heidi.inf b/examples/Heidi.inf new file mode 100644 index 0000000..49ba8e7 --- /dev/null +++ b/examples/Heidi.inf @@ -0,0 +1,76 @@ +!% -SD + +!=============================================================================== +Constant Story "Heidi"; +Constant Headline + "^A simple Inform example + ^by Roger Firth and Sonja Kesserich.^"; +Constant MAX_CARRIED 1; + +Include "Parser"; +Include "VerbLib"; + +!=============================================================================== +! The game objects + +Object before_cottage "In front of a cottage" + with description + "You stand outside a cottage. The forest stretches east.", + e_to forest, + has light; + +Object forest "Deep in the forest" + with description + "Through the dense foliage, you glimpse a building to the west. + A track heads to the northeast.", + w_to before_cottage, + ne_to clearing, + has light; + +Object bird "baby bird" forest + with description "Too young to fly, the nestling tweets helplessly.", + name 'baby' 'bird' 'nestling', + has ; + +Object clearing "A forest clearing" + with description + "A tall sycamore stands in the middle of this clearing. + The path winds southwest through the trees.", + sw_to forest, + u_to top_of_tree, + has light; + +Object nest "bird's nest" clearing + with description "The nest is carefully woven of twigs and moss.", + name 'bird^s' 'nest' 'twigs' 'moss', + has container open; + +Object tree "tall sycamore tree" clearing + with description + "Standing proud in the middle of the clearing, + the stout tree looks easy to climb.", + name 'tall' 'sycamore' 'tree' 'stout' 'proud', + has scenery; + +Object top_of_tree "At the top of the tree" + with description "You cling precariously to the trunk.", + d_to clearing, + has light; + +Object branch "wide firm bough" top_of_tree + with description "It's flat enough to support a small object.", + name 'wide' 'firm' 'flat' 'bough' 'branch', + each_turn [; if (nest in branch) deadflag = 2; ], + has static supporter; + +!=============================================================================== +! Entry point routines + +[ Initialise; location = before_cottage; ]; + +!=============================================================================== +! Standard and extended grammar + +Include "Grammar"; + +!=============================================================================== diff --git a/examples/HeidiPlus.inf b/examples/HeidiPlus.inf new file mode 100644 index 0000000..58609ee --- /dev/null +++ b/examples/HeidiPlus.inf @@ -0,0 +1,102 @@ +!% -SD + +!=============================================================================== +Constant Story "Heidi"; +Constant Headline + "^A simple Inform example + ^by Roger Firth and Sonja Kesserich.^"; +Constant MAX_CARRIED 1; + +Include "Parser"; +Include "VerbLib"; + +!=============================================================================== +! The game objects + +Object before_cottage "In front of a cottage" + with description + "You stand outside a cottage. The forest stretches east.", + e_to forest, + in_to "It's such a lovely day -- much too nice to go inside.", + cant_go "The only path lies to the east.", + has light; + +Object cottage "tiny cottage" before_cottage + with description "It's small and simple, but you're very happy here.", + name 'tiny' 'cottage' 'home' 'house' 'hut' 'shed' 'hovel', + before [; + Enter: + print_ret "It's such a lovely day -- much too nice to go inside."; + ], + has scenery; + +Object forest "Deep in the forest" + with description + "Through the dense foliage, you glimpse a building to the west. + A track heads to the northeast.", + w_to before_cottage, + ne_to clearing, + has light; + +Object bird "baby bird" forest + with description "Too young to fly, the nestling tweets helplessly.", + name 'baby' 'bird' 'nestling', + before [; + Listen: + print "It sounds scared and in need of assistance.^"; + return true; + ], + has ; + +Object clearing "A forest clearing" + with description + "A tall sycamore stands in the middle of this clearing. + The path winds southwest through the trees.", + sw_to forest, + u_to top_of_tree, + has light; + +Object nest "bird's nest" clearing + with description "The nest is carefully woven of twigs and moss.", + name 'bird^s' 'nest' 'twigs' 'moss', + has container open; + +Object tree "tall sycamore tree" clearing + with description + "Standing proud in the middle of the clearing, + the stout tree looks easy to climb.", + name 'tall' 'sycamore' 'tree' 'stout' 'proud', + before [; + Climb: + PlayerTo(top_of_tree); + return true; + ], + has scenery; + +Object top_of_tree "At the top of the tree" + with description "You cling precariously to the trunk.", + d_to clearing, + after [; + Drop: + move noun to clearing; + return false; + ], + has light; + +Object branch "wide firm bough" top_of_tree + with description "It's flat enough to support a small object.", + name 'wide' 'firm' 'flat' 'bough' 'branch', + each_turn [; if (bird in nest && nest in branch) deadflag = 2; ], + has static supporter; + +!=============================================================================== +! Entry point routines + +[ Initialise; location = before_cottage; ]; + +!=============================================================================== +! Standard and extended grammar + +Include "Grammar"; + +!=============================================================================== diff --git a/examples/Tell.inf b/examples/Tell.inf new file mode 100644 index 0000000..8a7e1cb --- /dev/null +++ b/examples/Tell.inf @@ -0,0 +1,560 @@ +!% -SD + +!============================================================================ +Constant Story "William Tell"; +Constant Headline + "^A simple Inform example + ^by Roger Firth and Sonja Kesserich.^"; +!Release 1; Serial "020428"; ! IBG first edition (public beta) +!Release 2; Serial "020827"; ! IBG second edition +Release 3; Serial "040804"; ! for keeping track of public releases + +Constant MAX_SCORE = 3; + +Include "Parser"; +Include "VerbLib"; + +!============================================================================ +! Object classes + +Class Room + has light; + +Class Prop + with before [; + Examine: + return false; + default: + print_ret "You don't need to worry about ", (the) self, "."; + ], + has scenery; + +Class Furniture + with before [; + Take,Pull,Push,PushDir: + print_ret (The) self, " is too heavy for that."; + ], + has static supporter; + +Class Arrow + with name 'arrow' 'arrows//p', + article "an", + plural "arrows", + description "Just like all your other arrows -- sharp and true.", + before [; + Drop,Give,ThrowAt: + print_ret "Your arrows are sharp, and you guard them carefully."; + ]; + +Class NPC + with life [; + Answer,Ask,Order,Tell: + print_ret "Just use T[ALK] [TO ", (the) self, "]."; + ], + has animate; + +!============================================================================ +! The game objects + +Room street "A street in Altdorf" + with description [; + print "The narrow street runs north towards the town square. + Local folk are pouring into the town through the gate to the + south, shouting greetings, offering produce for sale, + exchanging news, enquiring with exaggerated disbelief about + the prices of the goods displayed by merchants whose stalls + make progress even more difficult.^"; + if (self hasnt visited) + print "^~Stay close to me, son,~ you say, + ~or you'll get lost among all these people.~^"; + ], + n_to below_square, + s_to + "The crowd, pressing north towards the square, + makes that impossible."; + +Prop "south gate" street + with name 'south' 'southern' 'wooden' 'gate', + description "The large wooden gate in the town walls is wide open."; + +Prop "assorted stalls" + with name 'assorted' 'stalls', + description "Food, clothing, mountain gear; the usual stuff.", + found_in street below_square, + has pluralname; + +Prop "produce" !! added + with name 'goods' 'produce' 'food' 'clothing' 'mountain' 'gear' 'stuff', + description "Nothing special catches your eye.", + found_in street below_square, + has pluralname; + +Prop "merchants" + with name 'merchant' 'merchants' 'trader' 'traders', + description + "A few crooks, but mostly decent traders touting their wares + with raucous overstatement.", + found_in street below_square, + has animate pluralname; + +Prop "local people" + with name 'people' 'folk' 'local' 'crowd', + description "Mountain folk, just like yourself.", + found_in [; return true; ], + has animate pluralname; + +!---------------------------------------------------------------------------- + +Room below_square "Further along the street" + with description + "People are still pushing and shoving their way from the southern + gate towards the town square, just a little further north. + You recognise the owner of a fruit and vegetable stall.", + n_to south_square, + s_to street; + +Furniture stall "fruit and vegetable stall" below_square + with name 'fruit' 'veg' 'vegetable' 'stall' 'table', + description + "It's really only a small table, with a big heap of potatoes, + some carrots and turnips, and a few apples.", + before [; + Search: + <>; + ], + has scenery; + +Prop "potatoes" below_square + with name 'potato' 'potatoes' 'spuds', + description + "Must be a particularly early variety... by some 300 years!", + has pluralname; + +Prop "fruit and vegetables" below_square + with name 'carrot' 'carrots' 'turnip' 'turnips' 'apples' 'vegetables', + description "Fine locally grown produce.", + has pluralname; + +NPC stallholder "Helga" below_square + with name 'stallholder' 'greengrocer' 'monger' 'shopkeeper' 'merchant' + 'owner' 'Helga' 'dress' 'scarf' 'headscarf', + description + "Helga is a plump, cheerful woman, + concealed beneath a shapeless dress and a spotted headscarf.", + initial [; + print "Helga pauses from sorting potatoes + to give you a cheery wave.^"; + if (location hasnt visited) { + move apple to player; + print "^~Hello, Wilhelm, it's a fine day for trade! Is this + young Walter? My, how he's grown. Here's an apple for him + -- tell him to mind that scabby part, but the rest's good + enough. How's Frau Tell? Give her my best wishes.~^"; + } + ], + times_spoken_to 0, ! for counting the conversation topics + life [; + Kiss: + print_ret "~Ooh, you saucy thing!~"; + Talk: + self.times_spoken_to = self.times_spoken_to + 1; + switch (self.times_spoken_to) { + 1: score = score + 1; + print_ret "You warmly thank Helga for the apple."; + 2: print_ret "~See you again soon.~"; + default: + return false; + } + ], + has female proper; + +!---------------------------------------------------------------------------- + +Room south_square "South side of the square" + with description + "The narrow street to the south has opened onto the town square, + and resumes at the far side of this cobbled meeting place. + To continue along the street towards your destination -- + Johansson's tannery -- you must walk north across the square, + in the middle of which you see Gessler's hat set on that + loathsome pole. If you go on, there's no way you can avoid + passing it. Imperial soldiers jostle rudely through the throng, + pushing, kicking and swearing loudly.", + n_to mid_square, + s_to below_square; + +Prop "hat on a pole" !! changed + with name 'hat' 'pole', + before [; + default: + print_ret "You're too far away at the moment."; + ], + found_in south_square north_square; + +Prop "Gessler's soldiers" + with name 'soldier' 'soldiers' 'guard' 'guards', !! added + description "They're uncouth, violent men, not from around here.", + before [; + FireAt: + print_ret "You're outnumbered many times."; + Talk: + print_ret "Such scum are beneath your contempt."; + ], + found_in south_square mid_square north_square marketplace, + has animate pluralname proper; + +!---------------------------------------------------------------------------- + +Room mid_square "Middle of the square" + with description + "There is less of a crush in the middle of the square; most + people prefer to keep as far away as possible from the pole + which towers here, topped with that absurd ceremonial hat. A + group of soldiers stands nearby, watching everyone who passes.", + n_to north_square, + s_to south_square, + warnings_count 0, ! for counting the soldier's warnings + before [; + Go: + if (noun == s_obj) { + self.warnings_count = 0; + pole.has_been_saluted = false; + } + if (noun == n_obj) { + if (pole.has_been_saluted == true) { + print "^~Be sure to have a nice day.~^"; + return false; + } ! end of (pole has_been_saluted) + else { + self.warnings_count = self.warnings_count + 1; + switch (self.warnings_count) { + 1: print_ret "A soldier bars your way. ^^ + ~Oi, you, lofty; forgot yer manners, didn't you? + How's about a nice salute for the vogt's hat?~"; + 2: print_ret "^~I know you, Tell, yer a troublemaker, + ain't you? Well, we don't want no bovver here, + so just be a good boy and salute the friggin' + hat. Do it now: I ain't gonna ask you again...~"; + default: + print "^~OK, "; + style underline; print "Herr"; style roman; + print " Tell, now you're in real trouble. I asked you + nice, but you was too proud and too stupid. I + think it's time that the vogt had a little word + with you.~ + ^^ + And with that the soldiers seize you and Walter + and, while the sergeant hurries off to fetch + Gessler, the rest drag you roughly towards the + old lime tree growing in the marketplace.^"; + move apple to son; + PlayerTo(marketplace); + return true; + } ! end of switch + } ! end of (pole has_NOT_been_saluted) + } ! end of (noun == n_obj) + ]; + +Furniture pole "hat on a pole" mid_square !! changed + with name 'wooden' 'pole' 'pine' 'hat' 'black' 'red' 'brim' 'feathers', + description + "The pole, the trunk of a small pine some few inches in diameter, + stands about nine or ten feet high. Set carefully on top is + Gessler's ludicrous black and red leather hat, with a widely + curving brim and a cluster of dyed goose feathers.", + has_been_saluted false, + before [; + FireAt: !! added + print_ret "Tempting, but you're not looking for trouble."; + Salute: + self.has_been_saluted = true; + print_ret "You salute the hat on the pole. ^^ + ~Why, thank you, sir,~ sneers the soldier."; + ], + has scenery; + +!---------------------------------------------------------------------------- + +Room north_square "North side of the square" + with description + "A narrow street leads north from the cobbled square. In its + centre, a little way south, you catch a last glimpse of the pole + and hat.", + n_to [; + deadflag = 3; + print_ret "With Walter at your side, you leave the square by the + north street, heading for Johansson's tannery."; + ], + s_to "You hardly feel like going through all that again."; + +!---------------------------------------------------------------------------- + +Room marketplace "Marketplace near the square" + with description + "Altdorf's marketplace, close by the town square, has been hastily + cleared of stalls. A troop of soldiers has pushed back the crowd + to leave a clear space in front of the lime tree, which has been + growing here for as long as anybody can remember. Usually it + provides shade for the old men of the town, who gather below to + gossip, watch the girls, and play cards. Today, though, it + stands alone... apart, that is, from Walter, who has been lashed + to the trunk. About forty yards away, you are restrained by two + of the vogt's men.", + cant_go "What? And leave your son tied up here?"; + +Object tree "lime tree" marketplace + with name 'lime' 'tree', + description "It's just a large tree.", + before [; + FireAt: + if (BowOrArrow(second) == true) { + deadflag = 3; + print_ret "Your hand shakes a little, and your arrow flies + high, hitting the trunk a few inches above Walter's + head."; + } + return true; + ], + has scenery; + +NPC governor "governor" marketplace + with name 'governor' 'vogt' 'Hermann' 'Gessler', + description + "Short, stout but with a thin, mean face, Gessler relishes the + power he holds over the local community.", + initial [; + print "Gessler is watching from a safe distance, + a sneer on his face.^"; + if (location hasnt visited) + print "^~It appears that you need to be taught a lesson, + fool. Nobody shall pass through the square without paying + homage to His Imperial Highness Albert; nobody, hear me? + I could have you beheaded for treason, but I'm going to + be lenient. If you should be so foolish again, you can + expect no mercy, but this time, I'll let you go free... + just as soon as you demonstrate your archery skills by + hitting this apple from where you stand. That shouldn't + prove too difficult; here, sergeant, catch. Balance it on + the little bastard's head.~^"; + ], + life [; + Talk: + print_ret "You cannot bring yourself to speak to him."; + ], + before [; + FireAt: + if (BowOrArrow(second) == true) { + deadflag = 3; + print_ret "Before the startled soldiers can react, you turn + and fire at Gessler; your arrow pierces his heart, + and he dies messily. A gasp, and then a cheer, + goes up from the crowd."; + } + return true; + ], + has male; + +!============================================================================ +! The player's possessions + +Object bow "bow" + with name 'bow', + description "Your trusty yew bow, strung with flax.", + before [; + Drop,Give,ThrowAt: + print_ret "You're never without your trusty bow."; + ] + has clothing; + +Object quiver "quiver" + with name 'quiver', + description + "Made of goatskin, it usually hangs over your left shoulder.", + before [; + Drop,Give,ThrowAt: + print_ret "But it was a present from Hedwig, your wife."; + ], + has container open clothing; + +Arrow "arrow" quiver; +Arrow "arrow" quiver; +Arrow "arrow" quiver; + +NPC son "your son" + with name 'son' 'your' 'boy' 'lad' 'Walter', + description [; + if (location == marketplace) + print_ret "He stares at you, trying to appear brave and + remain still. His arms are pulled back and tied behind + the trunk, and the apple nestles amid his blond hair."; + else + print_ret "A quiet, blond lad of eight summers, he's fast + learning the ways of mountain folk."; + ], + life [; + Give: + score = score + 1; + move noun to self; + print_ret "~Thank you, Papa.~"; + Talk: + if (location == marketplace) + print_ret "~Stay calm, my son, and trust in God.~"; + else + print_ret "You point out a few interesting sights."; + ], + before [; + Examine,Listen,Salute,Talk: + return false; + FireAt: + if (location == marketplace) { + if (BowOrArrow(second) == true) { + deadflag = 3; + print_ret "Oops! Surely you didn't mean to do that?"; + } + return true; + } + else + return false; + default: + if (location == marketplace) + print_ret "Your guards won't permit it."; + else + return false; + ], + found_in [; return true; ], + has male proper scenery transparent; + +Object apple "apple" + with name 'apple', + description [; + if (location == marketplace) + print_ret "At this distance you can barely see it."; + else + print_ret "The apple is blotchy green and brown."; + ], + before [; + Drop: + print_ret "An apple is worth quite a bit -- + better hang on to it."; + Eat: + print_ret "Helga intended it for Walter..."; + FireAt: + if (location == marketplace) { + if (BowOrArrow(second) == true) { + score = score + 1; + deadflag = 2; + print_ret "Slowly and steadily, you place an arrow in + the bow, draw back the string, and take aim with + more care than ever in your life. Holding your + breath, unblinking, fearful, you release the + arrow. It flies across the square towards your + son, and drives the apple against the trunk of + the tree. The crowd erupts with joy; + Gessler looks distinctly disappointed."; + } + return true; + } + else + return false; + ]; + +!============================================================================ +! Entry point routines + +[ Initialise; + location = street; + lookmode = 2; ! like the VERBOSE command + move bow to player; + move quiver to player; give quiver worn; + player.description = + "You wear the traditional clothing of a Swiss mountaineer."; + print_ret "^^ + The place: Altdorf, in the Swiss canton of Uri. The year is 1307, + at which time Switzerland is under rule by the Emperor Albert of + Habsburg. His local governor -- the vogt -- is the bullying + Hermann Gessler, who has placed his hat atop a wooden pole in + the centre of the town square; everybody who passes through the + square must bow to this hated symbol of imperial might. + ^^ + You have come from your cottage high in the mountains, + accompanied by your younger son, to purchase provisions. You are + a proud and independent man, a hunter and guide, renowned both + for your skill as an archer and, perhaps unwisely (for his soldiers + are everywhere), for failing to hide your dislike of the vogt. + ^^ + It's market-day: the town is packed with people from the + surrounding villages and settlements.^"; +]; + +[ DeathMessage; print "You have screwed up a favourite folk story"; ]; + +!============================================================================ +! Standard and extended grammar + +Include "Grammar"; + +!---------------------------------------------------------------------------- + +[ TalkSub; + if (noun == player) print_ret "Nothing you hear surprises you."; + if (RunLife(noun,##Talk) ~= false) return; ! consult life[; Talk: ] + print_ret "At the moment, you can't think of anything to say."; +]; + +Verb 'talk' 't//' 'converse' 'chat' 'gossip' + * 'to'/'with' creature -> Talk + * creature -> Talk; + +!---------------------------------------------------------------------------- + +[ BowOrArrow o; + if (o == bow or nothing || o ofclass Arrow) return true; + print "That's an unlikely weapon, isn't it?^"; + return false; +]; + +[ FireAtSub; + if (noun == nothing) + print_ret "What, just fire off an arrow at random?"; + if (BowOrArrow(second) == true) + print_ret "Unthinkable!"; +]; + +Verb 'fire' 'shoot' 'aim' + * -> FireAt + * noun -> FireAt + * 'at' noun -> FireAt + * 'at' noun 'with' noun -> FireAt + * noun 'with' noun -> FireAt + * noun 'at' noun -> FireAt reverse; + +Extend 'attack' replace + * noun -> FireAt; + +!---------------------------------------------------------------------------- + +[ SaluteSub; + if (noun has animate) print_ret (The) noun, " acknowledges you."; + print_ret (The) noun, " takes no notice."; +]; + +Verb 'bow' 'nod' 'kowtow' 'genuflect' + * 'at'/'to'/'towards' noun -> Salute; + +Verb 'salute' 'greet' 'acknowledge' + * noun -> Salute; + +Extend 'give' + * 'homage' 'to' noun -> Salute; + +Extend 'wave' + * 'at' noun -> Salute; + +!---------------------------------------------------------------------------- + +[ UntieSub; print_ret "You really shouldn't try that."; ]; + +Verb 'untie' 'unfasten' 'unfix' 'free' 'release' + * noun -> Untie; + +!============================================================================