Inform 7 Home Page / Documentation
§10.8. Multiple endings
Interactive fictions vary considerably in the extent to which the player is allowed to influence the story-line. Sometimes the appearance of making choices is wholly bogus, as only one possible line is given more than lip service. But in other works, the player can radically change the outcome, and whole rafts of plot differ between one person's experience and another's. Inform allows multiple endings to its scenes to make this kind of branching story-line easy to achieve.
Any scene can have up to 31 alternate endings, differentiated by name (unless the Z-machine format has been selected on the Settings panel, in which case, 15). These alternates are created as and when conditions are set for them:
Brief Encounter ends happily when ...
Brief Encounter ends wisely but sadly when ...
"Ends happily" and "ends wisely but sadly" behave just like "ends". We can have rules "When Brief Encounter ends happily, ..." and so forth, in addition to rules "When Brief Encounter ends, ..." - if a rule doesn't specify any particular ending, it applies to all of them.
We can also link rules together from these branches, so
Stranger's Acceptance begins when Brief Encounter ends happily.
Stranger's Rejection begins when Brief Encounter ends wisely but sadly.
With this set-up and that of the previous section, there are now two possible paths through the story:
(i) Train Stop - Brief Encounter - Stranger's Acceptance - Bittersweet Ending
(ii) Train Stop - Brief Encounter - Stranger's Rejection - Bittersweet Ending
We might later need to know which of these paths has been taken, and to help with this Inform provides conditions like so:
if Brief Encounter ended happily ...
if Brief Encounter did not end happily ...
if Brief Encounter ended wisely but sadly ...
if Brief Encounter did not end wisely but sadly ...
(For a scene which repeats, note that these conditions apply only to the most recent repetition: and that such conditions are always false if the scene is currently going on. "Brief Encounter did not end happily" will be true only when the scene has finished but in a different way.)
Start of Chapter 10: Scenes | |
Back to §10.7. Multiple beginnings and repeats | |
Onward to §10.9. Why are scenes designed this way? |
ExamplePanache |
If we have a plot that branches and has multiple kinds of outcome, we might well want to assemble these into a plot summary in place of the more traditional score. One way to approach this is to build the scene information into a table, adding information when each scene ends.
We begin with a bit of setup:
The player is in a room called Beneath Roxane's Balcony. Christian is a man in the Balcony. "Christian stands in a spot of moonlight and tries to avoid too obviously glancing at the shadows that conceal you." The description of Christian is "Like you, Christian loves Roxane. Unlike you, he is handsome enough to receive her favor in return. He is the beauty to your brain."
Roxane is a woman in the Balcony. "Above you in the night is Roxane." Roxane can be wooed, skeptical, confused, or annoyed. Roxane is skeptical. The description of Roxane is "The brightest, the most radiant of women -- and in love with an utter fool."
Empty Street is a room. "No one is about at this hour, all alone under a pale moon."
Telling someone about something is speech. Asking someone about something is speech. Answering someone that something is speech.
This next portion borrows from the Advanced Actions chapter to allow us to command Christian to do things:
A persuasion rule for asking Christian to try speech: persuasion succeeds.
Carry out Christian answering someone that something:
now Roxane is wooed;
say "'[noun], [the topic understood].'"
Carry out Christian answering the player that something:
say "Christian parrots your words back to you." instead.
Carry out Christian telling a skeptical Roxane about something:
now Roxane is confused;
say "Christian turns to [the noun]. 'I must tell you about [the topic understood],' he says, and comes to a halt, looking at you for further direction.
Perhaps you'd better give him exact lines to say. Surely he can't mess up an instruction like 'say hello to Roxane.'" instead.
Carry out Christian asking a skeptical Roxane about something:
now Roxane is confused;
say "'So,' says Christian nervously to [the noun]. 'Did you know about [the topic understood]?' But Roxane merely seems puzzled." instead.
Carry out Christian telling a confused Roxane about something:
now Roxane is annoyed;
say "Christian begins rambling on witlessly about [the topic understood]." instead.
Carry out Christian asking a confused Roxane about something:
now Roxane is annoyed;
say "Christian puts another confused question about [the topic understood]." instead.
And now we have enough material to begin writing the scenes:
Courting Roxane is a scene. Courting Roxane begins when play begins. Courting Roxane ends in success when Roxane is wooed. Courting Roxane ends in failure when Roxane is annoyed.
When Courting Roxane ends in success:
record "Seduction by Proxy" in the Table of Events;
say "Roxane, deeply moved by this sentiment, invites Christian up to her balcony. He scrambles up the ivy and disappears into her bedroom; the last thing you hear is a girlish giggle from above.";
now Roxane is nowhere; now Christian is nowhere;
move the player to Empty Street.
When Courting Roxane ends in failure:
record "Ruining Christian's Chances" in the Table of Events;
say "Roxane sighs heavily and goes back into her room, slamming the door behind her.
'Thanks very much,' says Christian to you, striding off down the street.";
now Roxane is nowhere; now Christian is nowhere;
move the player to Empty Street.
Sulky Ramble is a scene. Sulky Ramble begins when Courting Roxane ends in success. Sulky Ramble ends when the time since Sulky Ramble began is 2 minutes. When Sulky Ramble ends: record "Wandering the Streets, Sulking" in the Table of Events.
Every turn during Sulky Ramble:
say "You find yourself kicking fenceposts quite without thinking about it."
Smug Ramble is a scene. Smug Ramble begins when Courting Roxane ends in failure. Smug Ramble ends when the time since Smug Ramble began is 2 minutes. When Smug Ramble ends: record "Wandering the Streets, Exultant" in the Table of Events; say "Of course, you will regret this soon enough."
Every turn during Smug Ramble:
say "You find yourself smiling fiercely at the moon."
To record (occurrence - text) in (target table - a table name):
choose a blank row in the target table;
now the event entry is the occurrence.
Table of Events
event
"A Duel of Insults"
with 30 blank rows.
The plot summary rule is listed instead of the announce the score rule in the carry out requesting the score rules.
This is the plot summary rule:
say "The Plot So Far: [paragraph break]";
let act number be 0;
repeat through the table of Events:
increment act number;
say " Act [act number]: [event entry][line break]".
Test me with "christian, ask roxane about love / christian, say your breath smells like ripe taleggio to roxane / score / z / z / score".
ExamplePine 4 |
Suppose in addition to our pathetic little family history, we have another secret to convey to the Princess, this one a little more peculiar. She either gets it or she doesn't; once she gets it, we do not revisit that flashback, though it is still possible to keep visiting the poverty flashback.
A person can be asleep or awake. A person can be active or passive.
The Spinning Tower is a room. "A remote corner of the old castle, reserved for spinning and weaving tasks."
Sleeping Beauty is an asleep woman in the Spinning Tower. "[if asleep]Sleeping Beauty lies here, oblivious to your presence[otherwise]Sleeping Beauty stands beside you, looking [attitude][end if]." The description is "She is even more magnificent than the rumors suggested." Understand "woman" or "girl" or "princess" or "lady" as Sleeping Beauty.
Discovery is a scene. Discovery begins when play begins. Discovery ends when Sleeping Beauty is awake. Marriage Proposal is a scene. Marriage Proposal begins when Discovery ends.
When Discovery ends: say "Throughout the palace you can hear the other sounds of stirring and movement as the spell of centuries is broken."; now Beauty is passive.
Instead of waiting in the presence of an asleep person (called snorer): say "You are alone with the sound of [the snorer] snoring sonorously."
Instead of attacking an asleep person:
now the noun is awake;
say "[The noun] sits bolt upright. 'Hey! Ow!' So much for that true love's kiss nonsense."
Instead of kissing an asleep person:
now the noun is awake;
say "[The noun] slowly stirs to wakefulness!"
Instead of throwing water at an asleep person:
now the second noun is awake;
now the noun is nowhere;
say "You pour out [the noun] on [the second noun].
[The second noun] wakes, shuddering. 'Agh! I had a terrible dream about drowning and then-- Hey!'"
The player carries a jug of water. Understand "pour [something] on [something]" or "splash [something] at/on [something]" as throwing it at.
topic |
reply |
quip |
"dream/dreams/nightmare/nightmares/sleep" |
"'Sleep well?' you ask solicitously. |
'Not really,' she replies, edging away from you. So much for that angle." |
"'Ghastly nightmares,' she remarks. You nod politely." |
"marriage/love/wedding/boyfriend/beau/lover" |
"'So,' you say. 'This is a little weird since we just met, but, um. Would you like to get married?' |
She looks at you nervously. 'Do I have to? I mean, I'd rather not.'
Well, this could get prickly fast." |
"'I, er,' she says. 'I hope I'm not supposed to marry you or something.' Uh oh." |
"marriage/love/wedding/boyfriend/beau/lover" |
"'I was told I was going to marry you and inherit the kingdom,' you say, apologetically. 'Would that be very bad?' This could be awkward, considering your family circumstances -- you did promise your mother that everything would be better, after this -- |
'Oh, it's not you -- I'm seeing someone,' she says, smiling quickly.
You try to think how to point out that it's been a hundred years since she last saw her boyfriend." |
"'Do you think I could go look for someone? I'm seeing him, you see, and I think I've been... sick... for a while, so he might be worried.' |
You try to think how to point out that it's been a hundred years since she last saw her boyfriend. And try not to think how awkward things would be in your family if she refuses to marry you."
"marriage/love/wedding/boyfriend/beau/lover" |
"'Do you think you could consider alternatives if he's no longer interested in you?' you suggest. |
She gives you the look of a wounded squirrel. 'My father might not approve of my love for the kitchen boy, but his heart is faithful and true!' she exclaims.
'Right; supposing that he's still around, I'm sure that his love won't have faded,' you say, considering your fingernails. Maybe you'd better come clean with her about your identity, after all: she might be more favorably inclined if she understood that you won't interfere in her base-born romances." |
"'I don't expect you to understand,' she says in a low whisper. 'I know it is not considered proper for a princess to love -- and such a one as my William, who works in the kitchen --' Her glance dares you to laugh. '-- but I cannot marry you without telling you this truth.' |
Right then. Perhaps you'd better tell her your secret, in exchange?"
"marriage/love/wedding/boyfriend/beau/lover" |
"'You've been up here for a hundred years,' you say. An unpleasant thought occurs to you. 'Was your young man in the castle somewhere?' |
She shakes her head mutely." |
"She goes to the window and looks out at the now-fading thicket of briar. 'That took a while to grow,' she observes. 'I've been up here longer than I thought.' |
Instead of asking an awake beauty about a topic listed in the Table of Conversation when Marriage Proposal is happening:
now Beauty is passive;
say "[reply entry][paragraph break]";
blank out the whole row.
Instead of telling an awake beauty about something: try asking the noun about it.
Instead of asking an asleep person about something:
say "[The noun] snores."
Marriage Proposal ends in failure when the number of filled rows in the Table of Conversation is 0.
Every turn during Marriage Proposal:
if Beauty is active and Beauty is visible:
repeat through Table of Conversation:
say "[quip entry][paragraph break]";
blank out the whole row;
make no decision.
When Marriage Proposal ends in failure: end the story saying "This is going to take some explaining."
Instead of asking an awake beauty about a topic listed in the Table of Flashback Material:
now Beauty is passive;
say "[reply entry][paragraph break]".
A fact is a kind of thing. A fact can be known or unknown. A fact can be current or past.
The family circumstances is a fact. The secret identity is a fact. The printed name of secret identity is "secret".
topic |
reply |
"poor/poverty/family/money/mother/circumstances" or "family circumstances" or "my family/mother" |
"[if family circumstances is unknown]'I wish you'd give some thought to marrying me. You see,' you say, your jaw tensing. 'I wouldn't ask if it weren't for my [family circumstances]...'[otherwise]'I don't think you fully understand the [family circumstances],' you say.[end if]" |
"secret/identity/gender/girl/female/woman" or "secret identity" or "my secret" or "my secret identity" or "my gender" |
"[if dramatic revelation ended in failure]'Look,' you say, trying again. 'Pay attention: I need you to understand my [secret identity].'[otherwise]You clear your throat and allow your voice to stray upward, into its natural register and out of this husky false tenor you've been affecting. 'There's, er, something you should know about my [secret identity],' you say...[end if][if dramatic revelation ended in success] She looks impatient. 'I get it, you know,' she says. 'I'm not stupid.'" |
After printing the name of a fact (called target): now the target is current; now the target is known.
Poverty flashback is a recurring scene. Poverty flashback begins when family circumstances is current. When poverty flashback begins: strip the player; move the player to the Woodcutter's Shack.
The Woodcutter's Shack is a room. "Your family lives in a shack in the forest. There are holes in the roof, and in the winter the snow comes in -- rain, too, for that matter. The walls aren't very well-boarded, and don't keep out the wind, and even though you live in the middle of dense woods, you can never gather enough fuel to keep this place fully heated. And then there's the stench. Pigs wander freely in and out, and your three youngest brothers play on the floor."
Pigs are an animal in the shack. The pigs are scenery. The description is "They really are very grubby, dirty animals, but what's worse than that, the value of pigs has declined a lot over the last few decades. This is hard to explain to someone who has been out of touch with the world for a while, but keeping pigs for meat is a dubious prospect when there's less and less for them to forage on." Instead of smelling the pigs: say "They smell the way animals do, when they live among their own refuse."; increase the pity of Beauty by 2.
The brothers are a man in the shack. The brothers are scenery. The description of brothers is "Hans, Franz, and Lukas. Twins and then the baby. So young, and growing up fatherless; and soon to be orphaned entirely, if your mother's health does not improve." Understand "brother" or "twin" or "twins" or "baby" or "franz" or "hans" or "lukas" as the brothers.
The untidy bed is scenery in the Shack. Mother is a woman on the untidy bed. The description of mother is "She is wasting away of a slow disease, her skin stretched tautly over bone. She hasn't been the same since your father left." On the bed is a folded letter.
The description of the letter is "Many times read over and creased, the letter explains how your father has gone away with a wealthy countess and will not return. Your mother was not able to read it herself, of course, and had to have it explained to her by the parish priest. Now she keeps it by the bed and crumples it in her fits of delirium."
Instead of kissing or touching Mother for the first time:
say "You place a gentle kiss on her feverish brow. She looks up at you, her oldest -- yes, never mind that bit -- with a look of sincere trust and admiration.
'You'll find a way through this for us,' she says, squeezing your fingers. 'I know you will.'"; increase the pity of Beauty by 3.
Instead of kissing Mother: say "You have no more heart-rending memories of affection to recount; that one incident will have to serve, for rhetorical purposes."
Instead of waiting in the Shack: say "The wind blows sharply through the walls."
Instead of attacking someone in the Shack:
say "Though sometimes the conditions of your life make you grouchy and impatient, you would never dream of striking a member of your own family. But from time to time you do feel the temptation."
Beauty has a number called pity. After examining something in the Woodcutter's Shack, increment the pity of Beauty. After examining mother, increase the pity of Beauty by 2. After examining the letter, increase the pity of Beauty by 3.
Poverty flashback ends when waiting or the time since poverty flashback began is five minutes.
When Poverty flashback ends:
now family circumstances is past;
say "...you finish describing the miserable circumstances of your home life, and allow your attention to return to the present.";
restore the player;
now Beauty is passive;
if Beauty is clever and Beauty is sympathetic:
say "'I understand,' she says slowly. 'Yes, I do. I'll do it.' She takes a deep breath and looks at you. 'We will be king together! and your family will be royalty!'";
end the story finally;
otherwise:
if Beauty is sympathetic, say "'Oh dear!' she says. 'What a dreadful life!' She wrings her hands. 'No wonder you are eager to improve your lot...! But --' Her brow clears, a new thought occurring. 'You needn't marry me, you know! We could arrange it differently! I am certain that my father would give you a large reward, instead, and then I would not be separated from my current boyfriend!'";
otherwise say "She makes a disgusted face, but she doesn't seem nearly so heart-wrung as you had hoped to make her. Tough audience, these modern princesses."
Definition: Beauty is sympathetic if the pity of Beauty is greater than 4.
To say attitude:
if Beauty is sympathetic, say "distressed on your behalf";
otherwise say "a little confused".
Saved location is a room that varies. Locker is a container. Wardrobe is a container.
To strip the player:
now every thing carried by the player is in the locker;
now every thing worn by the player is in the wardrobe;
now saved location is location.
To restore the player:
now every thing carried by the player is in the location;
now every thing in the locker is carried by the player;
now every thing in the wardrobe is worn by the player;
move the player to saved location.
This time, we're waiting for the princess either to understand or not understand -- so we don't want to rerun the scene once it has happened successfully.
Dramatic revelation is a recurring scene. Dramatic revelation begins when attempting confidence.
To decide whether attempting confidence:
if dramatic revelation ended in success, no;
if secret identity is current, yes;
no.
When dramatic revelation begins:
strip the player;
say "You reminisce about one of the many stops on the way here: you had a long journey from your homeland, and it wasn't made any easier by your poverty, the inability to afford decent inns or plentiful food or any kind of ride along the way.";
move the player to the Forest Clearing;
move the pack to the player; now the player wears the trousers; now the player wears the shirt.
Forest Clearing is a room. "It's mid-autumn in your memory, the pool clear and cold, gold and red leaves floating on the surface."
The pool is scenery in the Clearing. Understand "reflection" or "surface" or "water" as the pool. "The pool is cold but beautiful, and the stopping place a welcome rest." The leaves are scenery in the clearing. The description is "Bright gold and orange and red: it's been a sharply chilly autumn, as you have reason to know in detail."
The trousers and the shirt are wearable things. The pack is a container. The pack contains ale, food, and skirt. A distraction is a kind of thing. The ale, the food, the pair of trousers, and the shirt are distractions. The description of a distraction is usually "[The item described] is not the point of this story." The shirt and the trousers are wearable. The description of the trousers is "Borrowed from your oldest brother, who is only a year younger than you. They are too long for your legs and overly snug at the hip, but no one around here pays much attention to fashion, and you're getting away with it, more or less." After examining the trousers, increment the clue count of Beauty.
Instead of examining the player during dramatic revelation:
increment the clue count of Beauty;
say "You cannot see yourself without reflection, but you can feel your hair loose and unbound over your shoulders."
Rule for printing the name of the skirt while taking inventory: say "one skirt you have not been able to bring yourself to part with". The description of the skirt is "Made for you by your mother, and it looks quite pretty on you. If your primary plan does not work, you may be forced to wear it again, and hope to catch a male eye... but with luck that will not be necessary." After taking inventory: increment clue count of Beauty.
Swimming is an action applying to nothing. Understand "swim" or "dive" as swimming.
Instead of swimming in the presence of the pool:
increment clue count of Beauty;
say "You consider going for a swim, but don't dare be caught unclad and unarmed, not here. There are too many men around, and any of them discovering you here would surely take advantage."
Instead of searching or drinking the pool:
increment clue count of Beauty;
say "You lean over the pool and look carefully at your reflection, your hair loose and unbound, falling around your face in waves. (That should surely give it away!)"
Instead of waiting during dramatic revelation: say "You wait for the penny to drop, for her to understand."
Dramatic revelation ends in failure when waiting or the time since dramatic revelation began is five minutes. When dramatic revelation ends in failure:
now secret identity is past;
restore the player;
now Beauty is passive;
say "She wrinkles her nose. 'I don't understand!' she says. 'What are you trying to tell me?'
You could weep for womankind. But you don't quite dare spell it out in so many words, not when someone might come up the stair and overhear a chance revelation."
Dramatic revelation ends in success when Beauty is clever. When dramatic revelation ends in success:
restore the player;
now Beauty is passive;
say "'You're -- a girl? Like me?'
'Not much like you,' you say, glancing over her petite frame and pert nose. 'But female, at any rate.'"
Definition: Beauty is clever if the clue count of Beauty is greater than 2.
And now, since we don't really want to return to the rest of the 'marriage proposal' scene once she has learned our ID:
Marriage proposal ends in distraction when Dramatic Revelation ends in success.
Compromise proposal is a scene. Compromise proposal begins when Dramatic Revelation ends in success. When Compromise Proposal begins: now Beauty is passive.
Instead of asking an awake beauty about a topic listed in the Table of Secondary Conversation when Compromise Proposal is happening:
now Beauty is passive;
say "[reply entry][paragraph break]";
blank out the whole row.
Every turn during Compromise Proposal:
if Beauty is active and Beauty is visible:
repeat through Table of Secondary Conversation:
say "[quip entry][paragraph break]";
if the number of filled rows in the Table of Secondary Conversation is greater than 1, blank out the whole row;
make no decision.
Notice that we moved the re-activation rule down here so that the Compromise Proposal rule would fire first. There are other more complicated ways of handling order of every turn rules than by relying on text sequence alone; but we will save that for a later chapter. For now it is sufficient to depend on the order in which the rules are declared.
topic |
reply |
quip |
"girls/me/women/female/truth/identity" |
"'Marrying me would be no interference,' you go on. 'You could carry on whatever romances you wished, without your father noticing.' (Probably. You'll let the pragmatic details of this work themselves out later, and hope that any children she has will look vaguely like you.)" |
"'Girls can't rescue people.' |
'Wrong,' you say, feeling a little annoyed. 'But you see why marrying me wouldn't be an interference. You could carry on whatever romances you wished, without your father even noticing.'"
"king/man" |
"'If you're thinking that a woman can't be the prince -- and then king -- well, there was a woman Pope, once.' |
She looks awed." |
"The crease in her forehead does not go away. 'But if everyone thinks you are a man... later you would be king!' |
Before she can go on, you say, 'There was a woman Pope, once. Compared to that, a woman king is nothing.'"
"decision/proposal/marriage/choice" |
"'So,' you say. 'What do you think?' |
[final decision]" |
"Her pretty nose twitches again, which you are coming to recognize as a sign of hard mental labor. 'I think I see,' she says. [final decision]" |
To say final decision:
if Beauty is sympathetic:
say "She considers the matter silently for some minutes, then says: 'I will do it. My beloved William will be so glad!' You imagine that William's feelings on the matter will be a tad more complex than that, but do not bother quashing her exuberance...";
end the story finally;
otherwise:
say "'I still don't quite understand why you would want this so badly as to go to all that trouble,' she admits uneasily. Evidently you have not explained enough to her about the poverty of your home life."
Test me with "x beauty / pour water on beauty / ask beauty about sleep / tell beauty about poverty / smell pigs / x mother / x letter / kiss mother / ask beauty about marriage / tell beauty about identity / x me / look in water / i / z / ask beauty about marriage".