Fully subsume section 7 into YAML.

This commit is contained in:
Eric S. Raymond 2017-06-24 20:05:14 -04:00
parent 39eed7d678
commit 8a6e6aae7d
6 changed files with 156 additions and 49 deletions

View file

@ -86,14 +86,14 @@ static int attack(FILE *input, struct command_t *command)
pspeak(DRAGON, look, 3); pspeak(DRAGON, look, 3);
game.prop[DRAGON] = 1; game.prop[DRAGON] = 1;
game.prop[RUG] = 0; game.prop[RUG] = 0;
int k = (PLAC[DRAGON] + FIXD[DRAGON]) / 2; int k = (object_descriptions[DRAGON].plac + object_descriptions[DRAGON].fixd) / 2;
MOVE(DRAGON + NOBJECTS, -1); MOVE(DRAGON + NOBJECTS, -1);
MOVE(RUG + NOBJECTS, 0); MOVE(RUG + NOBJECTS, 0);
MOVE(DRAGON, k); MOVE(DRAGON, k);
MOVE(RUG, k); MOVE(RUG, k);
DROP(BLOOD, k); DROP(BLOOD, k);
for (obj = 1; obj <= NOBJECTS; obj++) { for (obj = 1; obj <= NOBJECTS; obj++) {
if (game.place[obj] == PLAC[DRAGON] || game.place[obj] == FIXD[DRAGON]) if (game.place[obj] == object_descriptions[DRAGON].plac || game.place[obj] == object_descriptions[DRAGON].fixd)
MOVE(obj, k); MOVE(obj, k);
} }
game.loc = k; game.loc = k;
@ -122,7 +122,7 @@ static int bigwords(token_t foo)
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
game.foobar = 0; game.foobar = 0;
if (game.place[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && game.loc == PLAC[EGGS])) { if (game.place[EGGS] == object_descriptions[EGGS].plac || (TOTING(EGGS) && game.loc == object_descriptions[EGGS].plac)) {
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} else { } else {
@ -132,8 +132,8 @@ static int bigwords(token_t foo)
game.prop[TROLL] = 1; game.prop[TROLL] = 1;
k = 2; k = 2;
if (HERE(EGGS))k = 1; if (HERE(EGGS))k = 1;
if (game.loc == PLAC[EGGS])k = 0; if (game.loc == object_descriptions[EGGS].plac)k = 0;
MOVE(EGGS, PLAC[EGGS]); MOVE(EGGS, object_descriptions[EGGS].plac);
pspeak(EGGS, look, k); pspeak(EGGS, look, k);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
@ -305,7 +305,7 @@ static int chain(token_t verb)
} else { } else {
spk = CHAIN_LOCKED; spk = CHAIN_LOCKED;
if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED; if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED;
if (game.loc != PLAC[CHAIN])spk = NO_LOCKSITE; if (game.loc != object_descriptions[CHAIN].plac)spk = NO_LOCKSITE;
if (spk != CHAIN_LOCKED) { if (spk != CHAIN_LOCKED) {
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
@ -350,7 +350,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
if (spk != RUG_WIGGLES) { if (spk != RUG_WIGGLES) {
int k = 2 - game.prop[RUG]; int k = 2 - game.prop[RUG];
game.prop[RUG] = k; game.prop[RUG] = k;
if (k == 2) k = PLAC[SAPPH]; if (k == 2) k = object_descriptions[SAPPH].plac;
MOVE(RUG + NOBJECTS, k); MOVE(RUG + NOBJECTS, k);
} }
} }
@ -367,11 +367,11 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
rspeak(TROLL_SCAMPERS); rspeak(TROLL_SCAMPERS);
MOVE(TROLL, 0); MOVE(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0); MOVE(TROLL + NOBJECTS, 0);
MOVE(TROLL2, PLAC[TROLL]); MOVE(TROLL2, object_descriptions[TROLL].plac);
MOVE(TROLL2 + NOBJECTS, FIXD[TROLL]); MOVE(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
JUGGLE(CHASM); JUGGLE(CHASM);
game.prop[TROLL] = 2; game.prop[TROLL] = 2;
} else if (obj != VASE || game.loc == PLAC[PILLOW]) { } else if (obj != VASE || game.loc == object_descriptions[PILLOW].plac) {
rspeak(OK_MAN); rspeak(OK_MAN);
} else { } else {
game.prop[VASE] = 2; game.prop[VASE] = 2;
@ -905,8 +905,8 @@ static int throw (FILE *cmdin, struct command_t *command)
DROP(command->obj, 0); DROP(command->obj, 0);
MOVE(TROLL, 0); MOVE(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0); MOVE(TROLL + NOBJECTS, 0);
DROP(TROLL2, PLAC[TROLL]); DROP(TROLL2, object_descriptions[TROLL].plac);
DROP(TROLL2 + NOBJECTS, FIXD[TROLL]); DROP(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
JUGGLE(CHASM); JUGGLE(CHASM);
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;

View file

@ -64,7 +64,10 @@
# #
# objects: Each item contains a description for use in the inventory command # objects: Each item contains a description for use in the inventory command
# and one or more messages describing the object in different states. # and one or more messages describing the object in different states.
# There is also a boolean "treasure" attribute, deaykting to false. # There is also a boolean "treasure" attribute, defaulting to false.
# An pbject 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).
# An object may also be flagged immovable, meaning it cannot be carried.
# If a state message is a tuple then the first element is made the name # If a state message is a tuple then the first element is made the name
# of a #define viible to the code for the associayed state, numbered # of a #define viible to the code for the associayed state, numbered
# from zero upwards. If the inventory desription begins with "*" the # from zero upwards. If the inventory desription begins with "*" the
@ -74,9 +77,9 @@
# significant, they're used in succession as the player racks up # significant, they're used in succession as the player racks up
# deaths. # deaths.
# #
# These correspond to sections 1, 2, 5, 6, 9, 10, 11, 13, and 14 in the old # These correspond to sections 1, 2, 5, 6, 7, 9, 10, 11, 13, and 14 in
# adventure.text format. Sections 3, 4, 7, and 8 haven't moved yet. # the old adventure.text format. Sections 3, 4, and 8 haven't moved
# Section 12 was obsolete. # yet. Section 12 was obsolete.
# #
# Message strings may include certain special character sequences to # Message strings may include certain special character sequences to
# denote that the program must provide parameters to insert into a # denote that the program must provide parameters to insert into a
@ -1500,37 +1503,47 @@ object_descriptions: !!omap
longs: !!null longs: !!null
- OBJ_1: - OBJ_1:
inventory: 'Set of keys' inventory: 'Set of keys'
locations: LOC_BUILDING
longs: longs:
- 'There are some keys on the ground here.' - 'There are some keys on the ground here.'
- OBJ_2: - OBJ_2:
inventory: 'Brass lantern' inventory: 'Brass lantern'
locations: LOC_BUILDING
longs: longs:
- [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.']
- OBJ_3: - OBJ_3:
inventory: '*grate' inventory: '*grate'
locations: [LOC_GRATE, LOC_BELOWGRATE]
immovable: true
longs: longs:
- [GRATE_CLOSED, 'The grate is locked.'] - [GRATE_CLOSED, 'The grate is locked.']
- [GRATE_OPEN, 'The grate is open.'] - [GRATE_OPEN, 'The grate is open.']
- OBJ_4: - OBJ_4:
inventory: 'Wicker cage' inventory: 'Wicker cage'
locations: LOC_COBBLE
longs: longs:
- 'There is a small wicker cage discarded nearby.' - 'There is a small wicker cage discarded nearby.'
- OBJ_5: - OBJ_5:
inventory: 'Black rod' inventory: 'Black rod'
locations: LOC_DEBRIS
longs: longs:
- '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.'
- OBJ_6: - OBJ_6:
inventory: 'Black rod' inventory: 'Black rod'
locations: LOC_NOWHERE
longs: longs:
- '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.'
- OBJ_7: - OBJ_7:
inventory: '*steps' inventory: '*steps'
locations: [LOC_PITTOP, LOC_MISTHALL]
immovable: true
longs: longs:
- '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.'
- OBJ_8: - OBJ_8:
inventory: 'Little bird in cage' inventory: 'Little bird in cage'
locations: LOC_BIRD
longs: longs:
- [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.']
@ -1544,15 +1557,20 @@ object_descriptions: !!omap
- 'The bird is singing to you in gratitude for your having returned it to\nits home. In return, it informs you of a magic word which it thinks\nyou may find useful somewhere near the Hall of Mists. The magic word\nchanges frequently, but for now the bird believes it is "%s". You\nthank the bird for this information, and it flies off into the forest.' - 'The bird is singing to you in gratitude for your having returned it to\nits home. In return, it informs you of a magic word which it thinks\nyou may find useful somewhere near the Hall of Mists. The magic word\nchanges frequently, but for now the bird believes it is "%s". You\nthank the bird for this information, and it flies off into the forest.'
- OBJ_9: - OBJ_9:
inventory: '*rusty door' inventory: '*rusty door'
locations: LOC_IMMENSE
immovable: true
longs: longs:
- '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.'
- OBJ_10: - OBJ_10:
inventory: 'Velvet pillow' inventory: 'Velvet pillow'
locations: LOC_SOFTROOM
longs: longs:
- 'A small velvet pillow lies on the floor.' - 'A small velvet pillow lies on the floor.'
- OBJ_11: - OBJ_11:
inventory: '*snake' inventory: '*snake'
locations: LOC_KINGHALL
immovable: true
longs: longs:
- 'A huge green fierce snake bars the way!' - 'A huge green fierce snake bars the way!'
- '' # chased away - '' # chased away
@ -1560,24 +1578,30 @@ object_descriptions: !!omap
- 'The snake is hissing venomously.' - 'The snake is hissing venomously.'
- OBJ_12: - OBJ_12:
inventory: '*fissure' inventory: '*fissure'
locations: [LOC_EASTBANK, LOC_WESTBANK]
immovable: true
longs: longs:
- '' - ''
- 'A crystal bridge now spans the fissure.' - 'A crystal bridge now spans the fissure.'
- 'The crystal bridge has vanished!' - 'The crystal bridge has vanished!'
- OBJ_13: - OBJ_13:
inventory: '*stone tablet' inventory: '*stone tablet'
locations: LOC_DARKROOM
immovable: true
longs: longs:
- '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!"'
- OBJ_14: - OBJ_14:
inventory: 'Giant clam >GRUNT!<' inventory: 'Giant clam >GRUNT!<'
locations: LOC_SHELLROOM
longs: longs:
- '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.'
- OBJ_15: - OBJ_15:
inventory: 'Giant oyster >GROAN!<' inventory: 'Giant oyster >GROAN!<'
locations: LOC_NOWHERE
longs: longs:
- '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.'
@ -1586,37 +1610,49 @@ object_descriptions: !!omap
- 'It says the same thing it did before. Hm, maybe it''s a pun?' - 'It says the same thing it did before. Hm, maybe it''s a pun?'
- OBJ_16: - OBJ_16:
inventory: '"Spelunker Today"' inventory: '"Spelunker Today"'
locations: LOC_ANTEROOM
longs: longs:
- '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."'
- OBJ_17: - OBJ_17:
inventory: !!null inventory: !!null
locations: LOC_NOWHERE
immovable: true
longs: !!null longs: !!null
- OBJ_18: - OBJ_18:
inventory: !!null inventory: !!null
locations: LOC_NOWHERE
longs: !!null longs: !!null
- OBJ_19: - OBJ_19:
inventory: 'Tasty food' inventory: 'Tasty food'
locations: LOC_BUILDING
longs: longs:
- 'There is food here.' - 'There is food here.'
- OBJ_20: - OBJ_20:
inventory: 'Small bottle' inventory: 'Small bottle'
locations: LOC_BUILDING
longs: longs:
- [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.']
- OBJ_21: - OBJ_21:
inventory: 'Water in the bottle' inventory: 'Water in the bottle'
locations: LOC_NOWHERE
longs: !!null longs: !!null
- OBJ_22: - OBJ_22:
inventory: 'Oil in the bottle' inventory: 'Oil in the bottle'
locations: LOC_NOWHERE
longs: !!null longs: !!null
- OBJ_23: - OBJ_23:
inventory: '*mirror' inventory: '*mirror'
locations: LOC_MIRRORCANYON
immovable: true
longs: !!null longs: !!null
- OBJ_24: - OBJ_24:
inventory: '*plant' inventory: '*plant'
locations: LOC_WESTPIT
immovable: true
longs: longs:
- '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!!"'
@ -1630,31 +1666,44 @@ object_descriptions: !!omap
- 'The plant now maintains a contented silence.' - 'The plant now maintains a contented silence.'
- OBJ_25: - OBJ_25:
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]
immovable: true
longs: longs:
- '' - ''
- '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.'
- OBJ_26: - OBJ_26:
inventory: '*stalactite' inventory: '*stalactite'
locations: LOC_TOPSTALACTITE
immovable: true
longs: longs:
- '' - ''
- OBJ_27: - OBJ_27:
inventory: '*shadowy figure and/or window' inventory: '*shadowy figure and/or window'
locations: [LOC_WINDOW1, LOC_WINDOW2]
immovable: true
longs: longs:
- 'The shadowy figure seems to be trying to attract your attention.' - 'The shadowy figure seems to be trying to attract your attention.'
- OBJ_28: - OBJ_28:
inventory: 'Dwarf''s axe' inventory: 'Dwarf''s axe'
locations: LOC_NOWHERE
longs: longs:
- '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:
inventory: '*cave drawings' inventory: '*cave drawings'
locations: LOC_ORIENTAL
immovable: true
longs: !!null longs: !!null
- OBJ_30: - OBJ_30:
inventory: '*pirate/genie' inventory: '*pirate/genie'
locations: LOC_NOWHERE
immovable: true
longs: !!null # never present longs: !!null # never present
- OBJ_31: - OBJ_31:
inventory: '*dragon' inventory: '*dragon'
locations: [LOC_SECRET4, LOC_SECRET6]
immovable: true
longs: longs:
- 'A huge green fierce dragon bars the way!' - '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.'
@ -1666,11 +1715,15 @@ object_descriptions: !!omap
- 'The dragon is, not surprisingly, silent.' - 'The dragon is, not surprisingly, silent.'
- OBJ_32: - OBJ_32:
inventory: '*chasm' inventory: '*chasm'
locations: [LOC_SWCHASM, LOC_NECHASM]
immovable: true
longs: longs:
- 'A rickety wooden bridge extends across the chasm, vanishing into the\nmist. A notice posted on the bridge reads, "Stop! Pay troll!"' - 'A rickety wooden bridge extends across the chasm, vanishing into the\nmist. A notice posted on the bridge reads, "Stop! Pay troll!"'
- 'The wreckage of a bridge (and a dead bear) can be seen at the bottom\nof the chasm.' - 'The wreckage of a bridge (and a dead bear) can be seen at the bottom\nof the chasm.'
- OBJ_33: - OBJ_33:
inventory: '*troll' inventory: '*troll'
locations: [LOC_SWCHASM, LOC_NECHASM]
immovable: true
longs: longs:
- '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.'
@ -1679,10 +1732,14 @@ object_descriptions: !!omap
- 'The troll sounds quite adamant in his demand for a treasure.' - 'The troll sounds quite adamant in his demand for a treasure.'
- OBJ_34: - OBJ_34:
inventory: '*phony troll' inventory: '*phony troll'
locations: [LOC_NOWHERE, LOC_NOWHERE]
immovable: true
longs: longs:
- 'The troll is nowhere to be seen.' - 'The troll is nowhere to be seen.'
- OBJ_35: - OBJ_35:
inventory: !!null # bear uses rtext 141 inventory: !!null # bear uses rtext 141
locations: LOC_BARRENROOM
immovable: true
longs: longs:
- '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.'
@ -1690,15 +1747,21 @@ object_descriptions: !!omap
- '' # dead - '' # dead
- OBJ_36: - OBJ_36:
inventory: '*message in second maze' inventory: '*message in second maze'
locations: LOC_NOWHERE
immovable: true
longs: longs:
- '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."'
- OBJ_37: - OBJ_37:
inventory: '*volcano and/or geyser' inventory: '*volcano and/or geyser'
locations: LOC_BREATHTAKING
immovable: true
longs: !!null longs: !!null
- OBJ_38: - OBJ_38:
inventory: '*vending machine' inventory: '*vending machine'
locations: LOC_DEADEND13
immovable: true
longs: longs:
- [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.']
@ -1707,57 +1770,77 @@ object_descriptions: !!omap
- '"Drop coins here to receive fresh batteries."' - '"Drop coins here to receive fresh batteries."'
- OBJ_39: - OBJ_39:
inventory: 'Batteries' inventory: 'Batteries'
locations: LOC_NOWHERE
longs: longs:
- [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:
inventory: '*carpet and/or moss and/or curtains' inventory: '*carpet and/or moss and/or curtains'
locations: LOC_SOFTROOM
immovable: true
longs: !!null longs: !!null
- OBJ_41: - OBJ_41:
inventory: '*ogre' inventory: '*ogre'
locations: LOC_LARGE
immovable: true
longs: longs:
- '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.'
- OBJ_42: - OBJ_42:
inventory: '*urn' inventory: '*urn'
locations: LOC_CLIFF
immovable: true
longs: longs:
- '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.'
- OBJ_43: - OBJ_43:
inventory: '*cavity' inventory: '*cavity'
locations: LOC_NOWHERE
immovable: true
longs: longs:
- '' # 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.'
- OBJ_44: - OBJ_44:
inventory: '*blood' inventory: '*blood'
locations: LOC_NOWHERE
immovable: true
longs: longs:
- '' # described with dragon - '' # described with dragon
- OBJ_45: - OBJ_45:
inventory: '*reservoir' inventory: '*reservoir'
locations: [LOC_RESERVOIR, LOC_RESNORTH]
immovable: true
longs: longs:
- '' - ''
- 'The waters have parted to form a narrow path across the reservoir.' - 'The waters have parted to form a narrow path across the reservoir.'
- 'The waters crash together again.' - 'The waters crash together again.'
- OBJ_46: - OBJ_46:
inventory: 'Leporine appendage' inventory: 'Leporine appendage'
locations: LOC_FOREST22
longs: longs:
- '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:
inventory: '*mud' inventory: '*mud'
locations: LOC_DEBRIS
immovable: true
longs: longs:
- '' - ''
texts: texts:
- '"MAGIC WORD XYZZY"' - '"MAGIC WORD XYZZY"'
- OBJ_48: - OBJ_48:
inventory: '*note' inventory: '*note'
locations: LOC_NUGGET
immovable: true
longs: longs:
- '' - ''
texts: texts:
- '"You won''t get it up the steps"' - '"You won''t get it up the steps"'
- OBJ_49: - OBJ_49:
inventory: '*sign' inventory: '*sign'
locations: LOC_ANTEROOM
immovable: true
longs: longs:
- [INGAME_SIGN, ''] - [INGAME_SIGN, '']
- [ENDGAME_SIGN, ''] - [ENDGAME_SIGN, '']
@ -1766,36 +1849,43 @@ object_descriptions: !!omap
- '"Treasure Vault. Keys in main office."' - '"Treasure Vault. Keys in main office."'
- OBJ_50: - OBJ_50:
inventory: 'Large gold nugget' inventory: 'Large gold nugget'
locations: LOC_NUGGET
treasure: true treasure: true
longs: longs:
- 'There is a large sparkling nugget of gold here!' - 'There is a large sparkling nugget of gold here!'
- OBJ_51: - OBJ_51:
inventory: 'Several diamonds' inventory: 'Several diamonds'
locations: LOC_WESTBANK
treasure: true treasure: true
longs: longs:
- 'There are diamonds here!' - 'There are diamonds here!'
- OBJ_52: - OBJ_52:
inventory: 'Bars of silver' inventory: 'Bars of silver'
locations: LOC_FLOORHOLE
treasure: true treasure: true
longs: longs:
- 'There are bars of silver here!' - 'There are bars of silver here!'
- OBJ_53: - OBJ_53:
inventory: 'Precious jewelry' inventory: 'Precious jewelry'
locations: LOC_SOUTHSIDE
treasure: true treasure: true
longs: longs:
- 'There is precious jewelry here!' - 'There is precious jewelry here!'
- OBJ_54: - OBJ_54:
inventory: 'Rare coins' inventory: 'Rare coins'
locations: LOC_WESTSIDE
treasure: true treasure: true
longs: longs:
- 'There are many coins here!' - 'There are many coins here!'
- OBJ_55: - OBJ_55:
inventory: 'Treasure chest' inventory: 'Treasure chest'
locations: LOC_NOWHERE
treasure: true treasure: true
longs: longs:
- 'The pirate''s treasure chest is here!' - 'The pirate''s treasure chest is here!'
- OBJ_56: - OBJ_56:
inventory: 'Golden eggs' inventory: 'Golden eggs'
locations: LOC_GIANTROOM
treasure: true treasure: true
longs: longs:
- 'There is a large nest here, full of golden eggs!' - 'There is a large nest here, full of golden eggs!'
@ -1803,11 +1893,13 @@ object_descriptions: !!omap
- 'Done!' - 'Done!'
- OBJ_57: - OBJ_57:
inventory: 'Jeweled trident' inventory: 'Jeweled trident'
locations: LOC_WATERFALL
treasure: true treasure: true
longs: longs:
- 'There is a jewel-encrusted trident here!' - 'There is a jewel-encrusted trident here!'
- OBJ_58: - OBJ_58:
inventory: 'Ming vase' inventory: 'Ming vase'
locations: LOC_ORIENTAL
treasure: true treasure: true
longs: longs:
- [VASE_WHOLE, 'There is a delicate, precious, ming vase here!'] - [VASE_WHOLE, 'There is a delicate, precious, ming vase here!']
@ -1816,22 +1908,27 @@ object_descriptions: !!omap
- [VASE_DROPS, 'The ming vase drops with a delicate crash.'] - [VASE_DROPS, 'The ming vase drops with a delicate crash.']
- OBJ_59: - OBJ_59:
inventory: 'Egg-sized emerald' inventory: 'Egg-sized emerald'
locations: LOC_PLOVER
treasure: true treasure: true
longs: longs:
- '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!'
- OBJ_60: - OBJ_60:
inventory: 'Platinum pyramid' inventory: 'Platinum pyramid'
locations: LOC_DARKROOM
treasure: true treasure: true
longs: longs:
- 'There is a platinum pyramid here, 8 inches on a side!' - 'There is a platinum pyramid here, 8 inches on a side!'
- OBJ_61: - OBJ_61:
inventory: 'Glistening pearl' inventory: 'Glistening pearl'
locations: LOC_NOWHERE
treasure: true treasure: true
longs: longs:
- 'Off to one side lies a glistening pearl!' - 'Off to one side lies a glistening pearl!'
- OBJ_62: - OBJ_62:
inventory: 'Persian rug' inventory: 'Persian rug'
locations: [LOC_SECRET4, LOC_SECRET6]
immovable: true
treasure: true treasure: true
longs: longs:
- 'There is a persian rug spread out on the floor!' - 'There is a persian rug spread out on the floor!'
@ -1839,11 +1936,14 @@ object_descriptions: !!omap
- 'There is a persian rug here, hovering in mid-air!' - 'There is a persian rug here, hovering in mid-air!'
- OBJ_63: - OBJ_63:
inventory: 'Rare spices' inventory: 'Rare spices'
locations: LOC_BOULDERS2
treasure: true treasure: true
longs: longs:
- 'There are rare spices here!' - 'There are rare spices here!'
- OBJ_64: - OBJ_64:
inventory: 'Golden chain' inventory: 'Golden chain'
locations: LOC_BARRENROOM
immovable: true
treasure: true treasure: true
longs: longs:
- 'There is a golden chain lying in a heap on the floor!' - 'There is a golden chain lying in a heap on the floor!'
@ -1851,29 +1951,34 @@ object_descriptions: !!omap
- 'There is a golden chain locked to the wall!' - 'There is a golden chain locked to the wall!'
- OBJ_65: - OBJ_65:
inventory: 'Giant ruby' inventory: 'Giant ruby'
locations: LOC_STOREROOM
treasure: true treasure: true
longs: longs:
- '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!'
- OBJ_66: - OBJ_66:
inventory: 'Jade necklace' inventory: 'Jade necklace'
locations: LOC_NOWHERE
treasure: true treasure: true
longs: longs:
- 'A precious jade necklace has been dropped here!' - 'A precious jade necklace has been dropped here!'
- OBJ_67: - OBJ_67:
inventory: 'Amber gemstone' inventory: 'Amber gemstone'
locations: LOC_NOWHERE
treasure: true treasure: true
longs: longs:
- '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!'
- OBJ_68: - OBJ_68:
inventory: 'Star sapphire' inventory: 'Star sapphire'
locations: LOC_LEDGE
treasure: true treasure: true
longs: longs:
- '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:
inventory: 'Ebony statuette' inventory: 'Ebony statuette'
locations: LOC_REACHDEAD
treasure: true treasure: true
longs: longs:
- 'There is a richly-carved ebony statuette here!' - 'There is a richly-carved ebony statuette here!'

View file

@ -60,11 +60,6 @@
* or "attack"). Else, if M=3, the word is a special case verb (such as * or "attack"). Else, if M=3, the word is a special case verb (such as
* "dig") and N % 1000 is an index into section 6. Objects from 50 to * "dig") and N % 1000 is an index into section 6. Objects from 50 to
* (currently, anyway) 79 are considered treasures (for pirate, closeout). * (currently, anyway) 79 are considered treasures (for pirate, closeout).
* Section 7: Object locations. Each line contains an object number and its
* initial location (zero (or omitted) if none). If the object is
* immovable, the location is followed by a "-1". If it has two locations
* (e.g. the grate) the first location is followed with the second, and
* the object is assumed to be immovable.
* Section 8: Action defaults. Each line contains an "action-verb" number and * Section 8: Action defaults. Each line contains an "action-verb" number and
* the index (in section 6) of the default message for the verb. * the index (in section 6) of the default message for the verb.
* Section 0: End of database. * Section 0: End of database.
@ -104,8 +99,6 @@ long LINES[LINSIZ + 1];
long TRAVEL[TRVSIZ + 1]; long TRAVEL[TRVSIZ + 1];
long KTAB[TABSIZ + 1]; long KTAB[TABSIZ + 1];
long ATAB[TABSIZ + 1]; long ATAB[TABSIZ + 1];
long PLAC[NOBJECTS + 1];
long FIXD[NOBJECTS + 1];
long ACTSPK[VRBSIZ + 1]; long ACTSPK[VRBSIZ + 1];
static long GETTXT(long SKIP, long ONEWRD, long UPPER) static long GETTXT(long SKIP, long ONEWRD, long UPPER)
@ -301,8 +294,7 @@ static void read_initial_locations(FILE* database)
{ {
long OBJ; long OBJ;
while ((OBJ = GETNUM(database)) != -1) { while ((OBJ = GETNUM(database)) != -1) {
PLAC[OBJ] = GETNUM(NULL); /* all done from YAML now */
FIXD[OBJ] = GETNUM(NULL);
} }
} }
@ -476,8 +468,6 @@ static void write_file(FILE* header_file)
write_1d(header_file, TRAVEL, TRVSIZ + 1, "TRAVEL"); write_1d(header_file, TRAVEL, TRVSIZ + 1, "TRAVEL");
write_1d(header_file, KTAB, TABSIZ + 1, "KTAB"); write_1d(header_file, KTAB, TABSIZ + 1, "KTAB");
write_1d(header_file, ATAB, TABSIZ + 1, "ATAB"); write_1d(header_file, ATAB, TABSIZ + 1, "ATAB");
write_1d(header_file, PLAC, NOBJECTS + 1, "PLAC");
write_1d(header_file, FIXD, NOBJECTS + 1, "FIXD");
write_1d(header_file, ACTSPK, VRBSIZ + 1, "ACTSPK"); write_1d(header_file, ACTSPK, VRBSIZ + 1, "ACTSPK");
fprintf(header_file, "#undef LOCATION\n"); fprintf(header_file, "#undef LOCATION\n");

12
init.c
View file

@ -40,17 +40,17 @@ void initialise(void)
* described last, we'll drop them first. */ * described last, we'll drop them first. */
for (int i = 1; i <= NOBJECTS; i++) { for (int i = 1; i <= NOBJECTS; i++) {
int k = NOBJECTS + 1 - i; int k = NOBJECTS + 1 - i;
if (FIXD[k] > 0) { if (object_descriptions[k].fixd > 0) {
DROP(k + NOBJECTS, FIXD[k]); DROP(k + NOBJECTS, object_descriptions[k].fixd);
DROP(k, PLAC[k]); DROP(k, object_descriptions[k].plac);
} }
} }
for (int i = 1; i <= NOBJECTS; i++) { for (int i = 1; i <= NOBJECTS; i++) {
int k = NOBJECTS + 1 - i; int k = NOBJECTS + 1 - i;
game.fixed[k] = FIXD[k]; game.fixed[k] = object_descriptions[k].fixd;
if (PLAC[k] != 0 && FIXD[k] <= 0) if (object_descriptions[k].plac != 0 && object_descriptions[k].fixd <= 0)
DROP(k, PLAC[k]); DROP(k, object_descriptions[k].plac);
} }
/* Treasure props are initially -1, and are set to 0 the first time /* Treasure props are initially -1, and are set to 0 the first time

14
main.c
View file

@ -294,7 +294,7 @@ static bool spotted_by_pirate(int i)
continue; continue;
/* Pirate won't take pyramid from plover room or dark /* Pirate won't take pyramid from plover room or dark
* room (too easy!). */ * room (too easy!). */
if (treasure == PYRAMID && (game.loc == PLAC[PYRAMID] || game.loc == PLAC[EMERALD])) { if (treasure == PYRAMID && (game.loc == object_descriptions[PYRAMID].plac || game.loc == object_descriptions[EMERALD].plac)) {
continue; continue;
} }
if (TOTING(treasure) || HERE(treasure)) if (TOTING(treasure) || HERE(treasure))
@ -328,7 +328,7 @@ static bool spotted_by_pirate(int i)
for (int treasure = 1; treasure <= NOBJECTS; treasure++) { for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
if (!object_descriptions[treasure].is_treasure) if (!object_descriptions[treasure].is_treasure)
continue; continue;
if (!(treasure == PYRAMID && (game.loc == PLAC[PYRAMID] || game.loc == PLAC[EMERALD]))) { if (!(treasure == PYRAMID && (game.loc == object_descriptions[PYRAMID].plac || game.loc == object_descriptions[EMERALD].plac))) {
if (AT(treasure) && game.fixed[treasure] == 0) if (AT(treasure) && game.fixed[treasure] == 0)
CARRY(treasure, game.loc); CARRY(treasure, game.loc);
if (TOTING(treasure)) if (TOTING(treasure))
@ -695,13 +695,13 @@ static bool playermove(token_t verb, int motion)
game.prop[TROLL] = 0; game.prop[TROLL] = 0;
MOVE(TROLL2, 0); MOVE(TROLL2, 0);
MOVE(TROLL2 + NOBJECTS, 0); MOVE(TROLL2 + NOBJECTS, 0);
MOVE(TROLL, PLAC[TROLL]); MOVE(TROLL, object_descriptions[TROLL].plac);
MOVE(TROLL + NOBJECTS, FIXD[TROLL]); MOVE(TROLL + NOBJECTS, object_descriptions[TROLL].fixd);
JUGGLE(CHASM); JUGGLE(CHASM);
game.newloc = game.loc; game.newloc = game.loc;
return true; return true;
} else { } else {
game.newloc = PLAC[TROLL] + FIXD[TROLL] - game.loc; game.newloc = object_descriptions[TROLL].plac + object_descriptions[TROLL].fixd - game.loc;
if (game.prop[TROLL] == 0)game.prop[TROLL] = 1; if (game.prop[TROLL] == 0)game.prop[TROLL] = 1;
if (!TOTING(BEAR)) return true; if (!TOTING(BEAR)) return true;
rspeak(BRIDGE_COLLAPSE); rspeak(BRIDGE_COLLAPSE);
@ -773,8 +773,8 @@ static bool closecheck(void)
} }
MOVE(TROLL, 0); MOVE(TROLL, 0);
MOVE(TROLL + NOBJECTS, 0); MOVE(TROLL + NOBJECTS, 0);
MOVE(TROLL2, PLAC[TROLL]); MOVE(TROLL2, object_descriptions[TROLL].plac);
MOVE(TROLL2 + NOBJECTS, FIXD[TROLL]); MOVE(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
JUGGLE(CHASM); JUGGLE(CHASM);
if (game.prop[BEAR] != 3)DESTROY(BEAR); if (game.prop[BEAR] != 3)DESTROY(BEAR);
game.prop[CHAIN] = 0; game.prop[CHAIN] = 0;

View file

@ -44,6 +44,7 @@ h_template = """/* Generated from adventure.yaml - do not hand-hack! */
typedef struct {{ typedef struct {{
const char* inventory; const char* inventory;
int plac, fixd;
bool is_treasure; bool is_treasure;
const char** longs; const char** longs;
const char** sounds; const char** sounds;
@ -240,6 +241,8 @@ def get_locations(loc):
def get_object_descriptions(obj): def get_object_descriptions(obj):
template = """ {{ template = """ {{
.inventory = {}, .inventory = {},
.plac = {},
.fixd = {},
.is_treasure = {}, .is_treasure = {},
.longs = (const char* []) {{ .longs = (const char* []) {{
{} {}
@ -254,13 +257,14 @@ def get_object_descriptions(obj):
""" """
obj_str = "" obj_str = ""
for item in obj: for item in obj:
i_msg = make_c_string(item[1]["inventory"]) attr = item[1]
i_msg = make_c_string(attr["inventory"])
longs_str = "" longs_str = ""
if item[1]["longs"] == None: if attr["longs"] == None:
longs_str = " " * 12 + "NULL," longs_str = " " * 12 + "NULL,"
else: else:
labels = [] labels = []
for l_msg in item[1]["longs"]: for l_msg in attr["longs"]:
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]
@ -275,21 +279,27 @@ def get_object_descriptions(obj):
statedefines += "#define %s\t%d /* %s */\n" % (label, i, message) statedefines += "#define %s\t%d /* %s */\n" % (label, i, message)
statedefines += "\n" statedefines += "\n"
sounds_str = "" sounds_str = ""
if item[1].get("sounds") == None: if attr.get("sounds") == None:
sounds_str = " " * 12 + "NULL," sounds_str = " " * 12 + "NULL,"
else: else:
for l_msg in item[1]["sounds"]: for l_msg in attr["sounds"]:
sounds_str += " " * 12 + make_c_string(l_msg) + ",\n" sounds_str += " " * 12 + make_c_string(l_msg) + ",\n"
sounds_str = sounds_str[:-1] # trim trailing newline sounds_str = sounds_str[:-1] # trim trailing newline
texts_str = "" texts_str = ""
if item[1].get("texts") == None: if attr.get("texts") == None:
texts_str = " " * 12 + "NULL," texts_str = " " * 12 + "NULL,"
else: else:
for l_msg in item[1]["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
treasure = "true" if item[1].get("treasure") else "false" locs = attr.get("locations", ["LOC_NOWHERE", "LOC_NOWHERE"])
obj_str += template.format(i_msg, treasure, longs_str, sounds_str, texts_str) immovable = attr.get("immovable", False)
if type(locs) == str:
locs = [locnames.index(locs), -1 if immovable else 0]
else:
locs = [locnames.index(x) for x in locs]
treasure = "true" if attr.get("treasure") else "false"
obj_str += template.format(i_msg, locs[0], locs[1], treasure, longs_str, sounds_str, texts_str)
obj_str = obj_str[:-1] # trim trailing newline obj_str = obj_str[:-1] # trim trailing newline
return obj_str return obj_str
@ -353,6 +363,8 @@ if __name__ == "__main__":
with open(yaml_name, "r") as f: with open(yaml_name, "r") as f:
db = yaml.load(f) db = yaml.load(f)
locnames = [x[0] for x in db["locations"]]
c = c_template.format( c = c_template.format(
h_name, h_name,
get_arbitrary_messages(db["arbitrary_messages"]), get_arbitrary_messages(db["arbitrary_messages"]),