diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index b44978b21e92..7cb3c474fb0c 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -246,9 +246,9 @@ static const quality_id qual_LOCKPICK( "LOCKPICK" ); static const species_id HUMAN( "HUMAN" ); static const species_id ZOMBIE( "ZOMBIE" ); -static const std::string trait_flag_CANNIBAL( "CANNIBAL" ); -static const std::string trait_flag_PSYCHOPATH( "PSYCHOPATH" ); -static const std::string trait_flag_SAPIOVORE( "SAPIOVORE" ); +static const trait_flag_str_id trait_flag_CANNIBAL( "CANNIBAL" ); +static const trait_flag_str_id trait_flag_PSYCHOPATH( "PSYCHOPATH" ); +static const trait_flag_str_id trait_flag_SAPIOVORE( "SAPIOVORE" ); static const bionic_id bio_ears( "bio_ears" ); static const bionic_id bio_painkiller( "bio_painkiller" ); diff --git a/src/character.cpp b/src/character.cpp index cb2dec4555c6..9e950664411d 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -3445,16 +3445,16 @@ void Character::practice( const skill_id &id, int amount, int cap, bool suppress amount = 0; } } - if( has_trait_flag( "PRED2" ) && skill.is_combat_skill() ) { + if( has_trait_flag( trait_flag_str_id( "PRED2" ) ) && skill.is_combat_skill() ) { if( one_in( 3 ) ) { amount *= 2; } } - if( has_trait_flag( "PRED3" ) && skill.is_combat_skill() ) { + if( has_trait_flag( trait_flag_str_id( "PRED3" ) ) && skill.is_combat_skill() ) { amount *= 2; } - if( has_trait_flag( "PRED4" ) && skill.is_combat_skill() ) { + if( has_trait_flag( trait_flag_str_id( "PRED4" ) ) && skill.is_combat_skill() ) { amount *= 3; } @@ -3488,7 +3488,7 @@ void Character::practice( const skill_id &id, int amount, int cap, bool suppress focus_pool -= chance_to_drop / 100; // Apex Predators don't think about much other than killing. // They don't lose Focus when practicing combat skills. - if( ( rng( 1, 100 ) <= ( chance_to_drop % 100 ) ) && ( !( has_trait_flag( "PRED4" ) && + if( ( rng( 1, 100 ) <= ( chance_to_drop % 100 ) ) && ( !( has_trait_flag( trait_flag_str_id( "PRED4" ) ) && skill.is_combat_skill() ) ) ) { focus_pool--; } @@ -3599,17 +3599,14 @@ void Character::apply_skill_boost() void Character::do_skill_rust() { const int rust_rate_tmp = rust_rate(); - static const std::string PRED2( "PRED2" ); - static const std::string PRED3( "PRED3" ); - static const std::string PRED4( "PRED4" ); for( std::pair &pair : *_skills ) { const Skill &aSkill = *pair.first; SkillLevel &skill_level_obj = pair.second; if( aSkill.is_combat_skill() && - ( ( has_trait_flag( PRED2 ) && calendar::once_every( 8_hours ) ) || - ( has_trait_flag( PRED3 ) && calendar::once_every( 4_hours ) ) || - ( has_trait_flag( PRED4 ) && calendar::once_every( 3_hours ) ) ) ) { + ( ( has_trait_flag( trait_flag_str_id( "PRED2" ) ) && calendar::once_every( 8_hours ) ) || + ( has_trait_flag( trait_flag_str_id( "PRED3" ) ) && calendar::once_every( 4_hours ) ) || + ( has_trait_flag( trait_flag_str_id( "PRED4" ) ) && calendar::once_every( 3_hours ) ) ) ) { // Their brain is optimized to remember this if( one_in( 13 ) ) { // They've already passed the roll to avoid rust at @@ -4437,7 +4434,7 @@ std::pair Character::get_fatigue_description() const void Character::mod_thirst( int nthirst ) { - if( has_trait_flag( "NO_THIRST" ) ) { + if( has_trait_flag( trait_flag_str_id( "NO_THIRST" ) ) ) { return; } set_thirst( std::max( -100, thirst + nthirst ) ); @@ -7077,7 +7074,7 @@ void Character::set_rad( int new_rad ) void Character::mod_rad( int mod ) { - if( has_trait_flag( "NO_RADIATION" ) ) { + if( has_trait_flag( trait_flag_str_id( "NO_RADIATION" ) ) ) { return; } set_rad( std::max( 0, get_rad() + mod ) ); diff --git a/src/character.h b/src/character.h index c3ff9d3f7ebf..d48b461d6cab 100644 --- a/src/character.h +++ b/src/character.h @@ -703,7 +703,7 @@ class Character : public Creature, public visitable /** Returns true if the player has the entered starting trait */ bool has_base_trait( const trait_id &b ) const; /** Returns true if player has a trait with a flag */ - bool has_trait_flag( const std::string &b ) const; + bool has_trait_flag( const trait_flag_id &b ) const; /** Returns true if character has a trait which cancels the entered trait. */ bool has_opposite_trait( const trait_id &flag ) const; diff --git a/src/consumption.cpp b/src/consumption.cpp index 344bdcda4f13..979e3ea7bb50 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -755,7 +755,7 @@ ret_val Character::will_eat( const item &food, bool interactive ) } const bool carnivore = has_trait( trait_CARNIVORE ); - if( food.has_flag( flag_CANNIBALISM ) && !has_trait_flag( "CANNIBAL" ) ) { + if( food.has_flag( flag_CANNIBALISM ) && !has_trait_flag( trait_flag_str_id( "CANNIBAL" ) ) ) { add_consequence( _( "The thought of eating human flesh makes you feel sick." ), edible_rating::cannibalism ); } diff --git a/src/item.cpp b/src/item.cpp index 10f9c46324d1..a6e0f5dd46b8 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -156,7 +156,7 @@ static const quality_id qual_JACK( "JACK" ); static const quality_id qual_LIFT( "LIFT" ); static const species_id ROBOT( "ROBOT" ); -static const std::string trait_flag_CANNIBAL( "CANNIBAL" ); +static const trait_flag_str_id trait_flag_CANNIBAL( "CANNIBAL" ); static const bionic_id bio_digestion( "bio_digestion" ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index feba98829f30..4b2cde781009 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -2050,9 +2050,9 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const int tolerance_level = 9; if( p.has_trait( trait_PSYCHOPATH ) || p.has_trait( trait_SAPIOVORE ) ) { tolerance_level = 0; - } else if( p.has_trait_flag( "PRED4" ) ) { + } else if( p.has_trait_flag( trait_flag_str_id( "PRED4" ) ) ) { tolerance_level = 5; - } else if( p.has_trait_flag( "PRED3" ) ) { + } else if( p.has_trait_flag( trait_flag_str_id( "PRED3" ) ) ) { tolerance_level = 7; } @@ -2096,9 +2096,9 @@ int enzlave_actor::use( player &p, item &it, bool t, const tripoint & ) const if( p.has_trait( trait_PACIFIST ) ) { moraleMalus *= 5; maxMalus *= 3; - } else if( p.has_trait_flag( "PRED1" ) ) { + } else if( p.has_trait_flag( trait_flag_str_id( "PRED1" ) ) ) { moraleMalus /= 4; - } else if( p.has_trait_flag( "PRED2" ) ) { + } else if( p.has_trait_flag( trait_flag_str_id( "PRED2" ) ) ) { moraleMalus /= 5; } diff --git a/src/magic.cpp b/src/magic.cpp index 7815169c505f..df38dfec12ae 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -758,13 +758,13 @@ float spell::spell_fail( const Character &guy ) const return 1.0f; } float fail_chance = std::pow( ( effective_skill - 30.0f ) / 30.0f, 2 ); - if( has_flag( spell_flag::SOMATIC ) && !guy.has_trait_flag( "SUBTLE_SPELL" ) ) { + if( has_flag( spell_flag::SOMATIC ) && !guy.has_trait_flag( trait_flag_str_id( "SUBTLE_SPELL" ) ) ) { // the first 20 points of encumbrance combined is ignored const int arms_encumb = std::max( 0, guy.encumb( bp_arm_l ) + guy.encumb( bp_arm_r ) - 20 ); // each encumbrance point beyond the "gray" color counts as half an additional fail % fail_chance += arms_encumb / 200.0f; } - if( has_flag( spell_flag::VERBAL ) && !guy.has_trait_flag( "SILENT_SPELL" ) ) { + if( has_flag( spell_flag::VERBAL ) && !guy.has_trait_flag( trait_flag_str_id( "SILENT_SPELL" ) ) ) { // a little bit of mouth encumbrance is allowed, but not much const int mouth_encumb = std::max( 0, guy.encumb( bp_mouth ) - 5 ); fail_chance += mouth_encumb / 100.0f; diff --git a/src/mondeath.cpp b/src/mondeath.cpp index 4b4ebc740618..68b63d44a691 100644 --- a/src/mondeath.cpp +++ b/src/mondeath.cpp @@ -438,8 +438,8 @@ void mdeath::guilt( monster &z ) guilt_tresholds[50] = _( "You regret killing %s." ); guilt_tresholds[25] = _( "You feel remorse for killing %s." ); - if( g->u.has_trait( trait_PSYCHOPATH ) || g->u.has_trait_flag( "PRED3" ) || - g->u.has_trait_flag( "PRED4" ) || g->u.has_trait( trait_KILLER ) ) { + if( g->u.has_trait( trait_PSYCHOPATH ) || g->u.has_trait_flag( trait_flag_str_id( "PRED3" ) || + g->u.has_trait_flag( trait_flag_str_id( "PRED4" ) || g->u.has_trait( trait_KILLER ) ) { return; } if( rl_dist( z.pos(), g->u.pos() ) > MAX_GUILT_DISTANCE ) { @@ -458,7 +458,7 @@ void mdeath::guilt( monster &z ) "about their deaths anymore." ), z.name( maxKills ) ); } return; - } else if( ( g->u.has_trait_flag( "PRED1" ) ) || ( g->u.has_trait_flag( "PRED2" ) ) ) { + } else if( ( g->u.has_trait_flag( trait_flag_str_id( "PRED1" ) ) || ( g->u.has_trait_flag( trait_flag_str_id( "PRED2" ) ) ) { msg = ( _( "Culling the weak is distasteful, but necessary." ) ); msgtype = m_neutral; } else { @@ -481,9 +481,9 @@ void mdeath::guilt( monster &z ) moraleMalus /= 10; if( g->u.has_trait( trait_PACIFIST ) ) { moraleMalus *= 5; - } else if( g->u.has_trait_flag( "PRED1" ) ) { + } else if( g->u.has_trait_flag( trait_flag_str_id( "PRED1" ) ) { moraleMalus /= 4; - } else if( g->u.has_trait_flag( "PRED2" ) ) { + } else if( g->u.has_trait_flag( trait_flag_str_id( "PRED2" ) ) { moraleMalus /= 5; } } diff --git a/src/mutation.cpp b/src/mutation.cpp index 03a1f30198d7..38a86f0d5174 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -103,7 +103,7 @@ bool Character::has_trait( const trait_id &b ) const return my_mutations.count( b ) || enchantment_cache->get_mutations().count( b ); } -bool Character::has_trait_flag( const std::string &b ) const +bool Character::has_trait_flag( const trait_flag_id &b ) const { for( const mutation_branch *mut : cached_mutations ) { if( mut->flags.count( b ) > 0 ) {