Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pockets that can let item inherit flags #57050

Merged
merged 7 commits into from
May 1, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"max_contains_volume": "10 L",
"max_contains_weight": "80 kg",
"flag_restriction": [ "EXO_TORSO_PLATE" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -55,6 +56,7 @@
"max_contains_volume": "2 L",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_MEDIUM_GADGET", "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -65,6 +67,7 @@
"max_contains_volume": "1500 ml",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -75,6 +78,7 @@
"max_contains_volume": "1500 ml",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -85,6 +89,7 @@
"max_contains_volume": "25 L",
"max_contains_weight": "140 kg",
"flag_restriction": [ "EXO_PSU", "EXO_LARGE_GADGET", "EXO_MEDIUM_GADGET", "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -96,6 +101,7 @@
"max_contains_volume": "12 L",
"max_contains_weight": "80 kg",
"flag_restriction": [ "EXO_ARM_PLATE" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -106,6 +112,7 @@
"max_contains_volume": "2 L",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_MEDIUM_GADGET", "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -116,6 +123,7 @@
"max_contains_volume": "2 L",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_MEDIUM_GADGET", "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -126,6 +134,7 @@
"max_contains_volume": "1500 ml",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -136,6 +145,7 @@
"max_contains_volume": "1500 ml",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -147,6 +157,7 @@
"max_contains_volume": "12 L",
"max_contains_weight": "80 kg",
"flag_restriction": [ "EXO_LEG_PLATE" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -157,6 +168,7 @@
"max_contains_volume": "2 L",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_MEDIUM_GADGET", "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -167,6 +179,7 @@
"max_contains_volume": "2 L",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_MEDIUM_GADGET", "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -177,6 +190,7 @@
"max_contains_volume": "1500 ml",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
},
{
Expand All @@ -187,6 +201,7 @@
"max_contains_volume": "1500 ml",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_SMALL_GADGET" ],
"inherits_flags": true,
"moves": 60
}
],
Expand Down Expand Up @@ -258,6 +273,7 @@
"max_contains_volume": "2 L",
"max_contains_weight": "5 kg",
"flag_restriction": [ "EXO_HELMET_GADGET" ],
"inherits_flags": true,
"moves": 60
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,21 @@
"type": "transform"
}
},
{
"id": "exo_lense_module",
"type": "TOOL",
"name": { "str": "exosuit multi lense zoom module" },
"description": "A series of strangely shaped hexagonal lenses that flutter about inside your helmet. As the lenses shift things around you stay perfectly in focus no matter your eyesight or distance. It can be mounted to an exosuit helmet.",
"weight": "500 g",
"volume": "250 ml",
"price": "10 kUSD",
"to_hit": -2,
"bashing": 6,
"material": [ "lvl4ballisticglass", "qt_steel" ],
"symbol": "(",
"color": "yellow",
"flags": [ "CANT_WEAR", "FIX_NEARSIGHT", "FIX_FARSIGHT", "ZOOM", "EXO_HELMET_GADGET" ]
},
{
"id": "exo_flashlight",
"type": "TOOL_ARMOR",
Expand Down
12 changes: 12 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6877,6 +6877,18 @@ bool item::has_flag( const flag_id &f ) const
}
}

// check flags from items in inherit pockets
for( const item_pocket *pocket : contents.get_all_contained_pockets().value() ) {
bombasticSlacks marked this conversation as resolved.
Show resolved Hide resolved
// if the pocket inherits flags
if( pocket->inherits_flags() ) {
for( const item *e : pocket->all_items_top() ) {
if( e->has_flag( f ) ) {
return true;
}
}
}
}

// other item type flags
ret = type->has_flag( f );
if( ret ) {
Expand Down
6 changes: 6 additions & 0 deletions src/item_pocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void pocket_data::load( const JsonObject &jo )
optional( jo, was_loaded, "rigid", rigid, false );
optional( jo, was_loaded, "holster", holster );
optional( jo, was_loaded, "ablative", ablative );
optional( jo, was_loaded, "inherits_flags", inherits_flags );
// if ablative also flag as a holster so it only holds 1 item
if( ablative ) {
holster = true;
Expand Down Expand Up @@ -1768,6 +1769,11 @@ bool item_pocket::airtight() const
return data->airtight;
}

bool item_pocket::inherits_flags() const
{
return data->inherits_flags;
}

bool item_pocket::allows_speedloader( const itype_id &speedloader_id ) const
{
if( data->allowed_speedloaders.empty() ) {
Expand Down
3 changes: 3 additions & 0 deletions src/item_pocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class item_pocket
bool rigid() const;
bool watertight() const;
bool airtight() const;
bool inherits_flags() const;
// is this speedloader compatible with this pocket (if any speedloaders are whitelisted)
bool allows_speedloader( const itype_id &speedloader_id ) const;

Expand Down Expand Up @@ -479,6 +480,8 @@ class pocket_data
bool airtight = false;
// the pocket will spill its contents if placed in another container
bool open_container = false;
// items in this pocket pass their flags to the parent item
bool inherits_flags = false;

// a description of the pocket
translation description;
Expand Down