Skip to content

Commit

Permalink
split HINT_THE_LOCATION from PRESERVE_SPAWN_OMT flag
Browse files Browse the repository at this point in the history
  • Loading branch information
GuardianDll committed Nov 27, 2024
1 parent ad13310 commit 920e35d
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 22 deletions.
5 changes: 5 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
62 changes: 45 additions & 17 deletions data/json/items/id_cards.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
12 changes: 11 additions & 1 deletion data/json/items/tool/electronics.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
{
Expand Down
2 changes: 1 addition & 1 deletion doc/EXAMINE.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Whether or not to remove hostile monsters with the `ID_CARD_DESPAWN` flag.
#### `omt_allowed_radius`
Optional, defaults to infinity.
Integer (0 or greater).
For cards with the `PRESERVE_SPAWN_OMT` flag, how many overmap tiles away a card can spawn and be accepted for this cardreader.
For cards with the `PRESERVE_SPAWN_OMT` / `HINT_THE_LOCATION` flag, how many overmap tiles away a card can spawn and be accepted for this cardreader.
For cards without the flag, this field is ignored.

#### `mapgen_id`
Expand Down
1 change: 1 addition & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,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``` Same as PRESERVE_SPAWN_OMT, but also 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`.
Expand Down
3 changes: 2 additions & 1 deletion src/item_tname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "type_id.h"
#include "units.h"

static const flag_id flag_HINT_THE_LOCATION( "HINT_THE_LOCATION" );

static const itype_id itype_barrel_small( "barrel_small" );
static const itype_id itype_disassembly( "disassembly" );
Expand Down Expand Up @@ -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(flag_HINT_THE_LOCATION) && it.has_var( "spawn_location_omt" ) ) {
tripoint_abs_omt loc( it.get_var( "spawn_location_omt", tripoint::zero ) );
tripoint_abs_omt player_loc( coords::project_to<coords::omt>( get_map().getglobal(
get_avatar().pos_bub() ) ) );
Expand Down
7 changes: 5 additions & 2 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ static const efftype_id effect_pet( "pet" );
static const field_type_str_id field_fd_clairvoyant( "fd_clairvoyant" );

static const flag_id json_flag_AVATAR_ONLY( "AVATAR_ONLY" );
static const flag_id json_flag_HINT_THE_LOCATION( "HINT_THE_LOCATION" );
static const flag_id json_flag_LEVITATION( "LEVITATION" );
static const flag_id json_flag_PRESERVE_SPAWN_OMT( "PRESERVE_SPAWN_OMT" );
static const flag_id json_flag_PROXIMITY( "PROXIMITY" );
Expand Down Expand Up @@ -5588,12 +5589,14 @@ item &map::add_item( const tripoint_bub_ms &p, item new_item, int copies )
coords::project_to<coords::omt>( getglobal( p ) ).raw() );
}

if( new_item.has_flag( json_flag_PRESERVE_SPAWN_OMT ) &&
if( ( new_item.has_flag( json_flag_PRESERVE_SPAWN_OMT ) ||
new_item.has_flag( json_flag_HINT_THE_LOCATION ) ) &&
!new_item.has_var( "spawn_location_omt" ) ) {
new_item.set_var( "spawn_location_omt", coords::project_to<coords::omt>( getglobal( p ) ).raw() );
}
for( item *const it : new_item.all_items_top( pocket_type::CONTAINER ) ) {
if( it->has_flag( json_flag_PRESERVE_SPAWN_OMT ) &&
if( ( it->has_flag( json_flag_PRESERVE_SPAWN_OMT ) ||
it->has_flag( json_flag_HINT_THE_LOCATION ) ) &&
!it->has_var( "spawn_location_omt" ) ) {
it->set_var( "spawn_location_omt", coords::project_to<coords::omt>( getglobal( p ) ).raw() );
}
Expand Down

0 comments on commit 920e35d

Please sign in to comment.