From: Eric S. Raymond Date: Fri, 23 Jun 2017 15:16:37 +0000 (-0400) Subject: Support loud locations. X-Git-Tag: 1.1~148 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=1e8c3a4a1dae68a13596ed8e1e82500e869695da;p=open-adventure.git Support loud locations. --- diff --git a/actions.c b/actions.c index 5a82a5b..b6cfc33 100644 --- a/actions.c +++ b/actions.c @@ -675,9 +675,11 @@ static int listen(void) int spk = ALL_SILENT; k = locations[game.loc].sound; if (k != SILENT) { - rspeak(labs(k)); - if (k < 0) return GO_CLEAROBJ; - spk = NO_MESSAGE; + rspeak(k); + if (locations[game.loc].loud) + return GO_CLEAROBJ; + else + spk = NO_MESSAGE; } for (int i = 1; i <= NOBJECTS; i++) { if (!HERE(i) || OBJSND[i] == 0 || game.prop[i] < 0) diff --git a/adventure.yaml b/adventure.yaml index 85a70bc..9fda115 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -35,7 +35,8 @@ # The optional hints field is a list of YAML references to hints # that may be available at this location. (This is why locations # 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 # these messages need to be kept adjacent and ordered (for now). @@ -829,6 +830,7 @@ locations: !!omap conditions: {NOARRR: true, LIT: true, DEEP: true} hints: [*jade] sound: TOTAL_ROAR + loud: true - LOC_BOULDERS2: 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.' @@ -1064,6 +1066,7 @@ locations: !!omap short: 'You''re at bottom of reservoir.' conditions: {FLUID: true, DEEP: true} sound: TOTAL_ROAR + loud: true - LOC_RESNORTH: description: long: 'You are at the northern edge of the reservoir. A northwest passage\nleads sharply up from here.' diff --git a/newdungeon.py b/newdungeon.py index 4553eea..873990c 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -13,6 +13,7 @@ h_template = """/* Generated from adventure.yaml - do not hand-hack! */ #define NEWDB_H #include +#include #define SILENT -1 /* no sound */ @@ -29,6 +30,7 @@ typedef struct {{ typedef struct {{ descriptions_t description; const long sound; + const bool loud; }} location_t; typedef struct {{ @@ -193,6 +195,7 @@ def get_locations(loc): .big = {}, }}, .sound = {}, + .loud = {}, }}, """ loc_str = "" @@ -200,7 +203,8 @@ def get_locations(loc): short_d = make_c_string(item[1]["description"]["short"]) long_d = make_c_string(item[1]["description"]["long"]) 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 return loc_str