diff --git a/src/character.cpp b/src/character.cpp index dabe9538e42fd..aee3d6fbafa4f 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -4684,6 +4684,16 @@ void Character::on_hurt( Creature *source, bool disturb /*= true*/ ) } } +bool Character::crossed_threshold() const +{ + for( const std::pair &mut : my_mutations ) { + if( mut.first->threshold ) { + return true; + } + } + return false; +} + void Character::spores() { fungal_effects fe( *g, g->m ); diff --git a/src/character.h b/src/character.h index 3eb90e7c18e2a..02e2cca3e3ef2 100644 --- a/src/character.h +++ b/src/character.h @@ -997,6 +997,10 @@ class Character : public Creature, public visitable */ void add_traits(); void add_traits( points_left &points ); + /** Returns true if the player has crossed a mutation threshold + * Player can only cross one mutation threshold. + */ + bool crossed_threshold() const; // --------------- Values --------------- std::string name; diff --git a/src/mutation.cpp b/src/mutation.cpp index a0bd2835ddb88..e44474a7505ac 100644 --- a/src/mutation.cpp +++ b/src/mutation.cpp @@ -1339,10 +1339,10 @@ mutagen_attempt mutagen_common_checks( player &p, const item &it, bool strong, return mutagen_attempt( true, 0 ); } -void test_crossing_threshold( player &p, const mutation_category_trait &m_category ) +void test_crossing_threshold( Character &guy, const mutation_category_trait &m_category ) { // Threshold-check. You only get to cross once! - if( p.crossed_threshold() ) { + if( guy.crossed_threshold() ) { return; } @@ -1355,11 +1355,11 @@ void test_crossing_threshold( player &p, const mutation_category_trait &m_catego std::string mutation_category = m_category.id; int total = 0; for( const auto &iter : mutation_category_trait::get_all() ) { - total += p.mutation_category_level[ iter.first ]; + total += guy.mutation_category_level[ iter.first ]; } // Threshold-breaching - const std::string &primary = p.get_highest_category(); - int breach_power = p.mutation_category_level[primary]; + const std::string &primary = guy.get_highest_category(); + int breach_power = guy.mutation_category_level[primary]; // Only if you were pushing for more in your primary category. // You wanted to be more like it and less human. // That said, you're required to have hit third-stage dreams first. @@ -1374,33 +1374,33 @@ void test_crossing_threshold( player &p, const mutation_category_trait &m_catego } int breacher = breach_power + booster; if( x_in_y( breacher, total ) ) { - p.add_msg_if_player( m_good, - _( "Something strains mightily for a moment... and then... you're... FREE!" ) ); - p.set_mutation( mutation_thresh ); - g->events().send( p.getID(), m_category.id ); + guy.add_msg_if_player( m_good, + _( "Something strains mightily for a moment... and then... you're... FREE!" ) ); + guy.set_mutation( mutation_thresh ); + g->events().send( guy.getID(), m_category.id ); // Manually removing Carnivore, since it tends to creep in // This is because carnivore is a prerequisite for the // predator-style post-threshold mutations. - if( mutation_category == "URSINE" && p.has_trait( trait_CARNIVORE ) ) { - p.unset_mutation( trait_CARNIVORE ); - p.add_msg_if_player( _( "Your appetite for blood fades." ) ); + if( mutation_category == "URSINE" && guy.has_trait( trait_CARNIVORE ) ) { + guy.unset_mutation( trait_CARNIVORE ); + guy.add_msg_if_player( _( "Your appetite for blood fades." ) ); } } - } else if( p.has_trait( trait_NOPAIN ) ) { + } else if( guy.has_trait( trait_NOPAIN ) ) { //~NOPAIN is a post-Threshold trait, so you shouldn't //~legitimately have it and get here! - p.add_msg_if_player( m_bad, _( "You feel extremely Bugged." ) ); + guy.add_msg_if_player( m_bad, _( "You feel extremely Bugged." ) ); } else if( breach_power > 100 ) { - p.add_msg_if_player( m_bad, _( "You stagger with a piercing headache!" ) ); - p.mod_pain_noresist( 8 ); - p.add_effect( effect_stunned, rng( 3_turns, 5_turns ) ); + guy.add_msg_if_player( m_bad, _( "You stagger with a piercing headache!" ) ); + guy.mod_pain_noresist( 8 ); + guy.add_effect( effect_stunned, rng( 3_turns, 5_turns ) ); } else if( breach_power > 80 ) { - p.add_msg_if_player( m_bad, - _( "Your head throbs with memories of your life, before all this..." ) ); - p.mod_pain_noresist( 6 ); - p.add_effect( effect_stunned, rng( 2_turns, 4_turns ) ); + guy.add_msg_if_player( m_bad, + _( "Your head throbs with memories of your life, before all this..." ) ); + guy.mod_pain_noresist( 6 ); + guy.add_effect( effect_stunned, rng( 2_turns, 4_turns ) ); } else if( breach_power > 60 ) { - p.add_msg_if_player( m_bad, _( "Images of your past life flash before you." ) ); - p.add_effect( effect_stunned, rng( 2_turns, 3_turns ) ); + guy.add_msg_if_player( m_bad, _( "Images of your past life flash before you." ) ); + guy.add_effect( effect_stunned, rng( 2_turns, 3_turns ) ); } } diff --git a/src/mutation.h b/src/mutation.h index 465fcbecfc01c..a38af7610bedc 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -469,6 +469,6 @@ struct mutagen_attempt { mutagen_attempt mutagen_common_checks( player &p, const item &it, bool strong, mutagen_technique technique ); -void test_crossing_threshold( player &p, const mutation_category_trait &m_category ); +void test_crossing_threshold( Character &guy, const mutation_category_trait &m_category ); #endif diff --git a/src/player.cpp b/src/player.cpp index 64c40c55e9f39..041d53da6c357 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -2016,16 +2016,6 @@ bool player::has_same_type_trait( const trait_id &flag ) const return false; } -bool player::crossed_threshold() const -{ - for( auto &mut : my_mutations ) { - if( mut.first->threshold ) { - return true; - } - } - return false; -} - bool player::purifiable( const trait_id &flag ) const { return flag->purifiable; diff --git a/src/player.h b/src/player.h index 1f0747a8e742f..b02251504fda3 100644 --- a/src/player.h +++ b/src/player.h @@ -296,10 +296,6 @@ class player : public Character bool has_higher_trait( const trait_id &flag ) const; /** Returns true if the player has a trait that shares a type with the entered trait */ bool has_same_type_trait( const trait_id &flag ) const; - /** Returns true if the player has crossed a mutation threshold - * Player can only cross one mutation threshold. - */ - bool crossed_threshold() const; /** Returns true if the entered trait may be purified away * Defaults to true */