From 5e3997c1e1361495c2805c748cb162b9beeae97d Mon Sep 17 00:00:00 2001 From: Anton Simakov <67688115+GuardianDll@users.noreply.github.com> Date: Tue, 7 Jan 2025 06:31:20 +0100 Subject: [PATCH] split HINT_THE_LOCATION from PRESERVE_SPAWN_OMT flag (#78193) --- data/json/flags.json | 5 +++ data/json/items/id_cards.json | 62 +++++++++++++++++++-------- data/json/items/tool/electronics.json | 12 +++++- doc/JSON_FLAGS.md | 1 + src/item_tname.cpp | 3 +- 5 files changed, 64 insertions(+), 19 deletions(-) diff --git a/data/json/flags.json b/data/json/flags.json index 2aa46e462c9a5..69ef17d4e5ed7 100644 --- a/data/json/flags.json +++ b/data/json/flags.json @@ -669,6 +669,11 @@ "type": "json_flag", "//": "This item will store the OMT it spawned in the 'spawn_location_omt' var" }, + { + "id": "HINT_THE_LOCATION", + "type": "json_flag", + "//": "Same as PRESERVE_SPAWN_OMT, but aslo shows a snippet of how far the character from the `spawn_location_omt`: 1 OMT or less is `(from here)`, less than 6 OMT is `(from nearby)`, less than 30 OMT is `(from this area)`, anything more is (from far away)" + }, { "id": "PROVIDES_TECHNIQUES", "type": "json_flag", diff --git a/data/json/items/id_cards.json b/data/json/items/id_cards.json index 432f14f31ce93..299c1eadfc629 100644 --- a/data/json/items/id_cards.json +++ b/data/json/items/id_cards.json @@ -89,7 +89,7 @@ "copy-from": "id_science", "name": { "str": "Maintenance: green zone badge" }, "description": "An employee badge for a maintenance worker. The reverse side describes the protocol for using it; this could grant access at green zone card readers.", - "flags": [ "SCIENCE_CARD_MAINTENANCE_GREEN", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_MAINTENANCE_GREEN", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -98,7 +98,7 @@ "copy-from": "id_science", "name": { "str": "Maintenance: ocher zone badge" }, "description": "An employee badge for a maintenance worker. The reverse side describes the protocol for using it; this could grant access at ocher zone card readers.", - "flags": [ "SCIENCE_CARD_MAINTENANCE_YELLOW", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_MAINTENANCE_YELLOW", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -107,7 +107,7 @@ "copy-from": "id_science", "name": { "str": "Maintenance: blue zone badge" }, "description": "An employee badge for a maintenance worker. The reverse side describes the protocol for using it; this could grant access at blue zone card readers.", - "flags": [ "SCIENCE_CARD_MAINTENANCE_BLUE", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_MAINTENANCE_BLUE", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -146,7 +146,7 @@ "copy-from": "id_science", "name": { "str": "Security: yellow zone badge" }, "description": "An employee badge for a security officer. The reverse side describes the protocol for using it; this could grant access at yellow zone card readers.", - "flags": [ "SCIENCE_CARD_SECURITY_YELLOW", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_SECURITY_YELLOW", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -155,7 +155,7 @@ "copy-from": "id_science", "name": { "str": "Security: magenta zone badge" }, "description": "An employee badge for a security officer. The reverse side describes the protocol for using it; this could grant access at magenta zone card readers.", - "flags": [ "SCIENCE_CARD_SECURITY_MAGENTA", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_SECURITY_MAGENTA", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -164,7 +164,7 @@ "copy-from": "id_science", "name": { "str": "Security: black zone badge" }, "description": "An employee badge for a security officer. The reverse side describes the protocol for using it; this could grant access at black zone card readers.", - "flags": [ "SCIENCE_CARD_SECURITY_BLACK", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_SECURITY_BLACK", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -173,7 +173,7 @@ "copy-from": "id_science", "name": { "str": "Researcher: light green zone badge" }, "description": "An employee badge for a research scientist. The reverse side describes the protocol for using it; this could grant access at light green zone card readers.", - "flags": [ "SCIENCE_CARD_MUTAGEN_GREEN", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_MUTAGEN_GREEN", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -182,7 +182,7 @@ "copy-from": "id_science", "name": { "str": "Researcher: pink zone badge" }, "description": "An employee badge for a research scientist. The reverse side describes the protocol for using it; this could grant access at pink zone card readers.", - "flags": [ "SCIENCE_CARD_MUTAGEN_PINK", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_MUTAGEN_PINK", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -191,7 +191,7 @@ "copy-from": "id_science", "name": { "str": "Researcher: cyan zone badge" }, "description": "An employee badge for a research scientist. The reverse side describes the protocol for using it; this could grant access at cyan zone card readers.", - "flags": [ "SCIENCE_CARD_MUTAGEN_CYAN", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_MUTAGEN_CYAN", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -200,7 +200,7 @@ "copy-from": "id_science", "name": { "str": "Doctor: red zone badge" }, "description": "An employee badge for a medical doctor. The reverse side describes the protocol for using it; this could grant access at red zone card readers.", - "flags": [ "SCIENCE_CARD_MEDICAL_RED", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ] + "flags": [ "SCIENCE_CARD_MEDICAL_RED", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ] }, { "type": "GENERIC", @@ -219,7 +219,7 @@ "looks_like": "id_science", "name": { "str": "LIXA ID badge" }, "description": "An ID badge for the LIXA facility, with a photo of an awkwardly smiling scientist on the front. Instructions on the back explain that this will grant you access to the LIXA experiment floor.", - "flags": [ "LIXA_SCIENCE_CARD", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ], + "flags": [ "LIXA_SCIENCE_CARD", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ], "price_postapoc": "2 USD 50 cent", "material": [ "plastic" ], "weight": "3 g", @@ -233,7 +233,7 @@ "looks_like": "id_science", "name": { "str": "defaced LIXA ID badge" }, "description": "An ID badge for the LIXA facility, with a photo of an awkwardly smiling scientist on the front. It is heavily scratched, and there is a line on the back in black marker.", - "flags": [ "LIXA_SCIENCE_CARD", "LIXA_SCIENCE_CARD_2", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ], + "flags": [ "LIXA_SCIENCE_CARD", "LIXA_SCIENCE_CARD_2", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ], "price_postapoc": "2 USD 50 cent", "material": [ "plastic" ], "weight": "3 g", @@ -247,7 +247,14 @@ "looks_like": "id_science", "name": { "str": "LIXA ID badge: Dr. Najma Saed", "str_pl": "LIXA ID badges: Dr. Najma Saed" }, "description": "An ID badge for the LIXA facility. The photo is of a pleasantly smiling woman in a hijab.", - "flags": [ "LIXA_SCIENCE_CARD", "LIXA_SCIENCE_CARD_2", "LIXA_SCIENCE_CARD_3", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ], + "flags": [ + "LIXA_SCIENCE_CARD", + "LIXA_SCIENCE_CARD_2", + "LIXA_SCIENCE_CARD_3", + "PRESERVE_SPAWN_OMT", + "HINT_THE_LOCATION", + "CREDIT_CARD_SHAPED" + ], "price_postapoc": "2 USD 50 cent", "material": [ "plastic" ], "weight": "3 g", @@ -261,7 +268,14 @@ "looks_like": "id_science", "name": { "str": "LIXA ID badge: Dr. Jason Mitchell", "str_pl": "LIXA ID badges: Dr. Jason Mitchell" }, "description": "An ID badge for the LIXA facility. The photo is of a confidently smiling young man.", - "flags": [ "LIXA_SCIENCE_CARD", "LIXA_SCIENCE_CARD_2", "LIXA_SCIENCE_CARD_3", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ], + "flags": [ + "LIXA_SCIENCE_CARD", + "LIXA_SCIENCE_CARD_2", + "LIXA_SCIENCE_CARD_3", + "PRESERVE_SPAWN_OMT", + "HINT_THE_LOCATION", + "CREDIT_CARD_SHAPED" + ], "price_postapoc": "2 USD 50 cent", "material": [ "plastic" ], "weight": "3 g", @@ -275,7 +289,14 @@ "looks_like": "id_science", "name": { "str": "LIXA ID badge: Dr. Kai-Mei Luo", "str_pl": "LIXA ID badges: Dr. Kai-Mei Luo" }, "description": "An ID badge for the LIXA facility. The photo is of an awkwardly smiling woman, who blinked during the picture.", - "flags": [ "LIXA_SCIENCE_CARD", "LIXA_SCIENCE_CARD_2", "LIXA_SCIENCE_CARD_3", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ], + "flags": [ + "LIXA_SCIENCE_CARD", + "LIXA_SCIENCE_CARD_2", + "LIXA_SCIENCE_CARD_3", + "PRESERVE_SPAWN_OMT", + "HINT_THE_LOCATION", + "CREDIT_CARD_SHAPED" + ], "price_postapoc": "2 USD 50 cent", "material": [ "plastic" ], "weight": "3 g", @@ -289,7 +310,14 @@ "looks_like": "id_science", "name": { "str": "LIXA ID badge: Dr. Richard Raimes", "str_pl": "LIXA ID badges: Dr. Richard Raimes" }, "description": "An ID badge for the LIXA facility. The photo is of a gently smiling older man, with kind eyes.", - "flags": [ "LIXA_SCIENCE_CARD", "LIXA_SCIENCE_CARD_2", "LIXA_SCIENCE_CARD_3", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ], + "flags": [ + "LIXA_SCIENCE_CARD", + "LIXA_SCIENCE_CARD_2", + "LIXA_SCIENCE_CARD_3", + "PRESERVE_SPAWN_OMT", + "HINT_THE_LOCATION", + "CREDIT_CARD_SHAPED" + ], "price_postapoc": "2 USD 50 cent", "material": [ "plastic" ], "weight": "3 g", @@ -303,7 +331,7 @@ "looks_like": "id_LIXA_mil", "name": { "str": "LIXA military police badge" }, "description": "An id card bearing the name, rank, and serial number of a soldier stationed at LIXA.", - "flags": [ "LIXA_MILITARY_CARD", "LIXA_SCIENCE_CARD", "PRESERVE_SPAWN_OMT", "CREDIT_CARD_SHAPED" ], + "flags": [ "LIXA_MILITARY_CARD", "LIXA_SCIENCE_CARD", "PRESERVE_SPAWN_OMT", "HINT_THE_LOCATION", "CREDIT_CARD_SHAPED" ], "price_postapoc": "2 USD 50 cent", "material": [ "plastic" ], "weight": "3 g", diff --git a/data/json/items/tool/electronics.json b/data/json/items/tool/electronics.json index 01d3cb467e382..583eb9dd24b6d 100644 --- a/data/json/items/tool/electronics.json +++ b/data/json/items/tool/electronics.json @@ -620,7 +620,17 @@ }, { "type": "link_up", "cable_length": 3, "charge_rate": "20 W" } ], - "flags": [ "WATCH", "ALARMCLOCK", "USE_UPS", "NO_UNLOAD", "NO_RELOAD", "WATER_BREAK", "CALORIES_INTAKE", "ELECTRONIC" ], + "flags": [ + "WATCH", + "ALARMCLOCK", + "USE_UPS", + "NO_UNLOAD", + "NO_RELOAD", + "WATER_BREAK", + "CALORIES_INTAKE", + "ELECTRONIC", + "PRESERVE_SPAWN_OMT" + ], "pocket_data": [ { "pocket_type": "MAGAZINE", "rigid": true, "ammo_restriction": { "battery": 56 } }, { diff --git a/doc/JSON_FLAGS.md b/doc/JSON_FLAGS.md index b174d52dd6a0c..67e2874b96666 100644 --- a/doc/JSON_FLAGS.md +++ b/doc/JSON_FLAGS.md @@ -839,6 +839,7 @@ These flags can be applied via JSON item definition to most items. Not to be co - ```PLANTABLE_SEED``` This item is a seed, and you can plant it. - ```POST_UP``` This item can be placed on terrain/furniture with the WALL flag. - ```PRESERVE_SPAWN_OMT``` This item will store the OMT that it spawns in, in the `spawn_location_omt` item var. +- ```HINT_THE_LOCATION``` if PRESERVE_SPAWN_OMT is used, shows a snippet of how far the character from the `spawn_location_omt`: 1 OMT or less is `(from here)`, less than 6 OMT is `(from nearby)`, less than 30 OMT is `(from this area)`, anything more is (from far away) - ```PROVIDES_TECHNIQUES``` This item will provide martial arts techniques when worn/in the character's inventory, in addition to those provided by the weapon and martial art. - ```PSEUDO``` Used internally to mark items that are referred to in the crafting inventory but are not actually items. They can be used as tools, but not as components. Implies `TRADER_AVOID`. - ```RABBIT``` Food that only player with `RABBIT` threshold mutation can eat. See also `INEDIBLE`. diff --git a/src/item_tname.cpp b/src/item_tname.cpp index d9fd8de7c53bd..3009150d5da43 100644 --- a/src/item_tname.cpp +++ b/src/item_tname.cpp @@ -28,6 +28,7 @@ #include "type_id.h" #include "units.h" +static const flag_id json_flag_HINT_THE_LOCATION( "HINT_THE_LOCATION" ); static const itype_id itype_barrel_small( "barrel_small" ); static const itype_id itype_disassembly( "disassembly" ); @@ -289,7 +290,7 @@ std::string food_traits( item const &it, unsigned int /* quantity */, std::string location_hint( item const &it, unsigned int /* quantity */, segment_bitset const &/* segments */ ) { - if( it.has_var( "spawn_location_omt" ) ) { + if( it.has_flag( json_flag_HINT_THE_LOCATION ) && it.has_var( "spawn_location_omt" ) ) { tripoint_abs_omt loc( it.get_var( "spawn_location_omt", tripoint_abs_omt::zero ) ); tripoint_abs_omt player_loc( coords::project_to( get_map().getglobal( get_avatar().pos_bub() ) ) );