Skip to content

Commit

Permalink
Commit what I have for now
Browse files Browse the repository at this point in the history
  • Loading branch information
chaosvolt committed Sep 11, 2023
1 parent 2bf1d30 commit 43d62f8
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
21 changes: 9 additions & 12 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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--;
}
Expand Down Expand Up @@ -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<const skill_id, SkillLevel> &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
Expand Down Expand Up @@ -4437,7 +4434,7 @@ std::pair<std::string, nc_color> 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 ) );
Expand Down Expand Up @@ -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 ) );
Expand Down
2 changes: 1 addition & 1 deletion src/character.h
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ class Character : public Creature, public visitable<Character>
/** 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;

Expand Down
2 changes: 1 addition & 1 deletion src/consumption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ ret_val<edible_rating> 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 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );

Expand Down
8 changes: 4 additions & 4 deletions src/iuse_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/mondeath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -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 {
Expand All @@ -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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/mutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down

0 comments on commit 43d62f8

Please sign in to comment.