From 4d920561429d56eac9e2c3cbb0b35cf199e94f89 Mon Sep 17 00:00:00 2001 From: Jude Brown Date: Sun, 6 Dec 2009 13:23:18 +1000 Subject: Add further door_XXX properties for opening, closing, etc. See documentation. This is somewhat hackish (or at least, hackier), but I think there's a precendent for it at least. --- crawl-ref/docs/develop/levels/advanced.txt | 23 ++++ crawl-ref/source/directn.cc | 34 +++++- crawl-ref/source/main.cc | 164 +++++++++++++++++++++++++---- 3 files changed, 195 insertions(+), 26 deletions(-) diff --git a/crawl-ref/docs/develop/levels/advanced.txt b/crawl-ref/docs/develop/levels/advanced.txt index 4a061f0034..f9cd653809 100644 --- a/crawl-ref/docs/develop/levels/advanced.txt +++ b/crawl-ref/docs/develop/levels/advanced.txt @@ -719,6 +719,29 @@ dungeon cell which they are on: before opening the door, with the value of the property used as the prompt string. +* door_description_adjective: Overwrite the adjective for the door. Not + currently used. + +* door_description_noun: Overwrite the noun used by the door. Replaces, for + instance, "door" with "doorway". + +* door_description_veto: Vetoes the use of "open", "closed" and "detected + secret" when applying adjectives to door descriptions. + +* door_berserk_verb_open: Replace the verb used for opening the door while + berserk. Should include "%s%s", as it is printed as a formatted string. + +* door_berserk_adjective: Replaces the adjective "with a bang" when the player + is not silenced while opening a door. + +* door_noisy_verb_open: Replaces "opens with a creak". Also requires "%s%s" as + it is a formatted string. + +* door_airborne_verb_open: Replaces "reach down and open", also requires "%s%s". + +* door_open_verb: Replaces "You open". Also requires "%s%s". All of the above "open" + have "close" counterparts which are used when closing a door. + * feature_description: What to use as the short description of the cell's feature. diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 1abc47b275..dbebce5637 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -2877,18 +2877,42 @@ std::string feature_description(const coord_def& where, bool bloody, const std::string door_desc_suffix = env.markers.property_at(where, MAT_ANY, "door_description_suffix"); + const std::string door_desc_noun = + env.markers.property_at(where, MAT_ANY, + "door_description_noun"); + const std::string door_desc_adj = + env.markers.property_at(where, MAT_ANY, + "door_description_adjective"); + const std::string door_desc_veto = + env.markers.property_at(where, MAT_ANY, + "door_description_veto"); std::set all_door; find_connected_identical(where, grd(where), all_door); const char *adj, *noun; get_door_description(all_door.size(), &adj, &noun); - std::string desc = adj; - desc += (grid == DNGN_OPEN_DOOR) ? "open " : "closed "; - if (grid == DNGN_DETECTED_SECRET_DOOR) - desc += "detected secret "; + std::string desc; + if (!door_desc_adj.empty()) + desc += door_desc_adj; + else + desc += adj; + + if (door_desc_veto.empty() || door_desc_veto != "veto") + { + desc += (grid == DNGN_OPEN_DOOR) ? "open " : "closed "; + if (grid == DNGN_DETECTED_SECRET_DOOR) + desc += "detected secret "; + } + + desc += door_desc_prefix; + + if (!door_desc_noun.empty()) + desc += door_desc_noun; + else + desc += noun; - desc += door_desc_prefix + noun + door_desc_suffix; + desc += door_desc_suffix; if (bloody) desc += ", spattered with blood"; diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index e37d27f76b..6b95501781 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -3310,6 +3310,10 @@ static void _open_door(coord_def move, bool check_confused) const coord_def doorpos = you.pos() + door_move.delta; const dungeon_feature_type feat = (in_bounds(doorpos) ? grd(doorpos) : DNGN_UNSEEN); + std::string door_already_open = ""; + if (in_bounds(doorpos)) + door_already_open = env.markers.property_at(doorpos, MAT_ANY, + "door_verb_already_open"); if (!feat_is_closed_door(feat)) { @@ -3322,8 +3326,12 @@ static void _open_door(coord_def move, bool check_confused) } switch (feat) { + // This doesn't ever sem to be triggered. case DNGN_OPEN_DOOR: - mpr("It's already open!"); + if (!door_already_open.empty()) + mpr(door_already_open.c_str()); + else + mpr("It's already open!"); break; default: mpr("There isn't anything that you can open there!"); @@ -3339,6 +3347,17 @@ static void _open_door(coord_def move, bool check_confused) const char *adj, *noun; get_door_description(all_door.size(), &adj, &noun); + const std::string door_desc_adj = + env.markers.property_at(doorpos, MAT_ANY, + "door_description_adjective"); + const std::string door_desc_noun = + env.markers.property_at(doorpos, MAT_ANY, + "door_description_noun"); + if (!door_desc_adj.empty()) + adj = door_desc_adj.c_str(); + if (!door_desc_noun.empty()) + noun = door_desc_noun.c_str(); + if (!(check_confused && you.confused())) { std::string door_open_prompt = @@ -3386,28 +3405,73 @@ static void _open_door(coord_def move, bool check_confused) int skill = you.dex + (you.skills[SK_TRAPS_DOORS] + you.skills[SK_STEALTH]) / 2; + std::string berserk_open = env.markers.property_at(doorpos, MAT_ANY, + "door_berserk_verb_open"); + std::string berserk_adjective = env.markers.property_at(doorpos, MAT_ANY, + "door_berserk_adjective"); + std::string door_open_creak = env.markers.property_at(doorpos, MAT_ANY, + "door_noisy_verb_open"); + std::string door_airborne = env.markers.property_at(doorpos, MAT_ANY, + "door_airborne_verb_open"); + std::string door_open_verb = env.markers.property_at(doorpos, MAT_ANY, + "door_verb_open"); + if (you.berserk()) { // XXX: Better flavour for larger doors? if (silenced(you.pos())) - mprf("The %s%s flies open!", adj, noun); + { + if (!berserk_open.empty()) + { + berserk_open += "."; + mprf(berserk_open.c_str(), adj, noun); + } + else + mprf("The %s%s flies open!", adj, noun); + } else { - mprf(MSGCH_SOUND, "The %s%s flies open with a bang!", adj, noun); + if (!berserk_open.empty()) + { + if (!berserk_adjective.empty()) + berserk_open += " " + berserk_adjective; + else + berserk_open += "."; + mprf(MSGCH_SOUND, berserk_open.c_str(), adj, noun); + } + else + mprf(MSGCH_SOUND, "The %s%s flies open with a bang!", adj, noun); noisy(15, you.pos()); } } else if (one_chance_in(skill) && !silenced(you.pos())) { - mprf(MSGCH_SOUND, "As you open the %s%s, it creaks loudly!", - adj, noun); + if (!door_open_creak.empty()) + mprf(MSGCH_SOUND, door_open_creak.c_str(), adj, noun); + else + mprf(MSGCH_SOUND, "As you open the %s%s, it creaks loudly!", + adj, noun); noisy(10, you.pos()); } else { - const char* verb = (you.airborne() ? "reach down and open" - : "open"); - mprf("You %s the %s%s.", verb, adj, noun); + const char* verb; + if (you.airborne()) + { + if (!door_airborne.empty()) + verb = door_airborne.c_str(); + else + verb = "You reach down and open the %s%s."; + } + else + { + if (!door_open_verb.empty()) + verb = door_open_verb.c_str(); + else + verb = "You open the %s%s"; + } + + mprf(verb, adj, noun); } bool seen_secret = false; @@ -3502,12 +3566,38 @@ static void _close_door(coord_def move) const dungeon_feature_type feat = (in_bounds(doorpos) ? grd(doorpos) : DNGN_UNSEEN); + std::string berserk_close = env.markers.property_at(doorpos, MAT_ANY, + "door_berserk_verb_close"); + std::string berserk_adjective = env.markers.property_at(doorpos, MAT_ANY, + "door_berserk_adjective"); + std::string door_close_creak = env.markers.property_at(doorpos, MAT_ANY, + "door_noisy_verb_close"); + std::string door_airborne = env.markers.property_at(doorpos, MAT_ANY, + "door_airborne_verb_close"); + std::string door_close_verb = env.markers.property_at(doorpos, MAT_ANY, + "door_verb_close"); + if (feat == DNGN_OPEN_DOOR) { std::set all_door; find_connected_identical(doorpos, grd(doorpos), all_door); const char *adj, *noun; get_door_description(all_door.size(), &adj, &noun); + const char *waynoun = make_stringf("%sway", noun).c_str(); + + const std::string door_desc_adj = + env.markers.property_at(doorpos, MAT_ANY, + "door_description_adjective"); + const std::string door_desc_noun = + env.markers.property_at(doorpos, MAT_ANY, + "door_description_noun"); + if (!door_desc_adj.empty()) + adj = door_desc_adj.c_str(); + if (!door_desc_noun.empty()) + { + noun = door_desc_noun.c_str(); + waynoun = noun; + } for (std::set::const_iterator i = all_door.begin(); i != all_door.end(); ++i) @@ -3519,23 +3609,23 @@ static void _close_door(coord_def move) // creature is invisible. if (!you.can_see(mon)) { - mprf("Something is blocking the %sway!", noun); + mprf("Something is blocking the %s!", waynoun); you.turn_is_over = true; } else - mprf("There's a creature in the %sway!", noun); + mprf("There's a creature in the %s!", waynoun); return; } if (igrd(dc) != NON_ITEM) { - mprf("There's something blocking the %sway.", noun); + mprf("There's something blocking the %s.", waynoun); return; } if (you.pos() == dc) { - mprf("There's a thick-headed creature in the %sway!", noun); + mprf("There's a thick-headed creature in the %s!", waynoun); return; } } @@ -3546,26 +3636,58 @@ static void _close_door(coord_def move) if (you.berserk()) { if (silenced(you.pos())) - mprf("You slam the %s%s shut!", adj, noun); + { + if (!berserk_close.empty()) + { + berserk_close += "."; + mprf(berserk_close.c_str(), adj, noun); + } + else + mprf("You slam the %s%s shut!", adj, noun); + } else { - mprf(MSGCH_SOUND, "You slam the %s%s shut with a bang!", - adj, noun); - noisy(25, you.pos()); + if (!berserk_close.empty()) + { + if (!berserk_adjective.empty()) + berserk_close += " " + berserk_adjective; + else + berserk_close += "."; + mprf(MSGCH_SOUND, berserk_close.c_str(), adj, noun); + } + else + mprf(MSGCH_SOUND, "You slam the %s%s shut with a bang!", adj, noun); + noisy(15, you.pos()); } } else if (one_chance_in(skill) && !silenced(you.pos())) { - mprf(MSGCH_SOUND, "As you close the %s%s, it creaks loudly!", - adj, noun); + if (!door_close_creak.empty()) + mprf(MSGCH_SOUND, door_close_creak.c_str(), adj, noun); + else + mprf(MSGCH_SOUND, "As you close the %s%s, it creaks loudly!", + adj, noun); noisy(10, you.pos()); } else { - const char* verb = you.airborne() ? "reach down and close" - : "close"; + const char* verb; + if (you.airborne()) + { + if (!door_airborne.empty()) + verb = door_airborne.c_str(); + else + verb = "You reach down and cloose the %s%s."; + } + else + { + if (!door_close_verb.empty()) + verb = door_close_verb.c_str(); + else + verb = "You close the %s%s"; + } - mprf("You %s the %s%s.", verb, adj, noun); + mprf(verb, adj, noun); } std::vector excludes; -- cgit v1.2.3-54-g00ecf