diff --git a/data/json/traps.json b/data/json/traps.json index a3c5270c31456..8b92672ce7382 100644 --- a/data/json/traps.json +++ b/data/json/traps.json @@ -399,7 +399,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "temple_toggle" + "action": "temple_toggle", + "always_invisible": true }, { "type": "trap", @@ -410,7 +411,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "glow" + "action": "glow", + "always_invisible": true }, { "type": "trap", @@ -421,7 +423,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "hum" + "action": "hum", + "always_invisible": true }, { "type": "trap", @@ -432,7 +435,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "shadow" + "action": "shadow", + "always_invisible": true }, { "type": "trap", @@ -443,7 +447,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "drain" + "action": "drain", + "always_invisible": true }, { "type": "trap", @@ -454,7 +459,8 @@ "visibility": 99, "avoidance": 99, "difficulty": 99, - "action": "snake" + "action": "snake", + "always_invisible": true }, { "type": "trap", diff --git a/src/player.cpp b/src/player.cpp index 377e4a058f840..01c98aba22298 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2932,8 +2932,8 @@ void player::search_surroundings() if( !sees( tp ) ) { continue; } - if( tr.name().empty() || tr.can_see( tp, *this ) ) { - // Already seen, or has no name -> can never be seen + if( tr.is_always_invisible() || tr.can_see( tp, *this ) ) { + // Already seen, or can never be seen continue; } // Chance to detect traps we haven't yet seen. diff --git a/src/trap.cpp b/src/trap.cpp index 64f158e3f4400..77c5cc20b8984 100644 --- a/src/trap.cpp +++ b/src/trap.cpp @@ -114,6 +114,7 @@ void trap::load( JsonObject &jo, const std::string & ) act = trap_function_from_string( jo.get_string( "action" ) ); optional( jo, was_loaded, "benign", benign, false ); + optional( jo, was_loaded, "always_invisible", always_invisible, false ); optional( jo, was_loaded, "funnel_radius", funnel_radius_mm, 0 ); assign( jo, "trigger_weight", trigger_weight ); optional( jo, was_loaded, "drops", components ); @@ -121,8 +122,7 @@ void trap::load( JsonObject &jo, const std::string & ) std::string trap::name() const { - // trap names can be empty, those are special always invisible traps. See player::search_surroundings - return name_.empty() ? name_ : _( name_ ); + return _( name_ ); } void trap::reset() diff --git a/src/trap.h b/src/trap.h index b8069122c1e2e..af4437630c6d8 100644 --- a/src/trap.h +++ b/src/trap.h @@ -76,6 +76,7 @@ struct trap { int avoidance; // 0 to ??, affects avoidance int difficulty; // 0 to ??, difficulty of assembly & disassembly bool benign = false; + bool always_invisible = false; trap_function act; std::string name_; /** @@ -86,6 +87,12 @@ struct trap { std::vector components; // For disassembly? public: std::string name() const; + /** + * There are special always invisible traps. See player::search_surroundings + */ + bool is_always_invisible() const { + return always_invisible; + } /** * How easy it is to spot the trap. Smaller values means it's easier to spot. */