Support loud locations.

This commit is contained in:
Eric S. Raymond 2017-06-23 11:16:37 -04:00
parent f47dc9f447
commit 1e8c3a4a1d
3 changed files with 14 additions and 5 deletions

View file

@ -675,9 +675,11 @@ static int listen(void)
int spk = ALL_SILENT; int spk = ALL_SILENT;
k = locations[game.loc].sound; k = locations[game.loc].sound;
if (k != SILENT) { if (k != SILENT) {
rspeak(labs(k)); rspeak(k);
if (k < 0) return GO_CLEAROBJ; if (locations[game.loc].loud)
spk = NO_MESSAGE; return GO_CLEAROBJ;
else
spk = NO_MESSAGE;
} }
for (int i = 1; i <= NOBJECTS; i++) { for (int i = 1; i <= NOBJECTS; i++) {
if (!HERE(i) || OBJSND[i] == 0 || game.prop[i] < 0) if (!HERE(i) || OBJSND[i] == 0 || game.prop[i] < 0)

View file

@ -35,7 +35,8 @@
# The optional hints field is a list of YAML references to hints # The optional hints field is a list of YAML references to hints
# that may be available at this location. (This is why locations # that may be available at this location. (This is why locations
# has to follow hints.) The "sound" attribute, if present, is s # has to follow hints.) The "sound" attribute, if present, is s
# label for a location sound. # label for a location sound. If there is a "loud" attribute and
# it is true, object sounds are drowned out at this location.
# #
# arbitrary_messages: These are arguments to rspeak(). Some spans of # arbitrary_messages: These are arguments to rspeak(). Some spans of
# these messages need to be kept adjacent and ordered (for now). # these messages need to be kept adjacent and ordered (for now).
@ -829,6 +830,7 @@ locations: !!omap
conditions: {NOARRR: true, LIT: true, DEEP: true} conditions: {NOARRR: true, LIT: true, DEEP: true}
hints: [*jade] hints: [*jade]
sound: TOTAL_ROAR sound: TOTAL_ROAR
loud: true
- LOC_BOULDERS2: - LOC_BOULDERS2:
description: description:
long: 'You are in a small chamber filled with large boulders. The walls are\nvery warm, causing the air in the room to be almost stifling from the\nheat. The only exit is a crawl heading west, through which is coming\na low rumbling.' long: 'You are in a small chamber filled with large boulders. The walls are\nvery warm, causing the air in the room to be almost stifling from the\nheat. The only exit is a crawl heading west, through which is coming\na low rumbling.'
@ -1064,6 +1066,7 @@ locations: !!omap
short: 'You''re at bottom of reservoir.' short: 'You''re at bottom of reservoir.'
conditions: {FLUID: true, DEEP: true} conditions: {FLUID: true, DEEP: true}
sound: TOTAL_ROAR sound: TOTAL_ROAR
loud: true
- LOC_RESNORTH: - LOC_RESNORTH:
description: description:
long: 'You are at the northern edge of the reservoir. A northwest passage\nleads sharply up from here.' long: 'You are at the northern edge of the reservoir. A northwest passage\nleads sharply up from here.'

View file

@ -13,6 +13,7 @@ h_template = """/* Generated from adventure.yaml - do not hand-hack! */
#define NEWDB_H #define NEWDB_H
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#define SILENT -1 /* no sound */ #define SILENT -1 /* no sound */
@ -29,6 +30,7 @@ typedef struct {{
typedef struct {{ typedef struct {{
descriptions_t description; descriptions_t description;
const long sound; const long sound;
const bool loud;
}} location_t; }} location_t;
typedef struct {{ typedef struct {{
@ -193,6 +195,7 @@ def get_locations(loc):
.big = {}, .big = {},
}}, }},
.sound = {}, .sound = {},
.loud = {},
}}, }},
""" """
loc_str = "" loc_str = ""
@ -200,7 +203,8 @@ def get_locations(loc):
short_d = make_c_string(item[1]["description"]["short"]) short_d = make_c_string(item[1]["description"]["short"])
long_d = make_c_string(item[1]["description"]["long"]) long_d = make_c_string(item[1]["description"]["long"])
sound = item[1].get("sound", "SILENT") sound = item[1].get("sound", "SILENT")
loc_str += template.format(short_d, long_d, sound) loud = "true" if item[1].get("loud") else "false"
loc_str += template.format(short_d, long_d, sound, loud)
loc_str = loc_str[:-1] # trim trailing newline loc_str = loc_str[:-1] # trim trailing newline
return loc_str return loc_str