From f76829ed22a7b9d20b0a217e7c988abd110de634 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Wed, 19 Aug 2009 21:59:45 +0000 Subject: A KFEAT specified trap can start out known to the player by adding "known" to the trap name. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10581 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/level_design.txt | 5 +++++ crawl-ref/source/dungeon.cc | 36 +++++++++++++++++++++++------------- crawl-ref/source/mapdef.cc | 4 +++- crawl-ref/source/traps.cc | 7 ++++++- crawl-ref/source/traps.h | 2 ++ 5 files changed, 39 insertions(+), 15 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/docs/level_design.txt b/crawl-ref/docs/level_design.txt index 922774ba6a..4f723186e0 100644 --- a/crawl-ref/docs/level_design.txt +++ b/crawl-ref/docs/level_design.txt @@ -822,6 +822,11 @@ KFEAT: Z = C / needle trap / antique armour shop / altar_zin 'floor'. If you do not want to specify the type of shop, use 'any shop' or 'random shop'. + If you want a trap to start out known to the player, add "known" + to the trap name: + + KFEAT: A = known needle trap + The placeholder used by KFEAT can be shared by KITEM and KMONS; see below. If the placeholder is shared, all defined Kxxxx operations for the placeholder are performed. Also, all Kxxx diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index 2c4a04ba1f..b5ef022f55 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -4768,14 +4768,20 @@ dungeon_feature_type map_feature(map_def *map, const coord_def &c, int rawfeat) if (mapsp) { const feature_spec f = mapsp->get_feat(); - if (f.feat >= 0) + if (f.trap >= 0) + { + // f.feat == 1 means trap is generated known. + if (f.feat == 1) + return trap_category(static_cast(f.trap)); + else + return (DNGN_UNDISCOVERED_TRAP); + } + else if (f.feat >= 0) return static_cast(f.feat); else if (f.glyph >= 0) return map_feature(NULL, c, rawfeat); else if (f.shop >= 0) return (DNGN_ENTER_SHOP); - else if (f.trap >= 0) - return (DNGN_UNDISCOVERED_TRAP); return (DNGN_FLOOR); } @@ -4829,7 +4835,20 @@ static void _vault_grid( vault_placement &place, if (mapsp) { const feature_spec f = mapsp->get_feat(); - if (f.feat >= 0) + if (f.trap >= 0) + { + const trap_type trap = + (f.trap == TRAP_INDEPTH) + ? random_trap_for_place(place.level_number) + : static_cast(f.trap); + + place_specific_trap(where, trap); + + // f.feat == 1 means trap is generated known. + if (f.feat == 1) + grd(where) = trap_category(trap); + } + else if (f.feat >= 0) { grd(where) = static_cast( f.feat ); vgrid = -1; @@ -4840,15 +4859,6 @@ static void _vault_grid( vault_placement &place, } else if (f.shop >= 0) place_spec_shop(place.level_number, where, f.shop); - else if (f.trap >= 0) - { - const trap_type trap = - (f.trap == TRAP_INDEPTH) - ? random_trap_for_place(place.level_number) - : static_cast(f.trap); - - place_specific_trap(where, trap); - } else grd(where) = DNGN_FLOOR; diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index d116bd6d4c..8d9e7408af 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -3352,6 +3352,8 @@ void keyed_mapspec::parse_features(const std::string &s) feature_spec keyed_mapspec::parse_trap(std::string s, int weight) { strip_tag(s, "trap"); + const bool known = strip_tag(s, "known"); + trim_string(s); lowercase(s); @@ -3359,7 +3361,7 @@ feature_spec keyed_mapspec::parse_trap(std::string s, int weight) if (trap == -1) err = make_stringf("bad trap name: '%s'", s.c_str()); - feature_spec fspec(-1, weight); + feature_spec fspec(known ? 1 : -1, weight); fspec.trap = trap; return (fspec); } diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 5aff02caec..3203f672e7 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -1244,7 +1244,12 @@ void trap_def::shoot_ammo(actor& act, bool was_known) // returns appropriate trap symbol dungeon_feature_type trap_def::category() const { - switch (this->type) + return trap_category(type); +} + +dungeon_feature_type trap_category(trap_type type) +{ + switch (type) { case TRAP_SHAFT: return (DNGN_TRAP_NATURAL); diff --git a/crawl-ref/source/traps.h b/crawl-ref/source/traps.h index 709618915e..20fc98452f 100644 --- a/crawl-ref/source/traps.h +++ b/crawl-ref/source/traps.h @@ -35,6 +35,8 @@ bool player_caught_in_net(); void clear_trapping_net(); void check_net_will_hold_monster(monsters *mon); +dungeon_feature_type trap_category(trap_type type); + void destroy_trap(const coord_def& pos); trap_def* find_trap(const coord_def& where); trap_type get_trap_type(const coord_def& where); -- cgit v1.2.3-54-g00ecf