Skip to content

Commit

Permalink
get_armor_type
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman committed Apr 27, 2020
1 parent e650787 commit fb8c5fe
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6196,10 +6196,10 @@ bool Character::is_immune_field( const field_type_id &fid ) const
get_env_resist( bodypart_id( "foot_r" ) ) >= 15 &&
get_env_resist( bodypart_id( "leg_l" ) ) >= 15 &&
get_env_resist( bodypart_id( "leg_r" ) ) >= 15 &&
get_armor_type( DT_ACID, bp_foot_l ) >= 5 &&
get_armor_type( DT_ACID, bp_foot_r ) >= 5 &&
get_armor_type( DT_ACID, bp_leg_l ) >= 5 &&
get_armor_type( DT_ACID, bp_leg_r ) >= 5;
get_armor_type( DT_ACID, bodypart_id( "foot_l" ) ) >= 5 &&
get_armor_type( DT_ACID, bodypart_id( "foot_r" ) ) >= 5 &&
get_armor_type( DT_ACID, bodypart_id( "leg_l" ) ) >= 5 &&
get_armor_type( DT_ACID, bodypart_id( "leg_r" ) ) >= 5;
}
// If we haven't found immunity yet fall up to the next level
return Creature::is_immune_field( fid );
Expand Down Expand Up @@ -7090,30 +7090,30 @@ int Character::get_armor_cut( bodypart_id bp ) const
return get_armor_cut_base( bp ) + armor_cut_bonus;
}

int Character::get_armor_type( damage_type dt, body_part bp ) const
int Character::get_armor_type( damage_type dt, bodypart_id bp ) const
{
switch( dt ) {
case DT_TRUE:
case DT_BIOLOGICAL:
return 0;
case DT_BASH:
return get_armor_bash( convert_bp( bp ).id() );
return get_armor_bash( bp );
case DT_CUT:
return get_armor_cut( convert_bp( bp ).id() );
return get_armor_cut( bp );
case DT_STAB:
return get_armor_cut( convert_bp( bp ).id() ) * 0.8f;
return get_armor_cut( bp ) * 0.8f;
case DT_ACID:
case DT_HEAT:
case DT_COLD:
case DT_ELECTRIC: {
int ret = 0;
for( auto &i : worn ) {
if( i.covers( bp ) ) {
if( i.covers( bp->token ) ) {
ret += i.damage_resist( dt );
}
}

ret += mutation_armor( bp, dt );
ret += mutation_armor( bp->token, dt );
return ret;
}
case DT_NULL:
Expand Down Expand Up @@ -7189,7 +7189,7 @@ int Character::get_env_resist( bodypart_id bp ) const

int Character::get_armor_acid( body_part bp ) const
{
return get_armor_type( DT_ACID, bp );
return get_armor_type( DT_ACID, convert_bp( bp ).id() );
}

int Character::get_stim() const
Expand Down Expand Up @@ -8329,7 +8329,7 @@ float Character::bionic_armor_bonus( body_part bp, damage_type dt ) const

int Character::get_armor_fire( body_part bp ) const
{
return get_armor_type( DT_HEAT, bp );
return get_armor_type( DT_HEAT, convert_bp( bp ).id() );
}

void Character::did_hit( Creature &target )
Expand Down
2 changes: 1 addition & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ class Character : public Creature, public visitable<Character>
/** Returns overall acid resistance for the body part */
int get_armor_acid( body_part bp ) const;
/** Returns overall resistance to given type on the bod part */
int get_armor_type( damage_type dt, body_part bp ) const override;
int get_armor_type( damage_type dt, bodypart_id bp ) const override;

int get_stim() const;
void set_stim( int new_stim );
Expand Down
2 changes: 1 addition & 1 deletion src/creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ class Creature
virtual int get_armor_bash_bonus() const;
virtual int get_armor_cut_bonus() const;

virtual int get_armor_type( damage_type dt, body_part bp ) const = 0;
virtual int get_armor_type( damage_type dt, bodypart_id bp ) const = 0;

virtual float get_dodge() const;
virtual float get_melee() const = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/map_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int map::burn_body_part( player &u, field_entry &cur, body_part bp, const int sc
const int intensity = cur.get_field_intensity();
const int damage = rng( 1, scale + intensity );
// A bit ugly, but better than being annoyed by acid when in hazmat
if( u.get_armor_type( DT_ACID, bp ) < damage ) {
if( u.get_armor_type( DT_ACID, convert_bp( bp ) ) < damage ) {
const dealt_damage_instance ddi = u.deal_damage( nullptr, convert_bp( bp ).id(),
damage_instance( DT_ACID, damage ) );
total_damage += ddi.total_damage();
Expand Down Expand Up @@ -1814,7 +1814,7 @@ void map::monster_in_field( monster &z )
if( z.flies() ) {
dam -= 15;
}
dam -= z.get_armor_type( DT_HEAT, bp_torso );
dam -= z.get_armor_type( DT_HEAT, bodypart_id("torso") );

if( cur.get_field_intensity() == 1 ) {
dam += rng( 2, 6 );
Expand Down
8 changes: 4 additions & 4 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ int monster::get_armor_bash( bodypart_id bp ) const
return static_cast<int>( type->armor_bash ) + armor_bash_bonus + get_worn_armor_val( DT_BASH );
}

int monster::get_armor_type( damage_type dt, body_part bp ) const
int monster::get_armor_type( damage_type dt, bodypart_id bp ) const
{
int worn_armor = get_worn_armor_val( dt );

Expand All @@ -1829,9 +1829,9 @@ int monster::get_armor_type( damage_type dt, body_part bp ) const
case DT_BIOLOGICAL:
return 0;
case DT_BASH:
return get_armor_bash( convert_bp( bp ).id() );
return get_armor_bash( bp );
case DT_CUT:
return get_armor_cut( convert_bp( bp ).id() );
return get_armor_cut( bp );
case DT_ACID:
return worn_armor + static_cast<int>( type->armor_acid );
case DT_STAB:
Expand Down Expand Up @@ -2421,7 +2421,7 @@ void monster::process_one_effect( effect &it, bool is_new )
dam = rng( 5, 10 );
}

dam -= get_armor_type( DT_HEAT, bp_torso );
dam -= get_armor_type( DT_HEAT, bodypart_id( "torso" ) );
if( dam > 0 ) {
apply_damage( nullptr, bodypart_id( "torso" ), dam );
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class monster : public Creature
int get_worn_armor_val( damage_type dt ) const;
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;
int get_armor_type( damage_type dt, bodypart_id bp ) const override;

float get_hit_base() const override;
float get_dodge_base() const override;
Expand Down

0 comments on commit fb8c5fe

Please sign in to comment.