Skip to content

Commit

Permalink
get_armor_cut
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Apr 27, 2020
1 parent 7bcf07a commit cfd2efc
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7085,9 +7085,9 @@ int Character::get_armor_bash( bodypart_id bp ) const
return get_armor_bash_base( bp->token ) + armor_bash_bonus;
}

int Character::get_armor_cut( body_part bp ) const
int Character::get_armor_cut( bodypart_id bp ) const
{
return get_armor_cut_base( bp ) + armor_cut_bonus;
return get_armor_cut_base( bp->token ) + armor_cut_bonus;
}

int Character::get_armor_type( damage_type dt, body_part bp ) const
Expand All @@ -7099,9 +7099,9 @@ int Character::get_armor_type( damage_type dt, body_part bp ) const
case DT_BASH:
return get_armor_bash( convert_bp( bp ).id() );
case DT_CUT:
return get_armor_cut( bp );
return get_armor_cut( convert_bp( bp ).id() );
case DT_STAB:
return get_armor_cut( bp ) * 0.8f;
return get_armor_cut( convert_bp( bp ).id() ) * 0.8f;
case DT_ACID:
case DT_HEAT:
case DT_COLD:
Expand Down
2 changes: 1 addition & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ class Character : public Creature, public visitable<Character>
/** Returns overall bashing resistance for the body_part */
int get_armor_bash( bodypart_id bp ) const override;
/** Returns overall cutting resistance for the body_part */
int get_armor_cut( body_part bp ) const override;
int get_armor_cut( bodypart_id bp ) const override;
/** Returns bashing resistance from the creature and armor only */
int get_armor_bash_base( body_part bp ) const override;
/** Returns cutting resistance from the creature and armor only */
Expand Down
2 changes: 1 addition & 1 deletion src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ int Creature::get_armor_bash( bodypart_id ) const
{
return armor_bash_bonus;
}
int Creature::get_armor_cut( body_part ) const
int Creature::get_armor_cut( bodypart_id ) const
{
return armor_cut_bonus;
}
Expand Down
2 changes: 1 addition & 1 deletion src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ class Creature
virtual int get_env_resist( bodypart_id bp ) const;

virtual int get_armor_bash( bodypart_id bp ) const;
virtual int get_armor_cut( body_part bp ) const;
virtual int get_armor_cut( bodypart_id bp ) const;
virtual int get_armor_bash_base( body_part bp ) const;
virtual int get_armor_cut_base( body_part bp ) const;
virtual int get_armor_bash_bonus() const;
Expand Down
9 changes: 5 additions & 4 deletions src/map_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,18 +1619,19 @@ void map::player_in_field( player &u )
const int intensity = cur.get_field_intensity();
// Bees will try to sting you in random body parts, up to 8 times.
for( int i = 0; i < rng( 1, 7 ); i++ ) {
body_part bp = random_body_part();
bodypart_id bp = u.get_random_body_part();
int sum_cover = 0;
for( const item &i : u.worn ) {
if( i.covers( bp ) ) {
if( i.covers( bp->token ) ) {
sum_cover += i.get_coverage();
}
}
// Get stung if [clothing on a body part isn't thick enough (like t-shirt) OR clothing covers less than 100% of body part]
// AND clothing on affected body part has low environmental protection value
if( ( u.get_armor_cut( bp ) <= 1 || ( sum_cover < 100 && x_in_y( 100 - sum_cover, 100 ) ) ) &&
u.add_env_effect( effect_stung, bp, intensity, 9_minutes ) ) {
u.add_msg_if_player( m_bad, _( "The bees sting you in %s!" ), body_part_name_accusative( bp ) );
u.add_env_effect( effect_stung, bp->token, intensity, 9_minutes ) ) {
u.add_msg_if_player( m_bad, _( "The bees sting you in %s!" ),
body_part_name_accusative( bp->token ) );
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/monattack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2171,11 +2171,11 @@ bool mattack::dermatik( monster *z )
}

// Can the bug penetrate our armor?
body_part targeted = target->get_random_body_part()->token;
const bodypart_id targeted = target->get_random_body_part();
if( 4 < g->u.get_armor_cut( targeted ) / 3 ) {
//~ 1$s monster name(dermatik), 2$s bodypart name in accusative.
target->add_msg_if_player( _( "The %1$s lands on your %2$s, but can't penetrate your armor." ),
z->name(), body_part_name_accusative( targeted ) );
z->name(), body_part_name_accusative( targeted->token ) );
z->moves -= 150; // Attempted laying takes a while
return true;
}
Expand All @@ -2185,9 +2185,9 @@ bool mattack::dermatik( monster *z )
//~ 1$s monster name(dermatik), 2$s bodypart name in accusative.
target->add_msg_if_player( m_bad, _( "The %1$s sinks its ovipositor into your %2$s!" ),
z->name(),
body_part_name_accusative( targeted ) );
body_part_name_accusative( targeted->token ) );
if( !foe->has_trait( trait_PARAIMMUNE ) || !foe->has_trait( trait_ACIDBLOOD ) ) {
foe->add_effect( effect_dermatik, 1_turns, targeted, true );
foe->add_effect( effect_dermatik, 1_turns, targeted->token, true );
g->events().send<event_type::dermatik_eggs_injected>( foe->getID() );
}

Expand Down
6 changes: 4 additions & 2 deletions src/monmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,10 +1546,12 @@ bool monster::move_to( const tripoint &p, bool force, bool step_on_critter,
if( type->size != MS_TINY && on_ground ) {
const int sharp_damage = rng( 1, 10 );
const int rough_damage = rng( 1, 2 );
if( g->m.has_flag( "SHARP", pos() ) && !one_in( 4 ) && get_armor_cut( bp_torso ) < sharp_damage ) {
if( g->m.has_flag( "SHARP", pos() ) && !one_in( 4 ) &&
get_armor_cut( bodypart_id( "torso" ) ) < sharp_damage ) {
apply_damage( nullptr, bodypart_id( "torso" ), sharp_damage );
}
if( g->m.has_flag( "ROUGH", pos() ) && one_in( 6 ) && get_armor_cut( bp_torso ) < rough_damage ) {
if( g->m.has_flag( "ROUGH", pos() ) && one_in( 6 ) &&
get_armor_cut( bodypart_id( "torso" ) ) < rough_damage ) {
apply_damage( nullptr, bodypart_id( "torso" ), rough_damage );
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,7 @@ int monster::get_worn_armor_val( damage_type dt ) const
return 0;
}

int monster::get_armor_cut( body_part bp ) const
int monster::get_armor_cut( bodypart_id bp ) const
{
( void ) bp;
// TODO: Add support for worn armor?
Expand All @@ -1831,7 +1831,7 @@ int monster::get_armor_type( damage_type dt, body_part bp ) const
case DT_BASH:
return get_armor_bash( convert_bp( bp ).id() );
case DT_CUT:
return get_armor_cut( bp );
return get_armor_cut( convert_bp( bp ).id() );
case DT_ACID:
return worn_armor + static_cast<int>( type->armor_acid );
case DT_STAB:
Expand Down Expand Up @@ -1968,7 +1968,7 @@ int monster::impact( const int force, const tripoint &p )
const float mod = fall_damage_mod();
int total_dealt = 0;
if( g->m.has_flag( TFLAG_SHARP, p ) ) {
const int cut_damage = std::max( 0.0f, 10 * mod - get_armor_cut( bp_torso ) );
const int cut_damage = std::max( 0.0f, 10 * mod - get_armor_cut( bodypart_id( "torso" ) ) );
apply_damage( nullptr, bodypart_id( "torso" ), cut_damage );
total_dealt += 10 * mod;
}
Expand Down
2 changes: 1 addition & 1 deletion src/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class monster : public Creature
float speed_rating() const override;

int get_worn_armor_val( damage_type dt ) const;
int get_armor_cut( body_part bp ) const override; // Natural armor, plus any worn armor
int get_armor_cut( bodypart_id bp ) const override; // Natural armor, plus any worn armor
int get_armor_bash( bodypart_id bp ) const override; // Natural armor, plus any worn armor
int get_armor_type( damage_type dt, body_part bp ) const override;

Expand Down
2 changes: 1 addition & 1 deletion src/vehicle_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ veh_collision vehicle::part_collision( int part, const tripoint &p,
ph->hitall( dam, 40, driver );
} else {
const int armor = part_flag( ret.part, "SHARP" ) ?
critter->get_armor_cut( bp_torso ) :
critter->get_armor_cut( bodypart_id( "torso" ) ) :
critter->get_armor_bash( bodypart_id( "torso" ) );
dam = std::max( 0, dam - armor );
critter->apply_damage( driver, bodypart_id( "torso" ), dam );
Expand Down

0 comments on commit cfd2efc

Please sign in to comment.