Implement and document state-changes messages in YAML.

Examples at the lamp and grate.  This is a way to pull strings out of
arbitrary_messages and make them part of the object definition.
This commit is contained in:
Eric S. Raymond 2017-06-28 16:14:23 -04:00
parent aca6d79087
commit 1ed8126912
5 changed files with 135 additions and 105 deletions

View file

@ -6,6 +6,12 @@
static int fill(token_t, token_t); static int fill(token_t, token_t);
static void state_change(long obj, long state)
{
game.prop[obj] = state;
pspeak(obj, change, state);
}
static int attack(FILE *input, struct command_t *command) static int attack(FILE *input, struct command_t *command)
/* Attack. Assume target if unambiguous. "Throw" also links here. /* Attack. Assume target if unambiguous. "Throw" also links here.
* Attackable objects fall into two categories: enemies (snake, * Attackable objects fall into two categories: enemies (snake,
@ -456,8 +462,7 @@ static int extinguish(token_t verb, int obj)
game.prop[URN] = game.prop[URN] / 2; game.prop[URN] = game.prop[URN] / 2;
spk = URN_DARK; spk = URN_DARK;
} else if (obj == LAMP) { } else if (obj == LAMP) {
game.prop[LAMP] = LAMP_DARK; state_change(LAMP, LAMP_DARK);
rspeak(LAMP_OFF);
spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE; spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
} else if (obj == DRAGON || obj == VOLCANO) } else if (obj == DRAGON || obj == VOLCANO)
spk = BEYOND_POWER; spk = BEYOND_POWER;
@ -663,8 +668,7 @@ static int light(token_t verb, token_t obj)
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
game.prop[LAMP] = LAMP_BRIGHT; state_change(LAMP, LAMP_BRIGHT);
rspeak(LAMP_ON);
if (game.wzdark) if (game.wzdark)
return GO_TOP; return GO_TOP;
else else
@ -737,8 +741,8 @@ static int lock(token_t verb, token_t obj)
if (!game.panic)game.clock2 = PANICTIME; if (!game.panic)game.clock2 = PANICTIME;
game.panic = true; game.panic = true;
} else { } else {
game.prop[GRATE] = (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN; state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
spk = game.prop[GRATE] ? GRATE_UNLOCKED : GRATE_LOCKED; return GO_CLEAROBJ;
} }
} }
} }

View file

@ -86,7 +86,7 @@ extern const char advent_to_ascii[];
extern FILE *logfp; extern FILE *logfp;
extern bool oldstyle, editline, prompt; extern bool oldstyle, editline, prompt;
enum speaktype {touch, look, hear, study}; enum speaktype {touch, look, hear, study, change};
/* b is not needed for POSIX but harmless */ /* b is not needed for POSIX but harmless */
#define READ_MODE "rb" #define READ_MODE "rb"

View file

@ -84,19 +84,25 @@
# Order doesn't matter; the logic simply tests every threshold on # Order doesn't matter; the logic simply tests every threshold on
# the assumption that turn counts never decrease nor skip values. # the assumption that turn counts never decrease nor skip values.
# #
# objects: Each item contains a description for use in the # objects: Objects have attributes as follows...
# inventory command and one or more messages describing the object # inventory: A description for use in the inventory command.
# in different states. The vocabulary word(s) referring to this # descriptions: Messages describing the object in different states.
# object are listed (words). There is also a boolean "treasure" # If a state message is a tuple then the first element
# attribute, defaulting to false. An object may have one or two # is made the name of a #define visible to the code for
# start locations (the gate is an example of a two-location object; # the associated state, numbered from zero upwards; it
# it can be accessed from above or below). An object may also be # is also a state label that can be used in travel-rule
# flagged immovable, meaning it cannot be carried. If a state # 'not' clauses.
# message is a tuple then the first element is made the name of a # changes: State-change messages to be emitted whenever the obect
# #define visible to the code for the associated state, numbered # *changes* to the (0-origin) state that is the index of the
# from zero upwards; it is also a state label that can be used in # message in this array.
# travel-rule 'not' clauses. If the inventory description begins with "*" # words: The vocabulary word(s) referring to this object.
# the object is dungeon furniture that cannot be taken or carried. # treasure: A boolean "treasure" used for point-scoring and pirate
# snatches, defaulting to false.
# immovable: An object may also be flagged
# immovable, meaning it cannot be carried.
# locations: An object may have one or two start locations (the gate
# is an example of a two-location object; it can be accessed
# from above or below).
# #
# obituaries: Death messages and reincarnation queries. Order is # obituaries: Death messages and reincarnation queries. Order is
# significant, they're used in succession as the player racks up # significant, they're used in succession as the player racks up
@ -2718,12 +2724,12 @@ arbitrary_messages: !!omap
- NO_LOCK: 'It has no lock.' - NO_LOCK: 'It has no lock.'
- NOT_LOCKABLE: 'I don''t know how to lock or unlock such a thing.' - NOT_LOCKABLE: 'I don''t know how to lock or unlock such a thing.'
- ALREADY_LOCKED: 'It was already locked.' - ALREADY_LOCKED: 'It was already locked.'
- GRATE_LOCKED: 'The grate is now locked.' - ARB_35: !!null
- GRATE_UNLOCKED: 'The grate is now unlocked.' - ARB_36: !!null
- ALREADY_UNLOCKED: 'It was already unlocked.' - ALREADY_UNLOCKED: 'It was already unlocked.'
- URN_EMPTY: 'The urn is empty and will not light.' - URN_EMPTY: 'The urn is empty and will not light.'
- LAMP_ON: 'Your lamp is now on.' - ARB_39: !!null
- LAMP_OFF: 'Your lamp is now off.' - ARB_40: !!null
- BEAR_BLOCKS: 'There is no way to get past the bear to unlock the chain, which is\nprobably just as well.' - BEAR_BLOCKS: 'There is no way to get past the bear to unlock the chain, which is\nprobably just as well.'
- NOTHING_HAPPENS: 'Nothing happens.' - NOTHING_HAPPENS: 'Nothing happens.'
- WHERE_QUERY: 'Where?' - WHERE_QUERY: 'Where?'
@ -3007,59 +3013,65 @@ turn_thresholds:
objects: !!omap objects: !!omap
- OBJ_0: - OBJ_0:
inventory: !!null inventory: !!null
longs: !!null descriptions: !!null
- KEYS: - KEYS:
words: ['keys', 'key'] words: ['keys', 'key']
inventory: 'Set of keys' inventory: 'Set of keys'
locations: LOC_BUILDING locations: LOC_BUILDING
longs: descriptions:
- 'There are some keys on the ground here.' - 'There are some keys on the ground here.'
- LAMP: - LAMP:
words: ['lamp', 'lante'] words: ['lamp', 'lante']
inventory: 'Brass lantern' inventory: 'Brass lantern'
locations: LOC_BUILDING locations: LOC_BUILDING
longs: descriptions:
- [LAMP_DARK, 'There is a shiny brass lamp nearby.'] - [LAMP_DARK, 'There is a shiny brass lamp nearby.']
- [LAMP_BRIGHT, 'There is a lamp shining nearby.'] - [LAMP_BRIGHT, 'There is a lamp shining nearby.']
changes:
- 'Your lamp is now off.'
- 'Your lamp is now on.'
- GRATE: - GRATE:
words: ['grate'] words: ['grate']
inventory: '*grate' inventory: '*grate'
locations: [LOC_GRATE, LOC_BELOWGRATE] locations: [LOC_GRATE, LOC_BELOWGRATE]
immovable: true immovable: true
longs: descriptions:
- [GRATE_CLOSED, 'The grate is locked.'] - [GRATE_CLOSED, 'The grate is locked.']
- [GRATE_OPEN, 'The grate is open.'] - [GRATE_OPEN, 'The grate is open.']
changes:
- 'The grate is now locked.'
- 'The grate is now unlocked.'
- CAGE: - CAGE:
words: ['cage'] words: ['cage']
inventory: 'Wicker cage' inventory: 'Wicker cage'
locations: LOC_COBBLE locations: LOC_COBBLE
longs: descriptions:
- 'There is a small wicker cage discarded nearby.' - 'There is a small wicker cage discarded nearby.'
- ROD: - ROD:
words: ['rod'] words: ['rod']
inventory: 'Black rod' inventory: 'Black rod'
locations: LOC_DEBRIS locations: LOC_DEBRIS
longs: descriptions:
- 'A three foot black rod with a rusty star on an end lies nearby.' - 'A three foot black rod with a rusty star on an end lies nearby.'
- ROD2: - ROD2:
words: ['rod'] words: ['rod']
inventory: 'Black rod' inventory: 'Black rod'
locations: LOC_NOWHERE locations: LOC_NOWHERE
longs: descriptions:
- 'A three foot black rod with a rusty mark on an end lies nearby.' - 'A three foot black rod with a rusty mark on an end lies nearby.'
- STEPS: - STEPS:
words: ['steps'] words: ['steps']
inventory: '*steps' inventory: '*steps'
locations: [LOC_PITTOP, LOC_MISTHALL] locations: [LOC_PITTOP, LOC_MISTHALL]
immovable: true immovable: true
longs: descriptions:
- 'Rough stone steps lead down the pit.' - 'Rough stone steps lead down the pit.'
- 'Rough stone steps lead up the dome.' - 'Rough stone steps lead up the dome.'
- BIRD: - BIRD:
words: ['bird'] words: ['bird']
inventory: 'Little bird in cage' inventory: 'Little bird in cage'
locations: LOC_BIRD locations: LOC_BIRD
longs: descriptions:
- [BIRD_UNCAGED, 'A cheerful little bird is sitting here singing.'] - [BIRD_UNCAGED, 'A cheerful little bird is sitting here singing.']
- [BIRD_CAGED, 'There is a little bird in the cage.'] - [BIRD_CAGED, 'There is a little bird in the cage.']
- [BIRD_FOREST_UNCAGED, 'A cheerful little bird is sitting here singing.'] - [BIRD_FOREST_UNCAGED, 'A cheerful little bird is sitting here singing.']
@ -3075,21 +3087,21 @@ objects: !!omap
inventory: '*rusty door' inventory: '*rusty door'
locations: LOC_IMMENSE locations: LOC_IMMENSE
immovable: true immovable: true
longs: descriptions:
- 'The way north is barred by a massive, rusty, iron door.' - 'The way north is barred by a massive, rusty, iron door.'
- 'The way north leads through a massive, rusty, iron door.' - 'The way north leads through a massive, rusty, iron door.'
- PILLOW: - PILLOW:
words: ['pillo', 'velve'] words: ['pillo', 'velve']
inventory: 'Velvet pillow' inventory: 'Velvet pillow'
locations: LOC_SOFTROOM locations: LOC_SOFTROOM
longs: descriptions:
- 'A small velvet pillow lies on the floor.' - 'A small velvet pillow lies on the floor.'
- SNAKE: - SNAKE:
words: ['snake'] words: ['snake']
inventory: '*snake' inventory: '*snake'
locations: LOC_KINGHALL locations: LOC_KINGHALL
immovable: true immovable: true
longs: descriptions:
- [SNAKE_BLOCKS, 'A huge green fierce snake bars the way!'] - [SNAKE_BLOCKS, 'A huge green fierce snake bars the way!']
- [SNAKE_CHASED, ''] # chased away - [SNAKE_CHASED, ''] # chased away
sounds: sounds:
@ -3099,7 +3111,7 @@ objects: !!omap
inventory: '*fissure' inventory: '*fissure'
locations: [LOC_EASTBANK, LOC_WESTBANK] locations: [LOC_EASTBANK, LOC_WESTBANK]
immovable: true immovable: true
longs: descriptions:
- [UNBRIDGED, ''] - [UNBRIDGED, '']
- [BRIDGED, 'A crystal bridge now spans the fissure.'] - [BRIDGED, 'A crystal bridge now spans the fissure.']
- [VANISHED, 'The crystal bridge has vanished!'] - [VANISHED, 'The crystal bridge has vanished!']
@ -3108,7 +3120,7 @@ objects: !!omap
inventory: '*stone tablet' inventory: '*stone tablet'
locations: LOC_DARKROOM locations: LOC_DARKROOM
immovable: true immovable: true
longs: descriptions:
- 'A massive stone tablet imbedded in the wall reads:\n"Congratulations on bringing light into the dark-room!"' - 'A massive stone tablet imbedded in the wall reads:\n"Congratulations on bringing light into the dark-room!"'
texts: texts:
- '"Congratulations on bringing light into the dark-room!"' - '"Congratulations on bringing light into the dark-room!"'
@ -3116,7 +3128,7 @@ objects: !!omap
words: ['clam'] words: ['clam']
inventory: 'Giant clam >GRUNT!<' inventory: 'Giant clam >GRUNT!<'
locations: LOC_SHELLROOM locations: LOC_SHELLROOM
longs: descriptions:
- 'There is an enormous clam here with its shell tightly closed.' - 'There is an enormous clam here with its shell tightly closed.'
sounds: sounds:
- 'The clam is as tight-mouthed as a, er, clam.' - 'The clam is as tight-mouthed as a, er, clam.'
@ -3124,7 +3136,7 @@ objects: !!omap
words: ['oyste'] words: ['oyste']
inventory: 'Giant oyster >GROAN!<' inventory: 'Giant oyster >GROAN!<'
locations: LOC_NOWHERE locations: LOC_NOWHERE
longs: descriptions:
- 'There is an enormous oyster here with its shell tightly closed.' - 'There is an enormous oyster here with its shell tightly closed.'
- 'Interesting. There seems to be something written on the underside of\nthe oyster.' - 'Interesting. There seems to be something written on the underside of\nthe oyster.'
sounds: sounds:
@ -3134,7 +3146,7 @@ objects: !!omap
words: ['issue', 'spelu', '"spel'] words: ['issue', 'spelu', '"spel']
inventory: '"Spelunker Today"' inventory: '"Spelunker Today"'
locations: LOC_ANTEROOM locations: LOC_ANTEROOM
longs: descriptions:
- 'There are a few recent issues of "Spelunker Today" magazine here.' - 'There are a few recent issues of "Spelunker Today" magazine here.'
texts: texts:
- 'I''m afraid the magazine is written in dwarvish. But pencilled on one\ncover you see, "Please leave the magazines at the construction site."' - 'I''m afraid the magazine is written in dwarvish. But pencilled on one\ncover you see, "Please leave the magazines at the construction site."'
@ -3143,23 +3155,23 @@ objects: !!omap
inventory: !!null inventory: !!null
locations: LOC_NOWHERE locations: LOC_NOWHERE
immovable: true immovable: true
longs: !!null descriptions: !!null
- KNIFE: - KNIFE:
words: ['knife', 'knive'] words: ['knife', 'knive']
inventory: !!null inventory: !!null
locations: LOC_NOWHERE locations: LOC_NOWHERE
longs: !!null descriptions: !!null
- FOOD: - FOOD:
words: ['food', 'ratio'] words: ['food', 'ratio']
inventory: 'Tasty food' inventory: 'Tasty food'
locations: LOC_BUILDING locations: LOC_BUILDING
longs: descriptions:
- 'There is food here.' - 'There is food here.'
- BOTTLE: - BOTTLE:
words: ['bottl', 'jar'] words: ['bottl', 'jar']
inventory: 'Small bottle' inventory: 'Small bottle'
locations: LOC_BUILDING locations: LOC_BUILDING
longs: descriptions:
- [WATER_BOTTLE, 'There is a bottle of water here.'] - [WATER_BOTTLE, 'There is a bottle of water here.']
- [EMPTY_BOTTLE, 'There is an empty bottle here.'] - [EMPTY_BOTTLE, 'There is an empty bottle here.']
- [OIL_BOTTLE, 'There is a bottle of oil here.'] - [OIL_BOTTLE, 'There is a bottle of oil here.']
@ -3167,24 +3179,24 @@ objects: !!omap
words: ['water', 'h2o'] words: ['water', 'h2o']
inventory: 'Water in the bottle' inventory: 'Water in the bottle'
locations: LOC_NOWHERE locations: LOC_NOWHERE
longs: !!null descriptions: !!null
- OIL: - OIL:
words: ['oil'] words: ['oil']
inventory: 'Oil in the bottle' inventory: 'Oil in the bottle'
locations: LOC_NOWHERE locations: LOC_NOWHERE
longs: !!null descriptions: !!null
- MIRROR: - MIRROR:
words: ['mirro'] words: ['mirro']
inventory: '*mirror' inventory: '*mirror'
locations: LOC_MIRRORCANYON locations: LOC_MIRRORCANYON
immovable: true immovable: true
longs: !!null descriptions: !!null
- PLANT: - PLANT:
words: ['plant', 'beans'] words: ['plant', 'beans']
inventory: '*plant' inventory: '*plant'
locations: LOC_WESTPIT locations: LOC_WESTPIT
immovable: true immovable: true
longs: descriptions:
- 'There is a tiny little plant in the pit, murmuring "water, water, ..."' - 'There is a tiny little plant in the pit, murmuring "water, water, ..."'
- 'There is a 12-foot-tall beanstalk stretching up out of the pit,\nbellowing "WATER!! WATER!!"' - 'There is a 12-foot-tall beanstalk stretching up out of the pit,\nbellowing "WATER!! WATER!!"'
- 'There is a gigantic beanstalk stretching all the way up to the hole.' - 'There is a gigantic beanstalk stretching all the way up to the hole.'
@ -3200,7 +3212,7 @@ objects: !!omap
inventory: '*phony plant' # seen in Twopit Room only when tall enough inventory: '*phony plant' # seen in Twopit Room only when tall enough
locations: [LOC_WESTEND, LOC_EASTEND] locations: [LOC_WESTEND, LOC_EASTEND]
immovable: true immovable: true
longs: descriptions:
- '' - ''
- 'The top of a 12-foot-tall beanstalk is poking out of the west pit.' - 'The top of a 12-foot-tall beanstalk is poking out of the west pit.'
- 'There is a huge beanstalk growing out of the west pit up to the hole.' - 'There is a huge beanstalk growing out of the west pit up to the hole.'
@ -3209,20 +3221,20 @@ objects: !!omap
inventory: '*stalactite' inventory: '*stalactite'
locations: LOC_TOPSTALACTITE locations: LOC_TOPSTALACTITE
immovable: true immovable: true
longs: descriptions:
- '' - ''
- OBJ_27: - OBJ_27:
words: ['shado', 'figur', 'windo'] words: ['shado', 'figur', 'windo']
inventory: '*shadowy figure and/or window' inventory: '*shadowy figure and/or window'
locations: [LOC_WINDOW1, LOC_WINDOW2] locations: [LOC_WINDOW1, LOC_WINDOW2]
immovable: true immovable: true
longs: descriptions:
- 'The shadowy figure seems to be trying to attract your attention.' - 'The shadowy figure seems to be trying to attract your attention.'
- AXE: - AXE:
words: ['axe'] words: ['axe']
inventory: 'Dwarf''s axe' inventory: 'Dwarf''s axe'
locations: LOC_NOWHERE locations: LOC_NOWHERE
longs: descriptions:
- 'There is a little axe here.' - 'There is a little axe here.'
- 'There is a little axe lying beside the bear.' - 'There is a little axe lying beside the bear.'
- OBJ_29: - OBJ_29:
@ -3230,19 +3242,19 @@ objects: !!omap
inventory: '*cave drawings' inventory: '*cave drawings'
locations: LOC_ORIENTAL locations: LOC_ORIENTAL
immovable: true immovable: true
longs: !!null descriptions: !!null
- OBJ_30: - OBJ_30:
words: ['pirat', 'genie', 'djinn'] words: ['pirat', 'genie', 'djinn']
inventory: '*pirate/genie' inventory: '*pirate/genie'
locations: LOC_NOWHERE locations: LOC_NOWHERE
immovable: true immovable: true
longs: !!null # never present descriptions: !!null # never present
- DRAGON: - DRAGON:
words: ['drago'] words: ['drago']
inventory: '*dragon' inventory: '*dragon'
locations: [LOC_SECRET4, LOC_SECRET6] locations: [LOC_SECRET4, LOC_SECRET6]
immovable: true immovable: true
longs: descriptions:
- [DRAGON_BLOCKS, 'A huge green fierce dragon bars the way!'] - [DRAGON_BLOCKS, 'A huge green fierce dragon bars the way!']
- 'The blood-specked body of a huge green dead dragon lies to one side.' - 'The blood-specked body of a huge green dead dragon lies to one side.'
- 'The body of a huge green dead dragon is lying off to one side.' - 'The body of a huge green dead dragon is lying off to one side.'
@ -3256,7 +3268,7 @@ objects: !!omap
inventory: '*chasm' inventory: '*chasm'
locations: [LOC_SWCHASM, LOC_NECHASM] locations: [LOC_SWCHASM, LOC_NECHASM]
immovable: true immovable: true
longs: descriptions:
- [TROLL_BRIDGE, 'A rickety wooden bridge extends across the chasm, vanishing into the\nmist. A notice posted on the bridge reads, "Stop! Pay troll!"'] - [TROLL_BRIDGE, 'A rickety wooden bridge extends across the chasm, vanishing into the\nmist. A notice posted on the bridge reads, "Stop! Pay troll!"']
- [BRIDGE_WRECKED, 'The wreckage of a bridge (and a dead bear) can be seen at the bottom\nof the chasm.'] - [BRIDGE_WRECKED, 'The wreckage of a bridge (and a dead bear) can be seen at the bottom\nof the chasm.']
- TROLL: - TROLL:
@ -3264,7 +3276,7 @@ objects: !!omap
inventory: '*troll' inventory: '*troll'
locations: [LOC_SWCHASM, LOC_NECHASM] locations: [LOC_SWCHASM, LOC_NECHASM]
immovable: true immovable: true
longs: descriptions:
- 'A burly troll stands by the bridge and insists you throw him a\ntreasure before you may cross.' - 'A burly troll stands by the bridge and insists you throw him a\ntreasure before you may cross.'
- 'The troll steps out from beneath the bridge and blocks your way.' - 'The troll steps out from beneath the bridge and blocks your way.'
- '' # chased away - '' # chased away
@ -3275,14 +3287,14 @@ objects: !!omap
inventory: '*phony troll' inventory: '*phony troll'
locations: [LOC_NOWHERE, LOC_NOWHERE] locations: [LOC_NOWHERE, LOC_NOWHERE]
immovable: true immovable: true
longs: descriptions:
- 'The troll is nowhere to be seen.' - 'The troll is nowhere to be seen.'
- BEAR: - BEAR:
words: ['bear'] words: ['bear']
inventory: !!null # bear uses rtext 141 inventory: !!null # bear uses rtext 141
locations: LOC_BARRENROOM locations: LOC_BARRENROOM
immovable: true immovable: true
longs: descriptions:
- 'There is a ferocious cave bear eying you from the far end of the room!' - 'There is a ferocious cave bear eying you from the far end of the room!'
- 'There is a gentle cave bear sitting placidly in one corner.' - 'There is a gentle cave bear sitting placidly in one corner.'
- 'There is a contented-looking bear wandering about nearby.' - 'There is a contented-looking bear wandering about nearby.'
@ -3292,7 +3304,7 @@ objects: !!omap
inventory: '*message in second maze' inventory: '*message in second maze'
locations: LOC_NOWHERE locations: LOC_NOWHERE
immovable: true immovable: true
longs: descriptions:
- 'There is a message scrawled in the dust in a flowery script, reading:\n"This is not the maze where the pirate leaves his treasure chest."' - 'There is a message scrawled in the dust in a flowery script, reading:\n"This is not the maze where the pirate leaves his treasure chest."'
texts: texts:
- '"This is not the maze where the pirate leaves his treasure chest."' - '"This is not the maze where the pirate leaves his treasure chest."'
@ -3301,13 +3313,13 @@ objects: !!omap
inventory: '*volcano and/or geyser' inventory: '*volcano and/or geyser'
locations: LOC_BREATHTAKING locations: LOC_BREATHTAKING
immovable: true immovable: true
longs: !!null descriptions: !!null
- VEND: - VEND:
words: ['machi', 'vendi'] words: ['machi', 'vendi']
inventory: '*vending machine' inventory: '*vending machine'
locations: LOC_DEADEND13 locations: LOC_DEADEND13
immovable: true immovable: true
longs: descriptions:
- [VEND_BLOCKS, 'There is a massive and somewhat battered vending machine here. The\ninstructions on it read: "Drop coins here to receive fresh batteries."'] - [VEND_BLOCKS, 'There is a massive and somewhat battered vending machine here. The\ninstructions on it read: "Drop coins here to receive fresh batteries."']
- [VEND_UNBLOCKS, 'There is a massive vending machine here, swung back to reveal a\nsouthward passage.'] - [VEND_UNBLOCKS, 'There is a massive vending machine here, swung back to reveal a\nsouthward passage.']
texts: texts:
@ -3317,7 +3329,7 @@ objects: !!omap
words: ['batte'] words: ['batte']
inventory: 'Batteries' inventory: 'Batteries'
locations: LOC_NOWHERE locations: LOC_NOWHERE
longs: descriptions:
- [FRESH_BATTERIES, 'There are fresh batteries here.'] - [FRESH_BATTERIES, 'There are fresh batteries here.']
- [DEAD_BATTERIES, 'Some worn-out batteries have been discarded nearby.'] - [DEAD_BATTERIES, 'Some worn-out batteries have been discarded nearby.']
- OBJ_40: - OBJ_40:
@ -3325,13 +3337,13 @@ objects: !!omap
inventory: '*carpet and/or moss and/or curtains' inventory: '*carpet and/or moss and/or curtains'
locations: LOC_SOFTROOM locations: LOC_SOFTROOM
immovable: true immovable: true
longs: !!null descriptions: !!null
- OGRE: - OGRE:
words: ['ogre'] words: ['ogre']
inventory: '*ogre' inventory: '*ogre'
locations: LOC_LARGE locations: LOC_LARGE
immovable: true immovable: true
longs: descriptions:
- 'A formidable ogre bars the northern exit.' - 'A formidable ogre bars the northern exit.'
sounds: sounds:
- 'The ogre is apparently the strong, silent type.' - 'The ogre is apparently the strong, silent type.'
@ -3340,7 +3352,7 @@ objects: !!omap
inventory: '*urn' inventory: '*urn'
locations: LOC_CLIFF locations: LOC_CLIFF
immovable: true immovable: true
longs: descriptions:
- 'A small urn is embedded in the rock.' - 'A small urn is embedded in the rock.'
- 'A small urn full of oil is embedded in the rock.' - 'A small urn full of oil is embedded in the rock.'
- 'A small oil flame extrudes from an urn embedded in the rock.' - 'A small oil flame extrudes from an urn embedded in the rock.'
@ -3349,7 +3361,7 @@ objects: !!omap
inventory: '*cavity' inventory: '*cavity'
locations: LOC_NOWHERE locations: LOC_NOWHERE
immovable: true immovable: true
longs: descriptions:
- '' # something in it - '' # something in it
- 'There is a small urn-shaped cavity in the rock.' - 'There is a small urn-shaped cavity in the rock.'
- BLOOD: - BLOOD:
@ -3357,14 +3369,14 @@ objects: !!omap
inventory: '*blood' inventory: '*blood'
locations: LOC_NOWHERE locations: LOC_NOWHERE
immovable: true immovable: true
longs: descriptions:
- '' # described with dragon - '' # described with dragon
- RESER: - RESER:
words: ['reser'] words: ['reser']
inventory: '*reservoir' inventory: '*reservoir'
locations: [LOC_RESERVOIR, LOC_RESNORTH] locations: [LOC_RESERVOIR, LOC_RESNORTH]
immovable: true immovable: true
longs: descriptions:
- '' - ''
- [WATERS_PARTED, 'The waters have parted to form a narrow path across the reservoir.'] - [WATERS_PARTED, 'The waters have parted to form a narrow path across the reservoir.']
- 'The waters crash together again.' - 'The waters crash together again.'
@ -3372,14 +3384,14 @@ objects: !!omap
words: ['appen', 'lepor'] words: ['appen', 'lepor']
inventory: 'Leporine appendage' inventory: 'Leporine appendage'
locations: LOC_FOREST22 locations: LOC_FOREST22
longs: descriptions:
- 'Your keen eye spots a severed leporine appendage lying on the ground.' - 'Your keen eye spots a severed leporine appendage lying on the ground.'
- OBJ_47: - OBJ_47:
words: ['mud'] words: ['mud']
inventory: '*mud' inventory: '*mud'
locations: LOC_DEBRIS locations: LOC_DEBRIS
immovable: true immovable: true
longs: descriptions:
- '' - ''
texts: texts:
- '"MAGIC WORD XYZZY"' - '"MAGIC WORD XYZZY"'
@ -3388,7 +3400,7 @@ objects: !!omap
inventory: '*note' inventory: '*note'
locations: LOC_NUGGET locations: LOC_NUGGET
immovable: true immovable: true
longs: descriptions:
- '' - ''
texts: texts:
- '"You won''t get it up the steps"' - '"You won''t get it up the steps"'
@ -3397,7 +3409,7 @@ objects: !!omap
inventory: '*sign' inventory: '*sign'
locations: LOC_ANTEROOM locations: LOC_ANTEROOM
immovable: true immovable: true
longs: descriptions:
- [INGAME_SIGN, ''] - [INGAME_SIGN, '']
- [ENDGAME_SIGN, ''] - [ENDGAME_SIGN, '']
texts: texts:
@ -3408,49 +3420,49 @@ objects: !!omap
inventory: 'Large gold nugget' inventory: 'Large gold nugget'
locations: LOC_NUGGET locations: LOC_NUGGET
treasure: true treasure: true
longs: descriptions:
- 'There is a large sparkling nugget of gold here!' - 'There is a large sparkling nugget of gold here!'
- OBJ_51: - OBJ_51:
words: ['diamo'] words: ['diamo']
inventory: 'Several diamonds' inventory: 'Several diamonds'
locations: LOC_WESTBANK locations: LOC_WESTBANK
treasure: true treasure: true
longs: descriptions:
- 'There are diamonds here!' - 'There are diamonds here!'
- OBJ_52: - OBJ_52:
words: ['silve', 'bars'] words: ['silve', 'bars']
inventory: 'Bars of silver' inventory: 'Bars of silver'
locations: LOC_FLOORHOLE locations: LOC_FLOORHOLE
treasure: true treasure: true
longs: descriptions:
- 'There are bars of silver here!' - 'There are bars of silver here!'
- OBJ_53: - OBJ_53:
words: ['jewel'] words: ['jewel']
inventory: 'Precious jewelry' inventory: 'Precious jewelry'
locations: LOC_SOUTHSIDE locations: LOC_SOUTHSIDE
treasure: true treasure: true
longs: descriptions:
- 'There is precious jewelry here!' - 'There is precious jewelry here!'
- COINS: - COINS:
words: ['coins'] words: ['coins']
inventory: 'Rare coins' inventory: 'Rare coins'
locations: LOC_WESTSIDE locations: LOC_WESTSIDE
treasure: true treasure: true
longs: descriptions:
- 'There are many coins here!' - 'There are many coins here!'
- CHEST: - CHEST:
words: ['chest', 'box', 'treas'] words: ['chest', 'box', 'treas']
inventory: 'Treasure chest' inventory: 'Treasure chest'
locations: LOC_NOWHERE locations: LOC_NOWHERE
treasure: true treasure: true
longs: descriptions:
- 'The pirate''s treasure chest is here!' - 'The pirate''s treasure chest is here!'
- EGGS: - EGGS:
words: ['eggs', 'egg', 'nest'] words: ['eggs', 'egg', 'nest']
inventory: 'Golden eggs' inventory: 'Golden eggs'
locations: LOC_GIANTROOM locations: LOC_GIANTROOM
treasure: true treasure: true
longs: descriptions:
- 'There is a large nest here, full of golden eggs!' - 'There is a large nest here, full of golden eggs!'
- 'The nest of golden eggs has vanished!' - 'The nest of golden eggs has vanished!'
- 'Done!' - 'Done!'
@ -3459,14 +3471,14 @@ objects: !!omap
inventory: 'Jeweled trident' inventory: 'Jeweled trident'
locations: LOC_WATERFALL locations: LOC_WATERFALL
treasure: true treasure: true
longs: descriptions:
- 'There is a jewel-encrusted trident here!' - 'There is a jewel-encrusted trident here!'
- VASE: - VASE:
words: ['vase', 'ming', 'shard', 'potte'] words: ['vase', 'ming', 'shard', 'potte']
inventory: 'Ming vase' inventory: 'Ming vase'
locations: LOC_ORIENTAL locations: LOC_ORIENTAL
treasure: true treasure: true
longs: descriptions:
- [VASE_WHOLE, 'There is a delicate, precious, ming vase here!'] - [VASE_WHOLE, 'There is a delicate, precious, ming vase here!']
- [VASE_RESTING, 'The vase is now resting, delicately, on a velvet pillow.'] - [VASE_RESTING, 'The vase is now resting, delicately, on a velvet pillow.']
- [VASE_BROKEN, 'The floor is littered with worthless shards of pottery.'] - [VASE_BROKEN, 'The floor is littered with worthless shards of pottery.']
@ -3476,7 +3488,7 @@ objects: !!omap
inventory: 'Egg-sized emerald' inventory: 'Egg-sized emerald'
locations: LOC_PLOVER locations: LOC_PLOVER
treasure: true treasure: true
longs: descriptions:
- 'There is an emerald here the size of a plover''s egg!' - 'There is an emerald here the size of a plover''s egg!'
- 'There is an emerald resting in a small cavity in the rock!' - 'There is an emerald resting in a small cavity in the rock!'
- PYRAMID: - PYRAMID:
@ -3484,14 +3496,14 @@ objects: !!omap
inventory: 'Platinum pyramid' inventory: 'Platinum pyramid'
locations: LOC_DARKROOM locations: LOC_DARKROOM
treasure: true treasure: true
longs: descriptions:
- 'There is a platinum pyramid here, 8 inches on a side!' - 'There is a platinum pyramid here, 8 inches on a side!'
- PEARL: - PEARL:
words: ['pearl'] words: ['pearl']
inventory: 'Glistening pearl' inventory: 'Glistening pearl'
locations: LOC_NOWHERE locations: LOC_NOWHERE
treasure: true treasure: true
longs: descriptions:
- 'Off to one side lies a glistening pearl!' - 'Off to one side lies a glistening pearl!'
- RUG: - RUG:
words: ['rug', 'persi'] words: ['rug', 'persi']
@ -3499,7 +3511,7 @@ objects: !!omap
locations: [LOC_SECRET4, LOC_SECRET6] locations: [LOC_SECRET4, LOC_SECRET6]
immovable: true immovable: true
treasure: true treasure: true
longs: descriptions:
- 'There is a persian rug spread out on the floor!' - 'There is a persian rug spread out on the floor!'
- 'The dragon is sprawled out on a persian rug!!' - 'The dragon is sprawled out on a persian rug!!'
- 'There is a persian rug here, hovering in mid-air!' - 'There is a persian rug here, hovering in mid-air!'
@ -3508,7 +3520,7 @@ objects: !!omap
inventory: 'Rare spices' inventory: 'Rare spices'
locations: LOC_BOULDERS2 locations: LOC_BOULDERS2
treasure: true treasure: true
longs: descriptions:
- 'There are rare spices here!' - 'There are rare spices here!'
- CHAIN: - CHAIN:
words: ['chain'] words: ['chain']
@ -3516,7 +3528,7 @@ objects: !!omap
locations: LOC_BARRENROOM locations: LOC_BARRENROOM
immovable: true immovable: true
treasure: true treasure: true
longs: descriptions:
- 'There is a golden chain lying in a heap on the floor!' - 'There is a golden chain lying in a heap on the floor!'
- 'The bear is locked to the wall with a golden chain!' - 'The bear is locked to the wall with a golden chain!'
- 'There is a golden chain locked to the wall!' - 'There is a golden chain locked to the wall!'
@ -3525,7 +3537,7 @@ objects: !!omap
inventory: 'Giant ruby' inventory: 'Giant ruby'
locations: LOC_STOREROOM locations: LOC_STOREROOM
treasure: true treasure: true
longs: descriptions:
- 'There is an enormous ruby here!' - 'There is an enormous ruby here!'
- 'There is a ruby resting in a small cavity in the rock!' - 'There is a ruby resting in a small cavity in the rock!'
- JADE: - JADE:
@ -3533,14 +3545,14 @@ objects: !!omap
inventory: 'Jade necklace' inventory: 'Jade necklace'
locations: LOC_NOWHERE locations: LOC_NOWHERE
treasure: true treasure: true
longs: descriptions:
- 'A precious jade necklace has been dropped here!' - 'A precious jade necklace has been dropped here!'
- AMBER: - AMBER:
words: ['amber', 'gemst'] words: ['amber', 'gemst']
inventory: 'Amber gemstone' inventory: 'Amber gemstone'
locations: LOC_NOWHERE locations: LOC_NOWHERE
treasure: true treasure: true
longs: descriptions:
- 'There is a rare amber gemstone here!' - 'There is a rare amber gemstone here!'
- 'There is an amber gemstone resting in a small cavity in the rock!' - 'There is an amber gemstone resting in a small cavity in the rock!'
- SAPPH: - SAPPH:
@ -3548,7 +3560,7 @@ objects: !!omap
inventory: 'Star sapphire' inventory: 'Star sapphire'
locations: LOC_LEDGE locations: LOC_LEDGE
treasure: true treasure: true
longs: descriptions:
- 'A brilliant blue star sapphire is here!' - 'A brilliant blue star sapphire is here!'
- 'There is a star sapphire resting in a small cavity in the rock!' - 'There is a star sapphire resting in a small cavity in the rock!'
- OBJ_69: - OBJ_69:
@ -3556,7 +3568,7 @@ objects: !!omap
inventory: 'Ebony statuette' inventory: 'Ebony statuette'
locations: LOC_REACHDEAD locations: LOC_REACHDEAD
treasure: true treasure: true
longs: descriptions:
- 'There is a richly-carved ebony statuette here!' - 'There is a richly-carved ebony statuette here!'
obituaries: obituaries:

5
misc.c
View file

@ -166,7 +166,7 @@ void pspeak(vocab_t msg, enum speaktype mode, int skip, ...)
vspeak(objects[msg].inventory, ap); vspeak(objects[msg].inventory, ap);
break; break;
case look: case look:
vspeak(objects[msg].longs[skip], ap); vspeak(objects[msg].descriptions[skip], ap);
break; break;
case hear: case hear:
vspeak(objects[msg].sounds[skip], ap); vspeak(objects[msg].sounds[skip], ap);
@ -174,6 +174,9 @@ void pspeak(vocab_t msg, enum speaktype mode, int skip, ...)
case study: case study:
vspeak(objects[msg].texts[skip], ap); vspeak(objects[msg].texts[skip], ap);
break; break;
case change:
vspeak(objects[msg].changes[skip], ap);
break;
} }
va_end(ap); va_end(ap);
} }

View file

@ -88,9 +88,10 @@ typedef struct {{
const char* inventory; const char* inventory;
int plac, fixd; int plac, fixd;
bool is_treasure; bool is_treasure;
const char** longs; const char** descriptions;
const char** sounds; const char** sounds;
const char** texts; const char** texts;
const char** changes;
}} object_t; }} object_t;
typedef struct {{ typedef struct {{
@ -341,13 +342,16 @@ def get_objects(obj):
.plac = {}, .plac = {},
.fixd = {}, .fixd = {},
.is_treasure = {}, .is_treasure = {},
.longs = (const char* []) {{ .descriptions = (const char* []) {{
{} {}
}}, }},
.sounds = (const char* []) {{ .sounds = (const char* []) {{
{} {}
}}, }},
.texts = (const char* []) {{ .texts = (const char* []) {{
{}
}},
.changes = (const char* []) {{
{} {}
}}, }},
}}, }},
@ -356,17 +360,17 @@ def get_objects(obj):
for (i, item) in enumerate(obj): for (i, item) in enumerate(obj):
attr = item[1] attr = item[1]
i_msg = make_c_string(attr["inventory"]) i_msg = make_c_string(attr["inventory"])
longs_str = "" descriptions_str = ""
if attr["longs"] == None: if attr["descriptions"] == None:
longs_str = " " * 12 + "NULL," descriptions_str = " " * 12 + "NULL,"
else: else:
labels = [] labels = []
for l_msg in attr["longs"]: for l_msg in attr["descriptions"]:
if not isinstance(l_msg, str): if not isinstance(l_msg, str):
labels.append(l_msg) labels.append(l_msg)
l_msg = l_msg[1] l_msg = l_msg[1]
longs_str += " " * 12 + make_c_string(l_msg) + ",\n" descriptions_str += " " * 12 + make_c_string(l_msg) + ",\n"
longs_str = longs_str[:-1] # trim trailing newline descriptions_str = descriptions_str[:-1] # trim trailing newline
if labels: if labels:
global statedefines global statedefines
statedefines += "/* States for %s */\n" % item[0] statedefines += "/* States for %s */\n" % item[0]
@ -389,6 +393,13 @@ def get_objects(obj):
for l_msg in attr["texts"]: for l_msg in attr["texts"]:
texts_str += " " * 12 + make_c_string(l_msg) + ",\n" texts_str += " " * 12 + make_c_string(l_msg) + ",\n"
texts_str = texts_str[:-1] # trim trailing newline texts_str = texts_str[:-1] # trim trailing newline
changes_str = ""
if attr.get("changes") == None:
changes_str = " " * 12 + "NULL,"
else:
for l_msg in attr["changes"]:
changes_str += " " * 12 + make_c_string(l_msg) + ",\n"
changes_str = changes_str[:-1] # trim trailing newline
locs = attr.get("locations", ["LOC_NOWHERE", "LOC_NOWHERE"]) locs = attr.get("locations", ["LOC_NOWHERE", "LOC_NOWHERE"])
immovable = attr.get("immovable", False) immovable = attr.get("immovable", False)
try: try:
@ -400,7 +411,7 @@ def get_objects(obj):
sys.stderr.write("dungeon: unknown object location in %s\n" % locs) sys.stderr.write("dungeon: unknown object location in %s\n" % locs)
sys.exit(1) sys.exit(1)
treasure = "true" if attr.get("treasure") else "false" treasure = "true" if attr.get("treasure") else "false"
obj_str += template.format(i, i_msg, locs[0], locs[1], treasure, longs_str, sounds_str, texts_str) obj_str += template.format(i, i_msg, locs[0], locs[1], treasure, descriptions_str, sounds_str, texts_str, changes_str)
obj_str = obj_str[:-1] # trim trailing newline obj_str = obj_str[:-1] # trim trailing newline
return obj_str return obj_str
@ -571,7 +582,7 @@ def buildtravel(locs, objs, voc):
if type(cond[2]) == int: if type(cond[2]) == int:
state = cond[2] state = cond[2]
else: else:
for (i, stateclause) in enumerate(objs[obj][1]["longs"]): for (i, stateclause) in enumerate(objs[obj][1]["descriptions"]):
if type(stateclause) == list: if type(stateclause) == list:
if stateclause[0] == cond[2]: if stateclause[0] == cond[2]:
state = i state = i