Inform 7 Home Page / Documentation
§10.8. Fire
Fire exhibits some of the properties of a gas: it is only vaguely located and tends to spread out, though it passes by touch rather than on the air. It is hazardous to life, through direct contact, heat, and smoke. Better governed, it provides light and warmth. Worse governed, it consumes almost anything it comes into contact with. Here the problem with "debris" is not so much that we need potentially hundreds of new objects to represent broken items: instead, fire could sweep through a work of IF destroying so much that no play is possible any longer. Setting up a problem in which the player must defeat a fully-capable fire is difficult to balance.
As with liquids, it is best to simulate the least amount of fire that the design will allow. Bruneseau's Journey provides a single candle which can be lit, or blown out, but where fire can never transfer from the candle's end to anything else - or vice versa: the player's source of fire, with which to light the candle, is discreetly neglected.
In the more realistic Thirst 2, a campfire is lit using a tinderbox, so that fire does transfer from one thing (tinder) to another (the campfire): but it is always confined to just these two items, and can be used only for light and warmth.
The Cow Exonerated provides a class of matches that can light any flammable object, but assumes that burning objects requires only one turn; lighting one thing does not burn another.
In Fire or in Flood provides a complete simulation of what we might call "wild-fire": combustion which spreads through arbitrary objects and rooms, destroying all in its path.
See Examining for a way to describe objects as charred once they have been partly burnt
See Heat for one consequence of fire having touched something
See Gases for an implementation of smoke without fire, if this can exist
See Liquids for water being used to extinguish a simple fire
See Lighting for other uses of candles and torches as light sources
Start of Chapter 10: Physics: Substances, Ropes, Energy and Weight | |
Back to §10.7. Electricity and Magnetism | |
Onward to §10.9. Heat |
ExampleThirst 2 |
The player carries a waterskin. The waterskin can be full, partly drained, or empty. The waterskin is full. Understand "water" as the waterskin.
Instead of drinking the waterskin when the waterskin is empty:
say "There is no water left."
Instead of drinking the waterskin: if the waterskin is partly drained, now the waterskin is empty; if the waterskin is full, now the waterskin is partly drained; say "You drink a long draught."
After printing the name of the waterskin: say " ([waterskin condition])"
Campsite is a room. "It is solid night now, and the stars have come out. Unfamiliar stars. On the other side of the valley -- a valley round-bottomed but shallow, like a soup bowl -- burn other campfires, most likely bandits. Their voices do not carry, but the smoke rises and obscures the starlight over that way."
A sleepsack is an enterable container in the Campsite. "Your sleepsack is laid out in a pocket of sandy soil and coarse grass."
The sandy soil, the stars, the distant campfires, and the coarse grass are scenery in the Campsite. Understand "smoke" as the campfires. Instead of listening in the presence of your campfire: say "All you hear are the reassuring snaps and cracks of the sticks in your fire." Understand "campfires" or "fires" as the distant campfires.
Your campfire is scenery in the Campsite. Instead of pushing, pulling, turning, tasting, or touching your campfire, say "You would burn yourself." Understand "fire" as your campfire. The description of your campfire is "A reassuring protection against wild animals and cold."
The description of the stars is "You invent constellations for them. The slingshot. The scroll. The heart (upside down)."
Instead of going nowhere when the player is in Campsite:
say "Now is not the time for wandering, alone in the dark. Better to keep here[if your campfire is visible], by the fire[end if]."
Singing is an action applying to nothing. Understand "sing" as singing.
Instead of singing:
say "You sing, deep and low, a song from home. It is a good night for singing and the song raises your spirits."
The player carries a tinderbox. The tinderbox contains a flint, a steel, some tinder, and a patch of carbonized cloth. The description of the flint is "A flat grey stone with flaked edges." The description of the steel is "Curved so that you can hold it over the knuckles of your right hand and strike it against the flint. There is a knack to it. Those without the knack end up with bloody knuckles and no fire." The steel is wearable. The description of the tinder is "Dried grass and similar." The description of the cloth is "The little, precious, spark-preserving scraps without which the fire would never begin."
Instead of attacking the flint when the steel is not worn by the player:
say "You must wear the steel over your knuckles, in order to hit the flint at the best angle."
Instead of attacking the flint when the steel is worn and the cloth is not in the location:
say "Though you strike the flint sharply with the steel and throw sparks, they have nothing to catch on, since the patch of cloth does not lie beneath."
Instead of attacking the flint when the steel is worn and the cloth is in the location and the cloth is not unlit:
say "The patch of cloth has already caught."
Instead of attacking the flint:
now the cloth is glowing;
say "You strike the flint against the steel and throw sparks onto the patch of cloth; they make tiny circles of orange there, which will only prosper if blown into flame."
Realistically, we ought to attach a randomization to this so that each step of the fire-starting has a good chance of failure. But because our player may not be as patient as someone who actually needs a fire started, we allow him to succeed the first time in every case.
Ignition is a kind of value. The ignitions are whole, fading, glowing, flaming. A thing has an ignition.
Blowing on is an action applying to one thing. Understand "breathe on [something]" or "blow on [something]" as blowing on.
Instead of blowing on the whole cloth:
say "There is no point, since no sparks have caught there."
Instead of blowing on the fading cloth:
now the cloth is flaming;
say "You blow on the faint sparks on the cloth and turn them into the beginnings of flame."
Instead of burning the whole tinder:
if the cloth is not flaming:
say "The patch of cloth must catch flame before you can light anything with it.";
otherwise:
now the tinder is flaming;
now the cloth is nowhere;
say "You light the tinder with the patch of cloth, and have the elements of a fire."
Every turn:
unless the cloth is flaming or the cloth is whole:
now the ignition of the cloth is the ignition before the ignition of the cloth;
say "Now the patch of cloth is [ignition of the cloth]."
Instead of burning the whole kindling:
if the tinder is not flaming:
say "You need the tinder to be flaming, first.";
otherwise:
now the tinder is nowhere;
now the kindling is nowhere;
move the campfire to the location;
say "You succeed in lighting yourself a proper campfire.";
now the printed name of Campsite is "By The Campfire".
Test me with "i / drink water / i / drink water / i / wear steel / get flint / get cloth / drop cloth / get tinder / hit flint / blow on cloth / burn tinder / burn kindling / look".
ExampleBruneseau's Journey |
"Sire," said the Minister of the Interior to Napoleon, "yesterday I saw the most intrepid man in your Empire." - "What man is that?" said the Emperor brusquely, "and what has he done?" - "He wants to do something, Sire." - "What is it?" - "To visit the sewers of Paris."
Let's say that our intrepid explorer has a candle that can be lit and blown out again, and should accordingly appear unlit, burning, or partly burnt:
The Sewer Beneath St Denis is a room. "A narrow, stone-lined passageway, with only a little ledge to walk above the level of the refuse that flows down towards the Seine."
The candle is carried by the player. The description of the candle is "A candle, [if the candle has been lit]partially burnt[otherwise]still in pristine condition with untouched wick[end if]."
Instead of examining the lit candle, say "It burns with a pure heart."
The block burning rule is not listed in the check burning rules.
Instead of burning the lit candle:
say "The candle is already lit."
Check burning:
if the noun is not the candle, say "[The noun] cannot profitably be set on fire."
Report burning:
if the candle had been lit, say "You relight the candle.";
otherwise say "You light the candle for the first time.".
Understand "blow out [something]" as blowing out. Understand "blow [something] out" as blowing out. Blowing out is an action applying to one thing.
Report blowing out:
if the noun is the candle and the candle was lit, say "You blow out [the noun].";
otherwise say "You blow on [the noun], to little effect."
Test me with "x candle / light candle / x candle / blow out candle / x candle".
We must be careful: "if the noun was lit" would throw errors because past-tense rules can only be applied to specific items, not to variables that could be anything.
ExampleThe Cow Exonerated |
Here we create a class of matches that can be used to burn other objects. Our objectives are as follow:
Burned objects other than matches should be removed from play instantly (just as edible objects are instantly eaten). We could give everything its own burning duration, but that complicates matters and allows for fire to spread from one object to another; for an example of how to do that, see the example "In Fire or in Flood".
Matches should be described to show whether they are burning or extinguished, and when the parser chooses one of several identical matches, it should make very clear which match it has selected.
The game must sensibly select and, if necessary, automatically light new matches to carry out a >BURN THING command.
The matches must burn for a set number of turns before going out, never to be used again.
And finally, the part for which the text will be useful: when several matches go out in the same turn, we want the game to print
rather than
A match goes out.
A match goes out.
A match goes out.
A match goes out.
This last function appears down in Section 3, if we wish to skip ahead and look at it.
Understand the commands "light" and "burn" as something new.
Understand "burn [something] with [strikable-match]" as burning it with. Understand "burn [something] with [something preferably held]" as burning it with. Burning it with is an action applying to one thing and one carried thing.
A thing can be flammable or impervious. A thing is usually impervious.
Check burning something with something (this is the burn only with flaming matches rule):
if the second noun is not a strikable-match, say "You can only light things with matches." instead;
if the second noun is not flaming, say "[The second noun] needs to be burning first." instead.
Check burning something with something (this is the burn only flammable things rule):
if the noun is impervious, say "[The noun] cannot be burned." instead.
Check burning something with something (this is the burn only things not held rule):
say "[one of]It occurs to you to set down [the noun] before burning, just for safety's sake. [or]Again, you decide to put down [the noun] prior to burning. [or]You try setting down [the noun] as usual. [stopping][run paragraph on]";
silently try the player dropping the noun;
if the player encloses the noun, stop the action.
Carry out burning something with something (this is the simplistic burning rule):
now the noun is nowhere.
Report burning something with something:
say "You burn up [the noun]."
Rule for implicitly taking the second noun while burning something with something which is not a strikable-match:
say "You can only light things with matches.";
stop the action.
The word "matches" is used by Inform to compare snippets of text (see "Reading a command" in the Activities chapter). This can sometimes cause awkwardness if we also have a kind called "match", so for the occasion we will give our matches a more specialized name, never visible to the player:
A strikable-match is a kind of thing. The plural of strikable-match is s-matches.
A strikable-match has a number called duration. The duration of a strikable-match is usually 3.
Rule for printing the name of a strikable-match: say "match".
Rule for printing the plural name of a strikable-match: say "matches".
Understand "match" as a strikable-match. Understand "matches" as a strikable-match.
Flame-state is a kind of value. The flame-states are burnt, flaming, and new. Understand "burning" or "lit" as flaming. Understand "unused" as new.
A strikable-match has a flame-state. A strikable-match is usually new. Understand the flame-state property as describing a strikable-match.
Before printing the name of a strikable-match while asking which do you mean:
say "[flame-state] ".
Before printing the name of a strikable-match while taking inventory:
say "[flame-state] ".
Before printing the plural name of a strikable-match while taking inventory:
say "[flame-state] ".
Before printing the name of a strikable-match while clarifying the parser's choice of something:
if not taking inventory, say "[flame-state] ".
After printing the name of a strikable-match (called special-target) while clarifying the parser's choice of something:
if the player carries the special-target:
say " you're carrying";
otherwise if the special-target is in the location:
say " on the ground";
otherwise:
say " [if the holder of the special-target is a container]in[otherwise]on[end if] [the holder of the special-target]".
Understand "strike [strikable-match]" as striking. Striking is an action applying to one carried thing.
Does the player mean striking a new strikable-match:
it is very likely.
Does the player mean striking a burnt strikable-match:
it is unlikely.
Check striking a strikable-match (this is the strike only new matches rule):
if the noun is burnt, say "[The noun] has already burnt down and cannot be relit." instead;
if the noun is flaming, say "[The noun] is already burning." instead.
Carry out striking a strikable-match (this is the standard striking rule):
now the noun is flaming;
now the noun is lit.
Report striking a strikable-match (this is the standard report striking rule):
say "You light [the noun]."
Before burning something with a new strikable-match (this is the prior lighting rule):
say "(first [if the player does not carry the second noun]taking and [end if]lighting [the second noun])[command clarification break]";
silently try striking the second noun;
if the second noun is not flaming, stop the action.
Rule for implicitly taking a strikable-match (called target) while striking:
try silently taking the target.
Does the player mean burning something with a flaming strikable-match:
it is very likely.
Does the player mean burning something with a new strikable-match:
it is likely.
Does the player mean burning something with a burnt strikable-match:
it is unlikely.
Instead of burning a burnt strikable-match with something:
say "[The noun] is completely consumed and cannot be relit."
Every turn:
let N be 0; [here we track how many matches are being put out during this turn, so that we don't have to mention each match individually if several go out during the same move]
repeat with item running through flaming s-matches:
decrement the duration of the item;
if the duration of the item is 0:
now the item is burnt;
now the item is unlit;
if the item is visible, increment N;
if N is 1:
say "[if the number of visible flaming s-matches is greater than 0]One of the matches [otherwise if the number of burnt visible s-matches is greater than 1]Your last burning match [otherwise]The match [end if]goes out.";
otherwise if N is greater than 1:
let enumeration be "[N in words]";
if N is the number of visible s-matches:
if N is two, say "Both";
otherwise say "All [enumeration]";
otherwise:
say "[enumeration in title case]";
say " matches go out[if a visible strikable-match is flaming], leaving [number of visible flaming s-matches in words] still lit[end if]."
The player carries a flammable thing called a log. Understand "wooden" and "wood" as the log.
The player carries two s-matches. The matchbox is an open openable container. It contains five s-matches. The player carries the matchbox.
When play begins:
now every strikable-match carried by the player is flaming;
now every strikable-match carried by the player is lit.
Test me with "i / burn match / i / i / burn log with match / burn matchbox with match / i".
ExampleIn Fire or in Flood |
Heat is a kind of value. The heats are whole, damp, and flaming. A thing has a heat. A thing is usually whole.
A thing has a number called endurance. The endurance of a thing is usually 5. A thing has a number called turns of burning. A thing can be flammable or flame-retardant.
Before printing the name of something flaming:
say "flaming ".
Before burning something when the player is not carrying something flaming:
if a flaming portable thing (called the lighter) is touchable:
say "(with [the lighter], which you first take)[command clarification break]";
try taking the lighter.
Instead of burning something when the player is not carrying something flaming:
say "You would first need a fire source."
Instead of burning something flame-retardant:
say "[The noun] is not the sort of thing that catches fire."
Instead of burning something flammable when the player is carrying something flaming (called the flame source):
say "You light [the noun] with [the flame source].";
now the heat of the noun is flaming.
Instead of burning something when the player is in the noun:
say "That seems dangerous given that you yourself are in [the noun]."
Instead of burning something when the player is on the noun:
say "That seems dangerous given that you yourself are on [the noun]."
Instead of examining something:
say "Hm, the [printed name] appears to be [heat]."
Before taking a flaming thing:
let turns remaining be the endurance of the noun minus the turns of burning of the noun;
if turns remaining is less than two, say "There's no portion of [the noun] sufficiently cool for you to pick up." instead.
But that's only a small part of the battle. The thing about fire is that it keeps on doing fiery things even when the player is otherwise occupied: destroying items that are on fire, and spreading to other things nearby. So we need a set of rules for the fire's behavior.
Every turn when something is flaming:
follow the fire rules.
A fire rule (this is the can't hold flaming objects rule):
repeat with item running through flaming things:
if the item is held by the player:
let turns remaining be the endurance of the item minus the turns of burning of the item;
if turns remaining is less than two:
say "[The item] becomes too hot to hold! ";
try dropping the item;
if the item is held by the player, say "This is certainly painful."
A fire rule (this is the flames spread rule):
repeat with item running through flaming things:
if the turns of burning of the item is one:
spread the flames from the item.
A fire rule (this is the fire destroys things rule):
now started printing is false;
repeat with item running through flaming things:
increment the turns of burning of the item;
if the turns of burning of the item is greater than the endurance of the item, destroy the item;
if started printing is true, say "[paragraph break]";
now started printing is false.
Because we've labelled all the fire rules, we could swap their order, or turn some of them off, while allowing the others run as usual. For instance, if there were a pair of fireproof gloves in the game, we might want to turn off the "can't hold flaming objects rule" whenever the player is wearing them.
This sort of flexibility is especially useful in the context of extensions. Someone writing an extension about burning would have no way of anticipating the need for a Fireproof Gauntlet of Thog, but the author would nonetheless be able to implement one easily.
Definition: a thing is vulnerable if it is flammable and it is whole.
The contact between things is a critical factor when it comes to fire, so we might add a couple of conditional relations do determine what is touching what.
Reliance relates a thing (called X) to a thing (called Y) when X is part of Y or X is in Y or X is on Y. The verb to be relying on means the reliance relation.
Contact relates a thing (called X) to a thing (called Y) when X is relying on Y or Y is relying on X. The verb to be joined to means the contact relation.
Having these at our disposal makes it much tidier to write what happens next:
To spread the flames from (item - a thing):
now started printing is false;
if the item is joined to a flammable whole thing (called the sacrifice):
if the sacrifice is visible:
now started printing is true;
say "Flames engulf [the list of flammable whole things which are joined to the item].";
now all the flammable whole things joined to the item are flaming.
Started printing is a truth state that varies. Started printing is false.
To destroy (item - a thing):
let home be the holder of the item;
if the item is part of something (called the superstructure), let home be the holder of the superstructure;
if the item is visible:
now started printing is true;
say "[The item] burns away[if something is relying on the item], leaving [a list of things which are relying on the item] behind[end if]. ";
if something is relying on the item,
now all the things which are relying on the item are in the home;
now the item is nowhere;
now the item is damp;
now every flaming thing which is part of the item is damp.
To destroy (item - a door):
let home be the holder of the item;
if item is visible:
now started printing is true;
say "[The item] burns away[if something flame-retardant is part of the item], leaving [a list of flame-retardant parts of the item] behind[end if]. ";
if home is a room, now all of the flame-retardant parts of the item are in the home;
now the item is damp;
now the item is open;
now the item is unopenable.
Before printing the name of a damp door:
say "burnt-out frame of ".
Instead of opening or closing a damp door:
say "[The noun] can no longer be opened or closed in any meaningful sense."
Instead of doing something other than examining or dropping to a flaming thing when the turns of burning of the noun is greater than 1:
say "Fire has too thoroughly engulfed [the noun] for that to be a good idea."
Instead of taking something when the noun is in a flaming thing (called the receptacle):
say "You don't quite dare reach into [the receptacle]."
Instead of touching something which is within a flaming thing (called the receptacle):
say "It seems a little risky since [the receptacle] is on fire."
Instead of turning something when the noun is contained in a flaming thing (called the receptacle):
say "It seems a little risky since [the receptacle] is on fire."
Instead of pushing or pulling something when the noun is inside a flaming thing (called the receptacle):
say "[The receptacle] deters you."
Before burning something which is in a container when the holder of the noun contains the player:
say "This could make things toasty for you..."
And that completes the rules which cover burning: things can catch fire, fire will spread, and gradually consume the world in flames. All of that was general and could be used in any setting, but we now provide a small game to show it off.
The Library of the Dead is a room. "This room -- little, dank, stone -- is filling with some miasma you do not quite dare breathe. It is imperative that you get out."
The desk is a flammable supporter in the Library. A drawer is part of the desk. The drawer is a flammable closed container. It is openable, lockable, and locked. The desk is scenery.
A box is in the Library. A metal hinge is part of the box. The hinge is flame-retardant. The box is open, flammable, and openable. The shroud of Laertes is a flammable thing in the box.
Instead of examining something when something is part of the noun:
say "You note [the list of things which are part of the noun]."
The world's last manuscript of the Psychagogoi by Aeschylus is on the desk. The manuscript is flammable. The manuscript has endurance 1.
The torch is a flammable flaming thing carried by the player. It has endurance 60. The asbestos sack is a flame-retardant player's holdall in the drawer.
The trapdoor is up of the Library and east of the Plaza. The trapdoor is a door. It is flammable, closed, lockable, and locked. "A trapdoor in the ceiling is your only hope of escape[if flaming]. Fortunately, it is rapidly burning through[end if]." The trapdoor has endurance 15.
Instead of going through the closed trapdoor, say "[The trapdoor] is closed."
We can then add a special fire rule to handle the trapdoor, which will be called as part of the same sequence. Again, this would be most important if the fire rules were part of a standard extension, and the trapdoor fire rule the author's own addition.
A fire rule:
if the trapdoor is flaming and a random chance of 1 in 3 succeeds:
let the caught thing be a random flammable whole thing which can be touched by the trapdoor;
if the caught thing is a thing:
say "A spark from [the trapdoor] catches [the caught thing]!";
now the caught thing is flaming.
Instead of going to the Plaza:
say "Out at last!";
end the story finally.
Test me with "get manuscript / get shroud / light desk / look / g / open drawer / look / g / g / g / get sack / put shroud in sack / put manuscript in sack / close sack / light trapdoor / look / g / g / g / g / g / g / g / g / g / g / g / g / g / g / up".