Skip to content

Commit

Permalink
Merge pull request #32869 from esotericist/aura-layers
Browse files Browse the repository at this point in the history
Add personal and outer aura layers, as well as the intangible flag
  • Loading branch information
Rivet-the-Zombie authored Aug 5, 2019
2 parents fec7fb1 + 45428d0 commit 2c5d4f7
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 40 deletions.
31 changes: 27 additions & 4 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
"context": [ "TOOL" ],
"info": "This item can be activated or reloaded from adjacent tile without picking it up."
},
{
"id": "AURA",
"type": "json_flag",
"context": [ "ARMOR", "TOOL_ARMOR" ],
"description": "This item goes in the outer aura layer, intended for metaphysical effects.",
"info": "This is in your <info>outer aura</info>.",
"conflicts": [ "OUTER", "SKINTIGHT", "WAIST", "PERSONAL", "BELTED" ]
},
{
"id": "BAROMETER",
"type": "json_flag",
Expand All @@ -41,7 +49,7 @@
"context": [ "ARMOR", "TOOL_ARMOR" ],
"description": "Layer for backpacks and things worn over outerwear.",
"info": "This gear is <info>strapped</info> onto you.",
"conflicts": [ "OUTER", "SKINTIGHT", "WAIST" ]
"conflicts": [ "OUTER", "SKINTIGHT", "WAIST", "PERSONAL", "AURA" ]
},
{
"id": "BIONIC_NPC_USABLE",
Expand Down Expand Up @@ -275,7 +283,7 @@
"context": [ "ARMOR", "TOOL_ARMOR" ],
"description": "Outer garment layer.",
"info": "This gear is generally <info>worn over</info> clothing.",
"conflicts": [ "BELTED", "SKINTIGHT", "WAIST" ]
"conflicts": [ "BELTED", "SKINTIGHT", "WAIST", "PERSONAL", "AURA" ]
},
{
"id": "OVERSIZE",
Expand All @@ -297,6 +305,14 @@
"info": "This gear <good>reduces</good> the volume of <info>sounds</info> to a safe level.",
"conflicts": [ "DEAF" ]
},
{
"id": "PERSONAL",
"type": "json_flag",
"context": [ "ARMOR", "TOOL_ARMOR" ],
"description": "This item goes in the personal aura layer, intended for metaphysical effects.",
"info": "This is in your <info>personal aura</info>.",
"conflicts": [ "BELTED", "OUTER", "WAIST", "SKINTIGHT", "AURA" ]
},
{
"id": "POCKETS",
"type": "json_flag",
Expand Down Expand Up @@ -356,6 +372,13 @@
"context": [ "ARMOR", "TOOL_ARMOR" ],
"description": "Prevents the player from wielding a weapon two-handed, forcing one-handed use if the weapon permits it."
},
{
"id": "SEMITANGIBLE",
"type": "json_flag",
"context": [ "ARMOR", "TOOL_ARMOR" ],
"description": "Prevents the item from participating in the encumbrance system when worn.",
"info": "It seems <info>partially intangible</info>, and can occupy the same space as other things when worn."
},
{
"id": "SHEATH_KNIFE",
"type": "json_flag",
Expand Down Expand Up @@ -386,7 +409,7 @@
"context": [ "ARMOR", "TOOL_ARMOR" ],
"description": "Undergarment layer.",
"info": "This clothing <info>lies close</info> to the skin.",
"conflicts": [ "BELTED", "OUTER", "WAIST" ]
"conflicts": [ "BELTED", "OUTER", "WAIST", "PERSONAL", "AURA" ]
},
{
"id": "SLOWS_MOVEMENT",
Expand Down Expand Up @@ -448,7 +471,7 @@
"context": [ "ARMOR", "TOOL_ARMOR" ],
"description": "Layer for belts and other things worn on the waist.",
"info": "This gear is worn on or around your <info>waist</info>.",
"conflicts": [ "BELTED", "OUTER", "SKINTIGHT" ]
"conflicts": [ "BELTED", "OUTER", "SKINTIGHT", "PERSONAL", "AURA" ]
},
{
"id": "WATCH",
Expand Down
6 changes: 4 additions & 2 deletions data/mods/Magiclysm/items/ethereal_items.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"bashing": 8,
"symbol": ",",
"color": "light_green",
"flags": [ "LIGHT_15", "LEAK_DAM" ]
"covers": [ "HEAD" ],
"flags": [ "LIGHT_15", "LEAK_DAM", "AURA", "SEMITANGIBLE" ]
},
{
"id": "magic_light",
Expand All @@ -87,7 +88,8 @@
"price": 0,
"symbol": ",",
"color": "light_green",
"flags": [ "LIGHT_5", "LEAK_DAM" ]
"covers": [ "HEAD" ],
"flags": [ "LIGHT_5", "LEAK_DAM", "AURA", "SEMITANGIBLE" ]
},
{
"id": "shield_ice",
Expand Down
3 changes: 3 additions & 0 deletions doc/JSON_FLAGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ Some armor flags, such as `WATCH` and `ALARMCLOCK` are compatible with other ite
- ```ACTIVE_CLOAKING``` While active, drains UPS to provide invisibility.
- ```ALARMCLOCK``` Has an alarm-clock feature.
- ```ALLOWS_NATURAL_ATTACKS``` Doesn't prevent any natural attacks or similar benefits from mutations, fingertip razors, etc., like most items covering the relevant body part would.
- ```AURA``` This item goes in the outer aura layer, intended for metaphysical effects.
- ```BAROMETER``` This gear is equipped with an accurate barometer (which is used to measure atmospheric pressure).
- ```BELTED``` Layer for backpacks and things worn over outerwear.
- ```BLIND``` Blinds the wearer while worn, and provides nominal protection v. flashbang flashes.
Expand All @@ -246,6 +247,7 @@ Some armor flags, such as `WATCH` and `ALARMCLOCK` are compatible with other ite
- ```OUTER``` Outer garment layer.
- ```OVERSIZE``` Can always be worn no matter encumbrance/mutations/bionics/etc., but prevents any other clothing being worn over this.
- ```PARTIAL_DEAF``` Reduces the volume of sounds to a safe level.
- ```PERSONAL``` This item goes in the personal aura layer, intended for metaphysical effects.
- ```POCKETS``` Increases warmth for hands if the player's hands are cold and the player is wielding nothing.
- ```PSYSHIELD_PARTIAL``` 25% chance to protect against fear_paralyze monster attack when worn.
- ```RAD_PROOF``` This piece of clothing completely protects you from radiation.
Expand All @@ -256,6 +258,7 @@ Some armor flags, such as `WATCH` and `ALARMCLOCK` are compatible with other ite
- ```ROLLER_ONE``` A less stable and slower version of ROLLER_QUAD, still allows the player to move faster than walking speed.
- ```ROLLER_QUAD```The medium choice between ROLLER_INLINE and ROLLER_ONE, while it is more stable, and moves faster, it also has a harsher non-flat terrain penalty then ROLLER_ONE.
- ```ROLLER_INLINE``` Faster, but less stable overall, the penalty for non-flat terrain is even harsher.
- ```SEMITANGIBLE``` Prevents the item from participating in the encumbrance system when worn.
- ```SKINTIGHT``` Undergarment layer.
- ```SLOWS_MOVEMENT``` This piece of clothing multiplies move cost by 1.1.
- ```SLOWS_THIRST``` This piece of clothing multiplies the rate at which the player grows thirsty by 0.70.
Expand Down
17 changes: 14 additions & 3 deletions src/armor_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ item_penalties get_item_penalties( std::list<item>::const_iterator worn_item_it,
}
const int num_items = std::count_if( c.worn.begin(), c.worn.end(),
[layer, bp]( const item & i ) {
return i.get_layer() == layer && i.covers( bp );
return i.get_layer() == layer && i.covers( bp ) && !i.has_flag( "SEMITANGIBLE" );
} );
if( num_items > 1 ) {
body_parts_with_stacking_penalty.push_back( bp );
Expand Down Expand Up @@ -179,7 +179,9 @@ void draw_mid_pane( const catacurses::window &w_sort_middle,
if( !penalties.body_parts_with_stacking_penalty.empty() ) {
std::string layer_description = [&]() {
switch( worn_item_it->get_layer() ) {
case UNDERWEAR:
case PERSONAL_LAYER:
return _( "in your <color_light_blue>personal aura</color>" );
case UNDERWEAR_LAYER:
return _( "<color_light_blue>close to your skin</color>" );
case REGULAR_LAYER:
return _( "of <color_light_blue>normal</color> clothing" );
Expand All @@ -189,6 +191,8 @@ void draw_mid_pane( const catacurses::window &w_sort_middle,
return _( "of <color_light_blue>outer</color> clothing" );
case BELTED_LAYER:
return _( "<color_light_blue>strapped</color> to you" );
case AURA_LAYER:
return _( "an <color_light_blue>aura</color> around you" );
default:
debugmsg( "Unexpected layer" );
return "";
Expand Down Expand Up @@ -243,14 +247,18 @@ std::string clothing_layer( const item &worn_item )
{
std::string layer;

if( worn_item.has_flag( "SKINTIGHT" ) ) {
if( worn_item.has_flag( "PERSONAL" ) ) {
layer = _( "This is in your personal aura." );
} else if( worn_item.has_flag( "SKINTIGHT" ) ) {
layer = _( "This is worn next to the skin." );
} else if( worn_item.has_flag( "WAIST" ) ) {
layer = _( "This is worn on or around your waist." );
} else if( worn_item.has_flag( "OUTER" ) ) {
layer = _( "This is worn over your other clothes." );
} else if( worn_item.has_flag( "BELTED" ) ) {
layer = _( "This is strapped onto you." );
} else if( worn_item.has_flag( "AURA" ) ) {
layer = _( "This is an aura around you." );
}

return layer;
Expand Down Expand Up @@ -329,6 +337,9 @@ std::vector<std::string> clothing_flags_description( const item &worn_item )
if( worn_item.has_flag( "SWIM_GOGGLES" ) ) {
description_stack.push_back( _( "It helps you to see clearly underwater." ) );
}
if( worn_item.has_flag( "SEMITANGIBLE" ) ) {
description_stack.push_back( _( "It can occupy the same space as other things." ) );
}

return description_stack;
}
Expand Down
22 changes: 21 additions & 1 deletion src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,16 @@ static void layer_item( std::array<encumbrance_data, num_bp> &vals,
// For the purposes of layering penalty, set a min of 2 and a max of 10 per item.
int layering_encumbrance = std::min( 10, std::max( 2, encumber_val ) );

/*
* Setting layering_encumbrance to 0 at this point makes the item cease to exist
* for the purposes of the layer penalty system. (normally an item has a minimum
* layering_encumbrance of 2 )
*/
if( it.has_flag( "SEMITANGIBLE" ) ) {
encumber_val = 0;
layering_encumbrance = 0;
}

const int armorenc = !power_armor || !it.is_power_armor() ?
encumber_val : std::max( 0, encumber_val - 40 );

Expand Down Expand Up @@ -1750,6 +1760,16 @@ void layer_details::reset()
// So we add them together and then subtract out the highest.
int layer_details::layer( const int encumbrance )
{
/*
* We should only get to this point with an encumbrance value of 0
* if the item is 'semitangible'. A normal item has a minimum of
* 2 encumbrance for layer penalty purposes.
* ( even if normally its encumbrance is 0 )
*/
if( encumbrance == 0 ) {
return total; // skip over the other logic because this item doesn't count
}

pieces.push_back( encumbrance );

int current = total;
Expand Down Expand Up @@ -1811,7 +1831,7 @@ void Character::item_encumb( std::array<encumbrance_data, num_bp> &vals,
// items
std::array<layer_level, num_bp> highest_layer_so_far;
std::fill( highest_layer_so_far.begin(), highest_layer_so_far.end(),
UNDERWEAR );
PERSONAL_LAYER );

const bool power_armored = is_wearing_active_power_armor();
for( auto w_it = worn.begin(); w_it != worn.end(); ++w_it ) {
Expand Down
4 changes: 2 additions & 2 deletions src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ struct encumbrance_data {
std::array<layer_details, static_cast<size_t>( layer_level::MAX_CLOTHING_LAYER )>
layer_penalty_details;

void layer( const layer_level level, const int emcumbrance ) {
layer_penalty += layer_penalty_details[static_cast<size_t>( level )].layer( emcumbrance );
void layer( const layer_level level, const int encumbrance ) {
layer_penalty += layer_penalty_details[static_cast<size_t>( level )].layer( encumbrance );
}

void reset() {
Expand Down
6 changes: 5 additions & 1 deletion src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ enum liquid_target_type { LTT_CONTAINER = 1, LTT_VEHICLE = 2, LTT_MAP = 3, LTT_M
* when starting the game.
*/
enum layer_level {
/* "Personal effects" layer, corresponds to PERSONAL flag */
PERSONAL_LAYER = 0,
/* "Close to skin" layer, corresponds to SKINTIGHT flag. */
UNDERWEAR = 0,
UNDERWEAR_LAYER,
/* "Normal" layer, default if no flags set */
REGULAR_LAYER,
/* "Waist" layer, corresponds to WAIST flag. */
Expand All @@ -175,6 +177,8 @@ enum layer_level {
OUTER_LAYER,
/* "Strapped" layer, corresponds to BELTED flag */
BELTED_LAYER,
/* "Aura" layer, corresponds to AURA flag */
AURA_LAYER,
/* Not a valid layer; used for C-style iteration through this enum */
MAX_CLOTHING_LAYER
};
Expand Down
14 changes: 11 additions & 3 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,14 +1925,18 @@ std::string item::info( std::vector<iteminfo> &info, const iteminfo_query *parts
if( parts->test( iteminfo_parts::ARMOR_LAYER ) && covers_anything ) {
temp1.str( "" );
temp1 << _( "Layer: " );
if( has_flag( "SKINTIGHT" ) ) {
if( has_flag( "PERSONAL" ) ) {
temp1 << _( "<stat>Personal aura</stat>. " );
} else if( has_flag( "SKINTIGHT" ) ) {
temp1 << _( "<stat>Close to skin</stat>. " );
} else if( has_flag( "BELTED" ) ) {
temp1 << _( "<stat>Strapped</stat>. " );
} else if( has_flag( "OUTER" ) ) {
temp1 << _( "<stat>Outer</stat>. " );
} else if( has_flag( "WAIST" ) ) {
temp1 << _( "<stat>Waist</stat>. " );
} else if( has_flag( "AURA" ) ) {
temp1 << _( "<stat>Outer aura</stat>. " );
} else {
temp1 << _( "<stat>Normal</stat>. " );
}
Expand Down Expand Up @@ -4397,14 +4401,18 @@ layer_level item::get_layer() const
return type->layer;
}

if( has_flag( "SKINTIGHT" ) ) {
return UNDERWEAR;
if( has_flag( "PERSONAL" ) ) {
return PERSONAL_LAYER;
} else if( has_flag( "SKINTIGHT" ) ) {
return UNDERWEAR_LAYER;
} else if( has_flag( "WAIST" ) ) {
return WAIST_LAYER;
} else if( has_flag( "OUTER" ) ) {
return OUTER_LAYER;
} else if( has_flag( "BELTED" ) ) {
return BELTED_LAYER;
} else if( has_flag( "AURA" ) ) {
return AURA_LAYER;
} else {
return REGULAR_LAYER;
}
Expand Down
8 changes: 6 additions & 2 deletions src/item_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,18 @@ void Item_factory::finalize_pre( itype &obj )
obj.drop_action.get_actor_ptr()->finalize( obj.id );
}

if( obj.item_tags.count( "SKINTIGHT" ) ) {
obj.layer = UNDERWEAR;
if( obj.item_tags.count( "PERSONAL" ) ) {
obj.layer = PERSONAL_LAYER;
} else if( obj.item_tags.count( "SKINTIGHT" ) ) {
obj.layer = UNDERWEAR_LAYER;
} else if( obj.item_tags.count( "WAIST" ) ) {
obj.layer = WAIST_LAYER;
} else if( obj.item_tags.count( "OUTER" ) ) {
obj.layer = OUTER_LAYER;
} else if( obj.item_tags.count( "BELTED" ) ) {
obj.layer = BELTED_LAYER;
} else if( obj.item_tags.count( "AURA" ) ) {
obj.layer = AURA_LAYER;
} else {
obj.layer = REGULAR_LAYER;
}
Expand Down
Loading

0 comments on commit 2c5d4f7

Please sign in to comment.